提交 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,6 +285,7 @@ describe("VibratorJsTest_misc_2", function () { ...@@ -277,6 +285,7 @@ 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) {
try {
function vibrateCallback(error) { function vibrateCallback(error) {
if (error) { if (error) {
console.info('VibratorJsTest010 stop success'); console.info('VibratorJsTest010 stop success');
...@@ -290,6 +299,12 @@ describe("VibratorJsTest_misc_2", function () { ...@@ -290,6 +299,12 @@ describe("VibratorJsTest_misc_2", function () {
}, 500); }, 500);
} }
vibrator.stop("", vibrateCallback); vibrator.stop("", vibrateCallback);
} catch (error) {
console.info(error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
}) })
/* /*
...@@ -403,6 +418,7 @@ describe("VibratorJsTest_misc_2", function () { ...@@ -403,6 +418,7 @@ 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) {
try {
vibrator.stop("").then(() => { vibrator.stop("").then(() => {
console.log("VibratorJsTest016 stop error"); console.log("VibratorJsTest016 stop error");
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -416,6 +432,12 @@ describe("VibratorJsTest_misc_2", function () { ...@@ -416,6 +432,12 @@ describe("VibratorJsTest_misc_2", function () {
done(); done();
}, 500); }, 500);
}); });
} catch (error) {
console.info(error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
}) })
/* /*
......
...@@ -53,6 +53,14 @@ describe("VibratorJsTest_misc_3", function () { ...@@ -53,6 +53,14 @@ describe("VibratorJsTest_misc_3", function () {
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
* @tc.desc:Verification results of the incorrect parameters of the test interface. * @tc.desc:Verification results of the incorrect parameters of the test interface.
...@@ -84,6 +92,7 @@ describe("VibratorJsTest_misc_3", function () { ...@@ -84,6 +92,7 @@ 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) {
try {
vibrator.vibrate({ vibrator.vibrate({
type: "", type: "",
duration: 1000 duration: 1000
...@@ -99,6 +108,12 @@ describe("VibratorJsTest_misc_3", function () { ...@@ -99,6 +108,12 @@ describe("VibratorJsTest_misc_3", function () {
done(); done();
}, 500); }, 500);
}); });
} catch (error) {
console.info(error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
}) })
/* /*
...@@ -133,6 +148,7 @@ describe("VibratorJsTest_misc_3", function () { ...@@ -133,6 +148,7 @@ 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) {
try {
vibrator.vibrate({ vibrator.vibrate({
type: "preset", type: "preset",
effectId: "", effectId: "",
...@@ -149,6 +165,13 @@ describe("VibratorJsTest_misc_3", function () { ...@@ -149,6 +165,13 @@ describe("VibratorJsTest_misc_3", function () {
done(); done();
}, 500); }, 500);
}); });
} catch (error) {
console.info(error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
}) })
/* /*
...@@ -157,6 +180,7 @@ describe("VibratorJsTest_misc_3", function () { ...@@ -157,6 +180,7 @@ 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) {
try {
vibrator.vibrate({ vibrator.vibrate({
type: "preset", type: "preset",
effectId: "haptic.clock.timer", effectId: "haptic.clock.timer",
...@@ -173,6 +197,13 @@ describe("VibratorJsTest_misc_3", function () { ...@@ -173,6 +197,13 @@ describe("VibratorJsTest_misc_3", function () {
done(); done();
}, 500); }, 500);
}); });
} catch (error) {
console.info(error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
}) })
/* /*
...@@ -215,6 +246,7 @@ describe("VibratorJsTest_misc_3", function () { ...@@ -215,6 +246,7 @@ 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) {
try {
await vibrator.vibrate({ await vibrator.vibrate({
type: "", type: "",
duration: 1000 duration: 1000
...@@ -226,6 +258,12 @@ describe("VibratorJsTest_misc_3", function () { ...@@ -226,6 +258,12 @@ describe("VibratorJsTest_misc_3", function () {
expect(true).assertTrue(); 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,6 +292,7 @@ describe("VibratorJsTest_misc_3", function () { ...@@ -254,6 +292,7 @@ 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) {
try {
vibrator.vibrate({ vibrator.vibrate({
type: "preset", type: "preset",
effectId: "", effectId: "",
...@@ -267,6 +306,12 @@ describe("VibratorJsTest_misc_3", function () { ...@@ -267,6 +306,12 @@ describe("VibratorJsTest_misc_3", function () {
expect(true).assertTrue(); 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();
}
}) })
/* /*
...@@ -275,6 +320,7 @@ describe("VibratorJsTest_misc_3", function () { ...@@ -275,6 +320,7 @@ 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) {
try {
vibrator.vibrate({ vibrator.vibrate({
type: "preset", type: "preset",
effectId: "haptic.clock.timer", effectId: "haptic.clock.timer",
...@@ -288,6 +334,12 @@ describe("VibratorJsTest_misc_3", function () { ...@@ -288,6 +334,12 @@ describe("VibratorJsTest_misc_3", function () {
expect(true).assertTrue(); 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();
}
}) })
/* /*
...@@ -812,6 +864,7 @@ describe("VibratorJsTest_misc_3", function () { ...@@ -812,6 +864,7 @@ 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) {
try {
vibrator.vibrate({ vibrator.vibrate({
type: "", type: "",
duration: 1000 duration: 1000
...@@ -828,6 +881,12 @@ describe("VibratorJsTest_misc_3", function () { ...@@ -828,6 +881,12 @@ describe("VibratorJsTest_misc_3", function () {
done(); done();
}, 500); }, 500);
}); });
} catch (error) {
console.info(error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
}) })
/* /*
...@@ -863,6 +922,7 @@ describe("VibratorJsTest_misc_3", function () { ...@@ -863,6 +922,7 @@ 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) {
try {
vibrator.vibrate({ vibrator.vibrate({
type: "preset", type: "preset",
effectId: "", effectId: "",
...@@ -880,6 +940,13 @@ describe("VibratorJsTest_misc_3", function () { ...@@ -880,6 +940,13 @@ describe("VibratorJsTest_misc_3", function () {
done(); done();
}, 500); }, 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;
const PARAMETER_ERROR_CODE = 401;
let errMessage; 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.
先完成此消息的编辑!
想要评论请 注册