提交 619856ed 编写于 作者: Z zwx1016320

add time framework and Copyright comments and modefi index

Signed-off-by: Nzwx1016320 <zhangyushuai1@huawei-partners.com>
上级 b06d98d0
......@@ -14,8 +14,5 @@
import("//build/ohos_var.gni")
group("time") {
testonly = true
deps = [
"TimeTest_js:ActsTimeJSApiTest",
"TimerTest_js:ActsTimerJSApiTest",
]
deps = [ "timeTest:ActsTimeAPITest" ]
}
{
"description": "Configuration for time js api Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "600000",
"package": "ohos.acts.time.timetest",
"shell-timeout": "600000"
},
"kits": [
{
"test-file-name": [
"ActsTimeJSApiTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "ohos.acts.time.timetest",
"vendor": "acts",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 7,
"target": 9
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.time.timetest",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"reqPermissions": [
{
"name": "ohos.permission.SET_TIME",
"reason": "use.ohos.permission.SET_TIME"
},
{
"name": "ohos.permission.SET_TIME_ZONE",
"reason": "use.ohos.permission.SET_TIME_ZONE"
}
],
"abilities": [
{
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "ohos.acts.time.timetest.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
}
}
]
}
}
{
"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) 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 app from '@system.app'
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.addService('report', instrumentLog)
core.init()
// core.subscribeEvent('spec', instrumentLog)
// core.subscribeEvent('suite', instrumentLog)
// core.subscribeEvent('task', instrumentLog)
const configService = core.getDefaultService('config')
this.timeout = 30000
configService.setConfig(this)
require('../../test/List.test')
core.execute()
},
onReady() {
},
}
/*
* 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.
*/
require('./SystemTimeJsunit.test.js')
\ No newline at end of file
/*
* 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.
*/
// @ts-nocheck
import {
describe,
beforeAll,
beforeEach,
afterEach,
afterAll,
it,
expect,
} from "deccjsunit/index";
import systemTime from "@ohos.systemTime";
describe("TimeTest", function () {
console.log("start################################start");
/**
* @tc.number SUB_systemTime_getCurrentTime_JS_API_0001
* @tc.name Test systemTime.getCurrentTime
* @tc.desc Obtains the number of milliseconds that have elapsed since the Unix epoch.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it("SUB_systemTime_getCurrentTime_JS_API_0001", 0, async function (done) {
console.log("---------------UB_systemTime_getCurrentTime_JS_API_0001 start----------------");
systemTime.getCurrentTime(true, (error, data) => {
if (error) {
console.error(`failed to systemTime.getCurrentTime because ` + JSON.stringify(error));
expect().assertFail()
}
console.log(`systemTime.getCurrentTime success data : ` + JSON.stringify(data));
expect(data != null).assertEqual(true);
});
console.log("---------------SUB_systemTime_getRealActiveTime_JS_API_0100 end-----------------");
done();
});
/**
* @tc.number SUB_systemTime_getCurrentTime_JS_API_0002
* @tc.name Test systemTime.getCurrentTime
* @tc.desc Obtains the number of milliseconds that have elapsed since the Unix epoch.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it("SUB_systemTime_getCurrentTime_JS_API_0002", 0, async function (done) {
console.log("----------SUB_systemTime_getCurrentTime_JS_API_0002 start----------------");
systemTime.getCurrentTime(true).then((data) => {
console.log(`systemTime.getCurrentTime promise success data : ` + JSON.stringify(data));
expect(data != null).assertEqual(true);
}).catch(err => {
console.error(`failed to systemTime.getCurrentTime promise because ` + JSON.stringify(error));
expect().assertFail()
})
console.log("----------SUB_systemTime_getCurrentTime_JS_API_0002 end------------");
done();
});
/**
* @tc.number SUB_systemTime_getRealActiveTime_JS_API_0001
* @tc.name Test systemTime.getCurrentTime
* @tc.desc Obtains the number of milliseconds elapsed since the system was booted, not including deep sleep time.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it("SUB_systemTime_getRealActiveTime_JS_API_0001", 0, async function (done) {
console.log("---------------SUB_systemTime_getRealActiveTime_JS_API_0001 start----------------");
systemTime.getRealActiveTime(true, (error, data) => {
if (error) {
console.error(`failed to systemTime.getRealActiveTime because ` + JSON.stringify(error));
expect().assertFail()
}
console.log(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data));
expect(data != null).assertEqual(true);
});
console.log("---------------SUB_systemTime_getRealActiveTime_JS_API_0001 end-----------------");
done();
});
/**
* @tc.number SUB_systemTime_getRealActiveTime_JS_API_0002
* @tc.name Test systemTime.getCurrentTime
* @tc.desc Obtains the number of milliseconds elapsed since the system was booted, not including deep sleep time.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it("SUB_systemTime_getRealActiveTime_JS_API_0002", 0, async function (done) {
console.log("----------SUB_systemTime_getRealActiveTime_JS_API_0002 start----------------");
systemTime.getRealActiveTime(true).then((data) => {
onsole.log(`systemTime.getRealActiveTime promise success data : ` + JSON.stringify(data));
expect(data != null).assertEqual(true);
}).catch(err => {
console.error(`failed to systemTime.getRealActiveTime promise because ` + JSON.stringify(error));
expect().assertFail()
})
console.log("----------SUB_systemTime_getRealActiveTime_JS_API_0002 end------------");
done();
});
/**
* @tc.number SUB_systemTime_getRealTime_JS_API_0001
* @tc.name Test systemTime.getCurrentTime
* @tc.desc Obtains the number of milliseconds elapsed since the system was booted, including deep sleep time.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it("SUB_systemTime_getRealTime_JS_API_0001", 0, async function (done) {
console.log("---------------SUB_systemTime_getRealTime_JS_API_0001 start----------------");
systemTime.getRealTime(true, (error, data) => {
if (error) {
console.error(`failed to systemTime.getRealTime because ` + JSON.stringify(error));
expect().assertFail()
}
console.log(`systemTime.getRealTime success data : ` + JSON.stringify(data));
expect(data != null).assertEqual(true);
});
console.log("---------------SUB_systemTime_getRealTime_JS_API_0001 end-----------------");
done();
});
/**
* @tc.number SUB_systemTime_getRealTime_JS_API_0002
* @tc.name Test systemTime.getCurrentTime
* @tc.desc Obtains the number of milliseconds elapsed since the system was booted, not including deep sleep time.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it("SUB_systemTime_getRealTime_JS_API_0002", 0, async function (done) {
console.log("----------SUB_systemTime_getRealTime_JS_API_0002 start----------------");
systemTime.getRealTime(true).then((data) => {
console.log(`systemTime.getRealTime promise success data : ` + JSON.stringify(data));
expect(data != null).assertEqual(true);
}).catch(err => {
console.error(`failed to systemTime.getRealTime promise because ` + JSON.stringify(error));
expect().assertFail()
})
console.log("----------SUB_systemTime_getRealTime_JS_API_0002 end------------");
done();
});
});
\ No newline at end of file
/*
* 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.
*/
// @ts-nocheck
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import systemTime from '@ohos.systemTime'
describe('TimeTest', function(){
console.log("-------------------TimeTest start----------------------" );
/**
* @tc.number SUB_systemTime_setTime_JS_API_0100
* @tc.name Test systemTime.setTime
* @tc.desc Test systemTime_setTime API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_systemTime_setTime_JS_API_0100', 0, async function (done) {
console.log("SUB_systemTime_setTime_JS_API_0100 start")
systemTime.setTime(1526003846000)
.then(data =>{
console.log("setTime ===data " + data)
execpt(data).assertEqual(true)
}).catch(error => {
console.log("setTime ===error " + error)
execpt(0).assertLarger(1)
});
console.log('SUB_systemTime_setTime_JS_API_0100 end');
done()
})
/**
* @tc.number SUB_systemTime_setTime_JS_API_0200
* @tc.name Test systemTime.setTime Invalid value
* @tc.desc Test systemTime_setTime API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_systemTime_setTime_JS_API_0200', 0, async function (done) {
console.log("SUB_systemTime_setTime_JS_API_0200 start")
systemTime.setTime(15222)
.then(data => {
console.log("setTime ===data " + data)
expect(true).assertTrue();
}).catch(error => {
console.log("setTime ===error " + error)
execpt(0).assertLarger(1)
});
console.log('SUB_systemTime_setTime_JS_API_0200 end');
done()
})
/**
* @tc.number SUB_systemTime_setTime_JS_API_0300
* @tc.name Test systemTime.setTime3
* @tc.desc Test systemTime_setTime API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_systemTime_setTime_JS_API_0300', 0, async function (done) {
console.log("SUB_systemTime_setTime_JS_API_0300 start")
systemTime.setTime(1597156246000, (err, data) => {
if (err) {
console.log("setTime ===error: " + err);
expect().assertFail()
}else{
console.log("setTime ===data: " + data);
expect(true).assertTrue();
}
});
console.log('SUB_systemTime_setTime_JS_API_0300 end');
done()
})
/**
* @tc.number SUB_systemTime_setTime_JS_API_0400
* @tc.name Test systemTime.setTime4 Invalid value
* @tc.desc Test systemTime_setTime API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_systemTime_setTime_JS_API_0400', 0, async function (done) {
console.log("SUB_systemTime_setTime_JS_API_0400 start")
try{
systemTime.setTime(18, (err, data) => {
console.log("setTime ===data: " + data);
console.log("setTime ===error: " + err);
expect(true).assertTrue();
})}catch(error) {error => {
expect(1).assertLarger(0)
}
}
console.log('SUB_systemTime_setTime_JS_API_0400 end');
done()
})
/**
* @tc.number SUB_systemTime_setDate_JS_API_0100
* @tc.name Test systemTime.setDate Invalid value
* @tc.desc Test systemTime_setDate API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_systemTime_setDate_JS_API_0100', 0, async function (done) {
console.log("SUB_systemTime_setDate_JS_API_0100 start");
var data = new Date("October 13, 2020 11:13:00");
systemTime.setDate(1).then(data => {
console.log("setTime ===data " + data);
expect(true).assertTrue();
}).catch(error => {
console.log("setTime ===error " + error);
expect().assertFail()
});
done();
});
/**
* @tc.number SUB_systemTime_setDate_JS_API_0200
* @tc.name Test systemTime.setDate Invalid value
* @tc.desc Test systemTime_setDate API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_systemTime_setDate_JS_API_0200', 0, async function (done) {
console.log("SUB_systemTime_setDate_JS_API_0200 start");
systemTime.setDate(0).then(data => {
console.log("setTime ===data " + data);
expect(true).assertTrue();
}).catch(error => {
console.log("setTime ===error " + error);
expect().assertFail()
});
done();
});
/**
* @tc.number SUB_systemTime_setDate_JS_API_0300
* @tc.name Test systemTime.setDate Invalid value
* @tc.desc Test systemTime_setDate API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_systemTime_setDate_JS_API_0300', 0, async function (done) {
console.log("SUB_systemTime_setDate_JS_API_0300 start");
var data = new Date("October 13, 2020 11:13:00");
systemTime.setDate(data, (error, data) => {
if(error){
console.log("setTime ===error " + error);
expect().assertFail()
}else{
console.log("setTime ===data " + data);
expect(true).assertTrue();
}
});
done();
});
/**
* @tc.number SUB_systemTime_setTimezone_JS_API_0100
* @tc.name Test systemTime.setTimezone Invalid value
* @tc.desc Test systemTime_setTimezone API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_systemTime_setTimezone_JS_API_0100', 0, async function (done) {
console.log("SUB_systemTime_setTimezone_JS_API_0100 start");
systemTime.setTimezone('Asia, Shanghai').then(data => {
console.log("setTime ===data " + data)
expect().assertFail()
}).catch(error => {
console.log("setTime ===error " + error)
expect(true).assertTrue();
});
done();
});
/**
* @tc.number SUB_systemTime_setTimezone_JS_API_0200
* @tc.name Test systemTime.setTimezone Invalid value
* @tc.desc Test systemTime_setTimezone API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_systemTime_setTimezone_JS_API_0200', 0, async function (done) {
console.log("SUB_systemTime_setTimezone_JS_API_0200 start");
systemTime.setTimezone('Beijing,China').then(data => {
console.log("setTime ===data " + data)
expect().assertFail()
}).catch(error => {
console.log("setTime ===error " + error)
expect(true).assertTrue();
});
done();
});
/**
* @tc.number SUB_systemTime_setTimezone_JS_API_0300
* @tc.name Test systemTime.setTimezone Invalid value
* @tc.desc Test systemTime_setTimezone API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_systemTime_setTimezone_JS_API_0300', 0, async function (done) {
console.log("SUB_systemTime_setTimezone_JS_API_0300 start");
systemTime.setTimezone('Baker Island, U.S.A.').then(data => {
console.log("setTime ===data " + data)
expect().assertFail()
}).catch(error => {
console.log("setTime ===error " + error)
expect(true).assertTrue();
});
done();
});
})
{
"string": [
{
"name": "app_name",
"value": "JstimeTest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ No newline at end of file
# 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsTimerJSApiTest") {
hap_profile = "./src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
subsystem_name = "time"
part_name = "time_service"
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsTimerJSApiTest"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
{
"description": "Configuration for time js api Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "600000",
"package": "ohos.acts.time.timertest",
"shell-timeout": "600000"
},
"kits": [
{
"test-file-name": [
"ActsTimerJSApiTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "ohos.acts.time.timertest",
"vendor": "acts",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 7,
"target": 9
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.time.timertest",
"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.time.timertest.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
}
}
]
}
}
{
"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) 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 app from '@system.app'
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.addService('report', instrumentLog)
core.init()
// core.subscribeEvent('spec', instrumentLog)
// core.subscribeEvent('suite', instrumentLog)
// core.subscribeEvent('task', instrumentLog)
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../test/List.test')
core.execute()
},
onReady() {
},
}
/*
* 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.
*/
require('./SystemTimerJsunit.test.js')
\ No newline at end of file
/*
* 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 {describe, it, expect} from 'deccjsunit/index';
import systemTimer from '@ohos.systemTimer';
import WantAgent from '@ohos.wantAgent';
var wantAgentInfo = {
wants: [
{
deviceId: "deviceId",
bundleName: "com.neu.setResultOnAbilityResultTest1",
abilityName: "com.example.test.MainAbility",
action: "action1",
entities: ["entity1"],
type: "MIMETYPE",
uri: "key={true,true,false}",
parameters:
{
mykey0: 2222,
mykey1: [1, 2, 3],
mykey2: "[1, 2, 3]",
mykey3: "ssssssssssssssssssssssssss",
mykey4: [false, true, false],
mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"],
mykey6: true,
}
}
],
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0
}
describe('systemTimerTest', function () {
function isIntNum(val) {
return typeof val === 'number' && val % 1 === 0;
}
/**
* @tc.number SUB_systemTimer_createTimer_0000
* @tc.name systemTimer_createTimer_test_000
* @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_REALTIME, repeat = false (Promise)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
*/
it('systemTimer_createTimer_test_000', 0, async function (done) {
console.info("systemTimer_createTimer_test_000 start")
let options = {
type:systemTimer.TIMER_TYPE_REALTIME,
repeat:false
}
try {
console.info("systemTimer_createTimer_test_000 create timer")
let timerID = await systemTimer.createTimer(options);
expect(isIntNum(timerID)).assertTrue();
console.info('systemTimer_createTimer_test_000 has SUCCESS');
systemTimer.destroyTimer(timerID, function(e){
done();
});
}catch (e) {
console.info('systemTimer_createTimer_test_000 has failed for '+e);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_systemTimer_createTimer_0100
* @tc.name systemTimer_createTimer_test_001
* @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_REALTIME, repeat = false (callback)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
*/
it('systemTimer_createTimer_test_001', 0, async function (done) {
console.info("systemTimer_createTimer_test_001 start")
let options = {
type:systemTimer.TIMER_TYPE_REALTIME,
repeat:false
}
try {
console.info("systemTimer_createTimer_test_001 create timer")
systemTimer.createTimer(options, function(err, timerID){
expect(isIntNum(timerID)).assertTrue();
systemTimer.destroyTimer(timerID, function(e){
console.info('systemTimer_createTimer_test_001 has SUCCESS');
done();
});
});
}catch (e) {
console.info('systemTimer_createTimer_test_001 has failed for '+e);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_systemTimer_createTimer_0200
* @tc.name systemTimer_createTimer_test_002
* @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_WAKEUP, repeat = true, interval (Promise)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('systemTimer_createTimer_test_002', 2, async function (done) {
console.info("systemTimer_createTimer_test_002 start")
let options = {
type:systemTimer.TIMER_TYPE_WAKEUP,
repeat:true,
interval:5001
}
try {
console.info("systemTimer_createTimer_test_002 create timer")
let timerID = await systemTimer.createTimer(options);
expect(isIntNum(timerID)).assertTrue();
console.info('systemTimer_createTimer_test_002 has SUCCESS');
systemTimer.destroyTimer(timerID, function(e){
done();
});
}catch (e) {
console.info('systemTimer_createTimer_test_002 has failed for '+e);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_systemTimer_createTimer_0300
* @tc.name systemTimer_createTimer_test_003
* @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_WAKEUP, repeat = true, interval (callback)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('systemTimer_createTimer_test_003', 2, async function (done) {
console.info("systemTimer_createTimer_test_003 start")
let options = {
type:systemTimer.TIMER_TYPE_WAKEUP,
repeat:true,
interval:5001
}
try {
console.info("systemTimer_createTimer_test_003 create timer")
systemTimer.createTimer(options, function(err, timerID){
expect(isIntNum(timerID)).assertTrue();
systemTimer.destroyTimer(timerID, function(e){
console.info('systemTimer_createTimer_test_003 has SUCCESS');
done();
});
});
}catch (e) {
console.info('systemTimer_createTimer_test_003 has failed for '+e);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_systemTimer_createTimer_0400
* @tc.name systemTimer_createTimer_test_004
* @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_EXACT, repeat = false (Promise)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('systemTimer_createTimer_test_004', 2, async function (done) {
console.info("systemTimer_createTimer_test_004 start")
let options = {
type:systemTimer.TIMER_TYPE_EXACT,
repeat:false
}
try {
console.info("systemTimer_createTimer_test_004 create timer")
let timerID = await systemTimer.createTimer(options);
expect(isIntNum(timerID)).assertTrue();
console.info('systemTimer_createTimer_test_004 has SUCCESS');
systemTimer.destroyTimer(timerID, function(e){
done();
});
}catch (e) {
console.info('systemTimer_createTimer_test_004 has failed for '+e);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_systemTimer_createTimer_0500
* @tc.name systemTimer_createTimer_test_005
* @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_EXACT, repeat = false (callback)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('systemTimer_createTimer_test_005', 2, async function (done) {
console.info("systemTimer_createTimer_test_005 start")
let options = {
type:systemTimer.TIMER_TYPE_EXACT,
repeat:false,
}
try {
console.info("systemTimer_createTimer_test_005 create timer")
systemTimer.createTimer(options, function(err, timerID){
expect(isIntNum(timerID)).assertTrue();
systemTimer.destroyTimer(timerID, function(e){
console.info('systemTimer_createTimer_test_005 has SUCCESS');
done();
});
});
}catch (e) {
console.info('systemTimer_createTimer_test_005 has failed for '+e);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_systemTimer_createTimer_0600
* @tc.name systemTimer_createTimer_test_006
* @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_IDLE, repeat = false, wantAgent (Promise)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('systemTimer_createTimer_test_006', 2, async function (done) {
console.info("systemTimer_createTimer_test_006 start")
let wantAgent = await WantAgent.getWantAgent(wantAgentInfo);
let options = {
type:systemTimer.TIMER_TYPE_IDLE,
repeat:false,
wantAgent:wantAgent
}
try {
console.info("systemTimer_createTimer_test_006 create timer")
let timerID = await systemTimer.createTimer(options);
expect(isIntNum(timerID)).assertTrue();
console.info('systemTimer_createTimer_test_006 has SUCCESS');
systemTimer.destroyTimer(timerID, function(e){
done();
});
}catch (e) {
console.info('systemTimer_createTimer_test_006 has failed for '+e);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_systemTimer_createTimer_0700
* @tc.name systemTimer_createTimer_test_007
* @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_IDLE, repeat = false, wantAgent(callback)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('systemTimer_createTimer_test_007', 2, async function (done) {
console.info("systemTimer_createTimer_test_007 start")
let wantAgent = await WantAgent.getWantAgent(wantAgentInfo);
let options = {
type:systemTimer.TIMER_TYPE_IDLE,
repeat:false,
wantAgent:wantAgent
}
try {
console.info("systemTimer_createTimer_test_007 create timer")
systemTimer.createTimer(options, function(err, timerID){
expect(isIntNum(timerID)).assertTrue();
systemTimer.destroyTimer(timerID, function(e){
console.info('systemTimer_createTimer_test_007 has SUCCESS');
done();
});
});
}catch (e) {
console.info('systemTimer_createTimer_test_007 has failed for '+e);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_systemTimer_createTimer_0800
* @tc.name systemTimer_createTimer_test_008
* @tc.desc Test createTimer() interfaces, type = 'TIMER_TYPE_REALTIME'(String)(Promise)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('systemTimer_createTimer_test_008', 2, async function (done) {
console.info("systemTimer_createTimer_test_008 start")
let options = {
type:'TIMER_TYPE_REALTIME',
repeat:false
}
try {
console.info("systemTimer_createTimer_test_008 create timer")
await systemTimer.createTimer(options);
expect(false).assertTrue();
}catch (e) {
console.info('systemTimer_createTimer_test_008 has failed for '+e);
expect(e.toString().indexOf('Wrong argument type') != -1).assertTrue();
done();
}
});
/**
* @tc.number SUB_systemTimer_createTimer_0900
* @tc.name systemTimer_createTimer_test_009
* @tc.desc Test createTimer() interfaces, type = 'TIMER_TYPE_REALTIME'(String)(callback)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('systemTimer_createTimer_test_009', 2, async function (done) {
console.info("systemTimer_createTimer_test_009 start")
let options = {
type:'TIMER_TYPE_REALTIME',
repeat:false
}
try {
console.info("systemTimer_createTimer_test_009 create timer")
systemTimer.createTimer(options, function(err, timerID){
console.info("systemTimer_createTimer_test_009 failed")
});
expect(false).assertTrue();
}catch (e) {
console.info('systemTimer_createTimer_test_009 has failed for '+e);
expect(e.toString().indexOf('Wrong argument type') != -1).assertTrue();
done();
}
});
/**
* @tc.number SUB_systemTimer_createTimer_1000
* @tc.name systemTimer_createTimer_test_010
* @tc.desc Test createTimer() interfaces, type = null(Promise)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('systemTimer_createTimer_test_010', 2, async function (done) {
console.info("systemTimer_createTimer_test_010 start")
let options = {
type:null,
repeat:false
}
try {
console.info("systemTimer_createTimer_test_010 create timer")
await systemTimer.createTimer(options);
expect(false).assertTrue();
}catch (e) {
console.info('systemTimer_createTimer_test_010 has failed for '+e);
expect(e.toString().indexOf('Wrong argument type') != -1).assertTrue();
done();
}
});
/**
* @tc.number SUB_systemTimer_createTimer_1100
* @tc.name systemTimer_createTimer_test_011
* @tc.desc Test createTimer() interfaces, type = null(callback)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('systemTimer_createTimer_test_011', 2, async function (done) {
console.info("systemTimer_createTimer_test_011 start")
let options = {
type:null,
repeat:false
}
try {
console.info("systemTimer_createTimer_test_011 create timer")
systemTimer.createTimer(options, function(err, timerID){
console.info("systemTimer_createTimer_test_011 failed ")
});
expect(false).assertTrue();
}catch (e) {
console.info('systemTimer_createTimer_test_011 has failed for '+e);
expect(e.toString().indexOf('Wrong argument type') != -1).assertTrue();
done();
}
});
/**
* @tc.number SUB_systemTimer_createTimer_1200
* @tc.name systemTimer_createTimer_test_012
* @tc.desc Test createTimer() interfaces, type = undefined(Promise)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('systemTimer_createTimer_test_012', 2, async function (done) {
console.info("systemTimer_createTimer_test_012 start")
let options = {
type:undefined,
repeat:false
}
try {
console.info("systemTimer_createTimer_test_012 create timer")
await systemTimer.createTimer(options);
expect(false).assertTrue();
}catch (e) {
console.info('systemTimer_createTimer_test_012 has failed for '+e);
expect(e.toString().indexOf('Wrong argument type') != -1).assertTrue();
done();
}
});
/**
* @tc.number SUB_systemTimer_createTimer_1300
* @tc.name systemTimer_createTimer_test_013
* @tc.desc Test createTimer() interfaces, type = undefined(callback)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('systemTimer_createTimer_test_013', 2, async function (done) {
console.info("systemTimer_createTimer_test_013 start")
let options = {
type:undefined,
repeat:false
}
try {
console.info("systemTimer_createTimer_test_013 create timer")
systemTimer.createTimer(options, function(err, timerID){
console.info("systemTimer_createTimer_test_013 failed ")
});
expect(false).assertTrue();
}catch (e) {
console.info('systemTimer_createTimer_test_013 has failed for '+e);
expect(e.toString().indexOf('Wrong argument type') != -1).assertTrue();
done();
}
});
/**
* @tc.number SUB_systemTimer_createTimer_1400
* @tc.name systemTimer_createTimer_test_014
* @tc.desc Test createTimer() interfaces, no parameters(Promise)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('systemTimer_createTimer_test_014', 2, async function (done) {
console.info("systemTimer_createTimer_test_014 start")
try {
console.info("systemTimer_createTimer_test_014 create timer")
await systemTimer.createTimer();
expect(false).assertTrue();
}catch (e) {
console.info('systemTimer_createTimer_test_014 has failed for '+e);
expect(e.toString().indexOf('Wrong number of arguments') != -1).assertTrue();
done();
}
});
/**
* @tc.number SUB_systemTimer_createTimer_1500
* @tc.name systemTimer_createTimer_test_015
* @tc.desc Test createTimer() interfaces, repeat = 'false'(String) (Promise)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('systemTimer_createTimer_test_015', 2, async function (done) {
console.info("systemTimer_createTimer_test_015 start")
let options = {
type:systemTimer.TIMER_TYPE_REALTIME,
repeat:'false'
}
try {
console.info("systemTimer_createTimer_test_015 create timer")
await systemTimer.createTimer(options);
expect(false).assertTrue();
}catch (e) {
console.info('systemTimer_createTimer_test_015 has failed for '+e);
expect(e.toString().indexOf('Wrong argument type') != -1).assertTrue();
done();
}
});
/**
* @tc.number SUB_systemTimer_createTimer_1600
* @tc.name systemTimer_createTimer_test_016
* @tc.desc Test createTimer() interfaces, repeat = 'false'(String)(callback)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('systemTimer_createTimer_test_016', 2, async function (done) {
console.info("systemTimer_createTimer_test_016 start")
let options = {
type:systemTimer.TIMER_TYPE_REALTIME,
repeat:'false'
}
try {
console.info("systemTimer_createTimer_test_016 create timer")
systemTimer.createTimer(options, function(err, timerID){
console.info("systemTimer_createTimer_test_016 failed ")
});
expect(false).assertTrue();
}catch (e) {
console.info('systemTimer_createTimer_test_016 has failed for '+e);
expect(e.toString().indexOf('Wrong argument type') != -1).assertTrue();
done();
}
});
/**
* @tc.number SUB_systemTimer_createTimer_1700
* @tc.name systemTimer_createTimer_test_017
* @tc.desc Test createTimer() interfaces, repeat = 0(number) (Promise)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('systemTimer_createTimer_test_017', 2, async function (done) {
console.info("systemTimer_createTimer_test_017 start")
let options = {
type:systemTimer.TIMER_TYPE_REALTIME,
repeat:0
}
try {
console.info("systemTimer_createTimer_test_017 create timer")
await systemTimer.createTimer(options);
expect(false).assertTrue();
}catch (e) {
console.info('systemTimer_createTimer_test_017 has failed for '+e);
expect(e.toString().indexOf('Wrong argument type') != -1).assertTrue();
done();
}
});
/**
* @tc.number SUB_systemTimer_createTimer_1800
* @tc.name systemTimer_createTimer_test_018
* @tc.desc Test createTimer() interfaces, repeat = 0(number)(callback)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('systemTimer_createTimer_test_018', 2, async function (done) {
console.info("systemTimer_createTimer_test_018 start")
let options = {
type:systemTimer.TIMER_TYPE_REALTIME,
repeat:0
}
try {
console.info("systemTimer_createTimer_test_018 create timer")
systemTimer.createTimer(options, function(err, timerID){
console.info("systemTimer_createTimer_test_018 failed ")
});
expect(false).assertTrue();
}catch (e) {
console.info('systemTimer_createTimer_test_018 has failed for '+e);
expect(e.toString().indexOf('Wrong argument type') != -1).assertTrue();
done();
}
});
/**
* @tc.number SUB_systemTimer_startTimer_0100
* @tc.name systemTimer_startTimer_test_001
* @tc.desc Test startTimer() interfaces, normal call(callback)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
*/
it('systemTimer_startTimer_test_001', 0, async function (done) {
console.info("systemTimer_startTimer_test_001 start")
let options = {
type:systemTimer.TIMER_TYPE_IDLE,
repeat:false,
}
let timerID = await systemTimer.createTimer(options);
expect(isIntNum(timerID)).assertTrue();
let triggerTime = 5000;
try {
console.info("systemTimer_startTimer_test_001 start timer")
systemTimer.startTimer(timerID, triggerTime, function(err, data){
systemTimer.stopTimer(timerID, function(err, data){
systemTimer.destroyTimer(timerID, function(err, data){
console.info('systemTimer_startTimer_test_001 has SUCCESS');
done();
});
});
});
}catch (e) {
console.info('systemTimer_startTimer_test_001 has failed for '+e);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_systemTimer_startTimer_0300
* @tc.name systemTimer_startTimer_test_003
* @tc.desc Test startTimer() interfaces, timer = 0(callback)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('systemTimer_startTimer_test_003', 2, async function (done) {
console.info("systemTimer_startTimer_test_003 start")
let timerID = 0;
let triggerTime = 5000;
try {
console.info("systemTimer_startTimer_test_003 start timer")
systemTimer.startTimer(timerID, triggerTime, function(err, data){
systemTimer.stopTimer(timerID, function(err, data){
systemTimer.destroyTimer(timerID, function(err, data){
console.info('systemTimer_startTimer_test_003 has SUCCESS');
done();
});
});
});
}catch (e) {
console.info('systemTimer_startTimer_test_003 has failed for '+e);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_systemTimer_startTimer_0500
* @tc.name systemTimer_startTimer_test_005
* @tc.desc Test startTimer() interfaces, triggerTime = -5000(callback)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('systemTimer_startTimer_test_005', 2, async function (done) {
console.info("systemTimer_startTimer_test_005 start")
let options = {
type:systemTimer.TIMER_TYPE_IDLE,
repeat:false,
}
let timerID = await systemTimer.createTimer(options);
expect(isIntNum(timerID)).assertTrue();
let triggerTime = -5000;
try {
console.info("systemTimer_startTimer_test_005 start timer")
systemTimer.startTimer(timerID, triggerTime, function(err, data){
console.info('systemTimer_startTimer_test_005 failed');
});
expect(false).assertTrue();
}catch (e) {
console.info('systemTimer_startTimer_test_005 has failed for '+e);
expect(e.toString().indexOf('Wrong argument triggerTime') != -1).assertTrue();
done();
}
});
/**
* @tc.number SUB_systemTimer_stopTimer_0100
* @tc.name systemTimer_stopTimer_test_001
* @tc.desc Test stopTimer() interfaces, normal call(callback)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
*/
it('systemTimer_stopTimer_test_001', 0, async function (done) {
console.info("systemTimer_stopTimer_test_001 start")
let options = {
type:systemTimer.TIMER_TYPE_IDLE,
repeat:false,
}
let timerID = await systemTimer.createTimer(options);
expect(isIntNum(timerID)).assertTrue();
systemTimer.startTimer(timerID,5000);
try {
console.info("systemTimer_stopTimer_test_001 stop timer")
systemTimer.stopTimer(timerID, function(err, data){
systemTimer.destroyTimer(timerID, function(err, data){
console.info('systemTimer_stopTimer_test_001 has SUCCESS');
done();
});
});
}catch (e) {
console.info('systemTimer_stopTimer_test_001 has failed for '+e);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_systemTimer_stopTimer_0400
* @tc.name systemTimer_stopTimer_test_004
* @tc.desc Test stopTimer() interfaces, timerID is not defined(callback)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('systemTimer_stopTimer_test_004', 2, async function (done) {
console.info("systemTimer_stopTimer_test_004 start")
try {
console.info("systemTimer_stopTimer_test_004 stop timer")
systemTimer.stopTimer(timerID, function(err, data){
console.info('systemTimer_stopTimer_test_004 failed');
});
expect(false).assertTrue();
}catch (e) {
console.info('systemTimer_stopTimer_test_004 has failed for '+e);
expect(e.toString().indexOf('timerID is not defined') != -1).assertTrue();
done();
}
});
/**
* @tc.number SUB_systemTimer_destroyTimer_0100
* @tc.name systemTimer_destroyTimer_test_001
* @tc.desc Test destroyTimer() interfaces, normal call(callback)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
*/
it('systemTimer_destroyTimer_test_001', 0, async function (done) {
console.info("systemTimer_destroyTimer_test_001 start")
let options = {
type:systemTimer.TIMER_TYPE_IDLE,
repeat:false,
}
let timerID = await systemTimer.createTimer(options);
expect(isIntNum(timerID)).assertTrue();
try {
console.info("systemTimer_destroyTimer_test_001 destroy timer")
systemTimer.destroyTimer(timerID, function(err, data){
console.info('systemTimer_destroyTimer_test_001 has SUCCESS');
done();
});
}catch (e) {
console.info('systemTimer_destroyTimer_test_001 has failed for '+e);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_systemTimer_destroyTimer_0400
* @tc.name systemTimer_destroyTimer_test_004
* @tc.desc Test destroyTimer() interfaces, timerID is not defined(callback)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('systemTimer_destroyTimer_test_004', 2, async function (done) {
console.info("systemTimer_destroyTimer_test_004 start")
try {
console.info("systemTimer_destroyTimer_test_004 destroy timer")
systemTimer.destroyTimer(timerID, function(err, data){
console.info('systemTimer_destroyTimer_test_004 failed');
});
expect(false).assertTrue();
}catch (e) {
console.info('systemTimer_destroyTimer_test_004 has failed for '+e);
expect(e.toString().indexOf('timerID is not defined') != -1).assertTrue();
done();
}
});
});
\ No newline at end of file
{
"app": {
"bundleName": "com.acts.time.test",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"distributedNotificationEnabled": true,
"keepAlive":true,
"singleUser":true,
"minAPIVersion":9,
"targetAPIVersion":9
}
}
{
"string": [
{
"name": "app_name",
"value": "JstimerTest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "ActsTimeAPITest"
}
]
}
# Copyright (C) 2022 Huawei Device Co., Ltd.
# 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
......@@ -13,21 +13,31 @@
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsTimeJSApiTest") {
hap_profile = "./src/main/config.json"
ohos_js_hap_suite("ActsTimeAPITest") {
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
":time_assets",
":time_resources",
]
ets2abc = true
js_build_mode = "debug"
subsystem_name = "time"
part_name = "time_service"
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsTimeJSApiTest"
hap_name = "ActsTimeAPITest"
hap_profile = "entry/src/main/module.json"
certificate_profile = "signature/ActsTimeAPITest.p7b"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./src/main/js/default"
ohos_app_scope("time_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("time_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
ohos_resources("time_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":time_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "180000",
"bundle-name": "com.acts.time.test",
"module-name": "entry_test",
"shell-timeout": "180000",
"testcase-timeout": 600000
},
"kits": [{
"test-file-name": [
"ActsTimeAPITest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}]
}
import hilog from '@ohos.hilog';
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'AbilityStage onCreate');
}
}
\ No newline at end of file
import hilog from '@ohos.hilog';
import Window from '@ohos.window';
import { Hypium } from '@ohos/hypium';
import testsuite from '../test/List.test';
import Ability from '@ohos.application.Ability';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:' + JSON.stringify(launchParam) ?? '');
var abilityDelegator: any;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
var abilityDelegatorArguments: any;
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments();
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
if (abilityDelegator != undefined && abilityDelegatorArguments != undefined) {
hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!');
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite);
} else {
hilog.info(0x0000, 'testTag', '%{public}s', 'abilityDelegator or abilityDelegatorArguments is undefined!!!');
}
}
onDestroy() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
}
onWindowStageCreate(windowStage: Window.WindowStage) {
// Main window is created, set main page for this ability
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
windowStage.loadContent('pages/index', (err, data) => {
if (err.code) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR);
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
}
onForeground() {
// Ability has brought to foreground
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
}
onBackground() {
// Ability has back to background
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
}
}
import hilog from '@ohos.hilog';
import TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${targetParams} ${key} ${parameters[key]}`
}
}
return targetParams.trim()
}
async function onAbilityCreateCallback() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback');
}
async function addAbilityMonitorCallback(err: any) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '');
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ');
}
async onRun() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run');
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a MainAbility ' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters['-D']
if (debug == 'true')
{
cmd += ' -D'
}
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd);
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? '');
})
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end');
}
}
\ No newline at end of file
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
// @ts-nocheck
/**
* 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
......@@ -12,12 +14,27 @@
* 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');
import hilog from '@ohos.hilog';
@Entry
@Component
struct Index {
aboutToAppear() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear');
}
@State message: string = 'TIME ETS TEST'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
};
.height('100%')
}
}
\ 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");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
......@@ -12,12 +12,10 @@
* 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');
}
};
import systemTimeJsunit from './systemTimeTest';
import systemTimerJsunit from './systemTimer.test';
export default function testsuite() {
systemTimerJsunit();
systemTimeJsunit();
}
\ No newline at end of file
// @ts-nocheck
/*
* 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 {describe, it, expect} from "hypium/index"
import systemTime from "@ohos.systemTime";
export default function systemTimeJsunit() {
describe('systemTimeTest', function () {
console.info('--------------------systemTimeTest start-----------------------');
/**
* @tc.number SUB_systemTime_getCurrentTime_JS_API_0001
* @tc.name Test systemTime.getCurrentTime
* @tc.desc Obtains the number of milliseconds that have elapsed since the Unix epoch.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it("SUB_systemTime_getCurrentTime_JS_API_0001", 0, async function (done) {
console.info("---------------UB_systemTime_getCurrentTime_JS_API_0001 start----------------");
systemTime.getCurrentTime(true, (error, data) => {
if (error) {
console.error(`failed to systemTime.getCurrentTime because ` + JSON.stringify(error));
expect().assertFail();
};
console.info(`systemTime.getCurrentTime success data : ` + JSON.stringify(data));
expect(data != null).assertEqual(true);
});
console.info("---------------SUB_systemTime_getRealActiveTime_JS_API_0100 end-----------------");
done();
});
/**
* @tc.number SUB_systemTime_getCurrentTime_JS_API_0002
* @tc.name Test systemTime.getCurrentTime
* @tc.desc Obtains the number of milliseconds that have elapsed since the Unix epoch.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it("SUB_systemTime_getCurrentTime_JS_API_0002", 0, async function (done) {
console.info("----------SUB_systemTime_getCurrentTime_JS_API_0002 start----------------");
systemTime.getCurrentTime(true).then((data) => {
console.info(`systemTime.getCurrentTime promise success data : ` + JSON.stringify(data));
expect(data != null).assertEqual(true);
}).catch(err => {
console.error(`failed to systemTime.getCurrentTime promise because ` + JSON.stringify(error));
expect().assertFail()
});
console.info("----------SUB_systemTime_getCurrentTime_JS_API_0002 end------------");
done();
});
/**
* @tc.number SUB_systemTime_getRealActiveTime_JS_API_0001
* @tc.name Test systemTime.getCurrentTime
* @tc.desc Obtains the number of milliseconds elapsed since the system was booted, not including deep sleep time.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it("SUB_systemTime_getRealActiveTime_JS_API_0001", 0, async function (done) {
console.info("---------------SUB_systemTime_getRealActiveTime_JS_API_0001 start----------------");
systemTime.getRealActiveTime(true, (error, data) => {
if (error) {
console.error(`failed to systemTime.getRealActiveTime because ` + JSON.stringify(error));
expect().assertFail()
};
console.info(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data));
expect(data != null).assertEqual(true);
});
console.info("---------------SUB_systemTime_getRealActiveTime_JS_API_0001 end-----------------");
done();
});
/**
* @tc.number SUB_systemTime_getRealActiveTime_JS_API_0002
* @tc.name Test systemTime.getCurrentTime
* @tc.desc Obtains the number of milliseconds elapsed since the system was booted, not including deep sleep time.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it("SUB_systemTime_getRealActiveTime_JS_API_0002", 0, async function (done) {
console.info("----------SUB_systemTime_getRealActiveTime_JS_API_0002 start----------------");
systemTime.getRealActiveTime(true).then((data) => {
onsole.log(`systemTime.getRealActiveTime promise success data : ` + JSON.stringify(data));
expect(data != null).assertEqual(true);
}).catch(err => {
console.error(`failed to systemTime.getRealActiveTime promise because ` + JSON.stringify(error));
expect().assertFail()
});
console.info("----------SUB_systemTime_getRealActiveTime_JS_API_0002 end------------");
done();
});
/**
* @tc.number SUB_systemTime_getRealTime_JS_API_0001
* @tc.name Test systemTime.getCurrentTime
* @tc.desc Obtains the number of milliseconds elapsed since the system was booted, including deep sleep time.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it("SUB_systemTime_getRealTime_JS_API_0001", 0, async function (done) {
console.info("---------------SUB_systemTime_getRealTime_JS_API_0001 start----------------");
systemTime.getRealTime(true, (error, data) => {
if (error) {
console.error(`failed to systemTime.getRealTime because ` + JSON.stringify(error));
expect().assertFail()
};
console.info(`systemTime.getRealTime success data : ` + JSON.stringify(data));
expect(data != null).assertEqual(true);
});
console.info("---------------SUB_systemTime_getRealTime_JS_API_0001 end-----------------");
done();
});
/**
* @tc.number SUB_systemTime_getRealTime_JS_API_0002
* @tc.name Test systemTime.getCurrentTime
* @tc.desc Obtains the number of milliseconds elapsed since the system was booted, not including deep sleep time.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it("SUB_systemTime_getRealTime_JS_API_0002", 0, async function (done) {
console.info("----------SUB_systemTime_getRealTime_JS_API_0002 start----------------");
systemTime.getRealTime(true).then((data) => {
console.info(`systemTime.getRealTime promise success data : ` + JSON.stringify(data));
expect(data != null).assertEqual(true);
}).catch(err => {
console.error(`failed to systemTime.getRealTime promise because ` + JSON.stringify(error));
expect().assertFail();
});
console.info("----------SUB_systemTime_getRealTime_JS_API_0002 end------------");
done();
});
/**
* @tc.number SUB_systemTime_setTime_JS_API_0100
* @tc.name Test systemTime.setTime
* @tc.desc Test systemTime_setTime API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_systemTime_setTime_JS_API_0100', 0, async function (done) {
console.info("SUB_systemTime_setTime_JS_API_0100 start");
systemTime.setTime(1526003846000)
.then(data =>{
console.info("setTime ===data " + data);
expect(data).assertEqual(true)
}).catch(error => {
console.info("setTime ===error " + error);
expect(0).assertLarger(1)
});
console.info('SUB_systemTime_setTime_JS_API_0100 end');
done();
});
/**
* @tc.number SUB_systemTime_setTime_JS_API_0200
* @tc.name Test systemTime.setTime Invalid value
* @tc.desc Test systemTime_setTime API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_systemTime_setTime_JS_API_0200', 0, async function (done) {
console.info("SUB_systemTime_setTime_JS_API_0200 start");
systemTime.setTime(15222)
.then(data => {
console.info("setTime ===data " + data);
expect(true).assertTrue();
}).catch(error => {
console.info("setTime ===error " + error);
expect(0).assertLarger(1)
});
console.info('SUB_systemTime_setTime_JS_API_0200 end');
done();
});
/**
* @tc.number SUB_systemTime_setTime_JS_API_0300
* @tc.name Test systemTime.setTime3
* @tc.desc Test systemTime_setTime API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_systemTime_setTime_JS_API_0300', 0, async function (done) {
console.info("SUB_systemTime_setTime_JS_API_0300 start");
systemTime.setTime(1597156246000, (err, data) => {
if (err) {
console.info("setTime ===error: " + err);
expect().assertFail()
}else{
console.info("setTime ===data: " + data);
expect(true).assertTrue();
};
});
console.info('SUB_systemTime_setTime_JS_API_0300 end');
done();
});
/**
* @tc.number SUB_systemTime_setTime_JS_API_0400
* @tc.name Test systemTime.setTime4 Invalid value
* @tc.desc Test systemTime_setTime API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_systemTime_setTime_JS_API_0400', 0, async function (done) {
console.info("SUB_systemTime_setTime_JS_API_0400 start");
try{
systemTime.setTime(18, (err, data) => {
console.info("setTime ===data: " + data);
console.info("setTime ===error: " + err);
expect(true).assertTrue();
})}catch(error) {error => {
expect(1).assertLarger(0);
};
};
console.info('SUB_systemTime_setTime_JS_API_0400 end');
done();
});
/**
* @tc.number SUB_systemTime_setDate_JS_API_0100
* @tc.name Test systemTime.setDate Invalid value
* @tc.desc Test systemTime_setDate API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_systemTime_setDate_JS_API_0100', 0, async function (done) {
console.info("SUB_systemTime_setDate_JS_API_0100 start");
var data = new Date("October 13, 2020 11:13:00");
systemTime.setDate(1).then(data => {
console.info("setTime ===data " + data);
expect(true).assertTrue();
}).catch(error => {
console.info("setTime ===error " + error);
expect().assertFail();
});
done();
});
/**
* @tc.number SUB_systemTime_setDate_JS_API_0200
* @tc.name Test systemTime.setDate Invalid value
* @tc.desc Test systemTime_setDate API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_systemTime_setDate_JS_API_0200', 0, async function (done) {
console.info("SUB_systemTime_setDate_JS_API_0200 start");
systemTime.setDate(0).then(data => {
console.info("setTime ===data " + data);
expect(true).assertTrue();
}).catch(error => {
console.info("setTime ===error " + error);
expect().assertFail();
});
done();
});
/**
* @tc.number SUB_systemTime_setDate_JS_API_0300
* @tc.name Test systemTime.setDate Invalid value
* @tc.desc Test systemTime_setDate API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_systemTime_setDate_JS_API_0300', 0, async function (done) {
console.info("SUB_systemTime_setDate_JS_API_0300 start");
var data = new Date("October 13, 2020 11:13:00");
systemTime.setDate(data, (error, data) => {
if(error){
console.info("setTime ===error " + error);
expect().assertFail();
}else{
console.info("setTime ===data " + data);
expect(true).assertTrue();
};
});
done();
});
/**
* @tc.number SUB_systemTime_setTimezone_JS_API_0100
* @tc.name Test systemTime.setTimezone Invalid value
* @tc.desc Test systemTime_setTimezone API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_systemTime_setTimezone_JS_API_0100', 0, async function (done) {
console.info("SUB_systemTime_setTimezone_JS_API_0100 start");
systemTime.setTimezone('Asia, Shanghai').then(data => {
console.info("setTime ===data " + data);
expect().assertFail();
}).catch(error => {
console.info("setTime ===error " + error);
expect(true).assertTrue();
});
done();
});
/**
* @tc.number SUB_systemTime_setTimezone_JS_API_0200
* @tc.name Test systemTime.setTimezone Invalid value
* @tc.desc Test systemTime_setTimezone API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_systemTime_setTimezone_JS_API_0200', 0, async function (done) {
console.info("SUB_systemTime_setTimezone_JS_API_0200 start");
systemTime.setTimezone('Beijing,China').then(data => {
console.info("setTime ===data " + data);
expect().assertFail();
}).catch(error => {
console.info("setTime ===error " + error);
expect(true).assertTrue();
});
done();
});
/**
* @tc.number SUB_systemTime_setTimezone_JS_API_0300
* @tc.name Test systemTime.setTimezone Invalid value
* @tc.desc Test systemTime_setTimezone API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_systemTime_setTimezone_JS_API_0300', 0, async function (done) {
console.info("SUB_systemTime_setTimezone_JS_API_0300 start");
systemTime.setTimezone('Baker Island, U.S.A.').then(data => {
console.info("setTime ===data " + data);
expect().assertFail();
}).catch(error => {
console.info("setTime ===error " + error);
expect(true).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 WantAgent from '@ohos.wantAgent';
import systemTimer from "@ohos.systemTimer";
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
export default function systemTimerTest() {
describe('systemTimerTest', function () {
console.info('systemTimer Test start');
//wantAgent对象
var wantAgent;
//WantAgentInfo对象
let wantAgentInfo = {
wants: [
{
bundleName: "com.acts.time.test",
abilityName: "MainAbility"
}
],
operationType: WantAgent.OperationType.SEND_COMMON_EVENT,
requestCode: 0,
wantAgentFlags:[WantAgent.WantAgentFlags.NO_BUILD_FLAG]
}
let interval_time = 5000;
let globalTimerID = undefined;
/**
* beforeAll: Prerequisites at the test suite level, which are executed before the test suite is executed.
*/
beforeAll(function () {
console.info('beforeAll: Prerequisites are executed.');
WantAgent.getWantAgent(wantAgentInfo)
.then((data) => {
if ( data != undefined || data != null) {
console.info('beforeAll: success to get wantAgent: ' + typeof(data));
wantAgent = data;
}
})
.catch(error => {
console.error('beforeAll: failed to get wantAgent!');
});
});
/**
* beforeEach: Prerequisites at the test case level, which are executed before each test case is executed.
*/
beforeEach(function () {
console.info('beforeEach: Prerequisites is executed.');
});
/**
* afterEach: Test case-level clearance conditions, which are executed after each test case is executed.
*/
afterEach(function () {
console.info('afterEach: Test case-level clearance conditions is executed.');
});
/**
* afterAll: Test suite-level cleanup condition, which is executed after the test suite is executed.
*/
afterAll(function () {
console.info('afterAll: Test suite-level cleanup condition is executed.');
});
/**
* @tc.number SUB_time_systemTimer_createTimer_0000
* @tc.name SUB_time_systemTimer_createTimer_0000
* @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_REALTIME, repeat = false (Callback)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_time_systemTimer_createTimer_0000', 0, async function (done) {
console.info('SUB_time_systemTimer_createTimer_0000 start.');
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
repeat: false
};
try {
console.info('SUB_time_systemTimer_createTimer_0000 create timer.');
systemTimer.createTimer(options, function (err, timerID) {
if (err) {
// 处理业务逻辑错误
expect().assertTrue();
done();
}
console.info('SUB_time_systemTimer_createTimer_0000 timerID: ' + timerID);
globalTimerID = timerID;
expect(Number.isInteger(timerID)).assertTrue();
done();
});
} catch (err) {
// 捕获参数错误
console.info('SUB_time_systemTimer_createTimer_0000 has failed for ' + err);
expect().assertTrue();
done();
}
});
/**
* @tc.number SUB_time_systemTimer_createTimer_0001
* @tc.name SUB_time_systemTimer_createTimer_0001
* @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_REALTIME, repeat = true (callback)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_time_systemTimer_createTimer_0001', 0, async function (done) {
console.info('SUB_time_systemTimer_createTimer_0001 start.');
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
repeat: false
}
try {
systemTimer.createTimer(options, function (err, timerID) {
if (err) {
console.info('SUB_time_systemTimer_createTimer_0001 wrong since ' + err.code);
expect().assertTrue();
done();
}
console.info('SUB_time_systemTimer_createTimer_0001 timerID: ' + timerID);
expect(Number.isInteger(timerID)).assertTrue();
done();
});
} catch (e) {
console.info('SUB_time_systemTimer_createTimer_0001 arv wrong since ' + e.code);
expect().assertTrue();
done();
}
});
/**
* @tc.number SUB_time_systemTimer_createTimer_0002
* @tc.name SUB_time_systemTimer_createTimer_0002
* @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_WAKEUP, repeat = true, interval (Callback)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_time_systemTimer_createTimer_0002', 2, async function (done) {
console.info("SUB_time_systemTimer_createTimer_0002 start")
WantAgent.getBundleName(wantAgent, (err, data)=>{
console.info('SUB_time_systemTimer_createTimer_0002 BundleName: ' + data);
})
let options = {
type: systemTimer.TIMER_TYPE_WAKEUP,
repeat: true,
wantAgent: wantAgent,
interval: interval_time
}
try {
console.info("SUB_time_systemTimer_createTimer_0002 create timer")
systemTimer.createTimer(options, function (err, timerID) {
if (err) {
console.info('SUB_time_systemTimer_createTimer_0002 wrong since ' + err.code);
expect().assertTrue();
done();
}
console.info('SUB_time_systemTimer_createTimer_0002 timerID: ' + timerID);
expect(Number.isInteger(timerID)).assertTrue();
done();
});
} catch (e) {
console.info('SUB_time_systemTimer_createTimer_0002 arv wrong since ' + e);
expect().assertTrue();
done();
}
});
/**
* @tc.number SUB_time_systemTimer_createTimer_0003
* @tc.name SUB_time_systemTimer_createTimer_0003
* @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_EXACT, repeat = false (Callback)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_time_systemTimer_createTimer_0003', 2, async function (done) {
console.info("SUB_time_systemTimer_createTimer_0003 start")
let options = {
type: systemTimer.TIMER_TYPE_EXACT,
repeat: false
}
try {
console.info("SUB_time_systemTimer_createTimer_0003 create timer")
systemTimer.createTimer(options, function (err, timerID) {
if (err) {
console.info('SUB_time_systemTimer_createTimer_0003 wrong since ' + err.code);
expect().assertTrue();
done();
}
expect(Number.isInteger(timerID)).assertTrue();
done();
});
} catch (e) {
console.info('SUB_time_systemTimer_createTimer_0002 arv wrong since ' + e);
expect().assertTrue();
done();
}
});
/**
* @tc.number SUB_time_systemTimer_createTimer_0004
* @tc.name SUB_time_systemTimer_createTimer_0004
* @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_IDLE, repeat = false, wantAgent(callback)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_time_systemTimer_createTimer_0004', 2, async function (done) {
console.info("SUB_time_systemTimer_createTimer_0004 start")
WantAgent.getBundleName(wantAgent, (err, data)=>{
console.info("SUB_time_systemTimer_createTimer_0004 BundleName: " + data);
})
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
repeat: true,
wantAgent: wantAgent,
interval: interval_time
}
try {
console.info("SUB_time_systemTimer_createTimer_0004 create timer")
systemTimer.createTimer(options, function (err, timerID) {
if (err) {
expect().assertTrue();
done();
}
expect(Number.isInteger(timerID)).assertTrue();
done();
});
} catch (e) {
console.info('SUB_time_systemTimer_createTimer_0004 has failed for ' + e);
expect().assertTrue();
done();
}
});
/**
* @tc.number SUB_time_systemTimer_createTimer_0005
* @tc.name SUB_time_systemTimer_createTimer_0005
* @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_REALTIME, repeat = false (Callback)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_time_systemTimer_createTimer_0005', 0, async function (done) {
console.info('SUB_time_systemTimer_createTimer_0005 start.');
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
repeat: false
};
try {
console.info('SUB_time_systemTimer_createTimer_0005 create timer.');
systemTimer.createTimer(options).then((timerID) =>{
console.info('SUB_time_systemTimer_createTimer_0005 timerID: ' + timerID);
// globalTimerID = timerID;
expect(Number.isInteger(timerID)).assertTrue();
done();
}).catch(err => {
console.info('SUB_time_systemTimer_createTimer_0005 promise failed ' + err);
expect().assertTrue();
done();
});
} catch (err) {
console.info('SUB_time_systemTimer_createTimer_0005 has failed for ' + err);
expect().assertTrue();
done();
}
});
/**
* @tc.number SUB_time_systemTimer_createTimer_0006
* @tc.name SUB_time_systemTimer_createTimer_0006
* @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_REALTIME, repeat = true (callback)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_time_systemTimer_createTimer_0006', 0, async function (done) {
console.info('SUB_time_systemTimer_createTimer_0006 start.');
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
repeat: false
}
try {
systemTimer.createTimer(options).then((timerID) => {
console.info('SUB_time_systemTimer_createTimer_0006 timerID: ' + timerID);
expect(Number.isInteger(timerID)).assertTrue();
done();
}).catch(err => {
console.info('SUB_time_systemTimer_createTimer_0006 promise failed ' + err);
expect().assertTrue();
done();
});
} catch (e) {
console.info('SUB_time_systemTimer_createTimer_0006 arv wrong since ' + e.code);
expect().assertTrue();
done();
}
});
/**
* @tc.number SUB_time_systemTimer_createTimer_0007
* @tc.name SUB_time_systemTimer_createTimer_0007
* @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_WAKEUP, repeat = true, interval (Callback)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_time_systemTimer_createTimer_0007', 2, async function (done) {
console.info("SUB_time_systemTimer_createTimer_0007 start")
WantAgent.getBundleName(wantAgent, (err, data)=>{
console.info('SUB_time_systemTimer_createTimer_0007 BundleName: ' + data);
})
let options = {
type: systemTimer.TIMER_TYPE_WAKEUP,
repeat: true,
wantAgent: wantAgent,
interval: interval_time
}
try {
console.info("SUB_time_systemTimer_createTimer_0007 create timer")
systemTimer.createTimer(options).then((timerID) => {
console.info('SUB_time_systemTimer_createTimer_0007 timerID: ' + timerID);
expect(Number.isInteger(timerID)).assertTrue();
done();
}).catch(err => {
console.info('SUB_time_systemTimer_createTimer_0007 promise failed ' + err);
expect().assertTrue();
done();
});
} catch (e) {
console.info('SUB_time_systemTimer_createTimer_0007 arv wrong since ' + e);
expect().assertTrue();
done();
}
});
/**
* @tc.number SUB_time_systemTimer_createTimer_0008
* @tc.name SUB_time_systemTimer_createTimer_0008
* @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_EXACT, repeat = false (Callback)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_time_systemTimer_createTimer_0008', 2, async function (done) {
console.info("SUB_time_systemTimer_createTimer_0008 start")
let options = {
type: systemTimer.TIMER_TYPE_EXACT,
repeat: false
}
try {
console.info("SUB_time_systemTimer_createTimer_0008 create timer")
systemTimer.createTimer(options).then((timerID) => {
expect(Number.isInteger(timerID)).assertTrue();
done();
}).catch(err => {
console.info('SUB_time_systemTimer_createTimer_0008 promise failed ' + err);
expect().assertTrue();
done();
});
} catch (e) {
console.info('SUB_time_systemTimer_createTimer_0008 arv wrong since ' + e);
expect().assertTrue();
done();
}
});
/**
* @tc.number SUB_time_systemTimer_createTimer_0009
* @tc.name SUB_time_systemTimer_createTimer_0009
* @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_IDLE, repeat = false, wantAgent(callback)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_time_systemTimer_createTimer_0009', 2, async function (done) {
console.info("SUB_time_systemTimer_createTimer_0009 start")
WantAgent.getBundleName(wantAgent, (err, data)=>{
console.info("SUB_time_systemTimer_createTimer_0009 BundleName: " + data);
})
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
repeat: true,
wantAgent: wantAgent,
interval: interval_time
}
try {
console.info("SUB_time_systemTimer_createTimer_0009 create timer")
systemTimer.createTimer(options).then((timerID) => {
expect(Number.isInteger(timerID)).assertTrue();
done();
}).catch(err => {
console.info('SUB_time_systemTimer_createTimer_0009 promise failed ' + err);
expect().assertTrue();
done();
});
} catch (e) {
console.info('SUB_time_systemTimer_createTimer_0009 has failed for ' + e);
expect().assertTrue();
done();
}
});
/**
* @tc.number SUB_time_systemTimer_startTimer_0001
* @tc.name SUB_time_systemTimer_startTimer_0001
* @tc.desc Test startTimer() interfaces, normal call(callback)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_time_systemTimer_startTimer_0001', 0, async function (done) {
console.info("SUB_time_systemTimer_startTimer_0001 start")
let options = {
type: systemTimer.TIMER_TYPE_IDLE,
repeat: false,
}
try {
console.info("SUB_time_systemTimer_startTimer_0001 start timer, timerID: " + globalTimerID)
let triggerTime = new Date().getTime() + interval_time * 1.2;
systemTimer.startTimer(globalTimerID, triggerTime, function (err, data) {
if (err) {
console.info('SUB_time_systemTimer_startTimer_0001 wrong since ' + err.code);
expect().assertTrue();
done();
}
console.info("SUB_time_systemTimer_startTimer_0001 success to start timerID: " + globalTimerID);
done();
});
} catch (e) {
console.info('SUB_time_systemTimer_startTimer_0001 has failed for ' + e);
expect().assertTrue();
done();
}
});
/**
* @tc.number SUB_time_systemTimer_stopTimer_0001
* @tc.name SUB_time_systemTimer_stopTimer_0001
* @tc.desc Test startTimer() interfaces, normal call(callback)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_time_systemTimer_stopTimer_0001', 0, async function (done) {
console.info("SUB_time_systemTimer_stopTimer_0001 start")
let options = {
type: systemTimer.TIMER_TYPE_IDLE,
repeat: false,
}
try {
console.info("SUB_time_systemTimer_stopTimer_0001 stop timer, timerID: " + globalTimerID)
systemTimer.stopTimer(globalTimerID, function (err, data) {
if (err) {
expect().assertTrue();
done();
}
console.info("SUB_time_systemTimer_stopTimer_0001 success to stop timerID: " + globalTimerID);
done();
});
} catch (e) {
console.info('SUB_time_systemTimer_stopTimer_0001 has failed for ' + e);
expect().assertTrue();
done();
}
});
/**
* @tc.number SUB_time_systemTimer_destroyTimer_0001
* @tc.name SUB_time_systemTimer_destroyTimer_0001
* @tc.desc Test startTimer() interfaces, normal call(callback)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_time_systemTimer_destroyTimer_0001', 0, async function (done) {
console.info("SUB_time_systemTimer_destroyTimer_0001 start")
let options = {
type: systemTimer.TIMER_TYPE_IDLE,
repeat: false,
}
try {
console.info("SUB_time_systemTimer_destroyTimer_0001 destroy timer, timerID: " + globalTimerID)
systemTimer.destroyTimer(globalTimerID, function (err, data) {
if (err) {
expect().assertTrue();
done();
}
console.info("SUB_time_systemTimer_destroyTimer_0001 success to destroy timerID: " + globalTimerID);
done();
});
} catch (e) {
console.info('SUB_time_systemTimer_destroyTimer_0001 has failed for ' + e);
expect().assertTrue();
done();
}
});
/**
* @tc.number SUB_time_systemTimer_createTimer_0006
* @tc.name SUB_time_systemTimer_createTimer_0006
* @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_REALTIME, repeat = false (Promise)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_time_systemTimer_createTimer_0006', 0, async function (done) {
console.info('SUB_time_systemTimer_createTimer_0006 start.');
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
repeat: false
};
try {
console.info('SUB_time_systemTimer_createTimer_0006 create timer.');
systemTimer.createTimer(options).then((timerID)=>{
console.info('SUB_time_systemTimer_createTimer_0006 timerID:' + timerID);
expect(Number.isInteger(timerID)).assertTrue();
globalTimerID = timerID;
done();
}, error => {
// 捕获业务逻辑错误
console.info('SUB_time_systemTimer_createTimer_0006 failed to create timer.');
expect().assertTrue();
done();
});
} catch (err) {
// 捕获参数错误
console.info('SUB_time_systemTimer_createTimer_0006 has failed for ' + err);
expect().assertTrue();
done();
}
});
/**
* @tc.number SUB_time_systemTimer_startTimer_0002
* @tc.name SUB_time_systemTimer_startTimer_0002
* @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_REALTIME, repeat = true (Promise)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_time_systemTimer_startTimer_0002', 0, async function (done) {
console.info('SUB_time_systemTimer_startTimer_0002 start.');
let options = {
type: systemTimer.TIMER_TYPE_WAKEUP,
repeat: false
};
try {
console.info('SUB_time_systemTimer_startTimer_0002 start timer, timerID: ' + globalTimerID);
let triggerTime = new Date().getTime() + interval_time * 2;
systemTimer.startTimer(globalTimerID, triggerTime)
.then(()=>{
console.info('SUB_time_systemTimer_startTimer_0002 timerID:' + globalTimerID);
done();
})
.catch(()=>{
// 捕获业务逻辑错误
console.info('SUB_time_systemTimer_startTimer_0002 failed to start timer.');
expect().assertTrue();
done();
});
} catch (err) {
// 捕获参数错误
console.info('SUB_time_systemTimer_startTimer_0002 has failed for ' + err);
expect().assertTrue();
done();
}
});
/**
* @tc.number SUB_time_systemTimer_stopTimer_0002
* @tc.name SUB_time_systemTimer_stopTimer_0002
* @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_REALTIME, repeat = true (Promise)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_time_systemTimer_stopTimer_0002', 0, async function (done) {
console.info('SUB_time_systemTimer_stopTimer_0002 start.');
let options = {
type: systemTimer.TIMER_TYPE_WAKEUP,
repeat: false
};
try {
console.info('SUB_time_systemTimer_stopTimer_0002 stop timer, timerID: ' + globalTimerID);
systemTimer.stopTimer(globalTimerID)
.then(()=>{
console.info('SUB_time_systemTimer_stopTimer_0002 timerID:' + globalTimerID);
done();
})
.catch(()=>{
// 捕获业务逻辑错误
console.info('SUB_time_systemTimer_stopTimer_0002 failed to stop timer.');
expect().assertTrue();
done();
});
} catch (err) {
// 捕获参数错误
console.info('SUB_time_systemTimer_stopTimer_0002 has failed for ' + err);
expect().assertTrue();
done();
}
});
/**
* @tc.number SUB_time_systemTimer_destroyTimer_0002
* @tc.name SUB_time_systemTimer_destroyTimer_0002
* @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_REALTIME, repeat = true (Promise)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_time_systemTimer_destroyTimer_0002', 0, async function (done) {
console.info('SUB_time_systemTimer_destroyTimer_0002 start.');
let options = {
type: systemTimer.TIMER_TYPE_WAKEUP,
repeat: false
};
try {
console.info('SUB_time_systemTimer_destroyTimer_0002 destroy timer, timerID: ' + globalTimerID);
systemTimer.destroyTimer(globalTimerID)
.then(()=>{
console.info('SUB_time_systemTimer_destroyTimer_0002 timerID:' + globalTimerID);
done();
})
.catch(()=>{
// 捕获业务逻辑错误
console.info('SUB_time_systemTimer_destroyTimer_0002 failed to destroy timer.');
expect().assertTrue();
done();
});
} catch (err) {
// 捕获参数错误
console.info('SUB_time_systemTimer_stopTimer_0002 has failed for ' + err);
expect().assertTrue();
done();
}
});
/**
* @tc.number SUB_time_systemTimer_ALL_Promise_0008
* @tc.name SUB_time_systemTimer_ALL_Promise_0008
* @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_REALTIME, repeat = false (Promise)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_time_systemTimer_ALL_Promise_0008', 0, async function (done) {
console.info('SUB_time_systemTimer_ALL_Promise_0008 start.');
let options = {
type: systemTimer.TIMER_TYPE_WAKEUP,
repeat: false
};
try {
console.info('SUB_time_systemTimer_ALL_Promise_0008 create timer.');
systemTimer.createTimer(options)
.then((timerID)=>{
console.info('SUB_time_systemTimer_ALL_Promise_0008 timerID:' + timerID);
expect(Number.isInteger(timerID)).assertTrue();
try {
let triggerTime = new Date().getTime() + interval_time * 1.2;
systemTimer.startTimer(timerID, triggerTime)
.then(()=>{
console.info('SUB_time_systemTimer_ALL_Promise_0008 start timerID: ' + timerID);
try {
systemTimer.stopTimer(timerID)
.then(()=>{
systemTimer.destroyTimer(timerID, function (err, data) {
console.info('SUB_time_systemTimer_ALL_Promise_0008 destroyTimer: ' + timerID);
done();
});
})
.catch(()=>{
// 捕获stopTimer业务逻辑错误
console.info('SUB_time_systemTimer_ALL_Promise_0008 failed to stop timer.');
expect().assertTrue();
done();
})
} catch (err) {
// 捕获stopTimer参数错误
console.info('SUB_time_systemTimer_ALL_Promise_0008 stopTimer with wrong arg: ' + err);
expect().assertTrue();
done();
}
})
.catch(()=>{
// 捕获startTimer业务逻辑错误
console.info('SUB_time_systemTimer_ALL_Promise_0008 failed to stop timer.');
expect().assertTrue();
done();
});
} catch (err) {
// 捕获参数错误
console.info('SUB_time_systemTimer_ALL_Promise_0008 startTimer with wrong arg: ' + err);
expect().assertTrue();
done();
}
})
.catch(()=>{
// 捕获业务逻辑错误
console.info('SUB_time_systemTimer_ALL_Promise_0008 failed to create timer.');
expect().assertTrue();
done();
});
} catch (err) {
// 捕获参数错误
console.info('SUB_time_systemTimer_ALL_Promise_0008 createTimer with wrong arg: ' + err);
expect().assertTrue();
done();
}
});
/**
* @tc.number SUB_time_systemTimer_ALL_Callback_0009
* @tc.name SUB_time_systemTimer_ALL_Callback_0009
* @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_REALTIME, repeat = false (Promise)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_time_systemTimer_ALL_Callback_0009', 0, async function (done) {
console.info('SUB_time_systemTimer_ALL_Callback_0009 start.');
let options = {
type: systemTimer.TIMER_TYPE_WAKEUP,
repeat: false
};
try {
console.info('SUB_time_systemTimer_ALL_Callback_0009 create timer.');
systemTimer.createTimer(options)
.then((timerID)=>{
console.info('SUB_time_systemTimer_ALL_Callback_0009 timerID:' + timerID);
expect(Number.isInteger(timerID)).assertTrue();
try {
let triggerTime = new Date().getTime() + interval_time * 1.2;
systemTimer.startTimer(timerID, triggerTime, ()=>{
console.info('SUB_time_systemTimer_ALL_Callback_0009 start timerID: ' + timerID);
try {
systemTimer.stopTimer(timerID, ()=>{
systemTimer.destroyTimer(timerID, function (err, data) {
console.info('SUB_time_systemTimer_ALL_Callback_0009 destroyTimer: ' + timerID);
done();
});
})
} catch (err) {
// 捕获stopTimer参数错误
console.info('SUB_time_systemTimer_ALL_Callback_0009 stopTimer with wrong arg: ' + err);
expect().assertTrue();
done();
}
})
} catch (err) {
// 捕获参数错误
console.info('SUB_time_systemTimer_ALL_Callback_0009 startTimer with wrong arg: ' + err);
expect().assertTrue();
done();
}
})
} catch (err) {
// 捕获参数错误
console.info('SUB_time_systemTimer_ALL_Callback_0009 createTimer with wrong arg: ' + err);
expect().assertTrue();
done();
}
});
});
}
\ No newline at end of file
{
"module": {
"name": "entry_test",
"type": "entry",
"srcEntrance": "./ets/Application/MyAbilityStage.ts",
"description": "$string:entry_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"abilities": [
{
"name": "MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:white",
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
],
"requestPermissions": [
{
"name":"ohos.permission.SET_TIME",
"reason":"need use ohos.permission.SET_TIME."
},
{
"name":"ohos.permission.SET_TIME_ZONE",
"reason":"need use ohos.permission.SET_TIME_ZONE."
}
]
}
}
\ No newline at end of file
{
"color": [
{
"name": "white",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "entry_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "ActsTimeAPITest"
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册