提交 0a4d2df6 编写于 作者: O openharmony_ci 提交者: Gitee

!1334 Sensor接口测试用例

Merge pull request !1334 from logic42/wanglong120916
# 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("//build/ohos_var.gni")
group("sensor") {
testonly = true
if (is_standard_system) {
deps = [ "sensor_standard:sensor_js_test" ]
}
}
# 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("sensor_js_test") {
hap_profile = "./src/main/config.json"
deps = [
":sensor_js_assets",
":sensor_js_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "SensorJSApiTest"
}
ohos_js_assets("sensor_js_assets") {
source_dir = "./src/main/js/default"
}
ohos_resources("sensor_js_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
{
"description": "Configuration for sensor js api Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "160000",
"package": "ohos.acts.sensors.sensor.function",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"SensorJSApiTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "ohos.acts.sensors.sensor.function",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.sensors.sensor.function",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "ohos.acts.sensors.sensor.function.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
/*
* 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.
*/
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* 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 {Core, ExpectExtend} from 'deccjsunit/index'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
const core = Core.getInstance()
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.
* 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.
*/
require('./SensorOnOffTest.test.js')
/*
* 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.
*/
// @ts-nocheck
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
import sensor from '@ohos.sensor'
function sleep (NumberMillis) {
var now = new Date()
var exitTime = now.getTime() + NumberMillis
while(true) {
now = new Date()
if (now.getTime > exitTime) {
return
}
}
}
describe('SystemParameterTest', function () {
beforeAll(function() {
console.info('beforeAll caled')
})
afterAll(function() {
console.info('afterAll caled')
})
beforeEach(function() {
console.info('beforeEach caled')
})
afterEach(function() {
console.info('afterEach caled')
})
/**
* @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', 0, async function (done) {
console.info('SUB_SENSORS_Sensor_JSTest_0010 start');
await sensor.on(0, function(error, data) {
if (error) {
console.info('testRegisterSensortest001 on error');
expect(false).assertTrue();
done();
} else {
console.info('testRegisterSensortest001 on success');
expect(data.x).assertInstanceOf('Number');
done();
}
});
console.info('SUB_SENSORS_Sensor_JSTest_0010 end');
})
/**
* @tc.number SUB_SENSORS_Sensor_JSTest_0020
* @tc.name testRegisterSensortest002
* @tc.desc test get sensor data by wrong sensor id.
*/
it('SUB_SENSORS_Sensor_JSTest_0020', 0, async function (done) {
console.info('SUB_SENSORS_Sensor_JSTest_0020 start');
await sensor.on(-1, function(error, data) {
if (error) {
console.info('testRegisterSensortest002 on error');
expect(true).assertTrue();
done();
} else {
console.info('testRegisterSensortest002 on success');
expect(false).assertTrue();
done();
}
});
console.info('SUB_SENSORS_Sensor_JSTest_0020 end');
})
})
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "SensorJSApiTest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ No newline at end of file
......@@ -32,6 +32,7 @@ _all_test_packages = [
"${ACTS_ROOT}/miscservices:miscservices",
"${ACTS_ROOT}/powermgr:powermgr",
"${ACTS_ROOT}/startup:startup",
"${ACTS_ROOT}/sensors:sensor",
"${ACTS_ROOT}/distributeddatamgr:distributeddatamgr",
# "${ACTS_ROOT}/distributedschedule:distributedschedule",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册