diff --git a/time/BUILD.gn b/time/BUILD.gn index 6b834079bf0a5403315d04c8a2bc9537c8690272..9c1a67e0c20a88c2da86f0d9b3717e2ae88e1b32 100644 --- a/time/BUILD.gn +++ b/time/BUILD.gn @@ -14,8 +14,5 @@ import("//build/ohos_var.gni") group("time") { testonly = true - deps = [ - "TimeTest_js:ActsTimeJSApiTest", - "TimerTest_js:ActsTimerJSApiTest", - ] + deps = [ "timeTest:ActsTimeAPITest" ] } diff --git a/time/TimeTest_js/Test.json b/time/TimeTest_js/Test.json deleted file mode 100644 index 162af643177b27e2244915014d50dc5d2d171d9a..0000000000000000000000000000000000000000 --- a/time/TimeTest_js/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "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 - } - ] -} diff --git a/time/TimeTest_js/signature/openharmony_sx.p7b b/time/TimeTest_js/signature/openharmony_sx.p7b deleted file mode 100644 index 66b4457a8a81fb8d3356cf46d67226c850944858..0000000000000000000000000000000000000000 Binary files a/time/TimeTest_js/signature/openharmony_sx.p7b and /dev/null differ diff --git a/time/TimeTest_js/src/main/config.json b/time/TimeTest_js/src/main/config.json deleted file mode 100644 index 4774a07e7ae122d7d5fc3b2a46ea79d12f1625cf..0000000000000000000000000000000000000000 --- a/time/TimeTest_js/src/main/config.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "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 - } - } - ] - } -} diff --git a/time/TimeTest_js/src/main/js/default/app.js b/time/TimeTest_js/src/main/js/default/app.js deleted file mode 100644 index 3f33c9fae0b3eb6b9a41b5d33a2ffa7e2d0d7d51..0000000000000000000000000000000000000000 --- a/time/TimeTest_js/src/main/js/default/app.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } -}; diff --git a/time/TimeTest_js/src/main/js/default/i18n/en-US.json b/time/TimeTest_js/src/main/js/default/i18n/en-US.json deleted file mode 100644 index e63c70d978a3a53be988388c87182f81785e170c..0000000000000000000000000000000000000000 --- a/time/TimeTest_js/src/main/js/default/i18n/en-US.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "hello": "Hello", - "world": "World" - } -} \ No newline at end of file diff --git a/time/TimeTest_js/src/main/js/default/i18n/zh-CN.json b/time/TimeTest_js/src/main/js/default/i18n/zh-CN.json deleted file mode 100644 index de6ee5748322f44942c1b003319d8e66c837675f..0000000000000000000000000000000000000000 --- a/time/TimeTest_js/src/main/js/default/i18n/zh-CN.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "hello": "您好", - "world": "世界" - } -} \ No newline at end of file diff --git a/time/TimeTest_js/src/main/js/default/pages/index/index.css b/time/TimeTest_js/src/main/js/default/pages/index/index.css deleted file mode 100644 index 6fda792753f2e15f22b529c7b90a82185b2770bf..0000000000000000000000000000000000000000 --- a/time/TimeTest_js/src/main/js/default/pages/index/index.css +++ /dev/null @@ -1,9 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.title { - font-size: 100px; -} diff --git a/time/TimeTest_js/src/main/js/default/pages/index/index.hml b/time/TimeTest_js/src/main/js/default/pages/index/index.hml deleted file mode 100644 index f64b040a5ae394dbaa5e185e1ecd4f4556b92184..0000000000000000000000000000000000000000 --- a/time/TimeTest_js/src/main/js/default/pages/index/index.hml +++ /dev/null @@ -1,5 +0,0 @@ -
- - {{ $t('strings.hello') }} {{ title }} - -
diff --git a/time/TimeTest_js/src/main/js/default/pages/index/index.js b/time/TimeTest_js/src/main/js/default/pages/index/index.js deleted file mode 100644 index eaac6fc987c8174e69676a9ef662ba069931387a..0000000000000000000000000000000000000000 --- a/time/TimeTest_js/src/main/js/default/pages/index/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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() { - }, -} diff --git a/time/TimeTest_js/src/main/js/default/test/List.test.js b/time/TimeTest_js/src/main/js/default/test/List.test.js deleted file mode 100644 index 5120a0a6a544098739b6250a5fb86d0f4527f055..0000000000000000000000000000000000000000 --- a/time/TimeTest_js/src/main/js/default/test/List.test.js +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 diff --git a/time/TimeTest_js/src/main/js/default/test/SystemTimeJsunit.test.js b/time/TimeTest_js/src/main/js/default/test/SystemTimeJsunit.test.js deleted file mode 100644 index 53dbcaa32e4ba7105e798c068c5ea73add015451..0000000000000000000000000000000000000000 --- a/time/TimeTest_js/src/main/js/default/test/SystemTimeJsunit.test.js +++ /dev/null @@ -1,166 +0,0 @@ -/* - * 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 diff --git a/time/TimeTest_js/src/main/js/default/test/Time.test.js b/time/TimeTest_js/src/main/js/default/test/Time.test.js deleted file mode 100644 index 44f16b9f3bae14f99bbb9a41d43b29a9c884d681..0000000000000000000000000000000000000000 --- a/time/TimeTest_js/src/main/js/default/test/Time.test.js +++ /dev/null @@ -1,236 +0,0 @@ -/* - * 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(); - }); -}) diff --git a/time/TimeTest_js/src/main/resources/base/element/string.json b/time/TimeTest_js/src/main/resources/base/element/string.json deleted file mode 100644 index ec03196184773273c7a5af69fc92d81cd0d3889b..0000000000000000000000000000000000000000 --- a/time/TimeTest_js/src/main/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "JstimeTest" - }, - { - "name": "mainability_description", - "value": "JS_Phone_Empty Feature Ability" - } - ] -} \ No newline at end of file diff --git a/time/TimerTest_js/BUILD.gn b/time/TimerTest_js/BUILD.gn deleted file mode 100644 index 68ce95cbfb3710bc82c6eec1a65377bd94875373..0000000000000000000000000000000000000000 --- a/time/TimerTest_js/BUILD.gn +++ /dev/null @@ -1,33 +0,0 @@ -# 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" -} diff --git a/time/TimerTest_js/Test.json b/time/TimerTest_js/Test.json deleted file mode 100644 index 5a5cf5fb5eecb8d35cdb06a8d547925cfffc7197..0000000000000000000000000000000000000000 --- a/time/TimerTest_js/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "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 - } - ] -} diff --git a/time/TimerTest_js/src/main/config.json b/time/TimerTest_js/src/main/config.json deleted file mode 100644 index 2c4c85a2e5ed4258c4e136d0d4bbea417a6f079a..0000000000000000000000000000000000000000 --- a/time/TimerTest_js/src/main/config.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "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 - } - } - ] - } -} diff --git a/time/TimerTest_js/src/main/js/default/i18n/en-US.json b/time/TimerTest_js/src/main/js/default/i18n/en-US.json deleted file mode 100644 index e63c70d978a3a53be988388c87182f81785e170c..0000000000000000000000000000000000000000 --- a/time/TimerTest_js/src/main/js/default/i18n/en-US.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "hello": "Hello", - "world": "World" - } -} \ No newline at end of file diff --git a/time/TimerTest_js/src/main/js/default/i18n/zh-CN.json b/time/TimerTest_js/src/main/js/default/i18n/zh-CN.json deleted file mode 100644 index de6ee5748322f44942c1b003319d8e66c837675f..0000000000000000000000000000000000000000 --- a/time/TimerTest_js/src/main/js/default/i18n/zh-CN.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "hello": "您好", - "world": "世界" - } -} \ No newline at end of file diff --git a/time/TimerTest_js/src/main/js/default/pages/index/index.css b/time/TimerTest_js/src/main/js/default/pages/index/index.css deleted file mode 100644 index 6fda792753f2e15f22b529c7b90a82185b2770bf..0000000000000000000000000000000000000000 --- a/time/TimerTest_js/src/main/js/default/pages/index/index.css +++ /dev/null @@ -1,9 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.title { - font-size: 100px; -} diff --git a/time/TimerTest_js/src/main/js/default/pages/index/index.hml b/time/TimerTest_js/src/main/js/default/pages/index/index.hml deleted file mode 100644 index f64b040a5ae394dbaa5e185e1ecd4f4556b92184..0000000000000000000000000000000000000000 --- a/time/TimerTest_js/src/main/js/default/pages/index/index.hml +++ /dev/null @@ -1,5 +0,0 @@ -
- - {{ $t('strings.hello') }} {{ title }} - -
diff --git a/time/TimerTest_js/src/main/js/default/pages/index/index.js b/time/TimerTest_js/src/main/js/default/pages/index/index.js deleted file mode 100644 index ea4ed5e4d6507dde6112f8501a68d24c6bd5aca4..0000000000000000000000000000000000000000 --- a/time/TimerTest_js/src/main/js/default/pages/index/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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() { - }, -} diff --git a/time/TimerTest_js/src/main/js/default/test/List.test.js b/time/TimerTest_js/src/main/js/default/test/List.test.js deleted file mode 100644 index 859f6c6d813adc8b8489234477358caf51ece81c..0000000000000000000000000000000000000000 --- a/time/TimerTest_js/src/main/js/default/test/List.test.js +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 diff --git a/time/TimerTest_js/src/main/js/default/test/SystemTimerJsunit.test.js b/time/TimerTest_js/src/main/js/default/test/SystemTimerJsunit.test.js deleted file mode 100644 index 16b42e1f22446ff1aba02c53c2c044f41f057483..0000000000000000000000000000000000000000 --- a/time/TimerTest_js/src/main/js/default/test/SystemTimerJsunit.test.js +++ /dev/null @@ -1,761 +0,0 @@ -/* - * 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 diff --git a/time/TimerTest_js/src/main/resources/base/element/string.json b/time/TimerTest_js/src/main/resources/base/element/string.json deleted file mode 100644 index 7d8cda7795aa2464c77c5bd64e5da3b1a860ea0b..0000000000000000000000000000000000000000 --- a/time/TimerTest_js/src/main/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "JstimerTest" - }, - { - "name": "mainability_description", - "value": "JS_Phone_Empty Feature Ability" - } - ] -} \ No newline at end of file diff --git a/time/timeTest/AppScope/app.json b/time/timeTest/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..6802f440a9ba4455a2f1b73aac5670dec2216556 --- /dev/null +++ b/time/timeTest/AppScope/app.json @@ -0,0 +1,15 @@ +{ + "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 + } +} diff --git a/time/timeTest/AppScope/resources/base/element/string.json b/time/timeTest/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..066e1ff18115359423b0e6d99014273b2408bdee --- /dev/null +++ b/time/timeTest/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ActsTimeAPITest" + } + ] +} diff --git a/time/TimeTest_js/src/main/resources/base/media/icon.png b/time/timeTest/AppScope/resources/base/media/app_icon.png similarity index 100% rename from time/TimeTest_js/src/main/resources/base/media/icon.png rename to time/timeTest/AppScope/resources/base/media/app_icon.png diff --git a/time/TimeTest_js/BUILD.gn b/time/timeTest/BUILD.gn similarity index 50% rename from time/TimeTest_js/BUILD.gn rename to time/timeTest/BUILD.gn index ba6ee6dd954308dfc0ddf79023bf14f333769d98..c6637e0fa8c7d76932895b2bb1d5a6968786c609 100644 --- a/time/TimeTest_js/BUILD.gn +++ b/time/timeTest/BUILD.gn @@ -1,4 +1,4 @@ -# 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" } diff --git a/time/timeTest/Test.json b/time/timeTest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..0e91ba878d1edb68beda4b9ebcc32158bbd561bd --- /dev/null +++ b/time/timeTest/Test.json @@ -0,0 +1,18 @@ +{ + "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 + }] +} diff --git a/time/timeTest/entry/src/main/ets/Application/MyAbilityStage.ts b/time/timeTest/entry/src/main/ets/Application/MyAbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..4bea34b35db86d55f1a555e4bfb97778968567d6 --- /dev/null +++ b/time/timeTest/entry/src/main/ets/Application/MyAbilityStage.ts @@ -0,0 +1,9 @@ +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 diff --git a/time/timeTest/entry/src/main/ets/MainAbility/MainAbility.ts b/time/timeTest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..9dc331bc8149d36521ac746384d6606c85bd7ee0 --- /dev/null +++ b/time/timeTest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,66 @@ +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'); + } +} diff --git a/time/timeTest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/time/timeTest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..1b7461ea56b950b1cb879f9269f67e4a441f8ef1 --- /dev/null +++ b/time/timeTest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,71 @@ +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 diff --git a/time/timeTest/entry/src/main/ets/pages/index.ets b/time/timeTest/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..6a23c90b5265a129db7c8cda8bb2e4978f38d386 --- /dev/null +++ b/time/timeTest/entry/src/main/ets/pages/index.ets @@ -0,0 +1,40 @@ + +// @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 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 diff --git a/time/TimerTest_js/src/main/js/default/app.js b/time/timeTest/entry/src/main/ets/test/List.test.ets similarity index 70% rename from time/TimerTest_js/src/main/js/default/app.js rename to time/timeTest/entry/src/main/ets/test/List.test.ets index 564b7cb972324e0ae905c2597f6e99ab7c6ad951..547578579527402967edc7d1673159093c4cc743 100644 --- a/time/TimerTest_js/src/main/js/default/app.js +++ b/time/timeTest/entry/src/main/ets/test/List.test.ets @@ -1,5 +1,5 @@ /* - * 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 diff --git a/time/timeTest/entry/src/main/ets/test/systemTimeTest.ets b/time/timeTest/entry/src/main/ets/test/systemTimeTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..8eaffa0518ce065d58de72f87b34f4771110ec34 --- /dev/null +++ b/time/timeTest/entry/src/main/ets/test/systemTimeTest.ets @@ -0,0 +1,369 @@ +// @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(); + }); + }) +} diff --git a/time/timeTest/entry/src/main/ets/test/systemTimer.test.ets b/time/timeTest/entry/src/main/ets/test/systemTimer.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..dc8bbb401b32594421077dd963a75a7aaa117d3a --- /dev/null +++ b/time/timeTest/entry/src/main/ets/test/systemTimer.test.ets @@ -0,0 +1,793 @@ +/* + * 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 diff --git a/time/timeTest/entry/src/main/module.json b/time/timeTest/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..c0ffdbdab6a2fc608622e0db486cd74f8cae5a02 --- /dev/null +++ b/time/timeTest/entry/src/main/module.json @@ -0,0 +1,47 @@ +{ + "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 diff --git a/time/timeTest/entry/src/main/resources/base/element/color.json b/time/timeTest/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..62a137a61b90c14f109ed8c81d9d551ea0a5888a --- /dev/null +++ b/time/timeTest/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "white", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/time/timeTest/entry/src/main/resources/base/element/string.json b/time/timeTest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..03bb7d00f7c5bd5750f08b254e645f0d3f960804 --- /dev/null +++ b/time/timeTest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "ActsTimeAPITest" + } + ] +} \ No newline at end of file diff --git a/time/TimerTest_js/src/main/resources/base/media/icon.png b/time/timeTest/entry/src/main/resources/base/media/icon.png similarity index 100% rename from time/TimerTest_js/src/main/resources/base/media/icon.png rename to time/timeTest/entry/src/main/resources/base/media/icon.png diff --git a/time/timeTest/entry/src/main/resources/base/profile/main_pages.json b/time/timeTest/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..feec276e105eeb8d621c20aaf838f318b0a94150 --- /dev/null +++ b/time/timeTest/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} diff --git a/time/TimerTest_js/signature/openharmony_sx.p7b b/time/timeTest/signature/ActsTimeAPITest.p7b similarity index 51% rename from time/TimerTest_js/signature/openharmony_sx.p7b rename to time/timeTest/signature/ActsTimeAPITest.p7b index 66b4457a8a81fb8d3356cf46d67226c850944858..e1caf6086a82e9791735e52954e2d5cdc0d40624 100644 Binary files a/time/TimerTest_js/signature/openharmony_sx.p7b and b/time/timeTest/signature/ActsTimeAPITest.p7b differ