提交 d1a720fb 编写于 作者: L lixiangpeng5

xts use case differentiating device modification

Signed-off-by: Nlixiangpeng5 <lixiangpeng5@huawei.com>
Change-Id: I36d72a16e2c9cefeb08e214d61adbc7cfca648ac
上级 471b0ca5
...@@ -13,17 +13,22 @@ ...@@ -13,17 +13,22 @@
* limitations under the License. * limitations under the License.
*/ */
import vibrator from '@ohos.vibrator' import vibrator from '@ohos.vibrator'
import deviceInfo from '@ohos.deviceInfo'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium'
export default function VibratorJsTest_misc_2() { export default function VibratorJsTest_misc_2() {
describe("VibratorJsTest_misc_2", function () { describe("VibratorJsTest_misc_2", function () {
var g_execute = true;
beforeAll(function () { beforeAll(function () {
/* /*
* @tc.setup: setup invoked before all testcases * @tc.setup: setup invoked before all testcases
*/ */
console.info('beforeAll caled') console.info('beforeAll called')
if (deviceInfo.deviceType == "tablet") {
g_execute = false;
}
}) })
afterAll(function () { afterAll(function () {
...@@ -31,7 +36,7 @@ describe("VibratorJsTest_misc_2", function () { ...@@ -31,7 +36,7 @@ describe("VibratorJsTest_misc_2", function () {
/* /*
* @tc.teardown: teardown invoked after all testcases * @tc.teardown: teardown invoked after all testcases
*/ */
console.info('afterAll caled') console.info('afterAll called')
}) })
beforeEach(function () { beforeEach(function () {
...@@ -39,7 +44,7 @@ describe("VibratorJsTest_misc_2", function () { ...@@ -39,7 +44,7 @@ describe("VibratorJsTest_misc_2", function () {
/* /*
* @tc.setup: setup invoked before each testcases * @tc.setup: setup invoked before each testcases
*/ */
console.info('beforeEach caled') console.info('beforeEach called')
}) })
afterEach(function () { afterEach(function () {
...@@ -47,14 +52,14 @@ describe("VibratorJsTest_misc_2", function () { ...@@ -47,14 +52,14 @@ describe("VibratorJsTest_misc_2", function () {
/* /*
* @tc.teardown: teardown invoked after each testcases * @tc.teardown: teardown invoked after each testcases
*/ */
console.info('afterEach caled') console.info('afterEach called')
}) })
const OPERATION_FAIL_CODE = 14600101; const DEVICE_OPERATION_FAILED = 14600101;
const PERMISSION_ERROR_CODE = 201; const PERMISSION_ERROR_CODE = 201;
const PARAMETER_ERROR_CODE = 401; const PARAMETER_ERROR_CODE = 401;
const OPERATION_FAIL_MSG = 'Device operation failed.' const DEVICE_OPERATION_MSG = 'Device operation failed.'
const PERMISSION_ERROR_MSG = 'Permission denied.' const PERMISSION_ERROR_MSG = 'Permission denied.'
const PARAMETER_ERROR_MSG = 'The parameter invalid.' const PARAMETER_ERROR_MSG = 'The parameter invalid.'
...@@ -190,19 +195,25 @@ describe("VibratorJsTest_misc_2", function () { ...@@ -190,19 +195,25 @@ describe("VibratorJsTest_misc_2", function () {
* @tc.number:SUB_SensorSystem_Vibrator_JsTest_0070 * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0070
*/ */
it("VibratorJsTest007", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("VibratorJsTest007", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
function vibrateCallback(error) { if (g_execute) {
if (error) { function vibrateCallback(error) {
console.info('VibratorJsTest007 vibrator error'); if (error) {
expect(false).assertTrue(); console.info('VibratorJsTest007 vibrator error');
} else { expect(false).assertTrue();
console.info('VibratorJsTest007 vibrator success'); } else {
expect(true).assertTrue(); console.info('VibratorJsTest007 vibrator success');
expect(true).assertTrue();
}
setTimeout(() => {
done();
}, 500);
} }
setTimeout(() => { vibrator.vibrate("haptic.clock.timer", vibrateCallback);
done(); } else {
}, 500); console.info('VibratorJsTest007 is not supported on this device');
expect(true).assertTrue();
done();
} }
vibrator.vibrate("haptic.clock.timer", vibrateCallback);
}) })
/* /*
...@@ -211,19 +222,25 @@ describe("VibratorJsTest_misc_2", function () { ...@@ -211,19 +222,25 @@ describe("VibratorJsTest_misc_2", function () {
* @tc.number:SUB_SensorSystem_Vibrator_JsTest_0080 * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0080
*/ */
it("VibratorJsTest008", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("VibratorJsTest008", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
function vibrateCallback(error) { if (g_execute) {
if (error) { function vibrateCallback(error) {
console.info('VibratorJsTest008 stop error'); if (error) {
expect(false).assertTrue(); console.info('VibratorJsTest008 stop error');
} else { expect(false).assertTrue();
console.info('VibratorJsTest008 stop success'); } else {
expect(true).assertTrue(); console.info('VibratorJsTest008 stop success');
expect(true).assertTrue();
}
setTimeout(() => {
done();
}, 500);
} }
setTimeout(() => { vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET, vibrateCallback);
done(); } else {
}, 500); console.info('VibratorJsTest008 is not supported on this device');
expect(true).assertTrue();
done();
} }
vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET, vibrateCallback);
}) })
/* /*
...@@ -232,7 +249,6 @@ describe("VibratorJsTest_misc_2", function () { ...@@ -232,7 +249,6 @@ describe("VibratorJsTest_misc_2", function () {
* @tc.number:SUB_SensorSystem_Vibrator_JsTest_0090 * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0090
*/ */
it("VibratorJsTest009", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("VibratorJsTest009", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------VibratorJsTest001---------------------------');
function stopPromise() { function stopPromise() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
vibrator.stop("time", (error) => { vibrator.stop("time", (error) => {
...@@ -376,19 +392,25 @@ describe("VibratorJsTest_misc_2", function () { ...@@ -376,19 +392,25 @@ describe("VibratorJsTest_misc_2", function () {
* @tc.number:SUB_SensorSystem_Vibrator_JsTest_0140 * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0140
*/ */
it("VibratorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("VibratorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER).then(() => { if (g_execute) {
console.log("VibratorJsTest014 vibrate success"); vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER).then(() => {
console.log("VibratorJsTest014 vibrate success");
expect(true).assertTrue();
setTimeout(() => {
done();
}, 500);
}, (error) => {
expect(false).assertTrue();
console.log("VibratorJsTest014 vibrate error");
setTimeout(() => {
done();
}, 500);
});
} else {
console.info('VibratorJsTest014 is not supported on this device');
expect(true).assertTrue(); expect(true).assertTrue();
setTimeout(() => { done();
done(); }
}, 500);
}, (error) => {
expect(false).assertTrue();
console.log("VibratorJsTest014 vibrate error");
setTimeout(() => {
done();
}, 500);
});
}) })
/* /*
...@@ -397,19 +419,25 @@ describe("VibratorJsTest_misc_2", function () { ...@@ -397,19 +419,25 @@ describe("VibratorJsTest_misc_2", function () {
* @tc.number:SUB_SensorSystem_Vibrator_JsTest_0150 * @tc.number:SUB_SensorSystem_Vibrator_JsTest_0150
*/ */
it("VibratorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("VibratorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
vibrator.stop("preset").then(() => { if (g_execute) {
console.log("VibratorJsTest015 off success"); vibrator.stop("preset").then(() => {
console.log("VibratorJsTest015 off success");
expect(true).assertTrue();
setTimeout(() => {
done();
}, 500);
}, (error) => {
expect(false).assertTrue();
console.log("VibratorJsTest015 off error");
setTimeout(() => {
done();
}, 500);
});
} else {
console.info('VibratorJsTest015 is not supported on this device');
expect(true).assertTrue(); expect(true).assertTrue();
setTimeout(() => { done();
done(); }
}, 500);
}, (error) => {
expect(false).assertTrue();
console.log("VibratorJsTest015 off error");
setTimeout(() => {
done();
}, 500);
});
}) })
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册