提交 56f113ab 编写于 作者: J jiyong_sd

Adapt to the new framework

Signed-off-by: Njiyong_sd <jiyong@huawei.com>
Change-Id: I3548d0ed520c167ddd4d8cd07aa3ec67eb66d2ae
上级 1896380b
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import("//test/xts/tools/build/suite.gni") import("//test/xts/tools/build/suite.gni")
......
...@@ -9,13 +9,13 @@ ...@@ -9,13 +9,13 @@
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import("//test/xts/tools/build/suite.gni") import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAbilityRunningInfosTest") { ohos_js_hap_suite("ActsAbilityRunningInfosTest") {
hap_profile = "./src/main/config.json"
hap_name = "ActsAbilityRunningInfosTest" hap_name = "ActsAbilityRunningInfosTest"
hap_profile = "./entry/src/main/config.json"
deps = [ deps = [
":hjs_demo_js_assets", ":hjs_demo_js_assets",
":hjs_demo_resources", ":hjs_demo_resources",
...@@ -23,9 +23,11 @@ ohos_js_hap_suite("ActsAbilityRunningInfosTest") { ...@@ -23,9 +23,11 @@ ohos_js_hap_suite("ActsAbilityRunningInfosTest") {
certificate_profile = "./signature/openharmony_sx.p7b" certificate_profile = "./signature/openharmony_sx.p7b"
} }
ohos_js_assets("hjs_demo_js_assets") { ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default" js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
} }
ohos_resources("hjs_demo_resources") { ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ] sources = [ "./src/main/resources" ]
hap_profile = "./entry/src/main/config.json" hap_profile = "./src/main/config.json"
} }
{ {
"description": "Configuration for hjunit demo Tests", "description": "Configuration for hjunit demo Tests",
"driver": { "driver": {
"type": "JSUnitTest", "type": "OHJSUnitTest",
"test-timeout": "120000", "test-timeout": "120000",
"package": "com.example.abilityrunninginfostest", "shell-timeout": "600000",
"shell-timeout": "600000" "bundle-name": "com.example.abilityrunninginfostest",
}, "package-name": "com.example.abilityrunninginfostest",
"kits": [ "testcase-timeout": 30000
{ },
"test-file-name": [ "kits": [
"ActsAbilityRunningInfosTest.hap" {
], "test-file-name": [
"type": "AppInstallKit", "ActsAbilityRunningInfosTest.hap"
"cleanup-apps": true ],
} "type": "AppInstallKit",
] "cleanup-apps": true
} }
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.abilityrunninginfostest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.abilityrunninginfostest",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.abilityrunninginfostest.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "singleton",
"visible": true
}
],
"reqPermissions": [
{
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name":"ohos.permission.GET_BUNDLE_INFO",
"reason":"need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE",
"reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name":"ohos.permission.REMOVE_CACHE_FILES",
"reason":"need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE"
},
{
"name":"ohos.permission.INSTALL_BUNDLE",
"reason":"need use ohos.permission.INSTALL_BUNDLE"
},
{
"name":"ohos.permission.MANAGE_MISSIONS",
"reason":"need use ohos.permission.MANAGE_MISSIONS"
},
{
"name":"ohos.permission.GET_RUNNING_INFO",
"reason":"need use ohos.permission.GET_RUNNING_INFO"
},
{
"name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES",
"reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES"
},
{
"name":"ohos.permission.CLEAN_APPLICATION_DATA",
"reason":"need use ohos.permission.CLEAN_APPLICATION_DATA"
},
{
"name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS",
"reason": "need use ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.abilityrunninginfostest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.abilityrunninginfostest",
"name": ".entry",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "js",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
},
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".TestAbility",
"srcLanguage": "js",
"srcPath": "TestAbility",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"label": "$string:TestAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"reqPermissions": [
{
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason": "need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO",
"reason": "need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name": "ohos.permission.CHANGE_ABILITY_ENABLED_STATE",
"reason": "need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name": "ohos.permission.REMOVE_CACHE_FILES",
"reason": "need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"name": "ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason": "need use ohos.permission.LISTEN_BUNDLE_CHANGE"
},
{
"name": "ohos.permission.INSTALL_BUNDLE",
"reason": "need use ohos.permission.INSTALL_BUNDLE"
},
{
"name": "ohos.permission.MANAGE_MISSIONS",
"reason": "need use ohos.permission.MANAGE_MISSIONS"
},
{
"name": "ohos.permission.GET_RUNNING_INFO",
"reason": "need use ohos.permission.GET_RUNNING_INFO"
},
{
"name": "ohos.permission.CLEAN_BACKGROUND_PROCESSES",
"reason": "need use ohos.permission.CLEAN_BACKGROUND_PROCESSES"
},
{
"name": "ohos.permission.CLEAN_APPLICATION_DATA",
"reason": "need use ohos.permission.CLEAN_APPLICATION_DATA"
},
{
"name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS",
"reason": "need use ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
},
"mainAbility": ".MainAbility",
"srcPath": ""
}
}
\ No newline at end of file
/* /*
* Copyright (c) 2022 Huawei Device Co., Ltd. * Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
export default { export default {
onCreate() { onCreate() {
console.info('ActsProcessManageJsTest onCreate'); console.info('ActsProcessManageJsTest onCreate');
}, },
onDestroy() { onDestroy() {
console.info('ActsProcessManageJsTest onDestroy'); console.info('ActsProcessManageJsTest onDestroy');
}, },
onShow() { onShow() {
console.info('ActsProcessManageJsTest onShow'); console.info('ActsProcessManageJsTest onShow');
}, },
onHide() { onHide() {
console.info('ActsProcessManageJsTest onHide'); console.info('ActsProcessManageJsTest onHide');
} }
}; };
\ No newline at end of file
{ {
"strings": { "strings": {
"hello": "您好", "hello": "您好",
"world": "世界" "world": "世界"
} }
} }
\ No newline at end of file
.container { .container {
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
.title { .title {
font-size: 100px; font-size: 100px;
} }
.btn { .btn {
width: 200px; width: 200px;
height: 80px; height: 80px;
} }
<div class="container"> <div class="container">
<text class="title"> <text class="title">
{{ $t('strings.hello') }} {{ title }} {{ $t('strings.hello') }} {{ title }}
</text> </text>
<button class="btn" type="capsule" value="start" onclick="start"></button> <button class="btn" type="capsule" value="start" onclick="start"></button>
</div> </div>
/* /*
* Copyright (c) 2022 Huawei Device Co., Ltd. * Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { Core, ExpectExtend } from 'deccjsunit/index' import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
const injectRef = Object.getPrototypeOf(global) || global import testsuite from '../../../test/List.test'
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
const injectRef = Object.getPrototypeOf(global) || global
export default { injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
data: {
title: "", export default {
testTime: 0 data: {
}, title: "",
onInit() { testTime: 0
console.info('ActsProcessManageJsTest onInit'); },
this.title = this.$t('strings.world'); onInit() {
}, console.info('ActsProcessManageJsTest onInit');
onShow() { this.title = this.$t('strings.world');
console.info('ActsProcessManageJsTest onShow'); },
console.info('ActsProcessManageJsTest testTime' + this.testTime); onShow() {
if (this.testTime == 0) { console.info('ActsProcessManageJsTest onShow');
const core = Core.getInstance() console.info('ActsProcessManageJsTest testTime' + this.testTime);
const expectExtend = new ExpectExtend({ if (this.testTime == 0) {
'id': 'extend' var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
}) var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
core.addService('expect', expectExtend) console.info('start run testcase!!!')
core.init() Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
const configService = core.getDefaultService('config') }
this.timeout = 30000; this.testTime++;
configService.setConfig(this) },
onReady() {
require('../../../test/List.test') console.info('ActsProcessManageJsTest onReady');
core.execute() },
} onActive() {
this.testTime++; console.info('ActsProcessManageJsTest onActive');
}, },
onReady() { onInactive() {
console.info('ActsProcessManageJsTest onReady'); console.info('ActsProcessManageJsTest onInactive');
}, },
onActive() { onHide() {
console.info('ActsProcessManageJsTest onActive'); console.info('ActsProcessManageJsTest onHide');
}, },
onInactive() { onDestroy() {
console.info('ActsProcessManageJsTest onInactive'); console.info('ActsProcessManageJsTest onDestroy');
}, },
onHide() { onBackPress() {
console.info('ActsProcessManageJsTest onHide'); console.info('ActsProcessManageJsTest onBackPress');
}, },
onDestroy() { onNewRequest() {
console.info('ActsProcessManageJsTest onDestroy'); console.info('ActsProcessManageJsTest onNewRequest');
}, },
onBackPress() { onStartContinuation() {
console.info('ActsProcessManageJsTest onBackPress'); console.info('ActsProcessManageJsTest onStartContinuation');
}, },
onNewRequest() { onSaveData(value) {
console.info('ActsProcessManageJsTest onNewRequest'); console.info('ActsProcessManageJsTest onSaveData:' + JSON.stringify(value));
}, },
onStartContinuation() { onRestoreData(value) {
console.info('ActsProcessManageJsTest onStartContinuation'); console.info('ActsProcessManageJsTest onRestoreData:' + JSON.stringify(value));
}, },
onSaveData(value) { onCompleteContinuation(code) {
console.info('ActsProcessManageJsTest onSaveData:' + JSON.stringify(value)); console.info('ActsProcessManageJsTest onCompleteContinuation:' + JSON.stringify(code));
}, },
onRestoreData(value) { onConfigurationUpdated(configuration) {
console.info('ActsProcessManageJsTest onRestoreData:' + JSON.stringify(value)); console.info('ActsProcessManageJsTest onConfigurationUpdated:' + JSON.stringify(configuration));
}, }
onCompleteContinuation(code) { }
console.info('ActsProcessManageJsTest onCompleteContinuation:' + JSON.stringify(code));
},
onConfigurationUpdated(configuration) {
console.info('ActsProcessManageJsTest onConfigurationUpdated:' + JSON.stringify(configuration));
}
}
/* /*
* Copyright (c) 2022 Huawei Device Co., Ltd. * Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
require('./ActsProcessManageJsTest.test.js')
\ No newline at end of file
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ No newline at end of file
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
.title {
font-size: 60px;
text-align: center;
width: 100%;
height: 40%;
margin: 10px;
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/* /*
* Copyright (C) 2021 Huawei Device Co., Ltd. * Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
require('./SensorOnOffTest.test.js') export default {
require('./SensorGeomagneticTest.test.js') data: {
require('./SensorGeneralalgorithm.test.js') title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
/*
* Copyright (c) 2022 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package', '-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
export default {
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
},
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility'
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
console.info('debug value : '+debug)
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + data.stdResult);
console.info('executeShellCommand : data : ' + data.exitCode);
})
}
};
/* /*
* Copyright (C) 2022 Huawei Device Co., Ltd. * Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index" import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "@ohos/hypium"
import appManager from '@ohos.application.appManager' import appManager from '@ohos.application.appManager'
describe('ActsAbilityRunningInfosTest', function () { export default function ActsAbilityRunningInfosTest() {
describe('ActsAbilityRunningInfosTest', function () {
function checkRunningProcess(name, dataInfo) {
for (let i = 0, len = dataInfo.length; i < len; i++) { function checkRunningProcess(name, dataInfo) {
if (dataInfo[i].processName.indexOf(name) >= 0) { for (let i = 0, len = dataInfo.length; i < len; i++) {
expect(dataInfo[i].uid).assertLarger(0); if (dataInfo[i].processName.indexOf(name) >= 0) {
expect(dataInfo[i].pid).assertLarger(0); expect(dataInfo[i].uid).assertLarger(0);
return true; expect(dataInfo[i].pid).assertLarger(0);
} return true;
} }
return false; }
} return false;
}
/*
* @tc.number: ACTS_getProcessRunningInfos_0100 /*
* @tc.name: Application running ability information query * @tc.number: ACTS_getProcessRunningInfos_0100
* @tc.desc: Verify applications are started to query getProcessRunningInfos ability information * @tc.name: Application running ability information query
* (by promise) * @tc.desc: Verify applications are started to query getProcessRunningInfos ability information
*/ * (by promise)
it('ACTS_getProcessRunningInfos_0100', 0, async function (done) { */
console.log('ACTS_getProcessRunningInfos_0100====<begin'); it('ACTS_getProcessRunningInfos_0100', 0, async function (done) {
var data = await appManager.getProcessRunningInfos() console.log('ACTS_getProcessRunningInfos_0100====<begin');
console.info('====> ACTS_getProcessRunningInfos_0100 ====>' + JSON.stringify(data)) var data = await appManager.getProcessRunningInfos()
expect(checkRunningProcess('com.ohos.launcher', data)).assertTrue(); console.info('====> ACTS_getProcessRunningInfos_0100 ====>' + JSON.stringify(data))
done(); expect(checkRunningProcess('com.ohos.launcher', data)).assertTrue();
}) done();
})
/*
* @tc.number: ACTS_getProcessRunningInfos_0200 /*
* @tc.name: Application running ability information query * @tc.number: ACTS_getProcessRunningInfos_0200
* @tc.desc: Verify applications are started to query getProcessRunningInfos ability information * @tc.name: Application running ability information query
* (by callback) * @tc.desc: Verify applications are started to query getProcessRunningInfos ability information
*/ * (by callback)
it('ACTS_getProcessRunningInfos_0200', 0, async function (done) { */
console.log('ACTS_getProcessRunningInfos_0200====<begin'); it('ACTS_getProcessRunningInfos_0200', 0, async function (done) {
appManager.getProcessRunningInfos((err, data) => { console.log('ACTS_getProcessRunningInfos_0200====<begin');
console.info('====> ACTS_getProcessRunningInfos_0200 ====>' + JSON.stringify(data)) appManager.getProcessRunningInfos((err, data) => {
expect(checkRunningProcess('com.example.abilityrunninginfostest', data)).assertTrue(); console.info('====> ACTS_getProcessRunningInfos_0200 ====>' + JSON.stringify(data))
done(); expect(checkRunningProcess('com.example.abilityrunninginfostest', data)).assertTrue();
}) done();
}) })
}) })
})
}
/*
* Copyright (c) 2022 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 ActsAbilityRunningInfosTest from './ActsProcessManageJsTest.test.js'
export default function testsuite() {
ActsAbilityRunningInfosTest()
}
{ {
"string": [ "string": [
{ {
"name": "app_name", "name": "app_name",
"value": "actsparticleabilitytest" "value": "actsparticleabilitytest"
}, },
{ {
"name": "mainability_description", "name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability" "value": "JS_Phone_Empty Feature Ability"
} },
] {
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
]
} }
\ No newline at end of file
# Copyright (c) 2021 Huawei Device Co., Ltd. # Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
# You may obtain a copy of the License at # You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import("//test/xts/tools/lite/build/suite_lite.gni") import("//test/xts/tools/lite/build/suite_lite.gni")
hctest_suite("ActsKitFwkApiTest") { hctest_suite("ActsKitFwkApiTest") {
suite_name = "acts" suite_name = "acts"
sources = [ "kitfwk_oem_api_test.c" ] sources = [ "kitfwk_oem_api_test.c" ]
include_dirs = [ include_dirs = [
"//test/xts/tools/lite/hctest/include", "//test/xts/tools/lite/hctest/include",
"//third_party/unity/src", "//third_party/unity/src",
"//utils/native/lite/include", "//utils/native/lite/include",
"//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr",
"//third_party/bounds_checking_function/include/", "//third_party/bounds_checking_function/include/",
"//third_party/mbedtls/include/", "//third_party/mbedtls/include/",
"//third_party/cJSON/", "//third_party/cJSON/",
"//base/startup/syspara_lite/interfaces/kits/", "//base/startup/syspara_lite/interfaces/kits/",
# dir for oem_auth_config.h and oem_auth_result_storage.h # dir for oem_auth_config.h and oem_auth_result_storage.h
"//vendor/kitframework/include/", "//vendor/kitframework/include/",
] ]
# un-comment this Macro for token-persist-test # un-comment this Macro for token-persist-test
# defines = [ "TOKEN_PERSIST_TEST" ] # defines = [ "TOKEN_PERSIST_TEST" ]
} }
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import("//test/xts/tools/build/suite.gni") import("//test/xts/tools/build/suite.gni")
...@@ -23,7 +23,9 @@ ohos_js_hap_suite("sensor_js_test") { ...@@ -23,7 +23,9 @@ ohos_js_hap_suite("sensor_js_test") {
hap_name = "ActsSensorJSApiTest" hap_name = "ActsSensorJSApiTest"
} }
ohos_js_assets("sensor_js_assets") { ohos_js_assets("sensor_js_assets") {
source_dir = "./src/main/js/default" js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
} }
ohos_resources("sensor_js_resources") { ohos_resources("sensor_js_resources") {
sources = [ "./src/main/resources" ] sources = [ "./src/main/resources" ]
......
{ {
"description": "Configuration for sensor js api Tests", "description": "Configuration for sensor js api Tests",
"driver": { "driver": {
"type": "JSUnitTest", "type": "OHJSUnitTest",
"test-timeout": "160000", "test-timeout": "160000",
"package": "ohos.acts.sensors.sensor.function", "shell-timeout": "160000",
"shell-timeout": "60000" "bundle-name": "ohos.acts.sensors.sensor.function",
}, "package-name": "ohos.acts.sensors.sensor.function"
"kits": [ },
{ "kits": [
"test-file-name": [ {
"ActsSensorJSApiTest.hap" "test-file-name": [
], "ActsSensorJSApiTest.hap"
"type": "AppInstallKit", ],
"cleanup-apps": true "type": "AppInstallKit",
} "cleanup-apps": true
] }
} ]
}
\ No newline at end of file
{ {
"app": { "app": {
"bundleName": "ohos.acts.sensors.sensor.function", "bundleName": "ohos.acts.sensors.sensor.function",
"vendor": "example", "vendor": "example",
"version": { "version": {
"code": 1, "code": 1,
"name": "1.0" "name": "1.0"
}, },
"apiVersion": { "apiVersion": {
"compatible": 4, "compatible": 4,
"target": 5 "target": 5
} }
}, },
"deviceConfig": {}, "deviceConfig": {},
"module": { "module": {
"package": "ohos.acts.sensors.sensor.function", "package": "ohos.acts.sensors.sensor.function",
"name": ".MyApplication", "name": ".entry",
"deviceType": [ "deviceType": [
"phone" "phone"
], ],
"distro": { "distro": {
"deliveryWithInstall": true, "deliveryWithInstall": true,
"moduleName": "entry", "moduleName": "entry",
"moduleType": "entry" "moduleType": "entry"
}, },
"abilities": [ "abilities": [
{ {
"visible": true, "skills": [
"skills": [ {
{ "entities": [
"entities": [ "entity.system.home"
"entity.system.home" ],
], "actions": [
"actions": [ "action.system.home"
"action.system.home" ]
] }
} ],
], "orientation": "unspecified",
"name": "ohos.acts.sensors.sensor.function.MainAbility", "formsEnabled": false,
"icon": "$media:icon", "name": ".MainAbility",
"description": "$string:mainability_description", "srcLanguage": "js",
"label": "$string:app_name", "srcPath": "MainAbility",
"type": "page", "icon": "$media:icon",
"launchType": "standard" "description": "$string:MainAbility_desc",
} "label": "$string:MainAbility_label",
], "type": "page",
"js": [ "visible": true,
{ "launchType": "standard"
"pages": [ },
"pages/index/index" {
], "orientation": "unspecified",
"name": "default", "formsEnabled": false,
"window": { "name": ".TestAbility",
"designWidth": 720, "srcLanguage": "js",
"autoDesignWidth": false "srcPath": "TestAbility",
} "icon": "$media:icon",
} "description": "$string:TestAbility_desc",
], "label": "$string:TestAbility_label",
"reqPermissions": [ "type": "page",
{ "visible": true,
"name": "ohos.permission.ACCELEROMETER", "launchType": "standard"
"reason": "need use ohos.permission.ACCELEROMETER" }
}, ],
{ "js": [
"name": "ohos.permission.GYROSCOPE", {
"reason": "need use ohos.permission.GYROSCOPE" "pages": [
} "pages/index/index"
] ],
} "name": "default",
} "window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"reqPermissions": [
{
"name": "ohos.permission.ACCELEROMETER",
"reason": "need use ohos.permission.ACCELEROMETER"
},
{
"name": "ohos.permission.GYROSCOPE",
"reason": "need use ohos.permission.GYROSCOPE"
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
},
"mainAbility": ".MainAbility",
"srcPath": ""
}
}
\ No newline at end of file
/*
* 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('TestApplication onCreate')
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
onDestroy() {
console.info("TestApplication onDestroy");
}
};
/* /*
* Copyright (C) 2021 Huawei Device Co., Ltd. * Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {Core, ExpectExtend} from 'deccjsunit/index'
const injectRef = Object.getPrototypeOf(global) || global
const injectRef = Object.getPrototypeOf(global) || global injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
export default { data: {
data: { title: ""
title: "" },
}, onInit() {
onInit() { this.title = this.$t('strings.world');
this.title = this.$t('strings.world'); },
}, onShow() {
onShow() { console.info('onShow finish')
console.info('onShow finish') },
const core = Core.getInstance() onReady() {
const expectExtend = new ExpectExtend({ },
'id': 'extend' }
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
this.timeout = 5000
configService.setConfig(this)
require('../../test/List.test')
core.execute()
},
onReady() {
},
}
/* /*
* Copyright (C) 2021 Huawei Device Co., Ltd. * Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
export default { export default {
onCreate() { onCreate() {
console.info('AceApplication onCreate'); console.info('AceApplication onCreate');
}, },
onDestroy() { onDestroy() {
console.info('AceApplication onDestroy'); console.info('AceApplication onDestroy');
} }
}; };
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ No newline at end of file
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
.title {
font-size: 60px;
text-align: center;
width: 100%;
height: 40%;
margin: 10px;
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* Copyright (c) 2022 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.
*/
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
/*
* Copyright (c) 2022 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package', '-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
export default {
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
},
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility'
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
console.info('debug value : '+debug)
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + data.stdResult);
console.info('executeShellCommand : data : ' + data.exitCode);
})
}
};
/*
* 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 SystemParameterTest from './SensorOnOffTest.test.js'
import SensorJsTest_sensor_2 from './SensorGeomagneticTest.test.js'
import SensorJsTest_sensor_1 from './SensorGeneralalgorithm.test.js'
export default function testsuite() {
SensorJsTest_sensor_1()
SensorJsTest_sensor_2()
SystemParameterTest()
}
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
// @ts-nocheck // @ts-nocheck
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium'
import sensor from '@ohos.sensor' import sensor from '@ohos.sensor'
function sleep(NumberMillis) { function sleep(NumberMillis) {
...@@ -29,6 +29,7 @@ function sleep(NumberMillis) { ...@@ -29,6 +29,7 @@ function sleep(NumberMillis) {
} }
} }
export default function SystemParameterTest() {
describe('SystemParameterTest', function () { describe('SystemParameterTest', function () {
beforeAll(function () { beforeAll(function () {
console.info('beforeAll caled') console.info('beforeAll caled')
...@@ -49,41 +50,12 @@ describe('SystemParameterTest', function () { ...@@ -49,41 +50,12 @@ describe('SystemParameterTest', function () {
let testSensorId = 0; let testSensorId = 0;
let testNullSensorId = -1; let testNullSensorId = -1;
/**
* @tc.number SUB_SENSORS_Sensor_JSTest_0010
* @tc.name testRegisterSensortest001
* @tc.desc test get sensor data by sensor id.
*/
it('SUB_SENSORS_Sensor_JSTest_0010', FUNCTION|MEDIUMTEST|LEVEL0, async function (done) {
console.info('SUB_SENSORS_Sensor_JSTest_0010 start');
try {
sensor.on(testSensorId, function (data) {
if (data) {
console.info('testRegisterSensortest001 on success');
expect(data.x).assertInstanceOf('Number');
expect(data.timestamp).assertInstanceOf('Number');
done();
} else {
console.info('testRegisterSensortest001 on error');
expect(false).assertTrue();
done();
}
});
} catch (error) {
console.info(error);
expect(true).assertTrue();
done();
}
console.info('SUB_SENSORS_Sensor_JSTest_0010 end');
})
/** /**
* @tc.number SUB_SENSORS_Sensor_JSTest_0020 * @tc.number SUB_SENSORS_Sensor_JSTest_0020
* @tc.name testRegisterSensortest002 * @tc.name testRegisterSensortest002
* @tc.desc test get sensor data by wrong sensor id. * @tc.desc test get sensor data by wrong sensor id.
*/ */
it('SUB_SENSORS_Sensor_JSTest_0020', FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { it('SUB_SENSORS_Sensor_JSTest_0020', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('SUB_SENSORS_Sensor_JSTest_0020 start'); console.info('SUB_SENSORS_Sensor_JSTest_0020 start');
function onSensorCallback(data) { function onSensorCallback(data) {
...@@ -101,4 +73,4 @@ describe('SystemParameterTest', function () { ...@@ -101,4 +73,4 @@ describe('SystemParameterTest', function () {
} }
console.info('SUB_SENSORS_Sensor_JSTest_0020 end'); console.info('SUB_SENSORS_Sensor_JSTest_0020 end');
}) })
}) })}
\ No newline at end of file
/* /*
* Copyright (C) 2021 Huawei Device Co., Ltd. * Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import sensor from '@ohos.sensor' import sensor from '@ohos.sensor'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium'
describe("SensorJsTest_sensor_6", function () { export default function SensorJsTest_sensor_6() {
beforeAll(function () { describe("SensorJsTest_sensor_6", function () {
beforeAll(function () {
/*
* @tc.setup: setup invoked before all testcases /*
*/ * @tc.setup: setup invoked before all testcases
console.info('beforeAll caled') */
}) console.info('beforeAll caled')
})
afterAll(function () {
afterAll(function () {
/*
* @tc.teardown: teardown invoked after all testcases /*
*/ * @tc.teardown: teardown invoked after all testcases
console.info('afterAll caled') */
}) console.info('afterAll caled')
})
beforeEach(function () {
beforeEach(function () {
/*
* @tc.setup: setup invoked before each testcases /*
*/ * @tc.setup: setup invoked before each testcases
console.info('beforeEach caled') */
}) console.info('beforeEach caled')
})
afterEach(function () {
afterEach(function () {
/*
* @tc.teardown: teardown invoked after each testcases /*
*/ * @tc.teardown: teardown invoked after each testcases
console.info('afterEach caled') */
}) console.info('afterEach caled')
})
/*
* @tc.number: SUB_SensorsSystem_Accelerometer_Uncalibrated_JSTest_0010 /*
* @tc.name: SensorAccelerometerUncalibratedJSTest001 * @tc.number: SUB_SensorsSystem_Accelerometer_Uncalibrated_JSTest_0010
* @tc.desc: Verification results of the incorrect parameters of the test interface * @tc.name: SensorAccelerometerUncalibratedJSTest001
*/ * @tc.desc: Verification results of the incorrect parameters of the test interface
it("SUB_SensorsSystem_Accelerometer_Uncalibrated_JSTest_0010", FUNCTION|MEDIUMTEST|LEVEL0, async function (done) { */
console.info('------------SUB_SensorsSystem_Accelerometer_Uncalibrated_JSTest_0010-----------------'); it("SUB_SensorsSystem_Accelerometer_Uncalibrated_JSTest_0010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
function offPromise() { console.info('------------SUB_SensorsSystem_Accelerometer_Uncalibrated_JSTest_0010-----------------');
return new Promise((resolve, reject) => { function offPromise() {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, (error) => { return new Promise((resolve, reject) => {
if (error) { sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, (error) => {
console.info('SensorAccelerometerUncalibratedJSTest001 off error'); if (error) {
expect(false).assertTrue(); console.info('SensorAccelerometerUncalibratedJSTest001 off error');
console.info('setTimeout ..start') expect(false).assertTrue();
setTimeout((err) => { console.info('setTimeout ..start')
reject(err); setTimeout((err) => {
}, 500); reject(err);
} else { }, 500);
console.info('SensorAccelerometerUncalibratedJSTest001 off success'); } else {
expect(true).assertTrue(); console.info('SensorAccelerometerUncalibratedJSTest001 off success');
setTimeout(() => { expect(true).assertTrue();
resolve(); setTimeout(() => {
}, 500); resolve();
} }, 500);
}, 1000) }
}) }, 1000)
} })
}
let promise = new Promise((resolve, reject) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, function (error, data) { let promise = new Promise((resolve, reject) => {
if (error) { sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, function (error, data) {
console.info('SensorAccelerometerUncalibratedJSTest001 on error'); if (error) {
expect(false).assertTrue(); console.info('SensorAccelerometerUncalibratedJSTest001 on error');
setTimeout((err) => { expect(false).assertTrue();
reject(err); setTimeout((err) => {
}, 500); reject(err);
} else { }, 500);
console.info('SensorAccelerometerUncalibratedJSTest001 on success, x: ' + data.x + "y: " } else {
+ data.y + "z: " + data.z + "biasX:" + data.biasX + "biasY: " console.info('SensorAccelerometerUncalibratedJSTest001 on success, x: ' + data.x + "y: "
+ data.biasY + "biasZ: " + data.biasZ); + data.y + "z: " + data.z + "biasX:" + data.biasX + "biasY: "
expect(typeof (data.x)).assertEqual("number"); + data.biasY + "biasZ: " + data.biasZ);
expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.x)).assertEqual("number");
expect(typeof (data.z)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number");
expect(typeof (data.biasX)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number");
expect(typeof (data.biasY)).assertEqual("number"); expect(typeof (data.biasX)).assertEqual("number");
expect(typeof (data.biasZ)).assertEqual("number"); expect(typeof (data.biasY)).assertEqual("number");
setTimeout(() => { expect(typeof (data.biasZ)).assertEqual("number");
resolve(); setTimeout(() => {
}, 500); resolve();
} }, 500);
}); }
}) });
})
await promise.then(() => {
return offPromise(); await promise.then(() => {
}, () => { return offPromise();
console.info("SensorAccelerometerUncalibratedJSTest001 reject"); }, () => {
}) console.info("SensorAccelerometerUncalibratedJSTest001 reject");
done(); })
}) done();
})
/*
* @tc.number: SUB_SensorsSystem_Accelerometer_Uncalibrated_JSTest_0020 /*
* @tc.name: SensorAccelerometerUncalibratedJSTest002 * @tc.number: SUB_SensorsSystem_Accelerometer_Uncalibrated_JSTest_0020
* @tc.desc: Verification results of the incorrect parameters of the test interface * @tc.name: SensorAccelerometerUncalibratedJSTest002
*/ * @tc.desc: Verification results of the incorrect parameters of the test interface
it("SUB_SensorsSystem_Accelerometer_Uncalibrated_JSTest_0020", FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { */
function onceSensorCallback(error, data) { it("SUB_SensorsSystem_Accelerometer_Uncalibrated_JSTest_0020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
if (error) { function onceSensorCallback(error, data) {
console.info('SensorAccelerometerUncalibratedJSTest002 once error'); if (error) {
expect(false).assertTrue(); console.info('SensorAccelerometerUncalibratedJSTest002 once error');
} else { expect(false).assertTrue();
console.info('SensorAccelerometerUncalibratedJSTest002 on success, x: ' + data.x + "y: " } else {
+ data.y + "z: " + data.z + "biasX:" + data.biasX + "biasY: " console.info('SensorAccelerometerUncalibratedJSTest002 on success, x: ' + data.x + "y: "
+ data.biasY + "biasZ: " + data.biasZ); + data.y + "z: " + data.z + "biasX:" + data.biasX + "biasY: "
expect(typeof (data.x)).assertEqual("number"); + data.biasY + "biasZ: " + data.biasZ);
expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.x)).assertEqual("number");
expect(typeof (data.z)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number");
expect(typeof (data.biasX)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number");
expect(typeof (data.biasY)).assertEqual("number"); expect(typeof (data.biasX)).assertEqual("number");
expect(typeof (data.biasZ)).assertEqual("number"); expect(typeof (data.biasY)).assertEqual("number");
} expect(typeof (data.biasZ)).assertEqual("number");
setTimeout(() => { }
done(); setTimeout(() => {
}, 500); done();
} }, 500);
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, onceSensorCallback); }
}) sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, onceSensorCallback);
}) })
})
}
/* /*
* Copyright (C) 2021 Huawei Device Co., Ltd. * Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import sensor from '@ohos.sensor' import sensor from '@ohos.sensor'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium'
describe("SensorJsTest_sensor_8", function () { export default function SensorJsTest_sensor_8() {
beforeAll(function () { describe("SensorJsTest_sensor_8", function () {
beforeAll(function () {
/*
* @tc.setup: setup invoked before all testcases /*
*/ * @tc.setup: setup invoked before all testcases
console.info('beforeAll caled') */
}) console.info('beforeAll caled')
})
afterAll(function () {
afterAll(function () {
/*
* @tc.teardown: teardown invoked after all testcases /*
*/ * @tc.teardown: teardown invoked after all testcases
console.info('afterAll caled') */
}) console.info('afterAll caled')
})
beforeEach(function () {
beforeEach(function () {
/*
* @tc.setup: setup invoked before each testcases /*
*/ * @tc.setup: setup invoked before each testcases
console.info('beforeEach caled') */
}) console.info('beforeEach caled')
})
afterEach(function () {
afterEach(function () {
/*
* @tc.teardown: teardown invoked after each testcases /*
*/ * @tc.teardown: teardown invoked after each testcases
console.info('afterEach caled') */
}) console.info('afterEach caled')
})
/*
* @tc.number: SUB_SensorsSystem_Barometer_JSTest_0010 /*
* @tc.name: SensorBarometerJSTest001 * @tc.number: SUB_SensorsSystem_Barometer_JSTest_0010
* @tc.desc: Verification results of the incorrect parameters of the test interface * @tc.name: SensorBarometerJSTest001
*/ * @tc.desc: Verification results of the incorrect parameters of the test interface
it("SUB_SensorsSystem_Barometer_JSTest_0010", FUNCTION|MEDIUMTEST|LEVEL0, async function (done) { */
console.info('----------------------SUB_SensorsSystem_Barometer_JSTest_0010---------------------------'); it("SUB_SensorsSystem_Barometer_JSTest_0010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
function offPromise() { console.info('----------------------SUB_SensorsSystem_Barometer_JSTest_0010---------------------------');
return new Promise((resolve, reject) => { function offPromise() {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, (error) => { return new Promise((resolve, reject) => {
if (error) { sensor.off(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, (error) => {
console.info('SensorBarometerJSTest001 off error'); if (error) {
expect(false).assertTrue(); console.info('SensorBarometerJSTest001 off error');
console.info('setTimeout ..start') expect(false).assertTrue();
setTimeout((err) => { console.info('setTimeout ..start')
reject(err); setTimeout((err) => {
}, 500); reject(err);
} else { }, 500);
console.info('SensorBarometerJSTest001 off success'); } else {
expect(true).assertTrue(); console.info('SensorBarometerJSTest001 off success');
setTimeout(() => { expect(true).assertTrue();
resolve(); setTimeout(() => {
}, 500); resolve();
} }, 500);
}, 1000) }
}) }, 1000)
} })
}
let promise = new Promise((resolve, reject) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, function (error, data) { let promise = new Promise((resolve, reject) => {
if (error) { sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, function (error, data) {
console.info('SensorBarometerJSTest001 on error'); if (error) {
expect(false).assertTrue(); console.info('SensorBarometerJSTest001 on error');
setTimeout((err) => { expect(false).assertTrue();
reject(err); setTimeout((err) => {
}, 500); reject(err);
} else { }, 500);
console.info('SensorBarometerJSTest001 on success pressure: ' + data.pressure); } else {
expect(typeof (data.pressure)).assertEqual("number"); console.info('SensorBarometerJSTest001 on success pressure: ' + data.pressure);
setTimeout(() => { expect(typeof (data.pressure)).assertEqual("number");
resolve(); setTimeout(() => {
}, 500); resolve();
} }, 500);
}); }
}) });
})
await promise.then(() => {
return offPromise(); await promise.then(() => {
}, () => { return offPromise();
console.info("SensorBarometerJSTest001 reject"); }, () => {
}) console.info("SensorBarometerJSTest001 reject");
done(); })
}) done();
})
/*
* @tc.number: SUB_SensorsSystem_Barometer_JSTest_0050 /*
* @tc.name: SensorBarometerJSTest005 * @tc.number: SUB_SensorsSystem_Barometer_JSTest_0050
* @tc.desc: Verification results of the incorrect parameters of the test interface * @tc.name: SensorBarometerJSTest005
*/ * @tc.desc: Verification results of the incorrect parameters of the test interface
it("SUB_SensorsSystem_Barometer_JSTest_0050", FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { */
function onceSensorCallback(error, data) { it("SUB_SensorsSystem_Barometer_JSTest_0050", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
if (error) { function onceSensorCallback(error, data) {
console.info('SensorBarometerJSTest005 once error'); if (error) {
expect(false).assertTrue(); console.info('SensorBarometerJSTest005 once error');
} else { expect(false).assertTrue();
console.info('SensorBarometerJSTest005 once success pressure: ' + data.pressure); } else {
expect(typeof (data.pressure)).assertEqual("number"); console.info('SensorBarometerJSTest005 once success pressure: ' + data.pressure);
} expect(typeof (data.pressure)).assertEqual("number");
setTimeout(() => { }
done(); setTimeout(() => {
}, 500); done();
} }, 500);
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, onceSensorCallback); }
}) sensor.once(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, onceSensorCallback);
}) })
})
}
/* /*
* Copyright (C) 2021 Huawei Device Co., Ltd. * Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import sensor from '@ohos.sensor' import sensor from '@ohos.sensor'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium'
describe("SensorJsTest_sensor_35", function () { export default function SensorJsTest_sensor_35() {
beforeAll(function () { describe("SensorJsTest_sensor_35", function () {
beforeAll(function () {
/*
* @tc.setup: setup invoked before all testcases /*
*/ * @tc.setup: setup invoked before all testcases
console.info('beforeAll caled') */
}) console.info('beforeAll caled')
})
afterAll(function () {
afterAll(function () {
/*
* @tc.teardown: teardown invoked after all testcases /*
*/ * @tc.teardown: teardown invoked after all testcases
console.info('afterAll caled') */
}) console.info('afterAll caled')
})
beforeEach(function () {
beforeEach(function () {
/*
* @tc.setup: setup invoked before each testcases /*
*/ * @tc.setup: setup invoked before each testcases
console.info('beforeEach caled') */
}) console.info('beforeEach caled')
})
afterEach(function () {
afterEach(function () {
/*
* @tc.teardown: teardown invoked after each testcases /*
*/ * @tc.teardown: teardown invoked after each testcases
console.info('afterEach caled') */
}) console.info('afterEach caled')
})
let errMessage;
let errMessage;
let invild;
let invild;
let errMessages = ['Wrong argument type, should be function', 'The number of parameters is not valid',
'xxx is not defined']; let errMessages = ['Wrong argument type, should be function', 'The number of parameters is not valid',
'xxx is not defined'];
/**
* @tc.number:SUB_SensorsSystem_GetSensorLists_JSTest_0010 /**
* @tc.name: getSensorLists_SensorJsTest001 * @tc.number:SUB_SensorsSystem_GetSensorLists_JSTest_0010
* @tc.desc: Verification results of the incorrect parameters of the test interface. * @tc.name: getSensorLists_SensorJsTest001
*/ * @tc.desc: Verification results of the incorrect parameters of the test interface.
it("getSensorLists_SensorJsTest001", FUNCTION|MEDIUMTEST|LEVEL0, async function (done) { */
console.info("---------------------------getSensorLists_SensorJsTest001----------------------------------"); it("getSensorLists_SensorJsTest001", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
sensor.getSensorList().then((data) => { console.info("---------------------------getSensorLists_SensorJsTest001----------------------------------");
console.info("---------------------------getSensorLists_SensorJsTest001 in-----------" + data.length); sensor.getSensorList().then((data) => {
for (let i = 0; i < data.length; i++) { console.info("---------------------------getSensorLists_SensorJsTest001 in-----------" + data.length);
console.info("getSensorLists_SensorJsTest001 " + JSON.stringify(data[i])); for (let i = 0; i < data.length; i++) {
} console.info("getSensorLists_SensorJsTest001 " + JSON.stringify(data[i]));
done(); }
}, (error)=>{ done();
console.info('getSensorLists_SensorJsTest001 failed'); }, (error)=>{
expect(false).assertTrue(); console.info('getSensorLists_SensorJsTest001 failed');
}); expect(false).assertTrue();
}) });
})
/**
* @tc.number:SUB_SensorsSystem_GetSensorLists_JSTest_0020 /**
* @tc.name: getSensorLists_SensorJsTest002 * @tc.number:SUB_SensorsSystem_GetSensorLists_JSTest_0020
* @tc.desc: Verification results of the incorrect parameters of the test interface. * @tc.name: getSensorLists_SensorJsTest002
*/ * @tc.desc: Verification results of the incorrect parameters of the test interface.
it("getSensorLists_SensorJsTest002", FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { */
console.info("---------------------------getSensorLists_SensorJsTest002----------------------------------"); it("getSensorLists_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
sensor.getSensorList((error, data) => { console.info("---------------------------getSensorLists_SensorJsTest002----------------------------------");
if (error) { sensor.getSensorList((error, data) => {
console.info('getSensorLists_SensorJsTest002 error'); if (error) {
expect(false).assertTrue(); console.info('getSensorLists_SensorJsTest002 error');
} else { expect(false).assertTrue();
console.info("---------------------------getSensorLists_SensorJsTest002 in-----------" + data.length); } else {
for (let i = 0; i < data.length; i++) { console.info("---------------------------getSensorLists_SensorJsTest002 in-----------" + data.length);
console.info("getSensorLists_SensorJsTest002 " + JSON.stringify(data[i])); for (let i = 0; i < data.length; i++) {
} console.info("getSensorLists_SensorJsTest002 " + JSON.stringify(data[i]));
done() }
} done()
}); }
}) });
})
/**
* @tc.number:SUB_SensorsSystem_GetSensorLists_JSTest_0030 /**
* @tc.name: getSensorLists_SensorJsTest003 * @tc.number:SUB_SensorsSystem_GetSensorLists_JSTest_0030
* @tc.desc: Verification results of the incorrect parameters of the test interface. * @tc.name: getSensorLists_SensorJsTest003
*/ * @tc.desc: Verification results of the incorrect parameters of the test interface.
it("getSensorLists_SensorJsTest003", FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { */
console.info("---------------------------getSensorLists_SensorJsTest003----------------------------------"); it("getSensorLists_SensorJsTest003", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
try { console.info("---------------------------getSensorLists_SensorJsTest003----------------------------------");
sensor.getSensorList(null) try {
} catch (error) { sensor.getSensorList(null)
errMessage = error.toString().slice(23, 62); } catch (error) {
console.info('getSensorLists_SensorJsTest003 error:' + error); errMessage = error.toString().slice(23, 62);
console.info('getSensorLists_SensorJsTest003 errMessage:' + errMessage); console.info('getSensorLists_SensorJsTest003 error:' + error);
expect(errMessage).assertEqual(errMessages[0]); console.info('getSensorLists_SensorJsTest003 errMessage:' + errMessage);
done(); expect(errMessage).assertEqual(errMessages[0]);
} done();
}) }
})
/**
* @tc.number:SUB_SensorsSystem_GetSensorLists_JSTest_0040 /**
* @tc.name: getSensorLists_SensorJsTest004 * @tc.number:SUB_SensorsSystem_GetSensorLists_JSTest_0040
* @tc.desc: Verification results of the incorrect parameters of the test interface. * @tc.name: getSensorLists_SensorJsTest004
*/ * @tc.desc: Verification results of the incorrect parameters of the test interface.
it('getSensorLists_SensorJsTest004', FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { */
console.info("------------------getSensorLists_SensorJsTest004-------------------------"); it('getSensorLists_SensorJsTest004', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
try { console.info("------------------getSensorLists_SensorJsTest004-------------------------");
sensor.getSensorList(invild) try {
} catch (error) { sensor.getSensorList(invild)
errMessage = error.toString().slice(23,62); } catch (error) {
console.info('getSensorLists_SensorJsTest004 error:' + error); errMessage = error.toString().slice(23,62);
console.info('getSensorLists_SensorJsTest004 errMessage:' + errMessage); console.info('getSensorLists_SensorJsTest004 error:' + error);
expect(errMessage).assertEqual(errMessages[0]); console.info('getSensorLists_SensorJsTest004 errMessage:' + errMessage);
done(); expect(errMessage).assertEqual(errMessages[0]);
} done();
}) }
})
/**
* @tc.number:SUB_SensorsSystem_GetSensorLists_JSTest_0050 /**
* @tc.name: getSensorLists_SensorJsTest005 * @tc.number:SUB_SensorsSystem_GetSensorLists_JSTest_0050
* @tc.desc: Verification results of the incorrect parameters of the test interface. * @tc.name: getSensorLists_SensorJsTest005
*/ * @tc.desc: Verification results of the incorrect parameters of the test interface.
it('getSensorLists_SensorJsTest005', FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { */
console.info("------------------getSensorLists_SensorJsTest005-------------------------"); it('getSensorLists_SensorJsTest005', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
try { console.info("------------------getSensorLists_SensorJsTest005-------------------------");
sensor.getSensorList('xxx') try {
} catch (error) { sensor.getSensorList('xxx')
errMessage = error.toString().slice(23,62); } catch (error) {
console.info('getSensorLists_SensorJsTest005 error:' + error); errMessage = error.toString().slice(23,62);
console.info('getSensorLists_SensorJsTest005 errMessage:' + errMessage); console.info('getSensorLists_SensorJsTest005 error:' + error);
expect(errMessage).assertEqual(errMessages[0]); console.info('getSensorLists_SensorJsTest005 errMessage:' + errMessage);
done(); expect(errMessage).assertEqual(errMessages[0]);
} done();
}) }
})
/**
* @tc.number:SUB_SensorsSystem_GetSensorLists_JSTest_0060 /**
* @tc.name: getSensorLists_SensorJsTest006 * @tc.number:SUB_SensorsSystem_GetSensorLists_JSTest_0060
* @tc.desc: Verification results of the incorrect parameters of the test interface. * @tc.name: getSensorLists_SensorJsTest006
*/ * @tc.desc: Verification results of the incorrect parameters of the test interface.
it("getSensorLists_SensorJsTest006", FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { */
console.info("---------------------------getSensorLists_SensorJsTest006----------------------------------"); it("getSensorLists_SensorJsTest006", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
sensor.getSensorList((error, data) => { console.info("---------------------------getSensorLists_SensorJsTest006----------------------------------");
if (error) { sensor.getSensorList((error, data) => {
console.info('getSensorLists_SensorJsTest006 error'); if (error) {
expect(true).assertTrue(); console.info('getSensorLists_SensorJsTest006 error');
done() expect(true).assertTrue();
} else { done()
console.info("---------------------------getSensorLists_SensorJsTest006 in-----------" + data.length); } else {
for (let i = 0; i < data.length; i++) { console.info("---------------------------getSensorLists_SensorJsTest006 in-----------" + data.length);
console.info("getSensorLists_SensorJsTest006 " + JSON.stringify(data[i])); for (let i = 0; i < data.length; i++) {
} console.info("getSensorLists_SensorJsTest006 " + JSON.stringify(data[i]));
done() }
} done()
}); }
sensor.getSensorList((error, data) => { });
if (error) { sensor.getSensorList((error, data) => {
console.info('getSensorLists_SensorJsTest006 error'); if (error) {
expect(true).assertTrue(); console.info('getSensorLists_SensorJsTest006 error');
done() expect(true).assertTrue();
} else { done()
console.info("---------------------------getSensorLists_SensorJsTest006 in-----------" + data.length); } else {
for (let i = 0; i < data.length; i++) { console.info("---------------------------getSensorLists_SensorJsTest006 in-----------" + data.length);
console.info("getSensorLists_SensorJsTest006 " + JSON.stringify(data[i])); for (let i = 0; i < data.length; i++) {
} console.info("getSensorLists_SensorJsTest006 " + JSON.stringify(data[i]));
done() }
} done()
}); }
}) });
}) })
})
}
...@@ -14,8 +14,9 @@ ...@@ -14,8 +14,9 @@
*/ */
import sensor from '@ohos.sensor' import sensor from '@ohos.sensor'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium'
export default function SensorJsTest_sensor_9() {
describe("SensorJsTest_sensor_9", function () { describe("SensorJsTest_sensor_9", function () {
function callback(data) { function callback(data) {
console.info("callback" + JSON.stringify(data)); console.info("callback" + JSON.stringify(data));
...@@ -73,7 +74,7 @@ describe("SensorJsTest_sensor_9", function () { ...@@ -73,7 +74,7 @@ describe("SensorJsTest_sensor_9", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
* @tc.number:SUB_SensorsSystem_GRAVITY_JsTest_0010 * @tc.number:SUB_SensorsSystem_GRAVITY_JsTest_0010
*/ */
it("gravity_SensorJsTest001", FUNCTION|MEDIUMTEST|LEVEL0, async function (done) { it("gravity_SensorJsTest001", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
console.info('----------------------gravity_SensorJsTest001---------------------------'); console.info('----------------------gravity_SensorJsTest001---------------------------');
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback);
setTimeout(()=>{ setTimeout(()=>{
...@@ -87,7 +88,7 @@ describe("SensorJsTest_sensor_9", function () { ...@@ -87,7 +88,7 @@ describe("SensorJsTest_sensor_9", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
* @tc.number:SUB_SensorsSystem_GRAVITY_JsTest_0020 * @tc.number:SUB_SensorsSystem_GRAVITY_JsTest_0020
*/ */
it("gravity_SensorJsTest002", FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { it("gravity_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------gravity_SensorJsTest002---------------------------'); console.info('----------------------gravity_SensorJsTest002---------------------------');
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback, {'interval': 100000000}); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback, {'interval': 100000000});
setTimeout(()=>{ setTimeout(()=>{
...@@ -103,7 +104,7 @@ describe("SensorJsTest_sensor_9", function () { ...@@ -103,7 +104,7 @@ describe("SensorJsTest_sensor_9", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
* @tc.number:SUB_SensorsSystem_GRAVITY_JsTest_0030 * @tc.number:SUB_SensorsSystem_GRAVITY_JsTest_0030
*/ */
it("gravity_SensorJsTest003", FUNCTION|MEDIUMTEST|LEVEL3, function (done) { it("gravity_SensorJsTest003", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) {
console.info('----------------------gravity_SensorJsTest003---------------------------'); console.info('----------------------gravity_SensorJsTest003---------------------------');
function onSensorCallback(data) { function onSensorCallback(data) {
console.info('gravity_SensorJsTest003 on error'); console.info('gravity_SensorJsTest003 on error');
...@@ -125,7 +126,7 @@ describe("SensorJsTest_sensor_9", function () { ...@@ -125,7 +126,7 @@ describe("SensorJsTest_sensor_9", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
* @tc.number:SUB_SensorsSystem_GRAVITY_JsTest_0040 * @tc.number:SUB_SensorsSystem_GRAVITY_JsTest_0040
*/ */
it("gravity_SensorJsTest004", FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { it("gravity_SensorJsTest004", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback); sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback);
setTimeout(()=>{ setTimeout(()=>{
expect(true).assertTrue(); expect(true).assertTrue();
...@@ -138,7 +139,7 @@ describe("SensorJsTest_sensor_9", function () { ...@@ -138,7 +139,7 @@ describe("SensorJsTest_sensor_9", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
* @tc.number:SUB_SensorsSystem_GRAVITY_JsTest_0050 * @tc.number:SUB_SensorsSystem_GRAVITY_JsTest_0050
*/ */
it("gravity_SensorJsTest005", FUNCTION|MEDIUMTEST|LEVEL3, function (done) { it("gravity_SensorJsTest005", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) {
function onceSensorCallback(data) { function onceSensorCallback(data) {
console.info('gravity_SensorJsTest005 on error'); console.info('gravity_SensorJsTest005 on error');
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -159,7 +160,7 @@ describe("SensorJsTest_sensor_9", function () { ...@@ -159,7 +160,7 @@ describe("SensorJsTest_sensor_9", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
* @tc.number:SUB_SensorsSystem_GRAVITY_JsTest_0060 * @tc.number:SUB_SensorsSystem_GRAVITY_JsTest_0060
*/ */
it("gravity_SensorJsTest006", FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { it("gravity_SensorJsTest006", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
try { try {
sensor.off(string, ""); sensor.off(string, "");
} catch (error) { } catch (error) {
...@@ -175,7 +176,7 @@ describe("SensorJsTest_sensor_9", function () { ...@@ -175,7 +176,7 @@ describe("SensorJsTest_sensor_9", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
* @tc.number:SUB_SensorsSystem_GRAVITY_JsTest_0070 * @tc.number:SUB_SensorsSystem_GRAVITY_JsTest_0070
*/ */
it("gravity_SensorJsTest007", FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { it("gravity_SensorJsTest007", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
function onSensorCallback(data) { function onSensorCallback(data) {
console.info('gravity_SensorJsTest007 on error'); console.info('gravity_SensorJsTest007 on error');
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -194,7 +195,7 @@ describe("SensorJsTest_sensor_9", function () { ...@@ -194,7 +195,7 @@ describe("SensorJsTest_sensor_9", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
* @tc.number:SUB_SensorsSystem_GRAVITY_JsTest_0080 * @tc.number:SUB_SensorsSystem_GRAVITY_JsTest_0080
*/ */
it("gravity_SensorJsTest008", FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { it("gravity_SensorJsTest008", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
function onSensorCallback(data) { function onSensorCallback(data) {
console.info('gravity_SensorJsTest008 on error'); console.info('gravity_SensorJsTest008 on error');
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -215,7 +216,7 @@ describe("SensorJsTest_sensor_9", function () { ...@@ -215,7 +216,7 @@ describe("SensorJsTest_sensor_9", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
* @tc.number:SUB_SensorsSystem_GRAVITY_JsTest_0090 * @tc.number:SUB_SensorsSystem_GRAVITY_JsTest_0090
*/ */
it("gravity_SensorJsTest009", FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { it("gravity_SensorJsTest009", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback);
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2);
setTimeout(()=>{ setTimeout(()=>{
...@@ -231,7 +232,7 @@ describe("SensorJsTest_sensor_9", function () { ...@@ -231,7 +232,7 @@ describe("SensorJsTest_sensor_9", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
* @tc.number:SUB_SensorsSystem_GRAVITY_JsTest_0100 * @tc.number:SUB_SensorsSystem_GRAVITY_JsTest_0100
*/ */
it("gravity_SensorJsTest010", FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { it("gravity_SensorJsTest010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback);
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2);
setTimeout(()=>{ setTimeout(()=>{
...@@ -252,7 +253,7 @@ describe("SensorJsTest_sensor_9", function () { ...@@ -252,7 +253,7 @@ describe("SensorJsTest_sensor_9", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
* @tc.number:SUB_SensorsSystem_GRAVITY_JsTest_0110 * @tc.number:SUB_SensorsSystem_GRAVITY_JsTest_0110
*/ */
it("gravity_SensorJsTest011", FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { it("gravity_SensorJsTest011", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------gravity_SensorJsTest011---------------------------'); console.info('----------------------gravity_SensorJsTest011---------------------------');
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback, {'interval': 100000000}); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback, {'interval': 100000000});
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2); sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2);
...@@ -269,7 +270,7 @@ describe("SensorJsTest_sensor_9", function () { ...@@ -269,7 +270,7 @@ describe("SensorJsTest_sensor_9", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
* @tc.number:SUB_SensorsSystem_GRAVITY_JsTest_0120 * @tc.number:SUB_SensorsSystem_GRAVITY_JsTest_0120
*/ */
it("gravity_SensorJsTest012", FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { it("gravity_SensorJsTest012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------gravity_SensorJsTest012---------------------------'); console.info('----------------------gravity_SensorJsTest012---------------------------');
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback, {'interval': 100000000}); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback, {'interval': 100000000});
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2, {'interval': 100000000}); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2, {'interval': 100000000});
...@@ -291,7 +292,7 @@ describe("SensorJsTest_sensor_9", function () { ...@@ -291,7 +292,7 @@ describe("SensorJsTest_sensor_9", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
* @tc.number:SUB_SensorsSystem_GRAVITY_JsTest_0130 * @tc.number:SUB_SensorsSystem_GRAVITY_JsTest_0130
*/ */
it("gravity_SensorJsTest013", FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { it("gravity_SensorJsTest013", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------gravity_SensorJsTest013---------------------------'); console.info('----------------------gravity_SensorJsTest013---------------------------');
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback, {'interval': 100000000}); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback, {'interval': 100000000});
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2, {'interval': 100000000}); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2, {'interval': 100000000});
...@@ -302,4 +303,4 @@ describe("SensorJsTest_sensor_9", function () { ...@@ -302,4 +303,4 @@ describe("SensorJsTest_sensor_9", function () {
done(); done();
}, 1000); }, 1000);
}) })
}) })}
\ No newline at end of file
/* /*
* Copyright (C) 2021 Huawei Device Co., Ltd. * Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import sensor from '@ohos.sensor' import sensor from '@ohos.sensor'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium'
describe("SensorJsTest_sensor_10", function () { export default function SensorJsTest_sensor_10() {
beforeAll(function () { describe("SensorJsTest_sensor_10", function () {
beforeAll(function () {
/*
* @tc.setup: setup invoked before all testcases /*
*/ * @tc.setup: setup invoked before all testcases
console.info('beforeAll caled') */
}) console.info('beforeAll caled')
})
afterAll(function () {
afterAll(function () {
/*
* @tc.teardown: teardown invoked after all testcases /*
*/ * @tc.teardown: teardown invoked after all testcases
console.info('afterAll caled') */
}) console.info('afterAll caled')
})
beforeEach(function () {
beforeEach(function () {
/*
* @tc.setup: setup invoked before each testcases /*
*/ * @tc.setup: setup invoked before each testcases
console.info('beforeEach caled') */
}) console.info('beforeEach caled')
})
afterEach(function () {
afterEach(function () {
/*
* @tc.teardown: teardown invoked after each testcases /*
*/ * @tc.teardown: teardown invoked after each testcases
console.info('afterEach caled') */
}) console.info('afterEach caled')
})
/*
* @tc.number: SUB_SensorsSystem_Gyroscope_Uncalibrated_JSTest_0010 /*
* @tc.name: SensorGyroscopeUncalibratedJSTest001 * @tc.number: SUB_SensorsSystem_Gyroscope_Uncalibrated_JSTest_0010
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.name: SensorGyroscopeUncalibratedJSTest001
*/ * @tc.desc:Verification results of the incorrect parameters of the test interface
it("SUB_SensorsSystem_Gyroscope_Uncalibrated_JSTest_0010", FUNCTION|MEDIUMTEST|LEVEL0, async function (done) { */
console.info('-----------------SUB_SensorsSystem_Gyroscope_Uncalibrated_JSTest_0010----------------------'); it("SUB_SensorsSystem_Gyroscope_Uncalibrated_JSTest_0010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
function offPromise() { console.info('-----------------SUB_SensorsSystem_Gyroscope_Uncalibrated_JSTest_0010----------------------');
return new Promise((resolve, reject) => { function offPromise() {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, (error) => { return new Promise((resolve, reject) => {
if (error) { sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, (error) => {
console.info('SensorGyroscopeUncalibratedJSTest001 off error'); if (error) {
expect(false).assertTrue(); console.info('SensorGyroscopeUncalibratedJSTest001 off error');
console.info('setTimeout ..start') expect(false).assertTrue();
setTimeout((err) => { console.info('setTimeout ..start')
reject(err); setTimeout((err) => {
}, 500); reject(err);
} else { }, 500);
console.info('SensorGyroscopeUncalibratedJSTest001 off success'); } else {
expect(true).assertTrue(); console.info('SensorGyroscopeUncalibratedJSTest001 off success');
setTimeout(() => { expect(true).assertTrue();
resolve(); setTimeout(() => {
}, 500); resolve();
} }, 500);
}, 1000) }
}) }, 1000)
} })
}
let promise = new Promise((resolve, reject) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, function (error, data) { let promise = new Promise((resolve, reject) => {
if (error) { sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, function (error, data) {
console.info('SensorGyroscopeUncalibratedJSTest001 on error'); if (error) {
expect(false).assertTrue(); console.info('SensorGyroscopeUncalibratedJSTest001 on error');
setTimeout((err) => { expect(false).assertTrue();
reject(err); setTimeout((err) => {
}, 500); reject(err);
} else { }, 500);
console.info('SensorGyroscopeUncalibratedJSTest001 on success, x: ' + data.x + "y: " } else {
+ data.y + "z: " console.info('SensorGyroscopeUncalibratedJSTest001 on success, x: ' + data.x + "y: "
+ data.z + "biasX:" + data.biasX + "biasY: " + data.biasY + "biasZ: " + data.biasZ); + data.y + "z: "
expect(typeof (data.x)).assertEqual("number"); + data.z + "biasX:" + data.biasX + "biasY: " + data.biasY + "biasZ: " + data.biasZ);
expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.x)).assertEqual("number");
expect(typeof (data.z)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number");
expect(typeof (data.biasX)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number");
expect(typeof (data.biasY)).assertEqual("number"); expect(typeof (data.biasX)).assertEqual("number");
expect(typeof (data.biasZ)).assertEqual("number"); expect(typeof (data.biasY)).assertEqual("number");
setTimeout(() => { expect(typeof (data.biasZ)).assertEqual("number");
resolve(); setTimeout(() => {
}, 500); resolve();
} }, 500);
}); }
}) });
})
await promise.then(() => {
return offPromise(); await promise.then(() => {
}, () => { return offPromise();
console.info("SensorGyroscopeUncalibratedJSTest001 reject"); }, () => {
}) console.info("SensorGyroscopeUncalibratedJSTest001 reject");
done(); })
}) done();
})
/*
* @tc.number: SUB_SensorsSystem_Gyroscope_Uncalibrated_JSTest_0050 /*
* @tc.name: SensorGyroscopeUncalibratedJSTest005 * @tc.number: SUB_SensorsSystem_Gyroscope_Uncalibrated_JSTest_0050
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.name: SensorGyroscopeUncalibratedJSTest005
*/ * @tc.desc:Verification results of the incorrect parameters of the test interface
it("SUB_SensorsSystem_Gyroscope_Uncalibrated_JSTest_0050", FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { */
function onceSensorCallback(error, data) { it("SUB_SensorsSystem_Gyroscope_Uncalibrated_JSTest_0050", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
if (error) { function onceSensorCallback(error, data) {
console.info('SensorGyroscopeUncalibratedJSTest005 once error'); if (error) {
expect(false).assertTrue(); console.info('SensorGyroscopeUncalibratedJSTest005 once error');
} else { expect(false).assertTrue();
console.info('SensorGyroscopeUncalibratedJSTest005 on success, x: ' + data.x + "y: " + data.y + "z: " } else {
+ data.z + "biasX:" + data.biasX + "biasY: " + data.biasY + "biasZ: " + data.biasZ); console.info('SensorGyroscopeUncalibratedJSTest005 on success, x: ' + data.x + "y: " + data.y + "z: "
expect(typeof (data.x)).assertEqual("number"); + data.z + "biasX:" + data.biasX + "biasY: " + data.biasY + "biasZ: " + data.biasZ);
expect(typeof (data.y)).assertEqual("number"); expect(typeof (data.x)).assertEqual("number");
expect(typeof (data.z)).assertEqual("number"); expect(typeof (data.y)).assertEqual("number");
expect(typeof (data.biasX)).assertEqual("number"); expect(typeof (data.z)).assertEqual("number");
expect(typeof (data.biasY)).assertEqual("number"); expect(typeof (data.biasX)).assertEqual("number");
expect(typeof (data.biasZ)).assertEqual("number"); expect(typeof (data.biasY)).assertEqual("number");
} expect(typeof (data.biasZ)).assertEqual("number");
setTimeout(() => { }
done(); setTimeout(() => {
}, 500); done();
} }, 500);
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, onceSensorCallback); }
}) sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, onceSensorCallback);
}) })
})
}
/* /*
* Copyright (C) 2021 Huawei Device Co., Ltd. * Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import sensor from '@ohos.sensor' import sensor from '@ohos.sensor'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium'
describe("SensorJsTest_sensor_11", function () { export default function SensorJsTest_sensor_11() {
beforeAll(function () { describe("SensorJsTest_sensor_11", function () {
beforeAll(function () {
/*
* @tc.setup: setup invoked before all testcases /*
*/ * @tc.setup: setup invoked before all testcases
console.info('beforeAll caled') */
}) console.info('beforeAll caled')
})
afterAll(function () {
afterAll(function () {
/*
* @tc.teardown: teardown invoked after all testcases /*
*/ * @tc.teardown: teardown invoked after all testcases
console.info('afterAll caled') */
}) console.info('afterAll caled')
})
beforeEach(function () {
beforeEach(function () {
/*
* @tc.setup: setup invoked before each testcases /*
*/ * @tc.setup: setup invoked before each testcases
console.info('beforeEach caled') */
}) console.info('beforeEach caled')
})
afterEach(function () {
afterEach(function () {
/*
* @tc.teardown: teardown invoked after each testcases /*
*/ * @tc.teardown: teardown invoked after each testcases
console.info('afterEach caled') */
}) console.info('afterEach caled')
})
/*
* @tc.number: SUB_SensorsSystem_Heart_Rate_JSTest_0010 /*
* @tc.name: SensorHeartRateJSTest001 * @tc.number: SUB_SensorsSystem_Heart_Rate_JSTest_0010
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.name: SensorHeartRateJSTest001
*/ * @tc.desc:Verification results of the incorrect parameters of the test interface
it("SUB_SensorsSystem_Heart_Rate_JSTest_0010", FUNCTION|MEDIUMTEST|LEVEL0, async function (done) { */
console.info('----------------------SUB_SensorsSystem_Heart_Rate_JSTest_0010---------------------------'); it("SUB_SensorsSystem_Heart_Rate_JSTest_0010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
function offPromise() { console.info('----------------------SUB_SensorsSystem_Heart_Rate_JSTest_0010---------------------------');
return new Promise((resolve, reject) => { function offPromise() {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE, (error) => { return new Promise((resolve, reject) => {
if (error) { sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE, (error) => {
console.info('SensorHeartRateJSTest001 off error'); if (error) {
expect(false).assertTrue(); console.info('SensorHeartRateJSTest001 off error');
console.info('setTimeout ..start') expect(false).assertTrue();
setTimeout((err) => { console.info('setTimeout ..start')
reject(err); setTimeout((err) => {
}, 500); reject(err);
} else { }, 500);
console.info('SensorHeartRateJSTest001 off success'); } else {
expect(true).assertTrue(); console.info('SensorHeartRateJSTest001 off success');
setTimeout(() => { expect(true).assertTrue();
resolve(); setTimeout(() => {
}, 500); resolve();
} }, 500);
}, 1000) }
}) }, 1000)
} })
}
let promise = new Promise((resolve, reject) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE, function (error, data) { let promise = new Promise((resolve, reject) => {
if (error) { sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE, function (error, data) {
console.info('SensorHeartRateJSTest001 on error'); if (error) {
expect(false).assertTrue(); console.info('SensorHeartRateJSTest001 on error');
setTimeout((err) => { expect(false).assertTrue();
reject(err); setTimeout((err) => {
}, 500); reject(err);
} else { }, 500);
console.info('SensorHeartRateJSTest001 once success heartRate: ' + data.heartRate); } else {
expect(typeof (data.heartRate)).assertEqual("number"); console.info('SensorHeartRateJSTest001 once success heartRate: ' + data.heartRate);
setTimeout(() => { expect(typeof (data.heartRate)).assertEqual("number");
resolve(); setTimeout(() => {
}, 500); resolve();
} }, 500);
}); }
}) });
})
await promise.then(() => {
return offPromise(); await promise.then(() => {
}, () => { return offPromise();
console.info("SensorHeartRateJSTest001 reject"); }, () => {
}) console.info("SensorHeartRateJSTest001 reject");
done(); })
}) done();
})
/*
* @tc.number: SUB_SensorsSystem_Heart_Rate_JSTest_0050 /*
* @tc.name: SensorHeartRateJSTest005 * @tc.number: SUB_SensorsSystem_Heart_Rate_JSTest_0050
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.name: SensorHeartRateJSTest005
*/ * @tc.desc:Verification results of the incorrect parameters of the test interface
it("SUB_SensorsSystem_Heart_Rate_JSTest_0050", FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { */
function onceSensorCallback(error, data) { it("SUB_SensorsSystem_Heart_Rate_JSTest_0050", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
if (error) { function onceSensorCallback(error, data) {
console.info('SensorHeartRateJSTest005 once error'); if (error) {
expect(false).assertTrue(); console.info('SensorHeartRateJSTest005 once error');
} else { expect(false).assertTrue();
console.info('SensorHeartRateJSTest005 once success heartRate: ' + data.heartRate); } else {
expect(typeof (data.heartRate)).assertEqual("number"); console.info('SensorHeartRateJSTest005 once success heartRate: ' + data.heartRate);
} expect(typeof (data.heartRate)).assertEqual("number");
setTimeout(() => { }
done(); setTimeout(() => {
}, 500); done();
} }, 500);
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE, onceSensorCallback); }
}) sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE, onceSensorCallback);
}) })
})
}
...@@ -14,8 +14,9 @@ ...@@ -14,8 +14,9 @@
*/ */
import sensor from '@ohos.sensor' import sensor from '@ohos.sensor'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium'
export default function SensorJsTest_sensor_16() {
describe("SensorJsTest_sensor_16", function () { describe("SensorJsTest_sensor_16", function () {
function callback(data) { function callback(data) {
console.info("callback" + JSON.stringify(data)); console.info("callback" + JSON.stringify(data));
...@@ -73,7 +74,7 @@ describe("SensorJsTest_sensor_16", function () { ...@@ -73,7 +74,7 @@ describe("SensorJsTest_sensor_16", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
* @tc.number:SUB_SensorSystem_ORIENTATION_JsTest_0010 * @tc.number:SUB_SensorSystem_ORIENTATION_JsTest_0010
*/ */
it("orientating_SensorJsTest001", FUNCTION|MEDIUMTEST|LEVEL0, async function (done) { it("orientating_SensorJsTest001", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
console.info('----------------------orientating_SensorJsTest001---------------------------'); console.info('----------------------orientating_SensorJsTest001---------------------------');
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback);
setTimeout(()=>{ setTimeout(()=>{
...@@ -87,7 +88,7 @@ describe("SensorJsTest_sensor_16", function () { ...@@ -87,7 +88,7 @@ describe("SensorJsTest_sensor_16", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
* @tc.number:SUB_SensorSystem_ORIENTATION_JsTest_0020 * @tc.number:SUB_SensorSystem_ORIENTATION_JsTest_0020
*/ */
it("orientating_SensorJsTest002", FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { it("orientating_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------orientating_SensorJsTest002---------------------------'); console.info('----------------------orientating_SensorJsTest002---------------------------');
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback, {'interval': 100000000}); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback, {'interval': 100000000});
setTimeout(()=>{ setTimeout(()=>{
...@@ -103,7 +104,7 @@ describe("SensorJsTest_sensor_16", function () { ...@@ -103,7 +104,7 @@ describe("SensorJsTest_sensor_16", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
* @tc.number:SUB_SensorSystem_ORIENTATION_JsTest_0030 * @tc.number:SUB_SensorSystem_ORIENTATION_JsTest_0030
*/ */
it("orientating_SensorJsTest003", FUNCTION|MEDIUMTEST|LEVEL3, function (done) { it("orientating_SensorJsTest003", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) {
console.info('----------------------orientating_SensorJsTest003---------------------------'); console.info('----------------------orientating_SensorJsTest003---------------------------');
function onSensorCallback(data) { function onSensorCallback(data) {
console.info('orientating_SensorJsTest003 on error'); console.info('orientating_SensorJsTest003 on error');
...@@ -125,7 +126,7 @@ describe("SensorJsTest_sensor_16", function () { ...@@ -125,7 +126,7 @@ describe("SensorJsTest_sensor_16", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
* @tc.number:SUB_SensorSystem_ORIENTATION_JsTest_0040 * @tc.number:SUB_SensorSystem_ORIENTATION_JsTest_0040
*/ */
it("orientating_SensorJsTest004", FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { it("orientating_SensorJsTest004", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback); sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback);
setTimeout(()=>{ setTimeout(()=>{
expect(true).assertTrue(); expect(true).assertTrue();
...@@ -138,7 +139,7 @@ describe("SensorJsTest_sensor_16", function () { ...@@ -138,7 +139,7 @@ describe("SensorJsTest_sensor_16", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
* @tc.number:SUB_SensorSystem_ORIENTATION_JsTest_0050 * @tc.number:SUB_SensorSystem_ORIENTATION_JsTest_0050
*/ */
it("orientating_SensorJsTest005", FUNCTION|MEDIUMTEST|LEVEL3, function (done) { it("orientating_SensorJsTest005", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) {
function onceSensorCallback(data) { function onceSensorCallback(data) {
console.info('orientating_SensorJsTest005 on error'); console.info('orientating_SensorJsTest005 on error');
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -159,7 +160,7 @@ describe("SensorJsTest_sensor_16", function () { ...@@ -159,7 +160,7 @@ describe("SensorJsTest_sensor_16", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
* @tc.number:SUB_SensorSystem_ORIENTATION_JsTest_0060 * @tc.number:SUB_SensorSystem_ORIENTATION_JsTest_0060
*/ */
it("orientating_SensorJsTest006", FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { it("orientating_SensorJsTest006", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
try { try {
sensor.off(string, ""); sensor.off(string, "");
} catch (error) { } catch (error) {
...@@ -175,7 +176,7 @@ describe("SensorJsTest_sensor_16", function () { ...@@ -175,7 +176,7 @@ describe("SensorJsTest_sensor_16", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
* @tc.number:SUB_SensorSystem_ORIENTATION_JsTest_0070 * @tc.number:SUB_SensorSystem_ORIENTATION_JsTest_0070
*/ */
it("orientating_SensorJsTest007", FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { it("orientating_SensorJsTest007", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
function onSensorCallback(data) { function onSensorCallback(data) {
console.info('orientating_SensorJsTest007 on error'); console.info('orientating_SensorJsTest007 on error');
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -194,7 +195,7 @@ describe("SensorJsTest_sensor_16", function () { ...@@ -194,7 +195,7 @@ describe("SensorJsTest_sensor_16", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
* @tc.number:SUB_SensorSystem_ORIENTATION_JsTest_0080 * @tc.number:SUB_SensorSystem_ORIENTATION_JsTest_0080
*/ */
it("orientating_SensorJsTest008", FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { it("orientating_SensorJsTest008", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
function onSensorCallback(data) { function onSensorCallback(data) {
console.info('orientating_SensorJsTest008 on error'); console.info('orientating_SensorJsTest008 on error');
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -215,7 +216,7 @@ describe("SensorJsTest_sensor_16", function () { ...@@ -215,7 +216,7 @@ describe("SensorJsTest_sensor_16", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
* @tc.number:SUB_SensorSystem_ORIENTATION_JsTest_0090 * @tc.number:SUB_SensorSystem_ORIENTATION_JsTest_0090
*/ */
it("orientating_SensorJsTest009", FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { it("orientating_SensorJsTest009", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback);
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback2); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback2);
setTimeout(()=>{ setTimeout(()=>{
...@@ -231,7 +232,7 @@ describe("SensorJsTest_sensor_16", function () { ...@@ -231,7 +232,7 @@ describe("SensorJsTest_sensor_16", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
* @tc.number:SUB_SensorSystem_ORIENTATION_JsTest_0100 * @tc.number:SUB_SensorSystem_ORIENTATION_JsTest_0100
*/ */
it("orientating_SensorJsTest010", FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { it("orientating_SensorJsTest010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback);
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback2); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback2);
setTimeout(()=>{ setTimeout(()=>{
...@@ -252,7 +253,7 @@ describe("SensorJsTest_sensor_16", function () { ...@@ -252,7 +253,7 @@ describe("SensorJsTest_sensor_16", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
* @tc.number:SUB_SensorSystem_ORIENTATION_JsTest_0110 * @tc.number:SUB_SensorSystem_ORIENTATION_JsTest_0110
*/ */
it("orientating_SensorJsTest011", FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { it("orientating_SensorJsTest011", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------orientating_SensorJsTest011---------------------------'); console.info('----------------------orientating_SensorJsTest011---------------------------');
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback, {'interval': 100000000}); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback, {'interval': 100000000});
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback2); sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback2);
...@@ -269,7 +270,7 @@ describe("SensorJsTest_sensor_16", function () { ...@@ -269,7 +270,7 @@ describe("SensorJsTest_sensor_16", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
* @tc.number:SUB_SensorSystem_ORIENTATION_JsTest_0120 * @tc.number:SUB_SensorSystem_ORIENTATION_JsTest_0120
*/ */
it("orientating_SensorJsTest012", FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { it("orientating_SensorJsTest012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------orientating_SensorJsTest012---------------------------'); console.info('----------------------orientating_SensorJsTest012---------------------------');
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback, {'interval': 100000000}); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback, {'interval': 100000000});
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback2, {'interval': 100000000}); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback2, {'interval': 100000000});
...@@ -291,7 +292,7 @@ describe("SensorJsTest_sensor_16", function () { ...@@ -291,7 +292,7 @@ describe("SensorJsTest_sensor_16", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
* @tc.number:SUB_SensorSystem_ORIENTATION_JsTest_0130 * @tc.number:SUB_SensorSystem_ORIENTATION_JsTest_0130
*/ */
it("orientating_SensorJsTest013", FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { it("orientating_SensorJsTest013", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------orientating_SensorJsTest013---------------------------'); console.info('----------------------orientating_SensorJsTest013---------------------------');
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback, {'interval': 100000000}); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback, {'interval': 100000000});
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback2, {'interval': 100000000}); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback2, {'interval': 100000000});
...@@ -302,4 +303,4 @@ describe("SensorJsTest_sensor_16", function () { ...@@ -302,4 +303,4 @@ describe("SensorJsTest_sensor_16", function () {
done(); done();
}, 1000); }, 1000);
}) })
}) })}
\ No newline at end of file
...@@ -14,8 +14,9 @@ ...@@ -14,8 +14,9 @@
*/ */
import sensor from '@system.sensor' import sensor from '@system.sensor'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium'
export default function SensorJsTest_sensor_26() {
describe("SensorJsTest_sensor_26", function () { describe("SensorJsTest_sensor_26", function () {
beforeAll(function () { beforeAll(function () {
...@@ -59,7 +60,7 @@ describe("SensorJsTest_sensor_26", function () { ...@@ -59,7 +60,7 @@ describe("SensorJsTest_sensor_26", function () {
* @tc.name:subscribeBarometer_SensorJsTest001 * @tc.name:subscribeBarometer_SensorJsTest001
* @tc.desc:Verification results of the incorrect parameters of the test interface. * @tc.desc:Verification results of the incorrect parameters of the test interface.
*/ */
it("subscribeBarometer_SensorJsTest001", FUNCTION|MEDIUMTEST|LEVEL0, async function (done) { it("subscribeBarometer_SensorJsTest001", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
console.info('----------------------subscribeBarometer_SensorJsTest001---------------------------'); console.info('----------------------subscribeBarometer_SensorJsTest001---------------------------');
sensor.subscribeBarometer({ sensor.subscribeBarometer({
success: function (data) { success: function (data) {
...@@ -89,7 +90,7 @@ describe("SensorJsTest_sensor_26", function () { ...@@ -89,7 +90,7 @@ describe("SensorJsTest_sensor_26", function () {
* @tc.name: subscribeBarometer_SensorJsTest002 * @tc.name: subscribeBarometer_SensorJsTest002
* @tc.desc:Verification results of the incorrect parameters of the test interface. * @tc.desc:Verification results of the incorrect parameters of the test interface.
*/ */
it("subscribeBarometer_SensorJsTest002", FUNCTION|MEDIUMTEST|LEVEL3, function (done) { it("subscribeBarometer_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) {
console.info('----------------------subscribeBarometer_SensorJsTest002---------------------------'); console.info('----------------------subscribeBarometer_SensorJsTest002---------------------------');
try { try {
sensor.subscribeBarometer({ sensor.subscribeBarometer({
...@@ -115,7 +116,7 @@ describe("SensorJsTest_sensor_26", function () { ...@@ -115,7 +116,7 @@ describe("SensorJsTest_sensor_26", function () {
* @tc.name: subscribeBarometer_SensorJsTest003 * @tc.name: subscribeBarometer_SensorJsTest003
* @tc.desc:Verification results of the incorrect parameters of the test interface. * @tc.desc:Verification results of the incorrect parameters of the test interface.
*/ */
it("subscribeBarometer_SensorJsTest003", FUNCTION|MEDIUMTEST|LEVEL3, function (done) { it("subscribeBarometer_SensorJsTest003", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) {
console.info('----------------------subscribeBarometer_SensorJsTest003---------------------------'); console.info('----------------------subscribeBarometer_SensorJsTest003---------------------------');
try { try {
sensor.subscribeBarometer({ sensor.subscribeBarometer({
...@@ -142,7 +143,7 @@ describe("SensorJsTest_sensor_26", function () { ...@@ -142,7 +143,7 @@ describe("SensorJsTest_sensor_26", function () {
* @tc.name: subscribeBarometer_SensorJsTest004 * @tc.name: subscribeBarometer_SensorJsTest004
* @tc.desc:Verification results of the incorrect parameters of the test interface. * @tc.desc:Verification results of the incorrect parameters of the test interface.
*/ */
it("subscribeBarometer_SensorJsTest004", FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { it("subscribeBarometer_SensorJsTest004", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------subscribeBarometer_SensorJsTest004---------------------------'); console.info('----------------------subscribeBarometer_SensorJsTest004---------------------------');
try { try {
sensor.unsubscribeBarometer('xxx'); sensor.unsubscribeBarometer('xxx');
...@@ -159,7 +160,7 @@ describe("SensorJsTest_sensor_26", function () { ...@@ -159,7 +160,7 @@ describe("SensorJsTest_sensor_26", function () {
* @tc.name: subscribeBarometer_SensorJsTest005 * @tc.name: subscribeBarometer_SensorJsTest005
* @tc.desc:Verification results of the incorrect parameters of the test interface. * @tc.desc:Verification results of the incorrect parameters of the test interface.
*/ */
it("subscribeBarometer_SensorJsTest005", FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { it("subscribeBarometer_SensorJsTest005", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------subscribeBarometer_SensorJsTest005---------------------------'); console.info('----------------------subscribeBarometer_SensorJsTest005---------------------------');
try { try {
sensor.subscribeBarometer(); sensor.subscribeBarometer();
...@@ -176,7 +177,7 @@ describe("SensorJsTest_sensor_26", function () { ...@@ -176,7 +177,7 @@ describe("SensorJsTest_sensor_26", function () {
* @tc.name: subscribeBarometer_SensorJsTest006 * @tc.name: subscribeBarometer_SensorJsTest006
* @tc.desc:Verification results of the incorrect parameters of the test interface. * @tc.desc:Verification results of the incorrect parameters of the test interface.
*/ */
it("subscribeBarometer_SensorJsTest006", FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { it("subscribeBarometer_SensorJsTest006", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------subscribeBarometer_SensorJsTest006---------------------------'); console.info('----------------------subscribeBarometer_SensorJsTest006---------------------------');
try { try {
sensor.subscribeBarometer('xxx'); sensor.subscribeBarometer('xxx');
...@@ -193,7 +194,7 @@ describe("SensorJsTest_sensor_26", function () { ...@@ -193,7 +194,7 @@ describe("SensorJsTest_sensor_26", function () {
* @tc.name: subscribeBarometer_SensorJsTest007 * @tc.name: subscribeBarometer_SensorJsTest007
* @tc.desc:Verification results of the incorrect parameters of the test interface. * @tc.desc:Verification results of the incorrect parameters of the test interface.
*/ */
it("subscribeBarometer_SensorJsTest007", FUNCTION|MEDIUMTEST|LEVEL3, function (done) { it("subscribeBarometer_SensorJsTest007", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) {
console.info('----------------------subscribeBarometer_SensorJsTest007---------------------------'); console.info('----------------------subscribeBarometer_SensorJsTest007---------------------------');
sensor.subscribeBarometer({ sensor.subscribeBarometer({
success: function (data) { success: function (data) {
...@@ -233,7 +234,7 @@ describe("SensorJsTest_sensor_26", function () { ...@@ -233,7 +234,7 @@ describe("SensorJsTest_sensor_26", function () {
* @tc.name: subscribeBarometer_SensorJsTest008 * @tc.name: subscribeBarometer_SensorJsTest008
* @tc.desc:Verification results of the incorrect parameters of the test interface. * @tc.desc:Verification results of the incorrect parameters of the test interface.
*/ */
it("subscribeBarometer_SensorJsTest008", FUNCTION|MEDIUMTEST|LEVEL3, async function (done) { it("subscribeBarometer_SensorJsTest008", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------subscribeBarometer_SensorJsTest008---------------------------'); console.info('----------------------subscribeBarometer_SensorJsTest008---------------------------');
try { try {
sensor.unsubscribeBarometer(); sensor.unsubscribeBarometer();
...@@ -250,7 +251,7 @@ describe("SensorJsTest_sensor_26", function () { ...@@ -250,7 +251,7 @@ describe("SensorJsTest_sensor_26", function () {
* @tc.name: subscribeBarometer_SensorJsTest009 * @tc.name: subscribeBarometer_SensorJsTest009
* @tc.desc:Verification results of the incorrect parameters of the test interface. * @tc.desc:Verification results of the incorrect parameters of the test interface.
*/ */
it("subscribeBarometer_SensorJsTest009", FUNCTION|MEDIUMTEST|LEVEL3, function (done) { it("subscribeBarometer_SensorJsTest009", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) {
console.info('----------------------subscribeBarometer_SensorJsTest009---------------------------'); console.info('----------------------subscribeBarometer_SensorJsTest009---------------------------');
sensor.subscribeBarometer({ sensor.subscribeBarometer({
success: function (data) { success: function (data) {
...@@ -274,4 +275,4 @@ describe("SensorJsTest_sensor_26", function () { ...@@ -274,4 +275,4 @@ describe("SensorJsTest_sensor_26", function () {
}) })
}) })
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册