提交 d1a720fb 编写于 作者: L lixiangpeng5

xts use case differentiating device modification

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