提交 08d868db 编写于 作者: B bailu1992

马达xts用例修改

Signed-off-by: Nbailu1992 <bailu27@huawei.com>
上级 a2b944fd
...@@ -50,6 +50,14 @@ describe("VibratorJsTest_misc_2", function () { ...@@ -50,6 +50,14 @@ describe("VibratorJsTest_misc_2", function () {
console.info('afterEach caled') console.info('afterEach caled')
}) })
const OPERATION_FAIL_CODE = 14600101;
const PERMISSION_ERROR_CODE = 201;
const PARAMETER_ERROR_CODE = 401;
const OPERATION_FAIL_MSG = 'Device operation failed.'
const PERMISSION_ERROR_MSG = 'Permission denied.'
const PARAMETER_ERROR_MSG = 'The parameter invalid.'
/* /*
* @tc.name:VibratorJsTest001 * @tc.name:VibratorJsTest001
* @tc.desc:Verification results of the incorrect parameters of the test interface. * @tc.desc:Verification results of the incorrect parameters of the test interface.
...@@ -277,19 +285,26 @@ describe("VibratorJsTest_misc_2", function () { ...@@ -277,19 +285,26 @@ describe("VibratorJsTest_misc_2", function () {
* @tc.number:SUB_SensorSystem_Vibrator_JsTest_0100 * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0100
*/ */
it("VibratorJsTest010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("VibratorJsTest010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
function vibrateCallback(error) { try {
if (error) { function vibrateCallback(error) {
console.info('VibratorJsTest010 stop success'); if (error) {
expect(true).assertTrue(); console.info('VibratorJsTest010 stop success');
} else { expect(true).assertTrue();
console.info('VibratorJsTest010 stop off'); } else {
expect(false).assertTrue(); console.info('VibratorJsTest010 stop off');
expect(false).assertTrue();
}
setTimeout(() => {
done();
}, 500);
} }
setTimeout(() => { vibrator.stop("", vibrateCallback);
done(); } catch (error) {
}, 500); console.info(error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
} }
vibrator.stop("", vibrateCallback);
}) })
/* /*
...@@ -403,19 +418,26 @@ describe("VibratorJsTest_misc_2", function () { ...@@ -403,19 +418,26 @@ describe("VibratorJsTest_misc_2", function () {
* @tc.number:SUB_SensorSystem_Vibrator_JsTest_0160 * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0160
*/ */
it("VibratorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("VibratorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
vibrator.stop("").then(() => { try {
console.log("VibratorJsTest016 stop error"); vibrator.stop("").then(() => {
expect(false).assertTrue(); console.log("VibratorJsTest016 stop error");
setTimeout(() => { expect(false).assertTrue();
done(); setTimeout(() => {
}, 500); done();
}, (error) => { }, 500);
expect(true).assertTrue(); }, (error) => {
console.log("VibratorJsTest016 stop success"); expect(true).assertTrue();
setTimeout(() => { console.log("VibratorJsTest016 stop success");
done(); setTimeout(() => {
}, 500); done();
}); }, 500);
});
} catch (error) {
console.info(error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
}) })
/* /*
......
...@@ -52,6 +52,14 @@ describe("VibratorJsTest_misc_3", function () { ...@@ -52,6 +52,14 @@ describe("VibratorJsTest_misc_3", function () {
vibrator.stop("time"); vibrator.stop("time");
console.info('afterEach called') console.info('afterEach called')
}) })
const OPERATION_FAIL_CODE = 14600101;
const PERMISSION_ERROR_CODE = 201;
const PARAMETER_ERROR_CODE = 401;
const OPERATION_FAIL_MSG = 'Device operation failed.'
const PERMISSION_ERROR_MSG = 'Permission denied.'
const PARAMETER_ERROR_MSG = 'The parameter invalid.'
/* /*
* @tc.name:VibratorJsTest019 * @tc.name:VibratorJsTest019
...@@ -84,21 +92,28 @@ describe("VibratorJsTest_misc_3", function () { ...@@ -84,21 +92,28 @@ describe("VibratorJsTest_misc_3", function () {
* @tc.number:SUB_SensorSystem_Vibrator_JsTest_0300 * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0300
*/ */
it("VibratorJsTest020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("VibratorJsTest020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
vibrator.vibrate({ try {
type: "", vibrator.vibrate({
duration: 1000 type: "",
}, { duration: 1000
usage: "unknown" }, {
}, (error)=>{ usage: "unknown"
if (error) { }, (error)=>{
expect(true).assertTrue(); if (error) {
} else { expect(true).assertTrue();
expect(false).assertTrue(); } else {
} expect(false).assertTrue();
setTimeout(()=>{ }
done(); setTimeout(()=>{
}, 500); done();
}); }, 500);
});
} catch (error) {
console.info(error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
}) })
/* /*
...@@ -133,22 +148,30 @@ describe("VibratorJsTest_misc_3", function () { ...@@ -133,22 +148,30 @@ describe("VibratorJsTest_misc_3", function () {
* @tc.number:SUB_SensorSystem_Vibrator_JsTest_0320 * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0320
*/ */
it("VibratorJsTest022", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("VibratorJsTest022", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
vibrator.vibrate({ try {
type: "preset", vibrator.vibrate({
effectId: "", type: "preset",
count: 3, effectId: "",
}, { count: 3,
usage: "unknown" }, {
}, (error)=>{ usage: "unknown"
if (error) { }, (error)=>{
expect(true).assertTrue(); if (error) {
} else { expect(true).assertTrue();
expect(false).assertTrue(); } else {
} expect(false).assertTrue();
setTimeout(()=>{ }
done(); setTimeout(()=>{
}, 500); done();
}); }, 500);
});
} catch (error) {
console.info(error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
}) })
/* /*
...@@ -157,22 +180,30 @@ describe("VibratorJsTest_misc_3", function () { ...@@ -157,22 +180,30 @@ describe("VibratorJsTest_misc_3", function () {
* @tc.number:SUB_SensorSystem_Vibrator_JsTest_0330 * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0330
*/ */
it("VibratorJsTest023", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("VibratorJsTest023", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
vibrator.vibrate({ try {
type: "preset", vibrator.vibrate({
effectId: "haptic.clock.timer", type: "preset",
count: 3, effectId: "haptic.clock.timer",
}, { count: 3,
usage: "" }, {
}, (error)=>{ usage: ""
if (error) { }, (error)=>{
expect(true).assertTrue(); if (error) {
} else { expect(true).assertTrue();
expect(false).assertTrue(); } else {
} expect(false).assertTrue();
setTimeout(()=>{ }
done(); setTimeout(()=>{
}, 500); done();
}); }, 500);
});
} catch (error) {
console.info(error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
}) })
/* /*
...@@ -215,17 +246,24 @@ describe("VibratorJsTest_misc_3", function () { ...@@ -215,17 +246,24 @@ describe("VibratorJsTest_misc_3", function () {
* @tc.number:SUB_SensorSystem_Vibrator_JsTest_0360 * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0360
*/ */
it("VibratorJsTest026", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("VibratorJsTest026", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
await vibrator.vibrate({ try {
type: "", await vibrator.vibrate({
duration: 1000 type: "",
}, { duration: 1000
usage: "unknown" }, {
}).then(()=>{ usage: "unknown"
expect(false).assertTrue(); }).then(()=>{
}).catch((error)=>{ expect(false).assertTrue();
expect(true).assertTrue(); }).catch((error)=>{
}); expect(true).assertTrue();
done(); });
done();
} catch (error) {
console.info(error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
}) })
/* /*
...@@ -254,19 +292,26 @@ describe("VibratorJsTest_misc_3", function () { ...@@ -254,19 +292,26 @@ describe("VibratorJsTest_misc_3", function () {
* @tc.number:SUB_SensorSystem_Vibrator_JsTest_0380 * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0380
*/ */
it("VibratorJsTest028", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("VibratorJsTest028", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
vibrator.vibrate({ try {
type: "preset", vibrator.vibrate({
effectId: "", type: "preset",
count: 3, effectId: "",
}, { count: 3,
usage: "unknown" }, {
}).then(()=>{ usage: "unknown"
expect(false).assertTrue(); }).then(()=>{
done(); expect(false).assertTrue();
}).catch((error)=>{ done();
expect(true).assertTrue(); }).catch((error)=>{
expect(true).assertTrue();
done();
});
} catch (error) {
console.info(error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done(); done();
}); }
}) })
/* /*
...@@ -275,19 +320,26 @@ describe("VibratorJsTest_misc_3", function () { ...@@ -275,19 +320,26 @@ describe("VibratorJsTest_misc_3", function () {
* @tc.number:SUB_SensorSystem_Vibrator_JsTest_0390 * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0390
*/ */
it("VibratorJsTest029", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("VibratorJsTest029", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
vibrator.vibrate({ try {
type: "preset", vibrator.vibrate({
effectId: "haptic.clock.timer", type: "preset",
count: 3, effectId: "haptic.clock.timer",
}, { count: 3,
usage: "" }, {
}).then(()=>{ usage: ""
expect(false).assertTrue(); }).then(()=>{
done(); expect(false).assertTrue();
}).catch((error)=>{ done();
expect(true).assertTrue(); }).catch((error)=>{
expect(true).assertTrue();
done();
});
} catch (error) {
console.info(error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done(); done();
}); }
}) })
/* /*
...@@ -812,22 +864,29 @@ describe("VibratorJsTest_misc_3", function () { ...@@ -812,22 +864,29 @@ describe("VibratorJsTest_misc_3", function () {
* @tc.number:SUB_SensorSystem_Vibrator_JsTest_0510 * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0510
*/ */
it("VibratorJsTest041", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("VibratorJsTest041", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
vibrator.vibrate({ try {
type: "", vibrator.vibrate({
duration: 1000 type: "",
}, { duration: 1000
id:1, }, {
usage: "unknown" id:1,
}, (error)=>{ usage: "unknown"
if (error) { }, (error)=>{
expect(true).assertTrue(); if (error) {
} else { expect(true).assertTrue();
expect(false).assertTrue(); } else {
} expect(false).assertTrue();
setTimeout(()=>{ }
done(); setTimeout(()=>{
}, 500); done();
}); }, 500);
});
} catch (error) {
console.info(error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
}) })
/* /*
...@@ -863,23 +922,31 @@ describe("VibratorJsTest_misc_3", function () { ...@@ -863,23 +922,31 @@ describe("VibratorJsTest_misc_3", function () {
* @tc.number:SUB_SensorSystem_Vibrator_JsTest_0530 * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0530
*/ */
it("VibratorJsTest043", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("VibratorJsTest043", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
vibrator.vibrate({ try {
type: "preset", vibrator.vibrate({
effectId: "", type: "preset",
count: 3, effectId: "",
}, { count: 3,
id:null, }, {
usage: "unknown" id:null,
}, (error)=>{ usage: "unknown"
if (error) { }, (error)=>{
expect(true).assertTrue(); if (error) {
} else { expect(true).assertTrue();
expect(false).assertTrue(); } else {
} expect(false).assertTrue();
setTimeout(()=>{ }
done(); setTimeout(()=>{
}, 500); done();
}); }, 500);
});
} catch (error) {
console.info(error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
}) })
}) })
} }
...@@ -50,9 +50,13 @@ describe("VibratorJsTest_misc_1", function () { ...@@ -50,9 +50,13 @@ describe("VibratorJsTest_misc_1", function () {
console.info('afterEach caled') console.info('afterEach caled')
}) })
let errMessages = ['Error: ParseParameter: "Get vibrate type fail"', 'Error: ParseParameter: "Wrong argument number"'] const OPERATION_FAIL_CODE = 14600101;
const PERMISSION_ERROR_CODE = 201;
let errMessage; const PARAMETER_ERROR_CODE = 401;
const OPERATION_FAIL_MSG = 'Device operation failed.'
const PERMISSION_ERROR_MSG = 'Permission denied.'
const PARAMETER_ERROR_MSG = 'The parameter invalid.'
/* /*
* @tc.name:SubVibratorJsTest0001 * @tc.name:SubVibratorJsTest0001
...@@ -193,9 +197,9 @@ describe("VibratorJsTest_misc_1", function () { ...@@ -193,9 +197,9 @@ describe("VibratorJsTest_misc_1", function () {
}, },
}, 25); }, 25);
} catch (error) { } catch (error) {
errMessage = error.toString();
console.info('SubVibratorJsTest0007 error:' + error); console.info('SubVibratorJsTest0007 error:' + error);
expect(errMessage).assertEqual(errMessages[0]); expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done(); done();
} }
}) })
...@@ -242,9 +246,9 @@ describe("VibratorJsTest_misc_1", function () { ...@@ -242,9 +246,9 @@ describe("VibratorJsTest_misc_1", function () {
try { try {
vibrator.vibrate(); vibrator.vibrate();
} catch (error) { } catch (error) {
errMessage = error.toString();
console.info('SubVibratorJsTest0009 error:' + error); console.info('SubVibratorJsTest0009 error:' + error);
expect(errMessage).assertEqual(errMessages[1]); expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done(); done();
} }
}) })
...@@ -267,9 +271,9 @@ describe("VibratorJsTest_misc_1", function () { ...@@ -267,9 +271,9 @@ describe("VibratorJsTest_misc_1", function () {
}, function () { }, function () {
}, 25); }, 25);
} catch (error) { } catch (error) {
errMessage = error.toString();
console.info('SubVibratorJsTest0010 error:' + error); console.info('SubVibratorJsTest0010 error:' + error);
expect(errMessage).assertEqual(errMessages[0]); expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done(); done();
} }
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册