diff --git a/account/appaccount/BUILD.gn b/account/appaccount/BUILD.gn index fd7341476df08398d3ef59bc74e4d90533d2aae7..337499c04cd82263bbf3cccdf6f1b05bae796e42 100644 --- a/account/appaccount/BUILD.gn +++ b/account/appaccount/BUILD.gn @@ -17,7 +17,6 @@ group("appaccount_hap") { testonly = true if (is_standard_system) { deps = [ - "actsaccountchangeonoff:ActsAccountChangeOnOff", "actsaccounttest:ActsAccountTest", "actsgetallaccounts:ActsGetAllAccounts", "actssetchecksyncenable:ActsSetCheckSyncEnable", diff --git a/account/appaccount/actsaccountchangeonoff/BUILD.gn b/account/appaccount/actsaccountchangeonoff/BUILD.gn deleted file mode 100755 index c2a6147085937ba33c658b52cb1412c116d20993..0000000000000000000000000000000000000000 --- a/account/appaccount/actsaccountchangeonoff/BUILD.gn +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//test/xts/tools/build/suite.gni") - -ohos_js_hap_suite("ActsAccountChangeOnOff") { - hap_profile = "./entry/src/main/config.json" - deps = [ - ":hjs_demo_js_assets", - ":hjs_demo_resources", - ] - certificate_profile = "./signature/openharmony_sx.p7b" - hap_name = "ActsAccountChangeOnOff" -} -ohos_js_assets("hjs_demo_js_assets") { - source_dir = "./entry/src/main/js/default" -} -ohos_resources("hjs_demo_resources") { - sources = [ "./entry/src/main/js/resources" ] - hap_profile = "./entry/src/main/config.json" -} diff --git a/account/appaccount/actsaccountchangeonoff/Test.json b/account/appaccount/actsaccountchangeonoff/Test.json deleted file mode 100755 index 6a7f0231cf022b5f74975e85176bedb90aac586f..0000000000000000000000000000000000000000 --- a/account/appaccount/actsaccountchangeonoff/Test.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "description": "Configuration for hjunit demo Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "60000", - "package": "com.example.actsaccountchangeonoff", - "shell-timeout": "60000" - }, - "kits": [ - { - "test-file-name": [ - "ActsAccountChangeOnOff.hap", - "ActsAccountSceneOnOff.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} diff --git a/account/appaccount/actsaccountchangeonoff/entry/src/main/config.json b/account/appaccount/actsaccountchangeonoff/entry/src/main/config.json deleted file mode 100755 index f1e5d6e6ddb8ec32c517a98bb960e36b4b9248b7..0000000000000000000000000000000000000000 --- a/account/appaccount/actsaccountchangeonoff/entry/src/main/config.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "app": { - "bundleName": "com.example.actsaccountchangeonoff", - "vendor": "example", - "version": { - "code": 1, - "name": "1.0" - }, - "apiVersion": { - "compatible": 4, - "target": 5, - "releaseType": "Beta1" - } - }, - "deviceConfig": {}, - "module": { - "package": "com.example.actsaccountchangeonoff", - "name": ".MyApplication", - "deviceType": [ - "phone" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry" - }, - "abilities": [ - { - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "name": "com.example.actsaccountchangeonoff.MainAbility", - "icon": "$media:icon", - "description": "$string:mainability_description", - "label": "$string:app_name", - "type": "page", - "visible": true, - "launchType": "standard" - } - ], - "js": [ - { - "pages": [ - "pages/index/index" - ], - "name": "default", - "window": { - "designWidth": 720, - "autoDesignWidth": false - } - } - ] - } -} \ No newline at end of file diff --git a/account/appaccount/actsaccountchangeonoff/entry/src/main/js/default/app.js b/account/appaccount/actsaccountchangeonoff/entry/src/main/js/default/app.js deleted file mode 100755 index 2a68c1992145a976957d7dcdd69a7e9c2e8e9877..0000000000000000000000000000000000000000 --- a/account/appaccount/actsaccountchangeonoff/entry/src/main/js/default/app.js +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } -}; diff --git a/account/appaccount/actsaccountchangeonoff/entry/src/main/js/default/i18n/en-US.json b/account/appaccount/actsaccountchangeonoff/entry/src/main/js/default/i18n/en-US.json deleted file mode 100755 index e63c70d978a3a53be988388c87182f81785e170c..0000000000000000000000000000000000000000 --- a/account/appaccount/actsaccountchangeonoff/entry/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/account/appaccount/actsaccountchangeonoff/entry/src/main/js/default/i18n/zh-CN.json b/account/appaccount/actsaccountchangeonoff/entry/src/main/js/default/i18n/zh-CN.json deleted file mode 100755 index de6ee5748322f44942c1b003319d8e66c837675f..0000000000000000000000000000000000000000 --- a/account/appaccount/actsaccountchangeonoff/entry/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/account/appaccount/actsaccountchangeonoff/entry/src/main/js/default/pages/index/index.css b/account/appaccount/actsaccountchangeonoff/entry/src/main/js/default/pages/index/index.css deleted file mode 100755 index 6fda792753f2e15f22b529c7b90a82185b2770bf..0000000000000000000000000000000000000000 --- a/account/appaccount/actsaccountchangeonoff/entry/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/account/appaccount/actsaccountchangeonoff/entry/src/main/js/default/pages/index/index.hml b/account/appaccount/actsaccountchangeonoff/entry/src/main/js/default/pages/index/index.hml deleted file mode 100755 index c45422b42d0bf788a1c2c0eb299a981f07ce8613..0000000000000000000000000000000000000000 --- a/account/appaccount/actsaccountchangeonoff/entry/src/main/js/default/pages/index/index.hml +++ /dev/null @@ -1,5 +0,0 @@ -
- - {{title}} - -
diff --git a/account/appaccount/actsaccountchangeonoff/entry/src/main/js/default/pages/index/index.js b/account/appaccount/actsaccountchangeonoff/entry/src/main/js/default/pages/index/index.js deleted file mode 100755 index 74740202b30376b23e2ae4be39b77ca839184db7..0000000000000000000000000000000000000000 --- a/account/appaccount/actsaccountchangeonoff/entry/src/main/js/default/pages/index/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import file from '@system.file' -import {Core, ExpectExtend} from 'deccjsunit/index' - -const injectRef = Object.getPrototypeOf(global) || global -injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') - -export default { - data: { - title: "测试on/off接口" - }, - onInit() { - this.title = "测试on/off接口"; - }, - onShow() { - console.info('onShow finish') - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - core.init() - - const configService = core.getDefaultService('config') - configService.setConfig(this) - - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} \ No newline at end of file diff --git a/account/appaccount/actsaccountchangeonoff/entry/src/main/js/resources/base/element/string.json b/account/appaccount/actsaccountchangeonoff/entry/src/main/js/resources/base/element/string.json deleted file mode 100755 index 52b714402b5bcddb2305cb1d6fa78f0250fec256..0000000000000000000000000000000000000000 --- a/account/appaccount/actsaccountchangeonoff/entry/src/main/js/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "ActsAccountChangeOnOff" - }, - { - "name": "mainability_description", - "value": "JS_Phone_Empty Feature Ability" - } - ] -} \ No newline at end of file diff --git a/account/appaccount/actsaccountchangeonoff/entry/src/main/js/resources/base/media/icon.png b/account/appaccount/actsaccountchangeonoff/entry/src/main/js/resources/base/media/icon.png deleted file mode 100755 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/account/appaccount/actsaccountchangeonoff/entry/src/main/js/resources/base/media/icon.png and /dev/null differ diff --git a/account/appaccount/actsaccountchangeonoff/entry/src/main/js/test/List.test.js b/account/appaccount/actsaccountchangeonoff/entry/src/main/js/test/List.test.js deleted file mode 100755 index c0b876e81cf0a75db974ee932d8fc06a1d5a6e66..0000000000000000000000000000000000000000 --- a/account/appaccount/actsaccountchangeonoff/entry/src/main/js/test/List.test.js +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -require('./ExampleJsunit.test.js') \ No newline at end of file diff --git a/account/appaccount/actsaccountchangeonoff/signature/openharmony_sx.p7b b/account/appaccount/actsaccountchangeonoff/signature/openharmony_sx.p7b deleted file mode 100755 index 9be1e98fa4c0c28ca997ed660112fa16b194f0f5..0000000000000000000000000000000000000000 Binary files a/account/appaccount/actsaccountchangeonoff/signature/openharmony_sx.p7b and /dev/null differ diff --git a/account/appaccount/actsaccounttest/Test.json b/account/appaccount/actsaccounttest/Test.json index de5b6c2c7551756e15a0a49f9e48b3215c3bd083..0f25d92c1a537c4d4f1613469e62c70ea69c2d6c 100755 --- a/account/appaccount/actsaccounttest/Test.json +++ b/account/appaccount/actsaccounttest/Test.json @@ -2,7 +2,7 @@ "description": "Configuration for hjunit demo Tests", "driver": { "type": "JSUnitTest", - "test-timeout": "200000", + "test-timeout": "300000", "package": "com.example.actsaccounttest", "shell-timeout": "60000" }, @@ -10,7 +10,8 @@ { "test-file-name": [ "ActsAccountTest.hap", - "ActsAccountSceneAppAccess.hap" + "ActsAccountSceneAppAccess.hap", + "ActsAccountSceneOnOff.hap" ], "type": "AppInstallKit", "cleanup-apps": true diff --git a/account/appaccount/actsaccounttest/entry/src/main/js/test/AddAccount.test.js b/account/appaccount/actsaccounttest/entry/src/main/js/test/AddAccount.test.js index a037e04ae30d56db40d77cbda418769e285ad2f1..5d4f81dc9f53a9db100aae2648d2078383914ffe 100755 --- a/account/appaccount/actsaccounttest/entry/src/main/js/test/AddAccount.test.js +++ b/account/appaccount/actsaccounttest/entry/src/main/js/test/AddAccount.test.js @@ -21,8 +21,8 @@ describe('ActsAccountAddAccount', function () { /* * @tc.number : ActsAccountAddAccount_0100 - * @tc.name : Add account calllback form - * @tc.desc : Add account in calllback form without additional information + * @tc.name : Add account callback form + * @tc.desc : Add account in callback form without additional information */ it('ActsAccountAddAccount_0100', 0, async function (done) { console.debug("====>ActsAccountAddAccount_0100 start===="); @@ -66,8 +66,8 @@ describe('ActsAccountAddAccount', function () { /* * @tc.number : ActsAccountAddAccount_0300 - * @tc.name : Add account calllback form - * @tc.desc : Add account in calllback form with additional information + * @tc.name : Add account callback form + * @tc.desc : Add account in callback form with additional information */ it('ActsAccountAddAccount_0300', 0, async function (done) { console.debug("====>ActsAccountAddAccount_0300 start===="); @@ -112,7 +112,7 @@ describe('ActsAccountAddAccount', function () { /* * @tc.number : ActsAccountAddAccount_0500 - * @tc.name : Add account calllback form + * @tc.name : Add account callback form * @tc.desc : Repeatedly add the same name account and the same additional information */ it('ActsAccountAddAccount_0500', 0, async function (done) { @@ -159,7 +159,7 @@ describe('ActsAccountAddAccount', function () { /* * @tc.number : ActsAccountAddAccount_0700 - * @tc.name : Add account calllback form + * @tc.name : Add account callback form * @tc.desc : The account name exceeds the length limit of 512 characters */ it('ActsAccountAddAccount_0700', 0, async function (done) { @@ -202,7 +202,7 @@ describe('ActsAccountAddAccount', function () { /* * @tc.number : ActsAccountAddAccount_0900 - * @tc.name : Add account calllback form + * @tc.name : Add account callback form * @tc.desc : Additional information exceeds the length limit of 1024 characters */ it('ActsAccountAddAccount_0900', 0, async function (done) { @@ -245,7 +245,7 @@ describe('ActsAccountAddAccount', function () { /* * @tc.number : ActsAccountAddAccount_1100 - * @tc.name : Add account calllback form + * @tc.name : Add account callback form * @tc.desc : The account name is an empty string */ it('ActsAccountAddAccount_1100', 0, async function (done) { @@ -281,7 +281,7 @@ describe('ActsAccountAddAccount', function () { /* * @tc.number : ActsAccountAddAccount_1300 - * @tc.name : Add account calllback form + * @tc.name : Add account callback form * @tc.desc : Additional information is an empty string */ it('ActsAccountAddAccount_1300', 0, async function (done) { @@ -323,7 +323,7 @@ describe('ActsAccountAddAccount', function () { /* * @tc.number : ActsAccountAddAccount_1500 - * @tc.name : Add account calllback form + * @tc.name : Add account callback form * @tc.desc : The account name is a special character such as a space */ it('ActsAccountAddAccount_1500', 0, async function (done) { @@ -361,7 +361,7 @@ describe('ActsAccountAddAccount', function () { /* * @tc.number : ActsAccountAddAccount_1700 - * @tc.name : Add account calllback form + * @tc.name : Add account callback form * @tc.desc : The account name is a special string */ it('ActsAccountAddAccount_1700', 0, async function (done) { @@ -406,7 +406,7 @@ describe('ActsAccountAddAccount', function () { /* * @tc.number : ActsAccountAddAccount_1900 - * @tc.name : Add account calllback form + * @tc.name : Add account callback form * @tc.desc : Additional information is a special character such as a space */ it('ActsAccountAddAccount_1900', 0, async function (done) { @@ -451,7 +451,7 @@ describe('ActsAccountAddAccount', function () { /* * @tc.number : ActsAccountAddAccount_2100 - * @tc.name : Add account calllback form + * @tc.name : Add account callback form * @tc.desc : Additional information is a special string */ it('ActsAccountAddAccount_2100', 0, async function (done) { @@ -496,7 +496,7 @@ describe('ActsAccountAddAccount', function () { /* * @tc.number : ActsAccountAddAccount_2300 - * @tc.name : Add account calllback form + * @tc.name : Add account callback form * @tc.desc : Repeatedly add accounts with the same name and different additional information */ it('ActsAccountAddAccount_2300', 0, async function (done) { @@ -543,7 +543,7 @@ describe('ActsAccountAddAccount', function () { /* * @tc.number : ActsAccountAddAccount_2500 - * @tc.name : Add account calllback form + * @tc.name : Add account callback form * @tc.desc : The account name reaches the limit of 512 characters */ it('ActsAccountAddAccount_2500', 0, async function (done) { @@ -594,7 +594,7 @@ describe('ActsAccountAddAccount', function () { /* * @tc.number : ActsAccountAddAccount_2700 - * @tc.name : Add account calllback form + * @tc.name : Add account callback form * @tc.desc : Additional information reaches the limit of 1024 characters */ it('ActsAccountAddAccount_2700', 0, async function (done) { diff --git a/account/appaccount/actsaccounttest/entry/src/main/js/test/DeleteAccount.test.js b/account/appaccount/actsaccounttest/entry/src/main/js/test/DeleteAccount.test.js index c46c59ff211e04addc2c98719906cfa32c7dd452..4eb7e9fb7d19f8eb837cbbcca1b7f4430b3dd155 100755 --- a/account/appaccount/actsaccounttest/entry/src/main/js/test/DeleteAccount.test.js +++ b/account/appaccount/actsaccounttest/entry/src/main/js/test/DeleteAccount.test.js @@ -15,8 +15,8 @@ import account from '@ohos.account.appAccount' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +const NAMELIMIT = 512; const TIMEOUT = 1000; -const STRCOUNT = 1025; describe('ActsAccountDeleteAccount', function () { function sleep(delay) { var start = (new Date()).getTime(); @@ -34,7 +34,7 @@ describe('ActsAccountDeleteAccount', function () { /* * @tc.number : ActsAccountDeleteAccount_0100 - * @tc.name : Delete account calllback form + * @tc.name : Delete account callback form * @tc.desc : Delete the added account in callback form */ it('ActsAccountDeleteAccount_0100', 0, async function (done) { @@ -77,7 +77,7 @@ describe('ActsAccountDeleteAccount', function () { /* * @tc.number : ActsAccountDeleteAccount_0300 - * @tc.name : Delete account calllback form + * @tc.name : Delete account callback form * @tc.desc : Delete unadded account in callback form */ it('ActsAccountDeleteAccount_0300', 0, async function (done) { @@ -113,7 +113,7 @@ describe('ActsAccountDeleteAccount', function () { /* * @tc.number : ActsAccountDeleteAccount_0500 - * @tc.name : Delete account calllback form + * @tc.name : Delete account callback form * @tc.desc : Delete the added account, the first time it can be deleted, the second time the deletion fails */ it('ActsAccountDeleteAccount_0500', 0, async function (done) { @@ -161,17 +161,17 @@ describe('ActsAccountDeleteAccount', function () { /* * @tc.number : ActsAccountDeleteAccount_0700 - * @tc.name : Delete account calllback form - * @tc.desc : Delete the account name exceeds the length limit of 1024 + * @tc.name : Delete account callback form + * @tc.desc : Delete the account name exceeds the length limit of 512 characters */ it('ActsAccountDeleteAccount_0700',0, async function (done){ console.debug("====>ActsAccountDeleteAccount_0700 start===="); - var bigStr = ''; - for (var i = 0; i < STRCOUNT; i++) { - bigStr += 't'; + var nameLimit = ''; + for (var i = 0; i < NAMELIMIT + 1; i++) { + nameLimit += 't'; } var appAccountManager = account.createAppAccountManager(); - appAccountManager.deleteAccount(bigStr, (err)=>{ + appAccountManager.deleteAccount(nameLimit, (err)=>{ console.debug("====>delete Account ActsAccountDeleteAccount_0700 err:" + JSON.stringify(err)); expect(err.code != 0).assertEqual(true); console.debug("====>ActsAccountDeleteAccount_0700 end===="); @@ -182,18 +182,18 @@ describe('ActsAccountDeleteAccount', function () { /* * @tc.number : ActsAccountDeleteAccount_0800 * @tc.name : Delete account promise form - * @tc.desc : Delete the account name exceeds the length limit of 1024 + * @tc.desc : Delete the account name exceeds the length limit of 512 characters */ it('ActsAccountDeleteAccount_0800', 0, async function (done){ console.debug("====>ActsAccountDeleteAccount_0800 start===="); - var bigStr = ''; - for (var i = 0; i < STRCOUNT; i++) { - bigStr += 't'; + var nameLimit = ''; + for (var i = 0; i < NAMELIMIT + 1; i++) { + nameLimit += 'n'; } var appAccountManager = account.createAppAccountManager(); console.debug("====>delete Account ActsAccountDeleteAccount_0800 start===="); try{ - await appAccountManager.deleteAccount(bigStr); + await appAccountManager.deleteAccount(nameLimit); } catch(err){ console.debug("====>delete account ActsAccountDeleteAccount_0800 err:" + JSON.stringify(err)); @@ -205,7 +205,7 @@ describe('ActsAccountDeleteAccount', function () { /* * @tc.number : ActsAccountDeleteAccount_0900 - * @tc.name : Delete account calllback form + * @tc.name : Delete account callback form * @tc.desc : Delete the account name is an empty string */ it('ActsAccountDeleteAccount_0900',0, async function (done){ diff --git a/account/appaccount/actsaccounttest/entry/src/main/js/test/List.test.js b/account/appaccount/actsaccounttest/entry/src/main/js/test/List.test.js index 2f16c5ad7d8bfd35838247ee411fb92b36d7d66f..b039751f859ec0ffaaacc08539f2a0b61ca9a0f0 100755 --- a/account/appaccount/actsaccounttest/entry/src/main/js/test/List.test.js +++ b/account/appaccount/actsaccounttest/entry/src/main/js/test/List.test.js @@ -20,4 +20,5 @@ require('./AssociatedData.test.js') require('./Credential.test.js') require('./OAuthToken.test.js') require('./CreatManager.test.js') -require('./NoPermission.test.js') \ No newline at end of file +require('./NoPermission.test.js') +require('./OnOff.js') \ No newline at end of file diff --git a/account/appaccount/actsaccounttest/entry/src/main/js/test/NoPermission.test.js b/account/appaccount/actsaccounttest/entry/src/main/js/test/NoPermission.test.js index d8fa94b906b24e4770f50cf6cabc3af96c715f3f..a0a76d8b826b87c18d7c9f642a05348a28757539 100755 --- a/account/appaccount/actsaccounttest/entry/src/main/js/test/NoPermission.test.js +++ b/account/appaccount/actsaccounttest/entry/src/main/js/test/NoPermission.test.js @@ -16,7 +16,7 @@ import account from '@ohos.account.appAccount' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' const TIMEOUT = 1000; -const ERR_APPACCOUNT_SERVICE_PERMISSION_DENIED = 4521990; +const ERR_APPACCOUNT_SERVICE_PERMISSION_DENIED = 4521992; describe('ActsAccountNoPermission', function () { function sleep(delay) { var start = (new Date()).getTime(); diff --git a/account/appaccount/actsaccountchangeonoff/entry/src/main/js/test/ExampleJsunit.test.js b/account/appaccount/actsaccounttest/entry/src/main/js/test/OnOff.js similarity index 57% rename from account/appaccount/actsaccountchangeonoff/entry/src/main/js/test/ExampleJsunit.test.js rename to account/appaccount/actsaccounttest/entry/src/main/js/test/OnOff.js index 3452f65f1e20b485199207268cd020e9bf1b616d..e7e9b044f3c7bbb91b302741760617f6d226af74 100755 --- a/account/appaccount/actsaccountchangeonoff/entry/src/main/js/test/ExampleJsunit.test.js +++ b/account/appaccount/actsaccounttest/entry/src/main/js/test/OnOff.js @@ -40,7 +40,7 @@ describe('ActsAccountChangeOnOff', async function () { /* * @tc.number : ActsAccountChangeOnOff_0100 - * @tc.name : Subscribe/unsubscribe to the change event of the specified application + * @tc.name : Subscribe/unsubscribe to the change event of application * @tc.desc : Received the account information change to the authorized account of the subscription to change * the additional information */ @@ -53,7 +53,7 @@ describe('ActsAccountChangeOnOff', async function () { console.debug("====>enableAppAccess ActsAccountChangeOnOff_0100 start"); await appAccountManager.enableAppAccess("changeonoff_extra", "com.example.actsaccountsceneonoff"); function unSubscriberCallback(err){ - console.debug("====>`unsubscribe` 0100 err:" + JSON.stringify(err)); + console.debug("====>unsubscribe 0100 err:" + JSON.stringify(err)); } function deleteAccountCallback(err){ console.debug("====>delete account 0100 err:" + JSON.stringify(err)); @@ -103,16 +103,12 @@ describe('ActsAccountChangeOnOff', async function () { setTimeout(function (){ console.debug("====>publish event account_on_change 0100===="); commonevent.publish("account_on_change", commonEventPublishData, publishCallback); - }, 1000) - - setTimeout(function(){ - console.debug("====>time out ActsAccountChangeOnOff_0100===="); - }, TIMEOUT); + }, 1000); }); /* * @tc.number : ActsAccountChangeOnOff_0200 - * @tc.name : Subscribe/unsubscribe to the change event of the specified application + * @tc.name : Subscribe/unsubscribe to the change event of application * @tc.desc : Received the account information change to the authorized account of the subscription to change * the associatal data */ @@ -170,16 +166,12 @@ describe('ActsAccountChangeOnOff', async function () { setTimeout(function (){ console.debug("====>publish event account_on_change 0200===="); commonevent.publish("account_on_change", commonEventPublishData, publishCallback); - }, 1000) - - setTimeout(function(){ - console.debug("====>time out ActsAccountChangeOnOff_0200===="); - }, TIMEOUT); + }, 1000); }); /* * @tc.number : ActsAccountChangeOnOff_0300 - * @tc.name : Subscribe/unsubscribe to the change event of the specified application + * @tc.name : Subscribe/unsubscribe to the change event of application * @tc.desc : Received the account information change to the authorized account of the subscription to change * the credential */ @@ -237,16 +229,12 @@ describe('ActsAccountChangeOnOff', async function () { setTimeout(function (){ console.debug("====>publish event account_on_change 0300===="); commonevent.publish("account_on_change", commonEventPublishData, publishCallback); - }, 1000) - - setTimeout(function(){ - console.debug("====>time out ActsAccountChangeOnOff_0300===="); - }, TIMEOUT); + }, 1000); }); /* * @tc.number : ActsAccountChangeOnOff_0400 - * @tc.name : Subscribe/unsubscribe to the change event of the specified application + * @tc.name : Subscribe/unsubscribe to the change event of application * @tc.desc : Received the account information change to the authorized account of the subscription to delete * authorized account */ @@ -308,16 +296,12 @@ describe('ActsAccountChangeOnOff', async function () { setTimeout(function (){ console.debug("====>publish event account_on_change 0400===="); commonevent.publish("account_on_change", commonEventPublishData, publishCallback); - }, 1000) - - setTimeout(function(){ - console.debug("====>time out ActsAccountChangeOnOff_0400===="); - }, TIMEOUT); + }, 1000); }); /* * @tc.number : ActsAccountChangeOnOff_0500 - * @tc.name : Subscribe/unsubscribe to the change event of the specified application + * @tc.name : Subscribe/unsubscribe to the change event of application * @tc.desc : Received the account information change to the authorized account of the subscription to delete * the only authorized account */ @@ -371,16 +355,12 @@ describe('ActsAccountChangeOnOff', async function () { setTimeout(function (){ console.debug("====>publish event account_on_change 0500===="); commonevent.publish("account_on_change", commonEventPublishData, publishCallback); - }, 1000) - - setTimeout(function(){ - console.debug("====>time out ActsAccountChangeOnOff_0500===="); - }, TIMEOUT); + }, 1000); }); /* * @tc.number : ActsAccountChangeOnOff_0600 - * @tc.name : Subscribe/unsubscribe to the change event of the specified application + * @tc.name : Subscribe/unsubscribe to the change event of application * @tc.desc : Received the account information change to the authorized account of the subscription to cancel * authorized account */ @@ -446,16 +426,12 @@ describe('ActsAccountChangeOnOff', async function () { setTimeout(function (){ console.debug("====>publish event account_on_change 0600===="); commonevent.publish("account_on_change", commonEventPublishData, publishCallback); - }, 1000) - - setTimeout(function(){ - console.debug("====>time out ActsAccountChangeOnOff_0600===="); - }, TIMEOUT); + }, 1000); }); /* * @tc.number : ActsAccountChangeOnOff_0700 - * @tc.name : Subscribe/unsubscribe to the change event of the specified application + * @tc.name : Subscribe/unsubscribe to the change event of application * @tc.desc : Received the account information change to the authorized account of the subscription to cancel * the only authorized account */ @@ -469,6 +445,9 @@ describe('ActsAccountChangeOnOff', async function () { await appAccountManager.enableAppAccess("onoff_disable", "com.example.actsaccountsceneonoff"); function unSubscriberCallback(err){ console.debug("====>unsubscribe 0700 err:" + JSON.stringify(err)); + } + function deleteAccountCallback(err){ + console.debug("====>delete account 0700 err:" + JSON.stringify(err)); expect(err.code).assertEqual(0); done(); } @@ -477,6 +456,7 @@ describe('ActsAccountChangeOnOff', async function () { expect(data.event).assertEqual("account_on_change_disable"); expect(data.data).assertEqual("SUCCESS"); commonevent.unsubscribe(subscriber, unSubscriberCallback); + appAccountManager.deleteAccount("onoff_disable", deleteAccountCallback); } function publishCallback(err){ console.debug("====>publish call back err:" + JSON.stringify(err)); @@ -509,10 +489,357 @@ describe('ActsAccountChangeOnOff', async function () { setTimeout(function (){ console.debug("====>publish event account_on_change 0700===="); commonevent.publish("account_on_change", commonEventPublishData, publishCallback); + }, 1000); + }); + + /* + * @tc.number : ActsAccountChangeOnOff_0800 + * @tc.name : Subscribe/unsubscribe to the change event of application + * @tc.desc : Receive account information after the app subscribes to itself and changes additional information + */ + it('ActsAccountChangeOnOff_0800', 0, async function (done) { + console.debug("====>ActsAccountChangeOnOff_0800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add account ActsAccountChangeOnOff_0800 start"); + await appAccountManager.addAccount("onoff_self"); + console.debug("====>on ActsAccountChangeOnOff_0800 start"); + function changeOnCallback(data){ + console.debug("====>receive change 0800 data:" + JSON.stringify(data)); + expect(data[0].name).assertEqual("onoff_self"); + expect(data[0].owner).assertEqual("com.example.actsaccounttest"); + appAccountManager.off('change', function (){ + console.debug("====>off ActsAccountChangeOnOff_0800 finish===="); + appAccountManager.deleteAccount("onoff_self", (err)=>{ + console.debug("====>delete account ActsAccountChangeOnOff_0800 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountChangeOnOff_0800 end===="); + done(); + }); + }); + } + try{ + appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnCallback); + } + catch(err){ + console.error("====>on ActsAccountChangeOnOff_0800 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>setAccountExtraInfo start===="); + try{ + await appAccountManager.setAccountExtraInfo("onoff_self", "change_extra"); + } + catch(err){ + console.error("====>setAccountExtraInfo fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + }); + + /* + * @tc.number : ActsAccountChangeOnOff_0900 + * @tc.name : Subscribe/unsubscribe to the change event of application + * @tc.desc : Receiving account information after adding two accounts to the app, subscribing to itself, + * and changing one of the associatal data + */ + it('ActsAccountChangeOnOff_0900', 0, async function (done) { + console.debug("====>ActsAccountChangeOnOff_0900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add first account ActsAccountChangeOnOff_0900 start"); + await appAccountManager.addAccount("onoff_self_first"); + console.debug("====>add second account ActsAccountChangeOnOff_0900 start"); + await appAccountManager.addAccount("onoff_self_second"); + console.debug("====>on ActsAccountChangeOnOff_0900 start"); + function changeOnCallback(data){ + console.debug("====>receive change 0900 data:" + JSON.stringify(data)); + expect(data[0].name).assertEqual("onoff_self_first"); + expect(data[0].owner).assertEqual("com.example.actsaccounttest"); + expect(data[1].name).assertEqual("onoff_self_second"); + expect(data[1].owner).assertEqual("com.example.actsaccounttest"); + appAccountManager.off('change', function (){ + console.debug("====>off ActsAccountChangeOnOff_0900 finish===="); + appAccountManager.deleteAccount("onoff_self_first", (err)=>{ + console.debug("====>delete first account 0900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount("onoff_self_second", (err)=>{ + console.debug("====>delete second account 0900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountChangeOnOff_0900 end===="); + done(); + }); + }); + }); + } + try{ + appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnCallback); + } + catch(err){ + console.error("====>on ActsAccountChangeOnOff_0900 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>setAssociatedData start===="); + try{ + await appAccountManager.setAssociatedData("onoff_self_second", "change_key", "change_value"); + } + catch(err){ + console.error("====>setAssociatedData fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + }); + + /* + * @tc.number : ActsAccountChangeOnOff_1000 + * @tc.name : Subscribe/unsubscribe to the change event of application + * @tc.desc : Repeat subscription account information changes, the subscription behavior is independent + */ + it('ActsAccountChangeOnOff_1000', 0, async function (done) { + console.debug("====>ActsAccountChangeOnOff_1000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add account ActsAccountChangeOnOff_1000 start"); + await appAccountManager.addAccount("onoff_twice"); + console.debug("====>on ActsAccountChangeOnOff_1000 start"); + var twiceSign = 0; + function changeOnFirstCallback(data){ + console.debug("====>first receive change 1000 data:" + JSON.stringify(data)); + expect(data[0].name).assertEqual("onoff_twice"); + expect(data[0].owner).assertEqual("com.example.actsaccounttest"); + twiceSign = twiceSign + 1; + } + function changeOnSecondCallback(data){ + console.debug("====>second receive change 1000 data:" + JSON.stringify(data)); + expect(data[0].name).assertEqual("onoff_twice"); + expect(data[0].owner).assertEqual("com.example.actsaccounttest"); + twiceSign = twiceSign + 1; + appAccountManager.off('change', function (){ + console.debug("====>off ActsAccountChangeOnOff_1000 finish===="); + appAccountManager.deleteAccount("onoff_twice", (err)=>{ + console.debug("====>delete account ActsAccountChangeOnOff_1000 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + expect(twiceSign).assertEqual(2); + console.debug("====>ActsAccountChangeOnOff_1000 end===="); + done(); + }); + }); + } + try{ + appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnFirstCallback); + appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnSecondCallback); + } + catch(err){ + console.error("====>on ActsAccountChangeOnOff_1000 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>setAccountExtraInfo start===="); + try{ + await appAccountManager.setAccountExtraInfo("onoff_twice", "change_extra"); + } + catch(err){ + console.error("====>setAccountExtraInfo fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + }); + + /* + * @tc.number : ActsAccountChangeOnOff_1100 + * @tc.name : Subscribe/unsubscribe to the change event of application + * @tc.desc : Subscription account information changes, where the bundleName in the parameter owners is + * duplicated + */ + it('ActsAccountChangeOnOff_1100', 0, async function (done) { + console.debug("====>ActsAccountChangeOnOff_1100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add account ActsAccountChangeOnOff_1100 start"); + await appAccountManager.addAccount("onoff_same"); + console.debug("====>on ActsAccountChangeOnOff_1100 start"); + var sameSign = 0; + function onCallBack(data){ + console.debug("====>receive change 1100 data:" + JSON.stringify(data)); + sameSign = sameSign + 1; + expect(data[0].name).assertEqual("onoff_same"); + expect(data[0].owner).assertEqual("com.example.actsaccounttest"); + } + try{ + appAccountManager.on('change', ["com.example.actsaccounttest", "com.example.actsaccounttest"], onCallBack); + } + catch(err){ + console.error("====>on ActsAccountChangeOnOff_1100 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>setAccountExtraInfo start===="); + try{ + await appAccountManager.setAccountExtraInfo("onoff_same", "change_extra"); + } + catch(err){ + console.error("====>setAccountExtraInfo fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + setTimeout(async function (){ + console.debug("====>off 1100 start===="); + expect(sameSign).assertEqual(1); + appAccountManager.off('change', function (){ + console.debug("====>off ActsAccountChangeOnOff_1100 finish===="); + appAccountManager.deleteAccount("onoff_same", (err)=>{ + console.debug("====>delete account ActsAccountChangeOnOff_1100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountChangeOnOff_1100 end===="); + done(); + }); + }); + }, 1000) + }); + + /* + * @tc.number : ActsAccountChangeOnOff_1200 + * @tc.name : Subscribe/unsubscribe to the change event of application + * @tc.desc : Repeatedly cancel the subscription after the subscription account information is changed + */ + it('ActsAccountChangeOnOff_1200', 0, async function (done) { + console.debug("====>ActsAccountChangeOnOff_1200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add account ActsAccountChangeOnOff_1200 start"); + await appAccountManager.addAccount("onoff_repeatoff"); + console.debug("====>on ActsAccountChangeOnOff_1200 start"); + function changeOnCallback(data){ + console.debug("====>receive change 1200 data:" + JSON.stringify(data)); + expect(data[0].name).assertEqual("onoff_repeatoff"); + expect(data[0].owner).assertEqual("com.example.actsaccounttest"); + appAccountManager.off('change', function (){ + console.debug("====>first off ActsAccountChangeOnOff_1200 finish===="); + appAccountManager.off('change', function (){ + console.debug("====>second off ActsAccountChangeOnOff_1200 finish===="); + setTimeout(async function (){ + console.debug("====>delete account 1200 start===="); + appAccountManager.deleteAccount("onoff_repeatoff", (err)=>{ + console.debug("====>delete account ActsAccountChangeOnOff_1200 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountChangeOnOff_1200 end===="); + done(); + }); + }, 1000) + }); + }); + } + try{ + appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnCallback); + } + catch(err){ + console.error("====>on ActsAccountChangeOnOff_1200 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>setAccountExtraInfo start===="); + try{ + await appAccountManager.setAccountExtraInfo("onoff_repeatoff", "change_extra"); + } + catch(err){ + console.error("====>setAccountExtraInfo fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + }); + + /* + * @tc.number : ActsAccountChangeOnOff_1300 + * @tc.name : Subscribe/unsubscribe to the change event of application + * @tc.desc : There is an unauthorized bundleName in the subscription parameter owners array, and the + * subscription fails + */ + it('ActsAccountChangeOnOff_1300', 0, async function (done) { + console.debug("====>ActsAccountChangeOnOff_1300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add account ActsAccountChangeOnOff_1300 start"); + await appAccountManager.addAccount("onoff_same"); + console.debug("====>on ActsAccountChangeOnOff_1300 start"); + function changeOnCallBack(data){ + console.debug("====>receive change 1300 data:" + JSON.stringify(data)); + expect().assertFail(); + done(); + } + var unauthorizedBundle = "com.example.actsaccountsceneonoff"; + try{ + appAccountManager.on('change', ["com.example.actsaccounttest", unauthorizedBundle], changeOnCallBack); + } + catch(err){ + console.error("====>on ActsAccountChangeOnOff_1300 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>setAccountExtraInfo start===="); + try{ + await appAccountManager.setAccountExtraInfo("onoff_same", "change_extra"); + } + catch(err){ + console.error("====>setAccountExtraInfo fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + setTimeout(async function (){ + console.debug("====>delete account 1300 start===="); + appAccountManager.deleteAccount("onoff_same", (err)=>{ + console.debug("====>delete account ActsAccountChangeOnOff_1300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountChangeOnOff_1300 end===="); + done(); + }); }, 1000) + }); - setTimeout(function(){ - console.debug("====>time out ActsAccountChangeOnOff_0700===="); - }, TIMEOUT); + /* + * @tc.number : ActsAccountChangeOnOff_1400 + * @tc.name : Subscribe/unsubscribe to the change event of application + * @tc.desc : There is a bundleName that does not exist in the subscription parameter owners array, and the + * subscription fails + */ + it('ActsAccountChangeOnOff_1400', 0, async function (done) { + console.debug("====>ActsAccountChangeOnOff_1400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add account ActsAccountChangeOnOff_1400 start"); + await appAccountManager.addAccount("onoff_same"); + console.debug("====>on ActsAccountChangeOnOff_1400 start"); + function changeOnCallBack(data){ + console.debug("====>receive change 1300 data:" + JSON.stringify(data)); + expect().assertFail(); + done(); + } + var nonexistentBundle = "com.example.actsaccountnoneexistent"; + try{ + appAccountManager.on('change', ["com.example.actsaccounttest", nonexistentBundle], changeOnCallBack); + } + catch(err){ + console.error("====>on ActsAccountChangeOnOff_1400 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>setAccountExtraInfo start===="); + try{ + await appAccountManager.setAccountExtraInfo("onoff_same", "change_extra"); + } + catch(err){ + console.error("====>setAccountExtraInfo fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + setTimeout(async function (){ + console.debug("====>delete account 1400 start===="); + appAccountManager.deleteAccount("onoff_same", (err)=>{ + console.debug("====>delete account ActsAccountChangeOnOff_1400 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountChangeOnOff_1400 end===="); + done(); + }); + }, 1000) }); }) \ No newline at end of file diff --git a/account/appaccount/actsgetallaccounts/entry/src/main/js/test/ExampleJsunit.test.js b/account/appaccount/actsgetallaccounts/entry/src/main/js/test/ExampleJsunit.test.js deleted file mode 100755 index b42f3629cac3a9e541eee77c8aac24a1c7e39832..0000000000000000000000000000000000000000 --- a/account/appaccount/actsgetallaccounts/entry/src/main/js/test/ExampleJsunit.test.js +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import account from '@ohos.account.appAccount' -import featureAbility from '@ohos.ability.featureability' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' - -const TIMEOUT = 2000; -const STRCOUNT = 1025; -describe('ActsGetAllAccounts', function () { - - /* - * @tc.number : ActsGetAllAccounts_0100 - * @tc.name : getAllAccounts callback - * @tc.desc : This application gets its own application information after adding an account - */ - it('ActsGetAllAccounts_0100', 0, async function (done) { - console.debug("====>ActsGetAllAccounts_0100 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - var selfBundle = "com.example.actsgetallaaccounts"; - appAccountManager.addAccount("Account_this_application_callback", (err)=>{ - console.debug("====>add account 0100 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getAllAccounts(selfBundle, (err, data)=>{ - console.debug("====>getAllAccounts 0100 err:" + JSON.stringify(err)); - console.debug("====>getAllAccounts 0100 data:" + JSON.stringify(data)); - expect(err.code).assertEqual(0); - try{ - expect(data[0].name).assertEqual("Account_this_application_callback"); - expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); - } - catch(err){ - console.error("====>getAllAccounts 0100 fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - appAccountManager.deleteAccount("Account_this_application_callback", (err)=>{ - console.debug("====>delete account 0100 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsGetAllAccounts_0100 end===="); - done(); - }); - }) - }); - }); - - /* - * @tc.number : ActsGetAllAccounts_0200 - * @tc.name : getAllAccounts promise - * @tc.desc : This application gets its own application information after adding an account - */ - it('ActsGetAllAccounts_0200', 0, async function (done) { - console.debug("====>ActsGetAllAccounts_0200 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - var selfBundle = "com.example.actsgetallaaccounts"; - console.debug("====>add account 0200 start===="); - await appAccountManager.addAccount("Account_this_application_promise"); - console.debug("====>getAllAccounts 0200 start===="); - try{ - var data = await appAccountManager.getAllAccounts(selfBundle); - } - catch(err){ - console.error("====>getAllAccounts 0200 fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - try{ - expect(data[0].name).assertEqual("Account_this_application_promise"); - expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); - } - catch(err){ - console.error("====>check data 0200 fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>delete account 0200 start===="); - await appAccountManager.deleteAccount("Account_this_application_promise"); - console.debug("====>ActsGetAllAccounts_0200 end===="); - done(); - }); - - /* - * @tc.number : ActsGetAllAccounts_0300 - * @tc.name : getAllAccounts callback - * @tc.desc : No account has been added to this application and it is not authorized by other applications to - * obtain account information for this application - */ - it('ActsGetAllAccounts_0300', 0, async function (done) { - console.debug("====>ActsGetAllAccounts_0300 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - var selfBundle = "com.example.actsgetallaaccounts"; - appAccountManager.getAllAccounts(selfBundle, (err, data)=>{ - console.debug("====>getAllAccounts 0300 err:" + JSON.stringify(err)); - console.debug("====>getAllAccounts 0300 data:" + JSON.stringify(data)); - expect(err.code).assertEqual(0); - expect(data.length).assertEqual(0); - console.debug("====>ActsGetAllAccounts_0300 end===="); - done(); - }) - }); - - /* - * @tc.number : ActsGetAllAccounts_0400 - * @tc.name : getAllAccounts promise - * @tc.desc : No account has been added to this application and it is not authorized by other applications to - * obtain account information for this application - */ - it('ActsGetAllAccounts_0400', 0, async function (done) { - console.debug("====>ActsGetAllAccounts_0400 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - var selfBundle = "com.example.actsgetallaaccounts"; - var data = await appAccountManager.getAllAccounts(selfBundle); - console.debug("====>getAllAccounts 0400 data:" + JSON.stringify(data)); - expect(data.length).assertEqual(0); - console.debug("====>ActsGetAllAccounts_0400 end===="); - done(); - }); - - /* - * @tc.number : ActsGetAllAccounts_0500 - * @tc.name : getAllAccounts callback - * @tc.desc : The parameter owner is an empty string - */ - it('ActsGetAllAccounts_0500', 0, async function (done) { - console.debug("====>ActsGetAllAccounts_0500 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - var emptyBundle = ""; - appAccountManager.getAllAccounts(emptyBundle, (err, data)=>{ - console.debug("====>getAllAccounts 0500 err:" + JSON.stringify(err)); - expect(err.code != 0).assertEqual(true); - console.debug("====>ActsGetAllAccounts_0500 end===="); - done(); - }) - }); - - /* - * @tc.number : ActsGetAllAccounts_0600 - * @tc.name : getAllAccounts promise - * @tc.desc : The parameter owner is an empty string - */ - it('ActsGetAllAccounts_0600', 0, async function (done) { - console.debug("====>ActsGetAllAccounts_0600 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - var emptyBundle = ""; - try{ - var data = await appAccountManager.getAllAccounts(emptyBundle); - } - catch(err){ - console.debug("====>getAllAccounts 0600 err:" + JSON.stringify(err)); - expect(err.code != 0).assertEqual(true); - console.debug("====>ActsGetAllAccounts_0600 end===="); - done(); - } - }); - - /* - * @tc.number : ActsGetAllAccounts_0700 - * @tc.name : getAllAccounts callback - * @tc.desc : The parameter owner is a string that exceeds the length limit - */ - it('ActsGetAllAccounts_0700', 0, async function (done) { - console.debug("====>ActsGetAllAccounts_0700 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - var bigBundleName = ''; - for (var i = 0; i < STRCOUNT; i++) { - bigBundleName += 't'; - } - appAccountManager.getAllAccounts(bigBundleName, (err, data)=>{ - console.debug("====>getAllAccounts 0700 err:" + JSON.stringify(err)); - expect(err.code != 0).assertEqual(true); - console.debug("====>ActsGetAllAccounts_0700 end===="); - done(); - }) - }); - - /* - * @tc.number : ActsGetAllAccounts_0800 - * @tc.name : getAllAccounts promise - * @tc.desc : The parameter owner is a string that exceeds the length limit - */ - it('ActsGetAllAccounts_0800', 0, async function (done) { - console.debug("====>ActsGetAllAccounts_0800 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - var bigBundleName = ''; - for (var i = 0; i < STRCOUNT; i++) { - bigBundleName += 't'; - } - try{ - var data = await appAccountManager.getAllAccounts(bigBundleName); - } - catch(err){ - console.debug("====>getAllAccounts 0800 err:" + JSON.stringify(err)); - expect(err.code != 0).assertEqual(true); - console.debug("====>ActsGetAllAccounts_0800 end===="); - done(); - } - }); - - /* - * @tc.number : ActsGetAllAccounts_0900 - * @tc.name : getAllAccounts - * @tc.desc : This application adds an account, and after other applications authorize an account to this - * application, this application obtains the information of its own application - */ - it('ActsGetAllAccounts_0900', 0, async function (done) { - console.debug("====>ActsGetAllAccounts_0900 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - var selfBundle = "com.example.actsgetallaaccounts"; - console.debug("====>add account 0900 start===="); - await appAccountManager.addAccount("Account_this_application"); - console.debug("====>startAbility 0900 start===="); - await featureAbility.startAbility( - { - want: - { - deviceId: "", - bundleName: "com.example.actsscenegetallaccounts", - abilityName: "com.example.actsscenegetallaccounts.MainAbility", - action: "action1", - parameters: - {}, - }, - }, - ); - setTimeout(async function(){ - console.debug("====>getAllAccounts 0900 start===="); - try{ - var data = await appAccountManager.getAllAccounts(selfBundle); - } - catch(err){ - console.error("====>getAllAccounts 0900 fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>getAllAccounts 0900 data:" + JSON.stringify(data)); - try{ - expect(data[0].name).assertEqual("Account_this_application"); - expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); - } - catch(err){ - console.error("====>check data 0900 fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>delete account 0900 start===="); - await appAccountManager.deleteAccount("Account_this_application"); - console.debug("====>ActsGetAllAccounts_0900 end===="); - done(); - }, TIMEOUT); - }); -}) \ No newline at end of file diff --git a/account/appaccount/actsgetallaccounts/entry/src/main/js/test/Getallaccounts.test.js b/account/appaccount/actsgetallaccounts/entry/src/main/js/test/Getallaccounts.test.js new file mode 100755 index 0000000000000000000000000000000000000000..1eec47c23b6412eec1d855a5ec3d86e1d546ae90 --- /dev/null +++ b/account/appaccount/actsgetallaccounts/entry/src/main/js/test/Getallaccounts.test.js @@ -0,0 +1,591 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import account from '@ohos.account.appAccount' +import featureAbility from '@ohos.ability.featureability' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + +const TIMEOUT = 2000; +const LENGTHLIMIT = 1024; +describe('ActsGetAllAccounts', function () { + + /* + * @tc.number : ActsGetAllAccounts_0100 + * @tc.name : getAllAccounts callback + * @tc.desc : This application gets its own application information after adding an account + */ + it('ActsGetAllAccounts_0100', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var selfBundle = "com.example.actsgetallaaccounts"; + appAccountManager.addAccount("Account_this_application_callback", (err)=>{ + console.debug("====>add account 0100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAllAccounts(selfBundle, (err, data)=>{ + console.debug("====>getAllAccounts 0100 err:" + JSON.stringify(err)); + console.debug("====>getAllAccounts 0100 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + try{ + expect(data[0].name).assertEqual("Account_this_application_callback"); + expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); + } + catch(err){ + console.error("====>getAllAccounts 0100 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + appAccountManager.deleteAccount("Account_this_application_callback", (err)=>{ + console.debug("====>delete account 0100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsGetAllAccounts_0100 end===="); + done(); + }); + }) + }); + }); + + /* + * @tc.number : ActsGetAllAccounts_0200 + * @tc.name : getAllAccounts promise + * @tc.desc : This application gets its own application information after adding an account + */ + it('ActsGetAllAccounts_0200', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var selfBundle = "com.example.actsgetallaaccounts"; + console.debug("====>add account 0200 start===="); + await appAccountManager.addAccount("Account_this_application_promise"); + console.debug("====>getAllAccounts 0200 start===="); + try{ + var data = await appAccountManager.getAllAccounts(selfBundle); + } + catch(err){ + console.error("====>getAllAccounts 0200 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + expect(data[0].name).assertEqual("Account_this_application_promise"); + expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); + } + catch(err){ + console.error("====>check data 0200 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>delete account 0200 start===="); + await appAccountManager.deleteAccount("Account_this_application_promise"); + console.debug("====>ActsGetAllAccounts_0200 end===="); + done(); + }); + + /* + * @tc.number : ActsGetAllAccounts_0300 + * @tc.name : getAllAccounts callback + * @tc.desc : No account has been added to this application and it is not authorized by other applications to + * obtain account information for this application + */ + it('ActsGetAllAccounts_0300', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_0300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var selfBundle = "com.example.actsgetallaaccounts"; + appAccountManager.getAllAccounts(selfBundle, (err, data)=>{ + console.debug("====>getAllAccounts 0300 err:" + JSON.stringify(err)); + console.debug("====>getAllAccounts 0300 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data.length).assertEqual(0); + console.debug("====>ActsGetAllAccounts_0300 end===="); + done(); + }) + }); + + /* + * @tc.number : ActsGetAllAccounts_0400 + * @tc.name : getAllAccounts promise + * @tc.desc : No account has been added to this application and it is not authorized by other applications to + * obtain account information for this application + */ + it('ActsGetAllAccounts_0400', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_0400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var selfBundle = "com.example.actsgetallaaccounts"; + var data = await appAccountManager.getAllAccounts(selfBundle); + console.debug("====>getAllAccounts 0400 data:" + JSON.stringify(data)); + expect(data.length).assertEqual(0); + console.debug("====>ActsGetAllAccounts_0400 end===="); + done(); + }); + + /* + * @tc.number : ActsGetAllAccounts_0500 + * @tc.name : getAllAccounts callback + * @tc.desc : The parameter owner is an empty string + */ + it('ActsGetAllAccounts_0500', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_0500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var emptyBundle = ""; + appAccountManager.getAllAccounts(emptyBundle, (err, data)=>{ + console.debug("====>getAllAccounts 0500 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsGetAllAccounts_0500 end===="); + done(); + }) + }); + + /* + * @tc.number : ActsGetAllAccounts_0600 + * @tc.name : getAllAccounts promise + * @tc.desc : The parameter owner is an empty string + */ + it('ActsGetAllAccounts_0600', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_0600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var emptyBundle = ""; + try{ + var data = await appAccountManager.getAllAccounts(emptyBundle); + } + catch(err){ + console.debug("====>getAllAccounts 0600 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsGetAllAccounts_0600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsGetAllAccounts_0700 + * @tc.name : getAllAccounts callback + * @tc.desc : The parameter owner is a string that exceeds the length limit + */ + it('ActsGetAllAccounts_0700', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_0700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var limitBundle = ''; + for (var i = 0; i < LENGTHLIMIT + 1; i++) { + limitBundle += 't'; + } + appAccountManager.getAllAccounts(limitBundle, (err, data)=>{ + console.debug("====>getAllAccounts 0700 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsGetAllAccounts_0700 end===="); + done(); + }) + }); + + /* + * @tc.number : ActsGetAllAccounts_0800 + * @tc.name : getAllAccounts promise + * @tc.desc : The parameter owner is a string that exceeds the length limit + */ + it('ActsGetAllAccounts_0800', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_0800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var limitBundle = ''; + for (var i = 0; i < LENGTHLIMIT + 1; i++) { + limitBundle += 'n'; + } + try{ + var data = await appAccountManager.getAllAccounts(limitBundle); + } + catch(err){ + console.debug("====>getAllAccounts 0800 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsGetAllAccounts_0800 end===="); + done(); + } + }); + + /* + * @tc.number : ActsGetAllAccounts_0900 + * @tc.name : getAllAccounts callback + * @tc.desc : This application adds an account, and after other applications authorize an account to this + * application, this application obtains the information of its own application + */ + it('ActsGetAllAccounts_0900', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_0900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var selfBundle = "com.example.actsgetallaaccounts"; + console.debug("====>add account 0900 start===="); + await appAccountManager.addAccount("Account_application_callback"); + console.debug("====>startAbility 0900 start===="); + await featureAbility.startAbility( + { + want: + { + deviceId: "", + bundleName: "com.example.actsscenegetallaccounts", + abilityName: "com.example.actsscenegetallaccounts.MainAbility", + action: "action1", + parameters: + {}, + }, + }, + ); + function getAllCallback(err, data){ + console.debug("====>getAllAccounts 0900 err:" + JSON.stringify(err)); + console.debug("====>getAllAccounts 0900 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data[0].name).assertEqual("Account_application_callback"); + expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); + appAccountManager.deleteAccount("Account_application_callback", (err)=>{ + console.debug("====>delete account 0900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsGetAllAccounts_0900 end===="); + done(); + }); + } + setTimeout(async function(){ + console.debug("====>getAllAccounts 0900 start===="); + appAccountManager.getAllAccounts(selfBundle, getAllCallback); + }, TIMEOUT); + }); + + /* + * @tc.number : ActsGetAllAccounts_1000 + * @tc.name : getAllAccounts promise + * @tc.desc : This application adds an account, and after other applications authorize an account to this + * application, this application obtains the information of its own application + */ + it('ActsGetAllAccounts_1000', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_1000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var selfBundle = "com.example.actsgetallaaccounts"; + console.debug("====>add account 1000 start===="); + await appAccountManager.addAccount("Account_application_promise"); + console.debug("====>startAbility 1000 start===="); + await featureAbility.startAbility( + { + want: + { + deviceId: "", + bundleName: "com.example.actsscenegetallaccounts", + abilityName: "com.example.actsscenegetallaccounts.MainAbility", + action: "action1", + parameters: + {}, + }, + }, + ); + setTimeout(async function(){ + console.debug("====>getAllAccounts 1000 start===="); + try{ + var data = await appAccountManager.getAllAccounts(selfBundle); + } + catch(err){ + console.error("====>getAllAccounts 1000 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAllAccounts 1000 data:" + JSON.stringify(data)); + try{ + expect(data[0].name).assertEqual("Account_application_promise"); + expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); + } + catch(err){ + console.error("====>check data 1000 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>delete account 1000 start===="); + await appAccountManager.deleteAccount("Account_application_promise"); + console.debug("====>ActsGetAllAccounts_1000 end===="); + done(); + }, TIMEOUT); + }); + + /* + * @tc.number : ActsGetAllAccounts_1100 + * @tc.name : getAllAccounts callback + * @tc.desc : This application adds an account, and after other applications authorize an account to this + * application, this application obtains the information of its own application + */ + it('ActsGetAllAccounts_1100', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_0900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var specifiedBundle = "com.example.actsscenegetallaccounts"; + console.debug("====>startAbility 1100 start===="); + await featureAbility.startAbility( + { + want: + { + deviceId: "", + bundleName: "com.example.actsscenegetallaccounts", + abilityName: "com.example.actsscenegetallaccounts.MainAbility", + action: "action1", + parameters: + {}, + }, + }, + ); + function getAllCallback(err, data){ + console.debug("====>getAllAccounts 1100 err:" + JSON.stringify(err)); + console.debug("====>getAllAccounts 1100 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data[0].name).assertEqual("account_name_scene_single"); + expect(data[0].owner).assertEqual("com.example.actsscenegetallaccounts"); + console.debug("====>ActsGetAllAccounts_1100 end===="); + done(); + } + setTimeout(async function(){ + console.debug("====>getAllAccounts 1100 start===="); + appAccountManager.getAllAccounts(specifiedBundle, getAllCallback); + }, TIMEOUT); + }); + + /* + * @tc.number : ActsGetAllAccounts_1200 + * @tc.name : getAllAccounts promise + * @tc.desc : This application adds an account, and after other applications authorize an account to this + * application, this application obtains the information of its own application + */ + it('ActsGetAllAccounts_1200', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_1200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var specifiedBundle = "com.example.actsscenegetallaccounts"; + console.debug("====>startAbility 1200 start===="); + await featureAbility.startAbility( + { + want: + { + deviceId: "", + bundleName: "com.example.actsscenegetallaccounts", + abilityName: "com.example.actsscenegetallaccounts.MainAbility", + action: "action1", + parameters: + {}, + }, + }, + ); + setTimeout(async function(){ + console.debug("====>getAllAccounts 1200 start===="); + try{ + var data = await appAccountManager.getAllAccounts(specifiedBundle); + } + catch(err){ + console.error("====>getAllAccounts 1200 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAllAccounts 1200 data:" + JSON.stringify(data)); + expect(data[0].name).assertEqual("account_name_scene_single"); + expect(data[0].owner).assertEqual("com.example.actsscenegetallaccounts"); + console.debug("====>ActsGetAllAccounts_1200 end===="); + done(); + }, TIMEOUT); + }); + + /* + * @tc.number : ActsGetAllAccounts_1300 + * @tc.name : getAllAccounts callback + * @tc.desc : The parameter owner is a bundlename that does not exist + */ + it('ActsGetAllAccounts_1300', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_1300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var nonexistentBundle = "com.example.actsgetallaccountsnonexistent"; + appAccountManager.getAllAccounts(nonexistentBundle, (err, data)=>{ + console.debug("====>getAllAccounts 1300 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsGetAllAccounts_1300 end===="); + done(); + }) + }); + + /* + * @tc.number : ActsGetAllAccounts_1400 + * @tc.name : getAllAccounts promise + * @tc.desc : The parameter owner is a bundlename that does not exist + */ + it('ActsGetAllAccounts_1400', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_1400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var nonexistentBundle = "com.example.actsgetallaccountsnonexistent"; + try{ + var data = await appAccountManager.getAllAccounts(nonexistentBundle); + } + catch(err){ + console.debug("====>getAllAccounts 1400 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsGetAllAccounts_1400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsGetAllAccounts_1500 + * @tc.name : getAllAccounts callback + * @tc.desc : Get account information after adding and deleting account + */ + it('ActsGetAllAccounts_1500', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_1500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var selfBundle = "com.example.actsgetallaaccounts"; + appAccountManager.addAccount("account_callback_delete", (err)=>{ + console.debug("====>add account 1500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAllAccounts(selfBundle, (err, data)=>{ + console.debug("====>getAllAccounts 1500 err:" + JSON.stringify(err)); + console.debug("====>getAllAccounts 1500 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data[0].name).assertEqual("account_callback_delete"); + expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); + appAccountManager.deleteAccount("account_callback_delete", (err)=>{ + console.debug("====>delete account 1500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAllAccounts(selfBundle, (err, data)=>{ + console.debug("====>getAllAccounts 1500 err:" + JSON.stringify(err)); + console.debug("====>getAllAccounts 1500 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data.length).assertEqual(0); + console.debug("====>ActsGetAllAccounts_1500 end===="); + done(); + }) + }); + }) + }); + }); + + /* + * @tc.number : ActsGetAllAccounts_1600 + * @tc.name : getAllAccounts promise + * @tc.desc : Get account information after adding and deleting account + */ + it('ActsGetAllAccounts_1600', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_1600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var selfBundle = "com.example.actsgetallaaccounts"; + console.debug("====>add account 1600 start===="); + await appAccountManager.addAccount("account_promise_delete"); + console.debug("====>first getAllAccounts 1600 start===="); + try{ + var data = await appAccountManager.getAllAccounts(selfBundle); + } + catch(err){ + console.error("====>getAllAccounts 1600 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + expect(data[0].name).assertEqual("account_promise_delete"); + expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); + console.debug("====>delete account 1600 start===="); + await appAccountManager.deleteAccount("account_promise_delete"); + console.debug("====>second getAllAccounts 1600 start===="); + try{ + var dataDelete = await appAccountManager.getAllAccounts(selfBundle); + } + catch(err){ + console.error("====>second getAllAccounts 1600 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + expect(dataDelete.length).assertEqual(0); + console.debug("====>ActsGetAllAccounts_1600 end===="); + done(); + }); + + /* + * @tc.number : ActsGetAllAccounts_1700 + * @tc.name : getAllAccounts callback + * @tc.desc : Get account information after adding an account with additional information and deleting an + * account + */ + it('ActsGetAllAccounts_1700', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_1700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var selfBundle = "com.example.actsgetallaaccounts"; + appAccountManager.addAccount("account_callback_additional", "account_extrainfo", (err)=>{ + console.debug("====>add account 1700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAllAccounts(selfBundle, (err, data)=>{ + console.debug("====>getAllAccounts 1700 err:" + JSON.stringify(err)); + console.debug("====>getAllAccounts 1700 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data[0].name).assertEqual("account_callback_additional"); + expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); + appAccountManager.deleteAccount("account_callback_additional", (err)=>{ + console.debug("====>delete account 1700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAllAccounts(selfBundle, (err, data)=>{ + console.debug("====>getAllAccounts 1700 err:" + JSON.stringify(err)); + console.debug("====>getAllAccounts 1700 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data.length).assertEqual(0); + console.debug("====>ActsGetAllAccounts_1700 end===="); + done(); + }) + }); + }) + }); + }); + + /* + * @tc.number : ActsGetAllAccounts_1800 + * @tc.name : getAllAccounts promise + * @tc.desc : Get account information after adding an account with additional information and deleting an + * account + */ + it('ActsGetAllAccounts_1800', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_1800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var selfBundle = "com.example.actsgetallaaccounts"; + console.debug("====>add account 1800 start===="); + await appAccountManager.addAccount("account_promise_additional", "account_extrainfo"); + console.debug("====>first getAllAccounts 1800 start===="); + try{ + var data = await appAccountManager.getAllAccounts(selfBundle); + } + catch(err){ + console.error("====>getAllAccounts 1800 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>first getAllAccounts 1800 data:" + JSON.stringify(data)); + expect(data[0].name).assertEqual("account_promise_additional"); + expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); + console.debug("====>delete account 1800 start===="); + await appAccountManager.deleteAccount("account_promise_additional"); + console.debug("====>second getAllAccounts 1800 start===="); + try{ + var dataDelete = await appAccountManager.getAllAccounts(selfBundle); + } + catch(err){ + console.error("====>second getAllAccounts 1800 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>second getAllAccounts 1800 data:" + JSON.stringify(data)); + expect(dataDelete.length).assertEqual(0); + console.debug("====>ActsGetAllAccounts_1800 end===="); + done(); + }); +}) \ No newline at end of file diff --git a/account/appaccount/actsgetallaccounts/entry/src/main/js/test/List.test.js b/account/appaccount/actsgetallaccounts/entry/src/main/js/test/List.test.js index c0b876e81cf0a75db974ee932d8fc06a1d5a6e66..8f39a18e324168ee07643339e39f59a584904a09 100755 --- a/account/appaccount/actsgetallaccounts/entry/src/main/js/test/List.test.js +++ b/account/appaccount/actsgetallaccounts/entry/src/main/js/test/List.test.js @@ -12,4 +12,4 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -require('./ExampleJsunit.test.js') \ No newline at end of file +require('./Getallaccounts.test.js') \ No newline at end of file diff --git a/account/appaccount/actssetchecksyncenable/entry/src/main/js/test/List.test.js b/account/appaccount/actssetchecksyncenable/entry/src/main/js/test/List.test.js index c0b876e81cf0a75db974ee932d8fc06a1d5a6e66..1328947d050117acb7c077dcff37e0074b9538af 100755 --- a/account/appaccount/actssetchecksyncenable/entry/src/main/js/test/List.test.js +++ b/account/appaccount/actssetchecksyncenable/entry/src/main/js/test/List.test.js @@ -12,4 +12,4 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -require('./ExampleJsunit.test.js') \ No newline at end of file +require('./Syncenable.test.js') \ No newline at end of file diff --git a/account/appaccount/actssetchecksyncenable/entry/src/main/js/test/ExampleJsunit.test.js b/account/appaccount/actssetchecksyncenable/entry/src/main/js/test/Syncenable.test.js similarity index 100% rename from account/appaccount/actssetchecksyncenable/entry/src/main/js/test/ExampleJsunit.test.js rename to account/appaccount/actssetchecksyncenable/entry/src/main/js/test/Syncenable.test.js diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/test/ExampleJsunit.test.js b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/test/Getallaccessible.test.js similarity index 99% rename from account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/test/ExampleJsunit.test.js rename to account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/test/Getallaccessible.test.js index 71ea464177c4d3ce987e05f8d532038e60d85dea..7f1a4c3b5a3c09b7c86ecd635decfce02c3d1487 100755 --- a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/test/ExampleJsunit.test.js +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/test/Getallaccessible.test.js @@ -17,7 +17,6 @@ import featureAbility from '@ohos.ability.featureability' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' const TIMEOUT = 2000; -const TIMEOUTEND = 4000; describe('ActsGetAllAccessibleAccounts', function () { /* @@ -534,8 +533,5 @@ describe('ActsGetAllAccessibleAccounts', function () { console.debug("====>ActsGetAllAccessibleAccounts_1100 end===="); done(); }, TIMEOUT); - setTimeout(function(){ - console.debug("====>time out ActsGetAllAccessibleAccounts_1100===="); - }, TIMEOUTEND); }); }) \ No newline at end of file diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/test/List.test.js b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/test/List.test.js index c0b876e81cf0a75db974ee932d8fc06a1d5a6e66..493d3c706514721f75a835604b23f2c48af2941a 100755 --- a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/test/List.test.js +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/test/List.test.js @@ -12,4 +12,4 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -require('./ExampleJsunit.test.js') \ No newline at end of file +require('./Getallaccessible.test.js') \ No newline at end of file diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/test/ExampleJsunit.test.js b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/test/Getmultiple.test.js similarity index 97% rename from account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/test/ExampleJsunit.test.js rename to account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/test/Getmultiple.test.js index 6df1f5e4ea6c9283c0d7eb4ad71f60ee8b759cf6..ff650ef2fefec4481c7805a9b669858ef7491d7b 100755 --- a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/test/ExampleJsunit.test.js +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/test/Getmultiple.test.js @@ -17,8 +17,6 @@ import featureAbility from '@ohos.ability.featureability' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' const TIMEOUT = 3000; -const TIMEOUTEND = 5000; - describe('ActsGetAllAccessibleMultiple', function () { beforeAll(async function (done) { console.debug("====>startAbility first 0100 start===="); @@ -108,8 +106,5 @@ describe('ActsGetAllAccessibleMultiple', function () { console.debug("====>ActsGetAllAccessibleAccounts_0100 end===="); done(); }, TIMEOUT); - setTimeout(function(){ - console.debug("====>time out ActsGetAllAccessibleMultiple_0100====>"); - }, TIMEOUTEND); }); }) \ No newline at end of file diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/test/List.test.js b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/test/List.test.js index c0b876e81cf0a75db974ee932d8fc06a1d5a6e66..8d14530a57213b2cb91c030c960702328ef95a1a 100755 --- a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/test/List.test.js +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/test/List.test.js @@ -12,4 +12,4 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -require('./ExampleJsunit.test.js') \ No newline at end of file +require('./Getmultiple.test.js') \ No newline at end of file diff --git a/account/appaccount/sceneProject/actsaccountaccessibleFirst/BUILD.gn b/account/appaccount/sceneProject/actsaccountaccessibleFirst/BUILD.gn index 6cb4ea07949f584c1094fc8ca0f7dc440b0dcc82..6d98ebaae9a59e396cf263a054ddf45153216eab 100755 --- a/account/appaccount/sceneProject/actsaccountaccessibleFirst/BUILD.gn +++ b/account/appaccount/sceneProject/actsaccountaccessibleFirst/BUILD.gn @@ -10,17 +10,20 @@ # 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("ActsAccountAccessibleFirst") { +ohos_hap("ActsAccountAccessibleFirst") { hap_profile = "./entry/src/main/config.json" + hap_name = "ActsAccountAccessibleFirst" + subsystem_name = XTS_SUITENAME + final_hap_path = + "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap" + testonly = true deps = [ ":hjs_demo_js_assets", ":hjs_demo_resources", ] certificate_profile = "./signature/openharmony_sx.p7b" - hap_name = "ActsAccountAccessibleFirst" } ohos_js_assets("hjs_demo_js_assets") { source_dir = "./entry/src/main/js/default" diff --git a/account/appaccount/sceneProject/actsaccountaccessibleSecond/BUILD.gn b/account/appaccount/sceneProject/actsaccountaccessibleSecond/BUILD.gn index d3d0df12ce1a750a421d63970dc72c9b014279e2..6b1a93c1e406a9796bcd1819087e44f8cdda2dcc 100755 --- a/account/appaccount/sceneProject/actsaccountaccessibleSecond/BUILD.gn +++ b/account/appaccount/sceneProject/actsaccountaccessibleSecond/BUILD.gn @@ -10,17 +10,20 @@ # 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("ActsAccountAccessibleSecond") { +ohos_hap("ActsAccountAccessibleSecond") { hap_profile = "./entry/src/main/config.json" + hap_name = "ActsAccountAccessibleSecond" + subsystem_name = XTS_SUITENAME + final_hap_path = + "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap" + testonly = true deps = [ ":hjs_demo_js_assets", ":hjs_demo_resources", ] certificate_profile = "./signature/openharmony_sx.p7b" - hap_name = "ActsAccountAccessibleSecond" } ohos_js_assets("hjs_demo_js_assets") { source_dir = "./entry/src/main/js/default" diff --git a/account/appaccount/sceneProject/actsaccountsceneaccessible/BUILD.gn b/account/appaccount/sceneProject/actsaccountsceneaccessible/BUILD.gn index 60007607052148d62ee2dfb367e98680883816e1..0837d2a700ca779eb3c0ec27e134be9730557ed3 100755 --- a/account/appaccount/sceneProject/actsaccountsceneaccessible/BUILD.gn +++ b/account/appaccount/sceneProject/actsaccountsceneaccessible/BUILD.gn @@ -10,17 +10,20 @@ # 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("ActsAccountSceneAccessible") { +ohos_hap("ActsAccountSceneAccessible") { hap_profile = "./entry/src/main/config.json" + hap_name = "ActsAccountSceneAccessible" + subsystem_name = XTS_SUITENAME + final_hap_path = + "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap" + testonly = true deps = [ ":hjs_demo_js_assets", ":hjs_demo_resources", ] certificate_profile = "./signature/openharmony_sx.p7b" - hap_name = "ActsAccountSceneAccessible" } ohos_js_assets("hjs_demo_js_assets") { source_dir = "./entry/src/main/js/default" diff --git a/account/appaccount/sceneProject/actsaccountsceneappaccess/BUILD.gn b/account/appaccount/sceneProject/actsaccountsceneappaccess/BUILD.gn index 47390cf5c697d832b3cf9511fec207215da92f19..42edc0d80c6da4b186b3fcfb953c56cceeba36d3 100755 --- a/account/appaccount/sceneProject/actsaccountsceneappaccess/BUILD.gn +++ b/account/appaccount/sceneProject/actsaccountsceneappaccess/BUILD.gn @@ -10,17 +10,20 @@ # 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("ActsAccountSceneAppAccess") { +ohos_hap("ActsAccountSceneAppAccess") { hap_profile = "./entry/src/main/config.json" + hap_name = "ActsAccountSceneAppAccess" + subsystem_name = XTS_SUITENAME + final_hap_path = + "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap" + testonly = true deps = [ ":hjs_demo_js_assets", ":hjs_demo_resources", ] certificate_profile = "./signature/openharmony_sx.p7b" - hap_name = "ActsAccountSceneAppAccess" } ohos_js_assets("hjs_demo_js_assets") { source_dir = "./entry/src/main/js/default" diff --git a/account/appaccount/sceneProject/actsaccountsceneonoff/BUILD.gn b/account/appaccount/sceneProject/actsaccountsceneonoff/BUILD.gn index 7834b5a2114f4eb7281fc8d8d1676d48fae9f533..12724a21e36f2f246e455d24654929f7df74a092 100755 --- a/account/appaccount/sceneProject/actsaccountsceneonoff/BUILD.gn +++ b/account/appaccount/sceneProject/actsaccountsceneonoff/BUILD.gn @@ -10,17 +10,20 @@ # 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("ActsAccountSceneOnOff") { +ohos_hap("ActsAccountSceneOnOff") { hap_profile = "./entry/src/main/config.json" + hap_name = "ActsAccountSceneOnOff" + subsystem_name = XTS_SUITENAME + final_hap_path = + "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap" + testonly = true deps = [ ":hjs_demo_js_assets", ":hjs_demo_resources", ] certificate_profile = "./signature/openharmony_sx.p7b" - hap_name = "ActsAccountSceneOnOff" } ohos_js_assets("hjs_demo_js_assets") { source_dir = "./entry/src/main/js/default" diff --git a/account/appaccount/sceneProject/actsaccountsceneonoff/entry/src/main/js/default/pages/index/index.js b/account/appaccount/sceneProject/actsaccountsceneonoff/entry/src/main/js/default/pages/index/index.js index 901d37a0eaafb784d9c8fb4e7bd923041d58a7af..ebf6a328a8905b72040b856f057c1b9fb590f519 100755 --- a/account/appaccount/sceneProject/actsaccountsceneonoff/entry/src/main/js/default/pages/index/index.js +++ b/account/appaccount/sceneProject/actsaccountsceneonoff/entry/src/main/js/default/pages/index/index.js @@ -14,6 +14,14 @@ */ import account from '@ohos.account.appAccount' import commonevent from '@ohos.commonevent' + +const ACCOUNT_TEST_ONOFF_EXTRA = 1 +const ACCOUNT_TEST_ONOFF_ASSOCIATEDDATA = 2 +const ACCOUNT_TEST_ONOFF_CREDENTIAL = 3 +const ACCOUNT_TEST_ONOFF_DELETE = 4 +const ACCOUNT_TEST_ONOFF_DELETEONLY = 5 +const ACCOUNT_TEST_ONOFF_DISABLE = 6 +const ACCOUNT_TEST_ONOFF_DISABLEONLY = 7 const injectRef = Object.getPrototypeOf(global) || global injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') @@ -29,6 +37,9 @@ export default { var commonEventSubscribeInfo = { events: ["account_on_change"] } + + // The callback of the event that publishes the verification result to the test application, and unsubscribe + // the change of account information function publishCallback(err){ console.debug("====>publish call back scene err:" + JSON.stringify(err)); console.debug("====>scene off start===="); @@ -36,10 +47,13 @@ export default { console.debug("====>scene off finish===="); }); } + + // Subscribe to the callback of account information changes, verify the received account information, and send + // an event with the verification result to the test application function changeOnExtra(data){ console.debug("====>receive change 0100 data:" + JSON.stringify(data)); try{ - if(data[0].owner == "com.example.actsaccountchangeonoff" && data[0].name == "changeonoff_extra"){ + if(data[0].owner == "com.example.actsaccounttest" && data[0].name == "changeonoff_extra"){ var commonEventPublishData = { data: "SUCCESS" } @@ -58,10 +72,11 @@ export default { commonevent.publish("account_on_change_extra", commonEventPublishData, publishCallback); } } + function changeOnAssociateData(data){ console.debug("====>receive change 0200 data:" + JSON.stringify(data)); try{ - if(data[0].owner == "com.example.actsaccountchangeonoff" && data[0].name == "onoff_associatedata"){ + if(data[0].owner == "com.example.actsaccounttest" && data[0].name == "onoff_associatedata"){ var commonEventPublishData = { data: "SUCCESS" } @@ -80,10 +95,11 @@ export default { commonevent.publish("account_on_change_associatedata", commonEventPublishData, publishCallback); } } + function changeOnCredential(data){ console.debug("====>receive change 0300 data:" + JSON.stringify(data)); try{ - if(data[0].owner == "com.example.actsaccountchangeonoff" && data[0].name == "onoff_credential"){ + if(data[0].owner == "com.example.actsaccounttest" && data[0].name == "onoff_credential"){ var commonEventPublishData = { data: "SUCCESS" } @@ -102,10 +118,11 @@ export default { commonevent.publish("account_on_change_credential", commonEventPublishData, publishCallback); } } + function changeOnDeleteAnother(data){ console.debug("====>receive change 0400 data:" + JSON.stringify(data)); try{ - if(data[0].owner == "com.example.actsaccountchangeonoff" && data[0].name == "onoff_deleteFir"){ + if(data[0].owner == "com.example.actsaccounttest" && data[0].name == "onoff_deleteFir"){ var commonEventPublishData = { data: "SUCCESS" } @@ -124,6 +141,7 @@ export default { commonevent.publish("account_on_delete_another", commonEventPublishData, publishCallback); } } + function changeOnDelete(data){ console.debug("====>receive change 0500 data:" + JSON.stringify(data)); try{ @@ -146,10 +164,11 @@ export default { commonevent.publish("account_on_change_delete", commonEventPublishData, publishCallback); } } + function changeOnDisableAnother(data){ console.debug("====>receive change 0600 data:" + JSON.stringify(data)); try{ - if(data[0].owner == "com.example.actsaccountchangeonoff" && data[0].name == "onoff_enableFir"){ + if(data[0].owner == "com.example.actsaccounttest" && data[0].name == "onoff_enableFir"){ var commonEventPublishData = { data: "SUCCESS" } @@ -168,6 +187,7 @@ export default { commonevent.publish("account_on_disable_another", commonEventPublishData, publishCallback); } } + function changeOnDisable(data){ console.debug("====>receive change 0700 data:" + JSON.stringify(data)); try{ @@ -190,37 +210,39 @@ export default { commonevent.publish("account_on_change_disable", commonEventPublishData, publishCallback); } } + + // Receive events sent by the test application to correspond to different test cases function subscriberCallback(err, data){ console.debug("====>receive event err:" + JSON.stringify(err)); console.debug("====>receive event data:" + JSON.stringify(data)); switch(data.code){ - case 1: + case ACCOUNT_TEST_ONOFF_EXTRA: console.debug("====>receive event 0100 event:" + data.event); - appAccountManager.on('change', ["com.example.actsaccountchangeonoff"], changeOnExtra); + appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnExtra); break; - case 2: + case ACCOUNT_TEST_ONOFF_ASSOCIATEDDATA: console.debug("====>receive event 0200 event:" + data.event); - appAccountManager.on('change', ["com.example.actsaccountchangeonoff"], changeOnAssociateData); + appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnAssociateData); break; - case 3: + case ACCOUNT_TEST_ONOFF_CREDENTIAL: console.debug("====>receive event 0300 event:" + data.event); - appAccountManager.on('change', ["com.example.actsaccountchangeonoff"], changeOnCredential); + appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnCredential); break; - case 4: + case ACCOUNT_TEST_ONOFF_DELETE: console.debug("====>receive event 0400 event:" + data.event); - appAccountManager.on('change', ["com.example.actsaccountchangeonoff"], changeOnDeleteAnother); + appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnDeleteAnother); break; - case 5: + case ACCOUNT_TEST_ONOFF_DELETEONLY: console.debug("====>receive event 0500 event:" + data.event); - appAccountManager.on('change', ["com.example.actsaccountchangeonoff"], changeOnDelete); + appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnDelete); break; - case 6: + case ACCOUNT_TEST_ONOFF_DISABLE: console.debug("====>receive event 0600 event:" + data.event); - appAccountManager.on('change', ["com.example.actsaccountchangeonoff"], changeOnDisableAnother); + appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnDisableAnother); break; - case 7: + case ACCOUNT_TEST_ONOFF_DISABLEONLY: console.debug("====>receive event 0700 event:" + data.event); - appAccountManager.on('change', ["com.example.actsaccountchangeonoff"], changeOnDisable); + appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnDisable); break; default: console.debug("====>receive event enter default===="); diff --git a/account/appaccount/sceneProject/actsscenegetallaccounts/BUILD.gn b/account/appaccount/sceneProject/actsscenegetallaccounts/BUILD.gn index 6ec46329b322d82f31bd6c27445a5d2b671d0dc2..d8d2e6091353f8030cedb142909fff3ad09ca4fe 100755 --- a/account/appaccount/sceneProject/actsscenegetallaccounts/BUILD.gn +++ b/account/appaccount/sceneProject/actsscenegetallaccounts/BUILD.gn @@ -10,17 +10,20 @@ # 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("ActsSceneGetAllAccounts") { +ohos_hap("ActsSceneGetAllAccounts") { hap_profile = "./entry/src/main/config.json" + hap_name = "ActsSceneGetAllAccounts" + subsystem_name = XTS_SUITENAME + final_hap_path = + "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap" + testonly = true deps = [ ":hjs_demo_js_assets", ":hjs_demo_resources", ] certificate_profile = "./signature/openharmony_sx.p7b" - hap_name = "ActsSceneGetAllAccounts" } ohos_js_assets("hjs_demo_js_assets") { source_dir = "./entry/src/main/js/default"