未验证 提交 d742b000 编写于 作者: O openharmony_ci 提交者: Gitee

!7911 【Openharmony4.0.5.2】【master分支】【sensor子系统】【ToC】【RK3568】【必现】增加xts用例

Merge pull request !7911 from ldy/master
......@@ -13,7 +13,7 @@
import("//build/ohos_var.gni")
group("sensor") {
group("sensors") {
testonly = true
if (is_standard_system) {
deps = [
......
......@@ -15,8 +15,10 @@
import VibratorJsTest_misc_1 from './Vibrator_old.test.js'
import VibratorJsTest_misc_2 from './Vibrator_new_common.test.js'
import VibratorJsTest_misc_3 from './Vibrator_newSupplement_common.test.js'
import VibratorJsTest_misc_6 from './Vibrator_newSupportTest.js'
export default function testsuite() {
VibratorJsTest_misc_1()
VibratorJsTest_misc_2()
VibratorJsTest_misc_3()
VibratorJsTest_misc_6()
}
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import vibrator from '@ohos.vibrator'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium'
export default function VibratorJsTest_misc_6() {
describe("VibratorJsTest_misc_6", function () {
var g_execute = true;
let EFFECT_ID = "haptic.clock.timer";
let INVALID_EFFECT_ID = "xxx";
beforeAll(function () {
/*
* @tc.setup: setup invoked before all testcases
*/
console.info('beforeAll caled')
})
afterAll(function () {
/*
* @tc.teardown: teardown invoked after all testcases
*/
console.info('afterAll caled')
})
beforeEach(function () {
/*
* @tc.setup: setup invoked before each testcases
*/
console.info('beforeEach caled')
})
afterEach(function () {
/*
* @tc.teardown: teardown invoked after each testcases
*/
console.info('afterEach caled')
vibrator.stop("preset");
vibrator.stop("time");
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:VibratorJsTest069
* @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.number:SUB_SensorSystem_Vibrator_JsTest_0790
*/
it("VibratorJsTest069", 0, async function (done) {
vibrator.isSupportEffect(INVALID_EFFECT_ID, (error, state) => {
if (error) {
console.info('VibratorJsTest069 error');
expect(false).assertTrue();
} else {
console.info('VibratorJsTest069 success');
expect(!state).assertTrue();
done();
}
});
})
/*
* @tc.name:VibratorJsTest070
* @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.number:SUB_SensorSystem_Vibrator_JsTest_0800
*/
it("VibratorJsTest070", 0, async function (done) {
let isSupport = false;
function vibratePromise() {
return new Promise((resolve, reject) => {
if (isSupport) {
vibrator.startVibration({
type: "preset",
effectId: EFFECT_ID,
count: 1,
}, {
usage: "unknown"
}, (error)=>{
if (error) {
expect(false).assertTrue();
reject(error);
} else {
expect(true).assertTrue();
resolve();
}
});
} else {
resolve();
}
})
}
function stopPromise() {
return new Promise((resolve, reject) => {
if (isSupport) {
vibrator.stopVibration((error) => {
if (error) {
expect(false).assertTrue();
reject(error);
} else {
expect(true).assertTrue();
resolve();
}
});
} else {
resolve();
}
})
}
let isSupportPromise = new Promise((resolve, reject) => {
vibrator.isSupportEffect(EFFECT_ID, (error, state) => {
if (error) {
expect(false).assertTrue();
reject(error);
} else {
expect(true).assertTrue();
isSupport = state;
resolve();
}
});
})
await isSupportPromise.then(() =>{
return vibratePromise();
}).then(() =>{
return stopPromise();
}).catch((error)=>{
expect(false).assertTrue();
})
done();
})
/*
* @tc.name:VibratorJsTest071
* @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.number:SUB_SensorSystem_Vibrator_JsTest_0810
*/
it("VibratorJsTest071", 0, async function (done) {
try {
vibrator.isSupportEffect(123, (error, state) => {
console.info("VibratorJsTest071 should not in this method");
expect(false).assertTrue();
done();
});
} catch (error) {
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.name:VibratorJsTest072
* @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.number:SUB_SensorSystem_Vibrator_JsTest_0820
*/
it("VibratorJsTest072", 0, async function (done) {
try {
vibrator.isSupportEffect();
} catch (error) {
console.info("VibratorJsTest072 error in :" + error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.name:VibratorJsTest073
* @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.number:SUB_SensorSystem_Vibrator_JsTest_0830
*/
it("VibratorJsTest073", 0, async function (done) {
await vibrator.isSupportEffect(INVALID_EFFECT_ID).then((state) => {
expect(!state).assertTrue();
}, (error) => {
expect(false).assertTrue();
});
done();
})
/*
* @tc.name:VibratorJsTest073
* @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.number:SUB_SensorSystem_Vibrator_JsTest_0830
*/
it("VibratorJsTest073", 0, async function (done) {
let isSupport = false;
function vibratePromise() {
return new Promise((resolve, reject) => {
if (isSupport) {
vibrator.startVibration({
type: "preset",
effectId: EFFECT_ID,
count: 1,
}, {
usage: "unknown"
}, (error)=>{
if (error) {
expect(false).assertTrue();
reject(error);
} else {
expect(true).assertTrue();
resolve();
}
});
} else {
resolve();
}
})
}
function stopPromise() {
return new Promise((resolve, reject) => {
if (isSupport) {
vibrator.stopVibration((error) => {
if (error) {
expect(false).assertTrue();
reject(error);
} else {
expect(true).assertTrue();
resolve();
}
});
} else {
resolve();
}
})
}
let isSupportPromise = new Promise((resolve, reject) => {
vibrator.isSupportEffect(EFFECT_ID).then((state) => {
expect(true).assertTrue();
isSupport = state;
resolve();
}, (error) => {
expect(false).assertTrue();
reject(error);
});
})
await isSupportPromise.then(() =>{
return vibratePromise();
}).then(() =>{
return stopPromise();
}).catch((error)=>{
expect(false).assertTrue();
})
done();
})
/*
* @tc.name:VibratorJsTest074
* @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.number:SUB_SensorSystem_Vibrator_JsTest_0840
*/
it("VibratorJsTest074", 0, async function (done) {
try {
vibrator.isSupportEffect(123).then((state) => {
expect(false).assertTrue();
done();
}, (error) => {
expect(false).assertTrue();
done();
});
} catch (error) {
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.name:VibratorJsTest075
* @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.number:SUB_SensorSystem_Vibrator_JsTest_0850
*/
it("VibratorJsTest075", 0, async function (done) {
try {
vibrator.isSupportEffect().then((state) => {
expect(false).assertTrue();
}, (error) => {
expect(true).assertTrue();
done()
});
} catch (error) {
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
})}
......@@ -16,18 +16,61 @@ import SystemParameterTest from './SensorOnOffTest.test.js'
import SensorJsTest_sensor_2 from './SensorGeomagneticTest.test.js'
import SensorJsTest_sensor_1 from './SensorGeneralalgorithm.test.js'
import SensorJsTest_sensor_60 from './SensorOnOffTest.test_newSensorGeomagnetic.js'
import SensorJsTest_sensor_35 from './SensorOnOffTest.test_newGetSensorList.js'
import SensorJsTest_sensor_36 from './SensorOnOffTest.test_newGetSingleSensor.js'
import SensorJsTest_sensor_3 from './SensorOnOffTest.test_oldAccelerometer.js'
import SensorJsTest_sensor_25 from './Subscribe_subscribeAccelerometer.js'
import SensorJsTest_sensor_39 from './SensorOnOffTest.test_newAccelerometer.js'
import SensorJsTest_sensor_43 from './SensorOnOffTest.test_newGyroScope.js'
import SensorJsTest_sensor_5 from './SensorOnOffTest.test_oldGyroScope.js'
import SensorJsTest_sensor_29 from './Subscribe_subscribeGyroscope.js'
import SensorJsTest_sensor_41 from './SensorOnOffTest.test_newAmbient_Light.js'
import SensorJsTest_sensor_4 from './SensorOnOffTest.test_oldAmbient_light.js'
import SensorJsTest_sensor_31 from './Subscribe_subscribeLight.js'
import SensorJsTest_sensor_42 from './SensorOnOffTest.test_newGravity.js'
import SensorJsTest_sensor_9 from './SensorOnOffTest.test_oldGravity.js'
import SensorJsTest_sensor_37 from './SensorOnOffTest.test_newMagneticField.js'
import SensorJsTest_sensor_15 from './SensorOnOffTest.test_oldMagneticField.js'
import SensorJsTest_sensor_49 from './SensorOnOffTest.test_newRotatingVector.js'
import SensorJsTest_sensor_20 from './SensorOnOffTest.test_oldRotatingVector.js'
import SensorJsTest_sensor_45 from './SensorOnOffTest.test_newHall.js'
import SensorJsTest_sensor_7 from './SensorOnOffTest.test_oldHall.js'
import SensorJsTest_sensor_48 from './SensorOnOffTest.test_newOrientating.js'
import SensorJsTest_sensor_16 from './SensorOnOffTest.test_oldOrientating.js'
import SensorJsTest_sensor_27 from './Subscribe_subscribeDeviceOrientation.js'
import SensorJsTest_sensor_53 from './SensorOnOffTest.test_newBarometer.js'
import SensorJsTest_sensor_8 from './SensorOnOffTest.test_oldBarometer.js'
import SensorJsTest_sensor_26 from './Subscribe_subscribeBarometer.js'
export default function testsuite() {
SensorJsTest_sensor_1()
SensorJsTest_sensor_2()
SensorJsTest_sensor_60()
SystemParameterTest()
SensorJsTest_sensor_3()
SensorJsTest_sensor_25()
SensorJsTest_sensor_39()
SensorJsTest_sensor_43()
}
SystemParameterTest()
SensorJsTest_sensor_2()
SensorJsTest_sensor_1()
SensorJsTest_sensor_60()
SensorJsTest_sensor_35()
SensorJsTest_sensor_36()
SensorJsTest_sensor_3()
SensorJsTest_sensor_25()
SensorJsTest_sensor_39()
SensorJsTest_sensor_43()
SensorJsTest_sensor_5()
SensorJsTest_sensor_29()
SensorJsTest_sensor_41()
SensorJsTest_sensor_4()
SensorJsTest_sensor_31()
SensorJsTest_sensor_42()
SensorJsTest_sensor_9()
SensorJsTest_sensor_37()
SensorJsTest_sensor_15()
SensorJsTest_sensor_49()
SensorJsTest_sensor_20()
SensorJsTest_sensor_45()
SensorJsTest_sensor_7()
SensorJsTest_sensor_48()
SensorJsTest_sensor_16()
SensorJsTest_sensor_27()
SensorJsTest_sensor_53()
SensorJsTest_sensor_8()
SensorJsTest_sensor_26()
}
......@@ -92,7 +92,7 @@ describe("SensorJsTest_sensor_43", function () {
}
})
} catch (error) {
console.info('newGyroScope_SensorJsTest014 Device does not support');
console.info('newGyroScope_SensorJsTest014 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -143,7 +143,7 @@ describe("SensorJsTest_sensor_43", function () {
}
})
} catch (error) {
console.info('newGyroScope_SensorJsTest016 Device does not support');
console.info('newGyroScope_SensorJsTest016 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -180,7 +180,7 @@ describe("SensorJsTest_sensor_43", function () {
}
})
} catch (error) {
console.info("newGyroScope_SensorJsTest017 Device does not support");
console.info("newGyroScope_SensorJsTest017 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -207,7 +207,7 @@ describe("SensorJsTest_sensor_43", function () {
}
})
} catch (error) {
console.info("newGyroScope_SensorJsTest018 Device does not support");
console.info("newGyroScope_SensorJsTest018 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -275,7 +275,7 @@ describe("SensorJsTest_sensor_43", function () {
try {
sensor.off(invalid, callback);
} catch (error) {
console.info('newGyroScope_SensorJsTest021 Device does not support');
console.info('newGyroScope_SensorJsTest021 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE)
expect(error.message).assertEqual(PARAMETER_ERROR_MSG)
done();
......@@ -370,7 +370,7 @@ describe("SensorJsTest_sensor_43", function () {
}
})
} catch (error) {
console.info("newGyroScope_SensorJsTest024 Device does not support");
console.info("newGyroScope_SensorJsTest024 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -386,7 +386,7 @@ describe("SensorJsTest_sensor_43", function () {
try {
sensor.off(sensor.SensorId.GYROSCOPE, 5);
} catch (error) {
console.info('newGyroScope_SensorJsTest025 Device does not support');
console.info('newGyroScope_SensorJsTest025 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE)
expect(error.message).assertEqual(PARAMETER_ERROR_MSG)
done();
......@@ -429,7 +429,7 @@ describe("SensorJsTest_sensor_43", function () {
}
})
} catch (error) {
console.info("newGyroScope_SensorJsTest026 Device does not support");
console.info("newGyroScope_SensorJsTest026 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -472,7 +472,7 @@ describe("SensorJsTest_sensor_43", function () {
}
})
} catch (error) {
console.info("newGyroScope_SensorJsTest027 Device does not support");
console.info("newGyroScope_SensorJsTest027 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -545,7 +545,7 @@ describe("SensorJsTest_sensor_43", function () {
}
})
} catch (error) {
console.info("newGyroScope_SensorJsTest029 Device does not support");
console.info("newGyroScope_SensorJsTest029 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -586,7 +586,7 @@ describe("SensorJsTest_sensor_43", function () {
}
})
} catch (error) {
console.info("newGyroScope_SensorJsTest030 Device does not support");
console.info("newGyroScope_SensorJsTest030 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -619,7 +619,7 @@ describe("SensorJsTest_sensor_43", function () {
}
})
} catch (error) {
console.info("newGyroScope_SensorJsTest031 Device does not support");
console.info("newGyroScope_SensorJsTest031 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -653,7 +653,7 @@ describe("SensorJsTest_sensor_43", function () {
}
})
} catch (error) {
console.info("newGyroScope_SensorJsTest032 Device does not support");
console.info("newGyroScope_SensorJsTest032 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......
......@@ -205,9 +205,12 @@ describe("SensorJsTest_sensor_25", function () {
expect(typeof (data.x)).assertEqual("number");
expect(typeof (data.y)).assertEqual("number");
expect(typeof (data.z)).assertEqual("number");
done();
},
});
setTimeout(() => {
sensor.unsubscribeAccelerometer();
done();
}, 1000);
})
/*
......@@ -215,21 +218,38 @@ describe("SensorJsTest_sensor_25", function () {
* @tc.name: subscribeAccelerometer_SensorJsTest007
* @tc.desc:Verification results of the incorrect parameters of the test interface.
*/
it("subscribeAccelerometer_SensorJsTest007", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
it("subscribeAccelerometer_SensorJsTest007", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------subscribeAccelerometer_SensorJsTest007---------------------------');
sensor.subscribeAccelerometer({
interval: 'normal',
interval: 'game',
success: function (data) {
console.info("subscribeAccelerometer_SensorJsTest007 success" + JSON.stringify(data));
expect(typeof (data.x)).assertEqual("number");
expect(typeof (data.y)).assertEqual("number");
expect(typeof (data.z)).assertEqual("number");
done();
},
fail: function (data, code) {
console.log("subscribeAccelerometer_SensorJsTest007 is failed, data: " + data + ", code: " + code);
expect(false).assertTrue();
},
});
sensor.subscribeAccelerometer({
interval: 'normal',
success: function (data) {
console.info("subscribeAccelerometer_SensorJsTest007_1 success" + JSON.stringify(data));
expect(typeof (data.x)).assertEqual("number");
expect(typeof (data.y)).assertEqual("number");
expect(typeof (data.z)).assertEqual("number");
},
fail: function (data, code) {
console.log("subscribeAccelerometer_SensorJsTest007_1 is failed, data: " + data + ", code: " + code);
expect(false).assertTrue();
},
});
setTimeout(() => {
sensor.unsubscribeAccelerometer();
done();
}, 1000);
})
})}
......@@ -31,7 +31,7 @@ _all_test_packages = [
"${ACTS_ROOT}/inputmethod:inputmethod",
"${ACTS_ROOT}/powermgr:powermgr",
"${ACTS_ROOT}/startup:startup",
"${ACTS_ROOT}/sensors:sensor",
"${ACTS_ROOT}/sensors:sensors",
"${ACTS_ROOT}/distributeddatamgr:pasteboard",
"${ACTS_ROOT}/distributeddatamgr:distributeddatamgr",
"${ACTS_ROOT}/graphic:graphic",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册