diff --git a/account/BUILD.gn b/account/BUILD.gn index 23bee6b47551d95607f8428cf58020cd1ee3aa8f..f53e90c68030c8d08396551c480db15d10afed28 100755 --- a/account/BUILD.gn +++ b/account/BUILD.gn @@ -15,11 +15,11 @@ import("//build/ohos_var.gni") group("account") { testonly = true if (is_standard_system) { - deps = [ "OsAccountTest_js:osaccount_js_test" ] - } else { deps = [ + "OsAccountTest_js:osaccount_js_test", "appaccount:appaccount_hap", - "osaccount:osaccount_hap", ] + } else { + deps = [] } } diff --git a/account/appaccount/BUILD.gn b/account/appaccount/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..fd7341476df08398d3ef59bc74e4d90533d2aae7 --- /dev/null +++ b/account/appaccount/BUILD.gn @@ -0,0 +1,28 @@ +# 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") + +group("appaccount_hap") { + testonly = true + if (is_standard_system) { + deps = [ + "actsaccountchangeonoff:ActsAccountChangeOnOff", + "actsaccounttest:ActsAccountTest", + "actsgetallaccounts:ActsGetAllAccounts", + "actssetchecksyncenable:ActsSetCheckSyncEnable", + "getallaccessibleaccounts:accessibleaccounts", + "sceneProject:appaccount_scene", + ] + } +} diff --git a/account/appaccount/actsaccountchangeonoff/BUILD.gn b/account/appaccount/actsaccountchangeonoff/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..c2a6147085937ba33c658b52cb1412c116d20993 --- /dev/null +++ b/account/appaccount/actsaccountchangeonoff/BUILD.gn @@ -0,0 +1,31 @@ +# 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 new file mode 100755 index 0000000000000000000000000000000000000000..6a7f0231cf022b5f74975e85176bedb90aac586f --- /dev/null +++ b/account/appaccount/actsaccountchangeonoff/Test.json @@ -0,0 +1,19 @@ +{ + "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 new file mode 100755 index 0000000000000000000000000000000000000000..f1e5d6e6ddb8ec32c517a98bb960e36b4b9248b7 --- /dev/null +++ b/account/appaccount/actsaccountchangeonoff/entry/src/main/config.json @@ -0,0 +1,61 @@ +{ + "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 new file mode 100755 index 0000000000000000000000000000000000000000..2a68c1992145a976957d7dcdd69a7e9c2e8e9877 --- /dev/null +++ b/account/appaccount/actsaccountchangeonoff/entry/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* + * 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 new file mode 100755 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/account/appaccount/actsaccountchangeonoff/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "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 new file mode 100755 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/account/appaccount/actsaccountchangeonoff/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "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 new file mode 100755 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/account/appaccount/actsaccountchangeonoff/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.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 new file mode 100755 index 0000000000000000000000000000000000000000..c45422b42d0bf788a1c2c0eb299a981f07ce8613 --- /dev/null +++ b/account/appaccount/actsaccountchangeonoff/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{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 new file mode 100755 index 0000000000000000000000000000000000000000..74740202b30376b23e2ae4be39b77ca839184db7 --- /dev/null +++ b/account/appaccount/actsaccountchangeonoff/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,45 @@ +/* + * 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 new file mode 100755 index 0000000000000000000000000000000000000000..52b714402b5bcddb2305cb1d6fa78f0250fec256 --- /dev/null +++ b/account/appaccount/actsaccountchangeonoff/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "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 new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/account/appaccount/actsaccountchangeonoff/entry/src/main/js/resources/base/media/icon.png differ diff --git a/account/appaccount/actsaccountchangeonoff/entry/src/main/js/test/ExampleJsunit.test.js b/account/appaccount/actsaccountchangeonoff/entry/src/main/js/test/ExampleJsunit.test.js new file mode 100755 index 0000000000000000000000000000000000000000..5aa08857f861e51d388b70facf492766a3a8666c --- /dev/null +++ b/account/appaccount/actsaccountchangeonoff/entry/src/main/js/test/ExampleJsunit.test.js @@ -0,0 +1,102 @@ +/* + * 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 commonevent from '@ohos.commonevent' +import featureAbility from '@ohos.ability.featureability' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + +const TIMEOUT = 5000; +describe('ActsAccountChangeOnOff', async function () { + + beforeAll(async function (done) { + console.debug("====>startAbility start===="); + await featureAbility.startAbility( + { + want: + { + deviceId: "", + bundleName: "com.example.actsaccountsceneonoff", + abilityName: "com.example.actsaccountsceneonoff.MainAbility", + action: "action1", + parameters: + {}, + }, + }, + ); + setTimeout(done(), TIMEOUT); + }); + + /* + * @tc.number : ActsAccountChangeOnOff_0100 + * @tc.name : Subscribe/unsubscribe to the change event of the specified application + * @tc.desc : Received the account information change to the authorized account of the subscription to change + * the additional information + */ + it('ActsAccountChangeOnOff_0100', 0, async function (done) { + console.debug("====>ActsAccountChangeOnOff_0100 start====>"); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add account ActsAccountChangeOnOff_0100 start"); + await appAccountManager.addAccount("changeonoff_first"); + console.debug("====>enableAppAccess ActsAccountChangeOnOff_0100 start"); + await appAccountManager.enableAppAccess("changeonoff_first", "com.example.actsaccountsceneonoff"); + function unSubscriberCallback(err){ + console.debug("====>unsubscribe 0100 err:" + JSON.stringify(err)); + } + function subscriberCallback(err, data){ + console.debug("====>subscriberCallback 0100 data:" + JSON.stringify(data)); + expect(data.event).assertEqual("account_on_change_first"); + expect(data.data).assertEqual("SUCCESS"); + commonevent.unsubscribe(subscriber, unSubscriberCallback); + done(); + } + function publishCallback(err){ + console.debug("====>publish call back err:" + JSON.stringify(err)); + setTimeout(async function (){ + console.debug("====>setAccountExtraInfo start===="); + console.debug("====>setAccountExtraInfo ActsAccountChangeOnOff_0100 start"); + try{ + await appAccountManager.setAccountExtraInfo("changeonoff_first", "change_extra"); + } + catch(err){ + console.error("====>setAccountExtraInfo fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + }, 500) + } + var commonEventSubscribeInfo = { + events: ["account_on_change_first"] + } + var subscriber + commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){ + subscriber = data; + commonevent.subscribe(subscriber, subscriberCallback); + console.debug("====>subscribe ActsAccountChangeOnOff_0100 finish====") + }); + + var commonEventPublishData = { + code: 1 + } + 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); + }); +}) \ No newline at end of file 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 new file mode 100755 index 0000000000000000000000000000000000000000..c0b876e81cf0a75db974ee932d8fc06a1d5a6e66 --- /dev/null +++ b/account/appaccount/actsaccountchangeonoff/entry/src/main/js/test/List.test.js @@ -0,0 +1,15 @@ +/* + * 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 new file mode 100755 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/account/appaccount/actsaccountchangeonoff/signature/openharmony_sx.p7b differ diff --git a/account/appaccount/actsaccounttest/BUILD.gn b/account/appaccount/actsaccounttest/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..0a668834c230e3a7049d4f06c222612f4130d32c --- /dev/null +++ b/account/appaccount/actsaccounttest/BUILD.gn @@ -0,0 +1,31 @@ +# 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("ActsAccountTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsAccountTest" +} +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/actsaccounttest/Test.json b/account/appaccount/actsaccounttest/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..de5b6c2c7551756e15a0a49f9e48b3215c3bd083 --- /dev/null +++ b/account/appaccount/actsaccounttest/Test.json @@ -0,0 +1,19 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "200000", + "package": "com.example.actsaccounttest", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAccountTest.hap", + "ActsAccountSceneAppAccess.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/account/appaccount/actsaccounttest/entry/src/main/config.json b/account/appaccount/actsaccounttest/entry/src/main/config.json new file mode 100755 index 0000000000000000000000000000000000000000..5e7e86957ad2c467082261e8150641a6d29c1f74 --- /dev/null +++ b/account/appaccount/actsaccounttest/entry/src/main/config.json @@ -0,0 +1,61 @@ +{ + "app": { + "bundleName": "com.example.actsaccounttest", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsaccounttest", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.actsaccounttest.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/actsaccounttest/entry/src/main/js/default/app.js b/account/appaccount/actsaccounttest/entry/src/main/js/default/app.js new file mode 100755 index 0000000000000000000000000000000000000000..2a68c1992145a976957d7dcdd69a7e9c2e8e9877 --- /dev/null +++ b/account/appaccount/actsaccounttest/entry/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* + * 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/actsaccounttest/entry/src/main/js/default/i18n/en-US.json b/account/appaccount/actsaccounttest/entry/src/main/js/default/i18n/en-US.json new file mode 100755 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/account/appaccount/actsaccounttest/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/account/appaccount/actsaccounttest/entry/src/main/js/default/i18n/zh-CN.json b/account/appaccount/actsaccounttest/entry/src/main/js/default/i18n/zh-CN.json new file mode 100755 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/account/appaccount/actsaccounttest/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/account/appaccount/actsaccounttest/entry/src/main/js/default/pages/index/index.css b/account/appaccount/actsaccounttest/entry/src/main/js/default/pages/index/index.css new file mode 100755 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/account/appaccount/actsaccounttest/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/account/appaccount/actsaccounttest/entry/src/main/js/default/pages/index/index.hml b/account/appaccount/actsaccounttest/entry/src/main/js/default/pages/index/index.hml new file mode 100755 index 0000000000000000000000000000000000000000..c45422b42d0bf788a1c2c0eb299a981f07ce8613 --- /dev/null +++ b/account/appaccount/actsaccounttest/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{title}} + +
diff --git a/account/appaccount/actsaccounttest/entry/src/main/js/default/pages/index/index.js b/account/appaccount/actsaccounttest/entry/src/main/js/default/pages/index/index.js new file mode 100755 index 0000000000000000000000000000000000000000..bdfe319894ba9c19a6fbbd85bf20289aaac0e287 --- /dev/null +++ b/account/appaccount/actsaccounttest/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,42 @@ +/* + * 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 { + onInit() { + this.title = "Application account js test"; + }, + 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/actsaccounttest/entry/src/main/js/resources/base/element/string.json b/account/appaccount/actsaccounttest/entry/src/main/js/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..33e22aa3af86be72867076efc4c950899185b180 --- /dev/null +++ b/account/appaccount/actsaccounttest/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ActsAccountTest" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/account/appaccount/actsaccounttest/entry/src/main/js/resources/base/media/icon.png b/account/appaccount/actsaccounttest/entry/src/main/js/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/account/appaccount/actsaccounttest/entry/src/main/js/resources/base/media/icon.png differ 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 new file mode 100755 index 0000000000000000000000000000000000000000..07b1d7c7d1c8d7a24426aad5e3ff2946ae200777 --- /dev/null +++ b/account/appaccount/actsaccounttest/entry/src/main/js/test/AddAccount.test.js @@ -0,0 +1,542 @@ +/* + * 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + +const STRCOUNT = 1025; +describe('ActsAccountAddAccount', function () { + + /* + * @tc.number : ActsAccountAddAccount_0100 + * @tc.name : Add account calllback form + * @tc.desc : Add account in calllback form without additional information + */ + it('ActsAccountAddAccount_0100', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_callback_first", (err)=>{ + console.debug("====>add account ActsAccountAddAccount_0100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount("account_name_callback_first", (err)=>{ + console.debug("====>delete Account ActsAccountAddAccount_0100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAddAccount_0100 end===="); + done(); + }); + }); + }); + + /* + * @tc.number : ActsAccountAddAccount_0200 + * @tc.name : Add account promise form + * @tc.desc : Add account in promise form without additional information + */ + it('ActsAccountAddAccount_0200', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account start===="); + try{ + await appAccountManager.addAccount("account_name_promise_first"); + } + catch(err){ + console.error("====>add account fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>delete account start===="); + await appAccountManager.deleteAccount("account_name_promise_first"); + console.debug("====>ActsAccountAddAccount_0200 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountAddAccount_0300 + * @tc.name : Add account calllback form + * @tc.desc : Add account in calllback form with additional information + */ + it('ActsAccountAddAccount_0300', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_0300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_callback_second", "account_extraInfo_callback_second", (err)=>{ + console.debug("====>add account ActsAccountAddAccount_0300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount("account_name_callback_second", (err)=>{ + console.debug("====>delete Account ActsAccountAddAccount_0300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAddAccount_0300 end===="); + done(); + }); + }); + }); + + /* + * @tc.number : ActsAccountAddAccount_0400 + * @tc.name : Add account promise form + * @tc.desc : Add account in promise form with additional information + */ + it('ActsAccountAddAccount_0400', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_0400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account start===="); + try{ + await appAccountManager.addAccount("account_name_promise_second", "account_extraInfo_promise_second"); + } + catch(err){ + console.error("====>add account fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>delete account start===="); + await appAccountManager.deleteAccount("account_name_promise_second"); + console.debug("====>ActsAccountAddAccount_0400 end===="); + done(); + }); + + + /* + * @tc.number : ActsAccountAddAccount_0500 + * @tc.name : Add account calllback form + * @tc.desc : Repeatedly add the same name account and the same additional information + */ + it('ActsAccountAddAccount_0500', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_0500 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_name_callback_third", "account_extraInfo_callback_third", (err)=>{ + console.debug("====>add account first time ActsAccountAddAccount_0500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.addAccount("account_name_callback_third", "account_extraInfo_callback_third", (err)=>{ + console.debug("====>add account second time ActsAccountAddAccount_0500 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + appAccountManager.deleteAccount("account_name_callback_third", (err)=>{ + console.debug("====>delete Account ActsAccountAddAccount_0500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAddAccount_0500 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountAddAccount_0600 + * @tc.name : Add account promise form + * @tc.desc : Repeatedly add the same name account and the same additional information + */ + it('ActsAccountAddAccount_0600', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_0600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>add account for the first time ActsAccountAddAccount_0600===="); + await appAccountManager.addAccount("account_name_promise_third", "account_extraInfo_promise_third"); + console.debug("====>add account for the second time ActsAccountAddAccount_0600 start===="); + try{ + await appAccountManager.addAccount("account_name_promise_third", "account_extraInfo_promise_third"); + } + catch(err){ + console.debug("====>add account for the second time 0600 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + await appAccountManager.deleteAccount("account_name_promise_third"); + console.debug("====>ActsAccountAddAccount_0600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountAddAccount_0700 + * @tc.name : Add account calllback form + * @tc.desc : The account name exceeds the length limit of 1024 + */ + it('ActsAccountAddAccount_0700', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_0700 start===="); + var bigAccountName = ''; + for (var i = 0; i < STRCOUNT; i++) { + bigAccountName += 't'; + } + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount(bigAccountName, "account_extraInfo_callback_fourth", (err)=>{ + console.debug("====>add account ActsAccountAddAccount_0700 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountAddAccount_0700 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsAccountAddAccount_0800 + * @tc.name : Add account promise form + * @tc.desc : The account name exceeds the length limit of 1024 + */ + it('ActsAccountAddAccount_0800', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_0800 start===="); + var bigStr = ''; + for (var i = 0; i < STRCOUNT; i++) { + bigStr += 't'; + } + var appAccountManager = account.createAppAccountManager(); + try{ + await appAccountManager.addAccount(bigStr, "account_extraInfo_promise_fourth"); + } + catch(err){ + console.debug("====>add account ActsAccountAddAccount_0800 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountAddAccount_0800 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountAddAccount_0900 + * @tc.name : Add account calllback form + * @tc.desc : Additional information exceeds the length limit of 1024 + */ + it('ActsAccountAddAccount_0900', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_0900 start===="); + var bigExtraInfo = ''; + for (var i = 0; i < STRCOUNT; i++) { + bigExtraInfo += 't'; + } + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_name_callback_fifth", bigExtraInfo, (err)=>{ + console.debug("====>add account ActsAccountAddAccount_0900 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountAddAccount_0900 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsAccountAddAccount_1000 + * @tc.name : Add account promise form + * @tc.desc : Additional information exceeds the length limit of 1024 + */ + it('ActsAccountAddAccount_1000', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_1000 start===="); + var bigStrExtra = ''; + for (var i = 0; i < STRCOUNT; i++) { + bigStrExtra += 't'; + } + var appAccountManager = account.createAppAccountManager(); + try{ + await appAccountManager.addAccount("account_name_promise_fifth", bigStrExtra); + } + catch(err){ + console.debug("====>add account ActsAccountAddAccount_1000 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountAddAccount_1000 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountAddAccount_1100 + * @tc.name : Add account calllback form + * @tc.desc : The account name is an empty string + */ + it('ActsAccountAddAccount_1100', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_1100 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("", "account_name_callback_sixth", (err)=>{ + console.debug("====>add account ActsAccountAddAccount_1100 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountAddAccount_1100 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsAccountAddAccount_1200 + * @tc.name : Add account promise form + * @tc.desc : The account name is an empty string + */ + it('ActsAccountAddAccount_1200', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_1200 start===="); + console.debug("====>ActsAccountAddAccount_1200 add account start===="); + var appAccountManager = account.createAppAccountManager(); + try{ + await appAccountManager.addAccount("", "account_name_promise_sixth"); + } + catch(err){ + console.debug("====>add account ActsAccountAddAccount_1200 err:"+ JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountAddAccount_1200 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountAddAccount_1300 + * @tc.name : Add account calllback form + * @tc.desc : Additional information is an empty string + */ + it('ActsAccountAddAccount_1300', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_1300 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_name_callback_seventh", "", (err)=>{ + console.debug("====>add account ActsAccountAddAccount_1300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount("account_name_callback_seventh", (err)=>{ + console.debug("====>delete Account ActsAccountAddAccount_1300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAddAccount_1300 end===="); + done(); + }); + }); + }); + + /* + * @tc.number : ActsAccountAddAccount_1400 + * @tc.name : Add account promise form + * @tc.desc : Additional information is an empty string + */ + it('ActsAccountAddAccount_1400', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_1400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>add account ActsAccountAddAccount_1400 start===="); + try{ + await appAccountManager.addAccount("account_name_promise_seventh", ""); + } + catch(err){ + console.error("====>add account ActsAccountAddAccount_1400 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>delete account ActsAccountAddAccount_1400 start===="); + await appAccountManager.deleteAccount("account_name_promise_seventh"); + done(); + }); + + /* + * @tc.number : ActsAccountAddAccount_1500 + * @tc.name : Add account calllback form + * @tc.desc : The account name is a special character such as a space + */ + it('ActsAccountAddAccount_1500', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_1500 start===="); + var appAccountManager = account.createAppAccountManager(); + var specialStr = " "; + appAccountManager.addAccount(specialStr, "account_extraInfo_callback_eight", (err)=>{ + console.debug("====>add account ActsAccountAddAccount_1500 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountAddAccount_1500 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsAccountAddAccount_1600 + * @tc.name : Add account promise form + * @tc.desc : The account name is a special character such as a space + */ + it('ActsAccountAddAccount_1600', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_1600 start===="); + var appAccountManager = account.createAppAccountManager(); + var specialStr = " "; + try{ + await appAccountManager.addAccount(specialStr, "account_extraInfo_promise_eighth"); + } + catch(err){ + console.debug("====>add Account ActsAccountAddAccount_1600 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountAddAccount_1600 end===="); + done(); + } + }); + + + /* + * @tc.number : ActsAccountAddAccount_1700 + * @tc.name : Add account calllback form + * @tc.desc : The account name is a special string + */ + it('ActsAccountAddAccount_1700', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_1700 start===="); + var appAccountManager = account.createAppAccountManager(); + var specialStr = "#@$%^&*()_+!<>~?,./[]abcdefgABCDEFG1234567890"; + appAccountManager.addAccount(specialStr, "account_extraInfo_callback_ninth", (err)=>{ + console.debug("====>add account ActsAccountAddAccount_1700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount(specialStr, (err)=>{ + console.debug("====>delete Account ActsAccountAddAccount_1700 err" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAddAccount_1700 end===="); + done(); + }); + }); + }); + + /* + * @tc.number : ActsAccountAddAccount_1800 + * @tc.name : Add account promise form + * @tc.desc : The account name is a special string + */ + it('ActsAccountAddAccount_1800', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_1800 start===="); + var appAccountManager = account.createAppAccountManager(); + var specialStr = "#@$%^&*()_+!<>~?,./[]abcdefgABCDEFG1234567890"; + console.debug("====>add account ActsAccountAddAccount_1800===="); + try{ + await appAccountManager.addAccount(specialStr, "account_extraInfo_promise_ninth"); + } + catch(err){ + console.error("====>add Account ActsAccountAddAccount_1800 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>delete account ActsAccountAddAccount_1800===="); + await appAccountManager.deleteAccount(specialStr); + console.debug("====>ActsAccountAddAccount_1800 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountAddAccount_1900 + * @tc.name : Add account calllback form + * @tc.desc : Additional information is a special character such as a space + */ + it('ActsAccountAddAccount_1900', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_1900 start===="); + var appAccountManager = account.createAppAccountManager(); + var specialStr = " "; + appAccountManager.addAccount("account_name_callback_tenth", specialStr, (err)=>{ + console.debug("====>add account ActsAccountAddAccount_1900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount("account_name_callback_tenth", (err)=>{ + console.debug("====>delete Account ActsAccountAddAccount_1900 err" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAddAccount_1900 end===="); + done(); + }); + }); + }); + + /* + * @tc.number : ActsAccountAddAccount_2000 + * @tc.name : Add account promise form + * @tc.desc : Additional information is a special character such as a space + */ + it('ActsAccountAddAccount_2000', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_2000 start===="); + var appAccountManager = account.createAppAccountManager(); + var specialStr = " "; + console.debug("====>add account ActsAccountAddAccount_2000===="); + try{ + await appAccountManager.addAccount("account_name_promise_tenth", specialStr); + } + catch(err){ + console.error("====>add Account ActsAccountAddAccount_2000 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>delete account ActsAccountAddAccount_2000===="); + await appAccountManager.deleteAccount("account_name_promise_tenth"); + console.debug("====>ActsAccountAddAccount_2000 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountAddAccount_2100 + * @tc.name : Add account calllback form + * @tc.desc : Additional information is a special string + */ + it('ActsAccountAddAccount_2100', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_2100 start===="); + var appAccountManager = account.createAppAccountManager(); + var specialStr = "#@$%^&*()_+!<>~?,./[]abcdefgABCDEFG1234567890"; + appAccountManager.addAccount("account_extraInfo_callback_eleventh", specialStr, (err)=>{ + console.debug("====>add account ActsAccountAddAccount_2100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount("account_extraInfo_callback_eleventh", (err)=>{ + console.debug("====>delete Account ActsAccountAddAccount_2100 err" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAddAccount_2100 end===="); + done(); + }); + }); + }); + + /* + * @tc.number : ActsAccountAddAccount_2200 + * @tc.name : Add account promise form + * @tc.desc : Additional information is a special string + */ + it('ActsAccountAddAccount_2200', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_2200 start===="); + var appAccountManager = account.createAppAccountManager(); + var specialStr = "#@$%^&*()_+!<>~?,./[]abcdefgABCDEFG1234567890"; + console.debug("====>add account ActsAccountAddAccount_2200===="); + try{ + await appAccountManager.addAccount("account_extraInfo_promise_eleventh", specialStr); + } + catch(err){ + console.error("====>add Account ActsAccountAddAccount_2200 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>delete account ActsAccountAddAccount_2200===="); + await appAccountManager.deleteAccount("account_extraInfo_promise_eleventh"); + console.debug("====>ActsAccountAddAccount_2200 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountAddAccount_2300 + * @tc.name : Add account calllback form + * @tc.desc : Repeatedly add accounts with the same name and different additional information + */ + it('ActsAccountAddAccount_2300', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_2300 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_name_callback_same", "account_extraInfo_callback", (err)=>{ + console.debug("====>add account first time ActsAccountAddAccount_2300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.addAccount("account_name_callback_same", "account_extraInfo_callback_different", (err)=>{ + console.debug("====>add account second time ActsAccountAddAccount_2300 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + appAccountManager.deleteAccount("account_name_callback_same", (err)=>{ + console.debug("====>delete Account ActsAccountAddAccount_2300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAddAccount_2300 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountAddAccount_2400 + * @tc.name : Add account promise form + * @tc.desc : Repeatedly add accounts with the same name and different additional information + */ + it('ActsAccountAddAccount_2400', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_2400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>add account for the first time ActsAccountAddAccount_2400===="); + await appAccountManager.addAccount("account_name_promise_same", "account_extraInfo_promise"); + console.debug("====>add account for the second time ActsAccountAddAccount_2400===="); + try{ + await appAccountManager.addAccount("account_name_promise_same", "account_extraInfo_promise_different"); + } + catch(err){ + console.debug("====>add account for the second time err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + appAccountManager.deleteAccount("account_name_promise_same"); + console.debug("====>ActsAccountAddAccount_2400 end===="); + done(); + } + }); +}) \ No newline at end of file diff --git a/account/appaccount/actsaccounttest/entry/src/main/js/test/AppAccess.test.js b/account/appaccount/actsaccounttest/entry/src/main/js/test/AppAccess.test.js new file mode 100755 index 0000000000000000000000000000000000000000..ffdf6c181e341dd1df952e6317479599c6d6eb42 --- /dev/null +++ b/account/appaccount/actsaccounttest/entry/src/main/js/test/AppAccess.test.js @@ -0,0 +1,538 @@ +/* + * 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + +const TIMEOUT = 10000; +const STRCOUNT = 1025; +describe('ActsAccountAppAccess', function () { + function sleep(delay) { + var start = (new Date()).getTime(); + while((new Date()).getTime() - start < delay) { + continue; + } + } + + beforeAll(async function (done) { + console.debug("====>beforeAll start===="); + sleep(TIMEOUT); + console.debug("====>beforeAll end===="); + done(); + }); + + /* + * @tc.number : ActsAccountAppAccess_0100 + * @tc.name : enableAppAccess callback + * @tc.desc : Enable the app to access the app itself + */ + it('ActsAccountAppAccess_0100', 0, async function (done) { + console.debug("====>ActsAccountAppAccess_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("AppAccess_callback_itself", "extrainfo_callback_itself", (err)=>{ + console.debug("====>add account ActsAccountAppAccess_0100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.enableAppAccess("AppAccess_callback_itself", "com.example.actsaccountappaccess", (err)=>{ + console.debug("====>enableAppAccess err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + appAccountManager.deleteAccount("AppAccess_callback_itself", (err)=>{ + console.debug("====>delete Account ActsAccountAppAccess_0100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAppAccess_0100 end===="); + done(); + }); + }) + }) + }); + + /* + * @tc.number : ActsAccountAppAccess_0200 + * @tc.name : enableAppAccess promise + * @tc.desc : Enable the app to access the app itself + */ + it('ActsAccountAppAccess_0200', 0, async function (done) { + console.debug("====>ActsAccountAppAccess_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountAppAccess_0200 start===="); + await appAccountManager.addAccount("AppAccess_promise_itself", "extrainfo_promise_itself"); + console.debug("====>enableAppAccess ActsAccountAppAccess_0200 start===="); + try{ + await appAccountManager.enableAppAccess("AppAccess_promise_itself", "com.example.actsaccountappaccess"); + } + catch(err){ + console.debug("====>enableAppAccess 0200 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>delete account ActsAccountAppAccess_0200 start===="); + await appAccountManager.deleteAccount("AppAccess_promise_itself"); + console.debug("====>ActsAccountAppAccess_0200 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountAppAccess_0300 + * @tc.name : enableAppAccess callback + * @tc.desc : The enabled bundleName does not exist + */ + it('ActsAccountAppAccess_0300', 0, async function (done) { + console.debug("====>ActsAccountAppAccess_0300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var nonExistBundle = "com.example.NonExistentBundleCallback"; + appAccountManager.addAccount("AppAccess_callback_NotExistBundle", "extrainfo_callback_NotExistBundle", (err)=>{ + console.debug("====>add account ActsAccountAppAccess_0300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.enableAppAccess("AppAccess_callback_NotExistBundle", nonExistBundle, (err)=>{ + console.debug("====>enableAppAccess 0300 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + appAccountManager.deleteAccount("AppAccess_callback_NotExistBundle", (err)=>{ + console.debug("====>delete Account ActsAccountAppAccess_0300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAppAccess_0300 end===="); + done(); + }); + }) + }) + }); + + /* + * @tc.number : ActsAccountAppAccess_0400 + * @tc.name : enableAppAccess promise + * @tc.desc : The enabled bundleName does not exist + */ + it('ActsAccountAppAccess_0400', 0, async function (done) { + console.debug("====>ActsAccountAppAccess_0400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var nonExistBundle = "com.example.NonExistentBundlePromise"; + console.debug("====>add account ActsAccountAppAccess_0400 start===="); + await appAccountManager.addAccount("AppAccess_promise_NotExistBundle", "extrainfo_promise_NotExistBundle"); + console.debug("====>enableAppAccess ActsAccountAppAccess_0400 start===="); + try{ + await appAccountManager.enableAppAccess("AppAccess_promise_NotExistBundle", nonExistBundle); + } + catch(err){ + console.error("====>enableAppAccess ActsAccountAppAccess_0400 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>delete account ActsAccountAppAccess_0400 start===="); + await appAccountManager.deleteAccount("AppAccess_promise_NotExistBundle"); + console.debug("====>ActsAccountAppAccess_0400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountAppAccess_0500 + * @tc.name : enableAppAccess callback + * @tc.desc : The enabled account name does not exist + */ + it('ActsAccountAppAccess_0500', 0, async function (done) { + console.debug("====>ActsAccountAppAccess_0500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var enableBundle = "com.example.actsaccountsceneappaccess"; + var nonExistAccount = "NonExistentAccountCallback"; + appAccountManager.enableAppAccess(nonExistAccount, enableBundle, (err)=>{ + console.debug("====>enableAppAccess 0500 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountAppAccess_0500 end===="); + done(); + }) + }); + + /* + * @tc.number : ActsAccountAppAccess_0600 + * @tc.name : enableAppAccess promise + * @tc.desc : The enabled account name does not exist + */ + it('ActsAccountAppAccess_0600', 0, async function (done) { + console.debug("====>ActsAccountAppAccess_0600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var enableBundle = "com.example.actsaccountsceneappaccess"; + var nonExistAccount = "NonExistentAccountPromise"; + console.debug("====>enableAppAccess ActsAccountAppAccess_0600 start===="); + try{ + await appAccountManager.enableAppAccess("NonExistentAccountPromise", enableBundle); + } + catch(err){ + console.debug("====>enableAppAccess 0600 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountAppAccess_0600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountAppAccess_0700 + * @tc.name : enableAppAccess disableAppAccess callback + * @tc.desc : Cancel the authorization after authorizing the account to another app + */ + it('ActsAccountAppAccess_0700', 0, async function (done) { + console.debug("====>ActsAccountAppAccess_0700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var enableBundle = "com.example.actsaccountsceneappaccess"; + appAccountManager.addAccount("AppAccess_callback_account", (err)=>{ + console.debug("====>add account ActsAccountAppAccess_0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.enableAppAccess("AppAccess_callback_account", enableBundle, (err)=>{ + console.debug("====>enableAppAccess 0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.disableAppAccess("AppAccess_callback_account", enableBundle, (err)=>{ + expect(err.code).assertEqual(0) + appAccountManager.deleteAccount("AppAccess_callback_account", (err)=>{ + console.debug("====>delete Account ActsAccountAppAccess_0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAppAccess_0700 end===="); + done(); + }); + }) + }) + }) + }); + + /* + * @tc.number : ActsAccountAppAccess_0800 + * @tc.name : enableAppAccess disableAppAccess promise + * @tc.desc : Cancel the authorization after authorizing the account to another account + */ + it('ActsAccountAppAccess_0800', 0, async function (done) { + console.debug("====>ActsAccountAppAccess_0800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var enableBundle = "com.example.actsaccountsceneappaccess"; + console.debug("====>add account ActsAccountAppAccess_0800 start===="); + await appAccountManager.addAccount("AppAccess_promise_account"); + console.debug("====>enableAppAccess ActsAccountAppAccess_0800 start===="); + try{ + await appAccountManager.enableAppAccess("AppAccess_promise_account", enableBundle); + } + catch(err){ + console.error("====>enableAppAccess ActsAccountAppAccess_0800 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>disableAppAccess ActsAccountAppAccess_0800 start===="); + await appAccountManager.disableAppAccess("AppAccess_promise_account", enableBundle); + console.debug("====>delete account ActsAccountAppAccess_0800 start===="); + await appAccountManager.deleteAccount("AppAccess_promise_account"); + console.debug("====>ActsAccountAppAccess_0800 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountAppAccess_0900 + * @tc.name : enableAppAccess callback + * @tc.desc : The authorized account name is a long string + */ + it('ActsAccountAppAccess_0900', 0, async function (done) { + console.debug("====>ActsAccountAppAccess_0900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var bigAccountName = ''; + for (var i = 0; i < STRCOUNT; i++) { + bigAccountName += 't'; + } + var enableBundle = "com.example.actsaccountsceneappaccess"; + appAccountManager.enableAppAccess(bigAccountName, enableBundle, (err)=>{ + console.debug("====>enableAppAccess 0900 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountAppAccess_0900 end===="); + done(); + }) + }); + + /* + * @tc.number : ActsAccountAppAccess_1000 + * @tc.name : enableAppAccess promise + * @tc.desc : The authorized account name is a long string + */ + it('ActsAccountAppAccess_1000', 0, async function (done) { + console.debug("====>ActsAccountAppAccess_1000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var bigAccountName = ''; + for (var i = 0; i < STRCOUNT; i++) { + bigAccountName += 't'; + } + var enableBundle = "com.example.actsaccountsceneappaccess"; + console.debug("====>enableAppAccess ActsAccountAppAccess_1000 start===="); + try{ + await appAccountManager.enableAppAccess(bigAccountName, enableBundle); + } + catch(err){ + console.debug("====>enableAppAccess 1000 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountAppAccess_1000 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountAppAccess_1100 + * @tc.name : enableAppAccess callback + * @tc.desc : The authorized bundle name is a long string + */ + it('ActsAccountAppAccess_1100', 0, async function (done) { + console.debug("====>ActsAccountAppAccess_1100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var bigBundleName = ''; + for (var i = 0; i < STRCOUNT; i++) { + bigBundleName += 't'; + } + appAccountManager.addAccount("AppAccess_callback_bigBundleName", (err)=>{ + console.debug("====>add account ActsAccountAppAccess_1100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.enableAppAccess("AppAccess_callback_bigBundleName", bigBundleName, (err)=>{ + console.debug("====>enableAppAccess 1100 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + appAccountManager.deleteAccount("AppAccess_callback_bigBundleName", (err)=>{ + console.debug("====>delete Account ActsAccountAppAccess_1100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAppAccess_1100 end===="); + done(); + }); + }) + }) + }); + + /* + * @tc.number : ActsAccountAppAccess_1200 + * @tc.name : enableAppAccess promise + * @tc.desc : The authorized bundle name is a long string + */ + it('ActsAccountAppAccess_1200', 0, async function (done) { + console.debug("====>ActsAccountAppAccess_1200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var bigBundleName = ''; + for (var i = 0; i < STRCOUNT; i++) { + bigBundleName += 't'; + } + console.debug("====>add account ActsAccountAppAccess_1200 start===="); + await appAccountManager.addAccount("AppAccess_promise_bigBundleName"); + console.debug("====>enableAppAccess ActsAccountAppAccess_1200 start===="); + try{ + await appAccountManager.enableAppAccess("AppAccess_promise_bigBundleName", bigBundleName); + } + catch(err){ + console.debug("====>enableAppAccess 1200 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>delete account ActsAccountAppAccess_1200 start===="); + await appAccountManager.deleteAccount("AppAccess_promise_bigBundleName"); + console.debug("====>ActsAccountAppAccess_1200 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountAppAccess_1300 + * @tc.name : enableAppAccess callback + * @tc.desc : The authorized account name is an empty string + */ + it('ActsAccountAppAccess_1300', 0, async function (done) { + console.debug("====>ActsAccountAppAccess_1300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var emptyBundleName = ''; + appAccountManager.addAccount("AppAccess_callback_emptyBundleName", (err)=>{ + console.debug("====>add account ActsAccountAppAccess_1300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.enableAppAccess("AppAccess_callback_emptyBundleName", emptyBundleName, (err)=>{ + console.debug("====>enableAppAccess 1300 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + appAccountManager.deleteAccount("AppAccess_callback_emptyBundleName", (err)=>{ + console.debug("====>delete Account ActsAccountAppAccess_1300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAppAccess_1300 end===="); + done(); + }); + }) + }) + }); + + /* + * @tc.number : ActsAccountAppAccess_1400 + * @tc.name : enableAppAccess promise + * @tc.desc : The authorized account name is an empty string + */ + it('ActsAccountAppAccess_1400', 0, async function (done) { + console.debug("====>ActsAccountAppAccess_1400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var emptyBundleName = ''; + console.debug("====>add account ActsAccountAppAccess_1400 start===="); + await appAccountManager.addAccount("AppAccess_promise_emptyBundleName"); + console.debug("====>enableAppAccess ActsAccountAppAccess_1400 start===="); + try{ + await appAccountManager.enableAppAccess("AppAccess_promise_emptyBundleName", emptyBundleName); + } + catch(err){ + console.debug("====>enableAppAccess 1400 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>delete account ActsAccountAppAccess_1400 start===="); + await appAccountManager.deleteAccount("AppAccess_promise_emptyBundleName"); + console.debug("====>ActsAccountAppAccess_1400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountAppAccess_1500 + * @tc.name : disableAppAccess callback + * @tc.desc : Cancel authorization Accounts that have not authorized other applications + */ + it('ActsAccountAppAccess_1500', 0, async function (done) { + console.debug("====>ActsAccountAppAccess_1500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var enableBundle = "com.example.actsaccountsceneappaccess"; + appAccountManager.addAccount("AppAccess_callback_account", (err)=>{ + console.debug("====>add account ActsAccountAppAccess_1500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.disableAppAccess("AppAccess_callback_account", enableBundle, (err)=>{ + expect(err.code != 0).assertEqual(true) + appAccountManager.deleteAccount("AppAccess_callback_account", (err)=>{ + console.debug("====>delete Account ActsAccountAppAccess_1500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAppAccess_1500 end===="); + done(); + }); + }) + }) + }); + + /* + * @tc.number : ActsAccountAppAccess_1600 + * @tc.name : disableAppAccess promise + * @tc.desc : Cancel authorization Accounts that have not authorized other applications + */ + it('ActsAccountAppAccess_1600', 0, async function (done) { + console.debug("====>ActsAccountAppAccess_1600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var enableBundle = "com.example.actsaccountsceneappaccess"; + console.debug("====>add account ActsAccountAppAccess_1600 start===="); + await appAccountManager.addAccount("AppAccess_promise_account"); + console.debug("====>disableAppAccess ActsAccountAppAccess_1600 start===="); + try{ + await appAccountManager.disableAppAccess("AppAccess_promise_account", enableBundle); + } + catch(err){ + console.debug("====>disableAppAccess ActsAccountAppAccess_1600 err:" + JSON.stringify(err)); + console.debug("====>delete account ActsAccountAppAccess_1600 start===="); + await appAccountManager.deleteAccount("AppAccess_promise_account"); + console.debug("====>ActsAccountAppAccess_1600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountAppAccess_1700 + * @tc.name : disableAppAccess callback + * @tc.desc : The disableAppAccess parameter bundleName does not exist + */ + it('ActsAccountAppAccess_1700', 0, async function (done) { + console.debug("====>ActsAccountAppAccess_1700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var notExistBundle = "com.example.actsaccountnotexistbundle"; + appAccountManager.addAccount("AppAccess_callback_notExistBundle", (err)=>{ + console.debug("====>add account ActsAccountAppAccess_1700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.disableAppAccess("AppAccess_callback_notExistBundle", notExistBundle, (err)=>{ + expect(err.code != 0).assertEqual(true) + appAccountManager.deleteAccount("AppAccess_callback_notExistBundle", (err)=>{ + console.debug("====>delete Account ActsAccountAppAccess_1700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAppAccess_1700 end===="); + done(); + }); + }) + }) + }); + + /* + * @tc.number : ActsAccountAppAccess_1800 + * @tc.name : disableAppAccess promise + * @tc.desc : The disableAppAccess parameter bundleName does not exist + */ + it('ActsAccountAppAccess_1800', 0, async function (done) { + console.debug("====>ActsAccountAppAccess_1800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var notExistBundle = "com.example.actsaccountnotexistbundle"; + console.debug("====>add account ActsAccountAppAccess_1800 start===="); + await appAccountManager.addAccount("AppAccess_promise_notExistBundle"); + console.debug("====>disableAppAccess ActsAccountAppAccess_1800 start===="); + try{ + await appAccountManager.disableAppAccess("AppAccess_promise_notExistBundle", notExistBundle); + } + catch(err){ + console.debug("====>disableAppAccess ActsAccountAppAccess_1800 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>delete account ActsAccountAppAccess_1800 start===="); + await appAccountManager.deleteAccount("AppAccess_promise_notExistBundle"); + console.debug("====>ActsAccountAppAccess_1600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountAppAccess_1900 + * @tc.name : disableAppAccess callback + * @tc.desc : The disableAppAccess parameter accountName does not exist + */ + it('ActsAccountAppAccess_1900', 0, async function (done) { + console.debug("====>ActsAccountAppAccess_1900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var notExistAccount = "AppAccess_callback_notExistAccount"; + var enableBundle = "com.example.actsaccountsceneappaccess"; + console.debug("====>disableAppAccess ActsAccountAppAccess_1900===="); + appAccountManager.disableAppAccess(notExistAccount, enableBundle, (err)=>{ + console.debug("====>disableAppAccess ActsAccountAppAccess_1900 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountAppAccess_1900 end===="); + done(); + }) + }); + + /* + * @tc.number : ActsAccountAppAccess_2000 + * @tc.name : disableAppAccess promise + * @tc.desc : The disableAppAccess parameter accountName does not exist + */ + it('ActsAccountAppAccess_2000', 0, async function (done) { + console.debug("====>ActsAccountAppAccess_2000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var notExistAccount = "AppAccess_promise_notExistAccount"; + var enableBundle = "com.example.actsaccountsceneappaccess"; + console.debug("====>disableAppAccess ActsAccountAppAccess_2000===="); + try{ + await appAccountManager.disableAppAccess(notExistAccount, enableBundle); + } + catch(err){ + console.debug("====>disableAppAccess ActsAccountAppAccess_2000 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountAppAccess_2000 end===="); + done(); + } + }); +}) \ No newline at end of file diff --git a/account/appaccount/actsaccounttest/entry/src/main/js/test/AssociatedData.test.js b/account/appaccount/actsaccounttest/entry/src/main/js/test/AssociatedData.test.js new file mode 100755 index 0000000000000000000000000000000000000000..38c4dec1ed31d42924160a266f0de6cffdbb4793 --- /dev/null +++ b/account/appaccount/actsaccounttest/entry/src/main/js/test/AssociatedData.test.js @@ -0,0 +1,1153 @@ +/* + * 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + +const TIMEOUT = 10000; +describe('ActsAccountAssociatedData', function () { + function sleep(delay) { + var start = (new Date()).getTime(); + while((new Date()).getTime() - start < delay) { + continue; + } + } + + beforeAll(async function (done) { + console.debug("====>beforeAll start===="); + sleep(TIMEOUT); + console.debug("====>beforeAll end===="); + done(); + }); + + /* + * @tc.number : ActsAccountAssociatedData_0100 + * @tc.name : The correct calls setAssociatedData and getAssociatedData get the value + * @tc.desc : The setAssociatedData setting valueis called when the forwarding parameters + * are correct, and then getAssociatedData is called for the value(callback) + */ + it('ActsAccountAssociatedData_0100', 0, async function (done) { + console.debug("====>ActsAccountAssociatedData_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_0100",(err)=>{ + console.debug("====>add accountActsAccountAssociatedData_0100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAssociatedData("account_name_0100", "key1", "value1", (err)=>{ + console.debug("====>setAssociatedData ActsAccountAssociatedData_0100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAssociatedData("account_name_0100", "key1", (err, data)=>{ + console.debug("====>getAssociatedData 0100 err:" + JSON.stringify(err)); + console.debug("====>getAssociatedData 0100 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data).assertEqual("value1"); + appAccountManager.deleteAccount("account_name_0100", (err)=>{ + console.debug("====>delete Account 0100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAssociatedData_0100 end===="); + done(); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountAssociatedData_0200 + * @tc.name : The correct calls setAssociatedData and getAssociatedData get the value + * @tc.desc : The setAssociatedData setting value is called when the forwarding parameters + * are correct, and then getAssociatedData is called for the value(promise) + */ + it('ActsAccountAssociatedData_0200', 0, async function (done) { + console.debug("====>ActsAccountAssociatedData_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountAssociatedData_0200 start===="); + try{ + await appAccountManager.addAccount("account_name_0200"); + } + catch(err){ + console.error("====>add Account ActsAccountAssociatedData_0200 err:" + JSON.stringify(err)); + expect().asserFail(); + done(); + } + console.debug("====>setAssociatedData ActsAccountAssociatedData_0200 start===="); + try{ + await appAccountManager.setAssociatedData("account_name_0200", "key2", "value2"); + } + catch(err){ + console.error("====>setAssociatedData ActsAccountAssociatedData_0200 err:" + JSON.stringify(err)); + expect().asserFail(); + done(); + } + console.debug("====>getAssociatedData ActsAccountAssociatedData_0200 start===="); + try{ + var data = await appAccountManager.getAssociatedData("account_name_0200", "key2"); + } + catch(err){ + console.error("====>getAssociatedData ActsAccountAssociatedData_0200 err:" + JSON.stringify(err)); + expect().asserFail(); + done(); + } + console.debug("====>getAssociatedData ActsAccountAssociatedData_0200 data:" + JSON.stringify(data)); + expect(data).assertEqual("value2"); + console.debug("====>delete account ActsAccountAssociatedData_0200 start===="); + try{ + await appAccountManager.deleteAccount("account_name_0200"); + } + catch(err){ + console.error("====>delete account 0200 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAccountAssociatedData_0200 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountAssociatedData_0300 + * @tc.name : Get it directly without setting value + * @tc.desc : Call getAssociatedData directly to get value without calling setAssociatedData(callback) + */ + it('ActsAccountAssociatedData_0300', 0, async function (done) { + console.debug("====>ActsAccountAssociatedData_0300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_0300", (err)=>{ + console.debug("====>add account ActsAccountAssociatedData_0300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAssociatedData("account_name_0300", "key3", (err, data)=>{ + console.debug("====>getAssociatedData 0300 err:" + JSON.stringify(err)); + console.debug("====>getAssociatedData 0300 data:" + JSON.stringify(data)); + expect(err.code != 0).assertEqual(true); + expect(data).assertEqual(""); + appAccountManager.deleteAccount("account_name_0300", (err)=>{ + console.debug("====>delete Account 0300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAssociatedData_0300 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountAssociatedData_0400 + * @tc.name : Get it directly without setting value + * @tc.desc : Call getAssociatedData directly to get value without calling setAssociatedData(promise) + */ + it('ActsAccountAssociatedData_0400', 0, async function (done) { + console.debug("====>ActsAccountAssociatedData_0400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountAssociatedData_0400 start===="); + try{ + await appAccountManager.addAccount("account_name_0400"); + } + catch(err){ + console.error("====>add Account ActsAccountAssociatedData_0400 err:" + JSON.stringify(err)); + expect().asserFail(); + done(); + } + try{ + await appAccountManager.getAssociatedData("account_name_0400", "key4"); + console.error("====>getAssociatedData fail ActsAccountAssociatedData_0400===="); + expect().assertFail(); + done(); + } + catch(err){ + console.debug("====>getAssociatedData ActsAccountAssociatedData_0400 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>delete account ActsAccountAssociatedData_0400 start===="); + try{ + await appAccountManager.deleteAccount("account_name_0400"); + } + catch(err){ + console.error("====>delete account 0400 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAccountAssociatedData_0400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountAssociatedData_0500 + * @tc.name : Call getAssociatedData to get value when passing in the error parameter + * @tc.desc : After calling setAssociatedData setting value correctly, + * call the getAssociatedData of the pass error to check if you get the value(callback) + */ + it('ActsAccountAssociatedData_0500', 0, async function (done) { + console.debug("====>ActsAccountAssociatedData_0500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_0500",(err)=>{ + console.debug("====>add account ActsAccountAssociatedData_0500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAssociatedData("account_name_0500", "key5", "value5", (err)=>{ + console.debug("====>setAssociatedData ActsAccountAssociatedData_0500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAssociatedData("account_name_0500", "keyerr", (err, data)=>{ + console.debug("====>getAssociatedData 0500 err:" + JSON.stringify(err)); + console.debug("====>getAssociatedData 0500 data:" + JSON.stringify(data)); + expect(err.code != 0).assertEqual(true); + appAccountManager.deleteAccount("account_name_0500", (err)=>{ + console.debug("====>delete Account 0500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAssociatedData_0500 end===="); + done(); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountAssociatedData_0600 + * @tc.name : Call getAssociatedData to get value when passing in the error parameter + * @tc.desc : After calling setAssociatedData setting value correctly, + * call the getAssociatedData of the pass error to check if you get the value(promise) + */ + it('ActsAccountAssociatedData_0600', 0, async function (done) { + console.debug("====>ActsAccountAssociatedData_0600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountAssociatedData_0600 start===="); + try{ + await appAccountManager.addAccount("account_name_0600"); + } + catch(err){ + console.error("====>add Account ActsAccountAssociatedData_0600 fail err:" + JSON.stringify(err)); + expect().asserFail(); + done(); + } + await appAccountManager.setAssociatedData("account_name_0600", "key6", "value6"); + try{ + var data = await appAccountManager.getAssociatedData("account_name_0600", "keyerr"); + } + catch(err){ + console.debug("====>getAssociatedData 0600 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>delete account ActsAccountAssociatedData_0600 start===="); + try{ + await appAccountManager.deleteAccount("account_name_0600"); + } + catch(err){ + console.error("====>delete account 0600 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAccountAssociatedData_0600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountAssociatedData_0700 + * @tc.name : Whether getAssociatedData can get the correct value when calling setAssociatedData multiple times + * @tc.desc : When the first setAssociatedData is called and the second setAssociatedData + * is called,the setting of the value is different if the call getAssociatedData + * can get the second value(callback) + */ + it('ActsAccountAssociatedData_0700', 0, async function (done) { + console.debug("====>ActsAccountAssociatedData_0700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_0700",(err)=>{ + console.debug("====>add account ActsAccountAssociatedData_0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAssociatedData("account_name_0700", "key7", "value7", (err)=>{ + console.debug("====>setAssociatedDatafir first time 0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAssociatedData("account_name_0700", "key7", "newvalue7", (err)=>{ + console.debug("====>setAssociatedDatafir second time 0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAssociatedData("account_name_0700", "key7", (err, data)=>{ + console.debug("====>getAssociatedData 0700 err:" + JSON.stringify(err)); + console.debug("====>getAssociatedData 0700 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data).assertEqual("newvalue7"); + appAccountManager.deleteAccount("account_name_0700", (err)=>{ + console.debug("====>delete Account 0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAssociatedData_0700 end===="); + done(); + }); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountAssociatedData_0800 + * @tc.name : Whether getAssociatedData can get the correct value when calling setAssociatedData multiple times + * @tc.desc : When the first setAssociatedData is called and the second setAssociatedData + * is called,the setting of the value is different if the call getAssociatedData + * can get the second value(promise) + */ + it('ActsAccountAssociatedData_0800', 0, async function (done) { + console.debug("====>ActsAccountAssociatedData_0800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + try{ + await appAccountManager.addAccount("account_name_0800"); + } + catch(err){ + console.error("====>add account ActsAccountAssociatedData_0800 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + await appAccountManager.setAssociatedData("account_name_0800","key8","value8"); + await appAccountManager.setAssociatedData("account_name_0800","key8","newvalue8"); + }catch(err){ + console.error("====>setAssociatedData ActsAccountAssociatedData_0800 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + var data = await appAccountManager.getAssociatedData("account_name_0800", "key8"); + } + catch(err){ + console.error("====>getAssociatedData ActsAccountAssociatedData_0800 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAssociatedData ActsAccountAssociatedData_0800 data:" + JSON.stringify(data)); + expect(data).assertEqual("newvalue8"); + console.debug("====>delete account ActsAccountAssociatedData_0800 start===="); + try{ + await appAccountManager.deleteAccount("account_name_0800"); + } + catch(err){ + console.error("====>delete account 0800 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAccountAssociatedData_0800 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountAssociatedData_0900 + * @tc.name : Whether getAssociatedData can get the correct value when calling setAssociatedData multiple times + * @tc.desc : When the first setAssociatedData is called and the second setAssociatedData + * is called,the setting of the value is same if the call getAssociatedData + * can get the second value(callback) + */ + it('ActsAccountAssociatedData_0900', 0, async function (done) { + console.debug("====>ActsAccountAssociatedData_0900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_0900",(err)=>{ + console.debug("====>add account ActsAccountAssociatedData_0900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAssociatedData("account_name_0900", "key9", "value9", (err)=>{ + console.debug("====>setAssociatedData first time 0900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAssociatedData("account_name_0900", "key9", "value9", (err)=>{ + console.debug("====>setAssociatedData second time 0900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAssociatedData("account_name_0900", "key9", (err, data)=>{ + console.debug("====>getAssociatedData 0900 err:" + JSON.stringify(err)); + console.debug("====>getAssociatedData 0900 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data).assertEqual("value9"); + appAccountManager.deleteAccount("account_name_0900", (err)=>{ + console.debug("====>delete Account 0900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAssociatedData_0900 end===="); + done(); + }); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountAssociatedData_1000 + * @tc.name : Whether getAssociatedData can get the correct value when calling setAssociatedData multiple times + * @tc.desc : When the first setAssociatedData is called and the second setAssociatedData + * is called,the setting of the value is same if the call getAssociatedData + * can get the second value(promise) + */ + it('ActsAccountAssociatedData_1000', 0, async function (done) { + console.debug("====>ActsAccountAssociatedData_1000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>addAccount ActsAccountAssociatedData_1000 start===="); + try{ + await appAccountManager.addAccount("account_name_1000"); + } + catch(err){ + console.error("====>add account ActsAccountAssociatedData_1000 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + await appAccountManager.setAssociatedData("account_name_1000", "key10", "value10"); + await appAccountManager.setAssociatedData("account_name_1000", "key10", "value10"); + } + catch(err){ + console.error("====>setAssociatedData ActsAccountAssociatedData_1000 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + var data = await appAccountManager.getAssociatedData("account_name_1000", "key10"); + } + catch(err){ + console.error("====>getAssociatedData ActsAccountAssociatedData_1000 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAssociatedData 1000 data:" + JSON.stringify(data)); + expect(data).assertEqual("value10"); + console.debug("====>delete account ActsAccountAssociatedData_1000 start===="); + try{ + await appAccountManager.deleteAccount("account_name_1000"); + } + catch(err){ + console.error("====>delete account 1000 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAccountAssociatedData_1000 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountAssociatedData_1100 + * @tc.name : Call multiple setAssociatedData calls multiple times getAssociatedData gets the value separately + * @tc.desc : Call setAssociatedData setting value again after calling setAssociatedData setting + * different value, and then call getAssociatedData twice to get the set value(callback) + */ + it('ActsAccountAssociatedData_1100', 0, async function (done) { + console.debug("====>ActsAccountAssociatedData_1100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_1100",(err)=>{ + console.debug("====>add account ActsAccountAssociatedData_1100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAssociatedData("account_name_1100", "key11_first", "value11_first", (err)=>{ + console.debug("====>setAssociatedData first time 1100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAssociatedData("account_name_1100", "key11_second", "value11_second", (err)=>{ + console.debug("====>setAssociatedData second time 1100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAssociatedData("account_name_1100", "key11_first", (err,data)=>{ + console.debug("====>getAssociatedData key11_first 1100 err:" + JSON.stringify(err)); + console.debug("====>getAssociatedData key11_first 1100 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data).assertEqual("value11_first"); + appAccountManager.getAssociatedData("account_name_1100", "key11_second", (err,data)=>{ + console.debug("====>getAssociatedData key11_second 1100 err:" + JSON.stringify(err)); + console.debug("====>getAssociatedData key11_second 1100 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data).assertEqual("value11_second"); + appAccountManager.deleteAccount("account_name_1100", (err)=>{ + console.debug("====>delete Account 1100 err:" + JSON.stringify(err)); + }); + console.debug("====>ActsAccountAssociatedData_1100 end===="); + done(); + }); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountAssociatedData_1200 + * @tc.name : Call multiple setAssociatedData calls multiple times getAssociatedData gets the value separately + * @tc.desc : Call setAssociatedData setting value again after calling setAssociatedData setting + * different value, and then call getAssociatedData twice to get the set value(promise) + */ + it('ActsAccountAssociatedData_1200', 0, async function (done) { + console.debug("====>ActsAccountAssociatedData_1200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>addAccount ActsAccountAssociatedData_1200 start===="); + try{ + await appAccountManager.addAccount("account_name_1200"); + } + catch(err){ + console.error("====>add account ActsAccountAssociatedData_1200 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + await appAccountManager.setAssociatedData("account_name_1200", "key12_first", "value12_first"); + await appAccountManager.setAssociatedData("account_name_1200", "key12_second", "value12_second"); + } + catch(err){ + console.error("====>setAssociatedData ActsAccountAssociatedData_1200 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + var dataFir = await appAccountManager.getAssociatedData("account_name_1200", "key12_first"); + var dataSec = await appAccountManager.getAssociatedData("account_name_1200", "key12_second"); + } + catch(err){ + console.error("====>getAssociatedData ActsAccountAssociatedData_1200 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAccountAssociatedData_1200 getAssociatedData dataFir:" + JSON.stringify(dataFir)); + expect(dataFir).assertEqual("value12_first"); + console.debug("====>ActsAccountAssociatedData_1200 getAssociatedData dataSec:" + JSON.stringify(dataSec)); + expect(dataSec).assertEqual("value12_second"); + console.debug("====>delete account ActsAccountAssociatedData_1200 start===="); + try{ + await appAccountManager.deleteAccount("account_name_1200"); + } + catch(err){ + console.error("====>delete account 1200 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAccountAssociatedData_1200 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountAssociatedData_1300 + * @tc.name : setAssociatedData setting value is called when the argument is wrong + * @tc.desc : Call setAssociatedData setting value when the incoming parameter KEY is wrong(callback) + */ + it('ActsAccountAssociatedData_1300', 0, async function (done) { + console.debug("====>ActsAccountAssociatedData_1300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_1300", (err)=>{ + console.debug("====>add account ActsAccountAssociatedData_1300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAssociatedData("account_name_1300", "", "value13", (err)=>{ + console.debug("====>setAssociatedData ActsAccountAssociatedData_1300 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + appAccountManager.deleteAccount("account_name_1300", (err)=>{ + console.debug("====>delete account ActsAccountAssociatedData_1300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAssociatedData_1300 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountAssociatedData_1400 + * @tc.name : setAssociatedData setting value is called when the argument is wrong + * @tc.desc : Call setAssociatedData setting value when the incoming parameter KEY is wrong(promise) + */ + it('ActsAccountAssociatedData_1400', 0, async function (done) { + console.debug("====>ActsAccountAssociatedData_1400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountAssociatedData_1400 start===="); + try{ + await appAccountManager.addAccount("account_name_1400"); + } + catch(err){ + console.error("====>add account ActsAccountAssociatedData_1400 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + await appAccountManager.setAssociatedData("account_name_1400", "", "value14"); + } + catch(err){ + console.debug("====>setAssociatedData ActsAccountAssociatedData_1400 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>delete account ActsAccountAssociatedData_1400 start===="); + try{ + await appAccountManager.deleteAccount("account_name_1400"); + } + catch(err){ + console.error("====>delete account 1400 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAccountAssociatedData_1400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountAssociatedData_1500 + * @tc.name : setAssociatedData setting key is called when the argument is wrong + * @tc.desc : Call setAssociatedData setting key when the incoming parameter KEY is wrong(callback) + */ + it('ActsAccountAssociatedData_1500', 0, async function (done) { + console.debug("====>ActsAccountAssociatedData_1500 start===="); + var keyOverSize = "K" + for(var i = 0;i < 256;i++) + keyOverSize = keyOverSize + "K!@#"; + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_1500", (err)=>{ + console.debug("====>add account ActsAccountAssociatedData_1500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>1500 keyOverSize.length:" + JSON.stringify(keyOverSize.length)); + expect(keyOverSize.length).assertEqual(1025); + appAccountManager.setAssociatedData("account_name_1500", keyOverSize, "value15", (err)=>{ + console.debug("====>setAssociatedData ActsAccountAssociatedData_1500 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + appAccountManager.deleteAccount("account_name_1500", (err)=>{ + console.debug("====>delete account ActsAccountAssociatedData_1500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAssociatedData_1500 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountAssociatedData_1600 + * @tc.name : setAssociatedData setting key is called when the argument is wrong + * @tc.desc : Call setAssociatedData setting key when the incoming parameter KEY is wrong(promise) + */ + it('ActsAccountAssociatedData_1600', 0, async function (done) { + console.debug("====>ActsAccountAssociatedData_1600 start===="); + var keyOverSize = "K" + for(var i=0;i<256;i++) + keyOverSize = keyOverSize + "K!@#"; + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + expect(keyOverSize.length).assertEqual(1025); + console.debug("====>add account ActsAccountAssociatedData_1600 start===="); + try{ + await appAccountManager.addAccount("account_name_1600"); + } + catch(err){ + console.error("====>add account ActsAccountAssociatedData_1600 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + await appAccountManager.setAssociatedData("account_name_1600", keyOverSize, "value16"); + } + catch(err){ + console.debug("====>setAssociatedData ActsAccountAssociatedData_1600 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>delete account ActsAccountAssociatedData_1600 start===="); + try{ + await appAccountManager.deleteAccount("account_name_1600"); + } + catch(err){ + console.error("====>delete account 1600 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAccountAssociatedData_1600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountAssociatedData_1700 + * @tc.name : setAssociatedData and getAssociatedData are called when the argument is spaced + * @tc.desc : Call setAssociatedData and then getAssociatedData when the incoming key is a space(callback) + */ + it('ActsAccountAssociatedData_1700', 0, async function (done) { + console.debug("====>ActsAccountAssociatedData_1700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_1700", (err)=>{ + console.debug("====>add account ActsAccountAssociatedData_1700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAssociatedData("account_name_1700", " ", "value17", (err)=>{ + console.debug("====>ActsAccountAssociatedData_1700 setAssociatedData:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAssociatedData("account_name_1700", " ", (err, data)=>{ + console.debug("====>getAssociatedData 1700 err:" + JSON.stringify(err)); + console.debug("====>getAssociatedData 1700 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data).assertEqual("value17"); + appAccountManager.deleteAccount("account_name_1700", (err)=>{ + console.debug("====>delete Account 1700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAssociatedData_1700 end===="); + done(); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountAssociatedData_1800 + * @tc.name : setAssociatedData and getAssociatedData are called when the argument is spaced + * @tc.desc : Call setAssociatedData and then getAssociatedData when the incoming key is a space(promise) + */ + it('ActsAccountAssociatedData_1800', 0, async function (done) { + console.debug("====>ActsAccountAssociatedData_1800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountAssociatedData_1800 start===="); + try{ + await appAccountManager.addAccount("account_name_1800"); + } + catch(err){ + console.error("====>add account ActsAccountAssociatedData_1800 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + await appAccountManager.setAssociatedData("account_name_1800", " ", "value18"); + try{ + var data = await appAccountManager.getAssociatedData("account_name_1800", " "); + } + catch(err){ + console.error("====>setAssociatedData ActsAccountAssociatedData_1800 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAssociatedData ActsAccountAssociatedData_1800 data:" + JSON.stringify(data)); + expect(data).assertEqual("value18"); + console.debug("====>delete account ActsAccountAssociatedData_1800 start===="); + try{ + await appAccountManager.deleteAccount("account_name_1800"); + } + catch(err){ + console.error("====>delete account 1800 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAccountAssociatedData_1800 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountAssociatedData_1900 + * @tc.name : setAssociatedData and getAssociatedData are called when the argument is spaced + * @tc.desc : Call setAssociatedData and then getAssociatedData when the incoming value is null(callback) + */ + it('ActsAccountAssociatedData_1900', 0, async function (done) { + console.debug("====>ActsAccountAssociatedData_1900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_1900", (err)=>{ + console.debug("====>add account ActsAccountAssociatedData_1900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAssociatedData("account_name_1900", "key19", "", (err)=>{ + console.debug("====>setAssociatedData ActsAccountAssociatedData_1900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAssociatedData("account_name_1900", "key19", (err, data)=>{ + console.debug("====>getAssociatedData 1900 err:" + JSON.stringify(err)); + console.debug("====>getAssociatedData 1900 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data).assertEqual(""); + appAccountManager.deleteAccount("account_name_1900", (err)=>{ + console.debug("====>delete Account 1900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAssociatedData_1900 end===="); + done(); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountAssociatedData_2000 + * @tc.name : setAssociatedData and getAssociatedData are called when the argument is spaced + * @tc.desc : Call setAssociatedData and then getAssociatedData when the incoming value is null(promise) + */ + it('ActsAccountAssociatedData_2000', 0, async function (done) { + console.debug("====>ActsAccountAssociatedData_2000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountAssociatedData_2000 start===="); + try{ + await appAccountManager.addAccount("account_name_2000"); + } + catch(err){ + console.error("====>add account ActsAccountAssociatedData_2000 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + await appAccountManager.setAssociatedData("account_name_2000", "key20", ""); + } + catch(err){ + console.error("====>setAssociatedData ActsAccountAssociatedData_2000 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + var data = await appAccountManager.getAssociatedData("account_name_2000", "key20"); + } + catch(err){ + console.error("====>getAssociatedData 2000 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAssociatedData ActsAccountAssociatedData_2000 data:" + JSON.stringify(data)); + expect(data).assertEqual(""); + console.debug("====>delete account ActsAccountAssociatedData_2000 start===="); + try{ + await appAccountManager.deleteAccount("account_name_2000"); + } + catch(err){ + console.error("====>delete account 2000 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAccountAssociatedData_2000 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountAssociatedData_2100 + * @tc.name : setAssociatedData setting value is called when the argument is wrong + * @tc.desc : Call setAssociatedData setting value when the incoming parameter value is wrong(callback) + */ + it('ActsAccountAssociatedData_2100', 0, async function (done) { + console.debug("====>ActsAccountAssociatedData_2100 start===="); + var valueOverSize = "K" + for(var i = 0;i < 256;i++) + valueOverSize = valueOverSize + "K!@#"; + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_2100",(err)=>{ + console.debug("====>add account ActsAccountAssociatedData_2100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + expect(valueOverSize.length).assertEqual(1025); + appAccountManager.setAssociatedData("account_name_2100", "key21", valueOverSize, (err)=>{ + console.debug("====>setAssociatedData ActsAccountAssociatedData_2100 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + appAccountManager.deleteAccount("account_name_2100", (err)=>{ + console.debug("====>delete Account ActsAccountAssociatedData_2100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAssociatedData_2100 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountAssociatedData_2200 + * @tc.name : setAssociatedData setting value is called when the argument is wrong + * @tc.desc : Call setAssociatedData setting value when the incoming parameter value is wrong(promise) + */ + it('ActsAccountAssociatedData_2200', 0, async function (done) { + console.debug("====>ActsAccountAssociatedData_2200 start===="); + var valueOverSize = "K" + for(var i = 0;i < 256;i++) + valueOverSize = valueOverSize + "K!@#"; + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + expect(valueOverSize.length).assertEqual(1025); + try{ + await appAccountManager.addAccount("account_name_2200"); + } + catch(err){ + console.error("====>add account ActsAccountAssociatedData_2200 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + await appAccountManager.setAssociatedData("account_name_2200", "key22", valueOverSize); + } + catch(err){ + console.debug("====>setAssociatedData ActsAccountAssociatedData_2200 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>delete account ActsAccountAssociatedData_2200 start===="); + try{ + await appAccountManager.deleteAccount("account_name_2200"); + } + catch(err){ + console.error("====>delete account 2200 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAccountAssociatedData_2200 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountAssociatedData_2300 + * @tc.name : setAssociatedData and getAssociatedData are called when the argument is spaced + * @tc.desc : Call setAssociatedData and then getAssociatedData when the incoming value is a space(callback) + */ + it('ActsAccountAssociatedData_2300', 0, async function (done) { + console.debug("====>ActsAccountAssociatedData_2300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_2300", (err)=>{ + console.debug("====>add account ActsAccountAssociatedData_2300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAssociatedData("account_name_2300", "key23", " ", (err)=>{ + console.debug("====>setAssociatedData ActsAccountAssociatedData_2300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAssociatedData("account_name_2300", "key23", (err, data)=>{ + console.debug("====>getAssociatedData 2300 err:" + JSON.stringify(err)); + console.debug("====>getAssociatedData 2300 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data).assertEqual(" "); + appAccountManager.deleteAccount("account_name_2300", (err)=>{ + console.debug("====>delete Account 2300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAssociatedData_2300 end===="); + done(); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountAssociatedData_2400 + * @tc.name : setAssociatedData and getAssociatedData are called when the argument is spaced + * @tc.desc : Call setAssociatedData and then getAssociatedData when the incoming value is a space(promise) + */ + it('ActsAccountAssociatedData_2400', 0, async function (done) { + console.debug("====>ActsAccountAssociatedData_2400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountAssociatedData_2400 start===="); + try{ + await appAccountManager.addAccount("account_name_2400"); + } + catch(err){ + console.error("====>add account ActsAccountAssociatedData_2400 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + await appAccountManager.setAssociatedData("account_name_2400", "key24", " "); + try{ + var data = await appAccountManager.getAssociatedData("account_name_2400", "key24"); + } + catch(err){ + console.error("====>getAssociatedData 2400 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAssociatedData 2400 err:" + JSON.stringify(data)); + expect(data).assertEqual(" "); + console.debug("====>delete account ActsAccountAssociatedData_2400 start===="); + try{ + await appAccountManager.deleteAccount("account_name_2400"); + } + catch(err){ + console.error("====>delete account 2400 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAccountAssociatedData_2400 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountAssociatedData_2500 + * @tc.name : setAssociatedData and getAssociatedData are called when the argument is spaced + * @tc.desc : Call setAssociatedData and then getAssociatedData when the incoming name is null(callback) + */ + it('ActsAccountAssociatedData_2500', 0, async function (done) { + console.debug("====>ActsAccountAssociatedData_2500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_2500", (err)=>{ + console.debug("====>add account ActsAccountAssociatedData_2500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAssociatedData("", "key25", "value25", (err)=>{ + console.debug("====>setAssociatedData ActsAccountAssociatedData_2500 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + appAccountManager.deleteAccount("account_name_2500", (err)=>{ + console.debug("====>delete Account ActsAccountAssociatedData_2500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAssociatedData_2500 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountAssociatedData_2600 + * @tc.name : setAssociatedData and getAssociatedData are called when the argument is spaced + * @tc.desc : Call setAssociatedData and then getAssociatedData when the incoming name is null(promise) + */ + it('ActsAccountAssociatedData_2600', 0, async function (done) { + console.debug("====>ActsAccountAssociatedData_2600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>ActsAccountAssociatedData_2600 addAccount start===="); + try{ + await appAccountManager.addAccount("account_name_2600"); + } + catch(err){ + console.error("====>add account ActsAccountAssociatedData_2600 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + await appAccountManager.setAssociatedData("", "key26", "value26"); + } + catch(err){ + console.debug("====>setAssociatedData ActsAccountAssociatedData_2600 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>delete account ActsAccountAssociatedData_2600 start===="); + try{ + await appAccountManager.deleteAccount("account_name_2600"); + } + catch(err){ + console.error("====>delete account 2600 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAccountAssociatedData_2600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountAssociatedData_2700 + * @tc.name : setAssociatedData setting name is called when the argument is wrong + * @tc.desc : Call setAssociatedData setting name when the incoming parameter name is wrong(callback) + */ + it('ActsAccountAssociatedData_2700', 0, async function (done) { + console.debug("====>ActsAccountAssociatedData_2700 start===="); + var nameOverSize = "n" + for(var i = 0;i < 256;i++) + nameOverSize = nameOverSize+"name"; + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_2700",(err)=>{ + console.debug("====>add account ActsAccountAssociatedData_2700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + expect(nameOverSize.length).assertEqual(1025); + appAccountManager.setAssociatedData(nameOverSize, "key27", "value27", (err)=>{ + console.debug("====>ActsAccountAssociatedData_2700 setAssociatedData:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + appAccountManager.deleteAccount("account_name_2700", (err)=>{ + console.debug("====>delete Account ActsAccountAssociatedData_2700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAssociatedData_2700 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountAssociatedData_2800 + * @tc.name : setAssociatedData setting name is called when the argument is wrong + * @tc.desc : Call setAssociatedData setting name when the incoming parameter name is wrong(promise) + */ + it('ActsAccountAssociatedData_2800', 0, async function (done) { + console.debug("====>ActsAccountAssociatedData_2800 start===="); + var nameOverSize = "n" + for(var i = 0;i < 256;i++) + nameOverSize = nameOverSize + "name"; + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + expect(nameOverSize.length).assertEqual(1025); + console.debug("====>add account ActsAccountAssociatedData_2800 start===="); + try{ + await appAccountManager.addAccount("account_name_2800"); + } + catch(err){ + console.error("====>add account ActsAccountAssociatedData_2800 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + await appAccountManager.setAssociatedData(nameOverSize, "key28", "value28"); + } + catch(err){ + console.debug("====>setAssociatedData ActsAccountAssociatedData_2800 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>delete account ActsAccountAssociatedData_2800 start===="); + try{ + await appAccountManager.deleteAccount("account_name_2800"); + } + catch(err){ + console.error("====>delete account 2800 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAccountAssociatedData_2800 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountAssociatedData_2900 + * @tc.name : setAssociatedData and getAssociatedData are called when the argument is spaced + * @tc.desc : Call setAssociatedData and then getAssociatedData when the incoming name is a space(callback) + */ + it('ActsAccountAssociatedData_2900', 0, async function (done) { + console.debug("====>ActsAccountAssociatedData_2900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount(" ", (err)=>{ + console.debug("====>add account ActsAccountAssociatedData_2900 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + appAccountManager.setAssociatedData(" ", "key29", "value29", (err)=>{ + console.debug("====>setAssociatedData ActsAccountAssociatedData_2900 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + appAccountManager.getAssociatedData(" ", "key29", (err, data)=>{ + console.debug("====>getAssociatedData 2900 err:" + JSON.stringify(err)); + console.debug("====>getAssociatedData 2900 data:" + JSON.stringify(data)); + expect(err.code != 0).assertEqual(true); + expect(data).assertEqual(""); + console.debug("====>ActsAccountAssociatedData_2900 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountAssociatedData_3000 + * @tc.name : setAssociatedData and getAssociatedData are called when the argument is spaced + * @tc.desc : Call setAssociatedData and then getAssociatedData when the incoming name is a space(promise) + */ + it('ActsAccountAssociatedData_3000', 0, async function (done) { + console.debug("====>ActsAccountAssociatedData_3000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + try{ + await appAccountManager.addAccount(" "); + } + catch(err){ + console.debug("====>add account ActsAccountAssociatedData_3000 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + try{ + await appAccountManager.setAssociatedData(" ", "key30", "value30"); + } + catch(err){ + console.error("====>setAssociatedData ActsAccountAssociatedData_3000 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + try{ + await appAccountManager.getAssociatedData(" ", "key30"); + } + catch(err){ + console.error("====>getAssociatedData ActsAccountAssociatedData_3000 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountAssociatedData_3000 end===="); + done(); + } + } + } + }) +}) \ No newline at end of file diff --git a/account/appaccount/actsaccounttest/entry/src/main/js/test/CreatManager.test.js b/account/appaccount/actsaccounttest/entry/src/main/js/test/CreatManager.test.js new file mode 100755 index 0000000000000000000000000000000000000000..6ed836ce6de18bfc2a7030d66f155cc07415d7e9 --- /dev/null +++ b/account/appaccount/actsaccounttest/entry/src/main/js/test/CreatManager.test.js @@ -0,0 +1,89 @@ +/* + * 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + +const TIMEOUT = 10000; +describe('ActsCreatAppAccountManager', function () { + function sleep(delay) { + var start = (new Date()).getTime(); + while((new Date()).getTime() - start < delay) { + continue; + } + } + + beforeAll(async function (done) { + console.debug("====>beforeAll start===="); + sleep(TIMEOUT); + console.debug("====>beforeAll end===="); + done(); + }); + /* + * @tc.number : ActsCreatAppAccountManager_0100 + * @tc.name : createAppAccountManager + * @tc.desc : Create two application account module objects, one object adds an application account, + * the other object deletes the application account + */ + it('ActsCreatAppAccountManager_0100', 0, async function (done) { + console.debug("====>ActsCreatAppAccountManager_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + var appAccountManagerTwo = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("creatappaccount_name_first", (err)=>{ + console.debug("====>add account ActsCreatAppAccountManager_0100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManagerTwo.deleteAccount("creatappaccount_name_first", (err)=>{ + console.debug("====>delete Account ActsCreatAppAccountManager_0100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsCreatAppAccountManager_0100 end===="); + done(); + }); + }); + }); + + /* + * @tc.number : ActsCreatAppAccountManager_0200 + * @tc.name : createAppAccountManager + * @tc.desc : Create two application account module objects, one object adds application accounts and + * sets additional information, and the other object can obtain additional information of + * the application account + */ + it('ActsCreatAppAccountManager_0200', 0, async function (done) { + console.debug("====>ActsCreatAppAccountManager_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + var appAccountManagerTwo = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("creatappaccount_name_second", (err)=>{ + console.debug("====>add account ActsCreatAppAccountManager_0200 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManagerTwo.setAccountExtraInfo("creatappaccount_name_second", "creatappaccount_extra", (err)=>{ + console.debug("====>setAccountExtraInfo err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAccountExtraInfo("creatappaccount_name_second", (err, data)=>{ + console.debug("====>getAccountExtraInfo err:" + JSON.stringify(err)); + console.debug("====>getAccountExtraInfo data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data).assertEqual("creatappaccount_extra"); + appAccountManagerTwo.deleteAccount("creatappaccount_name_second", (err)=>{ + console.debug("====>delete Account err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsCreatAppAccountManager_0200 end===="); + done(); + }); + }); + }); + }); + }); +}) \ No newline at end of file diff --git a/account/appaccount/actsaccounttest/entry/src/main/js/test/Credential.test.js b/account/appaccount/actsaccounttest/entry/src/main/js/test/Credential.test.js new file mode 100755 index 0000000000000000000000000000000000000000..8f6dd8139323b6cf576d1af7e8b330d189e346db --- /dev/null +++ b/account/appaccount/actsaccounttest/entry/src/main/js/test/Credential.test.js @@ -0,0 +1,665 @@ +/* + * 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + +const TIMEOUT = 10000; +describe('ActsAccountCredential', function () { + function sleep(delay) { + var start = (new Date()).getTime(); + while((new Date()).getTime() - start < delay) { + continue; + } + } + + beforeAll(async function (done) { + console.debug("====>beforeAll start===="); + sleep(TIMEOUT); + console.debug("====>beforeAll end===="); + done(); + }); + + /* + * @tc.number : ActsAccountCredential_0100 + * @tc.name : The correct calls setAssociatedData and getAccountCredential get the credential + * @tc.desc : The setAccountCredential setting credential is called when the forwarding parameters + * are correct, and then getAccountCredential is called for the credential(callback) + */ + it('ActsAccountCredential_0100', 0, async function (done) { + console.debug("====>ActsAccountCredential_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_0100", (err)=>{ + console.debug("====>add account ActsAccountCredential_0100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAccountCredential("account_name_0100", "credentialType1", "credential1",(err)=>{ + console.debug("====>ActsAccountCredential_0100 setAccountCredential:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAccountCredential("account_name_0100", "credentialType1", (err,data)=>{ + console.debug("====>getAccountCredential 0100 err:" + JSON.stringify(err)); + console.debug("====>getAccountCredential 0100 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data).assertEqual("credential1"); + appAccountManager.deleteAccount("account_name_0100", (err)=>{ + console.debug("====>delete Account 0100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountCredential_0100 end===="); + done(); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountCredential_0200 + * @tc.name : The correct calls setAccountCredential and getAccountCredential get the credential + * @tc.desc : The setAssociatedData setting credential is called when the forwarding parameters + * are correct, and then getAccountCredential is called for the credential(promise) + */ + it('ActsAccountCredential_0200', 0, async function (done) { + console.debug("====>ActsAccountCredential_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add accountActsAccountCredential_0200 start===="); + await appAccountManager.addAccount("account_name_0200"); + console.debug("====>setAccountCredential ActsAccountCredential_0200 start===="); + try{ + await appAccountManager.setAccountCredential("account_name_0200", "credentialType2", "credential2"); + } + catch(err){ + console.error("setAccountCredential ActsAccountCredential_0200 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAccountCredential ActsAccountCredential_0200 start===="); + try{ + var data = await appAccountManager.getAccountCredential("account_name_0200", "credentialType2"); + } + catch(err){ + console.error("getAccountCredential ActsAccountCredential_0200 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAccountCredential ActsAccountCredential_0200 data:" + JSON.stringify(data)); + expect(data).assertEqual("credential2"); + console.debug("====>delete account ActsAccountCredential_0200 start===="); + appAccountManager.deleteAccount("account_name_0200") + console.debug("====>ActsAccountCredential_0200 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountCredential_0300 + * @tc.name : Whether getAssociatedData can get the correct value when calling setAccountCredential two times + * @tc.desc : When the first setAccountCredential is called and the second setAccountCredential + * is called,the setting of the credential is different if the call getAccountCredential + * can get the second credential(callback) + */ + it('ActsAccountCredential_0300', 0, async function (done) { + console.debug("====>ActsAccountCredential_0300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_0300",(err)=>{ + console.debug("====>add account ActsAccountCredential_0300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAccountCredential("account_name_0300", "credentialType3", "credential3",(err)=>{ + console.debug("====>setAccountCredential first time 0300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAccountCredential("account_name_0300", "credentialType3", "newcredential3",(err)=>{ + console.debug("====>setAccountCredential second time 0300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAccountCredential("account_name_0300", "credentialType3", (err, data)=>{ + console.debug("====>getAccountCredential 0300 err:" + JSON.stringify(err)); + console.debug("====>getAccountCredential 0300 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data).assertEqual("newcredential3"); + appAccountManager.deleteAccount("account_name_0300", (err)=>{ + console.debug("====>delete Account 0300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountCredential_0300 end===="); + done(); + }); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountCredential_0400 + * @tc.name : Whether getAssociatedData can get the correct value when calling setAccountCredential two times + * @tc.desc : When the first setAccountCredential is called and the second setAccountCredential + * is called,the setting of the credential is different if the call getAccountCredential + * can get the second credential(promise) + */ + it('ActsAccountCredential_0400', 0, async function (done) { + console.debug("====>ActsAccountCredential_0400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountCredential_0400 start===="); + await appAccountManager.addAccount("account_name_0400"); + try{ + await appAccountManager.setAccountCredential("account_name_0400", "credentialType4", "credential4"); + await appAccountManager.setAccountCredential("account_name_0400", "credentialType4", "newcredential4") + } + catch(err){ + console.error("setAccountCredential ActsAccountCredential_0400 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + var data = await appAccountManager.getAccountCredential("account_name_0400", "credentialType4"); + } + catch(err){ + console.error("getAccountCredential ActsAccountCredential_0400 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsAccountCredential_0400 getAccountCredential data:" + JSON.stringify(data)); + expect(data).assertEqual("newcredential4"); + console.debug("====>delete account ActsAccountCredential_0400 start===="); + appAccountManager.deleteAccount("account_name_0400") + console.debug("====>ActsAccountCredential_0400 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountCredential_0500 + * @tc.name : setAssociatedData and getAssociatedData are called when the argument is null + * @tc.desc : Call setAssociatedData and then getAssociatedData when the incoming credential is null(callback) + */ + it('ActsAccountCredential_0500', 0, async function (done) { + console.debug("====>ActsAccountCredential_0500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_0500",(err)=>{ + console.debug("====>add account ActsAccountCredential_0500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAccountCredential("account_name_0500", "credentialType5", "", (err)=>{ + console.debug("====>setAccountCredential ActsAccountCredential_0500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAccountCredential("account_name_0500", "credentialType5", (err,data)=>{ + console.debug("====>getAccountCredential ActsAccountCredential_0500 err:" + JSON.stringify(err)); + console.debug("====>getAccountCredential ActsAccountCredential_0500 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data).assertEqual(""); + appAccountManager.deleteAccount("account_name_0500", (err)=>{ + console.debug("====>delete Account ActsAccountCredential_0500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountCredential_0500 end===="); + done(); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountCredential_0600 + * @tc.name : setAssociatedData and getAssociatedData are called when the argument is null + * @tc.desc : Call setAssociatedData and then getAssociatedData when the incoming credential is null(promise) + */ + it('ActsAccountCredential_0600', 0, async function (done) { + console.debug("====>ActsAccountCredential_0600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountCredential_0600 start===="); + await appAccountManager.addAccount("account_name_0600"); + console.debug("====>setAccountCredential ActsAccountCredential_0600 start===="); + await appAccountManager.setAccountCredential("account_name_0600", "credentialType6", ""); + console.debug("====>getAccountCredential ActsAccountCredential_0600 start===="); + var data = await appAccountManager.getAccountCredential("account_name_0600", "credentialType6"); + console.debug("====>getAccountCredential ActsAccountCredential_0600 data" + JSON.stringify(data)); + expect(data).assertEqual(""); + console.debug("====>delete account ActsAccountCredential_0600 start===="); + await appAccountManager.deleteAccount("account_name_0600"); + console.debug("====>ActsAccountCredential_0600 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountCredential_0700 + * @tc.name : setAssociatedData setting value is called when the argument is wrong + * @tc.desc : Call setAssociatedData setting credential when the incoming parameter type is null(callback) + */ + it('ActsAccountCredential_0700', 0, async function (done) { + console.debug("====>ActsAccountCredential_0700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_0700", (err)=>{ + console.debug("====>add account ActsAccountCredential_0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAccountCredential("account_name_0700", "", "credential7", (err)=>{ + console.debug("====>setAccountCredential ActsAccountCredential_0700 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + appAccountManager.deleteAccount("account_name_0700", (err)=>{ + console.debug("====>delete Account ActsAccountCredential_0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountCredential_0700 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountCredential_0800 + * @tc.name : setAssociatedData setting value is called when the argument is wrong + * @tc.desc : Call setAssociatedData setting credential when the incoming parameter type is null(promise) + */ + it('ActsAccountCredential_0800', 0, async function (done) { + console.debug("====>ActsAccountCredential_0800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ccountActsAccountCredential_0800 start===="); + await appAccountManager.addAccount("account_name_0800"); + try{ + await appAccountManager.setAccountCredential("account_name_0800", "", "credential8"); + } + catch(err){ + console.debug("====>setAccountCredential ActsAccountCredential_0800 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>delete account ActsAccountCredential_0800 start===="); + appAccountManager.deleteAccount("account_name_0800"); + console.debug("====>ActsAccountCredential_0800 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountCredential_0900 + * @tc.name : getAccountCredential getting value is called when the argument is wrong + * @tc.desc : Call getAccountCredential getting credential when the incoming parameter type is wrong(callback) + */ + it('ActsAccountCredential_0900', 0, async function (done) { + console.debug("====>ActsAccountCredential_0900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_0900", (err)=>{ + console.debug("====>add account ActsAccountCredential_0900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAccountCredential("account_name_0900", "", (err)=>{ + console.debug("====>getAccountCredential ActsAccountCredential_0900 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + appAccountManager.deleteAccount("account_name_0900", (err)=>{ + console.debug("====>delete Account ActsAccountCredential_0900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountCredential_0900 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountCredential_1000 + * @tc.name : getAccountCredential getting value is called when the argument is wrong + * @tc.desc : Call getAccountCredential getting credential when the incoming parameter type is wrong(promise) + */ + it('ActsAccountCredential_1000', 0, async function (done) { + console.debug("====>ActsAccountCredential_1000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountCredential_1000 start===="); + await appAccountManager.addAccount("account_name_1000"); + try{ + await appAccountManager.getAccountCredential("account_name_1000",""); + } + catch(err){ + console.debug("====>getAccountCredential ActsAccountCredential_1000 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>delete account ActsAccountCredential_1000 start===="); + await appAccountManager.deleteAccount("account_name_1000"); + console.debug("====>ActsAccountCredential_1000 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountCredential_1100 + * @tc.name : setAssociatedData setting credential is called when the argument is sapce + * @tc.desc : Call setAssociatedData setting credential when the incoming parameter type is space + * then use getAccountCredential getting the credential(callback) + */ + it('ActsAccountCredential_1100', 0, async function (done) { + console.debug("====>ActsAccountCredential_1100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_1100",(err)=>{ + console.debug("====>add account ActsAccountCredential_1100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAccountCredential("account_name_1100", " ", "credential11",(err)=>{ + console.debug("====>setAccountCredential ActsAccountCredential_1100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAccountCredential("account_name_1100", " ", (err, data)=>{ + console.debug("====>getAccountCredential 1100 err:" + JSON.stringify(err)); + console.debug("====>getAccountCredential 1100 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data).assertEqual("credential11"); + appAccountManager.deleteAccount("account_name_1100", (err)=>{ + console.debug("====>delete Account 1100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountCredential_1100 end===="); + done(); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountCredential_1200 + * @tc.name : setAssociatedData setting credential is called when the argument is sapce + * @tc.desc : Call setAssociatedData setting credential when the incoming parameter type is space + * then use getAccountCredential getting the credential(promise) + */ + it('ActsAccountCredential_1200', 0, async function (done) { + console.debug("====>ActsAccountCredential_1200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountCredential_1200 start===="); + await appAccountManager.addAccount("account_name_1200"); + console.debug("====>setAccountCredential ActsAccountCredential_1200 start===="); + await appAccountManager.setAccountCredential("account_name_1200", " ", "credential12"); + console.debug("====>getAccountCredential ActsAccountCredential_1200 start===="); + var data = await appAccountManager.getAccountCredential("account_name_1200", " "); + console.debug("====>getAccountCredential ActsAccountCredential_1200 data" + JSON.stringify(data)); + expect(data).assertEqual("credential12"); + console.debug("====>delete account ActsAccountCredential_1200 start===="); + await appAccountManager.deleteAccount("account_name_1200"); + console.debug("====>ActsAccountCredential_1200 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountCredential_1300 + * @tc.name : setAssociatedData setting credential is called when the argument is wrong + * @tc.desc : Call setAssociatedData setting credential when the incoming parameter name is null(callback) + */ + it('ActsAccountCredential_1300', 0, async function (done) { + console.debug("====>ActsAccountCredential_1300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_1300",(err)=>{ + console.debug("====>add account ActsAccountCredential_1300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAccountCredential("", "credentialType13", "credential13", (err)=>{ + console.debug("====>setAccountCredential ActsAccountCredential_1300 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + appAccountManager.deleteAccount("account_name_1300", (err)=>{ + console.debug("====>delete Account ActsAccountCredential_1300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountCredential_1300 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountCredential_1400 + * @tc.name : setAssociatedData setting credential is called when the argument is wrong + * @tc.desc : Call setAssociatedData setting credential when the incoming parameter name is null(promise) + */ + it('ActsAccountCredential_1400', 0, async function (done) { + console.debug("====>ActsAccountCredential_1400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountCredential_1400 start===="); + await appAccountManager.addAccount("account_name_1400"); + try{ + await appAccountManager.setAccountCredential("", "credentialType14", "credential14"); + } + catch(err){ + console.debug("====>setAccountCredential ActsAccountCredential_1400 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>delete account ActsAccountCredential_1400 start===="); + await appAccountManager.deleteAccount("account_name_1400"); + console.debug("====>ActsAccountCredential_1400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountCredential_1500 + * @tc.name : Get it directly without setting credential callback + * @tc.desc : Call getAccountCredential directly to get credential without calling setAccountCredential + */ + it('ActsAccountCredential_1500', 0, async function (done) { + console.debug("====>ActsAccountCredential_1500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_1500", (err)=>{ + console.debug("====>add account ActsAccountCredential_1500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAccountCredential("account_name_1500", "credentialType15", (err)=>{ + console.debug("====>getAccountCredential ActsAccountCredential_1500 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + appAccountManager.deleteAccount("account_name_1500", (err)=>{ + console.debug("====>delete Account ActsAccountCredential_1500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountCredential_1500 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountCredential_1600 + * @tc.name : Get it directly without setting credential promise + * @tc.desc : Call getAccountCredential directly to get credential without calling setAccountCredential + */ + it('ActsAccountCredential_1600', 0, async function (done) { + console.debug("====>ActsAccountCredential_1600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountCredential_1600 start===="); + await appAccountManager.addAccount("account_name_1600"); + try{ + await appAccountManager.getAccountCredential("account_name_1600", "credentialType16"); + } + catch(err){ + console.debug("====>getAccountCredential ActsAccountCredential_1600 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>delete account ActsAccountCredential_1600 start===="); + await appAccountManager.deleteAccount("account_name_1600"); + console.debug("====>ActsAccountCredential_1600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountCredential_1700 + * @tc.name : setAccountCredential setting credential is called when the argument is wrong callback + * @tc.desc : Call setAccountCredential setting credential when the incoming parameter credential is wrong + */ + it('ActsAccountCredential_1700', 0, async function (done) { + console.debug("====>ActsAccountCredential_1700 start===="); + var CREDENTIALOVERSIZE = "K" + for(var i = 0;i < 256;i++) + CREDENTIALOVERSIZE = CREDENTIALOVERSIZE + "K!@#"; + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_1700", (err)=>{ + console.debug("====>add account ActsAccountCredential_1700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAccountCredential("account_name_1700", "credentialType17", CREDENTIALOVERSIZE, (err)=>{ + console.debug("====>CREDENTIALOVERSIZE.length:" + JSON.stringify(CREDENTIALOVERSIZE.length)); + expect(CREDENTIALOVERSIZE.length).assertEqual(1025); + console.debug("====>setAccountCredential ActsAccountCredential_1700 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + appAccountManager.deleteAccount("account_name_1700", (err)=>{ + console.debug("====>delete Account ActsAccountCredential_1700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountCredential_1700 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountCredential_1800 + * @tc.name : setAccountCredential setting credential is called when the argument is wrong promise + * @tc.desc : Call setAccountCredential setting credential when the incoming parameter credential is wrong + */ + it('ActsAccountCredential_1800', 0, async function (done) { + console.debug("====>ActsAccountCredential_1800 start===="); + var bigStr = "K" + for(var i = 0;i < 256;i++) + bigStr = bigStr + "K!@#"; + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountCredential_1800 start===="); + await appAccountManager.addAccount("account_name_1800"); + try{ + await appAccountManager.setAccountCredential("account_name_1800", "credentialType18", bigStr); + } + catch(err){ + console.debug("====>bigStr.length:" + JSON.stringify(bigStr.length)); + expect(bigStr.length).assertEqual(1025); + console.debug("====>setAccountCredential ActsAccountCredential_1800 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>delete account ActsAccountCredential_1800 start===="); + await appAccountManager.deleteAccount("account_name_1800"); + console.debug("====>ActsAccountCredential_1800 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountCredential_1900 + * @tc.name : setAccountCredential setting credential is called when the argument is wrong + * @tc.desc : Call setAccountCredential setting type when the incoming parameter credential is wrong(callback) + */ + it('ActsAccountCredential_1900', 0, async function (done) { + console.debug("====>ActsAccountCredential_1900 start===="); + var CREDENTIALTYPEOVERSIZE = "K" + for(var i = 0;i < 256;i++) + CREDENTIALTYPEOVERSIZE = CREDENTIALTYPEOVERSIZE + "K!@#"; + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_1900", (err)=>{ + console.debug("====>add account ActsAccountCredential_1900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAccountCredential("account_name_1900", CREDENTIALTYPEOVERSIZE, "credential19", (err)=>{ + console.debug("====>CREDENTIALTYPEOVERSIZE.length:" + JSON.stringify(CREDENTIALTYPEOVERSIZE.length)); + expect(CREDENTIALTYPEOVERSIZE.length).assertEqual(1025); + console.debug("====>setAccountCredential ActsAccountCredential_1900 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + appAccountManager.deleteAccount("account_name_1900", (err)=>{ + console.debug("====>delete Account ActsAccountCredential_1900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountCredential_1900 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountCredential_2000 + * @tc.name : setAccountCredential setting credential is called when the argument is wrong + * @tc.desc : Call setAccountCredential setting type when the incoming parameter credential is wrong(promise) + */ + it('ActsAccountCredential_2000', 0, async function (done) { + console.debug("====>ActsAccountCredential_2000 start===="); + var CREDENTIALTYPEOVERSIZE = "K" + for(var i = 0;i < 256;i++) + CREDENTIALTYPEOVERSIZE=CREDENTIALTYPEOVERSIZE+"K!@#"; + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountCredential_2000 start===="); + await appAccountManager.addAccount("account_name_2000"); + try{ + await appAccountManager.setAccountCredential("account_name_2000", CREDENTIALTYPEOVERSIZE , "credential20"); + } + catch(err){ + console.debug("====>CREDENTIALTYPEOVERSIZE.length:" + JSON.stringify(CREDENTIALTYPEOVERSIZE.length)); + expect(CREDENTIALTYPEOVERSIZE.length).assertEqual(1025); + console.debug("====>setAccountCredential ActsAccountCredential_2000 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>delete account ActsAccountCredential_2000 start===="); + await appAccountManager.deleteAccount("account_name_2000"); + console.debug("====>ActsAccountCredential_2000 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountCredential_2100 + * @tc.name : setAccountCredential setting credential is called when the argument is wrong + * @tc.desc : Call setAccountCredential setting name when the incoming parameter name is wrong(callback) + */ + it('ActsAccountCredential_2100', 0, async function (done) { + console.debug("====>ActsAccountCredential_2100 start===="); + var NAMEOVERSIZE = "n" + for(var i = 0;i < 256;i++) + NAMEOVERSIZE = NAMEOVERSIZE + "name"; + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_2100", (err)=>{ + console.debug("====>add account ActsAccountCredential_2100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAccountCredential(NAMEOVERSIZE, "credentialType21", "credential21", (err)=>{ + console.debug("====>setAccountCredential ActsAccountCredential_2100 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + appAccountManager.deleteAccount("account_name_2100", (err)=>{ + console.debug("====>delete Account ActsAccountCredential_2100 err:" + JSON.stringify(err)); + console.debug("====>ActsAccountCredential_2100 end===="); + expect(err.code).assertEqual(0); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountCredential_2200 + * @tc.name : setAccountCredential setting credential is called when the argument is wrong + * @tc.desc : Call setAccountCredential setting name when the incoming parameter name is wrong(promise) + */ + it('ActsAccountCredential_2200', 0, async function (done) { + console.debug("====>ActsAccountCredential_2200 start===="); + var NAMEOVERSIZE ="n" + for(var i=0;i<256;i++) + NAMEOVERSIZE=NAMEOVERSIZE+"name"; + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountCredential_2200 start===="); + try{ + await appAccountManager.addAccount("account_name_2200"); + } + catch(err){ + console.debug("====>add account ActsAccountCredential_2200 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>setAccountCredential ActsAccountCredential_2200 start===="); + try{ + await appAccountManager.setAccountCredential(NAMEOVERSIZE, "credentialType22", "credential22"); + } + catch(err){ + console.debug("====>setAccountCredential ActsAccountCredential_2200 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>delete account ActsAccountCredential_2200 start===="); + await appAccountManager.deleteAccount("account_name_2200"); + console.debug("====>ActsAccountCredential_2200 end===="); + done(); + } + }); +}) \ No newline at end of file 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 new file mode 100755 index 0000000000000000000000000000000000000000..25020823449dbac460ea7dc6d483f53543feb5c8 --- /dev/null +++ b/account/appaccount/actsaccounttest/entry/src/main/js/test/DeleteAccount.test.js @@ -0,0 +1,241 @@ +/* + * 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + +const TIMEOUT = 10000; +const STRCOUNT = 1025; +describe('ActsAccountDeleteAccount', function () { + function sleep(delay) { + var start = (new Date()).getTime(); + while((new Date()).getTime() - start < delay) { + continue; + } + } + + beforeAll(async function (done) { + console.debug("====>beforeAll start===="); + sleep(TIMEOUT); + console.debug("====>beforeAll end===="); + done(); + }); + + /* + * @tc.number : ActsAccountDeleteAccount_0100 + * @tc.name : Delete account calllback form + * @tc.desc : Delete the added account in callback form + */ + it('ActsAccountDeleteAccount_0100', 0, async function (done) { + console.debug("====>ActsAccountDeleteAccount_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("deleteAccount_name_callback_first", "extraInfo_callback_first", (err)=>{ + console.debug("====>add account ActsAccountDeleteAccount_0100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount("deleteAccount_name_callback_first", (err)=>{ + console.debug("====>delete Account ActsAccountDeleteAccount_0100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountDeleteAccount_0100 end===="); + done(); + }); + }); + }); + + /* + * @tc.number : ActsAccountDeleteAccount_0200 + * @tc.name : Delete account calllback form + * @tc.desc : Delete unadded account in callback form + */ + it('ActsAccountDeleteAccount_0200', 0, async function (done) { + console.debug("====>ActsAccountDeleteAccount_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.deleteAccount("deleteAccount_name_callback_second", (err)=>{ + console.debug("====>delete Account ActsAccountDeleteAccount_0200 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountDeleteAccount_0200 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsAccountDeleteAccount_0300 + * @tc.name : Delete account calllback form + * @tc.desc : Delete the added account, the first time it can be deleted, the second time the deletion fails + */ + it('ActsAccountDeleteAccount_0300', 0, async function (done) { + console.debug("====>ActsAccountDeleteAccount_0300 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("deleteAccount_name_callback_third", "extraInfo_callback_third", (err)=>{ + console.debug("====>add account ActsAccountDeleteAccount_0300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount("deleteAccount_name_callback_third", (err)=>{ + console.debug("====>delete account first time err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount("deleteAccount_name_callback_third", (err)=>{ + console.debug("====>delete Account second time err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountDeleteAccount_0300 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountDeleteAccount_0400 + * @tc.name : Delete account calllback form + * @tc.desc : Delete the account name exceeds the length limit of 1024 + */ + it('ActsAccountDeleteAccount_0400',0, async function (done){ + console.debug("====>ActsAccountDeleteAccount_0400 start===="); + var bigStr = ''; + for (var i = 0; i < STRCOUNT; i++) { + bigStr += 't'; + } + var appAccountManager = account.createAppAccountManager(); + appAccountManager.deleteAccount(bigStr, (err)=>{ + console.debug("====>delete Account ActsAccountDeleteAccount_0400 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountDeleteAccount_0400 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsAccountDeleteAccount_0500 + * @tc.name : Delete account calllback form + * @tc.desc : Delete the account name is an empty string + */ + it('ActsAccountDeleteAccount_0500',0, async function (done){ + console.debug("====>ActsAccountDeleteAccount_0500 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.deleteAccount("", (err)=>{ + console.debug("====>delete Account ActsAccountDeleteAccount_0500 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountDeleteAccount_0500 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsAccountDeleteAccount_0600 + * @tc.name : Delete account promise form + * @tc.desc : Delete the added account in promise form + */ + it('ActsAccountDeleteAccount_0600',0,async function (done){ + console.debug("====>ActsAccountDeleteAccount_0600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>add account ActsAccountAddAccount_0600 start===="); + await appAccountManager.addAccount("deleteAccount_name_promise_first","extraInfo_promise_first"); + try{ + await appAccountManager.deleteAccount("deleteAccount_name_promise_first"); + console.debug("====>ActsAccountDeleteAccount_0600 end===="); + done(); + } + catch(err){ + console.error("====>delete account ActsAccountDeleteAccount_0600 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + }); + + /* + * @tc.number : ActsAccountDeleteAccount_0700 + * @tc.name : Delete account promise form + * @tc.desc : Delete unadded account in promise form + */ + it('ActsAccountDeleteAccount_0700', 0, async function(done){ + console.debug("====>ActsAccountDeleteAccount_0700 start===="); + var appAccountManager = account.createAppAccountManager(); + try{ + await appAccountManager.deleteAccount("deleteAccount_name_promise_second"); + } + catch(err){ + console.debug("====>delete account ActsAccountDeleteAccount_0700 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountDeleteAccount_0700 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountDeleteAccount_0800 + * @tc.name : Delete account promise form + * @tc.desc : Delete the added account, the first time it can be deleted, the second time the deletion fails + */ + it('ActsAccountDeleteAccount_0800', 0, async function (done){ + console.debug("====>ActsAccountDeleteAccount_0800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>add account ActsAccountAddAccount_0800 start===="); + await appAccountManager.addAccount("deleteAccount_name_promise_third", "extraInfo_promise_third"); + console.debug("====>delete Account first time ActsAccountDeleteAccount_0800 start===="); + await appAccountManager.deleteAccount("deleteAccount_name_promise_third"); + console.debug("====>delete Account second time ActsAccountDeleteAccount_0800 start===="); + try{ + await appAccountManager.deleteAccount("deleteAccount_name_promise_third"); + } + catch(err){ + console.debug("====>delete account ActsAccountDeleteAccount_0700 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountDeleteAccount_0700 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountDeleteAccount_0900 + * @tc.name : Delete account promise form + * @tc.desc : Delete the account name exceeds the length limit of 1024 + */ + it('ActsAccountDeleteAccount_0900', 0, async function (done){ + console.debug("====>ActsAccountDeleteAccount_0900 start===="); + var bigStr = ''; + for (var i = 0; i < STRCOUNT; i++) { + bigStr += 't'; + } + var appAccountManager = account.createAppAccountManager(); + console.debug("====>delete Account ActsAccountDeleteAccount_0900 start===="); + try{ + await appAccountManager.deleteAccount(bigStr); + } + catch(err){ + console.debug("====>delete account ActsAccountDeleteAccount_0900 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountDeleteAccount_0900 end===="); + done(); + } + }) + + /* + * @tc.number : ActsAccountDeleteAccount_1000 + * @tc.name : Delete account promise form + * @tc.desc : Delete the account name is an empty string + */ + it('ActsAccountDeleteAccount_1000', 0, async function (done){ + console.debug("====>ActsAccountDeleteAccount_1000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>delete Account ActsAccountDeleteAccount_1000 start===="); + try{ + await appAccountManager.deleteAccount(""); + } + catch(err){ + console.debug("====>delete account ActsAccountDeleteAccount_1000 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountDeleteAccount_1000 end===="); + done(); + } + }) +}) diff --git a/account/appaccount/actsaccounttest/entry/src/main/js/test/ExtraInfo.test.js b/account/appaccount/actsaccounttest/entry/src/main/js/test/ExtraInfo.test.js new file mode 100755 index 0000000000000000000000000000000000000000..ee3d581d8c4ff162dabf448665a22a51b1513274 --- /dev/null +++ b/account/appaccount/actsaccounttest/entry/src/main/js/test/ExtraInfo.test.js @@ -0,0 +1,506 @@ +/* + * 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + +const TIMEOUT = 10000; +describe('ActsAccountSetGetExtraInfo', function () { + function sleep(delay) { + var start = (new Date()).getTime(); + while((new Date()).getTime() - start < delay) { + continue; + } + } + + beforeAll(async function (done) { + console.debug("====>beforeAll start===="); + sleep(TIMEOUT); + console.debug("====>beforeAll end===="); + done(); + }); + + /* + * @tc.number : ActsAccountSetGetExtraInfo_0100 + * @tc.name : getAccountExtraInfo callback form + * @tc.desc : Get additional information about an existing account + */ + it('ActsAccountSetGetExtraInfo_0100', 0, async function (done) { + console.debug("====>ActsAccountSetGetExtraInfo_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + var extraInfoStr = "account_extrainfo_callback_first"; + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_callback_first", extraInfoStr, (err)=>{ + console.debug("====>add account ActsAccountSetGetExtraInfo_0100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAccountExtraInfo("account_name_callback_first", (err, data)=>{ + console.debug("====>getAccountExtraInfo 0100 err:" + JSON.stringify(err)); + console.debug("====>getAccountExtraInfo 0100 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data).assertEqual(extraInfoStr); + appAccountManager.deleteAccount("account_name_callback_first", (err)=>{ + console.debug("====>delete Account 0100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountSetGetExtraInfo_0100 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountSetGetExtraInfo_0200 + * @tc.name : getAccountExtraInfo promise form + * @tc.desc : Get additional information about an existing account + */ + it('ActsAccountSetGetExtraInfo_0200', 0, async function (done) { + console.debug("====>ActsAccountSetGetExtraInfo_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + var extraInfoStr = "account_extrainfo_promise_first"; + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountSetGetExtraInfo_0200 start===="); + await appAccountManager.addAccount("account_name_promise_first", extraInfoStr); + try{ + var data = await appAccountManager.getAccountExtraInfo("account_name_promise_first"); + } + catch(err){ + console.error("====>getAccountExtraInfo 0200 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAccountExtraInfo 0200 data:" + JSON.stringify(data)); + expect(data).assertEqual(extraInfoStr); + console.debug("====>delete account ActsAccountSetGetExtraInfo_0200 start===="); + await appAccountManager.deleteAccount("account_name_promise_first"); + console.debug("====>ActsAccountSetGetExtraInfo_0200 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountSetGetExtraInfo_0300 + * @tc.name : getAccountExtraInfo callback form + * @tc.desc : Get additional information about a non-existent account + */ + it('ActsAccountSetGetExtraInfo_0300', 0, async function (done) { + console.debug("====>ActsAccountSetGetExtraInfo_0300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var notExistBundle = "account_name_callback_notexistbundle_second"; + appAccountManager.getAccountExtraInfo(notExistBundle, (err, data)=>{ + console.debug("====>getAccountExtraInfo 0300 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountSetGetExtraInfo_0300 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsAccountSetGetExtraInfo_0400 + * @tc.name : getAccountExtraInfo promise form + * @tc.desc : Get additional information about a non-existent account + */ + it('ActsAccountSetGetExtraInfo_0400', 0, async function (done) { + console.debug("====>ActsAccountSetGetExtraInfo_0400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var notExistBundle = "account_name_promise_notexistbundle_second"; + try{ + await appAccountManager.getAccountExtraInfo(notExistBundle); + console.error("====>getAccountExtraInfo 0400 fail===="); + expect().assertFail(); + done(); + } + catch(err){ + console.debug("====>getAccountExtraInfo 0400 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountSetGetExtraInfo_0400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountSetGetExtraInfo_0500 + * @tc.name : getAccountExtraInfo callback form + * @tc.desc : Get additional information about deleted account + */ + it('ActsAccountSetGetExtraInfo_0500', 0, async function (done) { + console.debug("====>ActsAccountSetGetExtraInfo_0500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_callback_third", "account_extrainfo_callback_third", (err)=>{ + console.debug("====>add account ActsAccountSetGetExtraInfo_0500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount("account_name_callback_third", (err)=>{ + console.debug("====>delete Account 0500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAccountExtraInfo("account_name_callback_third", (err, data)=>{ + console.debug("====>getAccountExtraInfo 0500 err:" + JSON.stringify(err)); + console.debug("====>getAccountExtraInfo 0500 data:" + JSON.stringify(data)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountSetGetExtraInfo_0500 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountSetGetExtraInfo_0600 + * @tc.name : getAccountExtraInfo promise form + * @tc.desc : Get additional information about deleted account + */ + it('ActsAccountSetGetExtraInfo_0600', 0, async function (done) { + console.debug("====>ActsAccountSetGetExtraInfo_0600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountSetGetExtraInfo_0600 start===="); + await appAccountManager.addAccount("account_name_promise_third", "account_extrainfo_promise_third"); + console.debug("====>delete account ActsAccountSetGetExtraInfo_0600 start===="); + await appAccountManager.deleteAccount("account_name_promise_third"); + try{ + await appAccountManager.getAccountExtraInfo("account_name_promise_third"); + console.error("====>getAccountExtraInfo 0600 fail===="); + expect().assertFail(); + done(); + } + catch(err){ + console.debug("====>getAccountExtraInfo 0600 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountSetGetExtraInfo_0600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountSetGetExtraInfo_0700 + * @tc.name : getAccountExtraInfo callback form + * @tc.desc : Get additional information that is not set + */ + it('ActsAccountSetGetExtraInfo_0700', 0, async function (done) { + console.debug("====>ActsAccountSetGetExtraInfo_0700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_callback_fourth", (err)=>{ + console.debug("====>add account ActsAccountSetGetExtraInfo_0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAccountExtraInfo("account_name_callback_fourth", (err, data)=>{ + console.debug("====>getAccountExtraInfo 0700 err:" + JSON.stringify(err)); + console.debug("====>getAccountExtraInfo 0700 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data).assertEqual(""); + appAccountManager.deleteAccount("account_name_callback_fourth", (err)=>{ + console.debug("====>delete Account 0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountSetGetExtraInfo_0700 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountSetGetExtraInfo_0800 + * @tc.name : getAccountExtraInfo promise form + * @tc.desc : Get additional information that is not set + */ + it('ActsAccountSetGetExtraInfo_0800', 0, async function (done) { + console.debug("====>ActsAccountSetGetExtraInfo_0800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountSetGetExtraInfo_0800 start===="); + await appAccountManager.addAccount("account_name_promise_fourth"); + console.debug("====>getAccountExtraInfo ActsAccountSetGetExtraInfo_0800 start===="); + try{ + var data = await appAccountManager.getAccountExtraInfo("account_name_promise_fourth"); + } + catch(err){ + console.error("====>getAccountExtraInfo 0800 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAccountExtraInfo 0800 data:" + JSON.stringify(data)); + expect(data).assertEqual(""); + console.debug("====>delete account ActsAccountSetGetExtraInfo_0800 start===="); + await appAccountManager.deleteAccount("account_name_promise_fourth"); + console.debug("====>ActsAccountSetGetExtraInfo_0800 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountSetGetExtraInfo_0900 + * @tc.name : setAccountExtraInfo callback form + * @tc.desc : Set account extension information that does not exist + */ + it('ActsAccountSetGetExtraInfo_0900', 0, async function (done) { + console.debug("====>ActsAccountSetGetExtraInfo_0900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var notExtraAccount = "account_name_callback_fifth" + appAccountManager.setAccountExtraInfo(notExtraAccount, "account_extrainfo_fifth", (err)=>{ + console.debug("====>setAccountExtraInfo 0900 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountSetGetExtraInfo_0900 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsAccountSetGetExtraInfo_1000 + * @tc.name : setAccountExtraInfo promise form + * @tc.desc : Set account extension information that does not exist + */ + it('ActsAccountSetGetExtraInfo_1000', 0, async function (done) { + console.debug("====>ActsAccountSetGetExtraInfo_1000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var notExtraAccount = "account_name_promise_fifth" + try{ + await appAccountManager.setAccountExtraInfo(notExtraAccount, "account_extrainfo_fifth"); + console.error("====>setAccountExtraInfo fail ActsAccountSetGetExtraInfo_1000"); + expect().assertFail(); + done(); + } + catch(err){ + console.debug("====>setAccountExtraInfo 1000 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountSetGetExtraInfo_1000 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountSetGetExtraInfo_1100 + * @tc.name : setAccountExtraInfo getAccountExtraInfo callback form + * @tc.desc : Get additional information that has been set + */ + it('ActsAccountSetGetExtraInfo_1100', 0, async function (done) { + console.debug("====>ActsAccountSetGetExtraInfo_1100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_callback_sixth", "account_extrainfo_callback_sixth",(err)=>{ + console.debug("====>add account ActsAccountSetGetExtraInfo_1100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAccountExtraInfo("account_name_callback_sixth", "account_extra_sixth_twice", (err)=>{ + console.debug("====>setAccountExtraInfo 1100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAccountExtraInfo("account_name_callback_sixth", (err, data)=>{ + console.debug("====>getAccountExtraInfo 1100 err:" + JSON.stringify(err)); + console.debug("====>getAccountExtraInfo 1100 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data).assertEqual("account_extra_sixth_twice"); + appAccountManager.deleteAccount("account_name_callback_sixth", (err)=>{ + console.debug("====>delete Account 1100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountSetGetExtraInfo_1100 end===="); + done(); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountSetGetExtraInfo_1200 + * @tc.name : setAccountExtraInfo getAccountExtraInfo promise form + * @tc.desc : Get additional information that has been set + */ + it('ActsAccountSetGetExtraInfo_1200', 0, async function (done) { + console.debug("====>ActsAccountSetGetExtraInfo_1200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountSetGetExtraInfo_1200 start===="); + await appAccountManager.addAccount("account_name_promise_sixth", "account_extra_promise_sixth"); + console.debug("====>setAccountExtraInfo ActsAccountSetGetExtraInfo_1200 start===="); + await appAccountManager.setAccountExtraInfo("account_name_promise_sixth", "account_extra_sixth_twice"); + try{ + var data = await appAccountManager.getAccountExtraInfo("account_name_promise_sixth") + } + catch(err){ + console.error("====>getAccountExtraInfo 1200 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAccountExtraInfo 1200 data:" + JSON.stringify(data)); + expect(data).assertEqual("account_extra_sixth_twice"); + console.debug("====>delete account ActsAccountSetGetExtraInfo_1200 start===="); + await appAccountManager.deleteAccount("account_name_promise_sixth"); + console.debug("====>ActsAccountSetGetExtraInfo_1200 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountSetGetExtraInfo_1300 + * @tc.name : setAccountExtraInfo getAccountExtraInfo callback form + * @tc.desc : Get repeated setting of different additional information + */ + it('ActsAccountSetGetExtraInfo_1300', 0, async function (done) { + console.debug("====>ActsAccountSetGetExtraInfo_1300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_callback_seventh",(err)=>{ + console.debug("====>add account ActsAccountSetGetExtraInfo_1300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAccountExtraInfo("account_name_callback_seventh", "callback_seventh", (err)=>{ + console.debug("====>setAccountExtraInfo 1300 first time err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAccountExtraInfo("account_name_callback_seventh", "call_seventh_twice", (err)=>{ + console.debug("====>setAccountExtraInfo 1300 second time err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAccountExtraInfo("account_name_callback_seventh", (err, data)=>{ + console.debug("====>getAccountExtraInfo 1300 err:" + JSON.stringify(err)); + console.debug("====>getAccountExtraInfo 1300 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data).assertEqual("call_seventh_twice"); + appAccountManager.deleteAccount("account_name_callback_seventh", (err)=>{ + console.debug("====>delete Account 1300 err:" + JSON.stringify(err)); + }); + console.debug("====>ActsAccountSetGetExtraInfo_1300 end===="); + done(); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountSetGetExtraInfo_1400 + * @tc.name : setAccountExtraInfo getAccountExtraInfo promise form + * @tc.desc : Get repeated setting of different additional information + */ + it('ActsAccountSetGetExtraInfo_1400', 0, async function (done) { + console.debug("====>ActsAccountSetGetExtraInfo_1400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account start ActsAccountSetGetExtraInfo_1400 start===="); + await appAccountManager.addAccount("extrapromise_seventh"); + console.debug("====>setAccountExtraInfo first time ActsAccountSetGetExtraInfo_1400===="); + await appAccountManager.setAccountExtraInfo("extrapromise_seventh", "extra_promise_seventh"); + try{ + var data = await appAccountManager.getAccountExtraInfo("extrapromise_seventh"); + } + catch(err){ + console.error("====>getAccountExtraInfo first time 1400 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAccountExtraInfo 1400 first time data:" + JSON.stringify(data)); + expect(data).assertEqual("extra_promise_seventh"); + console.debug("====>setAccountExtraInfo second time ActsAccountSetGetExtraInfo_1400===="); + await appAccountManager.setAccountExtraInfo("extrapromise_seventh", "extra_promise_seventh_twice"); + try{ + var data = await appAccountManager.getAccountExtraInfo("extrapromise_seventh"); + } + catch(err){ + console.error("====>getAccountExtraInfo 1400 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAccountExtraInfo 1400 data:" + JSON.stringify(data)); + expect(data).assertEqual("extra_promise_seventh_twice"); + console.debug("====>delete account ActsAccountSetGetExtraInfo_1400 start===="); + await appAccountManager.deleteAccount("extrapromise_seventh"); + console.debug("====>ActsAccountSetGetExtraInfo_1400 end===="); + done(); + }); + + + /* + * @tc.number : ActsAccountSetGetExtraInfo_1500 + * @tc.name : setAccountExtraInfo getAccountExtraInfo callback form + * @tc.desc : Get repeated setting of same additional information + */ + it('ActsAccountSetGetExtraInfo_1500', 0, async function (done) { + console.debug("====>ActsAccountSetGetExtraInfo_1500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_name_callback_eighth",(err)=>{ + console.debug("====>add account ActsAccountSetGetExtraInfo_1500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAccountExtraInfo("account_name_callback_eighth", "extra_callback_eighth", (err)=>{ + console.debug("====>setAccountExtraInfo second time err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAccountExtraInfo("account_name_callback_eighth", "extra_callback_eighth", (err)=>{ + console.debug("====>setAccountExtraInfo 1500 first time err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAccountExtraInfo("account_name_callback_eighth", (err, data)=>{ + console.debug("====>getAccountExtraInfo 1500 err:" + JSON.stringify(err)); + console.debug("====>getAccountExtraInfo 1500 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data).assertEqual("extra_callback_eighth"); + appAccountManager.deleteAccount("account_name_callback_eighth", (err)=>{ + console.debug("====>delete Account 1500 err:" + JSON.stringify(err)); + }); + console.debug("====>ActsAccountSetGetExtraInfo_1500 end===="); + done(); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountSetGetExtraInfo_1600 + * @tc.name : setAccountExtraInfo getAccountExtraInfo promise form + * @tc.desc : Get repeated setting of same additional information + */ + it('ActsAccountSetGetExtraInfo_1600', 0, async function (done) { + console.debug("====>ActsAccountSetGetExtraInfo_1600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountSetGetExtraInfo_1600===="); + await appAccountManager.addAccount("account_name_promise_eighth"); + console.debug("====>setAccountExtraInfo first time start ActsAccountSetGetExtraInfo_1600===="); + try{ + await appAccountManager.setAccountExtraInfo("account_name_promise_eighth", "extra_promise_eighth"); + } + catch(err){ + console.error("====>setAccountExtraInfo first time err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + var dataFir = await appAccountManager.getAccountExtraInfo("account_name_promise_eighth"); + } + catch(err){ + console.error("====>getAccountExtraInfo first time 1600 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAccountExtraInfo first time 1600 dataFir:" + JSON.stringify(dataFir)); + expect(dataFir).assertEqual("extra_promise_eighth"); + console.debug("====>setAccountExtraInfo second time start ActsAccountSetGetExtraInfo_1600===="); + try{ + await appAccountManager.setAccountExtraInfo("account_name_promise_eighth", "extra_promise_eighth"); + } + catch(err){ + console.error("====>setAccountExtraInfo second time err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + try{ + var dataSec = await appAccountManager.getAccountExtraInfo("account_name_promise_eighth"); + } + catch(err){ + console.error("====>getAccountExtraInfo second time 1600 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAccountExtraInfo second time 1600 dataSec:" + JSON.stringify(dataSec)); + expect(dataSec).assertEqual("extra_promise_eighth"); + console.debug("====>delete account ActsAccountSetGetExtraInfo_1600 start===="); + await appAccountManager.deleteAccount("account_name_promise_eighth"); + console.debug("====>ActsAccountSetGetExtraInfo_1600 end===="); + done(); + }); +}) \ No newline at end of file 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 new file mode 100755 index 0000000000000000000000000000000000000000..2f16c5ad7d8bfd35838247ee411fb92b36d7d66f --- /dev/null +++ b/account/appaccount/actsaccounttest/entry/src/main/js/test/List.test.js @@ -0,0 +1,23 @@ +/* + * 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('./AddAccount.test.js') +require('./DeleteAccount.test.js') +require('./AppAccess.test.js') +require('./ExtraInfo.test.js') +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 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 new file mode 100755 index 0000000000000000000000000000000000000000..8053a94f108b88062e22bd2cc90015c7dc418d53 --- /dev/null +++ b/account/appaccount/actsaccounttest/entry/src/main/js/test/NoPermission.test.js @@ -0,0 +1,233 @@ +/* + * 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + +const TIMEOUT = 10000; +const ERR_APPACCOUNT_SERVICE_PERMISSION_DENIED = 4521990; +describe('ActsAccountNoPermission', function () { + function sleep(delay) { + var start = (new Date()).getTime(); + while((new Date()).getTime() - start < delay) { + continue; + } + } + + beforeAll(async function (done) { + console.debug("====>beforeAll start===="); + sleep(TIMEOUT); + console.debug("====>beforeAll end===="); + done(); + }); + + /* + * @tc.number : ActsAccountNoPermission_0100 + * @tc.name : setAppAccountSyncEnable callback + * @tc.desc : Set the added account to allow synchronization without permission + */ + it('ActsAccountNoPermission_0100', 0, async function (done) { + console.debug("====>ActsAccountNoPermission_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("syncenable_callback_setnopermission", (err)=>{ + console.debug("====>add account ActsAccountNoPermission_0100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAppAccountSyncEnable("syncenable_callback_setnopermission", true, (err)=>{ + console.debug("====>setAppAccountSyncEnable 0100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_APPACCOUNT_SERVICE_PERMISSION_DENIED); + appAccountManager.deleteAccount("syncenable_callback_setnopermission", (err)=>{ + console.debug("====>delete Account ActsAccountNoPermission_0100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountNoPermission_0100 end===="); + done(); + }); + }) + }); + }); + + /* + * @tc.number : ActsAccountNoPermission_0200 + * @tc.name : setAppAccountSyncEnable promise + * @tc.desc : Set the added account to allow synchronization without permission + */ + it('ActsAccountNoPermission_0200', 0, async function (done) { + console.debug("====>ActsAccountNoPermission_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountNoPermission_0200 start===="); + await appAccountManager.addAccount("syncenable_promise_setnopermission"); + console.debug("====>setAppAccountSyncEnable ActsAccountNoPermission_0200 start===="); + try{ + await appAccountManager.setAppAccountSyncEnable("syncenable_promise_setnopermission", true); + } + catch(err){ + console.debug("====>setAppAccountSyncEnable 0200 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_APPACCOUNT_SERVICE_PERMISSION_DENIED); + console.debug("====>delete account ActsAccountNoPermission_0200 start===="); + await appAccountManager.deleteAccount("syncenable_promise_setnopermission"); + console.debug("====>ActsAccountNoPermission_0200 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountNoPermission_0300 + * @tc.name : Check sync flag callback form + * @tc.desc : Check the added account synchronization without permission + */ + it('ActsAccountNoPermission_0300', 0, async function (done) { + console.debug("====>ActsAccountNoPermission_0300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("syncenable_callback_checknopermission", (err)=>{ + console.debug("====>add account ActsAccountNoPermission_0300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.checkAppAccountSyncEnable("syncenable_callback_checknopermission", (err, data)=>{ + console.debug("====>checkAppAccountSyncEnable 0300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_APPACCOUNT_SERVICE_PERMISSION_DENIED); + appAccountManager.deleteAccount("syncenable_callback_checknopermission", (err)=>{ + console.debug("====>delete Account ActsAccountNoPermission_0300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountNoPermission_0300 end===="); + done(); + }); + }) + }); + }); + + /* + * @tc.number : ActsAccountNoPermission_0400 + * @tc.name : Check sync flag promise form + * @tc.desc : Check the added account synchronization without permission + */ + it('ActsAccountNoPermission_0400', 0, async function (done) { + console.debug("====>ActsAccountNoPermission_0400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountNoPermission_0400 start===="); + await appAccountManager.addAccount("syncenable_promise_checknopermission"); + console.debug("====>checkAppAccountSyncEnable ActsAccountNoPermission_0400 start===="); + try{ + var data = await appAccountManager.checkAppAccountSyncEnable("syncenable_promise_checknopermission"); + } + catch(err){ + console.debug("====>checkAppAccountSyncEnable 0400 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_APPACCOUNT_SERVICE_PERMISSION_DENIED); + await appAccountManager.deleteAccount("syncenable_promise_checknopermission"); + console.debug("====>ActsAccountNoPermission_0400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountNoPermission_0500 + * @tc.name : getAllAccessibleAccounts callback + * @tc.desc : This application gets authorization after adding a single account without permission + */ + it('ActsAccountNoPermission_0500', 0, async function (done) { + console.debug("====>ActsAccountNoPermission_0500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("accessibleAccount_callback_nopermission", (err)=>{ + console.debug("====> add account ActsAccountNoPermission_0500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAllAccessibleAccounts((err, data)=>{ + console.debug("====>getAllAccessibleAccounts 0500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_APPACCOUNT_SERVICE_PERMISSION_DENIED); + appAccountManager.deleteAccount("accessibleAccount_callback_nopermission", (err)=>{ + console.debug("====>delete Account ActsAccountNoPermission_0500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountNoPermission_0500 end===="); + done(); + }) + }); + }); + }); + + /* + * @tc.number : ActsAccountNoPermission_0600 + * @tc.name : getAllAccessibleAccounts promise + * @tc.desc : This application gets authorization after adding a single account without permission + */ + it('ActsAccountNoPermission_0600', 0, async function (done) { + console.debug("====>ActsAccountNoPermission_0600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountNoPermission_0600 start===="); + await appAccountManager.addAccount("accessibleAccount_promise_nopermission"); + console.debug("====>getAllAccessibleAccounts 0600 start===="); + try{ + var data = await appAccountManager.getAllAccessibleAccounts(); + } + catch(err){ + console.debug("====>getAllAccessibleAccounts 0600 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_APPACCOUNT_SERVICE_PERMISSION_DENIED); + await appAccountManager.deleteAccount("accessibleAccount_promise_nopermission"); + console.debug("====>ActsAccountNoPermission_0600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountNoPermission_0700 + * @tc.name : getAllAccounts callback + * @tc.desc : This application gets its own application information after adding an account without permission + */ + it('ActsAccountNoPermission_0700', 0, async function (done) { + console.debug("====>ActsAccountNoPermission_0700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var selfBundle = "com.example.actsaccountnopermission"; + appAccountManager.addAccount("getAll_callback_nopermission", (err)=>{ + console.debug("====>add account 0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAllAccounts(selfBundle, (err, data)=>{ + console.debug("====>getAllAccounts 0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_APPACCOUNT_SERVICE_PERMISSION_DENIED); + appAccountManager.deleteAccount("getAll_callback_nopermission", (err)=>{ + console.debug("====>delete account 0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountNoPermission_0700 end===="); + done(); + }); + }) + }); + }); + + /* + * @tc.number : ActsAccountNoPermission_0800 + * @tc.name : getAllAccounts promise + * @tc.desc : This application gets its own application information after adding an account without permission + */ + it('ActsAccountNoPermission_0800', 0, async function (done) { + console.debug("====>ActsAccountNoPermission_0800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var selfBundle = "com.example.actsaccountnopermission"; + console.debug("====>add account 0800 start===="); + await appAccountManager.addAccount("getAll_promise_nopermission"); + console.debug("====>getAllAccounts 0800 start===="); + try{ + var data = await appAccountManager.getAllAccounts(selfBundle); + } + catch(err){ + console.error("====>getAllAccounts 0800 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_APPACCOUNT_SERVICE_PERMISSION_DENIED); + await appAccountManager.deleteAccount("getAll_promise_nopermission"); + console.debug("====>ActsAccountNoPermission_0800 end===="); + done(); + } + }); +}) \ No newline at end of file diff --git a/account/appaccount/actsaccounttest/entry/src/main/js/test/OAuthToken.test.js b/account/appaccount/actsaccounttest/entry/src/main/js/test/OAuthToken.test.js new file mode 100755 index 0000000000000000000000000000000000000000..649995589966301df2fec649209c8aebd5486217 --- /dev/null +++ b/account/appaccount/actsaccounttest/entry/src/main/js/test/OAuthToken.test.js @@ -0,0 +1,562 @@ +/* + * 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + +const TIMEOUT = 10000; +describe('ActsAccountOAuthToken', function () { + function sleep(delay) { + var start = (new Date()).getTime(); + while((new Date()).getTime() - start < delay) { + continue; + } + } + + beforeAll(async function (done) { + console.debug("====>beforeAll start===="); + sleep(TIMEOUT); + console.debug("====>beforeAll end===="); + done(); + }); + + /* + * @tc.number : ActsAccountOAuthToken_0100 + * @tc.name : Test oauth token in callback form + * @tc.desc : Clear the oauth token after obtaining the oauth token that has been set by the application + * account + */ + it('ActsAccountOAuthToken_0100', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("accountToken_callback_normal", (err)=>{ + console.debug("====>add account ActsAccountOAuthToken_0100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("accountToken_callback_normal", "token_callback_normal", (err)=>{ + console.debug("====>setOAuthToken ActsAccountOAuthToken_0100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("accountToken_callback_normal", (err, data)=>{ + console.debug("====>getOAuthToken 0100 err:" + JSON.stringify(err)); + console.debug("====>getOAuthToken 0100 data:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual("token_callback_normal"); + appAccountManager.clearOAuthToken("accountToken_callback_normal", (err)=>{ + console.debug("====>clearOAuthToken 0100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount("accountToken_callback_normal", (err)=>{ + console.debug("====>delete Account ActsAccountOAuthToken_0100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_0100 end===="); + done(); + }); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountOAuthToken_0200 + * @tc.name : Test oauth token in promise form + * @tc.desc : Clear the oauth token after obtaining the oauth token that has been set by the application + * account + */ + it('ActsAccountOAuthToken_0200', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountOAuthToken_0200 start===="); + await appAccountManager.addAccount("accountToken_promise_normal"); + console.debug("====>setOAuthToken ActsAccountOAuthToken_0200 start===="); + await appAccountManager.setOAuthToken("accountToken_promise_normal", "token_promise_normal"); + console.debug("====>getOAuthToken ActsAccountOAuthToken_0200 start===="); + var data = await appAccountManager.getOAuthToken("accountToken_promise_normal"); + console.debug("====>getOAuthToken 0200 data:" + data); + expect(data).assertEqual("token_promise_normal"); + console.debug("====>clearOAuthToken ActsAccountOAuthToken_0200 start===="); + await appAccountManager.clearOAuthToken("accountToken_promise_normal"); + await appAccountManager.deleteAccount("accountToken_promise_normal"); + console.debug("====>ActsAccountOAuthToken_0200 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountOAuthToken_0300 + * @tc.name : Test oauth token in callback form + * @tc.desc : Get the oauth token of the unset oauth token application account + */ + it('ActsAccountOAuthToken_0300', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_0300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("accountToken_callback_noset", (err)=>{ + console.debug("====>add account ActsAccountOAuthToken_0300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("accountToken_callback_noset", (err, data)=>{ + console.debug("====>getOAuthToken 0300 err:" + JSON.stringify(err)); + console.debug("====>getOAuthToken 0300 data:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual(""); + appAccountManager.deleteAccount("accountToken_callback_noset", (err)=>{ + console.debug("====>delete Account ActsAccountOAuthToken_0300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_0300 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountOAuthToken_0400 + * @tc.name : Test oauth token in promise form + * @tc.desc : Get the oauth token of the unset oauth token application account + */ + it('ActsAccountOAuthToken_0400', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_0400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountOAuthToken_0400 start===="); + await appAccountManager.addAccount("accountToken_promise_noset"); + console.debug("====>getOAuthToken ActsAccountOAuthToken_0400 start===="); + var data = await appAccountManager.getOAuthToken("accountToken_promise_noset"); + console.debug("====>getOAuthToken ActsAccountOAuthToken_0400 data:" + data); + expect(data).assertEqual(""); + await appAccountManager.deleteAccount("accountToken_promise_noset"); + console.debug("====>ActsAccountOAuthToken_0400 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountOAuthToken_0500 + * @tc.name : Test oauth token in callback form + * @tc.desc : Obtain the oauth token of the unadded application account + */ + it('ActsAccountOAuthToken_0500', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_0500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>getOAuthToken ActsAccountOAuthToken_0500 start===="); + appAccountManager.getOAuthToken("accountToken_callback_noadd", (err, data)=>{ + console.debug("====>getOAuthToken 0500 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_0500 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsAccountOAuthToken_0600 + * @tc.name : Test oauth token in promise form + * @tc.desc : Obtain the oauth token of the unadded application account + */ + it('ActsAccountOAuthToken_0600', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_0600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>getOAuthToken ActsAccountOAuthToken_0600 start===="); + try{ + var data = await appAccountManager.getOAuthToken("accountToken_promise_noadd"); + } + catch(err){ + console.debug("====>getOAuthToken 0600 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_0600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountOAuthToken_0700 + * @tc.name : Test oauth token in callback form + * @tc.desc : Get repeated settings of the same oauth token for the same account + */ + it('ActsAccountOAuthToken_0700', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_0700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("accountToken_callback_setsame", (err)=>{ + console.debug("====>add account ActsAccountOAuthToken_0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("accountToken_callback_setsame", "tokenCallback_setsame", (err)=>{ + console.debug("====>setOAuthToken first 0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("accountToken_callback_setsame", "tokenCallback_setsame", (err)=>{ + console.debug("====>setOAuthToken second 0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("accountToken_callback_setsame", (err, data)=>{ + console.debug("====>getOAuthToken 0700 err:" + JSON.stringify(err)); + console.debug("====>getOAuthToken 0700 data:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual("tokenCallback_setsame"); + appAccountManager.deleteAccount("accountToken_callback_setsame", (err)=>{ + console.debug("====>delete Account ActsAccountOAuthToken_0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_0700 end===="); + done(); + }); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountOAuthToken_0800 + * @tc.name : Test oauth token in promise form + * @tc.desc : Get repeated settings of the same oauth token for the same account + */ + it('ActsAccountOAuthToken_0800', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_0800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountOAuthToken_0800 start===="); + await appAccountManager.addAccount("accountToken_promise_setsame"); + console.debug("====>setOAuthToken first 0800 start===="); + await appAccountManager.setOAuthToken("accountToken_promise_setsame", "tokenPromise_setsame"); + console.debug("====>setOAuthToken second 0800 start===="); + await appAccountManager.setOAuthToken("accountToken_promise_setsame", "tokenPromise_setsame"); + console.debug("====>getOAuthToken ActsAccountOAuthToken_0800 start===="); + var data = await appAccountManager.getOAuthToken("accountToken_promise_setsame"); + console.debug("====>getOAuthToken 0800 data:" + data); + expect(data).assertEqual("tokenPromise_setsame"); + console.debug("====>clearOAuthToken ActsAccountOAuthToken_0800 start===="); + await appAccountManager.clearOAuthToken("accountToken_promise_setsame"); + console.debug("====>deleteAccount ActsAccountOAuthToken_0800 start===="); + await appAccountManager.deleteAccount("accountToken_promise_setsame"); + console.debug("====>ActsAccountOAuthToken_0800 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountOAuthToken_0900 + * @tc.name : Test oauth token in callback form + * @tc.desc : Get repeated settings of different oauth tokens for the same account + */ + it('ActsAccountOAuthToken_0900', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_0900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("accountToken_callback_setdiff", (err)=>{ + console.debug("====>add account ActsAccountOAuthToken_0900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("accountToken_callback_setdiff", "callback_setdiff_fir", (err)=>{ + console.debug("====>setOAuthToken first 0900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("accountToken_callback_setdiff", "callback_setdiff_sec", (err)=>{ + console.debug("====>setOAuthToken second 0900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("accountToken_callback_setdiff", (err, data)=>{ + console.debug("====>getOAuthToken 0900 err:" + JSON.stringify(err)); + console.debug("====>getOAuthToken 0900 data:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual("callback_setdiff_sec"); + appAccountManager.deleteAccount("accountToken_callback_setdiff", (err)=>{ + console.debug("====>delete Account ActsAccountOAuthToken_0900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_0900 end===="); + done(); + }); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountOAuthToken_1000 + * @tc.name : Test oauth token in promise form + * @tc.desc : Get repeated settings of different oauth tokens for the same account + */ + it('ActsAccountOAuthToken_1000', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_1000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountOAuthToken_1000 start===="); + await appAccountManager.addAccount("accountToken_promise_setdiff"); + console.debug("====>setOAuthToken first 1000 start===="); + await appAccountManager.setOAuthToken("accountToken_promise_setdiff", "promise_setdiff_fir"); + console.debug("====>setOAuthToken second 1000 start===="); + await appAccountManager.setOAuthToken("accountToken_promise_setdiff", "promise_setdiff_sec"); + console.debug("====>getOAuthToken ActsAccountOAuthToken_1000 start===="); + var data = await appAccountManager.getOAuthToken("accountToken_promise_setdiff"); + console.debug("====>getOAuthToken 1000 data:" + data); + expect(data).assertEqual("promise_setdiff_sec"); + console.debug("====>clearOAuthToken ActsAccountOAuthToken_1000 start===="); + await appAccountManager.clearOAuthToken("accountToken_promise_setdiff"); + await appAccountManager.deleteAccount("accountToken_promise_setdiff"); + console.debug("====>ActsAccountOAuthToken_1000 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountOAuthToken_1100 + * @tc.name : Test oauth token in callback form + * @tc.desc : Obtain the oauth token after clearing the oauth token that has been set + */ + it('ActsAccountOAuthToken_1100', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_1100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("accountToken_callback_setclear", (err)=>{ + console.debug("====>add account ActsAccountOAuthToken_1100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("accountToken_callback_setclear", "callback_setclear_token", (err)=>{ + console.debug("====>setOAuthToken 1100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.clearOAuthToken("accountToken_callback_setclear", (err)=>{ + console.debug("====>clearOAuthToken 1100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("accountToken_callback_setclear", (err, data)=>{ + console.debug("====>getOAuthToken 1100 err:" + JSON.stringify(err)); + console.debug("====>getOAuthToken 1100 data:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual(""); + appAccountManager.deleteAccount("accountToken_callback_setclear", (err)=>{ + console.debug("====>delete Account ActsAccountOAuthToken_1100 err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_1100 end===="); + done(); + }); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountOAuthToken_1200 + * @tc.name : Test oauth token in promise form + * @tc.desc : Obtain the oauth token after clearing the oauth token that has been set + */ + it('ActsAccountOAuthToken_1200', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_1200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountOAuthToken_1200 start===="); + await appAccountManager.addAccount("accountToken_promise_setclear"); + console.debug("====>setOAuthToken 1200 start===="); + await appAccountManager.setOAuthToken("accountToken_promise_setclear", "promise_setclear_token"); + console.debug("====>clearOAuthToken 1200 start===="); + await appAccountManager.clearOAuthToken("accountToken_promise_setclear"); + console.debug("====>getOAuthToken ActsAccountOAuthToken_1200 start===="); + var data = await appAccountManager.getOAuthToken("accountToken_promise_setclear"); + console.debug("====>getOAuthToken 1200 data:" + data); + expect(data).assertEqual(""); + await appAccountManager.deleteAccount("accountToken_promise_setclear"); + console.debug("====>ActsAccountOAuthToken_1200 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountOAuthToken_1300 + * @tc.name : Test oauth token in callback form + * @tc.desc : Set the oauth token of the unadded application account + */ + it('ActsAccountOAuthToken_1300', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_1300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var accountNotExist = "accountToken_callback_notExist"; + appAccountManager.setOAuthToken(accountNotExist, "account_notExist_token", (err)=>{ + console.debug("====>setOAuthToken 1300 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_1300 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsAccountOAuthToken_1400 + * @tc.name : Test oauth token in promise form + * @tc.desc : Set the oauth token of the unadded application account + */ + it('ActsAccountOAuthToken_1400', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_1400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var accountNotExist = "accountToken_promise_notExist" + console.debug("====>setOAuthToken 1400 start===="); + try{ + await appAccountManager.setOAuthToken(accountNotExist, "account_notExist_token"); + } + catch(err){ + console.debug("====>setOAuthToken 1400 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_1400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountOAuthToken_1500 + * @tc.name : Test oauth token in callback form + * @tc.desc : Clear the oauthtoken of the unadded application account + */ + it('ActsAccountOAuthToken_1500', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_1500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var accountNotExist = "accountToken_callback_notExist"; + appAccountManager.clearOAuthToken(accountNotExist, (err)=>{ + console.debug("====>clearOAuthToken 1500 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_1500 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsAccountOAuthToken_1600 + * @tc.name : Test oauth token in promise form + * @tc.desc : Clear the oauthtoken of the unadded application account + */ + it('ActsAccountOAuthToken_1600', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_1600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var accountNotExist = "accountToken_promise_notExist" + console.debug("====>clearOAuthToken 1600 start===="); + try{ + await appAccountManager.clearOAuthToken(accountNotExist); + } + catch(err){ + console.debug("====>clearOAuthToken 1600 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_1600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountOAuthToken_1700 + * @tc.name : Test oauth token in callback form + * @tc.desc : Obtain the oauth token after clearing the unset oauth token + */ + it('ActsAccountOAuthToken_1700', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_1700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("accountToken_callback_clearget", (err)=>{ + console.debug("====>add account ActsAccountOAuthToken_1700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.clearOAuthToken("accountToken_callback_clearget", (err)=>{ + console.debug("====>clearOAuthToken 1700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("accountToken_callback_clearget", (err)=>{ + console.debug("====>getOAuthToken 1700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount("accountToken_callback_clearget", (err)=>{ + console.debug("====>delete Account ActsAccountOAuthToken_1700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_1700 end===="); + done(); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountOAuthToken_1800 + * @tc.name : Test oauth token in promise form + * @tc.desc : Obtain the oauth token after clearing the unset oauth token + */ + it('ActsAccountOAuthToken_1800', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_1200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountOAuthToken_1800 start===="); + await appAccountManager.addAccount("accountToken_promise_clearget"); + console.debug("====>clearOAuthToken 1800 start===="); + await appAccountManager.clearOAuthToken("accountToken_promise_clearget"); + console.debug("====>getOAuthToken ActsAccountOAuthToken_1800 start===="); + var data = await appAccountManager.getOAuthToken("accountToken_promise_clearget"); + console.debug("====>getOAuthToken 1800 dataGet:" + data); + expect(data).assertEqual(""); + await appAccountManager.deleteAccount("accountToken_promise_clearget"); + console.debug("====>ActsAccountOAuthToken_1800 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountOAuthToken_1900 + * @tc.name : Test oauth token in callback form + * @tc.desc : Repeatedly clear the oauth token that has been set for the same account + */ + it('ActsAccountOAuthToken_1900', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_1900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("account_callback_repeatClear", (err)=>{ + console.debug("====>add account ActsAccountOAuthToken_1900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_repeatClear", "callback_repeatClear", (err)=>{ + console.debug("====>setOAuthToken 1900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.clearOAuthToken("account_callback_repeatClear", (err)=>{ + console.debug("====>clearOAuthToken first 1900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_callback_repeatClear", (err, data)=>{ + console.debug("====>getOAuthToken first 1900 err:" + JSON.stringify(err)); + console.debug("====>getOAuthToken first 1900 data:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual(""); + appAccountManager.clearOAuthToken("account_callback_repeatClear", (err)=>{ + console.debug("====>clearOAuthToken second 1900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_callback_repeatClear", (err, data)=>{ + console.debug("====>getOAuthToken second 1900 err:" + JSON.stringify(err)); + console.debug("====>getOAuthToken second 1900 data:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual(""); + appAccountManager.deleteAccount("account_callback_repeatClear", (err)=>{ + console.debug("====>delete Account 1900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_1900 end===="); + done(); + }); + }); + }); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountOAuthToken_2000 + * @tc.name : Test oauth token in promise form + * @tc.desc : Repeatedly clear the oauth token that has been set for the same account + */ + it('ActsAccountOAuthToken_2000', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_2000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsAccountOAuthToken_2000 start===="); + await appAccountManager.addAccount("accountToken_promise_setclear"); + console.debug("====>setOAuthToken 2000 start===="); + await appAccountManager.setOAuthToken("accountToken_promise_setclear", "promise_setclear_token"); + console.debug("====>clearOAuthToken first 2000 start===="); + await appAccountManager.clearOAuthToken("accountToken_promise_setclear"); + console.debug("====>clearOAuthToken second 2000 start===="); + await appAccountManager.clearOAuthToken("accountToken_promise_setclear"); + console.debug("====>getOAuthToken ActsAccountOAuthToken_2000 start===="); + var dataGet = await appAccountManager.getOAuthToken("accountToken_promise_setclear"); + expect(dataGet).assertEqual(""); + await appAccountManager.deleteAccount("accountToken_promise_setclear"); + console.debug("====>ActsAccountOAuthToken_2000 end===="); + done(); + }); +}) \ No newline at end of file diff --git a/account/appaccount/actsaccounttest/signature/openharmony_sx.p7b b/account/appaccount/actsaccounttest/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/account/appaccount/actsaccounttest/signature/openharmony_sx.p7b differ diff --git a/account/appaccount/actsgetallaccounts/BUILD.gn b/account/appaccount/actsgetallaccounts/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..3e3769db475fdc35ddabe29d2389c5128ae7356b --- /dev/null +++ b/account/appaccount/actsgetallaccounts/BUILD.gn @@ -0,0 +1,31 @@ +# 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("ActsGetAllAccounts") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsGetAllAccounts" +} +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/actsgetallaccounts/Test.json b/account/appaccount/actsgetallaccounts/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..1d1e370755d901cd666c23d0f956eb48b2edc281 --- /dev/null +++ b/account/appaccount/actsgetallaccounts/Test.json @@ -0,0 +1,19 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "60000", + "package": "com.example.actsgetallaaccounts", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsGetAllAccounts.hap", + "ActsSceneGetAllAccounts.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/account/appaccount/actsgetallaccounts/entry/src/main/config.json b/account/appaccount/actsgetallaccounts/entry/src/main/config.json new file mode 100755 index 0000000000000000000000000000000000000000..99e9deba03e0aba0701e496554397e6ef3abc15b --- /dev/null +++ b/account/appaccount/actsgetallaccounts/entry/src/main/config.json @@ -0,0 +1,74 @@ +{ + "app": { + "bundleName": "com.example.actsgetallaaccounts", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsgetallaaccounts", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "defPermissions": [ + { + "availableScope": [], + "grantMode": "system_grant", + "name": "ohos.permission.GET_ACCOUNTS_PRIVILEGED" + } + ], + "reqPermissions": [ + { + "name": "ohos.permission.GET_ACCOUNTS_PRIVILEGED", + "reason": "ceshi" + } + ], + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.actsgetallaaccounts.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/actsgetallaccounts/entry/src/main/js/default/app.js b/account/appaccount/actsgetallaccounts/entry/src/main/js/default/app.js new file mode 100755 index 0000000000000000000000000000000000000000..2a68c1992145a976957d7dcdd69a7e9c2e8e9877 --- /dev/null +++ b/account/appaccount/actsgetallaccounts/entry/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* + * 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/actsgetallaccounts/entry/src/main/js/default/i18n/en-US.json b/account/appaccount/actsgetallaccounts/entry/src/main/js/default/i18n/en-US.json new file mode 100755 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/account/appaccount/actsgetallaccounts/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/account/appaccount/actsgetallaccounts/entry/src/main/js/default/i18n/zh-CN.json b/account/appaccount/actsgetallaccounts/entry/src/main/js/default/i18n/zh-CN.json new file mode 100755 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/account/appaccount/actsgetallaccounts/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/account/appaccount/actsgetallaccounts/entry/src/main/js/default/pages/index/index.css b/account/appaccount/actsgetallaccounts/entry/src/main/js/default/pages/index/index.css new file mode 100755 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/account/appaccount/actsgetallaccounts/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/account/appaccount/actsgetallaccounts/entry/src/main/js/default/pages/index/index.hml b/account/appaccount/actsgetallaccounts/entry/src/main/js/default/pages/index/index.hml new file mode 100755 index 0000000000000000000000000000000000000000..c45422b42d0bf788a1c2c0eb299a981f07ce8613 --- /dev/null +++ b/account/appaccount/actsgetallaccounts/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{title}} + +
diff --git a/account/appaccount/actsgetallaccounts/entry/src/main/js/default/pages/index/index.js b/account/appaccount/actsgetallaccounts/entry/src/main/js/default/pages/index/index.js new file mode 100755 index 0000000000000000000000000000000000000000..e709083bf731187e31680743e927d64c31d772c4 --- /dev/null +++ b/account/appaccount/actsgetallaccounts/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,45 @@ +/* + * 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: "测试getAllAccounts接口" + }, + onInit() { + this.title = "测试getAllAccounts接口"; + }, + 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/actsgetallaccounts/entry/src/main/js/resources/base/element/string.json b/account/appaccount/actsgetallaccounts/entry/src/main/js/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..b50238a04201f2c134fb640b84189e89bd2b75fa --- /dev/null +++ b/account/appaccount/actsgetallaccounts/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ActsGetAllAccounts" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/account/appaccount/actsgetallaccounts/entry/src/main/js/resources/base/media/icon.png b/account/appaccount/actsgetallaccounts/entry/src/main/js/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/account/appaccount/actsgetallaccounts/entry/src/main/js/resources/base/media/icon.png differ 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 new file mode 100755 index 0000000000000000000000000000000000000000..b42f3629cac3a9e541eee77c8aac24a1c7e39832 --- /dev/null +++ b/account/appaccount/actsgetallaccounts/entry/src/main/js/test/ExampleJsunit.test.js @@ -0,0 +1,271 @@ +/* + * 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/List.test.js b/account/appaccount/actsgetallaccounts/entry/src/main/js/test/List.test.js new file mode 100755 index 0000000000000000000000000000000000000000..c0b876e81cf0a75db974ee932d8fc06a1d5a6e66 --- /dev/null +++ b/account/appaccount/actsgetallaccounts/entry/src/main/js/test/List.test.js @@ -0,0 +1,15 @@ +/* + * 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/actsgetallaccounts/signature/openharmony_sx.p7b b/account/appaccount/actsgetallaccounts/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/account/appaccount/actsgetallaccounts/signature/openharmony_sx.p7b differ diff --git a/account/appaccount/actssetchecksyncenable/BUILD.gn b/account/appaccount/actssetchecksyncenable/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..de9e0e036c9d5d3a9aa62b559e2ece64057c9713 --- /dev/null +++ b/account/appaccount/actssetchecksyncenable/BUILD.gn @@ -0,0 +1,31 @@ +# 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("ActsSetCheckSyncEnable") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsSetCheckSyncEnable" +} +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/actssetchecksyncenable/Test.json b/account/appaccount/actssetchecksyncenable/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..17a8998ccaa01fda57650293ebd93e0b89672a44 --- /dev/null +++ b/account/appaccount/actssetchecksyncenable/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "60000", + "package": "com.example.actssetchecksyncenable", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsSetCheckSyncEnable.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/account/appaccount/actssetchecksyncenable/entry/src/main/config.json b/account/appaccount/actssetchecksyncenable/entry/src/main/config.json new file mode 100755 index 0000000000000000000000000000000000000000..b927be6f21e58e4d1c1e3fc58f556f2eaf5414e8 --- /dev/null +++ b/account/appaccount/actssetchecksyncenable/entry/src/main/config.json @@ -0,0 +1,74 @@ +{ + "app": { + "bundleName": "com.example.actssetchecksyncenable", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actssetchecksyncenable", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "defPermissions": [ + { + "availableScope": [], + "grantMode": "system_grant", + "name": "ohos.permission.DISTRIBUTED_DATASYNC" + } + ], + "reqPermissions": [ + { + "name": "ohos.permission.DISTRIBUTED_DATASYNC", + "reason": "ceshi" + } + ], + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.actssetchecksyncenable.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/actssetchecksyncenable/entry/src/main/js/default/app.js b/account/appaccount/actssetchecksyncenable/entry/src/main/js/default/app.js new file mode 100755 index 0000000000000000000000000000000000000000..2a68c1992145a976957d7dcdd69a7e9c2e8e9877 --- /dev/null +++ b/account/appaccount/actssetchecksyncenable/entry/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* + * 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/actssetchecksyncenable/entry/src/main/js/default/i18n/en-US.json b/account/appaccount/actssetchecksyncenable/entry/src/main/js/default/i18n/en-US.json new file mode 100755 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/account/appaccount/actssetchecksyncenable/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/account/appaccount/actssetchecksyncenable/entry/src/main/js/default/i18n/zh-CN.json b/account/appaccount/actssetchecksyncenable/entry/src/main/js/default/i18n/zh-CN.json new file mode 100755 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/account/appaccount/actssetchecksyncenable/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/account/appaccount/actssetchecksyncenable/entry/src/main/js/default/pages/index/index.css b/account/appaccount/actssetchecksyncenable/entry/src/main/js/default/pages/index/index.css new file mode 100755 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/account/appaccount/actssetchecksyncenable/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/account/appaccount/actssetchecksyncenable/entry/src/main/js/default/pages/index/index.hml b/account/appaccount/actssetchecksyncenable/entry/src/main/js/default/pages/index/index.hml new file mode 100755 index 0000000000000000000000000000000000000000..c45422b42d0bf788a1c2c0eb299a981f07ce8613 --- /dev/null +++ b/account/appaccount/actssetchecksyncenable/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{title}} + +
diff --git a/account/appaccount/actssetchecksyncenable/entry/src/main/js/default/pages/index/index.js b/account/appaccount/actssetchecksyncenable/entry/src/main/js/default/pages/index/index.js new file mode 100755 index 0000000000000000000000000000000000000000..f08e1f41b09f9746be93ca03dc4f74b118edeec4 --- /dev/null +++ b/account/appaccount/actssetchecksyncenable/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,45 @@ +/* + * 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: "测试setAppAccountSyncEnable和checkAppAccountSyncEnable接口" + }, + onInit() { + this.title = "测试setAppAccountSyncEnable和checkAppAccountSyncEnable接口"; + }, + 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/actssetchecksyncenable/entry/src/main/js/resources/base/element/string.json b/account/appaccount/actssetchecksyncenable/entry/src/main/js/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..52efec27776c61fecdfd7bd9c8f9bbb6e7e5e234 --- /dev/null +++ b/account/appaccount/actssetchecksyncenable/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ActsSetCheckSyncEnable" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/account/appaccount/actssetchecksyncenable/entry/src/main/js/resources/base/media/icon.png b/account/appaccount/actssetchecksyncenable/entry/src/main/js/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/account/appaccount/actssetchecksyncenable/entry/src/main/js/resources/base/media/icon.png differ diff --git a/account/appaccount/actssetchecksyncenable/entry/src/main/js/test/ExampleJsunit.test.js b/account/appaccount/actssetchecksyncenable/entry/src/main/js/test/ExampleJsunit.test.js new file mode 100755 index 0000000000000000000000000000000000000000..23114a80df09744f13efc345c7270ff8f316fb5d --- /dev/null +++ b/account/appaccount/actssetchecksyncenable/entry/src/main/js/test/ExampleJsunit.test.js @@ -0,0 +1,548 @@ +/* + * 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + +describe('ActsSetCheckSyncEnable', function () { + + /* + * @tc.number : ActsSetCheckSyncEnable_0100 + * @tc.name : Check sync flag callback form + * @tc.desc : Get the synchronization flag of the account that has not set the synchronization flag + */ + it('ActsSetCheckSyncEnable_0100', 0, async function (done) { + console.debug("====>ActsSetCheckSyncEnable_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("syncenable_callback_notset", (err)=>{ + console.debug("====>add account ActsSetCheckSyncEnable_0100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.checkAppAccountSyncEnable("syncenable_callback_notset", (err, data)=>{ + console.debug("====>checkAppAccountSyncEnable 0100 err:" + JSON.stringify(err)); + console.debug("====>checkAppAccountSyncEnable 0100 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data).assertEqual(false); + appAccountManager.deleteAccount("syncenable_callback_notset", (err)=>{ + console.debug("====>delete Account ActsSetCheckSyncEnable_0100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsSetCheckSyncEnable_0100 end===="); + done(); + }); + }) + }); + }); + + /* + * @tc.number : ActsSetCheckSyncEnable_0200 + * @tc.name : Check sync flag promise form + * @tc.desc : Get the synchronization flag of the account that has not set the synchronization flag + */ + it('ActsSetCheckSyncEnable_0200', 0, async function (done) { + console.debug("====>ActsSetCheckSyncEnable_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsSetCheckSyncEnable_0200 start===="); + try{ + await appAccountManager.addAccount("syncenable_promise_notset"); + } + catch(err){ + console.error("====>add account ActsSetCheckSyncEnable_0200 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>checkAppAccountSyncEnable ActsSetCheckSyncEnable_0200 start===="); + try{ + var data = await appAccountManager.checkAppAccountSyncEnable("syncenable_promise_notset"); + } + catch(err){ + console.error("====>checkAppAccountSyncEnable 0200 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>checkAppAccountSyncEnable 0200 data:" + JSON.stringify(data)); + expect(data).assertEqual(false); + console.debug("====>delete account ActsSetCheckSyncEnable_0200 start===="); + try{ + await appAccountManager.deleteAccount("syncenable_promise_notset"); + } + catch(err){ + console.error("====>delete account 0200 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsSetCheckSyncEnable_0200 end===="); + done(); + }); + + /* + * @tc.number : ActsSetCheckSyncEnable_0300 + * @tc.name : Check the set synchronization flag callback form + * @tc.desc : Check the synchronization flag after setting the synchronization flag to true for the account + */ + it('ActsSetCheckSyncEnable_0300', 0, async function (done) { + console.debug("====>ActsSetCheckSyncEnable_0300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("syncenable_callback_settrue", (err)=>{ + console.debug("====>add account ActsSetCheckSyncEnable_0300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAppAccountSyncEnable("syncenable_callback_settrue", true, (err)=>{ + console.debug("====>setAppAccountSyncEnable 0300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.checkAppAccountSyncEnable("syncenable_callback_settrue", (err, data)=>{ + console.debug("====>checkAppAccountSyncEnable 0300 err:" + JSON.stringify(err)); + console.debug("====>checkAppAccountSyncEnable 0300 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data).assertEqual(true); + appAccountManager.deleteAccount("syncenable_callback_settrue", (err)=>{ + console.debug("====>delete Account ActsSetCheckSyncEnable_0300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsSetCheckSyncEnable_0300 end===="); + done(); + }); + }) + }) + }); + }); + + /* + * @tc.number : ActsSetCheckSyncEnable_0400 + * @tc.name : Check the set synchronization flag promise form + * @tc.desc : Check the synchronization flag after setting the synchronization flag to true for the account + */ + it('ActsSetCheckSyncEnable_0400', 0, async function (done) { + console.debug("====>ActsSetCheckSyncEnable_0400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsSetCheckSyncEnable_0400 start===="); + try{ + await appAccountManager.addAccount("syncenable_promise_settrue"); + } + catch(err){ + console.error("====>add account ActsSetCheckSyncEnable_0400 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>setAppAccountSyncEnable ActsSetCheckSyncEnable_0400 start===="); + await appAccountManager.setAppAccountSyncEnable("syncenable_promise_settrue", true); + console.debug("====>checkAppAccountSyncEnable ActsSetCheckSyncEnable_0400 start===="); + try{ + var data = await appAccountManager.checkAppAccountSyncEnable("syncenable_promise_settrue"); + } + catch(err){ + console.error("====>checkAppAccountSyncEnable 0400 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>checkAppAccountSyncEnable 0400 data:" + JSON.stringify(data)); + expect(data).assertEqual(true); + console.debug("====>delete account ActsSetCheckSyncEnable_0400 start===="); + try{ + await appAccountManager.deleteAccount("syncenable_promise_settrue"); + } + catch(err){ + console.error("====>delete account 0400 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsSetCheckSyncEnable_0400 end===="); + done(); + }); + + /* + * @tc.number : ActsSetCheckSyncEnable_0500 + * @tc.name : Check the set synchronization flag callback form + * @tc.desc : Check the synchronization flag after setting the synchronization flag to false for the account + */ + it('ActsSetCheckSyncEnable_0500', 0, async function (done) { + console.debug("====>ActsSetCheckSyncEnable_0500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("syncenable_callback_setfalse", (err)=>{ + console.debug("====>add account ActsSetCheckSyncEnable_0500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAppAccountSyncEnable("syncenable_callback_setfalse", false, (err)=>{ + console.debug("====>setAppAccountSyncEnable 0500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.checkAppAccountSyncEnable("syncenable_callback_setfalse", (err, data)=>{ + console.debug("====>checkAppAccountSyncEnable 0500 err:" + JSON.stringify(err)); + console.debug("====>checkAppAccountSyncEnable 0500 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data).assertEqual(false); + appAccountManager.deleteAccount("syncenable_callback_setfalse", (err)=>{ + console.debug("====>delete Account ActsSetCheckSyncEnable_0500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsSetCheckSyncEnable_0500 end===="); + done(); + }); + }) + }) + }); + }); + + /* + * @tc.number : ActsSetCheckSyncEnable_0600 + * @tc.name : Check the set synchronization flag promise form + * @tc.desc : Check the synchronization flag after setting the synchronization flag to false for the account + */ + it('ActsSetCheckSyncEnable_0600', 0, async function (done) { + console.debug("====>ActsSetCheckSyncEnable_0600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsSetCheckSyncEnable_0600 start===="); + try{ + await appAccountManager.addAccount("syncenable_promise_setfalse"); + } + catch(err){ + console.error("====>add account ActsSetCheckSyncEnable_0600 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>setAppAccountSyncEnable ActsSetCheckSyncEnable_0600 start===="); + await appAccountManager.setAppAccountSyncEnable("syncenable_promise_setfalse", false); + console.debug("====>checkAppAccountSyncEnable ActsSetCheckSyncEnable_0600 start===="); + try{ + var data = await appAccountManager.checkAppAccountSyncEnable("syncenable_promise_setfalse"); + } + catch(err){ + console.error("====>checkAppAccountSyncEnable 0600 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>checkAppAccountSyncEnable 0600 data:" + JSON.stringify(data)); + expect(data).assertEqual(false); + console.debug("====>delete account ActsSetCheckSyncEnable_0600 start===="); + try{ + await appAccountManager.deleteAccount("syncenable_promise_setfalse"); + } + catch(err){ + console.error("====>delete account 0600 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsSetCheckSyncEnable_0600 end===="); + done(); + }); + + /* + * @tc.number : ActsSetCheckSyncEnable_0700 + * @tc.name : Check the set synchronization flag callback form + * @tc.desc : Check the synchronization flag after setting the synchronization flag for the account to false + * for the first time and true for the second time + */ + it('ActsSetCheckSyncEnable_0700', 0, async function (done) { + console.debug("====>ActsSetCheckSyncEnable_0700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("syncenable_callback_falsetrue", (err)=>{ + console.debug("====>add account ActsSetCheckSyncEnable_0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAppAccountSyncEnable("syncenable_callback_falsetrue", false, (err)=>{ + console.debug("====>setAppAccountSyncEnable first time 0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAppAccountSyncEnable("syncenable_callback_falsetrue", true, (err)=>{ + console.debug("====>setAppAccountSyncEnable second time 0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.checkAppAccountSyncEnable("syncenable_callback_falsetrue", (err, data)=>{ + console.debug("====>checkAppAccountSyncEnable 0700 err:" + JSON.stringify(err)); + console.debug("====>checkAppAccountSyncEnable 0700 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data).assertEqual(true); + appAccountManager.deleteAccount("syncenable_callback_falsetrue", (err)=>{ + console.debug("====>delete Account 0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsSetCheckSyncEnable_0700 end===="); + done(); + }); + }) + }) + }) + }); + }); + + /* + * @tc.number : ActsSetCheckSyncEnable_0800 + * @tc.name : Check the set synchronization flag promise form + * @tc.desc : Check the synchronization flag after setting the synchronization flag for the account to false + * for the first time and true for the second time + */ + it('ActsSetCheckSyncEnable_0800', 0, async function (done) { + console.debug("====>ActsSetCheckSyncEnable_0800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsSetCheckSyncEnable_0800 start===="); + await appAccountManager.addAccount("syncenable_promise_truefalse"); + console.debug("====>setAppAccountSyncEnable first time ActsSetCheckSyncEnable_0800 start===="); + await appAccountManager.setAppAccountSyncEnable("syncenable_promise_truefalse", false); + console.debug("====>setAppAccountSyncEnable second time ActsSetCheckSyncEnable_0800 start===="); + await appAccountManager.setAppAccountSyncEnable("syncenable_promise_truefalse", true); + console.debug("====>checkAppAccountSyncEnable ActsSetCheckSyncEnable_0800 start===="); + try{ + var data = await appAccountManager.checkAppAccountSyncEnable("syncenable_promise_truefalse"); + } + catch(err){ + console.error("====>checkAppAccountSyncEnable 0800 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>checkAppAccountSyncEnable 0800 data:" + JSON.stringify(data)); + expect(data).assertEqual(true); + console.debug("====>delete account ActsSetCheckSyncEnable_0800 start===="); + try{ + await appAccountManager.deleteAccount("syncenable_promise_truefalse"); + } + catch(err){ + console.error("====>delete account 0800 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsSetCheckSyncEnable_0800 end===="); + done(); + }); + + /* + * @tc.number : ActsSetCheckSyncEnable_0900 + * @tc.name : Check the set synchronization flag callback form + * @tc.desc : Check the synchronization flag after setting the synchronization flag for the account to true + * for the first time and false for the second time + */ + it('ActsSetCheckSyncEnable_0900', 0, async function (done) { + console.debug("====>ActsSetCheckSyncEnable_0900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("syncenable_callback_falsetrue", (err)=>{ + console.debug("====>add account ActsSetCheckSyncEnable_0900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAppAccountSyncEnable("syncenable_callback_falsetrue", true, (err)=>{ + console.debug("====>setAppAccountSyncEnable first time 0900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAppAccountSyncEnable("syncenable_callback_falsetrue", false, (err)=>{ + console.debug("====>setAppAccountSyncEnable second time 0900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.checkAppAccountSyncEnable("syncenable_callback_falsetrue", (err, data)=>{ + console.debug("====>checkAppAccountSyncEnable 0900 err:" + JSON.stringify(err)); + console.debug("====>checkAppAccountSyncEnable 0900 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data).assertEqual(false); + appAccountManager.deleteAccount("syncenable_callback_falsetrue", (err)=>{ + console.debug("====>delete Account 0900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsSetCheckSyncEnable_0900 end===="); + done(); + }); + }) + }) + }) + }); + }); + + /* + * @tc.number : ActsSetCheckSyncEnable_1000 + * @tc.name : Check the set synchronization flag promise form + * @tc.desc : Check the synchronization flag after setting the synchronization flag for the account to true + * for the first time and false for the second time + */ + it('ActsSetCheckSyncEnable_1000', 0, async function (done) { + console.debug("====>ActsSetCheckSyncEnable_1000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsSetCheckSyncEnable_1000 start===="); + await appAccountManager.addAccount("syncenable_promise_truefalse"); + console.debug("====>setAppAccountSyncEnable first time ActsSetCheckSyncEnable_1000 start===="); + await appAccountManager.setAppAccountSyncEnable("syncenable_promise_truefalse", true); + console.debug("====>setAppAccountSyncEnable second time ActsSetCheckSyncEnable_1000 start===="); + await appAccountManager.setAppAccountSyncEnable("syncenable_promise_truefalse", false); + console.debug("====>checkAppAccountSyncEnable ActsSetCheckSyncEnable_1000 start===="); + try{ + var data = await appAccountManager.checkAppAccountSyncEnable("syncenable_promise_truefalse"); + } + catch(err){ + console.error("====>checkAppAccountSyncEnable 1000 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>checkAppAccountSyncEnable 1000 data:" + JSON.stringify(data)); + expect(data).assertEqual(false); + console.debug("====>delete account ActsSetCheckSyncEnable_1000 start===="); + try{ + await appAccountManager.deleteAccount("syncenable_promise_truefalse"); + } + catch(err){ + console.error("====>delete account 1000 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsSetCheckSyncEnable_1000 end===="); + done(); + }); + + /* + * @tc.number : ActsSetCheckSyncEnable_1100 + * @tc.name : Check the set synchronization flag callback form + * @tc.desc : Check the synchronization flag after setting the synchronization flag for the account to true + * for the first time and true for the second time + */ + it('ActsSetCheckSyncEnable_1100', 0, async function (done) { + console.debug("====>ActsSetCheckSyncEnable_1100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("syncenable_callback_truetrue", (err)=>{ + console.debug("====>add account ActsSetCheckSyncEnable_1100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAppAccountSyncEnable("syncenable_callback_truetrue", true, (err)=>{ + console.debug("====>setAppAccountSyncEnable first time 1100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setAppAccountSyncEnable("syncenable_callback_truetrue", true, (err)=>{ + console.debug("====>setAppAccountSyncEnable second time 1100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.checkAppAccountSyncEnable("syncenable_callback_truetrue", (err, data)=>{ + console.debug("====>checkAppAccountSyncEnable 1100 err:" + JSON.stringify(err)); + console.debug("====>checkAppAccountSyncEnable 1100 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data).assertEqual(true); + appAccountManager.deleteAccount("syncenable_callback_truetrue", (err)=>{ + console.debug("====>delete Account 1100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsSetCheckSyncEnable_1100 end===="); + done(); + }); + }) + }) + }) + }); + }); + + /* + * @tc.number : ActsSetCheckSyncEnable_1200 + * @tc.name : Check the set synchronization flag promise form + * @tc.desc : Check the synchronization flag after setting the synchronization flag for the account to true + * for the true time and true for the second time + */ + it('ActsSetCheckSyncEnable_1200', 0, async function (done) { + console.debug("====>ActsSetCheckSyncEnable_1200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsSetCheckSyncEnable_1200 start===="); + await appAccountManager.addAccount("syncenable_promise_truetrue"); + console.debug("====>setAppAccountSyncEnable first time ActsSetCheckSyncEnable_1200 start===="); + await appAccountManager.setAppAccountSyncEnable("syncenable_promise_truetrue", true); + console.debug("====>setAppAccountSyncEnable second time ActsSetCheckSyncEnable_1200 start===="); + await appAccountManager.setAppAccountSyncEnable("syncenable_promise_truetrue", true); + console.debug("====>checkAppAccountSyncEnable ActsSetCheckSyncEnable_1200 start===="); + try{ + var data = await appAccountManager.checkAppAccountSyncEnable("syncenable_promise_truetrue"); + } + catch(err){ + console.error("====>checkAppAccountSyncEnable 1200 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>checkAppAccountSyncEnable 1200 data:" + JSON.stringify(data)); + expect(data).assertEqual(true); + console.debug("====>delete account ActsSetCheckSyncEnable_1200 start===="); + try{ + await appAccountManager.deleteAccount("syncenable_promise_truetrue"); + } + catch(err){ + console.error("====>delete account 1200 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>ActsSetCheckSyncEnable_1200 end===="); + done(); + }); + + /* + * @tc.number : ActsSetCheckSyncEnable_1300 + * @tc.name : setAppAccountSyncEnable callback form + * @tc.desc : Set synchronization flag for non-existent account + */ + it('ActsSetCheckSyncEnable_1300', 0, async function (done) { + console.debug("====>ActsSetCheckSyncEnable_1300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>setAppAccountSyncEnable ActsSetCheckSyncEnable_1300 start====") + var accountNotExist = "syncenable_callback_notexist"; + appAccountManager.setAppAccountSyncEnable(accountNotExist, true, (err)=>{ + console.debug("====>setAppAccountSyncEnable 1300 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsSetCheckSyncEnable_1300 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsSetCheckSyncEnable_1400 + * @tc.name : setAppAccountSyncEnable promise form + * @tc.desc : Set synchronization flag for non-existent account + */ + it('ActsSetCheckSyncEnable_1400', 0, async function (done) { + console.debug("====>ActsSetCheckSyncEnable_1400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>setAppAccountSyncEnable ActsSetCheckSyncEnable_1400 start====") + var accountNotExist = "syncenable_promise_notexist"; + try{ + await appAccountManager.setAppAccountSyncEnable(accountNotExist, true); + } + catch(err){ + console.debug("====>setAppAccountSyncEnable 1400 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsSetCheckSyncEnable_1400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsSetCheckSyncEnable_1500 + * @tc.name : checkAppAccountSyncEnable callback form + * @tc.desc : Check synchronization flag for non-existent account + */ + it('ActsSetCheckSyncEnable_1500', 0, async function (done) { + console.debug("====>ActsSetCheckSyncEnable_1500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>checkAppAccountSyncEnable ActsSetCheckSyncEnable_1500 start====") + var accountNotExist = "syncenable_callback_notexist"; + appAccountManager.checkAppAccountSyncEnable(accountNotExist, (err, data)=>{ + console.debug("====>checkAppAccountSyncEnable 1500 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsSetCheckSyncEnable_1500 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsSetCheckSyncEnable_1600 + * @tc.name : checkAppAccountSyncEnable promise form + * @tc.desc : Check synchronization flag for non-existent account + */ + it('ActsSetCheckSyncEnable_1600', 0, async function (done) { + console.debug("====>ActsSetCheckSyncEnable_1600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>checkAppAccountSyncEnable ActsSetCheckSyncEnable_1600 start====") + var accountNotExist = "syncenable_promise_notexist"; + try{ + await appAccountManager.checkAppAccountSyncEnable(accountNotExist); + } + catch(err){ + console.debug("====>checkAppAccountSyncEnable 1600 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsSetCheckSyncEnable_1600 end===="); + done(); + } + }); +}) \ 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 new file mode 100755 index 0000000000000000000000000000000000000000..c0b876e81cf0a75db974ee932d8fc06a1d5a6e66 --- /dev/null +++ b/account/appaccount/actssetchecksyncenable/entry/src/main/js/test/List.test.js @@ -0,0 +1,15 @@ +/* + * 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/actssetchecksyncenable/signature/openharmony_sx.p7b b/account/appaccount/actssetchecksyncenable/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/account/appaccount/actssetchecksyncenable/signature/openharmony_sx.p7b differ diff --git a/account/appaccount/getallaccessibleaccounts/BUILD.gn b/account/appaccount/getallaccessibleaccounts/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..5e96006ceb3d15eee75447dbbf7246f01d870a6e --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/BUILD.gn @@ -0,0 +1,24 @@ +# 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") + +group("accessibleaccounts") { + testonly = true + if (is_standard_system) { + deps = [ + "actsgetallaccessibleaccounts:ActsGetAllAccessibleAccounts", + "actsgetallaccessiblemultiple:ActsGetAllAccessibleMultiple", + ] + } +} diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/BUILD.gn b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..7910f228e1e1e37dc9a35b298d4178ad4a4d52ed --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/BUILD.gn @@ -0,0 +1,31 @@ +# 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("ActsGetAllAccessibleAccounts") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsGetAllAccessibleAccounts" +} +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/getallaccessibleaccounts/actsgetallaccessibleaccounts/Test.json b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..62e730409699038c083e90d1766ea10611342d78 --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/Test.json @@ -0,0 +1,19 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "60000", + "package": "com.example.actsgetallaccessibleaccounts", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsGetAllAccessibleAccounts.hap", + "ActsAccountSceneAccessible.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/config.json b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/config.json new file mode 100755 index 0000000000000000000000000000000000000000..3d4351ecb1a217b509ed431d91a0890f0df10d88 --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/config.json @@ -0,0 +1,74 @@ +{ + "app": { + "bundleName": "com.example.actsgetallaccessibleaccounts", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsgetallaccessibleaccounts", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "defPermissions": [ + { + "availableScope": [], + "grantMode": "system_grant", + "name": "ohos.permission.GET_ACCOUNTS_PRIVILEGED" + } + ], + "reqPermissions": [ + { + "name": "ohos.permission.GET_ACCOUNTS_PRIVILEGED", + "reason": "ceshi" + } + ], + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.actsgetallaccessibleaccounts.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/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/default/app.js b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/default/app.js new file mode 100755 index 0000000000000000000000000000000000000000..2a68c1992145a976957d7dcdd69a7e9c2e8e9877 --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* + * 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/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/default/i18n/en-US.json b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/default/i18n/en-US.json new file mode 100755 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/default/i18n/zh-CN.json b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/default/i18n/zh-CN.json new file mode 100755 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/default/pages/index/index.css b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/default/pages/index/index.css new file mode 100755 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/default/pages/index/index.hml b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/default/pages/index/index.hml new file mode 100755 index 0000000000000000000000000000000000000000..c45422b42d0bf788a1c2c0eb299a981f07ce8613 --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{title}} + +
diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/default/pages/index/index.js b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/default/pages/index/index.js new file mode 100755 index 0000000000000000000000000000000000000000..f8ce30a59d5c8db20c972608f04d5bb55a82b6fd --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,45 @@ +/* + * 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: "测试getAllAccessibleAccounts接口" + }, + onInit() { + this.title = "测试getAllAccessibleAccounts接口"; + }, + 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/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/resources/base/element/string.json b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..9df422fd35d93a0806182ffcfea798416104bb52 --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ActsGetAllAccessibleAccounts" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/resources/base/media/icon.png b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/resources/base/media/icon.png differ 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/ExampleJsunit.test.js new file mode 100755 index 0000000000000000000000000000000000000000..71ea464177c4d3ce987e05f8d532038e60d85dea --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/test/ExampleJsunit.test.js @@ -0,0 +1,541 @@ +/* + * 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 TIMEOUTEND = 4000; +describe('ActsGetAllAccessibleAccounts', function () { + + /* + * @tc.number : ActsGetAllAccessibleAccounts_0100 + * @tc.name : getAllAccessibleAccounts callback + * @tc.desc : This application has not added an account and has not been authorized by other applications to + * obtain authorization + */ + it('ActsGetAllAccessibleAccounts_0100', 0, async function (done) { + console.debug("====>ActsGetAllAccessibleAccounts_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.getAllAccessibleAccounts((err, data)=>{ + console.debug("====>getAllAccessibleAccounts 0100 err:" + JSON.stringify(err)); + console.debug("====>getAllAccessibleAccounts 0100 data:" + JSON.stringify(data)); + console.debug("====>getAllAccessibleAccounts 0100 data.length:" + data.length); + expect(err.code).assertEqual(0); + expect(data.length).assertEqual(0); + console.debug("====>ActsGetAllAccessibleAccounts_0100 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsGetAllAccessibleAccounts_0200 + * @tc.name : getAllAccessibleAccounts promise + * @tc.desc : This application has not added an account and has not been authorized by other applications to + * obtain authorization + */ + it('ActsGetAllAccessibleAccounts_0200', 0, async function (done) { + console.debug("====>ActsGetAllAccessibleAccounts_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>getAllAccessibleAccounts 0300 start===="); + try{ + var data = await appAccountManager.getAllAccessibleAccounts(); + } + catch(err){ + console.error("====>getAllAccessibleAccounts 0200 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAllAccessibleAccounts 0200 data:" + JSON.stringify(data)); + console.debug("====>getAllAccessibleAccounts 0200 data.length:" + data.length); + expect(data.length).assertEqual(0); + console.debug("====>ActsGetAllAccessibleAccounts_0200 end===="); + done(); + }); + + /* + * @tc.number : ActsGetAllAccessibleAccounts_0300 + * @tc.name : getAllAccessibleAccounts callback + * @tc.desc : This application gets authorization after adding a single account + */ + it('ActsGetAllAccessibleAccounts_0300', 0, async function (done) { + console.debug("====>ActsGetAllAccessibleAccounts_0300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("accessibleAccount_callback_single", (err)=>{ + console.debug("====> add account ActsGetAllAccessibleAccounts_0300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAllAccessibleAccounts((err, data)=>{ + console.debug("====>getAllAccessibleAccounts 0300 err:" + JSON.stringify(err)); + console.debug("====>getAllAccessibleAccounts 0300 data:" + JSON.stringify(data)); + console.debug("====>getAllAccessibleAccounts 0300 data.length:" + data.length); + expect(err.code).assertEqual(0); + expect(data.length).assertEqual(1); + try{ + expect(data[0].name).assertEqual("accessibleAccount_callback_single"); + expect(data[0].owner).assertEqual("com.example.actsgetallaccessibleaccounts"); + } + catch(err){ + console.error("====>getAllAccessibleAccounts check data 0300 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + appAccountManager.deleteAccount("accessibleAccount_callback_single", (err)=>{ + console.debug("====>delete Account ActsGetAllAccessibleAccounts_0300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsGetAllAccessibleAccounts_0300 end===="); + done(); + }) + }); + }); + }); + + /* + * @tc.number : ActsGetAllAccessibleAccounts_0400 + * @tc.name : getAllAccessibleAccounts promise + * @tc.desc : This application gets authorization after adding a single account + */ + it('ActsGetAllAccessibleAccounts_0400', 0, async function (done) { + console.debug("====>ActsGetAllAccessibleAccounts_0400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account ActsGetAllAccessibleAccounts_0400 start===="); + await appAccountManager.addAccount("accessibleAccount_promise_single"); + console.debug("====>getAllAccessibleAccounts 0400 start===="); + try{ + var data = await appAccountManager.getAllAccessibleAccounts(); + } + catch(err){ + console.error("====>getAllAccessibleAccounts 0400 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAllAccessibleAccounts 0400 data:" + JSON.stringify(data)); + console.debug("====>getAllAccessibleAccounts 0400 data.length:" + data.length); + try{ + expect(data[0].name).assertEqual("accessibleAccount_promise_single"); + expect(data[0].owner).assertEqual("com.example.actsgetallaccessibleaccounts"); + } + catch(err){ + console.error("====>getAllAccessibleAccounts check data 0400 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + await appAccountManager.deleteAccount("accessibleAccount_promise_single"); + console.debug("====>ActsGetAllAccessibleAccounts_0400 end===="); + done(); + }); + + /* + * @tc.number : ActsGetAllAccessibleAccounts_0500 + * @tc.name : getAllAccessibleAccounts callback + * @tc.desc : This application is added to obtain authorization after adding multiple application accounts + */ + it('ActsGetAllAccessibleAccounts_0500', 0, async function (done) { + console.debug("====>ActsGetAllAccessibleAccounts_0500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("accessibleAccount_callback_first", (err)=>{ + console.debug("====>add account first time 0500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.addAccount("accessibleAccount_callback_second", (err)=>{ + console.debug("====>add account second time 0500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.addAccount("accessibleAccount_callback_third", (err)=>{ + console.debug("====>add account third time 0500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAllAccessibleAccounts((err, data)=>{ + console.debug("====>getAllAccessibleAccounts 0500 err:" + JSON.stringify(err)); + console.debug("====>getAllAccessibleAccounts 0500 data:" + JSON.stringify(data)); + console.debug("====>getAllAccessibleAccounts 0500 data.length:" + data.length); + expect(err.code).assertEqual(0); + expect(data.length).assertEqual(3); + try{ + expect(data[0].name).assertEqual("accessibleAccount_callback_first"); + expect(data[0].owner).assertEqual("com.example.actsgetallaccessibleaccounts"); + expect(data[1].name).assertEqual("accessibleAccount_callback_second"); + expect(data[1].owner).assertEqual("com.example.actsgetallaccessibleaccounts"); + expect(data[2].name).assertEqual("accessibleAccount_callback_third"); + expect(data[2].owner).assertEqual("com.example.actsgetallaccessibleaccounts"); + } + catch(err){ + console.error("====>check data 0500 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + appAccountManager.deleteAccount("accessibleAccount_callback_first", (err)=>{ + console.debug("====>delete Account first 0500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount("accessibleAccount_callback_second", (err)=>{ + console.debug("====>delete Account second 0500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount("accessibleAccount_callback_third", (err)=>{ + console.debug("====>delete Account third 0500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsGetAllAccessibleAccounts_0500 end===="); + done(); + }) + }) + }) + }); + }) + }) + }); + }); + + /* + * @tc.number : ActsGetAllAccessibleAccounts_0600 + * @tc.name : getAllAccessibleAccounts promise + * @tc.desc : This application is added to obtain authorization after adding multiple application accounts + */ + it('ActsGetAllAccessibleAccounts_0600', 0, async function (done) { + console.debug("====>ActsGetAllAccessibleAccounts_0600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add first account 0600 start===="); + await appAccountManager.addAccount("accessibleAccount_promise_first"); + console.debug("====>add second account 0600 start===="); + await appAccountManager.addAccount("accessibleAccount_promise_second"); + console.debug("====>add third account 0600 start===="); + await appAccountManager.addAccount("accessibleAccount_promise_third"); + try{ + var data = await appAccountManager.getAllAccessibleAccounts(); + } + catch(err){ + console.error("====>getAllAccessibleAccounts 0600 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAllAccessibleAccounts 0600 data:" + JSON.stringify(data)); + expect(data.length).assertEqual(3); + try{ + expect(data[0].name).assertEqual("accessibleAccount_promise_first"); + expect(data[0].owner).assertEqual("com.example.actsgetallaccessibleaccounts"); + expect(data[1].name).assertEqual("accessibleAccount_promise_second"); + expect(data[1].owner).assertEqual("com.example.actsgetallaccessibleaccounts"); + expect(data[2].name).assertEqual("accessibleAccount_promise_third"); + expect(data[2].owner).assertEqual("com.example.actsgetallaccessibleaccounts"); + } + catch(err){ + console.error("====>check data 0600 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>delete first account 0600 start===="); + await appAccountManager.deleteAccount("accessibleAccount_promise_first"); + console.debug("====>delete second account 0600 start===="); + await appAccountManager.deleteAccount("accessibleAccount_promise_second"); + console.debug("====>delete third account 0600 start===="); + await appAccountManager.deleteAccount("accessibleAccount_promise_third"); + console.debug("====>ActsGetAllAccessibleAccounts_0600 end===="); + done(); + }); + + /* + * @tc.number : ActsGetAllAccessibleAccounts_0700 + * @tc.name : getAllAccessibleAccounts callback + * @tc.desc : This application adds different application accounts three times in a row, and obtains + * authorization after deleting the account added for the second time + */ + it('ActsGetAllAccessibleAccounts_0700', 0, async function (done) { + console.debug("====>ActsGetAllAccessibleAccounts_0700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("accessibleAccount_callback_delete_first", (err)=>{ + console.debug("====>add first account 0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.addAccount("accessibleAccount_callback_delete_second", (err)=>{ + console.debug("====>add second account 0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.addAccount("accessibleAccount_callback_delete_third", (err)=>{ + console.debug("====>add third account 0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount("accessibleAccount_callback_delete_second", (err)=>{ + console.debug("====>delete second account 0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAllAccessibleAccounts((err, data)=>{ + console.debug("====>getAllAccessibleAccounts 0700 err:" + JSON.stringify(err)); + console.debug("====>getAllAccessibleAccounts 0700 data:" + JSON.stringify(data)); + console.debug("====>getAllAccessibleAccounts 0700 data.length:" + data.length); + expect(err.code).assertEqual(0); + expect(data.length).assertEqual(2); + try{ + expect(data[0].name).assertEqual("accessibleAccount_callback_delete_first"); + expect(data[0].owner).assertEqual("com.example.actsgetallaccessibleaccounts"); + expect(data[1].name).assertEqual("accessibleAccount_callback_delete_third"); + expect(data[1].owner).assertEqual("com.example.actsgetallaccessibleaccounts"); + } + catch(err){ + console.error("====>check data 0700 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + appAccountManager.deleteAccount("accessibleAccount_callback_delete_first", (err)=>{ + console.debug("====>delete first account 0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount("accessibleAccount_callback_delete_third", (err)=>{ + console.debug("====>delete third account 0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsGetAllAccessibleAccounts_0700 end===="); + done(); + }) + }) + }); + }) + }) + }) + }); + }); + + /* + * @tc.number : ActsGetAllAccessibleAccounts_0800 + * @tc.name : getAllAccessibleAccounts promise + * @tc.desc : This application adds different application accounts three times in a row, and obtains + * authorization after deleting the account added for the second time + */ + it('ActsGetAllAccessibleAccounts_0800', 0, async function (done) { + console.debug("====>ActsGetAllAccessibleAccounts_0800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add first account 0800 start===="); + await appAccountManager.addAccount("accessibleAccount_promise_first"); + console.debug("====>add second account 0800 start===="); + await appAccountManager.addAccount("accessibleAccount_promise_second"); + console.debug("====>add third account 0800 start===="); + await appAccountManager.addAccount("accessibleAccount_promise_third"); + console.debug("====>delete second account 0800 start===="); + await appAccountManager.deleteAccount("accessibleAccount_promise_second"); + try{ + var data = await appAccountManager.getAllAccessibleAccounts(); + } + catch(err){ + console.error("====>getAllAccessibleAccounts 0800 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAllAccessibleAccounts 0800 data:" + JSON.stringify(data)); + expect(data.length).assertEqual(2); + try{ + expect(data[0].name).assertEqual("accessibleAccount_promise_first"); + expect(data[0].owner).assertEqual("com.example.actsgetallaccessibleaccounts"); + expect(data[1].name).assertEqual("accessibleAccount_promise_third"); + expect(data[1].owner).assertEqual("com.example.actsgetallaccessibleaccounts"); + } + catch(err){ + console.error("====>check data 0800 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>delete first account 0800 start===="); + await appAccountManager.deleteAccount("accessibleAccount_promise_first"); + console.debug("====>delete third account 0800 start===="); + await appAccountManager.deleteAccount("accessibleAccount_promise_third"); + console.debug("====>ActsGetAllAccessibleAccounts_0800 end===="); + done(); + }); + + /* + * @tc.number : ActsGetAllAccessibleAccounts_0900 + * @tc.name : getAllAccessibleAccounts callback + * @tc.desc : This application adds different application accounts three times in a row, and then obtains + * authorization multiple times + */ + it('ActsGetAllAccessibleAccounts_0900', 0, async function (done) { + console.debug("====>ActsGetAllAccessibleAccounts_0900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.addAccount("accessibleAccount_callback_multiple_first", (err)=>{ + console.debug("====>add first account 0900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.addAccount("accessibleAccount_callback_multiple_second", (err)=>{ + console.debug("====>add third account 0900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAllAccessibleAccounts((err, data)=>{ + console.debug("====>getAllAccessibleAccounts first 0900 err:" + JSON.stringify(err)); + console.debug("====>getAllAccessibleAccounts first 0900 data:" + JSON.stringify(data)); + console.debug("====>getAllAccessibleAccounts first 0900 data.length:" + data.length); + expect(err.code).assertEqual(0); + expect(data.length).assertEqual(2); + try{ + expect(data[0].name).assertEqual("accessibleAccount_callback_multiple_first"); + expect(data[0].owner).assertEqual("com.example.actsgetallaccessibleaccounts"); + expect(data[1].name).assertEqual("accessibleAccount_callback_multiple_second"); + expect(data[1].owner).assertEqual("com.example.actsgetallaccessibleaccounts"); + } + catch(err){ + console.error("====>check data first 0900 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + appAccountManager.getAllAccessibleAccounts((err, data)=>{ + console.debug("====>getAllAccessibleAccounts second 0900 err:" + JSON.stringify(err)); + console.debug("====>getAllAccessibleAccounts second 0900 data:" + JSON.stringify(data)); + console.debug("====>getAllAccessibleAccounts second 0900 data.length:" + data.length); + expect(err.code).assertEqual(0); + expect(data.length).assertEqual(2); + try{ + expect(data[0].name).assertEqual("accessibleAccount_callback_multiple_first"); + expect(data[0].owner).assertEqual("com.example.actsgetallaccessibleaccounts"); + expect(data[1].name).assertEqual("accessibleAccount_callback_multiple_second"); + expect(data[1].owner).assertEqual("com.example.actsgetallaccessibleaccounts"); + } + catch(err){ + console.error("====>check data second 0900 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + appAccountManager.deleteAccount("accessibleAccount_callback_multiple_first", (err)=>{ + console.debug("====>delete first account 0900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount("accessibleAccount_callback_multiple_second", (err)=>{ + console.debug("====>delete second account 0900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsGetAllAccessibleAccounts_0900 end===="); + done(); + }) + }) + }) + }) + }) + }); + }); + + /* + * @tc.number : ActsGetAllAccessibleAccounts_1000 + * @tc.name : getAllAccessibleAccounts promise + * @tc.desc : This application adds different application accounts three times in a row, and then obtains + * authorization multiple times + */ + it('ActsGetAllAccessibleAccounts_1000', 0, async function (done) { + console.debug("====>ActsGetAllAccessibleAccounts_1000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add first account 1000 start===="); + await appAccountManager.addAccount("accessibleAccount_promise_multiple_first"); + console.debug("====>add second account 1000 start===="); + await appAccountManager.addAccount("accessibleAccount_promise_multiple_second"); + console.debug("====>getAllAccessibleAccounts first 1000 start===="); + try{ + var data = await appAccountManager.getAllAccessibleAccounts(); + } + catch(err){ + console.error("====>getAllAccessibleAccounts first 1000 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAllAccessibleAccounts 1000 data:" + JSON.stringify(data)); + expect(data.length).assertEqual(2); + try{ + expect(data[0].name).assertEqual("accessibleAccount_promise_multiple_first"); + expect(data[0].owner).assertEqual("com.example.actsgetallaccessibleaccounts"); + expect(data[1].name).assertEqual("accessibleAccount_promise_multiple_second"); + expect(data[1].owner).assertEqual("com.example.actsgetallaccessibleaccounts"); + } + catch(err){ + console.error("====>check data 1000 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAllAccessibleAccounts second 1000 start===="); + try{ + var dataTwo = await appAccountManager.getAllAccessibleAccounts(); + } + catch(err){ + console.error("====>getAllAccessibleAccounts second 1000 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAllAccessibleAccounts 1000 dataTwo:" + JSON.stringify(dataTwo)); + expect(data.length).assertEqual(2); + try{ + expect(dataTwo[0].name).assertEqual("accessibleAccount_promise_multiple_first"); + expect(dataTwo[0].owner).assertEqual("com.example.actsgetallaccessibleaccounts"); + expect(dataTwo[1].name).assertEqual("accessibleAccount_promise_multiple_second"); + expect(dataTwo[1].owner).assertEqual("com.example.actsgetallaccessibleaccounts"); + } + catch(err){ + console.error("====>check dataTwo 1000 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>delete first account 1000 start===="); + await appAccountManager.deleteAccount("accessibleAccount_promise_multiple_first"); + console.debug("====>delete second account 1000 start===="); + await appAccountManager.deleteAccount("accessibleAccount_promise_multiple_second"); + console.debug("====>ActsGetAllAccessibleAccounts_1000 end===="); + done(); + }); + + /* + * @tc.number : ActsGetAllAccessibleAccounts_1100 + * @tc.name : getAllAccessibleAccounts + * @tc.desc : This application adds an account, other application authorizes an account to this application + * and this application obtains authorization + */ + it('ActsGetAllAccessibleAccounts_1100', 0, async function (done) { + console.debug("====>ActsGetAllAccessibleAccounts_1100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add account 1100 start===="); + await appAccountManager.addAccount("accessibleAccount_this_application"); + console.debug("====>startAbility 1100 start===="); + await featureAbility.startAbility( + { + want: + { + deviceId: "", + bundleName: "com.example.actsaccountsceneaccessible", + abilityName: "com.example.actsaccountsceneaccessible.MainAbility", + action: "action1", + parameters: + {}, + }, + }, + ); + setTimeout(async function(){ + console.debug("====>getAllAccessibleAccounts 1100 start===="); + try{ + var data = await appAccountManager.getAllAccessibleAccounts(); + } + catch(err){ + console.error("====>getAllAccessibleAccounts 1100 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAllAccessibleAccounts 1100 data:" + JSON.stringify(data)); + expect(data.length).assertEqual(2); + try{ + expect(data[0].name).assertEqual("account_name_scene_single"); + expect(data[0].owner).assertEqual("com.example.actsaccountsceneaccessible"); + expect(data[1].name).assertEqual("accessibleAccount_this_application"); + expect(data[1].owner).assertEqual("com.example.actsgetallaccessibleaccounts"); + } + catch(err){ + console.error("====>check data 1100 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>delete account 1100 start===="); + await appAccountManager.deleteAccount("accessibleAccount_this_application"); + 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 new file mode 100755 index 0000000000000000000000000000000000000000..c0b876e81cf0a75db974ee932d8fc06a1d5a6e66 --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/test/List.test.js @@ -0,0 +1,15 @@ +/* + * 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/getallaccessibleaccounts/actsgetallaccessibleaccounts/signature/openharmony_sx.p7b b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/signature/openharmony_sx.p7b differ diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/BUILD.gn b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..119691b77ed040ee5b6008df0770739bce30563f --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/BUILD.gn @@ -0,0 +1,31 @@ +# 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("ActsGetAllAccessibleMultiple") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsGetAllAccessibleMultiple" +} +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/getallaccessibleaccounts/actsgetallaccessiblemultiple/Test.json b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..bd1a9798326be9d41b83b1a0e24468c5007201c1 --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/Test.json @@ -0,0 +1,20 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "60000", + "package": "com.example.actsgetallaccessiblemultiple", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsGetAllAccessibleMultiple.hap", + "ActsAccountAccessibleFirst.hap", + "ActsAccountAccessibleSecond.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/config.json b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/config.json new file mode 100755 index 0000000000000000000000000000000000000000..c54cdd98a5c1c32d639239be3fbf3aeae0e3be4a --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/config.json @@ -0,0 +1,74 @@ +{ + "app": { + "bundleName": "com.example.actsgetallaccessiblemultiple", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsgetallaccessiblemultiple", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "defPermissions": [ + { + "availableScope": [], + "grantMode": "system_grant", + "name": "ohos.permission.GET_ACCOUNTS_PRIVILEGED" + } + ], + "reqPermissions": [ + { + "name": "ohos.permission.GET_ACCOUNTS_PRIVILEGED", + "reason": "ceshi" + } + ], + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.actsgetallaccessiblemultiple.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/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/default/app.js b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/default/app.js new file mode 100755 index 0000000000000000000000000000000000000000..2a68c1992145a976957d7dcdd69a7e9c2e8e9877 --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* + * 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/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/default/i18n/en-US.json b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/default/i18n/en-US.json new file mode 100755 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/default/i18n/zh-CN.json b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/default/i18n/zh-CN.json new file mode 100755 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/default/pages/index/index.css b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/default/pages/index/index.css new file mode 100755 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/default/pages/index/index.hml b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/default/pages/index/index.hml new file mode 100755 index 0000000000000000000000000000000000000000..c45422b42d0bf788a1c2c0eb299a981f07ce8613 --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{title}} + +
diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/default/pages/index/index.js b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/default/pages/index/index.js new file mode 100755 index 0000000000000000000000000000000000000000..f8ce30a59d5c8db20c972608f04d5bb55a82b6fd --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,45 @@ +/* + * 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: "测试getAllAccessibleAccounts接口" + }, + onInit() { + this.title = "测试getAllAccessibleAccounts接口"; + }, + 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/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/resources/base/element/string.json b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..1835ed9344ce3ded8e53ef4267311fb1f07254bc --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ActsGetAllAccessibleMultiple" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/resources/base/media/icon.png b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/resources/base/media/icon.png differ 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/ExampleJsunit.test.js new file mode 100755 index 0000000000000000000000000000000000000000..6df1f5e4ea6c9283c0d7eb4ad71f60ee8b759cf6 --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/test/ExampleJsunit.test.js @@ -0,0 +1,115 @@ +/* + * 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 = 3000; +const TIMEOUTEND = 5000; + +describe('ActsGetAllAccessibleMultiple', function () { + beforeAll(async function (done) { + console.debug("====>startAbility first 0100 start===="); + await featureAbility.startAbility( + { + want: + { + deviceId: "", + bundleName: "com.example.actsaccountaccessiblefirst", + abilityName: "com.example.actsaccountaccessiblefirst.MainAbility", + action: "action1", + parameters: + {}, + }, + }, + ); + setTimeout(done(), 5000); + }); + + /* + * @tc.number : ActsGetAllAccessibleMultiple_0100 + * @tc.name : getAllAccessibleAccounts + * @tc.desc : This application adds multiple account, other applications authorizes multiple accounts to this + * application and this application obtains authorization + */ + it('ActsGetAllAccessibleMultiple_0100', 0, async function (done) { + console.debug("====>ActsGetAllAccessibleMultiple_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>add first account 0100 start===="); + await appAccountManager.addAccount("accessibleAccount_this_application_first"); + console.debug("====>add second account 0100 start===="); + await appAccountManager.addAccount("accessibleAccount_this_application_second"); + console.debug("====>add third account 0100 start===="); + await appAccountManager.addAccount("accessibleAccount_this_application_third"); + console.debug("====>startAbility second 0100 start===="); + await featureAbility.startAbility( + { + want: + { + deviceId: "", + bundleName: "com.example.actsaccountaccessiblesecond", + abilityName: "com.example.actsaccountaccessiblesecond.MainAbility", + action: "action1", + parameters: + {}, + }, + } + ); + setTimeout(async function(){ + console.debug("====>getAllAccessibleAccounts 0100 start===="); + try{ + var data = await appAccountManager.getAllAccessibleAccounts(); + } + catch(err){ + console.error("====>getAllAccessibleAccounts 0100 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAllAccessibleAccounts 0100 data:" + JSON.stringify(data)); + expect(data.length).assertEqual(7); + try{ + expect(data[0].name).assertEqual("account_name_scene_first_first"); + expect(data[0].owner).assertEqual("com.example.actsaccountaccessiblefirst"); + expect(data[1].name).assertEqual("account_name_scene_first_second"); + expect(data[1].owner).assertEqual("com.example.actsaccountaccessiblefirst"); + expect(data[2].name).assertEqual("account_name_scene_second_first"); + expect(data[2].owner).assertEqual("com.example.actsaccountaccessiblesecond"); + expect(data[3].name).assertEqual("account_name_scene_second_second"); + expect(data[3].owner).assertEqual("com.example.actsaccountaccessiblesecond"); + expect(data[4].name).assertEqual("accessibleAccount_this_application_first"); + expect(data[4].owner).assertEqual("com.example.actsgetallaccessiblemultiple"); + expect(data[5].name).assertEqual("accessibleAccount_this_application_second"); + expect(data[5].owner).assertEqual("com.example.actsgetallaccessiblemultiple"); + expect(data[6].name).assertEqual("accessibleAccount_this_application_third"); + expect(data[6].owner).assertEqual("com.example.actsgetallaccessiblemultiple"); + } + catch(err){ + console.error("====>check data 0100 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>delete account 0100 start===="); + await appAccountManager.deleteAccount("accessibleAccount_this_application_first"); + await appAccountManager.deleteAccount("accessibleAccount_this_application_second"); + await appAccountManager.deleteAccount("accessibleAccount_this_application_third"); + 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 new file mode 100755 index 0000000000000000000000000000000000000000..c0b876e81cf0a75db974ee932d8fc06a1d5a6e66 --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/test/List.test.js @@ -0,0 +1,15 @@ +/* + * 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/getallaccessibleaccounts/actsgetallaccessiblemultiple/signature/openharmony_sx.p7b b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/signature/openharmony_sx.p7b differ diff --git a/account/appaccount/sceneProject/BUILD.gn b/account/appaccount/sceneProject/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b0eb77687cc28e54696f2a8150f23698847a65e7 --- /dev/null +++ b/account/appaccount/sceneProject/BUILD.gn @@ -0,0 +1,28 @@ +# 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") + +group("appaccount_scene") { + testonly = true + if (is_standard_system) { + deps = [ + "actsaccountaccessibleFirst:ActsAccountAccessibleFirst", + "actsaccountaccessibleSecond:ActsAccountAccessibleSecond", + "actsaccountsceneaccessible:ActsAccountSceneAccessible", + "actsaccountsceneappaccess:ActsAccountSceneAppAccess", + "actsaccountsceneonoff:ActsAccountSceneOnOff", + "actsscenegetallaccounts:ActsSceneGetAllAccounts", + ] + } +} diff --git a/account/appaccount/sceneProject/actsaccountaccessibleFirst/BUILD.gn b/account/appaccount/sceneProject/actsaccountaccessibleFirst/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..6cb4ea07949f584c1094fc8ca0f7dc440b0dcc82 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountaccessibleFirst/BUILD.gn @@ -0,0 +1,31 @@ +# 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("ActsAccountAccessibleFirst") { + hap_profile = "./entry/src/main/config.json" + 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" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/account/appaccount/sceneProject/actsaccountaccessibleFirst/Test.json b/account/appaccount/sceneProject/actsaccountaccessibleFirst/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..7a88763ed8d2ac31dd30211b9574f47273e84549 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountaccessibleFirst/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests", +} diff --git a/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/config.json b/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/config.json new file mode 100755 index 0000000000000000000000000000000000000000..2ebdd72a9bf6b0a0e1c1d136120d8d967ccd8616 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/config.json @@ -0,0 +1,61 @@ +{ + "app": { + "bundleName": "com.example.actsaccountaccessiblefirst", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsaccountaccessiblefirst", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.actsaccountaccessiblefirst.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/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/default/app.js b/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/default/app.js new file mode 100755 index 0000000000000000000000000000000000000000..2a68c1992145a976957d7dcdd69a7e9c2e8e9877 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* + * 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/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/default/i18n/en-US.json b/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/default/i18n/en-US.json new file mode 100755 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/default/i18n/zh-CN.json b/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/default/i18n/zh-CN.json new file mode 100755 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/default/pages/index/index.css b/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/default/pages/index/index.css new file mode 100755 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/default/pages/index/index.hml b/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/default/pages/index/index.hml new file mode 100755 index 0000000000000000000000000000000000000000..c45422b42d0bf788a1c2c0eb299a981f07ce8613 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{title}} + +
diff --git a/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/default/pages/index/index.js b/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/default/pages/index/index.js new file mode 100755 index 0000000000000000000000000000000000000000..f8be6e7a9c4fa98d46c83bb32a991e3577cb4998 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,52 @@ +/* + * 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' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + }, + onInit() { + this.title = "scene accessible first application"; + }, + onShow() { + console.debug('====>scene accessible first application start===='); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat first scene manager finish===="); + var enableBundle = "com.example.actsgetallaccessiblemultiple"; + console.debug("====>add first account start===="); + appAccountManager.addAccount("account_name_scene_first_first", (err)=>{ + console.debug("====>add first account err:" + JSON.stringify(err)); + appAccountManager.enableAppAccess("account_name_scene_first_first", enableBundle, (err)=>{ + console.debug("====>enableAppAccess first account err:" + JSON.stringify(err)); + appAccountManager.addAccount("account_name_scene_first_second", (err)=>{ + console.debug("====>add second account err:" + JSON.stringify(err)); + appAccountManager.enableAppAccess("account_name_scene_first_second", enableBundle, (err)=>{ + console.debug("====>enableAppAccess second account err:" + JSON.stringify(err)); + featureAbility.terminateSelf( + (err, data)=>{ + console.debug('====>Terminate Ability Success====') + }); + }) + }) + }) + }) + }, + onReady() { + }, +} \ No newline at end of file diff --git a/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/resources/base/element/string.json b/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..aeb3adc8d5b81aa6de396b6da1cb1c509eb20895 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ActsAccountSceneAppAccess" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/resources/base/media/icon.png b/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/resources/base/media/icon.png differ diff --git a/account/appaccount/sceneProject/actsaccountaccessibleFirst/signature/openharmony_sx.p7b b/account/appaccount/sceneProject/actsaccountaccessibleFirst/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/account/appaccount/sceneProject/actsaccountaccessibleFirst/signature/openharmony_sx.p7b differ diff --git a/account/appaccount/sceneProject/actsaccountaccessibleSecond/BUILD.gn b/account/appaccount/sceneProject/actsaccountaccessibleSecond/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..d3d0df12ce1a750a421d63970dc72c9b014279e2 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountaccessibleSecond/BUILD.gn @@ -0,0 +1,31 @@ +# 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("ActsAccountAccessibleSecond") { + hap_profile = "./entry/src/main/config.json" + 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" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/account/appaccount/sceneProject/actsaccountaccessibleSecond/Test.json b/account/appaccount/sceneProject/actsaccountaccessibleSecond/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..7a88763ed8d2ac31dd30211b9574f47273e84549 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountaccessibleSecond/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests", +} diff --git a/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/config.json b/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/config.json new file mode 100755 index 0000000000000000000000000000000000000000..3b381d659f71c7893bb9a3c7250db5369480c7ed --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/config.json @@ -0,0 +1,61 @@ +{ + "app": { + "bundleName": "com.example.actsaccountaccessiblesecond", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsaccountaccessiblesecond", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.actsaccountaccessiblesecond.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/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/default/app.js b/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/default/app.js new file mode 100755 index 0000000000000000000000000000000000000000..2a68c1992145a976957d7dcdd69a7e9c2e8e9877 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* + * 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/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/default/i18n/en-US.json b/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/default/i18n/en-US.json new file mode 100755 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/default/i18n/zh-CN.json b/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/default/i18n/zh-CN.json new file mode 100755 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/default/pages/index/index.css b/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/default/pages/index/index.css new file mode 100755 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/default/pages/index/index.hml b/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/default/pages/index/index.hml new file mode 100755 index 0000000000000000000000000000000000000000..c45422b42d0bf788a1c2c0eb299a981f07ce8613 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{title}} + +
diff --git a/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/default/pages/index/index.js b/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/default/pages/index/index.js new file mode 100755 index 0000000000000000000000000000000000000000..3c2f93f24017b7c035bbf1c85cc65397088b0f72 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,51 @@ +/* + * 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' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + }, + onInit() { + this.title = "scene accessible second application"; + }, + onShow() { + console.debug('====>scene accessible second application start===='); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat second scene manager finish===="); + var enableBundle = "com.example.actsgetallaccessiblemultiple"; + console.debug("====>add second account start===="); + appAccountManager.addAccount("account_name_scene_second_first", (err)=>{ + console.debug("====>add second account err:" + JSON.stringify(err)); + appAccountManager.enableAppAccess("account_name_scene_second_first", enableBundle, (err)=>{ + console.debug("====>enableAppAccess second account err:" + JSON.stringify(err)); + appAccountManager.addAccount("account_name_scene_second_second", (err)=>{ + console.debug("====>add second account err:" + JSON.stringify(err)); + appAccountManager.enableAppAccess("account_name_scene_second_second", enableBundle, (err)=>{ + console.debug("====>enableAppAccess second account err:" + JSON.stringify(err)); + featureAbility.terminateSelf( + (err, data)=>{ + console.debug('====>Terminate Ability Success====') + }); + }) + }) + }) + }) + }, + onReady() { + }, +} \ No newline at end of file diff --git a/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/resources/base/element/string.json b/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..aeb3adc8d5b81aa6de396b6da1cb1c509eb20895 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ActsAccountSceneAppAccess" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/resources/base/media/icon.png b/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/resources/base/media/icon.png differ diff --git a/account/appaccount/sceneProject/actsaccountaccessibleSecond/signature/openharmony_sx.p7b b/account/appaccount/sceneProject/actsaccountaccessibleSecond/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/account/appaccount/sceneProject/actsaccountaccessibleSecond/signature/openharmony_sx.p7b differ diff --git a/account/appaccount/sceneProject/actsaccountsceneaccessible/BUILD.gn b/account/appaccount/sceneProject/actsaccountsceneaccessible/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..60007607052148d62ee2dfb367e98680883816e1 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountsceneaccessible/BUILD.gn @@ -0,0 +1,31 @@ +# 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("ActsAccountSceneAccessible") { + hap_profile = "./entry/src/main/config.json" + 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" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/account/appaccount/sceneProject/actsaccountsceneaccessible/Test.json b/account/appaccount/sceneProject/actsaccountsceneaccessible/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..7a88763ed8d2ac31dd30211b9574f47273e84549 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountsceneaccessible/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests", +} diff --git a/account/appaccount/sceneProject/actsaccountsceneaccessible/entry/src/main/config.json b/account/appaccount/sceneProject/actsaccountsceneaccessible/entry/src/main/config.json new file mode 100755 index 0000000000000000000000000000000000000000..65b0eb38c5358a4bf5625e30efa35f7988f3c8b4 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountsceneaccessible/entry/src/main/config.json @@ -0,0 +1,61 @@ +{ + "app": { + "bundleName": "com.example.actsaccountsceneaccessible", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsaccountsceneaccessible", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.actsaccountsceneaccessible.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/sceneProject/actsaccountsceneaccessible/entry/src/main/js/default/app.js b/account/appaccount/sceneProject/actsaccountsceneaccessible/entry/src/main/js/default/app.js new file mode 100755 index 0000000000000000000000000000000000000000..2a68c1992145a976957d7dcdd69a7e9c2e8e9877 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountsceneaccessible/entry/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* + * 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/sceneProject/actsaccountsceneaccessible/entry/src/main/js/default/i18n/en-US.json b/account/appaccount/sceneProject/actsaccountsceneaccessible/entry/src/main/js/default/i18n/en-US.json new file mode 100755 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountsceneaccessible/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/account/appaccount/sceneProject/actsaccountsceneaccessible/entry/src/main/js/default/i18n/zh-CN.json b/account/appaccount/sceneProject/actsaccountsceneaccessible/entry/src/main/js/default/i18n/zh-CN.json new file mode 100755 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountsceneaccessible/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/account/appaccount/sceneProject/actsaccountsceneaccessible/entry/src/main/js/default/pages/index/index.css b/account/appaccount/sceneProject/actsaccountsceneaccessible/entry/src/main/js/default/pages/index/index.css new file mode 100755 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountsceneaccessible/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/account/appaccount/sceneProject/actsaccountsceneaccessible/entry/src/main/js/default/pages/index/index.hml b/account/appaccount/sceneProject/actsaccountsceneaccessible/entry/src/main/js/default/pages/index/index.hml new file mode 100755 index 0000000000000000000000000000000000000000..c45422b42d0bf788a1c2c0eb299a981f07ce8613 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountsceneaccessible/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{title}} + +
diff --git a/account/appaccount/sceneProject/actsaccountsceneaccessible/entry/src/main/js/default/pages/index/index.js b/account/appaccount/sceneProject/actsaccountsceneaccessible/entry/src/main/js/default/pages/index/index.js new file mode 100755 index 0000000000000000000000000000000000000000..de497484928c2ce6f09188e9bfcb04486fbf2e59 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountsceneaccessible/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,41 @@ +/* + * 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' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + }, + onInit() { + this.title = "scene accessible account"; + }, + onShow() { + console.debug('====>scene accessible account start===='); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat scene manager finish===="); + var enableBundle = "com.example.actsgetallaccessibleaccounts"; + console.debug("====>add account scene start===="); + appAccountManager.addAccount("account_name_scene_single", (err)=>{ + console.debug("====>add account scene err:" + JSON.stringify(err)); + appAccountManager.enableAppAccess("account_name_scene_single", enableBundle, (err)=>{ + console.debug("====>enableAppAccess scene err:" + JSON.stringify(err)); + }); + }); + }, + onReady() { + }, +} \ No newline at end of file diff --git a/account/appaccount/sceneProject/actsaccountsceneaccessible/entry/src/main/js/resources/base/element/string.json b/account/appaccount/sceneProject/actsaccountsceneaccessible/entry/src/main/js/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..aeb3adc8d5b81aa6de396b6da1cb1c509eb20895 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountsceneaccessible/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ActsAccountSceneAppAccess" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/account/appaccount/sceneProject/actsaccountsceneaccessible/entry/src/main/js/resources/base/media/icon.png b/account/appaccount/sceneProject/actsaccountsceneaccessible/entry/src/main/js/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/account/appaccount/sceneProject/actsaccountsceneaccessible/entry/src/main/js/resources/base/media/icon.png differ diff --git a/account/appaccount/sceneProject/actsaccountsceneaccessible/signature/openharmony_sx.p7b b/account/appaccount/sceneProject/actsaccountsceneaccessible/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/account/appaccount/sceneProject/actsaccountsceneaccessible/signature/openharmony_sx.p7b differ diff --git a/account/appaccount/sceneProject/actsaccountsceneappaccess/BUILD.gn b/account/appaccount/sceneProject/actsaccountsceneappaccess/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..47390cf5c697d832b3cf9511fec207215da92f19 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountsceneappaccess/BUILD.gn @@ -0,0 +1,31 @@ +# 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("ActsAccountSceneAppAccess") { + hap_profile = "./entry/src/main/config.json" + 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" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/account/appaccount/sceneProject/actsaccountsceneappaccess/Test.json b/account/appaccount/sceneProject/actsaccountsceneappaccess/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..7a88763ed8d2ac31dd30211b9574f47273e84549 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountsceneappaccess/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests", +} diff --git a/account/appaccount/sceneProject/actsaccountsceneappaccess/entry/src/main/config.json b/account/appaccount/sceneProject/actsaccountsceneappaccess/entry/src/main/config.json new file mode 100755 index 0000000000000000000000000000000000000000..f0465cae8823a8cdd54b493e92ba4548c45d9b80 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountsceneappaccess/entry/src/main/config.json @@ -0,0 +1,61 @@ +{ + "app": { + "bundleName": "com.example.actsaccountsceneappaccess", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsaccountsceneappaccess", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.actsaccountsceneappaccess.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/sceneProject/actsaccountsceneappaccess/entry/src/main/js/default/app.js b/account/appaccount/sceneProject/actsaccountsceneappaccess/entry/src/main/js/default/app.js new file mode 100755 index 0000000000000000000000000000000000000000..2a68c1992145a976957d7dcdd69a7e9c2e8e9877 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountsceneappaccess/entry/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* + * 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/sceneProject/actsaccountsceneappaccess/entry/src/main/js/default/i18n/en-US.json b/account/appaccount/sceneProject/actsaccountsceneappaccess/entry/src/main/js/default/i18n/en-US.json new file mode 100755 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountsceneappaccess/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/account/appaccount/sceneProject/actsaccountsceneappaccess/entry/src/main/js/default/i18n/zh-CN.json b/account/appaccount/sceneProject/actsaccountsceneappaccess/entry/src/main/js/default/i18n/zh-CN.json new file mode 100755 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountsceneappaccess/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/account/appaccount/sceneProject/actsaccountsceneappaccess/entry/src/main/js/default/pages/index/index.css b/account/appaccount/sceneProject/actsaccountsceneappaccess/entry/src/main/js/default/pages/index/index.css new file mode 100755 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountsceneappaccess/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/account/appaccount/sceneProject/actsaccountsceneappaccess/entry/src/main/js/default/pages/index/index.hml b/account/appaccount/sceneProject/actsaccountsceneappaccess/entry/src/main/js/default/pages/index/index.hml new file mode 100755 index 0000000000000000000000000000000000000000..c45422b42d0bf788a1c2c0eb299a981f07ce8613 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountsceneappaccess/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{title}} + +
diff --git a/account/appaccount/sceneProject/actsaccountsceneappaccess/entry/src/main/js/default/pages/index/index.js b/account/appaccount/sceneProject/actsaccountsceneappaccess/entry/src/main/js/default/pages/index/index.js new file mode 100755 index 0000000000000000000000000000000000000000..adb0bc06b531778a2ae225b4861707c95ab87e0d --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountsceneappaccess/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,42 @@ +/* + * 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: { + }, + onInit() { + this.title = "scene AppAccess"; + }, + 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) + core.execute() + }, + onReady() { + }, +} \ No newline at end of file diff --git a/account/appaccount/sceneProject/actsaccountsceneappaccess/entry/src/main/js/resources/base/element/string.json b/account/appaccount/sceneProject/actsaccountsceneappaccess/entry/src/main/js/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..aeb3adc8d5b81aa6de396b6da1cb1c509eb20895 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountsceneappaccess/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ActsAccountSceneAppAccess" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/account/appaccount/sceneProject/actsaccountsceneappaccess/entry/src/main/js/resources/base/media/icon.png b/account/appaccount/sceneProject/actsaccountsceneappaccess/entry/src/main/js/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/account/appaccount/sceneProject/actsaccountsceneappaccess/entry/src/main/js/resources/base/media/icon.png differ diff --git a/account/appaccount/sceneProject/actsaccountsceneappaccess/signature/openharmony_sx.p7b b/account/appaccount/sceneProject/actsaccountsceneappaccess/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/account/appaccount/sceneProject/actsaccountsceneappaccess/signature/openharmony_sx.p7b differ diff --git a/account/appaccount/sceneProject/actsaccountsceneonoff/BUILD.gn b/account/appaccount/sceneProject/actsaccountsceneonoff/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..7834b5a2114f4eb7281fc8d8d1676d48fae9f533 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountsceneonoff/BUILD.gn @@ -0,0 +1,31 @@ +# 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("ActsAccountSceneOnOff") { + hap_profile = "./entry/src/main/config.json" + 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" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/account/appaccount/sceneProject/actsaccountsceneonoff/Test.json b/account/appaccount/sceneProject/actsaccountsceneonoff/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..7a88763ed8d2ac31dd30211b9574f47273e84549 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountsceneonoff/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests", +} diff --git a/account/appaccount/sceneProject/actsaccountsceneonoff/entry/src/main/config.json b/account/appaccount/sceneProject/actsaccountsceneonoff/entry/src/main/config.json new file mode 100755 index 0000000000000000000000000000000000000000..afe851d9e2dbae23256e3382566e6035bb136dc5 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountsceneonoff/entry/src/main/config.json @@ -0,0 +1,61 @@ +{ + "app": { + "bundleName": "com.example.actsaccountsceneonoff", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsaccountsceneonoff", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.actsaccountsceneonoff.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/sceneProject/actsaccountsceneonoff/entry/src/main/js/default/app.js b/account/appaccount/sceneProject/actsaccountsceneonoff/entry/src/main/js/default/app.js new file mode 100755 index 0000000000000000000000000000000000000000..2a68c1992145a976957d7dcdd69a7e9c2e8e9877 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountsceneonoff/entry/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* + * 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/sceneProject/actsaccountsceneonoff/entry/src/main/js/default/i18n/en-US.json b/account/appaccount/sceneProject/actsaccountsceneonoff/entry/src/main/js/default/i18n/en-US.json new file mode 100755 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountsceneonoff/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/account/appaccount/sceneProject/actsaccountsceneonoff/entry/src/main/js/default/i18n/zh-CN.json b/account/appaccount/sceneProject/actsaccountsceneonoff/entry/src/main/js/default/i18n/zh-CN.json new file mode 100755 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountsceneonoff/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/account/appaccount/sceneProject/actsaccountsceneonoff/entry/src/main/js/default/pages/index/index.css b/account/appaccount/sceneProject/actsaccountsceneonoff/entry/src/main/js/default/pages/index/index.css new file mode 100755 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountsceneonoff/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/account/appaccount/sceneProject/actsaccountsceneonoff/entry/src/main/js/default/pages/index/index.hml b/account/appaccount/sceneProject/actsaccountsceneonoff/entry/src/main/js/default/pages/index/index.hml new file mode 100755 index 0000000000000000000000000000000000000000..c45422b42d0bf788a1c2c0eb299a981f07ce8613 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountsceneonoff/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{title}} + +
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 new file mode 100755 index 0000000000000000000000000000000000000000..2823edb32711c870cc957943ed6ef0f9bc813792 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountsceneonoff/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,84 @@ +/* + * 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 commonevent from '@ohos.commonevent' +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + }, + onInit() { + this.title = "scene on off"; + }, + onShow() { + console.debug("====>change on off scene start===="); + var appAccountManager = account.createAppAccountManager(); + var commonEventSubscribeInfo = { + events: ["account_on_change"] + } + function publishCallback(err){ + console.debug("====>publish call back scene err:" + JSON.stringify(err)); + console.debug("====>scene off start===="); + appAccountManager.off('change', function (){ + console.debug("====>scene off finish===="); + }); + } + function changeOnCallbackFirst(data){ + console.debug("====>receive change 0100 data:" + JSON.stringify(data)); + try{ + if(data[0].owner == "com.example.actsaccountchangeonoff" && data[0].name == "changeonoff_first"){ + var commonEventPublishData = { + data: "SUCCESS" + } + commonevent.publish("account_on_change_first", commonEventPublishData, publishCallback); + }else{ + var commonEventPublishData = { + data: "FAIL" + } + commonevent.publish("account_on_change_first", commonEventPublishData, publishCallback); + } + } + catch(err){ + var commonEventPublishData = { + data: "FAIL" + } + commonevent.publish("account_on_change_first", commonEventPublishData, publishCallback); + } + } + 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: + console.debug("====>receive event 0100 event:" + data.event); + appAccountManager.on('change', ["com.example.actsaccountchangeonoff"], changeOnCallbackFirst); + break; + default: + console.debug("====>receive event enter default===="); + break; + } + + } + var subscriber + commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){ + subscriber = data; + commonevent.subscribe(subscriber, subscriberCallback); + console.debug("====>scene subscribe finish====") + }) + }, + onReady() { + }, +} \ No newline at end of file diff --git a/account/appaccount/sceneProject/actsaccountsceneonoff/entry/src/main/js/resources/base/element/string.json b/account/appaccount/sceneProject/actsaccountsceneonoff/entry/src/main/js/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..aeb3adc8d5b81aa6de396b6da1cb1c509eb20895 --- /dev/null +++ b/account/appaccount/sceneProject/actsaccountsceneonoff/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ActsAccountSceneAppAccess" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/account/appaccount/sceneProject/actsaccountsceneonoff/entry/src/main/js/resources/base/media/icon.png b/account/appaccount/sceneProject/actsaccountsceneonoff/entry/src/main/js/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/account/appaccount/sceneProject/actsaccountsceneonoff/entry/src/main/js/resources/base/media/icon.png differ diff --git a/account/appaccount/sceneProject/actsaccountsceneonoff/signature/openharmony_sx.p7b b/account/appaccount/sceneProject/actsaccountsceneonoff/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/account/appaccount/sceneProject/actsaccountsceneonoff/signature/openharmony_sx.p7b differ diff --git a/account/appaccount/sceneProject/actsscenegetallaccounts/BUILD.gn b/account/appaccount/sceneProject/actsscenegetallaccounts/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..6ec46329b322d82f31bd6c27445a5d2b671d0dc2 --- /dev/null +++ b/account/appaccount/sceneProject/actsscenegetallaccounts/BUILD.gn @@ -0,0 +1,31 @@ +# 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("ActsSceneGetAllAccounts") { + hap_profile = "./entry/src/main/config.json" + 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" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/account/appaccount/sceneProject/actsscenegetallaccounts/Test.json b/account/appaccount/sceneProject/actsscenegetallaccounts/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..7a88763ed8d2ac31dd30211b9574f47273e84549 --- /dev/null +++ b/account/appaccount/sceneProject/actsscenegetallaccounts/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests", +} diff --git a/account/appaccount/sceneProject/actsscenegetallaccounts/entry/src/main/config.json b/account/appaccount/sceneProject/actsscenegetallaccounts/entry/src/main/config.json new file mode 100755 index 0000000000000000000000000000000000000000..96089241228b621b8aa29ebe88db2891a7b296f4 --- /dev/null +++ b/account/appaccount/sceneProject/actsscenegetallaccounts/entry/src/main/config.json @@ -0,0 +1,61 @@ +{ + "app": { + "bundleName": "com.example.actsscenegetallaccounts", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsscenegetallaccounts", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.actsscenegetallaccounts.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/sceneProject/actsscenegetallaccounts/entry/src/main/js/default/app.js b/account/appaccount/sceneProject/actsscenegetallaccounts/entry/src/main/js/default/app.js new file mode 100755 index 0000000000000000000000000000000000000000..2a68c1992145a976957d7dcdd69a7e9c2e8e9877 --- /dev/null +++ b/account/appaccount/sceneProject/actsscenegetallaccounts/entry/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* + * 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/sceneProject/actsscenegetallaccounts/entry/src/main/js/default/i18n/en-US.json b/account/appaccount/sceneProject/actsscenegetallaccounts/entry/src/main/js/default/i18n/en-US.json new file mode 100755 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/account/appaccount/sceneProject/actsscenegetallaccounts/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/account/appaccount/sceneProject/actsscenegetallaccounts/entry/src/main/js/default/i18n/zh-CN.json b/account/appaccount/sceneProject/actsscenegetallaccounts/entry/src/main/js/default/i18n/zh-CN.json new file mode 100755 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/account/appaccount/sceneProject/actsscenegetallaccounts/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/account/appaccount/sceneProject/actsscenegetallaccounts/entry/src/main/js/default/pages/index/index.css b/account/appaccount/sceneProject/actsscenegetallaccounts/entry/src/main/js/default/pages/index/index.css new file mode 100755 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/account/appaccount/sceneProject/actsscenegetallaccounts/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/account/appaccount/sceneProject/actsscenegetallaccounts/entry/src/main/js/default/pages/index/index.hml b/account/appaccount/sceneProject/actsscenegetallaccounts/entry/src/main/js/default/pages/index/index.hml new file mode 100755 index 0000000000000000000000000000000000000000..c45422b42d0bf788a1c2c0eb299a981f07ce8613 --- /dev/null +++ b/account/appaccount/sceneProject/actsscenegetallaccounts/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{title}} + +
diff --git a/account/appaccount/sceneProject/actsscenegetallaccounts/entry/src/main/js/default/pages/index/index.js b/account/appaccount/sceneProject/actsscenegetallaccounts/entry/src/main/js/default/pages/index/index.js new file mode 100755 index 0000000000000000000000000000000000000000..080d2bb3a37e3ec7fa3d30b373404c94887f5dd4 --- /dev/null +++ b/account/appaccount/sceneProject/actsscenegetallaccounts/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,41 @@ +/* + * 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' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + }, + onInit() { + this.title = "scene getAllAccounts"; + }, + onShow() { + console.debug('====>scene getAllAccounts start===='); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat scene manager finish===="); + var enableBundle = "com.example.actsgetallaaccounts"; + console.debug("====>add account scene start===="); + appAccountManager.addAccount("account_name_scene_single", (err)=>{ + console.debug("====>add account scene err:" + JSON.stringify(err)); + appAccountManager.enableAppAccess("account_name_scene_single", enableBundle, (err)=>{ + console.debug("====>enableAppAccess scene err:" + JSON.stringify(err)); + }); + }); + }, + onReady() { + }, +} \ No newline at end of file diff --git a/account/appaccount/sceneProject/actsscenegetallaccounts/entry/src/main/js/resources/base/element/string.json b/account/appaccount/sceneProject/actsscenegetallaccounts/entry/src/main/js/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..6856bf087e9be994199106c55f5980845b1f86ee --- /dev/null +++ b/account/appaccount/sceneProject/actsscenegetallaccounts/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ActsSceneGetAllAccounts" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/account/appaccount/sceneProject/actsscenegetallaccounts/entry/src/main/js/resources/base/media/icon.png b/account/appaccount/sceneProject/actsscenegetallaccounts/entry/src/main/js/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/account/appaccount/sceneProject/actsscenegetallaccounts/entry/src/main/js/resources/base/media/icon.png differ diff --git a/account/appaccount/sceneProject/actsscenegetallaccounts/signature/openharmony_sx.p7b b/account/appaccount/sceneProject/actsscenegetallaccounts/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/account/appaccount/sceneProject/actsscenegetallaccounts/signature/openharmony_sx.p7b differ