diff --git a/account/OsAccountTest_js/BUILD.gn b/account/OsAccountTest_js/BUILD.gn old mode 100755 new mode 100644 index 1029b594c0a6f9d2f463fa61a8b291f8f20625b5..913fece4fe33206ad488c273ec091bc717dfd90f --- a/account/OsAccountTest_js/BUILD.gn +++ b/account/OsAccountTest_js/BUILD.gn @@ -16,16 +16,19 @@ import("//test/xts/tools/build/suite.gni") ohos_js_hap_suite("ActsOsAccountJSApiTest") { hap_profile = "./src/main/config.json" deps = [ - ":osaccount_js_assets", - ":osaccount_resources", + ":hjs_demo_js_assets", + ":hjs_demo_resources", ] certificate_profile = "./signature/openharmony_sx.p7b" hap_name = "ActsOsAccountJSApiTest" } -ohos_js_assets("osaccount_js_assets") { - source_dir = "./src/main/js/default" +ohos_js_assets("hjs_demo_js_assets") { + js2abc = true + hap_profile = "./src/main/config.json" + source_dir = "./src/main/js" } -ohos_resources("osaccount_resources") { + +ohos_resources("hjs_demo_resources") { sources = [ "./src/main/resources" ] hap_profile = "./src/main/config.json" } diff --git a/account/OsAccountTest_js/Test.json b/account/OsAccountTest_js/Test.json old mode 100755 new mode 100644 index 48740b5768136aae5c1833ee57bb1640427d36d1..af6c4fe53face45ac799b79dc9e39a88aed46563 --- a/account/OsAccountTest_js/Test.json +++ b/account/OsAccountTest_js/Test.json @@ -1,9 +1,10 @@ { "description": "Configuration for osaccount js api Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "60000", - "package": "ohos.acts.account.osaccount", + "bundle-name": "ohos.acts.account.osaccount", + "package-name": "ohos.acts.account.osaccount", "shell-timeout": "60000" }, "kits": [ diff --git a/account/OsAccountTest_js/src/main/config.json b/account/OsAccountTest_js/src/main/config.json old mode 100755 new mode 100644 index 92730f17deebfa1fdd9d9bbd4e28b4e48e391666..2ed8950e0d75e5997286b43a59bf1f94b888a755 --- a/account/OsAccountTest_js/src/main/config.json +++ b/account/OsAccountTest_js/src/main/config.json @@ -14,7 +14,9 @@ "deviceConfig": {}, "module": { "package": "ohos.acts.account.osaccount", - "name": ".MyApplication", + "name": ".entry", + "mainAbility": ".MainAbility", + "srcPath":"", "deviceType": [ "phone" ], @@ -38,25 +40,42 @@ ], "abilities": [ { - "visible": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "name": "ohos.acts.account.osaccount.MainAbility", - "icon": "$media:icon", - "description": "$string:mainability_description", - "label": "$string:app_name", - "type": "page", - "launchType": "standard" + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "formsEnabled": false, + "name": ".MainAbility", + "srcLanguage": "js", + "srcPath": "MainAbility", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "label": "$string:MainAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "js", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" } - ], + ], "js": [ { "pages": [ @@ -67,7 +86,21 @@ "designWidth": 720, "autoDesignWidth": false } + }, + { + "pages": [ + "pages/index/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } } - ] + ], + "testRunner": { + "name": "OpenHarmonyTestRunner", + "srcPath": "TestRunner" + } } } diff --git a/account/OsAccountTest_js/src/main/js/default/app.js b/account/OsAccountTest_js/src/main/js/MainAbility/app.js similarity index 100% rename from account/OsAccountTest_js/src/main/js/default/app.js rename to account/OsAccountTest_js/src/main/js/MainAbility/app.js diff --git a/account/OsAccountTest_js/src/main/js/default/i18n/en-US.json b/account/OsAccountTest_js/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from account/OsAccountTest_js/src/main/js/default/i18n/en-US.json rename to account/OsAccountTest_js/src/main/js/MainAbility/i18n/en-US.json diff --git a/account/OsAccountTest_js/src/main/js/default/i18n/zh-CN.json b/account/OsAccountTest_js/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from account/OsAccountTest_js/src/main/js/default/i18n/zh-CN.json rename to account/OsAccountTest_js/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/account/appaccount/actssetchecksyncenable/entry/src/main/js/test/List.test.js b/account/OsAccountTest_js/src/main/js/MainAbility/pages/index/index.css old mode 100755 new mode 100644 similarity index 82% rename from account/appaccount/actssetchecksyncenable/entry/src/main/js/test/List.test.js rename to account/OsAccountTest_js/src/main/js/MainAbility/pages/index/index.css index 1328947d050117acb7c077dcff37e0074b9538af..2334ecfa2c147f276998e82e2c35f62800cfb031 --- a/account/appaccount/actssetchecksyncenable/entry/src/main/js/test/List.test.js +++ b/account/OsAccountTest_js/src/main/js/MainAbility/pages/index/index.css @@ -1,15 +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. - */ -require('./Syncenable.test.js') \ No newline at end of file +/* + * 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. + */ + +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/account/OsAccountTest_js/src/main/js/MainAbility/pages/index/index.hml b/account/OsAccountTest_js/src/main/js/MainAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..267b40ae9f5c40064ab1fd18a43ae425ef789f7d --- /dev/null +++ b/account/OsAccountTest_js/src/main/js/MainAbility/pages/index/index.hml @@ -0,0 +1,19 @@ + +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/account/OsAccountTest_js/src/main/js/MainAbility/pages/index/index.js b/account/OsAccountTest_js/src/main/js/MainAbility/pages/index/index.js new file mode 100755 index 0000000000000000000000000000000000000000..7f41e27f73e2884ed0223a48d5ff696d6913d400 --- /dev/null +++ b/account/OsAccountTest_js/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,30 @@ +/* + * 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 app from '@system.app' + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + }, + onReady() { + }, +} diff --git a/account/OsAccountTest_js/src/main/js/TestAbility/app.js b/account/OsAccountTest_js/src/main/js/TestAbility/app.js new file mode 100644 index 0000000000000000000000000000000000000000..cdc31f3dcf031e2f6a7665d9653e53bb649e21c5 --- /dev/null +++ b/account/OsAccountTest_js/src/main/js/TestAbility/app.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('TestApplication onCreate') + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info("TestApplication onDestroy"); + } +}; diff --git a/account/OsAccountTest_js/src/main/js/TestAbility/i18n/en-US.json b/account/OsAccountTest_js/src/main/js/TestAbility/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..3cb24b374b1d919ca8eac0638f361692b603a900 --- /dev/null +++ b/account/OsAccountTest_js/src/main/js/TestAbility/i18n/en-US.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } +} \ No newline at end of file diff --git a/account/OsAccountTest_js/src/main/js/TestAbility/i18n/zh-CN.json b/account/OsAccountTest_js/src/main/js/TestAbility/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..c804e32c0c3103929baca5617cdac70be11fdba1 --- /dev/null +++ b/account/OsAccountTest_js/src/main/js/TestAbility/i18n/zh-CN.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } +} \ No newline at end of file diff --git a/account/OsAccountTest_js/src/main/js/TestAbility/pages/index/index.css b/account/OsAccountTest_js/src/main/js/TestAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..1ba8e4e82ace01dad36c1279ea520b4903c57e8f --- /dev/null +++ b/account/OsAccountTest_js/src/main/js/TestAbility/pages/index/index.css @@ -0,0 +1,37 @@ +/* + * 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. + */ + +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} + + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} \ No newline at end of file diff --git a/account/OsAccountTest_js/src/main/js/TestAbility/pages/index/index.hml b/account/OsAccountTest_js/src/main/js/TestAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..61ea59d936e5a2971f1ea3d179c44a7f3f596c54 --- /dev/null +++ b/account/OsAccountTest_js/src/main/js/TestAbility/pages/index/index.hml @@ -0,0 +1,21 @@ + + +
+ + {{ $t('strings.hello') }} {{title}} + + +
diff --git a/account/OsAccountTest_js/src/main/js/TestAbility/pages/index/index.js b/account/OsAccountTest_js/src/main/js/TestAbility/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..88b083a7f6b979019d6a2c5ad20b19c5fd43286b --- /dev/null +++ b/account/OsAccountTest_js/src/main/js/TestAbility/pages/index/index.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + } +} + + + diff --git a/account/OsAccountTest_js/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/account/OsAccountTest_js/src/main/js/TestRunner/OpenHarmonyTestRunner.js new file mode 100644 index 0000000000000000000000000000000000000000..c5fa8620ca77d381f20b65a903b833e6e3378c97 --- /dev/null +++ b/account/OsAccountTest_js/src/main/js/TestRunner/OpenHarmonyTestRunner.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package', '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + + export default { + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + }, + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + console.info('debug value : '+debug) + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, (err, data) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + data.stdResult); + console.info('executeShellCommand : data : ' + data.exitCode); + }) + } +}; diff --git a/account/OsAccountTest_js/src/main/js/default/pages/index/index.css b/account/OsAccountTest_js/src/main/js/default/pages/index/index.css deleted file mode 100755 index 6fda792753f2e15f22b529c7b90a82185b2770bf..0000000000000000000000000000000000000000 --- a/account/OsAccountTest_js/src/main/js/default/pages/index/index.css +++ /dev/null @@ -1,9 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.title { - font-size: 100px; -} diff --git a/account/OsAccountTest_js/src/main/js/default/pages/index/index.hml b/account/OsAccountTest_js/src/main/js/default/pages/index/index.hml deleted file mode 100755 index f64b040a5ae394dbaa5e185e1ecd4f4556b92184..0000000000000000000000000000000000000000 --- a/account/OsAccountTest_js/src/main/js/default/pages/index/index.hml +++ /dev/null @@ -1,5 +0,0 @@ -
- - {{ $t('strings.hello') }} {{ title }} - -
diff --git a/account/OsAccountTest_js/src/main/js/default/pages/index/index.js b/account/OsAccountTest_js/src/main/js/default/pages/index/index.js deleted file mode 100755 index e485a7268c3ee81c50468c02d5efa2ebd3e5840b..0000000000000000000000000000000000000000 --- a/account/OsAccountTest_js/src/main/js/default/pages/index/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import app from '@system.app' - -//import {Core, ExpectExtend, ReportExtend, InstrumentLog} from 'deccjsunit/index' -import {Core, ExpectExtend} from 'deccjsunit/index' - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - console.info('onShow finish') - const core = Core.getInstance() - // const instrumentLog = new InstrumentLog({ - // 'id': 'report' - // }) - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - // core.addService('report', instrumentLog) - core.init() - // core.subscribeEvent('spec', instrumentLog) - // core.subscribeEvent('suite', instrumentLog) - // core.subscribeEvent('task', instrumentLog) - - const configService = core.getDefaultService('config') - configService.setConfig(this) - - require('../../test/List.test') - core.execute() - }, - onReady() { - }, -} diff --git a/account/OsAccountTest_js/src/main/js/default/test/OsAccount.test.js b/account/OsAccountTest_js/src/main/js/default/test/OsAccount.test.js deleted file mode 100755 index d96f762ba6f742d0d75de8e05e8f76e7d246df39..0000000000000000000000000000000000000000 --- a/account/OsAccountTest_js/src/main/js/default/test/OsAccount.test.js +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// @ts-nocheck -import {describe, beforeEach, afterEach, it, expect} from 'deccjsunit/index' -import account from '@ohos.account.distributedAccount' - -describe('AccountTest', function () { - beforeEach(function () { - }) - afterEach(function () { - }) - - /** - * @tc.number ActsDistributedAccountDeviceId_0100 - * @tc.name Test query the distribruted id by callback. - * @tc.desc Test distributedAccount.queryOsAccountDistributedInfo API functionality by callback. - */ - it('ActsDistributedAccountDeviceId_0100', 0, async function(done){ - console.log("test query distribtued id start"); - const distributedId = '5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5'; - const accountAbility = account.getDistributedAccountAbility(); - accountAbility.updateOsAccountDistributedInfo( - { - name: 'ZhangSan', - id: '12345', - event: "Ohos.account.event.LOGIN" - }, (err)=>{ - console.log("update distributedInfo err:" + JSON.stringify(err)); - accountAbility.queryOsAccountDistributedInfo((err, distributedInfo)=>{ - console.log("query distributedInfo err:" + JSON.stringify(err)); - console.log("query distributedInfo:" + JSON.stringify(distributedInfo)); - expect(distributedInfo.name).assertEqual('ZhangSan'); - expect(distributedInfo.id).assertEqual(distributedId); - console.log("test query distribtued id end"); - done(); - }) - }) - }) - - /** - * @tc.number SUB_Account_distributedAccount_JS_API_0100 - * @tc.name Test distributedAccount.getDistributedAccountAbility. - * @tc.desc Test distributedAccount.getDistributedAccountAbility API functionality. - */ - it('account_getDistributedAccountAbility_test', 0, function () { - var ret = false; - const accountAbility = account.getDistributedAccountAbility() - if(accountAbility !== null){ - ret = true; - } - expect(ret).assertTrue() - }) - - /** - * @tc.number SUB_Account_distributedAccount_JS_API_0200 - * @tc.name Test distributedAccount.queryOsAccountDistributedInfo. - * @tc.desc Test distributedAccount.queryOsAccountDistributedInfo API functionality. - */ - it('account_queryOsAccountDistributedInfo_test001', 0, function () { - const accountAbility = account.getDistributedAccountAbility() - accountAbility.queryOsAccountDistributedInfo().then(function (data) { - expect(data.name).assertEqual('anonymous') - }); - }) - - /** - * @tc.number SUB_Account_distributedAccount_JS_API_0300 - * @tc.name Test distributedAccount.queryOsAccountDistributedInfo by callback. - * @tc.desc Test distributedAccount.queryOsAccountDistributedInfo API functionality by callback. - */ - it('account_queryOsAccountDistributedInfo_test002', 0, function () { - const accountAbility = account.getDistributedAccountAbility() - accountAbility.queryOsAccountDistributedInfo(function (data) { - expect(data.name).assertEqual('anonymous') - }); - }) - - /** - * @tc.number SUB_Account_distributedAccount_JS_API_0400 - * @tc.name Test distributedAccount.updateOsAccountDistributedInfo. - * @tc.desc Test distributedAccount.updateOsAccountDistributedInfo API functionality. - */ - it('account_updateOsAccountDistributedInfo_test001', 0, function () { - const accountAbility = account.getDistributedAccountAbility() - let data = null - let obj = { - id: '12345', - name: 'ZhangSan', - event: 'Ohos.account.event.LOGIN', - scalableData:data - }; - accountAbility.updateOsAccountDistributedInfo(obj).then(function (result) { - expect(result).assertTrue() - accountAbility.queryOsAccountDistributedInfo(function (data) { - expect(data.name).assertEqual('ZhangSan') - expect(data.id).assertEqual('12345') - let obj = { - id: '12345', - name: 'ZhangSan', - event: 'Ohos.account.event.LOGOUT' - }; - accountAbility.updateOsAccountDistributedInfo(obj).then(function (result) { - expect(result).assertTrue() - }); - }); - }); - accountAbility.queryOsAccountDistributedInfo(function (data) { - execpt(data).assertNull() - }) - }) - - /** - * @tc.number SUB_Account_distributedAccount_JS_API_0500 - * @tc.name Test distributedAccount.updateOsAccountDistributedInfo by callback. - * @tc.desc Test distributedAccount.updateOsAccountDistributedInfo API functionality by callback. - */ - it('account_updateOsAccountDistributedInfo_test002', 0, function () { - let data = null - const accountAbility = account.getDistributedAccountAbility() - let obj = { - id: '12345', - name: 'ZhangSan', - event: 'Ohos.account.event.LOGIN', - scalableData:data - }; - accountAbility.updateOsAccountDistributedInfo(obj, function (result) { - expect(result).assertTrue() - accountAbility.queryOsAccountDistributedInfo(function (data) { - expect(data.name).assertEqual('ZhangSan') - expect(data.id).assertEqual('12345') - const accountAbility = account.getDistributedAccountAbility() - let obj = { - id: '12345', - name: 'ZhangSan', - event: 'Ohos.account.event.LOGOUT' - - }; - accountAbility.updateOsAccountDistributedInfo(obj).then(function (result) { - expect(result).assertTrue() - }); - }); - }); - }) - - /** - * @tc.number SUB_Account_distributedAccount_JS_API_0300 - * @tc.name Test distributedAccount.updateOsAccountDistributedInfo by callback. - * @tc.desc Test distributedAccount.updateOsAccountDistributedInfo API functionality by callback. - */ - it('account_updateOsAccountDistributedInfo_test003', 0, function () { - const accountAbility = account.getDistributedAccountAbility() - let data = null - let obj = { - id: '12345', - name: 'ZhangSan', - event: 'Ohos.account.event.TOKEN_INVALID', - scalableData:data - }; - accountAbility.updateOsAccountDistributedInfo(obj, function (result) { - expect(result).assertTrue() - accountAbility.queryOsAccountDistributedInfo(obj).then(function (data) { - except(data.name).assertNull() - }) - }); - }) - - /** - * @tc.number SUB_Account_distributedAccount_JS_API_0500 - * @tc.name Test distributedAccount.updateOsAccountDistributedInfo by callback. - * @tc.desc Test distributedAccount.updateOsAccountDistributedInfo API functionality by callback. - */ - it('account_updateOsAccountDistributedInfo_test004', 0, function () { - const accountAbility = account.getDistributedAccountAbility() - let data = null - let obj = { - id: '12345', - name: 'ZhangSan', - event: 'Ohos.account.event.LOGIN', - scalableData:data - }; - accountAbility.updateOsAccountDistributedInfo(obj, function (result) { - expect(result).assertTrue() - accountAbility.queryOsAccountDistributedInfo(function (data) { - expect(data.name).assertEqual('ZhangSan') - expect(data.id).assertEqual('12345') - const accountAbility = account.getDistributedAccountAbility() - let obj = { - id: '12345', - name: 'ZhangSan', - event: 'Ohos.account.event.LOGOFF' - - }; - accountAbility.updateOsAccountDistributedInfo(obj).then(function (result) { - expect(result).assertNull() - }); - }); - }); - }) -}) diff --git a/account/OsAccountTest_js/src/main/js/default/test/List.test.js b/account/OsAccountTest_js/src/main/js/test/List.test.js similarity index 83% rename from account/OsAccountTest_js/src/main/js/default/test/List.test.js rename to account/OsAccountTest_js/src/main/js/test/List.test.js index facd38d5b5e9961a17599ef0c071af933f7a7d2a..90369e959345b4af6b635a17fd0a32efcb042cf3 100755 --- a/account/OsAccountTest_js/src/main/js/default/test/List.test.js +++ b/account/OsAccountTest_js/src/main/js/test/List.test.js @@ -12,5 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import AccountTest from './OsAccount.test.js' -require('./OsAccount.test.js') \ No newline at end of file +export default function testsuite() { + AccountTest() +} \ No newline at end of file diff --git a/account/OsAccountTest_js/src/main/js/test/OsAccount.test.js b/account/OsAccountTest_js/src/main/js/test/OsAccount.test.js new file mode 100755 index 0000000000000000000000000000000000000000..72b910a1219bb36c609744905a1814c08308005f --- /dev/null +++ b/account/OsAccountTest_js/src/main/js/test/OsAccount.test.js @@ -0,0 +1,214 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// @ts-nocheck +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +import account from '@ohos.account.distributedAccount' +export default function AccountTest() { + describe('AccountTest', function () { + beforeEach(function () { + }) + afterEach(function () { + }) + + /** + * @tc.number ActsDistributedAccountDeviceId_0100 + * @tc.name Test query the distribruted id by callback. + * @tc.desc Test distributedAccount.queryOsAccountDistributedInfo API functionality by callback. + */ + it('ActsDistributedAccountDeviceId_0100', 0, async function(done){ + console.log("test query distribtued id start"); + const distributedId = '5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5'; + const accountAbility = account.getDistributedAccountAbility(); + accountAbility.updateOsAccountDistributedInfo( + { + name: 'ZhangSan', + id: '12345', + event: "Ohos.account.event.LOGIN" + }, (err)=>{ + console.log("update distributedInfo err:" + JSON.stringify(err)); + accountAbility.queryOsAccountDistributedInfo((err, distributedInfo)=>{ + console.log("query distributedInfo err:" + JSON.stringify(err)); + console.log("query distributedInfo:" + JSON.stringify(distributedInfo)); + expect(distributedInfo.name).assertEqual('ZhangSan'); + expect(distributedInfo.id).assertEqual(distributedId); + console.log("test query distribtued id end"); + done(); + }) + }) + }) + + /** + * @tc.number SUB_Account_distributedAccount_JS_API_0100 + * @tc.name Test distributedAccount.getDistributedAccountAbility. + * @tc.desc Test distributedAccount.getDistributedAccountAbility API functionality. + */ + it('account_getDistributedAccountAbility_test', 0, function () { + var ret = false; + const accountAbility = account.getDistributedAccountAbility() + if(accountAbility !== null){ + ret = true; + } + expect(ret).assertTrue() + }) + + /** + * @tc.number SUB_Account_distributedAccount_JS_API_0200 + * @tc.name Test distributedAccount.queryOsAccountDistributedInfo. + * @tc.desc Test distributedAccount.queryOsAccountDistributedInfo API functionality. + */ + it('account_queryOsAccountDistributedInfo_test001', 0, function () { + const accountAbility = account.getDistributedAccountAbility() + accountAbility.queryOsAccountDistributedInfo().then(function (data) { + expect(data.name).assertEqual('anonymous') + }); + }) + + /** + * @tc.number SUB_Account_distributedAccount_JS_API_0300 + * @tc.name Test distributedAccount.queryOsAccountDistributedInfo by callback. + * @tc.desc Test distributedAccount.queryOsAccountDistributedInfo API functionality by callback. + */ + it('account_queryOsAccountDistributedInfo_test002', 0, function () { + const accountAbility = account.getDistributedAccountAbility() + accountAbility.queryOsAccountDistributedInfo(function (data) { + expect(data.name).assertEqual('anonymous') + }); + }) + + /** + * @tc.number SUB_Account_distributedAccount_JS_API_0400 + * @tc.name Test distributedAccount.updateOsAccountDistributedInfo. + * @tc.desc Test distributedAccount.updateOsAccountDistributedInfo API functionality. + */ + it('account_updateOsAccountDistributedInfo_test001', 0, function () { + const accountAbility = account.getDistributedAccountAbility() + let data = null + let obj = { + id: '12345', + name: 'ZhangSan', + event: 'Ohos.account.event.LOGIN', + scalableData:data + }; + accountAbility.updateOsAccountDistributedInfo(obj).then(function (result) { + expect(result).assertTrue() + accountAbility.queryOsAccountDistributedInfo(function (data) { + expect(data.name).assertEqual('ZhangSan') + expect(data.id).assertEqual('12345') + let obj = { + id: '12345', + name: 'ZhangSan', + event: 'Ohos.account.event.LOGOUT' + }; + accountAbility.updateOsAccountDistributedInfo(obj).then(function (result) { + expect(result).assertTrue() + }); + }); + }); + accountAbility.queryOsAccountDistributedInfo(function (data) { + execpt(data).assertNull() + }) + }) + + /** + * @tc.number SUB_Account_distributedAccount_JS_API_0500 + * @tc.name Test distributedAccount.updateOsAccountDistributedInfo by callback. + * @tc.desc Test distributedAccount.updateOsAccountDistributedInfo API functionality by callback. + */ + it('account_updateOsAccountDistributedInfo_test002', 0, function () { + let data = null + const accountAbility = account.getDistributedAccountAbility() + let obj = { + id: '12345', + name: 'ZhangSan', + event: 'Ohos.account.event.LOGIN', + scalableData:data + }; + accountAbility.updateOsAccountDistributedInfo(obj, function (result) { + expect(result).assertTrue() + accountAbility.queryOsAccountDistributedInfo(function (data) { + expect(data.name).assertEqual('ZhangSan') + expect(data.id).assertEqual('12345') + const accountAbility = account.getDistributedAccountAbility() + let obj = { + id: '12345', + name: 'ZhangSan', + event: 'Ohos.account.event.LOGOUT' + + }; + accountAbility.updateOsAccountDistributedInfo(obj).then(function (result) { + expect(result).assertTrue() + }); + }); + }); + }) + + /** + * @tc.number SUB_Account_distributedAccount_JS_API_0300 + * @tc.name Test distributedAccount.updateOsAccountDistributedInfo by callback. + * @tc.desc Test distributedAccount.updateOsAccountDistributedInfo API functionality by callback. + */ + it('account_updateOsAccountDistributedInfo_test003', 0, function () { + const accountAbility = account.getDistributedAccountAbility() + let data = null + let obj = { + id: '12345', + name: 'ZhangSan', + event: 'Ohos.account.event.TOKEN_INVALID', + scalableData:data + }; + accountAbility.updateOsAccountDistributedInfo(obj, function (result) { + expect(result).assertTrue() + accountAbility.queryOsAccountDistributedInfo(obj).then(function (data) { + except(data.name).assertNull() + }) + }); + }) + + /** + * @tc.number SUB_Account_distributedAccount_JS_API_0500 + * @tc.name Test distributedAccount.updateOsAccountDistributedInfo by callback. + * @tc.desc Test distributedAccount.updateOsAccountDistributedInfo API functionality by callback. + */ + it('account_updateOsAccountDistributedInfo_test004', 0, function () { + const accountAbility = account.getDistributedAccountAbility() + let data = null + let obj = { + id: '12345', + name: 'ZhangSan', + event: 'Ohos.account.event.LOGIN', + scalableData:data + }; + accountAbility.updateOsAccountDistributedInfo(obj, function (result) { + expect(result).assertTrue() + accountAbility.queryOsAccountDistributedInfo(function (data) { + expect(data.name).assertEqual('ZhangSan') + expect(data.id).assertEqual('12345') + const accountAbility = account.getDistributedAccountAbility() + let obj = { + id: '12345', + name: 'ZhangSan', + event: 'Ohos.account.event.LOGOFF' + + }; + accountAbility.updateOsAccountDistributedInfo(obj).then(function (result) { + expect(result).assertNull() + }); + }); + }); + }) + }) +} diff --git a/account/OsAccountTest_js/src/main/resources/base/element/string.json b/account/OsAccountTest_js/src/main/resources/base/element/string.json index 14f9c3a9210f78b12caf3b945dc2b2c0f63f7d3d..841f6d1ff59e0fb5088ce9a6f9946adbe98e42be 100755 --- a/account/OsAccountTest_js/src/main/resources/base/element/string.json +++ b/account/OsAccountTest_js/src/main/resources/base/element/string.json @@ -7,6 +7,22 @@ { "name": "mainability_description", "value": "JS_Phone_Empty Feature Ability" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" } ] } \ No newline at end of file diff --git a/account/appaccount/actsaccountpressure/BUILD.gn b/account/appaccount/actsaccountpressure/BUILD.gn index a0f36d00ad5e1d0a2e0cb74aa586ef4bb7ccb640..9845012481fbadcb63822d02e64027d77f69e53f 100644 --- a/account/appaccount/actsaccountpressure/BUILD.gn +++ b/account/appaccount/actsaccountpressure/BUILD.gn @@ -14,7 +14,7 @@ import("//test/xts/tools/build/suite.gni") ohos_js_hap_suite("ActsAccountPressure") { - hap_profile = "./entry/src/main/config.json" + hap_profile = "./src/main/config.json" deps = [ ":hjs_demo_js_assets", ":hjs_demo_resources", @@ -23,9 +23,12 @@ ohos_js_hap_suite("ActsAccountPressure") { hap_name = "ActsAccountPressure" } ohos_js_assets("hjs_demo_js_assets") { - source_dir = "./entry/src/main/js/default" + js2abc = true + hap_profile = "./src/main/config.json" + source_dir = "./src/main/js" } + ohos_resources("hjs_demo_resources") { - sources = [ "./entry/src/main/js/resources" ] - hap_profile = "./entry/src/main/config.json" + sources = [ "./src/main/resources" ] + hap_profile = "./src/main/config.json" } diff --git a/account/appaccount/actsaccountpressure/Test.json b/account/appaccount/actsaccountpressure/Test.json index 6a464d872c47147d07907e0b2936041da9cc4b2e..5d4e86f754ca0b0d3cef84e43bda93dd788d57dd 100644 --- a/account/appaccount/actsaccountpressure/Test.json +++ b/account/appaccount/actsaccountpressure/Test.json @@ -1,10 +1,11 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "1500000", - "package": "com.example.actsaccountpressure", - "shell-timeout": "60000" + "bundle-name": "com.example.actsaccountpressure", + "package-name": "com.example.actsaccountpressure", + "shell-timeout": "1500000" }, "kits": [ { diff --git a/account/appaccount/actsaccountpressure/entry/src/main/js/default/pages/index/index.css b/account/appaccount/actsaccountpressure/entry/src/main/js/default/pages/index/index.css deleted file mode 100644 index 6fda792753f2e15f22b529c7b90a82185b2770bf..0000000000000000000000000000000000000000 --- a/account/appaccount/actsaccountpressure/entry/src/main/js/default/pages/index/index.css +++ /dev/null @@ -1,9 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.title { - font-size: 100px; -} diff --git a/account/appaccount/actsaccountpressure/entry/src/main/js/default/pages/index/index.hml b/account/appaccount/actsaccountpressure/entry/src/main/js/default/pages/index/index.hml deleted file mode 100644 index c45422b42d0bf788a1c2c0eb299a981f07ce8613..0000000000000000000000000000000000000000 --- a/account/appaccount/actsaccountpressure/entry/src/main/js/default/pages/index/index.hml +++ /dev/null @@ -1,5 +0,0 @@ -
- - {{title}} - -
diff --git a/account/appaccount/actsaccountpressure/entry/src/main/js/resources/base/element/string.json b/account/appaccount/actsaccountpressure/entry/src/main/js/resources/base/element/string.json deleted file mode 100644 index fecd7c5d952385ddd11c8e7d344dd67a98b50cc5..0000000000000000000000000000000000000000 --- a/account/appaccount/actsaccountpressure/entry/src/main/js/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "ActsAccountPressure" - }, - { - "name": "mainability_description", - "value": "JS_Phone_Empty Feature Ability" - } - ] -} \ No newline at end of file diff --git a/account/appaccount/actsaccountpressure/entry/src/main/js/test/Pressure.test.js b/account/appaccount/actsaccountpressure/entry/src/main/js/test/Pressure.test.js deleted file mode 100644 index 6a4fb5af6eb477811ffd3084c8d64cf3c458f075..0000000000000000000000000000000000000000 --- a/account/appaccount/actsaccountpressure/entry/src/main/js/test/Pressure.test.js +++ /dev/null @@ -1,786 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import abilityAccessCtrl from '@ohos.abilityAccessCtrl' -import account from '@ohos.account.appAccount' -import bundle from '@ohos.bundle' -import featureAbility from '@ohos.ability.featureAbility' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' - -const STRESSLEVEL = 100; -const TIMEOUT = 300; -const ACCOUNTLIMIT = 1000; -const PERMISSION_USER_SET = 1; -const PERMISSION_USER_NAME = "ohos.permission.DISTRIBUTED_DATASYNC"; -var tokenID = undefined; -describe('ActsAccountPressure', function () { - - beforeAll(async function (done) { - console.debug("====>beforeAll start===="); - var appInfo = await bundle.getApplicationInfo('com.example.actsaccountpressure', 0, 100); - tokenID = appInfo.accessTokenId; - console.debug("accessTokenId" + appInfo.accessTokenId + " bundleName:" + appInfo.bundleName); - var atManager = abilityAccessCtrl.createAtManager(); - var result = await atManager.grantUserGrantedPermission(tokenID, PERMISSION_USER_NAME, PERMISSION_USER_SET); - console.debug("tokenId" + tokenID + " result:" + result); - sleep(2000); - console.debug("====>startAbility start===="); - await featureAbility.startAbility( - { - want: - { - deviceId: "", - bundleName: "com.example.actsaccountsceneappaccess", - abilityName: "com.example.actsaccountsceneappaccess.MainAbility", - action: "action1", - parameters: - {}, - }, - }, - ); - sleep(TIMEOUT); - setTimeout(done(), TIMEOUT); - }); - - function sleep(delay) { - var start = (new Date()).getTime(); - while((new Date()).getTime() - start < delay) { - continue; - } - } - - /* - * @tc.number : ActsAccountPressure_0100 - * @tc.name : Stress test add and delete accounts - * @tc.desc : Stress test to add and delete accounts, and to determine the success of the addition and - * deletion by obtaining the specified application information - */ - it('ActsAccountPressure_0100', 0, async function (done) { - console.debug("====>ActsAccountPressure_0100 start===="); - var appAccountManager = account.createAppAccountManager(); - var selfBundle = "com.example.actsaccountpressure"; - let count; - for (count = 0; count < STRESSLEVEL; count++) { - console.debug("====>addAccount time: " + count); - try{ - await appAccountManager.addAccount("account_pressure_promise"); - sleep(TIMEOUT); - } - catch(err){ - console.error("====>addAccount fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - var data = await appAccountManager.getAllAccounts(selfBundle); - sleep(TIMEOUT); - console.debug("====>getAllAccounts time: " + count); - console.debug('====>getAllAccounts data: ' + JSON.stringify(data)); - expect(typeof data).assertEqual('object'); - expect(data[0].name).assertEqual("account_pressure_promise"); - expect(data[0].owner).assertEqual(selfBundle); - expect(data.length).assertEqual(1); - console.debug("====>deleteAccount time: " + count); - try{ - await appAccountManager.deleteAccount("account_pressure_promise"); - sleep(TIMEOUT); - } - catch(err){ - console.error("====>deleteAccount fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - var dataDel = await appAccountManager.getAllAccounts(selfBundle); - console.debug("====>getAllAccounts time: " + count); - console.debug('====>getAllAccounts dataDel: ' + JSON.stringify(dataDel)); - expect(typeof data).assertEqual('object'); - expect(dataDel.length).assertEqual(0); - if(data.length != 1 || dataDel.length != 0){ - break; - } - sleep(TIMEOUT); - } - console.debug("====>the number of times to complete the stress test is: " + count); - console.debug("====>ActsAccountPressure_0100 end===="); - done(); - }); - - /* - * @tc.number : ActsAccountPressure_0200 - * @tc.name : Stress test add and delete accounts - * @tc.desc : Stress test callback form add and delete accounts - */ - it('ActsAccountPressure_0200', 0, async function (done) { - console.debug("====>ActsAccountPressure_0200 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - let flag = true; - let count = 0; - let STRESSNUM; - if(STRESSLEVEL > ACCOUNTLIMIT){ - STRESSNUM = ACCOUNTLIMIT; - }else{ - STRESSNUM = STRESSLEVEL; - } - for (let i = 0; i < STRESSNUM; i++) { - let accountName = "account_pressure_callback" + i; - sleep(TIMEOUT); - appAccountManager.addAccount(accountName, (err)=>{ - console.debug('====>addAccount name: ' + accountName); - expect(err.code).assertEqual(0); - if(err.code != 0){ - console.error("====>addAccount fail err:" + JSON.stringify(err)); - expect().assertFail(); - flag = false; - done(); - } - sleep(TIMEOUT); - appAccountManager.deleteAccount(accountName, (err)=>{ - console.debug('====>deleteAccount name: ' + accountName); - expect(err.code).assertEqual(0); - if(err.code != 0){ - console.error("====>deleteAccount fail err:" + JSON.stringify(err)); - console.error('====>call function level is: ' + count); - expect().assertFail(); - flag = false; - done(); - } - if (count == STRESSLEVEL - 1) { - count++; - console.debug("====>the number of times to complete the stress test is: " + count); - console.debug("====>ActsAccountPressure_0200 end===="); - done(); - } - count++; - }) - }); - if (!flag) { - done(); - break; - } - } - }); - - /* - * @tc.number : ActsAccountPressure_0300 - * @tc.name : Stress test add and delete accounts - * @tc.desc : Stress testing a large number of adding accounts together and deleting accounts together - */ - it('ActsAccountPressure_0300', 0, async function (done) { - console.debug("====>ActsAccountPressure_0300 start===="); - var appAccountManager = account.createAppAccountManager(); - let count; - let STRESSNUM; - if(STRESSLEVEL > ACCOUNTLIMIT){ - STRESSNUM = ACCOUNTLIMIT; - }else{ - STRESSNUM = STRESSLEVEL; - } - console.debug("====>addAccount start===="); - for (count = 0; count < STRESSNUM; count++) { - let accountName = "account_pressure_limit" + count; - console.debug('====>addAccount name: ' + accountName); - try{ - await appAccountManager.addAccount(accountName); - sleep(TIMEOUT); - } - catch(err){ - console.error("====>addAccount fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - } - if(STRESSNUM == ACCOUNTLIMIT){ - try{ - await appAccountManager.addAccount("account_name_limit"); - console.debug("====>the number of added accounts exceeds the limit===="); - expect().assertFail(); - done(); - } - catch(err){ - console.debug("====>add Account that exceed the limit err:" + JSON.stringify(err)); - expect(err.code != 0).assertEqual(true); - console.debug("====>deleteAccount start===="); - for (count = 0; count < STRESSNUM; count++) { - let accountName = "account_pressure_limit" + count; - console.debug('====>deleteAccount name: ' + accountName); - try{ - await appAccountManager.deleteAccount(accountName); - sleep(TIMEOUT); - } - catch(err){ - console.error("====>deleteAccount fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - } - console.debug("====>the number of times to complete the stress test is: " + count) - console.debug("====>ActsAccountPressure_0300 end===="); - done(); - } - }else{ - console.debug("====>deleteAccount start===="); - for (count = 0; count < STRESSNUM; count++) { - let accountName = "account_pressure_limit" + count; - console.debug('====>deleteAccount name: ' + accountName); - try{ - await appAccountManager.deleteAccount(accountName); - sleep(TIMEOUT); - } - catch(err){ - console.error("====>deleteAccount fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - } - console.debug("====>the number of times to complete the stress test is: " + count) - console.debug("====>ActsAccountPressure_0300 end===="); - done(); - } - }); - - /* - * @tc.number : ActsAccountPressure_0400 - * @tc.name : Stress test enableAppAccess and disableAppAccess - * @tc.desc : Stress test authorize the account to the application and de-authorize the account to the - * application - */ - it('ActsAccountPressure_0400', 0, async function (done) { - console.debug("====>ActsAccountPressure_0400 start===="); - var appAccountManager = account.createAppAccountManager(); - var enableBundle = "com.example.actsaccountsceneappaccess"; - let count; - console.debug("====>addAccount 0400 start===="); - try{ - await appAccountManager.addAccount("account_pressure_enable"); - sleep(TIMEOUT); - } - catch(err){ - console.error("====>addAccount fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - for (count = 0; count < STRESSLEVEL; count++) { - console.debug("====>enableAppAccess time: " + count); - try{ - await appAccountManager.enableAppAccess("account_pressure_enable", enableBundle); - sleep(TIMEOUT); - } - catch(err){ - console.error("====>enableAppAccess 0400 err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>disableAppAccess time: " + count); - try{ - await appAccountManager.disableAppAccess("account_pressure_enable", enableBundle); - sleep(TIMEOUT); - } - catch(err){ - console.error("====>disableAppAccess 0400 err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - } - console.debug("====>deleteAccount 0400 start===="); - try{ - await appAccountManager.deleteAccount("account_pressure_enable"); - sleep(TIMEOUT); - } - catch(err){ - console.error("====>deleteAccount fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>the number of times to complete the stress test is: " + count) - console.debug("====>ActsAccountPressure_0400 end===="); - done(); - }); - - /* - * @tc.number : ActsAccountPressure_0500 - * @tc.name : Stress test setAssociatedData and getAssociatedData - * @tc.desc : Stress test setting associated data and obtaining associated data - */ - it('ActsAccountPressure_0500', 0, async function (done) { - console.debug("====>ActsAccountPressure_0500 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - let count; - let associateKey = ""; - let associateValue = ""; - console.debug("====>add account 0500 start===="); - try{ - await appAccountManager.addAccount("account_pressure_associate"); - sleep(TIMEOUT); - } - catch(err){ - console.error("====>add Account ActsAccountPressure_0500 err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - for (count = 0; count < STRESSLEVEL; count++) { - console.debug("====>setAssociatedData time: " + count); - associateKey = "key_pre" + count; - associateValue = "value_pressure" + count; - try{ - await appAccountManager.setAssociatedData("account_pressure_associate", associateKey, associateValue); - sleep(TIMEOUT); - } - catch(err){ - console.error("====>setAssociatedData ActsAccountPressure_0500 err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>getAssociatedData time: " + count); - try{ - var data = await appAccountManager.getAssociatedData("account_pressure_associate", associateKey); - sleep(TIMEOUT); - } - catch(err){ - console.error("====>getAssociatedData ActsAccountPressure_0500 err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>getAssociatedData data:" + JSON.stringify(data)); - expect(data).assertEqual(associateValue); - } - console.debug("====>deleteAccount 0500 start===="); - try{ - await appAccountManager.deleteAccount("account_pressure_associate"); - sleep(TIMEOUT); - } - catch(err){ - console.error("====>delete account 0500 fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>the number of times to complete the stress test is: " + count) - console.debug("====>ActsAccountPressure_0500 end===="); - done(); - }); - - /* - * @tc.number : ActsAccountPressure_0600 - * @tc.name : Stress test setAccountExtraInfo and getAccountExtraInfo - * @tc.desc : Stress test setting additional information and obtaining additional information - */ - it('ActsAccountPressure_0600', 0, async function (done) { - console.debug("====>ActsAccountPressure_0600 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - let count; - let extraInfo = ""; - console.debug("====>add account 0600 start===="); - try{ - await appAccountManager.addAccount("account_pressure_extrainfo"); - sleep(TIMEOUT); - } - catch(err){ - console.error("====>addAccount 0600 err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - for (count = 0; count < STRESSLEVEL; count++) { - console.debug("====>setAccountExtraInfo time: " + count); - extraInfo = "pressure_extra" + count; - try{ - await appAccountManager.setAccountExtraInfo("account_pressure_extrainfo", extraInfo); - sleep(TIMEOUT); - } - catch(err){ - console.error("====>setAccountExtraInfo 0600 err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>getAccountExtraInfo time: " + count); - try{ - var data = await appAccountManager.getAccountExtraInfo("account_pressure_extrainfo"); - sleep(TIMEOUT); - } - catch(err){ - console.error("====>getAccountExtraInfo 0600 err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>getAccountExtraInfo data:" + JSON.stringify(data)); - expect(data).assertEqual(extraInfo); - } - console.debug("====>delete account 0600 start===="); - try{ - await appAccountManager.deleteAccount("account_pressure_extrainfo"); - sleep(TIMEOUT); - } - catch(err){ - console.error("====>deleteAccount 0600 err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>the number of times to complete the stress test is: " + count) - console.debug("====>ActsAccountPressure_0600 end===="); - done(); - }); - - /* - * @tc.number : ActsAccountPressure_0700 - * @tc.name : Stress test setAccountCredential and getAccountCredential - * @tc.desc : Stress test setting credential and obtaining credential - */ - it('ActsAccountPressure_0700', 0, async function (done) { - console.debug("====>ActsAccountPressure_0700 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - let count; - let credentialType = ""; - let credentialvalue = ""; - console.debug("====>addAccount 0700 start===="); - try{ - await appAccountManager.addAccount("account_credential"); - sleep(TIMEOUT); - } - catch(err){ - console.error("addAccount 0700 err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - for (count = 0; count < STRESSLEVEL; count++) { - console.debug("====>setAccountCredential time: " + count); - credentialType = "pressure_credentialType" + count; - credentialvalue = "pressure_credential" + count; - try{ - await appAccountManager.setAccountCredential("account_credential", credentialType, credentialvalue); - sleep(TIMEOUT); - } - catch(err){ - console.error("setAccountCredential 0700 err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>getAccountCredential time: " + count); - try{ - var data = await appAccountManager.getAccountCredential("account_credential", credentialType); - sleep(TIMEOUT); - } - catch(err){ - console.error("getAccountCredential 0700 err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>getAccountCredential 0700 data:" + JSON.stringify(data)); - expect(data).assertEqual(credentialvalue); - } - console.debug("====>delete account 0700 start===="); - try{ - await appAccountManager.deleteAccount("account_credential"); - sleep(TIMEOUT); - } - catch(err){ - console.error("deleteAccount 0700 err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>the number of times to complete the stress test is: " + count) - console.debug("====>ActsAccountPressure_0700 end===="); - done(); - }); - - // /* - // * @tc.number : ActsAccountPressure_0800 - // * @tc.name : setOAuthToken getOAuthToken and clearOAuthToken - // * @tc.desc : Stress test sets the token, obtains the token and then clears the token - // */ - // it('ActsAccountPressure_0800', 0, async function (done) { - // console.debug("====>ActsAccountPressure_0800 start===="); - // var appAccountManager = account.createAppAccountManager(); - // console.debug("====>creat finish===="); - // let count; - // let oauthToken = ""; - // console.debug("====>addAccount 0800 start===="); - // try{ - // await appAccountManager.addAccount("accountToken_pressure_token"); - // sleep(TIMEOUT); - // } - // catch(err){ - // console.error("addAccount 0800 err:" + JSON.stringify(err)); - // expect().assertFail(); - // done(); - // } - // for (count = 0; count < STRESSLEVEL; count++) { - // console.debug("====>setOAuthToken time: " + count); - // oauthToken = "pressure_token" + count; - // try{ - // await appAccountManager.setOAuthToken("accountToken_pressure_token", oauthToken); - // sleep(TIMEOUT); - // } - // catch(err){ - // console.error("setOAuthToken 0800 err:" + JSON.stringify(err)); - // expect().assertFail(); - // done(); - // } - // console.debug("====>getOAuthToken time: " + count); - // try{ - // var data = await appAccountManager.getOAuthToken("accountToken_pressure_token"); - // sleep(TIMEOUT); - // } - // catch(err){ - // console.error("getOAuthToken 0800 err:" + JSON.stringify(err)); - // expect().assertFail(); - // done(); - // } - // console.debug("====>getOAuthToken data: " + data); - // expect(data).assertEqual(oauthToken); - // console.debug("====>clearOAuthToken time: " + count); - // try{ - // await appAccountManager.clearOAuthToken("accountToken_pressure_token"); - // sleep(TIMEOUT); - // } - // catch(err){ - // console.error("clearOAuthToken 0800 err:" + JSON.stringify(err)); - // expect().assertFail(); - // done(); - // } - // } - // console.debug("====>delete account 0800 start===="); - // try{ - // await appAccountManager.deleteAccount("accountToken_pressure_token"); - // sleep(TIMEOUT); - // } - // catch(err){ - // console.error("deleteAccount 0800 err:" + JSON.stringify(err)); - // expect().assertFail(); - // done(); - // } - // console.debug("====>the number of times to complete the stress test is: " + count); - // console.debug("====>ActsAccountPressure_0800 end===="); - // done(); - // }); - - /* - * @tc.number : ActsAccountPressure_0900 - * @tc.name : Stress test setAppAccountSyncEnable and checkAppAccountSyncEnable - * @tc.desc : Stress test setting synchronization flag and obtaining synchronization flag - */ - it('ActsAccountPressure_0900', 0, async function (done) { - console.debug("====>ActsAccountPressure_0900 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - let count; - console.debug("====>add account 0900 start===="); - try{ - await appAccountManager.addAccount("account_pressure_syncenable"); - } - catch(err){ - console.error("====>add account 0900 fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - for (count = 0; count < STRESSLEVEL; count++) { - console.debug("====>setAppAccountSyncEnable time: " + count); - try{ - await appAccountManager.setAppAccountSyncEnable("account_pressure_syncenable", true); - sleep(TIMEOUT); - } - catch(err){ - console.error("====>setAppAccountSyncEnable 0900 fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>checkAppAccountSyncEnable time: " + count); - try{ - var data = await appAccountManager.checkAppAccountSyncEnable("account_pressure_syncenable"); - sleep(TIMEOUT); - } - catch(err){ - console.error("====>checkAppAccountSyncEnable 0900 fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>checkAppAccountSyncEnable data:" + data); - expect(data).assertEqual(true); - } - console.debug("====>delete account 0900 start===="); - try{ - await appAccountManager.deleteAccount("account_pressure_syncenable"); - } - catch(err){ - console.error("====>delete account 0900 fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>the number of times to complete the stress test is: " + count); - console.debug("====>ActsAccountPressure_0900 end===="); - done(); - }); - - /* - * @tc.number : ActsAccountPressure_1000 - * @tc.name : Stress test getAllAccounts - * @tc.desc : Stress test to obtain specified application information - */ - it('ActsAccountPressure_1000', 0, async function (done) { - console.debug("====>ActsAccountPressure_1000 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - let count; - var specifyBundle = "com.example.actsaccountsceneappaccess"; - for (count = 0; count < STRESSLEVEL; count++) { - console.debug("====>getAllAccounts time: " + count); - try{ - var data = await appAccountManager.getAllAccounts(specifyBundle); - sleep(TIMEOUT); - } - catch(err){ - console.error("====>getAllAccounts 1000 fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>getAllAccounts data: " + JSON.stringify(data)); - expect(data[0].name).assertEqual("account_name_scene_first"); - expect(data[0].owner).assertEqual(specifyBundle); - expect(data[1].name).assertEqual("account_name_scene_second"); - expect(data[1].owner).assertEqual(specifyBundle); - } - console.debug("====>the number of times to complete the stress test is: " + count); - console.debug("====>ActsAccountPressure_1000 end===="); - done(); - }); - - /* - * @tc.number : ActsAccountPressure_1100 - * @tc.name : Stress test getAllAccessibleAccounts - * @tc.desc : Stress test to obtain the application account information and authorized account information - */ - it('ActsAccountPressure_1100', 0, async function (done) { - console.debug("====>ActsAccountPressure_1100 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - let count; - var selfBundle = "com.example.actsaccountpressure"; - var specifyBundle = "com.example.actsaccountsceneappaccess"; - console.debug("====>add account 1100 start===="); - try{ - await appAccountManager.addAccount("account_accessible_first"); - await appAccountManager.addAccount("account_accessible_second"); - } - catch(err){ - console.error("====>add account 1100 fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - for (count = 0; count < STRESSLEVEL; count++) { - console.debug("====>getAllAccounts time: " + count); - try{ - var data = await appAccountManager.getAllAccessibleAccounts(); - sleep(TIMEOUT); - } - catch(err){ - console.error("====>getAllAccounts 1100 fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>getAllAccounts data: " + JSON.stringify(data)); - console.debug("====>getAllAccounts data.length: " + data.length); - expect(data.length).assertEqual(4); - expect(data[0].name).assertEqual("account_name_scene_first"); - expect(data[0].owner).assertEqual(specifyBundle); - expect(data[1].name).assertEqual("account_name_scene_second"); - expect(data[1].owner).assertEqual(specifyBundle); - expect(data[2].name).assertEqual("account_accessible_first"); - expect(data[2].owner).assertEqual(selfBundle); - expect(data[3].name).assertEqual("account_accessible_second"); - expect(data[3].owner).assertEqual(selfBundle); - } - console.debug("====>delete account 1100 start===="); - try{ - await appAccountManager.deleteAccount("account_accessible_first"); - await appAccountManager.deleteAccount("account_accessible_second"); - } - catch(err){ - console.error("====>delete account 1100 fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>the number of times to complete the stress test is: " + count); - console.debug("====>ActsAccountPressure_1100 end===="); - done(); - }); - - /* - * @tc.number : ActsAccountPressure_1200 - * @tc.name : Stress test on and off - * @tc.desc : Stress test receive account information changes - */ - it('ActsAccountPressure_1200', 0, async function (done) { - console.debug("====>ActsAccountPressure_1200 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat appAccountManager finish"); - console.debug("====>add account 1200 start"); - let count; - var countSign = 0; - let changeExtra = ""; - try{ - await appAccountManager.addAccount("account_pressure_onoff"); - } - catch(err){ - console.error("====>add account 1200 fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - function changeOnCallback(data){ - console.debug("====>receive change 1200 data:" + JSON.stringify(data)); - expect(data[0].name).assertEqual("account_pressure_onoff"); - expect(data[0].owner).assertEqual("com.example.actsaccountpressure"); - countSign++; - } - console.debug("====>on ActsAccountPressure_1200 start"); - try{ - appAccountManager.on('change', ["com.example.actsaccountpressure"], changeOnCallback); - } - catch(err){ - console.error("====>on ActsAccountPressure_1200 err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - for (count = 0; count < STRESSLEVEL; count++) { - console.debug("====>change account information time: " + count); - changeExtra = "pressure_extra" + count; - try{ - await appAccountManager.setAccountExtraInfo("account_pressure_onoff", changeExtra); - sleep(TIMEOUT); - } - catch(err){ - console.error("====>setAccountExtraInfo fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - } - console.debug("====>off 1200 start===="); - appAccountManager.off('change', async function (){ - console.debug("====>off enter===="); - console.debug("====>countSign is: " + countSign); - expect(countSign).assertEqual(STRESSLEVEL); - console.debug("====>delete account===="); - try{ - await appAccountManager.deleteAccount("account_pressure_onoff"); - } - catch(err){ - console.error("====>delete account 1200 fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>the number of times to complete the stress test is: " + count); - console.debug("====>ActsAccountPressure_1200 end===="); - done(); - }); - }); -}) \ No newline at end of file diff --git a/account/appaccount/actsaccountpressure/entry/src/main/config.json b/account/appaccount/actsaccountpressure/src/main/config.json similarity index 54% rename from account/appaccount/actsaccountpressure/entry/src/main/config.json rename to account/appaccount/actsaccountpressure/src/main/config.json index a0910dafefb4a0ee9208b0ab4b1cda7fe4508a0e..aaa92454ad11f81d8352d1158023f3578017d526 100644 --- a/account/appaccount/actsaccountpressure/entry/src/main/config.json +++ b/account/appaccount/actsaccountpressure/src/main/config.json @@ -15,7 +15,9 @@ "deviceConfig": {}, "module": { "package": "com.example.actsaccountpressure", - "name": ".MyApplication", + "name": ".entry", + "mainAbility": ".MainAbility", + "srcPath":"", "deviceType": [ "phone" ], @@ -72,36 +74,67 @@ ], "abilities": [ { - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "name": "com.example.actsaccountpressure.MainAbility", - "icon": "$media:icon", - "description": "$string:mainability_description", - "label": "$string:app_name", - "type": "page", - "visible": true, - "launchType": "standard" - } - ], - "js": [ + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "formsEnabled": false, + "name": ".MainAbility", + "srcLanguage": "js", + "srcPath": "MainAbility", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "label": "$string:MainAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + }, { - "pages": [ - "pages/index/index" - ], - "name": "default", - "window": { - "designWidth": 720, - "autoDesignWidth": false - } + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "js", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false } - ] + }, + { + "pages": [ + "pages/index/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "testRunner": { + "name": "OpenHarmonyTestRunner", + "srcPath": "TestRunner" + } } } \ No newline at end of file diff --git a/account/appaccount/actsaccountpressure/entry/src/main/js/default/app.js b/account/appaccount/actsaccountpressure/src/main/js/MainAbility/app.js similarity index 100% rename from account/appaccount/actsaccountpressure/entry/src/main/js/default/app.js rename to account/appaccount/actsaccountpressure/src/main/js/MainAbility/app.js diff --git a/account/appaccount/actsaccountpressure/entry/src/main/js/default/i18n/en-US.json b/account/appaccount/actsaccountpressure/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from account/appaccount/actsaccountpressure/entry/src/main/js/default/i18n/en-US.json rename to account/appaccount/actsaccountpressure/src/main/js/MainAbility/i18n/en-US.json diff --git a/account/appaccount/actsaccountpressure/entry/src/main/js/default/i18n/zh-CN.json b/account/appaccount/actsaccountpressure/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from account/appaccount/actsaccountpressure/entry/src/main/js/default/i18n/zh-CN.json rename to account/appaccount/actsaccountpressure/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/test/List.test.js b/account/appaccount/actsaccountpressure/src/main/js/MainAbility/pages/index/index.css old mode 100755 new mode 100644 similarity index 82% rename from account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/test/List.test.js rename to account/appaccount/actsaccountpressure/src/main/js/MainAbility/pages/index/index.css index 493d3c706514721f75a835604b23f2c48af2941a..2334ecfa2c147f276998e82e2c35f62800cfb031 --- a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/test/List.test.js +++ b/account/appaccount/actsaccountpressure/src/main/js/MainAbility/pages/index/index.css @@ -1,15 +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. - */ -require('./Getallaccessible.test.js') \ No newline at end of file +/* + * 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. + */ + +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/account/appaccount/actsaccountpressure/src/main/js/MainAbility/pages/index/index.hml b/account/appaccount/actsaccountpressure/src/main/js/MainAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..f7fa13538134ab88f502a6d53885f46df315d7bf --- /dev/null +++ b/account/appaccount/actsaccountpressure/src/main/js/MainAbility/pages/index/index.hml @@ -0,0 +1,20 @@ + + +
+ + {{title}} + +
diff --git a/account/appaccount/actsaccountpressure/entry/src/main/js/default/pages/index/index.js b/account/appaccount/actsaccountpressure/src/main/js/MainAbility/pages/index/index.js similarity index 69% rename from account/appaccount/actsaccountpressure/entry/src/main/js/default/pages/index/index.js rename to account/appaccount/actsaccountpressure/src/main/js/MainAbility/pages/index/index.js index 21dce8485e7329da7cc3e28e0fc853048030635f..b96fb1c174d0681ed04e262a5917fc9f5886f502 100644 --- a/account/appaccount/actsaccountpressure/entry/src/main/js/default/pages/index/index.js +++ b/account/appaccount/actsaccountpressure/src/main/js/MainAbility/pages/index/index.js @@ -13,7 +13,6 @@ * 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') @@ -27,19 +26,6 @@ export default { }, onShow() { console.info('onShow finish') - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - core.init() - - const configService = core.getDefaultService('config') - this.timeout = 180000; - configService.setConfig(this) - - require('../../../test/List.test') - core.execute() }, onReady() { }, diff --git a/account/appaccount/actsaccountpressure/src/main/js/TestAbility/app.js b/account/appaccount/actsaccountpressure/src/main/js/TestAbility/app.js new file mode 100644 index 0000000000000000000000000000000000000000..cdc31f3dcf031e2f6a7665d9653e53bb649e21c5 --- /dev/null +++ b/account/appaccount/actsaccountpressure/src/main/js/TestAbility/app.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('TestApplication onCreate') + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info("TestApplication onDestroy"); + } +}; diff --git a/account/appaccount/actsaccountpressure/src/main/js/TestAbility/i18n/en-US.json b/account/appaccount/actsaccountpressure/src/main/js/TestAbility/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..3cb24b374b1d919ca8eac0638f361692b603a900 --- /dev/null +++ b/account/appaccount/actsaccountpressure/src/main/js/TestAbility/i18n/en-US.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } +} \ No newline at end of file diff --git a/account/appaccount/actsaccountpressure/src/main/js/TestAbility/i18n/zh-CN.json b/account/appaccount/actsaccountpressure/src/main/js/TestAbility/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..c804e32c0c3103929baca5617cdac70be11fdba1 --- /dev/null +++ b/account/appaccount/actsaccountpressure/src/main/js/TestAbility/i18n/zh-CN.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } +} \ No newline at end of file diff --git a/account/appaccount/actsaccountpressure/src/main/js/TestAbility/pages/index/index.css b/account/appaccount/actsaccountpressure/src/main/js/TestAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..2b45eb97c17e67ef5d63436aad8998113aa95d6d --- /dev/null +++ b/account/appaccount/actsaccountpressure/src/main/js/TestAbility/pages/index/index.css @@ -0,0 +1,50 @@ +/* + * 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. + */ + +.container { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + left: 0px; + top: 0px; + width: 100%; + height: 100%; +} + +.title { + font-size: 60px; + text-align: center; + width: 100%; + height: 40%; + margin: 10px; +} +.btn { + width: 50%; + height: 100px; + font-size: 40px; +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} \ No newline at end of file diff --git a/account/appaccount/actsaccountpressure/src/main/js/TestAbility/pages/index/index.hml b/account/appaccount/actsaccountpressure/src/main/js/TestAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..61ea59d936e5a2971f1ea3d179c44a7f3f596c54 --- /dev/null +++ b/account/appaccount/actsaccountpressure/src/main/js/TestAbility/pages/index/index.hml @@ -0,0 +1,21 @@ + + +
+ + {{ $t('strings.hello') }} {{title}} + + +
diff --git a/account/appaccount/actsaccountpressure/src/main/js/TestAbility/pages/index/index.js b/account/appaccount/actsaccountpressure/src/main/js/TestAbility/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..88b083a7f6b979019d6a2c5ad20b19c5fd43286b --- /dev/null +++ b/account/appaccount/actsaccountpressure/src/main/js/TestAbility/pages/index/index.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + } +} + + + diff --git a/account/appaccount/actsaccountpressure/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/account/appaccount/actsaccountpressure/src/main/js/TestRunner/OpenHarmonyTestRunner.js new file mode 100644 index 0000000000000000000000000000000000000000..c5fa8620ca77d381f20b65a903b833e6e3378c97 --- /dev/null +++ b/account/appaccount/actsaccountpressure/src/main/js/TestRunner/OpenHarmonyTestRunner.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package', '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + + export default { + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + }, + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + console.info('debug value : '+debug) + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, (err, data) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + data.stdResult); + console.info('executeShellCommand : data : ' + data.exitCode); + }) + } +}; diff --git a/account/appaccount/actsgetallaccounts/entry/src/main/js/test/List.test.js b/account/appaccount/actsaccountpressure/src/main/js/test/List.test.js old mode 100755 new mode 100644 similarity index 83% rename from account/appaccount/actsgetallaccounts/entry/src/main/js/test/List.test.js rename to account/appaccount/actsaccountpressure/src/main/js/test/List.test.js index 8f39a18e324168ee07643339e39f59a584904a09..f90121363ea7b92df4b5a29340263366bc9064da --- a/account/appaccount/actsgetallaccounts/entry/src/main/js/test/List.test.js +++ b/account/appaccount/actsaccountpressure/src/main/js/test/List.test.js @@ -1,15 +1,19 @@ -/* - * 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('./Getallaccounts.test.js') \ No newline at end of file +/* + * 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 ActsAccountPressure from './Pressure.test.js' + +export default function testsuite() { + ActsAccountPressure() +} \ No newline at end of file diff --git a/account/appaccount/actsaccountpressure/src/main/js/test/Pressure.test.js b/account/appaccount/actsaccountpressure/src/main/js/test/Pressure.test.js new file mode 100644 index 0000000000000000000000000000000000000000..088c549ace308448dcae1581c42dc496ede5ab7f --- /dev/null +++ b/account/appaccount/actsaccountpressure/src/main/js/test/Pressure.test.js @@ -0,0 +1,788 @@ +/* + * 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 abilityAccessCtrl from '@ohos.abilityAccessCtrl' +import account from '@ohos.account.appAccount' +import bundle from '@ohos.bundle' +import featureAbility from '@ohos.ability.featureAbility' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +const STRESSLEVEL = 100; +const TIMEOUT = 300; +const ACCOUNTLIMIT = 1000; +const PERMISSION_USER_SET = 1; +const PERMISSION_USER_NAME = "ohos.permission.DISTRIBUTED_DATASYNC"; +var tokenID = undefined; +export default function ActsAccountPressure() { + describe('ActsAccountPressure', function () { + + beforeAll(async function (done) { + console.debug("====>beforeAll start===="); + var appInfo = await bundle.getApplicationInfo('com.example.actsaccountpressure', 0, 100); + tokenID = appInfo.accessTokenId; + console.debug("accessTokenId" + appInfo.accessTokenId + " bundleName:" + appInfo.bundleName); + var atManager = abilityAccessCtrl.createAtManager(); + var result = await atManager.grantUserGrantedPermission(tokenID, PERMISSION_USER_NAME, PERMISSION_USER_SET); + console.debug("tokenId" + tokenID + " result:" + result); + sleep(2000); + console.debug("====>startAbility start===="); + await featureAbility.startAbility( + { + want: + { + deviceId: "", + bundleName: "com.example.actsaccountsceneappaccess", + abilityName: "com.example.actsaccountsceneappaccess.MainAbility", + action: "action1", + parameters: + {}, + }, + }, + ); + sleep(TIMEOUT); + setTimeout(done(), TIMEOUT); + }); + + function sleep(delay) { + var start = (new Date()).getTime(); + while((new Date()).getTime() - start < delay) { + continue; + } + } + + /* + * @tc.number : ActsAccountPressure_0100 + * @tc.name : Stress test add and delete accounts + * @tc.desc : Stress test to add and delete accounts, and to determine the success of the addition and + * deletion by obtaining the specified application information + */ + it('ActsAccountPressure_0100', 0, async function (done) { + console.debug("====>ActsAccountPressure_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + var selfBundle = "com.example.actsaccountpressure"; + let count; + for (count = 0; count < STRESSLEVEL; count++) { + console.debug("====>addAccount time: " + count); + try{ + await appAccountManager.addAccount("account_pressure_promise"); + sleep(TIMEOUT); + } + catch(err){ + console.error("====>addAccount fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + var data = await appAccountManager.getAllAccounts(selfBundle); + sleep(TIMEOUT); + console.debug("====>getAllAccounts time: " + count); + console.debug('====>getAllAccounts data: ' + JSON.stringify(data)); + expect(typeof data).assertEqual('object'); + expect(data[0].name).assertEqual("account_pressure_promise"); + expect(data[0].owner).assertEqual(selfBundle); + expect(data.length).assertEqual(1); + console.debug("====>deleteAccount time: " + count); + try{ + await appAccountManager.deleteAccount("account_pressure_promise"); + sleep(TIMEOUT); + } + catch(err){ + console.error("====>deleteAccount fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + var dataDel = await appAccountManager.getAllAccounts(selfBundle); + console.debug("====>getAllAccounts time: " + count); + console.debug('====>getAllAccounts dataDel: ' + JSON.stringify(dataDel)); + expect(typeof data).assertEqual('object'); + expect(dataDel.length).assertEqual(0); + if(data.length != 1 || dataDel.length != 0){ + break; + } + sleep(TIMEOUT); + } + console.debug("====>the number of times to complete the stress test is: " + count); + console.debug("====>ActsAccountPressure_0100 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountPressure_0200 + * @tc.name : Stress test add and delete accounts + * @tc.desc : Stress test callback form add and delete accounts + */ + it('ActsAccountPressure_0200', 0, async function (done) { + console.debug("====>ActsAccountPressure_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + let flag = true; + let count = 0; + let STRESSNUM; + if(STRESSLEVEL > ACCOUNTLIMIT){ + STRESSNUM = ACCOUNTLIMIT; + }else{ + STRESSNUM = STRESSLEVEL; + } + for (let i = 0; i < STRESSNUM; i++) { + let accountName = "account_pressure_callback" + i; + sleep(TIMEOUT); + appAccountManager.addAccount(accountName, (err)=>{ + console.debug('====>addAccount name: ' + accountName); + expect(err.code).assertEqual(0); + if(err.code != 0){ + console.error("====>addAccount fail err:" + JSON.stringify(err)); + expect().assertFail(); + flag = false; + done(); + } + sleep(TIMEOUT); + appAccountManager.deleteAccount(accountName, (err)=>{ + console.debug('====>deleteAccount name: ' + accountName); + expect(err.code).assertEqual(0); + if(err.code != 0){ + console.error("====>deleteAccount fail err:" + JSON.stringify(err)); + console.error('====>call function level is: ' + count); + expect().assertFail(); + flag = false; + done(); + } + if (count == STRESSLEVEL - 1) { + count++; + console.debug("====>the number of times to complete the stress test is: " + count); + console.debug("====>ActsAccountPressure_0200 end===="); + done(); + } + count++; + }) + }); + if (!flag) { + done(); + break; + } + } + }); + + /* + * @tc.number : ActsAccountPressure_0300 + * @tc.name : Stress test add and delete accounts + * @tc.desc : Stress testing a large number of adding accounts together and deleting accounts together + */ + it('ActsAccountPressure_0300', 0, async function (done) { + console.debug("====>ActsAccountPressure_0300 start===="); + var appAccountManager = account.createAppAccountManager(); + let count; + let STRESSNUM; + if(STRESSLEVEL > ACCOUNTLIMIT){ + STRESSNUM = ACCOUNTLIMIT; + }else{ + STRESSNUM = STRESSLEVEL; + } + console.debug("====>addAccount start===="); + for (count = 0; count < STRESSNUM; count++) { + let accountName = "account_pressure_limit" + count; + console.debug('====>addAccount name: ' + accountName); + try{ + await appAccountManager.addAccount(accountName); + sleep(TIMEOUT); + } + catch(err){ + console.error("====>addAccount fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + } + if(STRESSNUM == ACCOUNTLIMIT){ + try{ + await appAccountManager.addAccount("account_name_limit"); + console.debug("====>the number of added accounts exceeds the limit===="); + expect().assertFail(); + done(); + } + catch(err){ + console.debug("====>add Account that exceed the limit err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>deleteAccount start===="); + for (count = 0; count < STRESSNUM; count++) { + let accountName = "account_pressure_limit" + count; + console.debug('====>deleteAccount name: ' + accountName); + try{ + await appAccountManager.deleteAccount(accountName); + sleep(TIMEOUT); + } + catch(err){ + console.error("====>deleteAccount fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + } + console.debug("====>the number of times to complete the stress test is: " + count) + console.debug("====>ActsAccountPressure_0300 end===="); + done(); + } + }else{ + console.debug("====>deleteAccount start===="); + for (count = 0; count < STRESSNUM; count++) { + let accountName = "account_pressure_limit" + count; + console.debug('====>deleteAccount name: ' + accountName); + try{ + await appAccountManager.deleteAccount(accountName); + sleep(TIMEOUT); + } + catch(err){ + console.error("====>deleteAccount fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + } + console.debug("====>the number of times to complete the stress test is: " + count) + console.debug("====>ActsAccountPressure_0300 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountPressure_0400 + * @tc.name : Stress test enableAppAccess and disableAppAccess + * @tc.desc : Stress test authorize the account to the application and de-authorize the account to the + * application + */ + it('ActsAccountPressure_0400', 0, async function (done) { + console.debug("====>ActsAccountPressure_0400 start===="); + var appAccountManager = account.createAppAccountManager(); + var enableBundle = "com.example.actsaccountsceneappaccess"; + let count; + console.debug("====>addAccount 0400 start===="); + try{ + await appAccountManager.addAccount("account_pressure_enable"); + sleep(TIMEOUT); + } + catch(err){ + console.error("====>addAccount fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + for (count = 0; count < STRESSLEVEL; count++) { + console.debug("====>enableAppAccess time: " + count); + try{ + await appAccountManager.enableAppAccess("account_pressure_enable", enableBundle); + sleep(TIMEOUT); + } + catch(err){ + console.error("====>enableAppAccess 0400 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>disableAppAccess time: " + count); + try{ + await appAccountManager.disableAppAccess("account_pressure_enable", enableBundle); + sleep(TIMEOUT); + } + catch(err){ + console.error("====>disableAppAccess 0400 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + } + console.debug("====>deleteAccount 0400 start===="); + try{ + await appAccountManager.deleteAccount("account_pressure_enable"); + sleep(TIMEOUT); + } + catch(err){ + console.error("====>deleteAccount fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>the number of times to complete the stress test is: " + count) + console.debug("====>ActsAccountPressure_0400 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountPressure_0500 + * @tc.name : Stress test setAssociatedData and getAssociatedData + * @tc.desc : Stress test setting associated data and obtaining associated data + */ + it('ActsAccountPressure_0500', 0, async function (done) { + console.debug("====>ActsAccountPressure_0500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + let count; + let associateKey = ""; + let associateValue = ""; + console.debug("====>add account 0500 start===="); + try{ + await appAccountManager.addAccount("account_pressure_associate"); + sleep(TIMEOUT); + } + catch(err){ + console.error("====>add Account ActsAccountPressure_0500 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + for (count = 0; count < STRESSLEVEL; count++) { + console.debug("====>setAssociatedData time: " + count); + associateKey = "key_pre" + count; + associateValue = "value_pressure" + count; + try{ + await appAccountManager.setAssociatedData("account_pressure_associate", associateKey, associateValue); + sleep(TIMEOUT); + } + catch(err){ + console.error("====>setAssociatedData ActsAccountPressure_0500 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAssociatedData time: " + count); + try{ + var data = await appAccountManager.getAssociatedData("account_pressure_associate", associateKey); + sleep(TIMEOUT); + } + catch(err){ + console.error("====>getAssociatedData ActsAccountPressure_0500 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAssociatedData data:" + JSON.stringify(data)); + expect(data).assertEqual(associateValue); + } + console.debug("====>deleteAccount 0500 start===="); + try{ + await appAccountManager.deleteAccount("account_pressure_associate"); + sleep(TIMEOUT); + } + catch(err){ + console.error("====>delete account 0500 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>the number of times to complete the stress test is: " + count) + console.debug("====>ActsAccountPressure_0500 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountPressure_0600 + * @tc.name : Stress test setAccountExtraInfo and getAccountExtraInfo + * @tc.desc : Stress test setting additional information and obtaining additional information + */ + it('ActsAccountPressure_0600', 0, async function (done) { + console.debug("====>ActsAccountPressure_0600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + let count; + let extraInfo = ""; + console.debug("====>add account 0600 start===="); + try{ + await appAccountManager.addAccount("account_pressure_extrainfo"); + sleep(TIMEOUT); + } + catch(err){ + console.error("====>addAccount 0600 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + for (count = 0; count < STRESSLEVEL; count++) { + console.debug("====>setAccountExtraInfo time: " + count); + extraInfo = "pressure_extra" + count; + try{ + await appAccountManager.setAccountExtraInfo("account_pressure_extrainfo", extraInfo); + sleep(TIMEOUT); + } + catch(err){ + console.error("====>setAccountExtraInfo 0600 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAccountExtraInfo time: " + count); + try{ + var data = await appAccountManager.getAccountExtraInfo("account_pressure_extrainfo"); + sleep(TIMEOUT); + } + catch(err){ + console.error("====>getAccountExtraInfo 0600 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAccountExtraInfo data:" + JSON.stringify(data)); + expect(data).assertEqual(extraInfo); + } + console.debug("====>delete account 0600 start===="); + try{ + await appAccountManager.deleteAccount("account_pressure_extrainfo"); + sleep(TIMEOUT); + } + catch(err){ + console.error("====>deleteAccount 0600 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>the number of times to complete the stress test is: " + count) + console.debug("====>ActsAccountPressure_0600 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountPressure_0700 + * @tc.name : Stress test setAccountCredential and getAccountCredential + * @tc.desc : Stress test setting credential and obtaining credential + */ + it('ActsAccountPressure_0700', 0, async function (done) { + console.debug("====>ActsAccountPressure_0700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + let count; + let credentialType = ""; + let credentialvalue = ""; + console.debug("====>addAccount 0700 start===="); + try{ + await appAccountManager.addAccount("account_credential"); + sleep(TIMEOUT); + } + catch(err){ + console.error("addAccount 0700 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + for (count = 0; count < STRESSLEVEL; count++) { + console.debug("====>setAccountCredential time: " + count); + credentialType = "pressure_credentialType" + count; + credentialvalue = "pressure_credential" + count; + try{ + await appAccountManager.setAccountCredential("account_credential", credentialType, credentialvalue); + sleep(TIMEOUT); + } + catch(err){ + console.error("setAccountCredential 0700 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAccountCredential time: " + count); + try{ + var data = await appAccountManager.getAccountCredential("account_credential", credentialType); + sleep(TIMEOUT); + } + catch(err){ + console.error("getAccountCredential 0700 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAccountCredential 0700 data:" + JSON.stringify(data)); + expect(data).assertEqual(credentialvalue); + } + console.debug("====>delete account 0700 start===="); + try{ + await appAccountManager.deleteAccount("account_credential"); + sleep(TIMEOUT); + } + catch(err){ + console.error("deleteAccount 0700 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>the number of times to complete the stress test is: " + count) + console.debug("====>ActsAccountPressure_0700 end===="); + done(); + }); + + // /* + // * @tc.number : ActsAccountPressure_0800 + // * @tc.name : setOAuthToken getOAuthToken and clearOAuthToken + // * @tc.desc : Stress test sets the token, obtains the token and then clears the token + // */ + // it('ActsAccountPressure_0800', 0, async function (done) { + // console.debug("====>ActsAccountPressure_0800 start===="); + // var appAccountManager = account.createAppAccountManager(); + // console.debug("====>creat finish===="); + // let count; + // let oauthToken = ""; + // console.debug("====>addAccount 0800 start===="); + // try{ + // await appAccountManager.addAccount("accountToken_pressure_token"); + // sleep(TIMEOUT); + // } + // catch(err){ + // console.error("addAccount 0800 err:" + JSON.stringify(err)); + // expect().assertFail(); + // done(); + // } + // for (count = 0; count < STRESSLEVEL; count++) { + // console.debug("====>setOAuthToken time: " + count); + // oauthToken = "pressure_token" + count; + // try{ + // await appAccountManager.setOAuthToken("accountToken_pressure_token", oauthToken); + // sleep(TIMEOUT); + // } + // catch(err){ + // console.error("setOAuthToken 0800 err:" + JSON.stringify(err)); + // expect().assertFail(); + // done(); + // } + // console.debug("====>getOAuthToken time: " + count); + // try{ + // var data = await appAccountManager.getOAuthToken("accountToken_pressure_token"); + // sleep(TIMEOUT); + // } + // catch(err){ + // console.error("getOAuthToken 0800 err:" + JSON.stringify(err)); + // expect().assertFail(); + // done(); + // } + // console.debug("====>getOAuthToken data: " + data); + // expect(data).assertEqual(oauthToken); + // console.debug("====>clearOAuthToken time: " + count); + // try{ + // await appAccountManager.clearOAuthToken("accountToken_pressure_token"); + // sleep(TIMEOUT); + // } + // catch(err){ + // console.error("clearOAuthToken 0800 err:" + JSON.stringify(err)); + // expect().assertFail(); + // done(); + // } + // } + // console.debug("====>delete account 0800 start===="); + // try{ + // await appAccountManager.deleteAccount("accountToken_pressure_token"); + // sleep(TIMEOUT); + // } + // catch(err){ + // console.error("deleteAccount 0800 err:" + JSON.stringify(err)); + // expect().assertFail(); + // done(); + // } + // console.debug("====>the number of times to complete the stress test is: " + count); + // console.debug("====>ActsAccountPressure_0800 end===="); + // done(); + // }); + + /* + * @tc.number : ActsAccountPressure_0900 + * @tc.name : Stress test setAppAccountSyncEnable and checkAppAccountSyncEnable + * @tc.desc : Stress test setting synchronization flag and obtaining synchronization flag + */ + it('ActsAccountPressure_0900', 0, async function (done) { + console.debug("====>ActsAccountPressure_0900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + let count; + console.debug("====>add account 0900 start===="); + try{ + await appAccountManager.addAccount("account_pressure_syncenable"); + } + catch(err){ + console.error("====>add account 0900 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + for (count = 0; count < STRESSLEVEL; count++) { + console.debug("====>setAppAccountSyncEnable time: " + count); + try{ + await appAccountManager.setAppAccountSyncEnable("account_pressure_syncenable", true); + sleep(TIMEOUT); + } + catch(err){ + console.error("====>setAppAccountSyncEnable 0900 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>checkAppAccountSyncEnable time: " + count); + try{ + var data = await appAccountManager.checkAppAccountSyncEnable("account_pressure_syncenable"); + sleep(TIMEOUT); + } + catch(err){ + console.error("====>checkAppAccountSyncEnable 0900 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>checkAppAccountSyncEnable data:" + data); + expect(data).assertEqual(true); + } + console.debug("====>delete account 0900 start===="); + try{ + await appAccountManager.deleteAccount("account_pressure_syncenable"); + } + catch(err){ + console.error("====>delete account 0900 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>the number of times to complete the stress test is: " + count); + console.debug("====>ActsAccountPressure_0900 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountPressure_1000 + * @tc.name : Stress test getAllAccounts + * @tc.desc : Stress test to obtain specified application information + */ + it('ActsAccountPressure_1000', 0, async function (done) { + console.debug("====>ActsAccountPressure_1000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + let count; + var specifyBundle = "com.example.actsaccountsceneappaccess"; + for (count = 0; count < STRESSLEVEL; count++) { + console.debug("====>getAllAccounts time: " + count); + try{ + var data = await appAccountManager.getAllAccounts(specifyBundle); + sleep(TIMEOUT); + } + catch(err){ + console.error("====>getAllAccounts 1000 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAllAccounts data: " + JSON.stringify(data)); + expect(data[0].name).assertEqual("account_name_scene_first"); + expect(data[0].owner).assertEqual(specifyBundle); + expect(data[1].name).assertEqual("account_name_scene_second"); + expect(data[1].owner).assertEqual(specifyBundle); + } + console.debug("====>the number of times to complete the stress test is: " + count); + console.debug("====>ActsAccountPressure_1000 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountPressure_1100 + * @tc.name : Stress test getAllAccessibleAccounts + * @tc.desc : Stress test to obtain the application account information and authorized account information + */ + it('ActsAccountPressure_1100', 0, async function (done) { + console.debug("====>ActsAccountPressure_1100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + let count; + var selfBundle = "com.example.actsaccountpressure"; + var specifyBundle = "com.example.actsaccountsceneappaccess"; + console.debug("====>add account 1100 start===="); + try{ + await appAccountManager.addAccount("account_accessible_first"); + await appAccountManager.addAccount("account_accessible_second"); + } + catch(err){ + console.error("====>add account 1100 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + for (count = 0; count < STRESSLEVEL; count++) { + console.debug("====>getAllAccounts time: " + count); + try{ + var data = await appAccountManager.getAllAccessibleAccounts(); + sleep(TIMEOUT); + } + catch(err){ + console.error("====>getAllAccounts 1100 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAllAccounts data: " + JSON.stringify(data)); + console.debug("====>getAllAccounts data.length: " + data.length); + expect(data.length).assertEqual(4); + expect(data[0].name).assertEqual("account_name_scene_first"); + expect(data[0].owner).assertEqual(specifyBundle); + expect(data[1].name).assertEqual("account_name_scene_second"); + expect(data[1].owner).assertEqual(specifyBundle); + expect(data[2].name).assertEqual("account_accessible_first"); + expect(data[2].owner).assertEqual(selfBundle); + expect(data[3].name).assertEqual("account_accessible_second"); + expect(data[3].owner).assertEqual(selfBundle); + } + console.debug("====>delete account 1100 start===="); + try{ + await appAccountManager.deleteAccount("account_accessible_first"); + await appAccountManager.deleteAccount("account_accessible_second"); + } + catch(err){ + console.error("====>delete account 1100 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>the number of times to complete the stress test is: " + count); + console.debug("====>ActsAccountPressure_1100 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountPressure_1200 + * @tc.name : Stress test on and off + * @tc.desc : Stress test receive account information changes + */ + it('ActsAccountPressure_1200', 0, async function (done) { + console.debug("====>ActsAccountPressure_1200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add account 1200 start"); + let count; + var countSign = 0; + let changeExtra = ""; + try{ + await appAccountManager.addAccount("account_pressure_onoff"); + } + catch(err){ + console.error("====>add account 1200 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + function changeOnCallback(data){ + console.debug("====>receive change 1200 data:" + JSON.stringify(data)); + expect(data[0].name).assertEqual("account_pressure_onoff"); + expect(data[0].owner).assertEqual("com.example.actsaccountpressure"); + countSign++; + } + console.debug("====>on ActsAccountPressure_1200 start"); + try{ + appAccountManager.on('change', ["com.example.actsaccountpressure"], changeOnCallback); + } + catch(err){ + console.error("====>on ActsAccountPressure_1200 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + for (count = 0; count < STRESSLEVEL; count++) { + console.debug("====>change account information time: " + count); + changeExtra = "pressure_extra" + count; + try{ + await appAccountManager.setAccountExtraInfo("account_pressure_onoff", changeExtra); + sleep(TIMEOUT); + } + catch(err){ + console.error("====>setAccountExtraInfo fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + } + console.debug("====>off 1200 start===="); + appAccountManager.off('change', async function (){ + console.debug("====>off enter===="); + console.debug("====>countSign is: " + countSign); + expect(countSign).assertEqual(STRESSLEVEL); + console.debug("====>delete account===="); + try{ + await appAccountManager.deleteAccount("account_pressure_onoff"); + } + catch(err){ + console.error("====>delete account 1200 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>the number of times to complete the stress test is: " + count); + console.debug("====>ActsAccountPressure_1200 end===="); + done(); + }); + }); + }) +} \ No newline at end of file diff --git a/account/appaccount/actsaccountpressure/src/main/resources/base/element/string.json b/account/appaccount/actsaccountpressure/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..d43be82875dc199de442811300003b9efeeb0a0b --- /dev/null +++ b/account/appaccount/actsaccountpressure/src/main/resources/base/element/string.json @@ -0,0 +1,28 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ActsAccountPressure" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/account/appaccount/actsaccountpressure/entry/src/main/js/resources/base/media/icon.png b/account/appaccount/actsaccountpressure/src/main/resources/base/media/icon.png similarity index 100% rename from account/appaccount/actsaccountpressure/entry/src/main/js/resources/base/media/icon.png rename to account/appaccount/actsaccountpressure/src/main/resources/base/media/icon.png diff --git a/account/appaccount/actsaccounttest/BUILD.gn b/account/appaccount/actsaccounttest/BUILD.gn old mode 100755 new mode 100644 index 0a668834c230e3a7049d4f06c222612f4130d32c..b6bc39e7c29af3ab7435b793fcee3140d45f3962 --- a/account/appaccount/actsaccounttest/BUILD.gn +++ b/account/appaccount/actsaccounttest/BUILD.gn @@ -14,7 +14,7 @@ import("//test/xts/tools/build/suite.gni") ohos_js_hap_suite("ActsAccountTest") { - hap_profile = "./entry/src/main/config.json" + hap_profile = "./src/main/config.json" deps = [ ":hjs_demo_js_assets", ":hjs_demo_resources", @@ -23,9 +23,12 @@ ohos_js_hap_suite("ActsAccountTest") { hap_name = "ActsAccountTest" } ohos_js_assets("hjs_demo_js_assets") { - source_dir = "./entry/src/main/js/default" + js2abc = true + hap_profile = "./src/main/config.json" + source_dir = "./src/main/js" } + ohos_resources("hjs_demo_resources") { - sources = [ "./entry/src/main/js/resources" ] - hap_profile = "./entry/src/main/config.json" + sources = [ "./src/main/resources" ] + hap_profile = "./src/main/config.json" } diff --git a/account/appaccount/actsaccounttest/Test.json b/account/appaccount/actsaccounttest/Test.json old mode 100755 new mode 100644 index 17b543c5327fcf8b77f5f9bcaf4ceb5a5f7e4b9f..f1c6d4fab38faf4864ce2ee01bb311d29a4abee9 --- a/account/appaccount/actsaccounttest/Test.json +++ b/account/appaccount/actsaccounttest/Test.json @@ -1,10 +1,11 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "3000000", - "package": "com.example.actsaccounttest", - "shell-timeout": "60000" + "bundle-name": "com.example.actsaccounttest", + "package-name": "com.example.actsaccounttest", + "shell-timeout": "3000000" }, "kits": [ { 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 deleted file mode 100755 index 6fda792753f2e15f22b529c7b90a82185b2770bf..0000000000000000000000000000000000000000 --- a/account/appaccount/actsaccounttest/entry/src/main/js/default/pages/index/index.css +++ /dev/null @@ -1,9 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.title { - font-size: 100px; -} diff --git a/account/appaccount/actsaccounttest/entry/src/main/js/default/pages/index/index.hml b/account/appaccount/actsaccounttest/entry/src/main/js/default/pages/index/index.hml deleted file mode 100755 index c45422b42d0bf788a1c2c0eb299a981f07ce8613..0000000000000000000000000000000000000000 --- a/account/appaccount/actsaccounttest/entry/src/main/js/default/pages/index/index.hml +++ /dev/null @@ -1,5 +0,0 @@ -
- - {{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 deleted file mode 100755 index c0e5ca01ff4500eb2687d930af32609be8823653..0000000000000000000000000000000000000000 --- a/account/appaccount/actsaccounttest/entry/src/main/js/default/pages/index/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import {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 deleted file mode 100755 index 33e22aa3af86be72867076efc4c950899185b180..0000000000000000000000000000000000000000 --- a/account/appaccount/actsaccounttest/entry/src/main/js/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "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/test/AddAccount.test.js b/account/appaccount/actsaccounttest/entry/src/main/js/test/AddAccount.test.js deleted file mode 100755 index a75498bb2855ac28816f0f6fb52905988c164806..0000000000000000000000000000000000000000 --- a/account/appaccount/actsaccounttest/entry/src/main/js/test/AddAccount.test.js +++ /dev/null @@ -1,646 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import account from '@ohos.account.appAccount' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' - -const NAMELIMIT = 512; -const LENGTHLIMIT = 1024; -describe('ActsAccountAddAccount', function () { - - /* - * @tc.number : ActsAccountAddAccount_0100 - * @tc.name : Add account callback form - * @tc.desc : Add account in callback form without additional information - */ - it('ActsAccountAddAccount_0100', 0, async function (done) { - console.debug("====>ActsAccountAddAccount_0100 start===="); - 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 callback form - * @tc.desc : Add account in callback 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 callback 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 callback form - * @tc.desc : The account name exceeds the length limit of 512 characters - */ - it('ActsAccountAddAccount_0700', 0, async function (done) { - console.debug("====>ActsAccountAddAccount_0700 start===="); - var limitAccountName = ''; - for (var i = 0; i < NAMELIMIT + 1; i++) { - limitAccountName += 't'; - } - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount(limitAccountName, "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 512 characters - */ - it('ActsAccountAddAccount_0800', 0, async function (done) { - console.debug("====>ActsAccountAddAccount_0800 start===="); - var limitAccountName = ''; - for (var i = 0; i < NAMELIMIT + 1; i++) { - limitAccountName += 'n'; - } - var appAccountManager = account.createAppAccountManager(); - try{ - await appAccountManager.addAccount(limitAccountName, "account_extraInfo_promise_fourth"); - expect().assertFail(); - done(); - } - 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 callback form - * @tc.desc : Additional information exceeds the length limit of 1024 characters - */ - it('ActsAccountAddAccount_0900', 0, async function (done) { - console.debug("====>ActsAccountAddAccount_0900 start===="); - var limitAccountExtra = ''; - for (var i = 0; i < LENGTHLIMIT + 1; i++) { - limitAccountExtra += 't'; - } - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_name_callback_fifth", limitAccountExtra, (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 characters - */ - it('ActsAccountAddAccount_1000', 0, async function (done) { - console.debug("====>ActsAccountAddAccount_1000 start===="); - var limitAccountExtra = ''; - for (var i = 0; i < LENGTHLIMIT + 1; i++) { - limitAccountExtra += 'e'; - } - var appAccountManager = account.createAppAccountManager(); - try{ - await appAccountManager.addAccount("account_name_promise_fifth", limitAccountExtra); - } - 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 callback 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 callback 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 callback 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 callback 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 callback 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 callback 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 callback 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(); - } - }); - - /* - * @tc.number : ActsAccountAddAccount_2500 - * @tc.name : Add account callback form - * @tc.desc : The account name reaches the limit of 512 characters - */ - it('ActsAccountAddAccount_2500', 0, async function (done) { - console.debug("====>ActsAccountAddAccount_2500 start===="); - var limitName = ''; - for (var i = 0; i < NAMELIMIT; i++) { - limitName += 't'; - } - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount(limitName, "account_extraInfo_callback", (err)=>{ - console.debug("====>add account ActsAccountAddAccount_2500 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.deleteAccount(limitName, (err)=>{ - console.debug("====>delete Account ActsAccountAddAccount_2500 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountAddAccount_2500 end===="); - done(); - }); - }); - }); - - /* - * @tc.number : ActsAccountAddAccount_2600 - * @tc.name : Add account promise form - * @tc.desc : The account name reaches the limit of 512 characters - */ - it('ActsAccountAddAccount_2600', 0, async function (done) { - console.debug("====>ActsAccountAddAccount_2600 start===="); - var nameLimit = ''; - for (var i = 0; i < NAMELIMIT; i++) { - nameLimit += 't'; - } - var appAccountManager = account.createAppAccountManager(); - console.debug("====>add account ActsAccountAddAccount_2600 start===="); - try{ - await appAccountManager.addAccount(nameLimit, "account_extraInfo_promise"); - } - catch(err){ - console.error("====>add account ActsAccountAddAccount_2600 err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>delete account ActsAccountAddAccount_2600 start===="); - await appAccountManager.deleteAccount(nameLimit); - console.debug("====>ActsAccountAddAccount_2600 end===="); - done(); - }); - - /* - * @tc.number : ActsAccountAddAccount_2700 - * @tc.name : Add account callback form - * @tc.desc : Additional information reaches the limit of 1024 characters - */ - it('ActsAccountAddAccount_2700', 0, async function (done) { - console.debug("====>ActsAccountAddAccount_2700 start===="); - var limitExtra = ''; - for (var i = 0; i < LENGTHLIMIT; i++) { - limitExtra += 't'; - } - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_extra_callback_limit", limitExtra, (err)=>{ - console.debug("====>add account ActsAccountAddAccount_2700 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.deleteAccount("account_extra_callback_limit", (err)=>{ - console.debug("====>delete Account ActsAccountAddAccount_2700 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountAddAccount_2700 end===="); - done(); - }); - }); - }); - - /* - * @tc.number : ActsAccountAddAccount_2800 - * @tc.name : Add account promise form - * @tc.desc : Additional information reaches the limit of 1024 characters - */ - it('ActsAccountAddAccount_2800', 0, async function (done) { - console.debug("====>ActsAccountAddAccount_2800 start===="); - var extraLimit = ''; - for (var i = 0; i < LENGTHLIMIT; i++) { - extraLimit += 't'; - } - var appAccountManager = account.createAppAccountManager(); - try{ - await appAccountManager.addAccount("account_extra_promise_limit", extraLimit); - } - catch(err){ - console.error("====>add account ActsAccountAddAccount_2800 err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>delete account ActsAccountAddAccount_2800 start===="); - appAccountManager.deleteAccount("account_extra_promise_limit"); - console.debug("====>ActsAccountAddAccount_2800 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 deleted file mode 100755 index 900b4951058c5469586cfb06e9a811a24250c904..0000000000000000000000000000000000000000 --- a/account/appaccount/actsaccounttest/entry/src/main/js/test/AppAccess.test.js +++ /dev/null @@ -1,562 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import account from '@ohos.account.appAccount' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' - -const TIMEOUT = 5000; -const STRCOUNT = 1025; -const EACHTIMEOUT = 500; -describe('ActsAccountAppAccess', function () { - function sleep(delay) { - return new Promise((resolve, reject) => { - setTimeout(() => { - resolve() - }, delay) - }).then(() => { - console.info(`sleep #{time} over ...`) - }) - } - - beforeAll(async function (done) { - console.debug("====>beforeAll start===="); - await sleep(TIMEOUT); - console.debug("====>beforeAll end===="); - done(); - }) - - beforeEach(async function (done) { - console.debug("====>beforeEach enter===="); - await sleep(EACHTIMEOUT); - 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===="); - try{ - await appAccountManager.addAccount("AppAccess_promise_account"); - } - catch(err){ - console.error("====>addAccount ActsAccountAppAccess_0800 fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - 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===="); - try{ - await appAccountManager.addAccount("AppAccess_promise_account"); - } - catch(err){ - console.error("====>addAccount ActsAccountAppAccess_1600 fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - 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 deleted file mode 100755 index 570c6c04fcd80c49f9c44a0be7d5a50b602b6afa..0000000000000000000000000000000000000000 --- a/account/appaccount/actsaccounttest/entry/src/main/js/test/AssociatedData.test.js +++ /dev/null @@ -1,1163 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import account from '@ohos.account.appAccount' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' - -const TIMEOUT = 5000; -const EACHTIMEOUT = 500; -describe('ActsAccountAssociatedData', function () { - function sleep(delay) { - return new Promise((resolve, reject) => { - setTimeout(() => { - resolve() - }, delay) - }).then(() => { - console.info(`sleep #{time} over ...`) - }) - } - - beforeAll(async function (done) { - console.debug("====>beforeAll start===="); - await sleep(TIMEOUT); - console.debug("====>beforeAll end===="); - done(); - }) - - beforeEach(async function (done) { - console.debug("====>beforeEach enter===="); - await sleep(EACHTIMEOUT); - 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().assertFail(); - 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().assertFail(); - 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().assertFail(); - 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().assertFail(); - 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().assertFail(); - 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 deleted file mode 100755 index 9ced61338b6d2c0b4cba4eadf816f37886da9b77..0000000000000000000000000000000000000000 --- a/account/appaccount/actsaccounttest/entry/src/main/js/test/CreatManager.test.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import account from '@ohos.account.appAccount' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' - -const TIMEOUT = 5000; -describe('ActsCreatAppAccountManager', function () { - function sleep(delay) { - return new Promise((resolve, reject) => { - setTimeout(() => { - resolve() - }, delay) - }).then(() => { - console.info(`sleep #{time} over ...`) - }) - } - - beforeAll(async function (done) { - console.debug("====>beforeAll start===="); - await 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 deleted file mode 100755 index cf57142461da796fad9cf51db83f4fbd04d9052b..0000000000000000000000000000000000000000 --- a/account/appaccount/actsaccounttest/entry/src/main/js/test/Credential.test.js +++ /dev/null @@ -1,675 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import account from '@ohos.account.appAccount' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' - -const TIMEOUT = 5000; -const EACHTIMEOUT = 500; -describe('ActsAccountCredential', function () { - function sleep(delay) { - return new Promise((resolve, reject) => { - setTimeout(() => { - resolve() - }, delay) - }).then(() => { - console.info(`sleep #{time} over ...`) - }) - } - - beforeAll(async function (done) { - console.debug("====>beforeAll start===="); - await sleep(TIMEOUT); - console.debug("====>beforeAll end===="); - done(); - }) - - beforeEach(async function (done) { - console.debug("====>beforeEach enter===="); - await sleep(EACHTIMEOUT); - 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 deleted file mode 100755 index 254a3daa36ae0c10bb0fb6b59b29156b69c59736..0000000000000000000000000000000000000000 --- a/account/appaccount/actsaccounttest/entry/src/main/js/test/DeleteAccount.test.js +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import account from '@ohos.account.appAccount' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' - -const NAMELIMIT = 512; -const TIMEOUT = 5000; -describe('ActsAccountDeleteAccount', function () { - function sleep(delay) { - return new Promise((resolve, reject) => { - setTimeout(() => { - resolve() - }, delay) - }).then(() => { - console.info(`sleep #{time} over ...`) - }) - } - - beforeAll(async function (done) { - console.debug("====>beforeAll start===="); - await sleep(TIMEOUT); - console.debug("====>beforeAll end===="); - done(); - }); - - /* - * @tc.number : ActsAccountDeleteAccount_0100 - * @tc.name : Delete account callback 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 promise form - * @tc.desc : Delete the added account in promise form - */ - it('ActsAccountDeleteAccount_0200',0,async function (done){ - console.debug("====>ActsAccountDeleteAccount_0200 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>add account ActsAccountAddAccount_0200 start===="); - await appAccountManager.addAccount("deleteAccount_name_promise_first","extraInfo_promise_first"); - try{ - await appAccountManager.deleteAccount("deleteAccount_name_promise_first"); - console.debug("====>ActsAccountDeleteAccount_0200 end===="); - done(); - } - catch(err){ - console.error("====>delete account ActsAccountDeleteAccount_0200 err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - }); - - /* - * @tc.number : ActsAccountDeleteAccount_0300 - * @tc.name : Delete account callback form - * @tc.desc : Delete unadded account in callback form - */ - it('ActsAccountDeleteAccount_0300', 0, async function (done) { - console.debug("====>ActsAccountDeleteAccount_0300 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - appAccountManager.deleteAccount("deleteAccount_name_callback_second", (err)=>{ - console.debug("====>delete Account ActsAccountDeleteAccount_0300 err:" + JSON.stringify(err)); - expect(err.code != 0).assertEqual(true); - console.debug("====>ActsAccountDeleteAccount_0300 end===="); - done(); - }); - }); - - /* - * @tc.number : ActsAccountDeleteAccount_0400 - * @tc.name : Delete account promise form - * @tc.desc : Delete unadded account in promise form - */ - it('ActsAccountDeleteAccount_0400', 0, async function(done){ - console.debug("====>ActsAccountDeleteAccount_0400 start===="); - var appAccountManager = account.createAppAccountManager(); - try{ - await appAccountManager.deleteAccount("deleteAccount_name_promise_second"); - } - catch(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 callback form - * @tc.desc : Delete the added account, the first time it can be deleted, the second time the deletion fails - */ - it('ActsAccountDeleteAccount_0500', 0, async function (done) { - console.debug("====>ActsAccountDeleteAccount_0500 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("deleteAccount_name_callback_third", "extraInfo_callback_third", (err)=>{ - console.debug("====>add account ActsAccountDeleteAccount_0500 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_0500 end===="); - done(); - }); - }); - }); - }); - - /* - * @tc.number : ActsAccountDeleteAccount_0600 - * @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_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_third", "extraInfo_promise_third"); - console.debug("====>delete Account first time ActsAccountDeleteAccount_0600 start===="); - await appAccountManager.deleteAccount("deleteAccount_name_promise_third"); - console.debug("====>delete Account second time ActsAccountDeleteAccount_0600 start===="); - try{ - await appAccountManager.deleteAccount("deleteAccount_name_promise_third"); - } - catch(err){ - console.debug("====>delete account ActsAccountDeleteAccount_0600 err:" + JSON.stringify(err)); - expect(err.code != 0).assertEqual(true); - console.debug("====>ActsAccountDeleteAccount_0600 end===="); - done(); - } - }); - - /* - * @tc.number : ActsAccountDeleteAccount_0700 - * @tc.name : Delete account callback form - * @tc.desc : Delete the account name exceeds the length limit of 512 characters - */ - it('ActsAccountDeleteAccount_0700',0, async function (done){ - console.debug("====>ActsAccountDeleteAccount_0700 start===="); - var nameLimit = ''; - for (var i = 0; i < NAMELIMIT + 1; i++) { - nameLimit += 't'; - } - var appAccountManager = account.createAppAccountManager(); - appAccountManager.deleteAccount(nameLimit, (err)=>{ - console.debug("====>delete Account ActsAccountDeleteAccount_0700 err:" + JSON.stringify(err)); - expect(err.code != 0).assertEqual(true); - console.debug("====>ActsAccountDeleteAccount_0700 end===="); - done(); - }); - }); - - /* - * @tc.number : ActsAccountDeleteAccount_0800 - * @tc.name : Delete account promise form - * @tc.desc : Delete the account name exceeds the length limit of 512 characters - */ - it('ActsAccountDeleteAccount_0800', 0, async function (done){ - console.debug("====>ActsAccountDeleteAccount_0800 start===="); - var nameLimit = ''; - for (var i = 0; i < NAMELIMIT + 1; i++) { - nameLimit += 'n'; - } - var appAccountManager = account.createAppAccountManager(); - console.debug("====>delete Account ActsAccountDeleteAccount_0800 start===="); - try{ - await appAccountManager.deleteAccount(nameLimit); - } - catch(err){ - console.debug("====>delete account ActsAccountDeleteAccount_0800 err:" + JSON.stringify(err)); - expect(err.code != 0).assertEqual(true); - console.debug("====>ActsAccountDeleteAccount_0800 end===="); - done(); - } - }) - - /* - * @tc.number : ActsAccountDeleteAccount_0900 - * @tc.name : Delete account callback form - * @tc.desc : Delete the account name is an empty string - */ - it('ActsAccountDeleteAccount_0900',0, async function (done){ - console.debug("====>ActsAccountDeleteAccount_0900 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.deleteAccount("", (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 deleted file mode 100755 index ea6f39de2e901aeda58e721352a6b7ace1844855..0000000000000000000000000000000000000000 --- a/account/appaccount/actsaccounttest/entry/src/main/js/test/ExtraInfo.test.js +++ /dev/null @@ -1,516 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import account from '@ohos.account.appAccount' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' - -const TIMEOUT = 5000; -const EACHTIMEOUT = 500; -describe('ActsAccountSetGetExtraInfo', function () { - function sleep(delay) { - return new Promise((resolve, reject) => { - setTimeout(() => { - resolve() - }, delay) - }).then(() => { - console.info(`sleep #{time} over ...`) - }) - } - - beforeAll(async function (done) { - console.debug("====>beforeAll start===="); - await sleep(TIMEOUT); - console.debug("====>beforeAll end===="); - done(); - }) - - beforeEach(async function (done) { - console.debug("====>beforeEach enter===="); - await sleep(EACHTIMEOUT); - 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 deleted file mode 100755 index b039751f859ec0ffaaacc08539f2a0b61ca9a0f0..0000000000000000000000000000000000000000 --- a/account/appaccount/actsaccounttest/entry/src/main/js/test/List.test.js +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -require('./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') -require('./OnOff.js') \ No newline at end of file diff --git a/account/appaccount/actsaccounttest/entry/src/main/js/test/NoPermission.test.js b/account/appaccount/actsaccounttest/entry/src/main/js/test/NoPermission.test.js deleted file mode 100755 index 754cc16f6bc32efca55542fe35ee67b0571a89b7..0000000000000000000000000000000000000000 --- a/account/appaccount/actsaccounttest/entry/src/main/js/test/NoPermission.test.js +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import account from '@ohos.account.appAccount' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' - -const TIMEOUT = 5000; -const ERR_APPACCOUNT_SERVICE_PERMISSION_DENIED = 4521993; -describe('ActsAccountNoPermission', function () { - function sleep(delay) { - return new Promise((resolve, reject) => { - setTimeout(() => { - resolve() - }, delay) - }).then(() => { - console.info(`sleep #{time} over ...`) - }) - } - beforeAll(async function (done) { - console.debug("====>beforeAll start===="); - await 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(account.ResultCode.ERROR_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(account.ResultCode.ERROR_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(account.ResultCode.ERROR_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(account.ResultCode.ERROR_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(account.ResultCode.ERROR_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(account.ResultCode.ERROR_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.actsaccounttest"; - 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(account.ResultCode.ERROR_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.actsaccounttest"; - 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(account.ResultCode.ERROR_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 deleted file mode 100644 index 320763922dd4ef0157132f2836e95d0eeb832fc0..0000000000000000000000000000000000000000 --- a/account/appaccount/actsaccounttest/entry/src/main/js/test/OAuthToken.test.js +++ /dev/null @@ -1,3420 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import account from '@ohos.account.appAccount' -import resmgr from '@ohos.resourceManager' -import featureAbility from '@ohos.ability.featureAbility' -import {describe, it, expect, beforeAll, beforeEach} from 'deccjsunit/index' - - -const TIMEOUT = 1000; -const EACHTIMEOUT = 500; -const LENGTHLIMIT = 512; -const TOKENLENGTHLIMIT = 1024; -const AUTHTYPELENGTHLIMIT = 1024; -const OWNERLENGTHLIMIT = 1024; - -const OWNERSELF = "com.example.actsaccounttest"; - -describe('ActsAccountOAuthToken', function () { - function sleep(delay) { - return new Promise((resolve, reject) => { - setTimeout(() => { - resolve() - }, delay) - }).then(() => { - console.info(`sleep #{time} over ...`) - }) - } - - beforeAll(async function (done) { - console.debug("====>beforeAll start===="); - await sleep(TIMEOUT); - console.debug("====>beforeAll end===="); - done(); - }); - - beforeEach(async function (done) { - console.debug("====>beforeAll enter===="); - await sleep(EACHTIMEOUT); - done(); - }); - - /* - * @tc.number : testGetEntriesString101 - * @tc.name : Use getEntries get the value by mixing the string key - * @tc.desc : Mixed strings value can be obtained correctly - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 1 - */ - - - it('ActsAccountOAuthToken_9100', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_9100 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_tokenTest_name",(err,)=>{ - console.debug("====>ActsAccountOAuthToken_9100 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_tokenTest_name","authType1","test_token1",(err)=>{ - console.debug("====>ActsAccountOAuthToken_9100 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_tokenTest_name","authType1","test_token2",(err)=>{ - console.debug("====>ActsAccountOAuthToken_9100 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthTokenVisibility("account_tokenTest_name","authType1","other_app_bundleName",true,(err)=>{ - console.debug("====>ActsAccountOAuthToken_9100 setOAuthTokenVisibility err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_tokenTest_name","authType2","test_token2",(err)=>{ - console.debug("====>ActsAccountOAuthToken_9100 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getAllOAuthTokens("account_tokenTest_name", OWNERSELF,(err,ArrayData)=>{ - console.debug("====>ActsAccountOAuthToken_9100 getAllOAuthTokens err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_9100 getAllOAuthTokens ArrayData:" + JSON.stringify(ArrayData)); - expect(err.code).assertEqual(0); - expect(ArrayData.length).assertEqual(2); - appAccountManager.deleteOAuthToken("account_tokenTest_name",OWNERSELF,"authType1","test_token2",(err)=>{ - console.debug("====>ActsAccountOAuthToken_9100 deleteOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getAllOAuthTokens("account_tokenTest_name", OWNERSELF,(err,ArrayData)=>{ - console.debug("====>ActsAccountOAuthToken_9100 getAllOAuthTokens err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_9100 getAllOAuthTokens ArrayData:" + JSON.stringify(ArrayData)); - expect(err.code).assertEqual(0); - expect(ArrayData.length).assertEqual(2); - appAccountManager.deleteAccount("account_tokenTest_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_9100 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_9100 end===="); - done(); - appAccountManager.getOAuthToken("account_tokenTest_name",OWNERSELF,"authType",(err,data)=>{ - console.debug("====>ActsAccountOAuthToken_9100 getOAuthToken err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_9100 getOAuthToken data:" + data); - expect(err.code!=0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_9100 end===="); - done(); - }); - }); - }); - }); - }); - }); - }); - }); - }); - }); - }); - - - it('ActsAccountOAuthToken_9000', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_9000 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_tokenTest_name",(err,)=>{ - console.debug("====>ActsAccountOAuthToken_9000 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_tokenTest_name","authType","test_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_9000 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthToken("account_tokenTest_name",OWNERSELF,"authType",(err,data)=>{ - console.debug("====>ActsAccountOAuthToken_9000 getOAuthToken err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_9000 getOAuthToken data:" + data); - expect(err.code).assertEqual(0); - expect(data).assertEqual("test_token"); - appAccountManager.setOAuthTokenVisibility("account_tokenTest_name","authType","other_app_bundleName",true,(err)=>{ - console.debug("====>ActsAccountOAuthToken_9000 setOAuthTokenVisibility err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthList("account_tokenTest_name","authType",(err,dataArray)=>{ - console.debug("====>ActsAccountOAuthToken_9000 getOAuthList err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_9000 getOAuthList dataArray:" + JSON.stringify(dataArray)); - expect(dataArray.length).assertEqual(1); - expect(dataArray[0]).assertEqual("other_app_bundleName"); - appAccountManager.deleteOAuthToken("account_tokenTest_name",OWNERSELF,"authType","test_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_9000 deleteOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getAllOAuthTokens("account_tokenTest_name", OWNERSELF,(err,ArrayData)=>{ - console.debug("====>ActsAccountOAuthToken_9000 getAllOAuthTokens err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_9000 getAllOAuthTokens ArrayData:" + JSON.stringify(ArrayData)); - expect(err.code).assertEqual(0); - expect(ArrayData.length).assertEqual(1); - expect(ArrayData[0].authType).assertEqual("authType"); - expect(ArrayData[0].token).assertEqual(""); - appAccountManager.setOAuthTokenVisibility("account_tokenTest_name","authType",OWNERSELF,false,(err)=>{ - console.debug("====>ActsAccountOAuthToken_9000 setOAuthTokenVisibility err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthToken("account_tokenTest_name",OWNERSELF,"authType",(err,data)=>{ - console.debug("====>ActsAccountOAuthToken_9000 getOAuthToken err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_9000 getOAuthToken data:" + data); - expect(err.code!=0).assertEqual(true); - expect(data).assertEqual(""); - appAccountManager.deleteAccount("account_tokenTest_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_9000 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_9000 end===="); - done(); - }); - }); - }); - }); - }); - }); - }); - }); - }); - }); - }); - - - - it('ActsAccountOAuthToken_7100', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_7100 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_7100 addAccount start===="); - appAccountManager.addAccount("account_tokenTest_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_7100 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_tokenTest_name","authType1","test_token1",(err)=>{ - console.debug("====>ActsAccountOAuthToken_7100 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_tokenTest_name","authType1","test_token2",(err)=>{ - console.debug("====>ActsAccountOAuthToken_7100 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_tokenTest_name","authType2","test_token2",(err)=>{ - console.debug("====>ActsAccountOAuthToken_7100 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getAllOAuthTokens("account_tokenTest_name", OWNERSELF,(err,ArrayData)=>{ - console.debug("====>ActsAccountOAuthToken_7100 getAllOAuthTokens err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_7100 getAllOAuthTokens ArrayData:" + JSON.stringify(ArrayData)); - expect(err.code).assertEqual(0); - expect(ArrayData.length).assertEqual(2); - expect(ArrayData[0].authType).assertEqual("authType1"); - expect(ArrayData[0].token).assertEqual("test_token2"); - expect(ArrayData[1].authType).assertEqual("authType2"); - expect(ArrayData[1].token).assertEqual("test_token2"); - appAccountManager.deleteOAuthToken("account_tokenTest_name",OWNERSELF,"authType1","test_token2",(err)=>{ - console.debug("====>ActsAccountOAuthToken_7100 deleteOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getAllOAuthTokens("account_tokenTest_name", OWNERSELF,(err,ArrayData)=>{ - console.debug("====>ActsAccountOAuthToken_7100 getAllOAuthTokens err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_7100 getAllOAuthTokens ArrayData:" + JSON.stringify(ArrayData)); - expect(err.code).assertEqual(0); - expect(ArrayData.length).assertEqual(1); - expect(ArrayData[0].authType).assertEqual("authType2"); - expect(ArrayData[0].token).assertEqual("test_token2"); - appAccountManager.deleteAccount("account_tokenTest_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_7100 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthToken("account_tokenTest_name",OWNERSELF,"authType",(err,data)=>{ - console.debug("====>ActsAccountOAuthToken_7100 getOAuthToken err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_7100 getOAuthToken data:" + data); - expect(err.code!=0).assertEqual(true); - expect(data).assertEqual(""); - console.debug("====>ActsAccountOAuthToken_7100 end===="); - done(); - }); - }); - }); - }); - }); - }); - }); - }); - }); - }); - - - it('ActsAccountOAuthToken_7200', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_7200 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_tokenTest_name",(err,)=>{ - console.debug("====>ActsAccountOAuthToken_7200 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_tokenTest_name","authType","test_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_7200 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthToken("account_tokenTest_name",OWNERSELF,"authType",(err,data)=>{ - console.debug("====>ActsAccountOAuthToken_7200 getOAuthToken err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_7200 getOAuthToken data:" + data); - expect(err.code).assertEqual(0); - expect(data).assertEqual("test_token"); - appAccountManager.getOAuthList("account_tokenTest_name","authType",(err,dataArray)=>{ - console.debug("====>ActsAccountOAuthToken_7200 getOAuthList err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_7200 getOAuthList dataArray:" + JSON.stringify(dataArray)); - expect(dataArray.length).assertEqual(0); - appAccountManager.deleteAccount("account_tokenTest_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_7200 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_7200 end===="); - done(); - }); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_7300', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_7300 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_7300 addAccount start===="); - appAccountManager.addAccount("account_tokenTest_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_7300 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_tokenTest_name","authType","test_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_7300 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthToken("account_tokenTest_name",OWNERSELF,"authType",(err,data)=>{ - console.debug("====>ActsAccountOAuthToken_7300 getOAuthToken err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_7300 getOAuthToken data:" + data); - expect(err.code).assertEqual(0); - expect(data).assertEqual("test_token"); - appAccountManager.checkOAuthTokenVisibility("account_tokenTest_name","authType",OWNERSELF,(err,stateBack)=>{ - console.debug("====>ActsAccountOAuthToken_7300 checkOAuthTokenVisibility err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_7300 checkOAuthTokenVisibility stateBack:" + stateBack); - expect(err.code).assertEqual(0); - expect(stateBack).assertEqual(true); - appAccountManager.setOAuthTokenVisibility("account_tokenTest_name","authType",OWNERSELF,false,(err)=>{ - console.debug("====>ActsAccountOAuthToken_7300 setOAuthTokenVisibility err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.checkOAuthTokenVisibility("account_tokenTest_name","authType",OWNERSELF,(err,stateBack)=>{ - console.debug("====>ActsAccountOAuthToken_7300 checkOAuthTokenVisibility err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_7300 checkOAuthTokenVisibility stateBack:" + stateBack); - expect(err.code).assertEqual(0); - expect(stateBack).assertEqual(true); - appAccountManager.deleteOAuthToken("account_tokenTest_name",OWNERSELF,"authType","test_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_7300 deleteOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.deleteAccount("account_tokenTest_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_7300 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_7300 end===="); - done(); - }); - }); - }); - }); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_7400', 0, async function (done) { - var limitAuthType = ''; - for(var i = 0;i < AUTHTYPELENGTHLIMIT + 1; i++){ - limitAuthType += 'c'; - } - console.debug("====>ActsAccountOAuthToken_7400 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_7400 addAccount start===="); - appAccountManager.addAccount("account_callback_authType_limit",(err)=>{ - console.debug("====>ActsAccountOAuthToken_7400 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_callback_authType_limit","authType","callback_authType_limit_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_7400 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.deleteOAuthToken("account_callback_authType_limit",OWNERSELF,limitAuthType,"callback_authType_limit_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_7400 getOAuthToken err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - appAccountManager.deleteAccount("account_callback_authType_limit",(err)=>{ - console.debug("====>ActsAccountOAuthToken_7400 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_7400 end===="); - done(); - }); - }); - }); - }); - }); - - - it('ActsAccountOAuthToken_7500', 0, async function (done) { - var limitAuthType = ''; - for(var i = 0;i < AUTHTYPELENGTHLIMIT + 1; i++){ - limitAuthType += 'c'; - } - console.debug("====>ActsAccountOAuthToken_7500 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_7500 addAccount start===="); - await appAccountManager.addAccount("account_promise_authType_limit"); - console.debug("====>ActsAccountOAuthToken_7500 getOAuthToken start===="); - try{ - await appAccountManager.deleteOAuthToken("account_promise_authType_limit",OWNERSELF,limitAuthType,"promise_authType_limit_token"); - } - catch(err){ - console.debug("====>ActsAccountOAuthToken_7500 getOAuthToken err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_7500 deleteAccount start===="); - await appAccountManager.deleteAccount("account_promise_authType_limit"); - console.debug("====>ActsAccountOAuthToken_7500 end===="); - done(); - } - }); - - - - it('ActsAccountOAuthToken_7600', 0, async function (done) { - var limitAuthType = ''; - for(var i = 0;i < AUTHTYPELENGTHLIMIT; i++){ - limitAuthType += 'c'; - } - console.debug("====>ActsAccountOAuthToken_7600 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_7600 addAccount start===="); - appAccountManager.addAccount("account_callback_authType_limit",(err)=>{ - console.debug("====>ActsAccountOAuthToken_7600 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_callback_authType_limit",limitAuthType,"callback_authType_limit_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_7600 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.deleteOAuthToken("account_callback_authType_limit",OWNERSELF,limitAuthType,"callback_authType_limit_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_7600 getOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.deleteAccount("account_callback_authType_limit",(err)=>{ - console.debug("====>ActsAccountOAuthToken_7600 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_7600 end===="); - done(); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_7700', 0, async function (done) { - var limitAuthType = ''; - for(var i = 0;i < AUTHTYPELENGTHLIMIT; i++){ - limitAuthType += 'c'; - } - console.debug("====>ActsAccountOAuthToken_7700 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_7700 addAccount start===="); - await appAccountManager.addAccount("account_promise_authType_limit") - console.debug("====>ActsAccountOAuthToken_7700 setOAuthToken start===="); - await appAccountManager.setOAuthToken("account_promise_authType_limit",limitAuthType,"promise_authType_limit_token"); - console.debug("====>ActsAccountOAuthToken_7700 deleteOAuthToken start===="); - await appAccountManager.deleteOAuthToken("account_promise_authType_limit",OWNERSELF,limitAuthType,"promise_authType_limit_token") - console.debug("====>ActsAccountOAuthToken_7700 deleteAccount start===="); - await appAccountManager.deleteAccount("account_promise_authType_limit") - console.debug("====>ActsAccountOAuthToken_7700 end===="); - done(); - - }); - - - - it('ActsAccountOAuthToken_7800', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_7800 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_7800 addAccount start===="); - appAccountManager.addAccount("account_callback_empty_authType",(err)=>{ - console.debug("====>ActsAccountOAuthToken_7800 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_callback_empty_authType","authType","callback_empty_authType_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_7800 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.deleteOAuthToken("account_callback_empty_authType",OWNERSELF,"","callback_empty_authType_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_7800 deleteOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthToken("account_callback_empty_authType",OWNERSELF,"authType",(err,data)=>{ - console.debug("====>ActsAccountOAuthToken_7800 getOAuthToken err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_7800 getOAuthToken data:" + data); - expect(err.code).assertEqual(0); - expect(data).assertEqual("callback_empty_authType_token"); - appAccountManager.deleteAccount("account_callback_empty_authType",(err)=>{ - console.debug("====>ActsAccountOAuthToken_7800 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_7800 end===="); - done(); - }); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_7900', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_7900 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_7900 addAccount start===="); - await appAccountManager.addAccount("account_promise_empty_authType"); - console.debug("====>ActsAccountOAuthToken_7900 setOAuthToken start===="); - await appAccountManager.setOAuthToken("account_promise_empty_authType","authType","promise_empty_authType_token"); - console.debug("====>ActsAccountOAuthToken_7900 deleteOAuthToken start===="); - await appAccountManager.deleteOAuthToken("account_promise_empty_authType",OWNERSELF,"","promise_empty_authType_token"); - console.debug("====>ActsAccountOAuthToken_7900 getOAuthToken start===="); - var data = await appAccountManager.getOAuthToken("account_promise_empty_authType",OWNERSELF,"authType"); - expect(data).assertEqual("promise_empty_authType_token"); - console.debug("====>ActsAccountOAuthToken_7900 deleteAccount start===="); - await appAccountManager.deleteAccount("account_promise_empty_authType"); - console.debug("====>ActsAccountOAuthToken_7900 end===="); - done(); - - }); - - - it('ActsAccountOAuthToken_8000', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_8000 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_8000 addAccount start===="); - appAccountManager.addAccount("account_callback_setSameAuthType",(err)=>{ - console.debug("====>ActsAccountOAuthToken_8000 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_callback_setSameAuthType","authType","callback_setSameAuthType_token1",(err)=>{ - console.debug("====>ActsAccountOAuthToken_8000 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_callback_setSameAuthType","authType","callback_setSameAuthType_token2",(err)=>{ - console.debug("====>ActsAccountOAuthToken_8000 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthToken("account_callback_setSameAuthType",OWNERSELF,"authType",(err,data)=>{ - console.debug("====>ActsAccountOAuthToken_8000 getOAuthToken err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_8000 getOAuthToken data:" + data); - expect(err.code).assertEqual(0); - expect(data).assertEqual("callback_setSameAuthType_token2"); - appAccountManager.deleteOAuthToken("account_callback_setSameAuthType",OWNERSELF,"authType","callback_setSameAuthType_token1",(err,data)=>{ - console.debug("====>ActsAccountOAuthToken_8000 deleteOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.deleteAccount("account_callback_setSameAuthType",(err)=>{ - console.debug("====>ActsAccountOAuthToken_8000 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_8000 end===="); - done(); - }); - }); - }); - }); - }); - }); - }); - - - - - - it('ActsAccountOAuthToken_8100', 0, async function (done) { - var limitName = ''; - for(var i = 0;i < LENGTHLIMIT + 1; i++){ - limitName += 'c'; - } - console.debug("====>ActsAccountOAuthToken_8100 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_8100 getAllOAuthTokens start===="); - appAccountManager.getAllOAuthTokens(limitName, OWNERSELF,(err,ArrayData)=>{ - console.debug("====>ActsAccountOAuthToken_8100 getAllOAuthTokens err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_8100 getAllOAuthTokens ArrayData:" + JSON.stringify(ArrayData)); - expect(err.code!=0).assertEqual(true); - expect(ArrayData.length).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_8100 ===="); - done(); - }); - }); - - it('ActsAccountOAuthToken_8200', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_8200 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_8200 getAllOAuthTokens start===="); - appAccountManager.getAllOAuthTokens("", OWNERSELF,(err,ArrayData)=>{ - console.debug("====>ActsAccountOAuthToken_8200 getAllOAuthTokens err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_8200 getAllOAuthTokens ArrayData:" + JSON.stringify(ArrayData)); - expect(err.code!=0).assertEqual(true); - expect(ArrayData.length).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_8200 ===="); - done(); - }); - }); - - it('ActsAccountOAuthToken_8300', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_8300 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_8300 getAllOAuthTokens start===="); - appAccountManager.getAllOAuthTokens("acount_no_setToken", OWNERSELF,(err,ArrayData)=>{ - console.debug("====>ActsAccountOAuthToken_8300 getAllOAuthTokens err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_8300 getAllOAuthTokens ArrayData:" + JSON.stringify(ArrayData)); - expect(err.code!=0).assertEqual(true); - expect(ArrayData.length).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_8300 end===="); - done(); - }); - }); - - - - it('ActsAccountOAuthToken_8400', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_8400 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_8400 addAccount start===="); - appAccountManager.addAccount("acount_no_setToken",(err)=>{ - console.debug("====>ActsAccountOAuthToken_8400 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getAllOAuthTokens("acount_no_setToken", OWNERSELF,(err,ArrayData)=>{ - console.debug("====>ActsAccountOAuthToken_8400 getAllOAuthTokens err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_8400 getAllOAuthTokens ArrayData:" + JSON.stringify(ArrayData)); - expect(err.code).assertEqual(0); - expect(ArrayData.length).assertEqual(0); - appAccountManager.deleteAccount("acount_no_setToken",(err)=>{ - console.debug("====>ActsAccountOAuthToken_8400 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_8400 end===="); - done(); - }); - }); - }); - }); - - - - it('ActsAccountOAuthToken_8500', 0, async function (done) { - var limitName = ''; - for(var i = 0;i < LENGTHLIMIT; i++){ - limitName += 'c'; - } - console.debug("====>ActsAccountOAuthToken_8500 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_8500 addAccount start===="); - appAccountManager.addAccount(limitName,(err)=>{ - console.debug("====>ActsAccountOAuthToken_8500 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken(limitName,"authType","test_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_8500 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getAllOAuthTokens(limitName, OWNERSELF,(err,ArrayData)=>{ - console.debug("====>ActsAccountOAuthToken_8500 getAllOAuthTokens err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_8500 getAllOAuthTokens ArrayData:" + JSON.stringify(ArrayData)); - expect(err.code).assertEqual(0); - expect(ArrayData.length).assertEqual(1); - expect(ArrayData[0].authType).assertEqual("authType"); - expect(ArrayData[0].token).assertEqual("test_token"); - appAccountManager.deleteAccount(limitName,(err)=>{ - console.debug("====>ActsAccountOAuthToken_8500 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_8500 end===="); - done(); - }); - }); - }); - }); - }); - - - it('ActsAccountOAuthToken_8600', 0, async function (done) { - var limitOwner = ''; - for(var i = 0;i < OWNERLENGTHLIMIT + 1; i++){ - limitOwner += 'c'; - } - console.debug("====>ActsAccountOAuthToken_8600 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_8600 addAccount start===="); - appAccountManager.addAccount("account_callback_getAllOAuthTokens_test",(err)=>{ - console.debug("====>ActsAccountOAuthToken_8600 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getAllOAuthTokens("account_callback_getAllOAuthTokens_test",limitOwner,(err,ArrayData)=>{ - console.debug("====>ActsAccountOAuthToken_8600 getAllOAuthTokens err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_8600 getAllOAuthTokens ArrayData:" + JSON.stringify(ArrayData)); - expect(err.code!=0).assertEqual(true); - expect(ArrayData.length).assertEqual(0); - appAccountManager.deleteAccount("account_callback_getAllOAuthTokens_test",(err)=>{ - console.debug("====>ActsAccountOAuthToken_8600 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_8600 end===="); - done(); - }); - }); - }); - }); - - - it('ActsAccountOAuthToken_8700', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_8700 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_8700 addAccount start===="); - appAccountManager.addAccount("account_callback_getAllOAuthTokens_test",(err)=>{ - console.debug("====>ActsAccountOAuthToken_8700 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getAllOAuthTokens("account_callback_getAllOAuthTokens_test","",(err,ArrayData)=>{ - console.debug("====>ActsAccountOAuthToken_8700 getAllOAuthTokens err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_8700 getAllOAuthTokens ArrayData:" + JSON.stringify(ArrayData)); - expect(err.code!=0).assertEqual(true); - expect(ArrayData.length).assertEqual(0); - appAccountManager.deleteAccount("account_callback_getAllOAuthTokens_test",(err)=>{ - console.debug("====>ActsAccountOAuthToken_8700 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_8700 end===="); - done(); - }); - }); - }); - }); - - - it('ActsAccountOAuthToken_8800', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_8800 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_8800 addAccount start===="); - appAccountManager.addAccount("account_callback_getAllOAuthTokens_test",(err)=>{ - console.debug("====>ActsAccountOAuthToken_8800 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getAllOAuthTokens("account_callback_getAllOAuthTokens_test","invalid_owner",(err,ArrayData)=>{ - console.debug("====>ActsAccountOAuthToken_8800 getAllOAuthTokens err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_8800 getAllOAuthTokens ArrayData:" + JSON.stringify(ArrayData)); - expect(err.code!=0).assertEqual(true); - expect(ArrayData.length).assertEqual(0); - appAccountManager.deleteAccount("account_callback_getAllOAuthTokens_test",(err)=>{ - console.debug("====>ActsAccountOAuthToken_8800 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_8800 end===="); - done(); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_8900', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_8900 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_8900 addAccount start===="); - appAccountManager.addAccount("account_callback_getAllOAuthTokens_test",(err)=>{ - console.debug("====>ActsAccountOAuthToken_8900 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getAllOAuthTokens("account_callback_getAllOAuthTokens_test"," ",(err,ArrayData)=>{ - console.debug("====>ActsAccountOAuthToken_8900 getAllOAuthTokens err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_8900 getAllOAuthTokens ArrayData:" + JSON.stringify(ArrayData)); - expect(err.code!=0).assertEqual(true); - expect(ArrayData.length).assertEqual(0); - appAccountManager.deleteAccount("account_callback_getAllOAuthTokens_test",(err)=>{ - console.debug("====>ActsAccountOAuthToken_8900 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_8900 end===="); - done(); - }); - }); - }); - }); - - - - - it('ActsAccountOAuthToken_0100', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_0100 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_0100 addAccount start===="); - appAccountManager.addAccount("account_callback_normal",(err)=>{ - console.debug("====>ActsAccountOAuthToken_0100 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_callback_normal","authType","callback_normal_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_0100 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthToken("account_callback_normal",OWNERSELF,"authType",(err,data)=>{ - console.debug("====>ActsAccountOAuthToken_0100 getOAuthToken err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_0100 getOAuthToken data:" + data); - expect(err.code).assertEqual(0); - expect(data).assertEqual("callback_normal_token"); - appAccountManager.checkOAuthTokenVisibility("account_callback_normal","authType",OWNERSELF,(err,stateBack)=>{ - console.debug("====>ActsAccountOAuthToken_0100 checkOAuthTokenVisibility err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_0100 checkOAuthTokenVisibility stateBack:" + stateBack); - expect(err.code).assertEqual(0); - expect(stateBack).assertEqual(true); - appAccountManager.deleteOAuthToken("account_callback_normal",OWNERSELF,"authType","callback_normal_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_0100 deleteOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.deleteAccount("account_callback_normal",(err)=>{ - console.debug("====>ActsAccountOAuthToken_0100 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_0100 end===="); - done(); - }); - }); - }); - }); - }); - }); - }); - - - it('ActsAccountOAuthToken_0200', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_0200 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_0200 addAccount start===="); - await appAccountManager.addAccount("account_promise_normal"); - console.debug("====>ActsAccountOAuthToken_0200 setOAuthToken start===="); - await appAccountManager.setOAuthToken("account_promise_normal","authType","promise_normal_token"); - console.debug("====>ActsAccountOAuthToken_0200 getOAuthToken start===="); - var data1 = await appAccountManager.getOAuthToken("account_promise_normal",OWNERSELF,"authType"); - console.debug("====>getOAuthToken ActsAccountOAuthToken_0200 data:" + data1); - expect(data1).assertEqual("promise_normal_token"); - console.debug("====>ActsAccountOAuthToken_0200 checkOAuthTokenVisibility start===="); - var state = await appAccountManager.checkOAuthTokenVisibility("account_promise_normal","authType",OWNERSELF); - console.debug("====>checkOAuthTokenVisibility ActsAccountOAuthToken_0200 state:" + state); - expect(state).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_0200 deleteOAuthToken start===="); - await appAccountManager.deleteOAuthToken("account_promise_normal",OWNERSELF,"authType","promise_normal_token"); - console.debug("====>ActsAccountOAuthToken_0200 deleteAccount start===="); - await appAccountManager.deleteAccount("account_promise_normal"); - console.debug("====>ActsAccountOAuthToken_0200 end===="); - done(); - }); - - - - - it('ActsAccountOAuthToken_0300', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_0300 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_0300 getOAuthToken start===="); - appAccountManager.addAccount("account_callback_noSetToken",(err)=>{ - console.debug("====>ActsAccountOAuthToken_0300 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthToken("account_callback_noSetToken",OWNERSELF,"authType",(err,data)=>{ - console.debug("====>ActsAccountOAuthToken_0300 getOAuthToken err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_0300 getOAuthToken data:" + data); - expect(err.code!=0).assertEqual(true); - expect(data).assertEqual(""); - appAccountManager.deleteAccount("account_callback_noSetToken",(err)=>{ - console.debug("====>ActsAccountOAuthToken_0300 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_0300 end===="); - done(); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_0400', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_0400 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_0400 addAccount start===="); - await appAccountManager.addAccount("account_promise_noSetToken"); - console.debug("====>ActsAccountOAuthToken_0400 getOAuthToken start===="); - try{ - await appAccountManager.getOAuthToken("account_promise_noSetToken",OWNERSELF,"authType"); - } - catch(err){ - console.debug("====>ActsAccountOAuthToken_0400 getOAuthToken err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_0400 deleteAccount start===="); - await appAccountManager.deleteAccount("account_promise_noSetToken"); - console.debug("====>ActsAccountOAuthToken_0400 end===="); - done(); - } - }); - - - it('ActsAccountOAuthToken_0500', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_0500 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_0500 getOAuthToken start===="); - appAccountManager.getOAuthToken("noAdd_account_callback",OWNERSELF,"authType",(err,data)=>{ - console.debug("====>ActsAccountOAuthToken_0500 getOAuthToken err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_0500 getOAuthToken data:" + data); - expect(err.code!=0).assertEqual(true); - expect(data).assertEqual(""); - done(); - }); - }); - - it('ActsAccountOAuthToken_0600', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_0600 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_0600 getOAuthToken start===="); - try{ - await appAccountManager.getOAuthToken("noAdd_account_promise",OWNERSELF,"authType"); - } - catch(err){ - console.debug("====>ActsAccountOAuthToken_0600 getOAuthToken err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_0600 end===="); - done(); - } - }); - - - it('ActsAccountOAuthToken_0700', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_0700 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_0700 addAccount start===="); - appAccountManager.addAccount("account_callback_setSameAuthType",(err)=>{ - console.debug("====>ActsAccountOAuthToken_0700 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_callback_setSameAuthType","authType","callback_setSameAuthType_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_0700 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_callback_setSameAuthType","authType","callback_setSameAuthType_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_0700 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthToken("account_callback_setSameAuthType",OWNERSELF,"authType",(err,data)=>{ - console.debug("====>ActsAccountOAuthToken_0700 getOAuthToken err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_0700 getOAuthToken data:" + data); - expect(err.code).assertEqual(0); - expect(data).assertEqual("callback_setSameAuthType_token"); - appAccountManager.setOAuthToken("account_callback_setSameAuthType","authType","callback_setSameAuthType_DiffToken",(err)=>{ - console.debug("====>ActsAccountOAuthToken_0700 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthToken("account_callback_setSameAuthType",OWNERSELF,"authType",(err,data)=>{ - console.debug("====>ActsAccountOAuthToken_0700 getOAuthToken err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_0700 getOAuthToken data:" + data); - expect(err.code).assertEqual(0); - expect(data).assertEqual("callback_setSameAuthType_DiffToken"); - appAccountManager.deleteAccount("account_callback_setSameAuthType",(err)=>{ - console.debug("====>ActsAccountOAuthToken_0700 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_0700 end===="); - done(); - }); - }); - }); - }); - }); - }); - }); - }); - - - - - it('ActsAccountOAuthToken_0800', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_0800 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_0800 addAccount start===="); - await appAccountManager.addAccount("account_promise_setSameAuthType"); - console.debug("====>ActsAccountOAuthToken_0800 setOAuthToken start===="); - await appAccountManager.setOAuthToken("account_promise_setSameAuthType","authType","promise_setSameAuthType_token"); - console.debug("====>ActsAccountOAuthToken_0800 repeat setOAuthToken start===="); - await appAccountManager.setOAuthToken("account_promise_setSameAuthType","authType","promise_setSameAuthType_token"); - var data1 = await appAccountManager.getOAuthToken("account_promise_setSameAuthType",OWNERSELF,"authType"); - console.debug("====>getOAuthToken ActsAccountOAuthToken_0800 data:" + data1); - expect(data1).assertEqual("promise_setSameAuthType_token"); - console.debug("====>ActsAccountOAuthToken_0800 repeat set diffToken setOAuthToken start===="); - await appAccountManager.setOAuthToken("account_promise_setSameAuthType","authType","promise_setSameAuthType_DiffToken"); - var data2 = await appAccountManager.getOAuthToken("account_promise_setSameAuthType",OWNERSELF,"authType"); - console.debug("====>getOAuthToken ActsAccountOAuthToken_0800 data:" + data2); - expect(data2).assertEqual("promise_setSameAuthType_DiffToken"); - console.debug("====>ActsAccountOAuthToken_0800 deleteAccount start===="); - await appAccountManager.deleteAccount("account_promise_setSameAuthType"); - console.debug("====>ActsAccountOAuthToken_0800 end===="); - done(); - }); - - - - it('ActsAccountOAuthToken_0900', 0, async function(done) { - console.debug("====>ActsAccountOAuthToken_0900 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_callback_setDiff", (err)=>{ - console.debug("====>addAccount ActsAccountOAuthToken_0900 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_callback_setDiff","authType1","callback_setDiff_token1",(err)=>{ - console.debug("====>getOAuthToken ActsAccountOAuthToken_0900 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_callback_setDiff","authType2","callback_setDiff_token2",(err)=>{ - console.debug("====>getOAuthToken ActsAccountOAuthToken_0900 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthToken("account_callback_setDiff",OWNERSELF,"authType1", (err, data)=>{ - console.debug("====>getOAuthToken ActsAccountOAuthToken_0900 err:" + JSON.stringify(err)); - console.debug("====>getOAuthToken ActsAccountOAuthToken_0900 data:" + data); - expect(err.code).assertEqual(0); - expect(data).assertEqual("callback_setDiff_token1"); - appAccountManager.getOAuthToken("account_callback_setDiff",OWNERSELF,"authType2", (err, data)=>{ - console.debug("====>getOAuthToken ActsAccountOAuthToken_0900 err:" + JSON.stringify(err)); - console.debug("====>getOAuthToken ActsAccountOAuthToken_0900 data:" + data); - expect(err.code).assertEqual(0); - expect(data).assertEqual("callback_setDiff_token2"); - appAccountManager.deleteAccount("account_callback_setDiff", (err)=>{ - console.debug("====>deleteAccount ActsAccountOAuthToken_0900 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_0900 end===="); - done(); - }); - }); - }); - }); - }); - }); - }); - - - - it('ActsAccountOAuthToken_1000', 0, async function(done) { - console.debug("====>ActsAccountOAuthToken_1000 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_1000 addAccount start===="); - await appAccountManager.addAccount("account_promise_setDiff"); - console.debug("====>setOAuthToken ActsAccountOAuthToken_1000 start===="); - await appAccountManager.setOAuthToken("account_promise_setDiff","aythType1","promise_setDiff_token1"); - console.debug("====>setOAuthToken ActsAccountOAuthToken_1000 start===="); - await appAccountManager.setOAuthToken("account_promise_setDiff","aythType2","promise_setDiff_token2"); - - console.debug("====>getOAuthToken ActsAccountOAuthToken_1000 start===="); - var data1 = await appAccountManager.getOAuthToken("account_promise_setDiff",OWNERSELF,"aythType1"); - console.debug("====>getOAuthToken getOld ActsAccountOAuthToken_1000 data:" + data1); - expect(data1).assertEqual("promise_setDiff_token1"); - console.debug("====>getOAuthToken ActsAccountOAuthToken_1000 start===="); - var data2 = await appAccountManager.getOAuthToken("account_promise_setDiff",OWNERSELF,"aythType2"); - console.debug("====>getOAuthToken getNew ActsAccountOAuthToken_1000 data:" + data2); - expect(data2).assertEqual("promise_setDiff_token2"); - - console.debug("====>deleteOAuthToken ActsAccountOAuthToken_1000 start===="); - await appAccountManager.deleteOAuthToken("account_promise_setDiff",OWNERSELF,"aythType1","promise_setDiff_token1"); - console.debug("====>deleteOAuthToken ActsAccountOAuthToken_1000 start===="); - await appAccountManager.deleteOAuthToken("account_promise_setDiff",OWNERSELF,"aythType2","promise_setDiff_token2"); - console.debug("====>ActsAccountOAuthToken_1000 deleteAccount start===="); - await appAccountManager.deleteAccount("account_promise_setDiff"); - console.debug("====>ActsAccountOAuthToken_1000 end===="); - done(); - }); - - - - it('ActsAccountOAuthToken_1100', 0, async function(done) { - console.debug("====>ActsAccountOAuthToken_1100 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_callback_setDeleteGet", (err)=>{ - console.debug("====>addAccount ActsAccountOAuthToken_1100 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_callback_setDeleteGet","old_authType","callback_setDeleteGet_token",(err)=>{ - console.debug("====>getOAuthToken ActsAccountOAuthToken_1100 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_callback_setDeleteGet","new_authType","callback_setDeleteGet_token",(err)=>{ - console.debug("====>getOAuthToken ActsAccountOAuthToken_1100 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthToken("account_callback_setDeleteGet",OWNERSELF,"old_authType", (err, data)=>{ - console.debug("====>getOAuthToken getOld ActsAccountOAuthToken_1100 err:" + JSON.stringify(err)); - console.debug("====>getOAuthToken getOld ActsAccountOAuthToken_1100 data:" + data); - expect(err.code).assertEqual(0); - expect(data).assertEqual("callback_setDeleteGet_token"); - appAccountManager.getOAuthToken("account_callback_setDeleteGet",OWNERSELF,"new_authType", (err, data)=>{ - console.debug("====>getOAuthToken getNew ActsAccountOAuthToken_1100 err:" + JSON.stringify(err)); - console.debug("====>getOAuthToken getNew ActsAccountOAuthToken_1100 data:" + data); - expect(err.code).assertEqual(0); - expect(data).assertEqual("callback_setDeleteGet_token"); - appAccountManager.deleteOAuthToken("account_callback_setDeleteGet",OWNERSELF,"old_authType","callback_setDeleteGet_token",(err)=>{ - console.debug("====>deleteOAuthToken deleteOld ActsAccountOAuthToken_1100 err:" + JSON.stringify(err)); - appAccountManager.getOAuthToken("account_callback_setDeleteGet",OWNERSELF,"old_authType", (err, data)=>{ - console.debug("====>getOAuthToken getOld ActsAccountOAuthToken_1100 err:" + JSON.stringify(err)); - console.debug("====>getOAuthToken getOld ActsAccountOAuthToken_1100 data:" + data); - expect(err.code!=0).assertEqual(true); - expect(data).assertEqual(""); - appAccountManager.getOAuthToken("account_callback_setDeleteGet",OWNERSELF,"new_authType", (err, data)=>{ - console.debug("====>getOAuthToken getNew ActsAccountOAuthToken_1100 err:" + JSON.stringify(err)); - console.debug("====>getOAuthToken getNew ActsAccountOAuthToken_1100 data:" + data); - expect(err.code).assertEqual(0); - expect(data).assertEqual("callback_setDeleteGet_token"); - appAccountManager.deleteOAuthToken("account_callback_setDeleteGet",OWNERSELF,"new_authType","callback_setDeleteGet_token",(err)=>{ - console.debug("====>deleteOAuthToken deleteNew ActsAccountOAuthToken_1100 err:" + JSON.stringify(err)); - appAccountManager.getOAuthToken("account_callback_setDeleteGet",OWNERSELF,"old_authType", (err, data)=>{ - console.debug("====>getOAuthToken getOld ActsAccountOAuthToken_1100 err:" + JSON.stringify(err)); - console.debug("====>getOAuthToken getOld ActsAccountOAuthToken_1100 data:" + data); - expect(err.code!=0).assertEqual(true); - expect(data).assertEqual(""); - appAccountManager.getOAuthToken("account_callback_setDeleteGet",OWNERSELF,"new_authType", (err, data)=>{ - console.debug("====>getOAuthToken getNew ActsAccountOAuthToken_1100 err:" + JSON.stringify(err)); - console.debug("====>getOAuthToken getNew ActsAccountOAuthToken_1100 data:" + data); - expect(err.code!=0).assertEqual(true); - expect(data).assertEqual(""); - appAccountManager.deleteAccount("account_callback_setDeleteGet", (err)=>{ - console.debug("====>deleteAccount ActsAccountOAuthToken_1100 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_1100 end===="); - done(); - }); - }); - }) - }); - }); - }); - }); - }); - }); - }); - }); - }); - }); - - - it('ActsAccountOAuthToken_1200', 0, async function(done) { - console.debug("====>ActsAccountOAuthToken_1200 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_1200 addAccount start===="); - await appAccountManager.addAccount("account_promise_setDeleteGet"); - - console.debug("====>setOAuthToken setOld ActsAccountOAuthToken_1200 start===="); - await appAccountManager.setOAuthToken("account_promise_setDeleteGet","old_authType","promise_setDeleteGet_token"); - console.debug("====>setOAuthToken setNew ActsAccountOAuthToken_1200 start===="); - await appAccountManager.setOAuthToken("account_promise_setDeleteGet","new_authType","promise_setDeleteGet_token"); - - console.debug("====>getOAuthToken ActsAccountOAuthToken_1200 start===="); - var data1_beforeDel = await appAccountManager.getOAuthToken("account_promise_setDeleteGet",OWNERSELF,"old_authType"); - console.debug("====>getOAuthToken getOld ActsAccountOAuthToken_1200 data:" + data1_beforeDel); - expect(data1_beforeDel).assertEqual("promise_setDeleteGet_token"); - console.debug("====>getOAuthToken ActsAccountOAuthToken_1200 start===="); - var data2_beforeDel = await appAccountManager.getOAuthToken("account_promise_setDeleteGet",OWNERSELF,"new_authType"); - console.debug("====>getOAuthToken getNew ActsAccountOAuthToken_1200 data:" + data2_beforeDel); - expect(data2_beforeDel).assertEqual("promise_setDeleteGet_token"); - - console.debug("====>deleteOAuthToken deleteOld ActsAccountOAuthToken_1200 start===="); - try{ - await appAccountManager.deleteOAuthToken("account_promise_setDeleteGet",OWNERSELF,"old_authType","promise_setDeleteGet_token"); - } - catch(err){ - console.debug("====>deleteOAuthToken ActsAccountOAuthToken_1200 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - } - - console.debug("====>getOAuthToken ActsAccountOAuthToken_1200 start===="); - try{ - var data1_AfterDel = await appAccountManager.getOAuthToken("account_promise_setDeleteGet",OWNERSELF,"old_authType",); - } - catch(err){ - console.debug("====>getOAuthToken getOld ActsAccountOAuthToken_1200 err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - console.debug("====>getOAuthToken getOld ActsAccountOAuthToken_1200 data:" + data1_AfterDel); - expect(data1_AfterDel).assertEqual(undefined); - } - console.debug("====>getOAuthToken ActsAccountOAuthToken_1200 start===="); - try{ - var data2_AfterDel = await appAccountManager.getOAuthToken("account_promise_setDeleteGet",OWNERSELF,"new_authType",); - } - catch(err){ - console.debug("====>getOAuthToken getNew ActsAccountOAuthToken_1200 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>getOAuthToken getNew ActsAccountOAuthToken_1200 data:" + data2_AfterDel); - expect(data2_AfterDel).assertEqual("promise_setDeleteGet_token"); - } - console.debug("====>deleteOAuthToken deleteNew ActsAccountOAuthToken_1200 start===="); - try{ - await appAccountManager.deleteOAuthToken("account_promise_setDeleteGet",OWNERSELF,"new_authType","promise_setDeleteGet_token"); - } - catch(err){ - console.debug("====>deleteOAuthToken ActsAccountOAuthToken_1200 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - } - - console.debug("====>getOAuthToken getOld ActsAccountOAuthToken_1200 start===="); - try{ - var data1_AgainDel = await appAccountManager.getOAuthToken("account_promise_setDeleteGet",OWNERSELF,"old_authType",); - } - catch(err){ - console.debug("====>getOAuthToken getOld ActsAccountOAuthToken_1200 err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - console.debug("====>getOAuthToken getOld ActsAccountOAuthToken_1200 data:" + data1_AgainDel); - expect(data1_AgainDel).assertEqual(undefined); - } - console.debug("====>getOAuthToken getNew ActsAccountOAuthToken_1200 start===="); - try{ - var data2_AgainDel = await appAccountManager.getOAuthToken("account_promise_setDeleteGet",OWNERSELF,"new_authType",); - } - catch(err){ - console.debug("====>getOAuthToken getNew ActsAccountOAuthToken_1200 err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - console.debug("====>getOAuthToken getNew ActsAccountOAuthToken_1200 data:" + data2_AgainDel); - expect(data2_AgainDel).assertEqual(undefined); - } - await appAccountManager.deleteAccount("account_promise_setDeleteGet"); - console.debug("====>ActsAccountOAuthToken_1200 end===="); - done(); - - }); - - - it('ActsAccountOAuthToken_1300', 0, async function(done) { - console.debug("====>ActsAccountOAuthToken_1300 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_callback_setDeleteGet", (err)=>{ - console.debug("====>addAccount ActsAccountOAuthToken_1300 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_callback_setDeleteGet","authType","account_callback_setDeleteGet_token",(err)=>{ - console.debug("====>getOAuthToken ActsAccountOAuthToken_1300 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.deleteOAuthToken("account_callback_setDeleteGet",OWNERSELF,"authType","account_callback_setDeleteGet_token",(err)=>{ - console.debug("====>deleteOAuthToken ActsAccountOAuthToken_1300 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthToken("account_callback_setDeleteGet",OWNERSELF,"authType", (err, data)=>{ - console.debug("====>getOAuthToken ActsAccountOAuthToken_1300 err:" + JSON.stringify(err)); - console.debug("====>getOAuthToken ActsAccountOAuthToken_1300 data:" + data); - expect(err.code != 0).assertEqual(true); - expect(data).assertEqual(""); - appAccountManager.deleteAccount("account_callback_setDeleteGet", (err)=>{ - console.debug("====>deleteAccount ActsAccountOAuthToken_1300 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_1300 end===="); - done(); - }); - }); - }); - }); - }); - }); - - - it('ActsAccountOAuthToken_1400', 0, async function(done) { - console.debug("====>ActsAccountOAuthToken_1400 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_1400 addAccount start===="); - await appAccountManager.addAccount("account_promise_setDeleteGet"); - console.debug("====>setOAuthToken ActsAccountOAuthToken_1400 start===="); - await appAccountManager.setOAuthToken("account_promise_setDeleteGet","authType","promise_setDeleteGet_token"); - console.debug("====>deleteOAuthToken ActsAccountOAuthToken_1400 start===="); - await appAccountManager.deleteOAuthToken("account_promise_setDeleteGet",OWNERSELF,"authType","promise_setDeleteGet_token"); - console.debug("====>getOAuthToken ActsAccountOAuthToken_1400 start===="); - try{ - var data = await appAccountManager.getOAuthToken("account_promise_setDeleteGet",OWNERSELF,"authType"); - } - catch(err){ - console.debug("====>getOAuthToken ActsAccountOAuthToken_1400 err:" + JSON.stringify(err)); - expect(err.code != 0).assertEqual(true); - console.debug("====>getOAuthToken ActsAccountOAuthToken_1400 data:" + data); - console.debug("====>ActsAccountOAuthToken_1400 deleteAccount start===="); - await appAccountManager.deleteAccount("account_promise_setDeleteGet"); - console.debug("====>ActsAccountOAuthToken_1400 end===="); - done(); - } - }); - - - it('ActsAccountOAuthToken_1500', 0, async function(done) { - console.debug("====>ActsAccountOAuthToken_1500 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.setOAuthToken("account_callback_accountNotExit","authType","account_callback_accountNotExit_token", (err)=>{ - console.debug("====>setOAuthToken ActsAccountOAuthToken_1500 err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_1500 end===="); - done(); - }); - }); - - it('ActsAccountOAuthToken_1600', 0, async function(done) { - console.debug("====>ActsAccountOAuthToken_1600 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>setOAuthToken ActsAccountOAuthToken_1600 start===="); - try{ - await appAccountManager.setOAuthToken("account_promise_accountNotExit","authType","account_promise_accountNotExit_token"); - } - catch(err){ - console.debug("====>setOAuthToken ActsAccountOAuthToken_1600 err:" + JSON.stringify(err)); - expect(err.code != 0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_1600 end===="); - done(); - } - }); - - - - it('ActsAccountOAuthToken_1700', 0, async function(done) { - console.debug("====>ActsAccountOAuthToken_1700 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.deleteOAuthToken("account_callback_accountNotExit",OWNERSELF,"authType","account_callback_accountNotExit_token", (err)=>{ - console.debug("====>deleteOAuthToken ActsAccountOAuthToken_1700 err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_1700 end===="); - done(); - }); - }); - - it('ActsAccountOAuthToken_1800', 0, async function(done) { - console.debug("====>ActsAccountOAuthToken_1800 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>deleteOAuthToken ActsAccountOAuthToken_1800 start===="); - try{ - await appAccountManager.deleteOAuthToken("account_promise_accountNotExit",OWNERSELF,"authType","account_promise_accountNotExit_token"); - } - catch(err){ - console.debug("====>deleteOAuthToken ActsAccountOAuthToken_1800 err:" + JSON.stringify(err)); - expect(err.code != 0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_1800 end===="); - done(); - } - }); - - - - it('ActsAccountOAuthToken_1900', 0, async function(done) { - console.debug("====>ActsAccountOAuthToken_1900 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_callback_repeatDelete", (err)=>{ - console.debug("====>addAccount ActsAccountOAuthToken_1900 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.deleteOAuthToken("account_callback_repeatDelete",OWNERSELF,"aythType","promise_repeatDelete_token",(err)=>{ - console.debug("====>deleteOAuthToken ActsAccountOAuthToken_1900 err:" + JSON.stringify(err)); - appAccountManager.getOAuthToken("account_callback_repeatDelete",OWNERSELF,"authType", (err, data)=>{ - console.debug("====>getOAuthToken ActsAccountOAuthToken_1900 err:" + JSON.stringify(err)); - console.debug("====>getOAuthToken ActsAccountOAuthToken_1900 data:" + data); - expect(err.code != 0).assertEqual(true); - expect(data).assertEqual(""); - appAccountManager.deleteAccount("account_callback_repeatDelete", (err)=>{ - console.debug("====>deleteAccount ActsAccountOAuthToken_1900 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_1900 end===="); - done(); - }); - }); - }); - }); - }); - - - it('ActsAccountOAuthToken_2000', 0, async function(done) { - console.debug("====>ActsAccountOAuthToken_2000 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_2000 addAccount start===="); - await appAccountManager.addAccount("account_promise_noExitToken"); - console.debug("====>deleteOAuthToken ActsAccountOAuthToken_2000 start===="); - await appAccountManager.deleteOAuthToken("account_promise_noExitToken",OWNERSELF,"aythType","test_token").catch((err)=>{ - console.debug("====>deleteOAuthToken ActsAccountOAuthToken_2000 err:" + JSON.stringify(err)); - }); - console.debug("====>getOAuthToken ActsAccountOAuthToken_2000 start===="); - try{ - var data = await appAccountManager.getOAuthToken("account_promise_noExitToken",OWNERSELF,"authType"); - } - catch(err){ - console.debug("====>getOAuthToken ActsAccountOAuthToken_2000 err:" + JSON.stringify(err)); - expect(err.code != 0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_2000 deleteAccount start===="); - await appAccountManager.deleteAccount("account_promise_noExitToken"); - console.debug("====>ActsAccountOAuthToken_2000 end===="); - done(); - } - }); - - - it('ActsAccountOAuthToken_2100', 0, async function(done) { - console.debug("====>ActsAccountOAuthToken_2100 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_callback_repeatDelete", (err)=>{ - console.debug("====>addAccount ActsAccountOAuthToken_2100 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_callback_repeatDelete","authType","",(err)=>{ - console.debug("====>getOAuthToken ActsAccountOAuthToken_2100 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.deleteOAuthToken("account_callback_repeatDelete",OWNERSELF,"aythType","promise_repeatDelete_token",(err)=>{ - console.debug("====>deleteOAuthToken first ActsAccountOAuthToken_2100 err:" + JSON.stringify(err)); - appAccountManager.getOAuthToken("account_callback_repeatDelete",OWNERSELF,"authType", (err, data)=>{ - console.debug("====>getOAuthToken first ActsAccountOAuthToken_2100 err:" + JSON.stringify(err)); - console.debug("====>getOAuthToken first ActsAccountOAuthToken_2100 data:" + data); - expect(err.code != 0).assertEqual(true); - expect(data).assertEqual(""); - appAccountManager.deleteOAuthToken("account_callback_repeatDelete",OWNERSELF,"aythType","promise_repeatDelete_token",(err)=>{ - console.debug("====>deleteOAuthToken second ActsAccountOAuthToken_2100 err:" + JSON.stringify(err)); - appAccountManager.getOAuthToken("account_callback_repeatDelete",OWNERSELF,"authType", (err, data)=>{ - console.debug("====>getOAuthToken second ActsAccountOAuthToken_2100 err:" + JSON.stringify(err)); - console.debug("====>getOAuthToken second ActsAccountOAuthToken_2100 data:" + data); - expect(err.code != 0).assertEqual(true); - expect(data).assertEqual(""); - appAccountManager.deleteAccount("account_callback_repeatDelete", (err)=>{ - console.debug("====>deleteAccount ActsAccountOAuthToken_2100 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_2100 end===="); - done(); - }); - }); - }); - }); - }); - }); - }); - }); - - - - it('ActsAccountOAuthToken_2200', 0, async function(done) { - console.debug("====>ActsAccountOAuthToken_2200 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_2200 addAccount start===="); - await appAccountManager.addAccount("account_promise_repeatDelete"); - console.debug("====>setOAuthToken ActsAccountOAuthToken_2200 start===="); - await appAccountManager.setOAuthToken("account_promise_repeatDelete","aythType","promise_repeatDelete_token"); - console.debug("====>deleteOAuthToken first ActsAccountOAuthToken_2200 start===="); - await appAccountManager.deleteOAuthToken("account_promise_repeatDelete",OWNERSELF,"aythType","promise_repeatDelete_token"); - console.debug("====>deleteOAuthToken second ActsAccountOAuthToken_2200 start===="); - await appAccountManager.deleteOAuthToken("account_promise_repeatDelete",OWNERSELF,"aythType","promise_repeatDelete_token"); - console.debug("====>getOAuthToken ActsAccountOAuthToken_2200 start===="); - try{ - var data = await appAccountManager.getOAuthToken("account_promise_repeatDelete",OWNERSELF,"authType"); - } - catch(err){ - console.debug("====>getOAuthToken ActsAccountOAuthToken_2200 err:" + JSON.stringify(err)); - expect(err.code != 0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_2200 deleteAccount start===="); - await appAccountManager.deleteAccount("account_promise_repeatDelete"); - console.debug("====>ActsAccountOAuthToken_2200 end===="); - done(); - } - }); - - - it('ActsAccountOAuthToken_2300', 0, async function(done) { - console.debug("====>ActsAccountOAuthToken_2300 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_callback_setEmptyToken", (err)=>{ - console.debug("====>addAccount ActsAccountOAuthToken_2300 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_callback_setEmptyToken","authType","",(err)=>{ - console.debug("====>getOAuthToken ActsAccountOAuthToken_2300 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthToken("account_callback_setEmptyToken",OWNERSELF,"authType", (err, data)=>{ - console.debug("====>getOAuthToken ActsAccountOAuthToken_2300 err:" + JSON.stringify(err)); - console.debug("====>getOAuthToken ActsAccountOAuthToken_2300 data:" + data); - expect(err.code != 0).assertEqual(true); - expect(data).assertEqual(""); - appAccountManager.deleteAccount("account_callback_setEmptyToken", (err)=>{ - console.debug("====>deleteAccount ActsAccountOAuthToken_2300 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_2300 end===="); - done(); - }); - }); - }); - }); - }); - - - it('ActsAccountOAuthToken_2400', 0, async function(done) { - console.debug("====>ActsAccountOAuthToken_2400 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_2400 addAccount start===="); - await appAccountManager.addAccount("account_promise_setEmptyToken"); - console.debug("====>setOAuthToken ActsAccountOAuthToken_2400 start===="); - await appAccountManager.setOAuthToken("account_promise_setEmptyToken","aythType",""); - console.debug("====>getOAuthToken ActsAccountOAuthToken_2400 start===="); - try{ - await appAccountManager.getOAuthToken("account_promise_setEmptyToken","authType",limitToken); - } - catch(err){ - console.debug("====>getOAuthToken ActsAccountOAuthToken_2400 err:" + JSON.stringify(err)); - expect(err.code != 0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_2400 deleteAccount start===="); - await appAccountManager.deleteAccount("account_promise_setEmptyToken"); - console.debug("====>ActsAccountOAuthToken_2400 end===="); - done(); - } - }); - - - - it('ActsAccountOAuthToken_2500', 0, async function(done) { - console.debug("====>ActsAccountOAuthToken_2500 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_callback_spaceToken", (err)=>{ - console.debug("====>addAccount ActsAccountOAuthToken_2500 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_callback_spaceToken","authType"," ",(err)=>{ - console.debug("====>getOAuthToken ActsAccountOAuthToken_2500 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthToken("account_callback_spaceToken",OWNERSELF,"authType", (err, data)=>{ - console.debug("====>getOAuthToken ActsAccountOAuthToken_2500 err:" + JSON.stringify(err)); - console.debug("====>getOAuthToken ActsAccountOAuthToken_2500 data:" + data); - expect(err.code).assertEqual(0); - expect(data).assertEqual(" "); - appAccountManager.deleteAccount("account_callback_spaceToken", (err)=>{ - console.debug("====>deleteAccount ActsAccountOAuthToken_2500 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_2500 end===="); - done(); - }); - }); - }); - }); - }); - - - it('ActsAccountOAuthToken_2600', 0, async function(done) { - console.debug("====>ActsAccountOAuthToken_2600 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_2600 addAccount start===="); - await appAccountManager.addAccount("account_promise_spaceToken"); - console.debug("====>setOAuthToken ActsAccountOAuthToken_2600 start===="); - await appAccountManager.setOAuthToken("account_promise_spaceToken","aythType"," "); - console.debug("====>getOAuthToken ActsAccountOAuthToken_2600 start===="); - var data = await appAccountManager.getOAuthToken("account_promise_spaceToken",OWNERSELF,"aythType"); - expect(data).assertEqual(" "); - console.debug("====>ActsAccountOAuthToken_2600 deleteAccount start===="); - await appAccountManager.deleteAccount("account_promise_spaceToken"); - console.debug("====>ActsAccountOAuthToken_2600 end===="); - done(); - }); - - - - it('ActsAccountOAuthToken_2700', 0, async function(done) { - var limitToken = ''; - for (let i = 0; i < TOKENLENGTHLIMIT + 1; i++) { - limitToken += 't'; - } - console.debug("====>ActsAccountOAuthToken_2700 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_callback_exceed_limitToken", (err)=>{ - console.debug("====>addAccount ActsAccountOAuthToken_2700 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_callback_exceed_limitToken","authType",limitToken,(err)=>{ - console.debug("====>getOAuthToken ActsAccountOAuthToken_2700 err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - appAccountManager.deleteAccount("account_callback_exceed_limitToken", (err)=>{ - console.debug("====>deleteAccount ActsAccountOAuthToken_2700 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_2700 end===="); - done(); - }); - }); - }); - }); - - - it('ActsAccountOAuthToken_2800', 0, async function(done) { - var limitToken = ''; - for (let i = 0; i < TOKENLENGTHLIMIT + 1; i++) { - limitToken += 't'; - } - console.debug("====>ActsAccountOAuthToken_2800 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_2800 addAccount start===="); - await appAccountManager.addAccount("account_promise_exceed_limitToken"); - console.debug("====>setOAuthToken ActsAccountOAuthToken_2800 start===="); - try{ - await appAccountManager.setOAuthToken("account_promise_exceed_limitToken","authType",limitToken); - } - catch(err){ - console.debug("====>setOAuthToken ActsAccountOAuthToken_2800 err:" + JSON.stringify(err)); - expect(err.code != 0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_2800 deleteAccount start===="); - appAccountManager.deleteAccount("account_promise_exceed_limitToken"); - console.debug("====>ActsAccountOAuthToken_2800 end===="); - done(); - } - }); - - - it('ActsAccountOAuthToken_2900', 0, async function(done) { - var limitToken = ''; - for (let i = 0; i < TOKENLENGTHLIMIT; i++) { - limitToken += 't'; - } - console.debug("====>ActsAccountOAuthToken_2900 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_callback_limitToken", (err)=>{ - console.debug("====>addAccount ActsAccountOAuthToken_2900 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_callback_limitToken","authType",limitToken,(err)=>{ - console.debug("====>getOAuthToken ActsAccountOAuthToken_2900 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthToken("account_callback_limitToken",OWNERSELF,"authType", (err, data)=>{ - console.debug("====>getOAuthToken ActsAccountOAuthToken_2900 err:" + JSON.stringify(err)); - console.debug("====>getOAuthToken ActsAccountOAuthToken_2900 data:" + data); - expect(err.code).assertEqual(0); - expect(data).assertEqual(limitToken); - appAccountManager.deleteAccount("account_callback_limitToken", (err)=>{ - console.debug("====>deleteAccount ActsAccountOAuthToken_2900 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_2900 end===="); - done(); - }); - }); - }); - }); - }); - - - it('ActsAccountOAuthToken_3000', 0, async function(done) { - var limitToken = ''; - for (let i = 0; i < TOKENLENGTHLIMIT; i++) { - limitToken += 't'; - } - console.debug("====>ActsAccountOAuthToken_3000 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_3000 addAccount start===="); - await appAccountManager.addAccount("account_promise_limitToken"); - console.debug("====>setOAuthToken ActsAccountOAuthToken_3000 start===="); - await appAccountManager.setOAuthToken("account_promise_limitToken","authType",limitToken); - console.debug("====>getOAuthToken ActsAccountOAuthToken_3000 start===="); - var data = await appAccountManager.getOAuthToken("account_promise_limitToken",OWNERSELF,"authType"); - expect(data).assertEqual(limitToken); - console.debug("====>ActsAccountOAuthToken_3000 deleteAccount start===="); - await appAccountManager.deleteAccount("account_promise_limitToken"); - console.debug("====>ActsAccountOAuthToken_3000 end===="); - done(); - }); - - - it('ActsAccountOAuthToken_3100', 0, async function(done) { - var limitAuthType = ''; - for (let i = 0; i < AUTHTYPELENGTHLIMIT + 1; i++) { - limitAuthType += 't'; - } - console.debug("====>ActsAccountOAuthToken_3100 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_callback_limitAuthType", (err)=>{ - console.debug("====>addAccount ActsAccountOAuthToken_3100 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_callback_limitAuthType",limitAuthType,"account_callback_limitAuthType_token",(err, data)=>{ - console.debug("====>getOAuthToken ActsAccountOAuthToken_3100 err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - appAccountManager.deleteAccount("account_callback_limitAuthType", (err)=>{ - console.debug("====>deleteAccount ActsAccountOAuthToken_3100 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_3100 end===="); - done(); - }); - }); - }); - }); - - - it('ActsAccountOAuthToken_3200', 0, async function(done) { - var limitAuthType = ''; - for (let i = 0; i < AUTHTYPELENGTHLIMIT + 1; i++) { - limitAuthType += 't'; - } - console.debug("====>ActsAccountOAuthToken_3400 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_3400 addAccount start===="); - await appAccountManager.addAccount("account_promise_exceed_limitAuthType"); - console.debug("====>setOAuthToken ActsAccountOAuthToken_3400 start===="); - try{ - await appAccountManager.setOAuthToken("account_promise_exceed_limitAuthType",limitAuthType,"account_promise_limitAuthType_token"); - } - catch(err){ - console.debug("====>setOAuthToken ActsAccountOAuthToken_3400 err:" + JSON.stringify(err)); - expect(err.code != 0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_3400 deleteAccount start===="); - appAccountManager.deleteAccount("account_promise_exceed_limitAuthType"); - console.debug("====>ActsAccountOAuthToken_3400 end===="); - done(); - } - }); - - - - it('ActsAccountOAuthToken_3300', 0, async function(done) { - var limitAuthType = ''; - for (let i = 0; i < AUTHTYPELENGTHLIMIT + 1; i++) { - limitAuthType += 't'; - } - console.debug("====>ActsAccountOAuthToken_3300 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_callback_limitAuthType", (err)=>{ - console.debug("====>addAccount ActsAccountOAuthToken_3300 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthToken("account_callback_limitAuthType","com.example.actsaccounttest",limitAuthType, (err, data)=>{ - console.debug("====>getOAuthToken ActsAccountOAuthToken_3300 err:" + JSON.stringify(err)); - console.debug("====>getOAuthToken ActsAccountOAuthToken_3300 data:" + data); - expect(err.code!=0).assertEqual(true); - appAccountManager.deleteAccount("account_callback_limitAuthType", (err)=>{ - console.debug("====>deleteAccount ActsAccountOAuthToken_3300 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_3300 end===="); - done(); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_3400', 0, async function(done) { - var limitAuthType = ''; - for (let i = 0; i < AUTHTYPELENGTHLIMIT + 1; i++) { - limitAuthType += 't'; - } - console.debug("====>ActsAccountOAuthToken_3400 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_3400 addAccount start===="); - await appAccountManager.addAccount("account_promise_limitAuthType"); - console.debug("====>getOAuthToken ActsAccountOAuthToken_3400 start===="); - try{ - await appAccountManager.getOAuthToken("account_promise_limitAuthType",OWNERSELF,limitAuthType); - } - catch(err){ - console.debug("====>getOAuthToken ActsAccountOAuthToken_3400 err:" + JSON.stringify(err)); - expect(err.code != 0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_3400 deleteAccount start===="); - appAccountManager.deleteAccount("account_promise_limitAuthType"); - console.debug("====>ActsAccountOAuthToken_3400 end===="); - done(); - } - }); - - - - /* - * @tc.number : ActsAccountOAuthToken_2700 - * @tc.name : Test oauth token in callback form - * @tc.desc : 设置一个authType长度刚好为限制长度的token 查询 - */ - it('ActsAccountOAuthToken_3500', 0, async function(done) { - console.debug("====>ActsAccountOAuthToken_3500 start===="); - var limitAuthType = ''; - for (let i = 0; i < AUTHTYPELENGTHLIMIT; i++) { - limitAuthType += 't'; - } - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_3500 create finish===="); - appAccountManager.addAccount("account_callback_limitAuthType", (err)=>{ - console.debug("====>add account ActsAccountOAuthToken_3500 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_callback_limitAuthType",limitAuthType,"account_callback_limitAuthType_token", (err)=>{ - console.debug("====>setOAuthToken ActsAccountOAuthToken_3500 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthToken("account_callback_limitAuthType","com.example.actsaccounttest",limitAuthType, (err, data)=>{ - console.debug("====>getOAuthToken ActsAccountOAuthToken_3500 err:" + JSON.stringify(err)); - console.debug("====>getOAuthToken ActsAccountOAuthToken_3500 data:" + data); - expect(err.code).assertEqual(0); - expect(data).assertEqual("account_callback_limitAuthType_token"); - appAccountManager.deleteAccount("account_callback_limitAuthType", (err)=>{ - console.debug("====>delete Account ActsAccountOAuthToken_3500 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_3500 end===="); - done(); - }); - }); - }); - }); - }); - - /* - * @tc.number : ActsAccountOAuthToken_2800 - * @tc.name : Test oauth token in promise form - * @tc.desc : 设置一个authType长度刚好为限制长度的token - */ - - /* - * @tc.number : ActsAccountOAuthToken_2900 - * @tc.name : Test oauth token in callback form - * @tc.desc : Clear token parameter name is an empty string - */ - //测试 删除一个账号名为空的token callback方式 - it('ActsAccountOAuthToken_4100', 0, async function(done) { - console.debug("====>ActsAccountOAuthToken_4100 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_4100 create finish===="); - appAccountManager.deleteOAuthToken(" ","com.example.actsaccounttest","authType","account_notExist_token", (err)=>{ - console.debug("====>clearOAuthToken ActsAccountOAuthToken_4100 err:" + JSON.stringify(err)); - expect(err.code != 0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_4100 end===="); - done(); - }); - }); - - /* - * @tc.number : ActsAccountOAuthToken_3000 - * @tc.name : Test oauth token in promise form - * @tc.desc : Clear token parameter name is an empty string - */ - //测试 删除一个账号名为空的token promise方式 - it('ActsAccountOAuthToken_4200', 0, async function(done) { - console.debug("====>ActsAccountOAuthToken_4200 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_4200 create finish===="); - console.debug("====>clearOAuthToken ActsAccountOAuthToken_4200 start===="); - try{ - await appAccountManager.deleteOAuthToken("","com.example.actsaccounttest","authType","account_notExist_token"); - } - catch(err){ - console.debug("====>deleteOAuthToken ActsAccountOAuthToken_4200 err:" + JSON.stringify(err)); - expect(err.code != 0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_4200 end===="); - done(); - } - }); - - /* - * @tc.number : ActsAccountOAuthToken_3100 - * @tc.name : Test oauth token in callback form - * @tc.desc : The clear token parameter name is a space string - */ - it('ActsAccountOAuthToken_4300', 0, async function(done) { - console.debug("====>ActsAccountOAuthToken_4300 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_4300 create finish===="); - appAccountManager.deleteOAuthToken(" ","com.example.actsaccounttest","authType","account_notExist_token", (err)=>{ - console.debug("====>clearOAuthToken ActsAccountOAuthToken_4300 err:" + JSON.stringify(err)); - expect(err.code != 0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_4300 end===="); - done(); - }); - }); - - /* - * @tc.number : ActsAccountOAuthToken_3200 - * @tc.name : Test oauth token in promise form - * @tc.desc : The clear token parameter name is a space string - */ - it('ActsAccountOAuthToken_4400', 0, async function(done) { - console.debug("====>ActsAccountOAuthToken_4400 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_4400 create finish===="); - console.debug("====>clearOAuthToken ActsAccountOAuthToken_4400 start===="); - try{ - await appAccountManager.deleteOAuthToken(" ","com.example.actsaccounttest","authType","account_notExist_token"); - } - catch(err){ - console.debug("====>deleteOAuthToken ActsAccountOAuthToken_4400 err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_4400 end===="); - done(); - } - }); - - /* - * @tc.number : ActsAccountOAuthToken_3300 - * @tc.name : Test oauth token in callback form - * @tc.desc : Clear the token parameter name exceeds the length limit of 1024 characters - */ - it('ActsAccountOAuthToken_4500', 0, async function(done) { - console.debug("====>ActsAccountOAuthToken_4500 start===="); - var nameLimit = ''; - for (let i = 0; i < LENGTHLIMIT + 1; i++) { - nameLimit += 't'; - } - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_4500 create finish===="); - appAccountManager.deleteOAuthToken(nameLimit,"com.example.actsaccounttest","authType","account_notExist_token", (err)=>{ - console.debug("====>clearOAuthToken ActsAccountOAuthToken_4500 err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_4500 end===="); - done(); - }); - }); - - /* - * @tc.number : ActsAccountOAuthToken_3400 - * @tc.name : Test oauth token in promise form - * @tc.desc : Clear the token parameter name exceeds the length limit of 1024 characters - */ - it('ActsAccountOAuthToken_4600', 0, async function(done) { - console.debug("====>ActsAccountOAuthToken_4600 start===="); - var nameLimit = ''; - for (let i = 0; i < LENGTHLIMIT + 1; i++) { - nameLimit += 't'; - } - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_4600 create finish===="); - console.debug("====>deleteOAuthToken ActsAccountOAuthToken_4600 start===="); - try{ - await appAccountManager.deleteOAuthToken(nameLimit,"com.example.actsaccounttest","authType","account_notExist_token"); - } - catch(err){ - console.debug("====>deleteOAuthToken ActsAccountOAuthToken_4600 err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_4600 end===="); - done(); - } - }); - - //查询无效包名owner(为其他字符串时)账号的token callback方式 - it('ActsAccountOAuthToken_4700', 0, async function(done) { - console.debug("====>ActsAccountOAuthToken_4700 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_4700 create finish===="); - appAccountManager.addAccount("account_callback_invalid_owner", (err)=>{ - console.debug("====>add account ActsAccountOAuthToken_4700 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthToken("account_callback_invalid_owner","invalid_owner","authType", (err, data)=>{ - console.debug("====>getOAuthToken ActsAccountOAuthToken_4700 err:" + JSON.stringify(err)); - console.debug("====>getOAuthToken ActsAccountOAuthToken_4700 data:" + data); - expect(err.code!=0).assertEqual(true); - expect(data).assertEqual(""); - appAccountManager.deleteAccount("account_callback_invalid_owner", (err)=>{ - console.debug("====>delete account ActsAccountOAuthToken_4700 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_4700 end===="); - done(); - }); - }); - }); - }); - - - it('ActsAccountOAuthToken_3600', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_3600 start===="); - var limitAuthType = ''; - for (var i = 0; i < AUTHTYPELENGTHLIMIT; i++) { - limitAuthType += 't'; - } - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_3600 addAccount start===="); - await appAccountManager.addAccount("account_promise_limitAuthType"); - console.debug("====>ActsAccountOAuthToken_3600 setOAuthToken start===="); - await appAccountManager.setOAuthToken("account_promise_limitAuthType",limitAuthType,"account_promise_limitAuthType_token"); - console.debug("====>ActsAccountOAuthToken_3600 getOAuthToken start===="); - var data = await appAccountManager.getOAuthToken("account_promise_limitAuthType",OWNERSELF,limitAuthType); - expect(data).assertEqual("account_promise_limitAuthType_token"); - console.debug("====>ActsAccountOAuthToken_3600 deleteAccount start===="); - await appAccountManager.deleteAccount("account_promise_limitAuthType"); - console.debug("====>ActsAccountOAuthToken_3600 end===="); - done(); - }); - - - it('ActsAccountOAuthToken_3700', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_3700 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_3700 addAccount start===="); - appAccountManager.addAccount("account_callback_authType_empty",(err)=>{ - console.debug("====>ActsAccountOAuthToken_3700 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_callback_authType_empty","","account_callback_authType_empty_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_3700 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthToken("account_callback_authType_empty",OWNERSELF,"",(err,data)=>{ - console.debug("====>ActsAccountOAuthToken_3700 getOAuthToken err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_3700 getOAuthToken data:" + data); - expect(err.code).assertEqual(0); - expect(data).assertEqual("account_callback_authType_empty_token"); - appAccountManager.deleteAccount("account_callback_authType_empty",(err)=>{ - console.debug("====>ActsAccountOAuthToken_3700 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_3700 end===="); - done(); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_3800', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_3800 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_3800 addAccount start===="); - await appAccountManager.addAccount("account_promise_authType_empty"); - console.debug("====>ActsAccountOAuthToken_3800 setOAuthToken start===="); - await appAccountManager.setOAuthToken("account_promise_authType_empty","","account_promise_authType_empty_token"); - console.debug("====>ActsAccountOAuthToken_3800 getOAuthToken start===="); - var data = await appAccountManager.getOAuthToken("account_promise_authType_empty",OWNERSELF,""); - expect(data).assertEqual("account_promise_authType_empty_token"); - console.debug("====>ActsAccountOAuthToken_3800 deleteAccount start===="); - await appAccountManager.deleteAccount("account_promise_authType_empty"); - console.debug("====>ActsAccountOAuthToken_3800 end===="); - done(); - }); - - it('ActsAccountOAuthToken_3900', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_3900 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_3900 addAccount start===="); - appAccountManager.addAccount("account_callback_authType_space",(err)=>{ - console.debug("====>ActsAccountOAuthToken_3900 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_callback_authType_space"," ","account_callback_authType_space_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_3900 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthToken("account_callback_authType_space",OWNERSELF," ",(err,data)=>{ - console.debug("====>ActsAccountOAuthToken_3900 getOAuthToken err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_3900 getOAuthToken data:" + data); - expect(err.code).assertEqual(0); - expect(data).assertEqual("account_callback_authType_space_token"); - appAccountManager.deleteAccount("account_callback_authType_space",(err)=>{ - console.debug("====>ActsAccountOAuthToken_3900 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_3900 end===="); - done(); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_4000', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_4000 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_4000 addAccount start===="); - await appAccountManager.addAccount("account_promise_authType_space"); - console.debug("====>ActsAccountOAuthToken_4000 setOAuthToken start===="); - await appAccountManager.setOAuthToken("account_promise_authType_space"," ","account_promise_authType_space_token"); - console.debug("====>ActsAccountOAuthToken_4000 getOAuthToken start===="); - var data = await appAccountManager.getOAuthToken("account_promise_authType_space",OWNERSELF," "); - expect(data).assertEqual("account_promise_authType_space_token"); - console.debug("====>ActsAccountOAuthToken_4000 deleteAccount start===="); - await appAccountManager.deleteAccount("account_promise_authType_space"); - console.debug("====>ActsAccountOAuthToken_4000 end===="); - done(); - }); - - - it('ActsAccountOAuthToken_4800', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_4800 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_4800 addAccount start===="); - await appAccountManager.addAccount("account_promise_invalid_owner"); - console.debug("====>ActsAccountOAuthToken_4800 getOAuthToken start===="); - try{ - var data = await appAccountManager.getOAuthToken("account_promise_invalid_owner","invalid_owner","authType"); - } - catch(err){ - console.debug("====>ActsAccountOAuthToken_4800 getOAuthToken err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_4800 deleteAccount start===="); - await appAccountManager.deleteAccount("account_promise_invalid_owner"); - console.debug("====>ActsAccountOAuthToken_4800 end===="); - done(); - } - }); - - it('ActsAccountOAuthToken_4900', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_4900 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_4900 addAccount start===="); - appAccountManager.addAccount("account_callback_owner_empty",(err)=>{ - console.debug("====>ActsAccountOAuthToken_4900 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthToken("account_callback_owner_empty","","authType",(err,data)=>{ - console.debug("====>ActsAccountOAuthToken_4900 getOAuthToken err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_4900 getOAuthToken data:" + data); - expect(err.code!=0).assertEqual(true); - expect(data).assertEqual(""); - appAccountManager.deleteAccount("account_callback_owner_empty",(err)=>{ - console.debug("====>ActsAccountOAuthToken_4900 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_4900 end===="); - done(); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_5000', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_5000 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_5000 addAccount start===="); - await appAccountManager.addAccount("account_promise_owner_empty"); - console.debug("====>ActsAccountOAuthToken_5000 getOAuthToken start===="); - try{ - var data = await appAccountManager.getOAuthToken("account_promise_owner_empty","","authType"); - } - catch(err){ - console.debug("====>ActsAccountOAuthToken_5000 getOAuthToken err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_5000 deleteAccount start===="); - await appAccountManager.deleteAccount("account_promise_owner_empty"); - console.debug("====>ActsAccountOAuthToken_5000 end===="); - done(); - } - }); - - it('ActsAccountOAuthToken_5100', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_5100 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_5100 addAccount start===="); - appAccountManager.addAccount("account_callback_owner_space",(err)=>{ - console.debug("====>ActsAccountOAuthToken_5100 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthToken("account_callback_owner_space"," ","authType",(err,data)=>{ - console.debug("====>ActsAccountOAuthToken_5100 getOAuthToken err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_5100 getOAuthToken data:" + data); - expect(err.code!=0).assertEqual(true); - expect(data).assertEqual(""); - appAccountManager.deleteAccount("account_callback_owner_space",(err)=>{ - console.debug("====>ActsAccountOAuthToken_5100 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_5100 end===="); - done(); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_5200', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_5200 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_5200 addAccount start===="); - await appAccountManager.addAccount("account_callback_owner_space"); - console.debug("====>ActsAccountOAuthToken_5200 getOAuthToken start===="); - try{ - var data = await appAccountManager.getOAuthToken("account_callback_owner_space"," ","authType"); - } - catch(err){ - console.debug("====>ActsAccountOAuthToken_5200 getOAuthToken err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_5200 deleteAccount start===="); - await appAccountManager.deleteAccount("account_callback_owner_space"); - console.debug("====>ActsAccountOAuthToken_5200 end===="); - done(); - } - }); - - it('ActsAccountOAuthToken_5300', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_5300 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_5300 addAccount start===="); - appAccountManager.addAccount("account_callback_authType_invalid",(err)=>{ - console.debug("====>ActsAccountOAuthToken_5300 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_callback_authType_invalid","authType","account_callback_authType_invalid_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_5300 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthToken("account_callback_authType_invalid",OWNERSELF,"invalid_authType",(err,data)=>{ - console.debug("====>ActsAccountOAuthToken_5300 getOAuthToken err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_5300 getOAuthToken data:" + data); - expect(err.code!=0).assertEqual(true); - expect(data).assertEqual(""); - appAccountManager.deleteAccount("account_callback_authType_invalid",(err)=>{ - console.debug("====>ActsAccountOAuthToken_5300 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_5300 end===="); - done(); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_5400', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_5400 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_5400 addAccount start===="); - await appAccountManager.addAccount("account_promise_authType_invalid"); - console.debug("====>ActsAccountOAuthToken_5400 setOAuthToken start===="); - await appAccountManager.setOAuthToken("account_promise_authType_invalid","authType","account_promise_authType_invalid_token"); - console.debug("====>ActsAccountOAuthToken_5400 getOAuthToken start===="); - try{ - var data = await appAccountManager.getOAuthToken("account_promise_authType_invalid",OWNERSELF,"invalid_authType"); - } - catch(err){ - console.debug("====>ActsAccountOAuthToken_5400 getOAuthToken err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_5400 deleteAccount start===="); - await appAccountManager.deleteAccount("account_promise_authType_invalid"); - console.debug("====>ActsAccountOAuthToken_5400 end===="); - done(); - } - }); - - it('ActsAccountOAuthToken_5500', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_5500 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_5500 addAccount start===="); - appAccountManager.addAccount("account_callback_authType_empty",(err)=>{ - console.debug("====>ActsAccountOAuthToken_5500 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_callback_authType_empty","authType","account_callback_authType_empty_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_5500 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthToken("account_callback_authType_empty",OWNERSELF,"",(err,data)=>{ - console.debug("====>ActsAccountOAuthToken_5500 getOAuthToken err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_5500 getOAuthToken data:" + data); - expect(err.code!=0).assertEqual(true); - expect(data).assertEqual(""); - appAccountManager.deleteAccount("account_callback_authType_empty",(err)=>{ - console.debug("====>ActsAccountOAuthToken_5500 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_5500 end===="); - done(); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_5600', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_5600 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_5600 addAccount start===="); - await appAccountManager.addAccount("account_promise_authType_empty"); - console.debug("====>ActsAccountOAuthToken_5600 setOAuthToken start===="); - await appAccountManager.setOAuthToken("account_promise_authType_empty","authType","account_promise_authType_empty_token"); - console.debug("====>ActsAccountOAuthToken_5600 getOAuthToken start===="); - try{ - var data = await appAccountManager.getOAuthToken("account_promise_authType_empty",OWNERSELF,""); - } - catch(err){ - console.debug("====>ActsAccountOAuthToken_5600 getOAuthToken err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_5600 deleteAccount start===="); - await appAccountManager.deleteAccount("account_promise_authType_empty"); - console.debug("====>ActsAccountOAuthToken_5600 end===="); - done(); - } - }); - - it('ActsAccountOAuthToken_5700', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_5700 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_5700 addAccount start===="); - appAccountManager.addAccount("account_callback_authType_space",(err)=>{ - console.debug("====>ActsAccountOAuthToken_5700 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_callback_authType_space","authType","account_callback_authType_space_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_5700 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthToken("account_callback_authType_space",OWNERSELF," ",(err,data)=>{ - console.debug("====>ActsAccountOAuthToken_5700 getOAuthToken err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_5700 getOAuthToken data:" + data); - expect(err.code!=0).assertEqual(true); - expect(data).assertEqual(""); - appAccountManager.deleteAccount("account_callback_authType_space",(err)=>{ - console.debug("====>ActsAccountOAuthToken_5700 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_5700 end===="); - done(); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_5800', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_5800 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_5800 addAccount start===="); - await appAccountManager.addAccount("account_promise_authType_space"); - console.debug("====>ActsAccountOAuthToken_5800 setOAuthToken start===="); - await appAccountManager.setOAuthToken("account_promise_authType_space","authType","account_promise_authType_space_token"); - console.debug("====>ActsAccountOAuthToken_5800 getOAuthToken start===="); - try{ - var data = await appAccountManager.getOAuthToken("account_promise_authType_space",OWNERSELF," "); - } - catch(err){ - console.debug("====>ActsAccountOAuthToken_5800 getOAuthToken err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_5800 deleteAccount start===="); - await appAccountManager.deleteAccount("account_promise_authType_space"); - console.debug("====>ActsAccountOAuthToken_5800 end===="); - done(); - } - }); - - it('ActsAccountOAuthToken_5900', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_5900 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_5900 addAccount start===="); - appAccountManager.addAccount("account_callback_owner_invalid",(err)=>{ - console.debug("====>ActsAccountOAuthToken_5900 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_callback_owner_invalid","authType","account_callback_owner_invalid_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_5900 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.deleteOAuthToken("account_callback_owner_invalid","invalid_owner","authType","account_callback_owner_invalid_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_5900 getOAuthToken err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - appAccountManager.deleteAccount("account_callback_owner_invalid",(err)=>{ - console.debug("====>ActsAccountOAuthToken_5900 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_5900 end===="); - done(); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_6000', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_6000 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_6000 addAccount start===="); - await appAccountManager.addAccount("account_promise_owner_invalid"); - console.debug("====>ActsAccountOAuthToken_6000 setOAuthToken start===="); - await appAccountManager.setOAuthToken("account_promise_owner_invalid","authType","account_promise_owner_invalid_token"); - console.debug("====>ActsAccountOAuthToken_6000 getOAuthToken start===="); - try{ - await appAccountManager.deleteOAuthToken("account_promise_owner_invalid","invalid_owner","authType","account_promise_owner_invalid_token"); - } - catch(err){ - console.debug("====>ActsAccountOAuthToken_6000 getOAuthToken err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_6000 deleteAccount start===="); - await appAccountManager.deleteAccount("account_promise_owner_invalid"); - console.debug("====>ActsAccountOAuthToken_6000 end===="); - done(); - } - }); - - it('ActsAccountOAuthToken_6100', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_6100 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_6100 addAccount start===="); - appAccountManager.addAccount("account_callback_owner_empty",(err)=>{ - console.debug("====>ActsAccountOAuthToken_6100 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_callback_owner_empty","authType","account_callback_owner_empty_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_6100 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.deleteOAuthToken("account_callback_owner_empty","","authType","account_callback_owner_empty_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_6100 getOAuthToken err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - appAccountManager.deleteAccount("account_callback_owner_empty",(err)=>{ - console.debug("====>ActsAccountOAuthToken_6100 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_6100 end===="); - done(); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_6200', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_6200 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_6200 addAccount start===="); - await appAccountManager.addAccount("account_promise_owner_empty"); - console.debug("====>ActsAccountOAuthToken_6200 setOAuthToken start===="); - await appAccountManager.setOAuthToken("account_promise_owner_empty","authType","account_promise_owner_empty_token"); - console.debug("====>ActsAccountOAuthToken_6200 getOAuthToken start===="); - try{ - await appAccountManager.deleteOAuthToken("account_promise_owner_empty","","authType","account_promise_owner_empty_token"); - } - catch(err){ - console.debug("====>ActsAccountOAuthToken_6200 getOAuthToken err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_6200 deleteAccount start===="); - await appAccountManager.deleteAccount("account_promise_owner_empty"); - console.debug("====>ActsAccountOAuthToken_6200 end===="); - done(); - } - }); - - it('ActsAccountOAuthToken_6300', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_6300 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_6300 addAccount start===="); - appAccountManager.addAccount("account_callback_owner_space",(err)=>{ - console.debug("====>ActsAccountOAuthToken_6300 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_callback_owner_space","authType","account_callback_owner_space_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_6300 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.deleteOAuthToken("account_callback_owner_space"," ","authType","account_callback_owner_space_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_6300 getOAuthToken err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - appAccountManager.deleteAccount("account_callback_owner_space",(err)=>{ - console.debug("====>ActsAccountOAuthToken_6300 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_6300 end===="); - done(); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_6400', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_6400 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_6400 addAccount start===="); - await appAccountManager.addAccount("account_promise_owner_space"); - console.debug("====>ActsAccountOAuthToken_6400 setOAuthToken start===="); - await appAccountManager.setOAuthToken("account_promise_owner_space","authType","account_promise_owner_space_token"); - console.debug("====>ActsAccountOAuthToken_6400 getOAuthToken start===="); - try{ - await appAccountManager.deleteOAuthToken("account_promise_owner_space"," ","authType","account_promise_owner_space_token"); - } - catch(err){ - console.debug("====>ActsAccountOAuthToken_6400 getOAuthToken err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_6400 deleteAccount start===="); - await appAccountManager.deleteAccount("account_promise_owner_space"); - console.debug("====>ActsAccountOAuthToken_6400 end===="); - done(); - } - }); - - it('ActsAccountOAuthToken_6500', 0, async function (done) { - var limitToken = ''; - for(var i = 0;i < TOKENLENGTHLIMIT + 1; i++){ - limitToken += 'c'; - } - console.debug("====>ActsAccountOAuthToken_6500 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_6500 addAccount start===="); - appAccountManager.addAccount("account_callback_token_exceedLimit",(err)=>{ - console.debug("====>ActsAccountOAuthToken_6500 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.deleteOAuthToken("account_callback_token_exceedLimit",OWNERSELF,"authType",limitToken,(err)=>{ - console.debug("====>ActsAccountOAuthToken_6500 getOAuthToken err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - appAccountManager.deleteAccount("account_callback_token_exceedLimit",(err)=>{ - console.debug("====>ActsAccountOAuthToken_6500 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_6500 end===="); - done(); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_6600', 0, async function (done) { - var limitToken = ''; - for(var i = 0;i < TOKENLENGTHLIMIT + 1; i++){ - limitToken += 'c'; - } - console.debug("====>ActsAccountOAuthToken_6600 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_6600 addAccount start===="); - await appAccountManager.addAccount("account_promise_token_exceedLimit"); - console.debug("====>ActsAccountOAuthToken_6600 deleteOAuthToken start===="); - try{ - await appAccountManager.deleteOAuthToken("account_promise_token_exceedLimit",OWNERSELF,"authType",limitToken); - } - catch(err){ - console.debug("====>ActsAccountOAuthToken_6600 getOAuthToken err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_6600 deleteAccount start===="); - await appAccountManager.deleteAccount("account_promise_token_exceedLimit"); - console.debug("====>ActsAccountOAuthToken_6600 end===="); - done(); - } - }); - - it('ActsAccountOAuthToken_6700', 0, async function (done) { - var limitToken = ''; - for(var i = 0;i < TOKENLENGTHLIMIT; i++){ - limitToken += 'c'; - } - console.debug("====>ActsAccountOAuthToken_6700 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_6700 addAccount start===="); - appAccountManager.addAccount("account_callback_token_limit",(err)=>{ - console.debug("====>ActsAccountOAuthToken_6700 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_callback_token_limit","authType",limitToken,(err)=>{ - console.debug("====>ActsAccountOAuthToken_6700 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.deleteOAuthToken("account_callback_token_limit",OWNERSELF,"authType",limitToken,(err)=>{ - console.debug("====>ActsAccountOAuthToken_6700 getOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.deleteAccount("account_callback_token_limit",(err)=>{ - console.debug("====>ActsAccountOAuthToken_6700 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_6700 end===="); - done(); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_6800', 0, async function (done) { - var limitToken = ''; - for(var i = 0;i < TOKENLENGTHLIMIT; i++){ - limitToken += 'c'; - } - console.debug("====>ActsAccountOAuthToken_6800 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_6800 addAccount start===="); - await appAccountManager.addAccount("account_promise_token_limit"); - console.debug("====>ActsAccountOAuthToken_6800 setOAuthToken start===="); - await appAccountManager.setOAuthToken("account_promise_token_limit","authType",limitToken); - console.debug("====>ActsAccountOAuthToken_6800 deleteOAuthToken start===="); - await appAccountManager.deleteOAuthToken("account_promise_token_limit",OWNERSELF,"authType",limitToken); - console.debug("====>ActsAccountOAuthToken_6800 deleteAccount start===="); - await appAccountManager.deleteAccount("account_promise_token_limit"); - console.debug("====>ActsAccountOAuthToken_6800 end===="); - done(); - }); - - it('ActsAccountOAuthToken_6900', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_6900 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_6900 addAccount start===="); - appAccountManager.addAccount("account_callback_delete_space",(err)=>{ - console.debug("====>ActsAccountOAuthToken_6900 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_callback_delete_space","authType","account_callback_delete_space_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_6900 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.deleteOAuthToken("account_callback_delete_space",OWNERSELF,"authType","",(err)=>{ - console.debug("====>ActsAccountOAuthToken_6900 getOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthToken("account_callback_delete_space",OWNERSELF,"authType",(err,data)=>{ - console.debug("====>ActsAccountOAuthToken_6900 getOAuthToken err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_6900 getOAuthToken data:" + data); - expect(err.code).assertEqual(0); - expect(data).assertEqual("account_callback_delete_space_token"); - appAccountManager.deleteAccount("account_callback_delete_space",(err)=>{ - console.debug("====>ActsAccountOAuthToken_6900 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_6900 end===="); - done(); - }); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_7000', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_7000 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>ActsAccountOAuthToken_7000 addAccount start===="); - await appAccountManager.addAccount("account_promise_delete_space"); - console.debug("====>ActsAccountOAuthToken_7000 setOAuthToken start===="); - await appAccountManager.setOAuthToken("account_promise_delete_space","authType","account_promise_delete_space_token"); - console.debug("====>ActsAccountOAuthToken_7000 deleteOAuthToken start===="); - await appAccountManager.deleteOAuthToken("account_promise_delete_space",OWNERSELF,"authType",""); - console.debug("====>ActsAccountOAuthToken_7000 getOAuthToken start===="); - var data = await appAccountManager.getOAuthToken("account_promise_delete_space",OWNERSELF,"authType"); - expect(data).assertEqual("account_promise_delete_space_token"); - console.debug("====>ActsAccountOAuthToken_7000 deleteAccount start===="); - await appAccountManager.deleteAccount("account_promise_delete_space"); - console.debug("====>ActsAccountOAuthToken_7000 end===="); - done(); - }); - - it('ActsAccountOAuthToken_9200', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_9200 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.getAuthenticatorCallback("test_sessionId",(err,databack)=>{ - console.debug("====>ActsAccountOAuthToken_9200 getAuthenticatorCallback err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - expect(databack).assertEqual(undefined); - done(); - }); - }); - - it('ActsAccountOAuthToken_9300', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_9300 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.getAuthenticatorCallback("",(err,databack)=>{ - console.debug("====>ActsAccountOAuthToken_9300 getAuthenticatorCallback err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - expect(databack).assertEqual(undefined); - done(); - }); - }); - - it('ActsAccountOAuthToken_9400', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_9400 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.getAuthenticatorCallback(" ",(err,databack)=>{ - console.debug("====>ActsAccountOAuthToken_9400 getAuthenticatorCallback err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - expect(databack).assertEqual(undefined); - done(); - }); - }); - - it('ActsAccountOAuthToken_9500', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_9500 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.getAuthenticatorInfo(OWNERSELF,(err,databack)=>{ - console.debug("====>ActsAccountOAuthToken_9500 getAuthenticatorInfo err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - expect(account.ResultCode.SUCCESS).assertEqual(0); - expect(account.ResultCode.ERROR_ACCOUNT_NOT_EXIST).assertEqual(10001); - expect(account.ResultCode.ERROR_APP_ACCOUNT_SERVICE_EXCEPTION).assertEqual(10002); - expect(account.ResultCode.ERROR_INVALID_PASSWORD).assertEqual(10003); - expect(account.ResultCode.ERROR_INVALID_REQUEST).assertEqual(10004); - expect(account.ResultCode.ERROR_INVALID_RESPONSE).assertEqual(10005); - expect(account.ResultCode.ERROR_NETWORK_EXCEPTION).assertEqual(10006); - expect(account.ResultCode.ERROR_OAUTH_AUTHENTICATOR_NOT_EXIST).assertEqual(10007); - expect(account.ResultCode.ERROR_OAUTH_CANCELED).assertEqual(10008); - expect(account.ResultCode.ERROR_OAUTH_LIST_TOO_LARGE).assertEqual(10009); - expect(account.ResultCode.ERROR_OAUTH_SERVICE_BUSY).assertEqual(10010); - expect(account.ResultCode.ERROR_OAUTH_SERVICE_EXCEPTION).assertEqual(10011); - expect(account.ResultCode.ERROR_OAUTH_SESSION_NOT_EXIST).assertEqual(10012); - expect(account.ResultCode.ERROR_OAUTH_TIMEOUT).assertEqual(10013); - expect(account.ResultCode.ERROR_OAUTH_TOKEN_NOT_EXIST).assertEqual(10014); - expect(account.ResultCode.ERROR_OAUTH_TOKEN_TOO_MANY).assertEqual(10015); - expect(account.ResultCode.ERROR_OAUTH_UNSUPPORT_ACTION).assertEqual(10016); - expect(account.ResultCode.ERROR_OAUTH_UNSUPPORT_AUTH_TYPE).assertEqual(10017); - expect(account.ResultCode.ERROR_PERMISSION_DENIED).assertEqual(10018); - done(); - }); - }); - - it('ActsAccountOAuthToken_9600', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_9600 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.getAuthenticatorInfo("",(err,databack)=>{ - console.debug("====>ActsAccountOAuthToken_9600 getAuthenticatorInfo err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - expect(account.Constants.ACTION_ADD_ACCOUNT_IMPLICITLY).assertEqual('addAccountImplicitly'); - expect(account.Constants.ACTION_AUTHENTICATE).assertEqual('authenticate'); - expect(account.Constants.KEY_NAME).assertEqual('name'); - expect(account.Constants.KEY_OWNER).assertEqual('owner'); - expect(account.Constants.KEY_TOKEN).assertEqual('token'); - expect(account.Constants.KEY_ACTION).assertEqual('action'); - expect(account.Constants.KEY_AUTH_TYPE).assertEqual('authType'); - expect(account.Constants.KEY_SESSION_ID).assertEqual('sessionId'); - expect(account.Constants.KEY_CALLER_PID).assertEqual('callerPid'); - expect(account.Constants.KEY_CALLER_UID).assertEqual('callerUid'); - expect(account.Constants.KEY_CALLER_BUNDLE_NAME).assertEqual('callerBundleName'); - done(); - }); - }); - - it('ActsAccountOAuthToken_9700', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_9700 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.getAuthenticatorInfo(" ",(err,databack)=>{ - console.debug("====>ActsAccountOAuthToken_9700 getAuthenticatorInfo err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - done(); - }); - }); - - it('ActsAccountOAuthToken_9800', 0, async function (done) { - var limiOwner = ''; - for(var i = 0;i < OWNERLENGTHLIMIT + 1; i++){ - limiOwner += 't'; - } - console.debug("====>ActsAccountOAuthToken_9800 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.getAuthenticatorInfo(limiOwner,(err,databack)=>{ - console.debug("====>ActsAccountOAuthToken_9800 getAuthenticatorInfo err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - done(); - }); - }); - - it('ActsAccountOAuthToken_9900', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_9900 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_setOAuthTokenVisibility_name",(err,)=>{ - console.debug("====>ActsAccountOAuthToken_9900 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthTokenVisibility("account_setOAuthTokenVisibility_name","authType","test_BundleName",true,(err)=>{ - console.debug("====>ActsAccountOAuthToken_9900 setOAuthTokenVisibility err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthToken("account_setOAuthTokenVisibility_name",OWNERSELF,"authType",(err,data)=>{ - console.debug("====>ActsAccountOAuthToken_9900 getOAuthToken err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_9900 getOAuthToken data:" + data); - expect(err.code!=0).assertEqual(true); - expect(data).assertEqual(""); - appAccountManager.getOAuthList("account_setOAuthTokenVisibility_name","authType",(err,dataArray)=>{ - console.debug("====>ActsAccountOAuthToken_9900 getOAuthList err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_9900 getOAuthList dataArray:" + JSON.stringify(dataArray)); - expect(dataArray.length).assertEqual(1); - expect(dataArray[0]).assertEqual("test_BundleName"); - appAccountManager.deleteAccount("account_setOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_9900 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_9900 end===="); - done(); - }); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_10000', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_10000 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_setOAuthTokenVisibility_name",(err,)=>{ - console.debug("====>ActsAccountOAuthToken_10000 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_setOAuthTokenVisibility_name","authType","test_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_10000 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthTokenVisibility("account_setOAuthTokenVisibility_name","authType","test_BundleName","",(err)=>{ - console.debug("====>ActsAccountOAuthToken_10000 setOAuthTokenVisibility err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthList("account_setOAuthTokenVisibility_name","authType",(err,dataArray)=>{ - console.debug("====>ActsAccountOAuthToken_10000 getOAuthList err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_10000 getOAuthList dataArray:" + JSON.stringify(dataArray)); - expect(dataArray.length).assertEqual(0); - appAccountManager.deleteAccount("account_setOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_10000 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_10000 end===="); - done(); - }); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_10100', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_10100 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_setOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_10100 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_setOAuthTokenVisibility_name","authType","test_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_10100 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthTokenVisibility("account_setOAuthTokenVisibility_name","authType","test_BundleName","invalid_string",(err)=>{ - console.debug("====>ActsAccountOAuthToken_10100 setOAuthTokenVisibility err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthList("account_setOAuthTokenVisibility_name","authType",(err,dataArray)=>{ - console.debug("====>ActsAccountOAuthToken_10100 getOAuthList err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_10100 getOAuthList dataArray:" + JSON.stringify(dataArray)); - expect(dataArray.length).assertEqual(0); - appAccountManager.deleteAccount("account_setOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_10100 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_10100 end===="); - done(); - }); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_10200', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_10200 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_setOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_10200 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_setOAuthTokenVisibility_name","authType","test_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_10200 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthTokenVisibility("account_setOAuthTokenVisibility_name","authType","",true,(err)=>{ - console.debug("====>ActsAccountOAuthToken_10200 setOAuthTokenVisibility err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - appAccountManager.deleteAccount("account_setOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_10200 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_10200 end===="); - done(); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_10300', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_10300 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_setOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_10300 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_setOAuthTokenVisibility_name","authType","test_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_10300 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthTokenVisibility("account_setOAuthTokenVisibility_name","authType"," ",true,(err)=>{ - console.debug("====>ActsAccountOAuthToken_10300 setOAuthTokenVisibility err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthList("account_setOAuthTokenVisibility_name","authType",(err,dataArray)=>{ - console.debug("====>ActsAccountOAuthToken_10300 getOAuthList err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_10300 getOAuthList dataArray:" + JSON.stringify(dataArray)); - expect(dataArray.length).assertEqual(1); - expect(dataArray[0]).assertEqual(" "); - appAccountManager.deleteAccount("account_setOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_10300 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_10300 end===="); - done(); - }); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_10400', 0, async function (done) { - var limitBundleName = ''; - for(var i = 0;i < OWNERLENGTHLIMIT + 1; i++){ - limitBundleName += 't'; - } - console.debug("====>ActsAccountOAuthToken_10400 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_setOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_10400 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_setOAuthTokenVisibility_name","authType","test_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_10400 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthTokenVisibility("account_setOAuthTokenVisibility_name","authType",limitBundleName,true,(err)=>{ - console.debug("====>ActsAccountOAuthToken_10400 setOAuthTokenVisibility err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - appAccountManager.deleteAccount("account_setOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_10400 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_10400 end===="); - done(); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_10500', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_10500 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_setOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_10500 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_setOAuthTokenVisibility_name","authType","test_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_10500 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthTokenVisibility("account_setOAuthTokenVisibility_name","","test_bundleName",true,(err)=>{ - console.debug("====>ActsAccountOAuthToken_10500 setOAuthTokenVisibility err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthList("account_setOAuthTokenVisibility_name","",(err,dataArray)=>{ - console.debug("====>ActsAccountOAuthToken_10500 getOAuthList err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_10500 getOAuthList dataArray:" + JSON.stringify(dataArray)); - expect(dataArray.length).assertEqual(1); - expect(dataArray[0]).assertEqual("test_bundleName"); - appAccountManager.getOAuthList("account_setOAuthTokenVisibility_name","authType",(err,dataArray)=>{ - console.debug("====>ActsAccountOAuthToken_10500 getOAuthList authType:\"authType\" err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_10500 getOAuthList authType:\"authType\" dataArray:" + JSON.stringify(dataArray)); - expect(dataArray.length).assertEqual(0); - appAccountManager.deleteAccount("account_setOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_10500 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_10500 end===="); - done(); - }); - }); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_10600', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_10600 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_setOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_10600 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_setOAuthTokenVisibility_name","authType","test_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_10600 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthTokenVisibility("account_setOAuthTokenVisibility_name"," ","test_bundleName",true,(err)=>{ - console.debug("====>ActsAccountOAuthToken_10600 setOAuthTokenVisibility err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthList("account_setOAuthTokenVisibility_name"," ",(err,dataArray)=>{ - console.debug("====>ActsAccountOAuthToken_10600 getOAuthList err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_10600 getOAuthList dataArray:" + JSON.stringify(dataArray)); - expect(dataArray.length).assertEqual(1); - expect(dataArray[0]).assertEqual("test_bundleName"); - appAccountManager.getOAuthList("account_setOAuthTokenVisibility_name","authType",(err,dataArray)=>{ - console.debug("====>ActsAccountOAuthToken_10600 getOAuthList authType:\"authType\" err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_10600 getOAuthList authType:\"authType\" dataArray:" + JSON.stringify(dataArray)); - expect(dataArray.length).assertEqual(0); - appAccountManager.deleteAccount("account_setOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_10600 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_10600 end===="); - done(); - }); - }); - }); - }); - }); - }); - }); - - - it('ActsAccountOAuthToken_10700', 0, async function (done) { - var limitAuthType = ''; - for(var i = 0;i < AUTHTYPELENGTHLIMIT + 1; i++){ - limitAuthType += 't'; - } - console.debug("====>ActsAccountOAuthToken_10700 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_setOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_10700 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_setOAuthTokenVisibility_name","authType","test_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_10700 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthTokenVisibility("account_setOAuthTokenVisibility_name",limitAuthType,"test_bundleName",true,(err)=>{ - console.debug("====>ActsAccountOAuthToken_10700 setOAuthTokenVisibility err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - appAccountManager.getOAuthList("account_setOAuthTokenVisibility_name","authType",(err,dataArray)=>{ - console.debug("====>ActsAccountOAuthToken_10700 getOAuthList authType:\"authType\" err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_10700 getOAuthList authType:\"authType\" dataArray:" + JSON.stringify(dataArray)); - expect(dataArray.length).assertEqual(0); - appAccountManager.deleteAccount("account_setOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_10700 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_10700 end===="); - done(); - }); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_10800', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_10800 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_setOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_10800 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_setOAuthTokenVisibility_name","authType","test_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_10800 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthTokenVisibility("account_setOAuthTokenVisibility_name","invalid_authType","test_bundleName",true,(err)=>{ - console.debug("====>ActsAccountOAuthToken_10800 setOAuthTokenVisibility err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthList("account_setOAuthTokenVisibility_name","invalid_authType",(err,dataArray)=>{ - console.debug("====>ActsAccountOAuthToken_10800 getOAuthList err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_10800 getOAuthList dataArray:" + JSON.stringify(dataArray)); - expect(dataArray.length).assertEqual(1); - expect(dataArray[0]).assertEqual("test_bundleName"); - appAccountManager.getOAuthList("account_setOAuthTokenVisibility_name","authType",(err,dataArray)=>{ - console.debug("====>ActsAccountOAuthToken_10800 getOAuthList authType:\"authType\" err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_10800 getOAuthList authType:\"authType\" dataArray:" + JSON.stringify(dataArray)); - expect(dataArray.length).assertEqual(0); - appAccountManager.deleteAccount("account_setOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_10800 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_10800 end===="); - done(); - }); - }); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_10900', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_10900 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.setOAuthTokenVisibility("","authType","test_bundleName",true,(err)=>{ - console.debug("====>ActsAccountOAuthToken_10900 setOAuthTokenVisibility err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - done(); - }); - }); - - it('ActsAccountOAuthToken_11000', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_11000 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.setOAuthTokenVisibility(" ","authType","test_bundleName",true,(err)=>{ - console.debug("====>ActsAccountOAuthToken_11000 setOAuthTokenVisibility err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - done(); - }); - }); - - it('ActsAccountOAuthToken_11100', 0, async function (done) { - var limitName = ''; - for(var i = 0; i < LENGTHLIMIT + 1; i++){ - limitName += 't'; - } - console.debug("====>ActsAccountOAuthToken_11100 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.setOAuthTokenVisibility(limitName,"authType","test_bundleName",true,(err)=>{ - console.debug("====>ActsAccountOAuthToken_11100 setOAuthTokenVisibility err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - done(); - }); - }); - - it('ActsAccountOAuthToken_11200', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_11200 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.setOAuthTokenVisibility("no_add_account","authType","test_bundleName",true,(err)=>{ - console.debug("====>ActsAccountOAuthToken_11200 setOAuthTokenVisibility err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - done(); - }); - }); - - it('ActsAccountOAuthToken_11300', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_11300 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.checkOAuthTokenVisibility("","authType","test_bundleName",(err,stateBack)=>{ - console.debug("====>ActsAccountOAuthToken_11300 checkOAuthTokenVisibility err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - done(); - }); - }); - - it('ActsAccountOAuthToken_11400', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_11400 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.checkOAuthTokenVisibility(" ","authType","test_bundleName",(err,stateBack)=>{ - console.debug("====>ActsAccountOAuthToken_11400 checkOAuthTokenVisibility err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - done(); - }); - }); - - it('ActsAccountOAuthToken_11500', 0, async function (done) { - var limitName = ''; - for(var i = 0; i < LENGTHLIMIT + 1; i++){ - limitName += 't'; - } - console.debug("====>ActsAccountOAuthToken_11500 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.checkOAuthTokenVisibility(limitName,"authType","test_bundleName",(err,stateBack)=>{ - console.debug("====>ActsAccountOAuthToken_11500 checkOAuthTokenVisibility err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - done(); - }); - }); - - it('ActsAccountOAuthToken_11600', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_11600 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.checkOAuthTokenVisibility("no_add_account","authType","test_bundleName",(err,stateBack)=>{ - console.debug("====>ActsAccountOAuthToken_11600 checkOAuthTokenVisibility err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - done(); - }); - }); - - it('ActsAccountOAuthToken_11700', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_11700 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_checkOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_11700 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_checkOAuthTokenVisibility_name","authType","test_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_11700 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.checkOAuthTokenVisibility("account_checkOAuthTokenVisibility_name","","test_bundleName",(err,stateBack)=>{ - console.debug("====>ActsAccountOAuthToken_11700 checkOAuthTokenVisibility err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_11700 checkOAuthTokenVisibility stateBack:" + stateBack); - expect(err.code).assertEqual(0); - expect(stateBack).assertEqual(false); - appAccountManager.checkOAuthTokenVisibility("account_checkOAuthTokenVisibility_name","",OWNERSELF,(err,stateBack)=>{ - console.debug("====>ActsAccountOAuthToken_11700 checkOAuthTokenVisibility err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_11700 checkOAuthTokenVisibility stateBack:" + stateBack); - expect(err.code).assertEqual(0); - expect(stateBack).assertEqual(true); - appAccountManager.deleteAccount("account_checkOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_11700 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_11700 end===="); - done(); - }); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_11800', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_11800 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_checkOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_11800 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_checkOAuthTokenVisibility_name","authType","test_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_11800 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.checkOAuthTokenVisibility("account_checkOAuthTokenVisibility_name"," ","test_bundleName",(err,stateBack)=>{ - console.debug("====>ActsAccountOAuthToken_11800 checkOAuthTokenVisibility err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_11800 checkOAuthTokenVisibility stateBack:" + stateBack); - expect(err.code).assertEqual(0); - expect(stateBack).assertEqual(false); - appAccountManager.checkOAuthTokenVisibility("account_checkOAuthTokenVisibility_name"," ",OWNERSELF,(err,stateBack)=>{ - console.debug("====>ActsAccountOAuthToken_11800 checkOAuthTokenVisibility err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_11800 checkOAuthTokenVisibility stateBack:" + stateBack); - expect(err.code).assertEqual(0); - expect(stateBack).assertEqual(true); - appAccountManager.deleteAccount("account_checkOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_11800 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_11800 end===="); - done(); - }); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_11900', 0, async function (done) { - var limitAuthType =''; - for(var i = 0; i < AUTHTYPELENGTHLIMIT + 1; i++){ - limitAuthType += 't'; - } - console.debug("====>ActsAccountOAuthToken_11900 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_checkOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_11900 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_checkOAuthTokenVisibility_name","authType","test_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_11900 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.checkOAuthTokenVisibility("account_checkOAuthTokenVisibility_name",limitAuthType,"test_bundleName",(err,stateBack)=>{ - console.debug("====>ActsAccountOAuthToken_11900 checkOAuthTokenVisibility err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - appAccountManager.checkOAuthTokenVisibility("account_checkOAuthTokenVisibility_name",limitAuthType,OWNERSELF,(err,stateBack)=>{ - console.debug("====>ActsAccountOAuthToken_11900 checkOAuthTokenVisibility err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - appAccountManager.deleteAccount("account_checkOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_11900 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_11900 end===="); - done(); - }); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_12000', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_12000 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_checkOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_12000 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_checkOAuthTokenVisibility_name","authType","test_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_12000 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.checkOAuthTokenVisibility("account_checkOAuthTokenVisibility_name","invalid_authType","test_bundleName",(err,stateBack)=>{ - console.debug("====>ActsAccountOAuthToken_12000 checkOAuthTokenVisibility err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_12000 checkOAuthTokenVisibility stateBack:" + stateBack); - expect(err.code).assertEqual(0); - expect(stateBack).assertEqual(false); - appAccountManager.checkOAuthTokenVisibility("account_checkOAuthTokenVisibility_name","invalid_authType",OWNERSELF,(err,stateBack)=>{ - console.debug("====>ActsAccountOAuthToken_12000 checkOAuthTokenVisibility err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_12000 checkOAuthTokenVisibility stateBack:" + stateBack); - expect(err.code).assertEqual(0); - expect(stateBack).assertEqual(true); - appAccountManager.deleteAccount("account_checkOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_12000 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_12000 end===="); - done(); - }); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_12100', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_12100 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_checkOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_12100 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_checkOAuthTokenVisibility_name","authType","test_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_12100 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.checkOAuthTokenVisibility("account_checkOAuthTokenVisibility_name","authType","",(err,stateBack)=>{ - console.debug("====>ActsAccountOAuthToken_12100 checkOAuthTokenVisibility err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_12100 checkOAuthTokenVisibility stateBack:" + stateBack); - expect(err.code!=0).assertEqual(true); - appAccountManager.deleteAccount("account_checkOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_12100 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_12100 end===="); - done(); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_12200', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_12200 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_checkOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_12200 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_checkOAuthTokenVisibility_name","authType","test_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_12200 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.checkOAuthTokenVisibility("account_checkOAuthTokenVisibility_name","authType"," ",(err,stateBack)=>{ - console.debug("====>ActsAccountOAuthToken_12200 checkOAuthTokenVisibility err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_12200 checkOAuthTokenVisibility stateBack:" + stateBack); - expect(err.code).assertEqual(0); - expect(stateBack).assertEqual(false); - appAccountManager.deleteAccount("account_checkOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_12200 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_12200 end===="); - done(); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_12300', 0, async function (done) { - var limitBundleName = ''; - for(var i = 0; i < OWNERLENGTHLIMIT + 1; i++){ - limitBundleName += 't'; - } - console.debug("====>ActsAccountOAuthToken_12300 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_checkOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_12300 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_checkOAuthTokenVisibility_name","authType","test_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_12300 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.checkOAuthTokenVisibility("account_checkOAuthTokenVisibility_name","authType",limitBundleName,(err,stateBack)=>{ - console.debug("====>ActsAccountOAuthToken_12300 checkOAuthTokenVisibility err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_12300 checkOAuthTokenVisibility stateBack:" + stateBack); - expect(err.code!=0).assertEqual(true); - appAccountManager.deleteAccount("account_checkOAuthTokenVisibility_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_12300 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_12300 end===="); - done(); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_12400', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_12400 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_testGetOAuthList_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_12400 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_testGetOAuthList_name","authType","test_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_12400 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthTokenVisibility("account_testGetOAuthList_name","authType","test_bundleName",true,(err)=>{ - console.debug("====>ActsAccountOAuthToken_12400 setOAuthTokenVisibility err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthList("account_testGetOAuthList_name","",(err,dataArray)=>{ - console.debug("====>ActsAccountOAuthToken_12400 getOAuthList err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_12400 getOAuthList dataArray:" + JSON.stringify(dataArray)); - expect(dataArray.length).assertEqual(0); - appAccountManager.deleteAccount("account_testGetOAuthList_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_12400 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_12400 end===="); - done(); - }); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_12500', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_12500 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_testGetOAuthList_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_12500 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_testGetOAuthList_name","authType","test_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_12500 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthTokenVisibility("account_testGetOAuthList_name","authType","test_bundleName",true,(err)=>{ - console.debug("====>ActsAccountOAuthToken_12500 setOAuthTokenVisibility err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthList("account_testGetOAuthList_name"," ",(err,dataArray)=>{ - console.debug("====>ActsAccountOAuthToken_12500 getOAuthList err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_12500 getOAuthList dataArray:" + JSON.stringify(dataArray)); - expect(dataArray.length).assertEqual(0); - appAccountManager.deleteAccount("account_testGetOAuthList_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_12500 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_12500 end===="); - done(); - }); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_12600', 0, async function (done) { - var limitAuthType =''; - for(var i = 0; i < AUTHTYPELENGTHLIMIT + 1; i++){ - limitAuthType += 't'; - } - console.debug("====>ActsAccountOAuthToken_12600 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_testGetOAuthList_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_12600 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_testGetOAuthList_name","authType","test_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_12600 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthTokenVisibility("account_testGetOAuthList_name","authType","test_bundleName",true,(err)=>{ - console.debug("====>ActsAccountOAuthToken_12600 setOAuthTokenVisibility err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthList("account_testGetOAuthList_name",limitAuthType,(err,dataArray)=>{ - console.debug("====>ActsAccountOAuthToken_12600 getOAuthList err:" + JSON.stringify(err)); - expect(err.code!=0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_12600 getOAuthList dataArray:" + JSON.stringify(dataArray)); - expect(dataArray.length).assertEqual(0); - appAccountManager.deleteAccount("account_testGetOAuthList_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_12600 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_12600 end===="); - done(); - }); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_12700', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_12700 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.getOAuthList("","authType",(err,dataArray)=>{ - console.debug("====>ActsAccountOAuthToken_12700 getOAuthList err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_12700 getOAuthList dataArray:" + JSON.stringify(dataArray)); - expect(err.code!=0).assertEqual(true); - expect(dataArray.length).assertEqual(0); - done(); - }); - }); - - it('ActsAccountOAuthToken_12800', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_12800 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.getOAuthList(" ","authType",(err,dataArray)=>{ - console.debug("====>ActsAccountOAuthToken_12800 getOAuthList err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_12800 getOAuthList dataArray:" + JSON.stringify(dataArray)); - expect(err.code!=0).assertEqual(true); - expect(dataArray.length).assertEqual(0); - done(); - }); - }); - - it('ActsAccountOAuthToken_12900', 0, async function (done) { - var limitName = ''; - for(var i = 0; i < LENGTHLIMIT + 1; i++){ - limitName += 't'; - } - console.debug("====>ActsAccountOAuthToken_12900 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.getOAuthList(limitName,"authType",(err,dataArray)=>{ - console.debug("====>ActsAccountOAuthToken_12900 getOAuthList err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_12900 getOAuthList dataArray:" + JSON.stringify(dataArray)); - expect(err.code!=0).assertEqual(true); - expect(dataArray.length).assertEqual(0); - done(); - }); - }); - - it('ActsAccountOAuthToken_13000', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_13000 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.getOAuthList("no_add_account","authType",(err,dataArray)=>{ - console.debug("====>ActsAccountOAuthToken_13000 getOAuthList err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_13000 getOAuthList dataArray:" + JSON.stringify(dataArray)); - expect(err.code!=0).assertEqual(true); - expect(dataArray.length).assertEqual(0); - done(); - }); - }); - - it('ActsAccountOAuthToken_13100', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_13100 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccount("account_tokenTest_name",(err,)=>{ - console.debug("====>ActsAccountOAuthToken_13100 addAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.setOAuthToken("account_tokenTest_name","authType","test_token",(err)=>{ - console.debug("====>ActsAccountOAuthToken_13100 setOAuthToken err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getOAuthToken("account_tokenTest_name",OWNERSELF,"authType",(err,data)=>{ - console.debug("====>ActsAccountOAuthToken_13100 getOAuthToken err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_13100 getOAuthToken stateBack:" + data); - expect(err.code).assertEqual(0); - expect(data).assertEqual("test_token"); - appAccountManager.checkOAuthTokenVisibility("account_tokenTest_name","authType","test_bundleName",(err,stateBack)=>{ - console.debug("====>ActsAccountOAuthToken_13100 checkOAuthTokenVisibility err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_13100 checkOAuthTokenVisibility stateBack:" + stateBack); - expect(err.code).assertEqual(0); - expect(stateBack).assertEqual(false); - appAccountManager.getOAuthList("account_tokenTest_name","authType",(err,dataArray)=>{ - console.debug("====>ActsAccountOAuthToken_13100 getOAuthList err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_13100 getOAuthList dataArray:" + JSON.stringify(dataArray)); - expect(err.code).assertEqual(0); - expect(dataArray.length).assertEqual(0); - appAccountManager.setOAuthTokenVisibility("account_tokenTest_name","authType","test_bundleName",true,(err)=>{ - console.debug("====>ActsAccountOAuthToken_13100 setOAuthTokenVisibility err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.checkOAuthTokenVisibility("account_tokenTest_name","authType","test_bundleName",(err,stateBack)=>{ - console.debug("====>ActsAccountOAuthToken_13100 checkOAuthTokenVisibility err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_13100 checkOAuthTokenVisibility stateBack:" + stateBack); - expect(err.code).assertEqual(0); - expect(stateBack).assertEqual(true); - appAccountManager.getOAuthList("account_tokenTest_name","authType",(err,dataArray)=>{ - console.debug("====>ActsAccountOAuthToken_13100 getOAuthList err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_13100 getOAuthList dataArray:" + JSON.stringify(dataArray)); - expect(err.code).assertEqual(0); - expect(dataArray.length).assertEqual(1); - expect(dataArray[0]).assertEqual("test_bundleName"); - appAccountManager.deleteAccount("account_tokenTest_name",(err)=>{ - console.debug("====>ActsAccountOAuthToken_13100 deleteAccount err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountOAuthToken_13100 end===="); - done(); - }); - }); - }); - }); - }); - }); - }); - }); - }); - }); - - it('ActsAccountOAuthToken_13200', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_13200 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.getAuthenticatorInfo("com.example.actsaccountOauthtoken",(err,dataInfo)=>{ - console.debug("====>ActsAccountOAuthToken_13200 getAuthenticatorInfo err:" + JSON.stringify(err)); - console.debug("====>ActsAccountOAuthToken_13200 getAuthenticatorInfo dataInfo:" + JSON.stringify(dataInfo)); - expect(err.code).assertEqual(0); - expect(isNaN(dataInfo.iconId)).assertFalse(); - expect(isNaN(dataInfo.labelId)).assertFalse(); - done(); - }); - }); - - it('ActsAccountOAuthToken_13300', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_13300 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.authenticate("authenticate_test_account","com.example.actsaccountOauthtoken","authType",{},{ - onResult: (resultCode, resultData)=>{ - console.debug("====>ActsAccountOAuthToken_13300 authenticate resultCode:" + JSON.stringify(resultCode)); - console.debug("====>ActsAccountOAuthToken_13300 authenticate resultData:" + JSON.stringify(resultData)); - expect(resultCode.code).assertEqual(0); - expect(resultData.name).assertEqual("authenticate_test_account"); - expect(resultData.authType).assertEqual("authType"); - expect(resultData.token).assertEqual("serviceApp/authenticate/Token"); - done(); - }, - onRequestRedirected: null - }); - done(); - }); - - it('ActsAccountOAuthToken_13400', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_13400 start===="); - var appAccountManager = account.createAppAccountManager(); - appAccountManager.addAccountImplicitly("com.example.actsaccountOauthtoken","authType",{},{ - onResult: (resultCode, resultData) =>{ - console.debug("====>ActsAccountOAuthToken_13400 authenticate resultCode:" + JSON.stringify(resultCode)); - console.debug("====>ActsAccountOAuthToken_13400 authenticate resultData:" + JSON.stringify(resultData)); - expect(resultCode.code).assertEqual(0); - expect(resultData.name).assertEqual("authenticate_test_account"); - expect(resultData.authType).assertEqual("authType"); - expect(resultData.token).assertEqual("serviceApp/authenticate/Token"); - done(); - }, - onRequestRedirected: (request) =>{ - console.debug("====>ActsAccountOAuthToken_13400 onRequestRedirected request:" + JSON.stringify(request)); - let abilityStartSetting = { - want:request - } - featureAbility.startAbility(abilityStartSetting, (err, result)=>{ - console.debug("====>ActsAccountOAuthToken_13400 onRequestRedirected err:" + JSON.stringify(err)); - }); - done(); - } - }); - done(); - }); -}) diff --git a/account/appaccount/actsaccounttest/entry/src/main/js/test/OnOff.js b/account/appaccount/actsaccounttest/entry/src/main/js/test/OnOff.js deleted file mode 100755 index 3e4554fd3f6027f919b09dba42406b3f43c5fc20..0000000000000000000000000000000000000000 --- a/account/appaccount/actsaccounttest/entry/src/main/js/test/OnOff.js +++ /dev/null @@ -1,916 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import account from '@ohos.account.appAccount' -import 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 () { - - function sleep(delay) { - return new Promise((resolve, reject) => { - setTimeout(() => { - resolve() - }, delay) - }).then(() => { - console.info(`sleep #{time} over ...`) - }) - } - 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: - {}, - }, - }, - ); - await sleep(TIMEOUT); - done(); - }); - - /* - * @tc.number : ActsAccountChangeOnOff_0100 - * @tc.name : Subscribe/unsubscribe to the change event of application - * @tc.desc : Received the account information change to the authorized account of the subscription to change - * the additional information - */ - 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_extra"); - console.debug("====>enableAppAccess ActsAccountChangeOnOff_0100 start"); - await appAccountManager.enableAppAccess("changeonoff_extra", "com.example.actsaccountsceneonoff"); - function unSubscriberCallback(err){ - console.debug("====>unsubscribe 0100 err:" + JSON.stringify(err)); - } - function deleteAccountCallback(err){ - console.debug("====>delete account 0100 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - done(); - } - function disCallback(err){ - console.debug("====>delete account 0100 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.deleteAccount("changeonoff_extra", deleteAccountCallback); - } - function subscriberCallback(err, data){ - console.debug("====>subscriberCallback 0100 data:" + JSON.stringify(data)); - expect(data.event).assertEqual("account_on_change_extra"); - expect(data.data).assertEqual("SUCCESS"); - commonevent.unsubscribe(subscriber, unSubscriberCallback); - appAccountManager.disableAppAccess("changeonoff_extra", "com.example.actsaccountsceneonoff", disCallback); - } - function publishCallback(err){ - console.debug("====>publish call back err:" + JSON.stringify(err)); - setTimeout(async function (){ - console.debug("====>setAccountExtraInfo start===="); - try{ - await appAccountManager.setAccountExtraInfo("changeonoff_extra", "change_extra"); - } - catch(err){ - console.error("====>setAccountExtraInfo fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>setAccountExtraInfo finish===="); - }, 500) - } - var commonEventSubscribeInfo = { - events: ["account_on_change_extra"] - } - 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); - }); - - /* - * @tc.number : ActsAccountChangeOnOff_0200 - * @tc.name : Subscribe/unsubscribe to the change event of application - * @tc.desc : Received the account information change to the authorized account of the subscription to change - * the associatal data - */ - it('ActsAccountChangeOnOff_0200', 0, async function (done) { - console.debug("====>ActsAccountChangeOnOff_0200 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat appAccountManager finish"); - console.debug("====>add account ActsAccountChangeOnOff_0200 start"); - await appAccountManager.addAccount("onoff_associatedata"); - console.debug("====>enableAppAccess ActsAccountChangeOnOff_0200 start"); - await appAccountManager.enableAppAccess("onoff_associatedata", "com.example.actsaccountsceneonoff"); - function unSubscriberCallback(err){ - console.debug("====>unsubscribe 0200 err:" + JSON.stringify(err)); - } - function deleteAccountCallback(err){ - console.debug("====>delete account 0200 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - done(); - } - function subscriberCallback(err, data){ - console.debug("====>subscriberCallback 0200 data:" + JSON.stringify(data)); - expect(data.event).assertEqual("account_on_change_associatedata"); - expect(data.data).assertEqual("SUCCESS"); - commonevent.unsubscribe(subscriber, unSubscriberCallback); - appAccountManager.deleteAccount("onoff_associatedata", deleteAccountCallback); - } - function publishCallback(err){ - console.debug("====>publish call back err:" + JSON.stringify(err)); - setTimeout(async function (){ - console.debug("====>setAssociatedData start===="); - try{ - await appAccountManager.setAssociatedData("onoff_associatedata", "change_key", "change_value"); - } - catch(err){ - console.error("====>setAssociatedData fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>setAssociatedData finish===="); - }, 500) - } - var commonEventSubscribeInfo = { - events: ["account_on_change_associatedata"] - } - var subscriber - commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){ - subscriber = data; - commonevent.subscribe(subscriber, subscriberCallback); - console.debug("====>subscribe ActsAccountChangeOnOff_0200 finish====") - }); - - var commonEventPublishData = { - code: 2 - } - setTimeout(function (){ - console.debug("====>publish event account_on_change 0200===="); - commonevent.publish("account_on_change", commonEventPublishData, publishCallback); - }, 1000); - }); - - /* - * @tc.number : ActsAccountChangeOnOff_0300 - * @tc.name : Subscribe/unsubscribe to the change event of application - * @tc.desc : Received the account information change to the authorized account of the subscription to change - * the credential - */ - it('ActsAccountChangeOnOff_0300', 0, async function (done) { - console.debug("====>ActsAccountChangeOnOff_0300 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat appAccountManager finish"); - console.debug("====>add account ActsAccountChangeOnOff_0300 start"); - await appAccountManager.addAccount("onoff_credential"); - console.debug("====>enableAppAccess ActsAccountChangeOnOff_0300 start"); - await appAccountManager.enableAppAccess("onoff_credential", "com.example.actsaccountsceneonoff"); - function unSubscriberCallback(err){ - console.debug("====>unsubscribe 0300 err:" + JSON.stringify(err)); - } - function deleteAccountCallback(err){ - console.debug("====>delete account 0300 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - done(); - } - function subscriberCallback(err, data){ - console.debug("====>subscriberCallback 0300 data:" + JSON.stringify(data)); - expect(data.event).assertEqual("account_on_change_credential"); - expect(data.data).assertEqual("SUCCESS"); - commonevent.unsubscribe(subscriber, unSubscriberCallback); - appAccountManager.deleteAccount("onoff_credential", deleteAccountCallback); - } - function publishCallback(err){ - console.debug("====>publish call back err:" + JSON.stringify(err)); - setTimeout(async function (){ - console.debug("====>setAccountCredential start===="); - try{ - await appAccountManager.setAccountCredential("onoff_credential", "credentialType", "credential"); - } - catch(err){ - console.error("====>setAccountCredential fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>setAccountCredential finish===="); - }, 500) - } - var commonEventSubscribeInfo = { - events: ["account_on_change_credential"] - } - var subscriber - commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){ - subscriber = data; - commonevent.subscribe(subscriber, subscriberCallback); - console.debug("====>subscribe ActsAccountChangeOnOff_0300 finish====") - }); - - var commonEventPublishData = { - code: 3 - } - setTimeout(function (){ - console.debug("====>publish event account_on_change 0300===="); - commonevent.publish("account_on_change", commonEventPublishData, publishCallback); - }, 1000); - }); - - /* - * @tc.number : ActsAccountChangeOnOff_0400 - * @tc.name : Subscribe/unsubscribe to the change event of application - * @tc.desc : Received the account information change to the authorized account of the subscription to delete - * authorized account - */ - it('ActsAccountChangeOnOff_0400', 0, async function (done) { - console.debug("====>ActsAccountChangeOnOff_0400 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat appAccountManager finish"); - console.debug("====>add first account ActsAccountChangeOnOff_0400 start"); - await appAccountManager.addAccount("onoff_deleteFir"); - console.debug("====>add second account ActsAccountChangeOnOff_0400 start"); - await appAccountManager.addAccount("onoff_deleteSec"); - console.debug("====>enableAppAccess first ActsAccountChangeOnOff_0400 start"); - await appAccountManager.enableAppAccess("onoff_deleteFir", "com.example.actsaccountsceneonoff"); - console.debug("====>enableAppAccess second ActsAccountChangeOnOff_0400 start"); - await appAccountManager.enableAppAccess("onoff_deleteSec", "com.example.actsaccountsceneonoff"); - function unSubscriberCallback(err){ - console.debug("====>unsubscribe 0400 err:" + JSON.stringify(err)); - } - function deleteAccountCallback(err){ - console.debug("====>delete account 0400 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - done(); - } - function subscriberCallback(err, data){ - console.debug("====>subscriberCallback 0400 data:" + JSON.stringify(data)); - expect(data.event).assertEqual("account_on_delete_another"); - expect(data.data).assertEqual("SUCCESS"); - commonevent.unsubscribe(subscriber, unSubscriberCallback); - appAccountManager.deleteAccount("onoff_deleteFir", deleteAccountCallback); - } - function publishCallback(err){ - console.debug("====>publish call back err:" + JSON.stringify(err)); - setTimeout(async function (){ - console.debug("====>deleteAccount start===="); - try{ - await appAccountManager.deleteAccount("onoff_deleteSec"); - } - catch(err){ - console.error("====>deleteAccount fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>deleteAccount finish===="); - }, 500) - } - var commonEventSubscribeInfo = { - events: ["account_on_delete_another"] - } - var subscriber - commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){ - subscriber = data; - commonevent.subscribe(subscriber, subscriberCallback); - console.debug("====>subscribe ActsAccountChangeOnOff_0400 finish====") - }); - - var commonEventPublishData = { - code: 4 - } - setTimeout(function (){ - console.debug("====>publish event account_on_change 0400===="); - commonevent.publish("account_on_change", commonEventPublishData, publishCallback); - }, 1000); - }); - - /* - * @tc.number : ActsAccountChangeOnOff_0500 - * @tc.name : Subscribe/unsubscribe to the change event of application - * @tc.desc : Received the account information change to the authorized account of the subscription to delete - * the only authorized account - */ - it('ActsAccountChangeOnOff_0500', 0, async function (done) { - console.debug("====>ActsAccountChangeOnOff_0500 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat appAccountManager finish"); - console.debug("====>add account ActsAccountChangeOnOff_0500 start"); - await appAccountManager.addAccount("onoff_delete"); - console.debug("====>enableAppAccess ActsAccountChangeOnOff_0500 start"); - await appAccountManager.enableAppAccess("onoff_delete", "com.example.actsaccountsceneonoff"); - function unSubscriberCallback(err){ - console.debug("====>unsubscribe 0500 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - done(); - } - function subscriberCallback(err, data){ - console.debug("====>subscriberCallback 0500 data:" + JSON.stringify(data)); - expect(data.event).assertEqual("account_on_change_delete"); - expect(data.data).assertEqual("SUCCESS"); - commonevent.unsubscribe(subscriber, unSubscriberCallback); - } - function publishCallback(err){ - console.debug("====>publish call back err:" + JSON.stringify(err)); - setTimeout(async function (){ - console.debug("====>deleteAccount start===="); - try{ - await appAccountManager.deleteAccount("onoff_delete"); - } - catch(err){ - console.error("====>deleteAccount fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>deleteAccount finish===="); - }, 500) - } - var commonEventSubscribeInfo = { - events: ["account_on_change_delete"] - } - var subscriber - commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){ - subscriber = data; - commonevent.subscribe(subscriber, subscriberCallback); - console.debug("====>subscribe ActsAccountChangeOnOff_0500 finish====") - }); - - var commonEventPublishData = { - code: 5 - } - setTimeout(function (){ - console.debug("====>publish event account_on_change 0500===="); - commonevent.publish("account_on_change", commonEventPublishData, publishCallback); - }, 1000); - }); - - /* - * @tc.number : ActsAccountChangeOnOff_0600 - * @tc.name : Subscribe/unsubscribe to the change event of application - * @tc.desc : Received the account information change to the authorized account of the subscription to cancel - * authorized account - */ - it('ActsAccountChangeOnOff_0600', 0, async function (done) { - console.debug("====>ActsAccountChangeOnOff_0600 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat appAccountManager finish"); - console.debug("====>add first account ActsAccountChangeOnOff_0600 start"); - await appAccountManager.addAccount("onoff_enableFir"); - console.debug("====>add second account ActsAccountChangeOnOff_0600 start"); - await appAccountManager.addAccount("onoff_enableSec"); - console.debug("====>enableAppAccess first ActsAccountChangeOnOff_0600 start"); - await appAccountManager.enableAppAccess("onoff_enableFir", "com.example.actsaccountsceneonoff"); - console.debug("====>enableAppAccess second ActsAccountChangeOnOff_0600 start"); - await appAccountManager.enableAppAccess("onoff_enableSec", "com.example.actsaccountsceneonoff"); - function unSubscriberCallback(err){ - console.debug("====>unsubscribe 0600 err:" + JSON.stringify(err)); - } - function deleteAccountCallback(err){ - console.debug("====>delete first account 0600 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.deleteAccount("onoff_enableSec", (err)=>{ - console.debug("====>delete second account 0600 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - done(); - }); - } - function subscriberCallback(err, data){ - console.debug("====>subscriberCallback 0600 data:" + JSON.stringify(data)); - expect(data.event).assertEqual("account_on_disable_another"); - expect(data.data).assertEqual("SUCCESS"); - commonevent.unsubscribe(subscriber, unSubscriberCallback); - appAccountManager.deleteAccount("onoff_enableFir", deleteAccountCallback); - } - function publishCallback(err){ - console.debug("====>publish call back err:" + JSON.stringify(err)); - setTimeout(async function (){ - console.debug("====>disableAppAccess start===="); - try{ - await appAccountManager.disableAppAccess("onoff_enableSec", "com.example.actsaccountsceneonoff"); - } - catch(err){ - console.error("====>disableAppAccess fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>disableAppAccess finish===="); - }, 500) - } - var commonEventSubscribeInfo = { - events: ["account_on_disable_another"] - } - var subscriber - commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){ - subscriber = data; - commonevent.subscribe(subscriber, subscriberCallback); - console.debug("====>subscribe ActsAccountChangeOnOff_0600 finish====") - }); - - var commonEventPublishData = { - code: 6 - } - setTimeout(function (){ - console.debug("====>publish event account_on_change 0600===="); - commonevent.publish("account_on_change", commonEventPublishData, publishCallback); - }, 1000); - }); - - /* - * @tc.number : ActsAccountChangeOnOff_0700 - * @tc.name : Subscribe/unsubscribe to the change event of application - * @tc.desc : Received the account information change to the authorized account of the subscription to cancel - * the only authorized account - */ - it('ActsAccountChangeOnOff_0700', 0, async function (done) { - console.debug("====>ActsAccountChangeOnOff_0700 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat appAccountManager finish"); - console.debug("====>add account ActsAccountChangeOnOff_0700 start"); - await appAccountManager.addAccount("onoff_disable"); - console.debug("====>enableAppAccess ActsAccountChangeOnOff_0700 start"); - await appAccountManager.enableAppAccess("onoff_disable", "com.example.actsaccountsceneonoff"); - function unSubscriberCallback(err){ - console.debug("====>unsubscribe 0700 err:" + JSON.stringify(err)); - } - function deleteAccountCallback(err){ - console.debug("====>delete account 0700 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - done(); - } - function subscriberCallback(err, data){ - console.debug("====>subscriberCallback 0700 data:" + JSON.stringify(data)); - expect(data.event).assertEqual("account_on_change_disable"); - expect(data.data).assertEqual("SUCCESS"); - commonevent.unsubscribe(subscriber, unSubscriberCallback); - appAccountManager.deleteAccount("onoff_disable", deleteAccountCallback); - } - function publishCallback(err){ - console.debug("====>publish call back err:" + JSON.stringify(err)); - setTimeout(async function (){ - console.debug("====>disableAppAccess start===="); - try{ - await appAccountManager.disableAppAccess("onoff_disable", "com.example.actsaccountsceneonoff"); - } - catch(err){ - console.error("====>disableAppAccess fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>disableAppAccess finish===="); - }, 500) - } - var commonEventSubscribeInfo = { - events: ["account_on_change_disable"] - } - var subscriber - commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){ - subscriber = data; - commonevent.subscribe(subscriber, subscriberCallback); - console.debug("====>subscribe ActsAccountChangeOnOff_0700 finish====") - }); - - var commonEventPublishData = { - code: 7 - } - setTimeout(function (){ - console.debug("====>publish event account_on_change 0700===="); - commonevent.publish("account_on_change", commonEventPublishData, publishCallback); - }, 1000); - }); - - /* - * @tc.number : ActsAccountChangeOnOff_0800 - * @tc.name : Subscribe/unsubscribe to the change event of application - * @tc.desc : Receive account information after the app subscribes to itself and changes additional information - */ - it('ActsAccountChangeOnOff_0800', 0, async function (done) { - console.debug("====>ActsAccountChangeOnOff_0800 start===="); - let dataMap = new Map(); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat appAccountManager finish"); - console.debug("====>add account ActsAccountChangeOnOff_0800 start"); - await appAccountManager.addAccount("onoff_self"); - console.debug("====>on ActsAccountChangeOnOff_0800 start"); - function changeOnCallback(data){ - console.debug("====>receive change 0800 data:" + JSON.stringify(data)); - console.debug("====>data.length:" + data.length); - for (let i = 0, len = data.length; i < len; i++) { - dataMap.set(data[i].name, data[i].owner) - } - expect(dataMap.has("onoff_self")).assertTrue(); - if (dataMap.has("onoff_self")) { - let data = dataMap.get("onoff_self"); - console.debug("====>the account owner is: " + data); - expect(data).assertEqual("com.example.actsaccounttest"); - } - appAccountManager.off('change', function (){ - console.debug("====>off ActsAccountChangeOnOff_0800 finish===="); - appAccountManager.deleteAccount("onoff_self", (err)=>{ - console.debug("====>delete account ActsAccountChangeOnOff_0800 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountChangeOnOff_0800 end===="); - done(); - }); - }); - } - try{ - appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnCallback); - } - catch(err){ - console.error("====>on ActsAccountChangeOnOff_0800 err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>setAccountExtraInfo start===="); - try{ - await appAccountManager.setAccountExtraInfo("onoff_self", "change_extra"); - } - catch(err){ - console.error("====>setAccountExtraInfo fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - }); - - /* - * @tc.number : ActsAccountChangeOnOff_0900 - * @tc.name : Subscribe/unsubscribe to the change event of application - * @tc.desc : Receiving account information after adding two accounts to the app, subscribing to itself, - * and changing one of the associatal data - */ - it('ActsAccountChangeOnOff_0900', 0, async function (done) { - console.debug("====>ActsAccountChangeOnOff_0900 start===="); - let dataMap = new Map(); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat appAccountManager finish"); - console.debug("====>add first account ActsAccountChangeOnOff_0900 start"); - await appAccountManager.addAccount("onoff_self_first"); - console.debug("====>add second account ActsAccountChangeOnOff_0900 start"); - await appAccountManager.addAccount("onoff_self_second"); - console.debug("====>on ActsAccountChangeOnOff_0900 start"); - function changeOnCallback(data){ - console.debug("====>receive change 0900 data:" + JSON.stringify(data)); - console.debug("====>data.length:" + data.length); - for (let i = 0, len = data.length; i < len; i++) { - dataMap.set(data[i].name, data[i].owner) - } - expect(dataMap.has("onoff_self_first")).assertTrue(); - if (dataMap.has("onoff_self_first")) { - let data = dataMap.get("onoff_self_first"); - console.debug("====>the account owner is: " + data); - expect(data).assertEqual("com.example.actsaccounttest"); - } - expect(dataMap.has("onoff_self_second")).assertTrue(); - if (dataMap.has("onoff_self_second")) { - let data = dataMap.get("onoff_self_second"); - console.debug("====>the account owner is: " + data); - expect(data).assertEqual("com.example.actsaccounttest"); - } - appAccountManager.off('change', function (){ - console.debug("====>off ActsAccountChangeOnOff_0900 finish===="); - appAccountManager.deleteAccount("onoff_self_first", (err)=>{ - console.debug("====>delete first account 0900 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.deleteAccount("onoff_self_second", (err)=>{ - console.debug("====>delete second account 0900 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountChangeOnOff_0900 end===="); - done(); - }); - }); - }); - } - try{ - appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnCallback); - } - catch(err){ - console.error("====>on ActsAccountChangeOnOff_0900 err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>setAssociatedData start===="); - try{ - await appAccountManager.setAssociatedData("onoff_self_second", "change_key", "change_value"); - } - catch(err){ - console.error("====>setAssociatedData fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - }); - - /* - * @tc.number : ActsAccountChangeOnOff_1000 - * @tc.name : Subscribe/unsubscribe to the change event of application - * @tc.desc : Repeat subscription account information changes, the subscription behavior is independent - */ - it('ActsAccountChangeOnOff_1000', 0, async function (done) { - console.debug("====>ActsAccountChangeOnOff_1000 start===="); - let dataMapFir = new Map(); - let dataMapSec = new Map(); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat appAccountManager finish"); - console.debug("====>add account ActsAccountChangeOnOff_1000 start"); - await appAccountManager.addAccount("onoff_twice"); - console.debug("====>on ActsAccountChangeOnOff_1000 start"); - var twiceSign = 0; - function changeOnFirstCallback(data){ - console.debug("====>first receive change 1000 data:" + JSON.stringify(data)); - console.debug("====>data.length:" + data.length); - for (let i = 0, len = data.length; i < len; i++) { - dataMapFir.set(data[i].name, data[i].owner) - } - expect(dataMapFir.has("onoff_twice")).assertTrue(); - if (dataMapFir.has("onoff_twice")) { - let data = dataMapFir.get("onoff_twice"); - console.debug("====>the account owner is: " + data); - expect(data).assertEqual("com.example.actsaccounttest"); - } - twiceSign = twiceSign + 1; - } - function changeOnSecondCallback(data){ - console.debug("====>second receive change 1000 data:" + JSON.stringify(data)); - console.debug("====>data.length:" + data.length); - for (let i = 0, len = data.length; i < len; i++) { - dataMapSec.set(data[i].name, data[i].owner) - } - expect(dataMapSec.has("onoff_twice")).assertTrue(); - if (dataMapSec.has("onoff_twice")) { - let data = dataMapSec.get("onoff_twice"); - console.debug("====>the account owner is: " + data); - expect(data).assertEqual("com.example.actsaccounttest"); - } - twiceSign = twiceSign + 1; - setTimeout(async function (){ - console.debug("====>off start===="); - appAccountManager.off('change', function (){ - console.debug("====>off ActsAccountChangeOnOff_1000 finish===="); - appAccountManager.deleteAccount("onoff_twice", (err)=>{ - console.debug("====>delete account ActsAccountChangeOnOff_1000 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - expect(twiceSign).assertEqual(2); - console.debug("====>ActsAccountChangeOnOff_1000 end===="); - done(); - }); - }); - }, 1000) - } - try{ - appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnFirstCallback); - appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnSecondCallback); - } - catch(err){ - console.error("====>on ActsAccountChangeOnOff_1000 err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>setAccountExtraInfo start===="); - try{ - await appAccountManager.setAccountExtraInfo("onoff_twice", "change_extra"); - } - catch(err){ - console.error("====>setAccountExtraInfo fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - }); - - /* - * @tc.number : ActsAccountChangeOnOff_1100 - * @tc.name : Subscribe/unsubscribe to the change event of application - * @tc.desc : Subscription account information changes, where the bundleName in the parameter owners is - * duplicated - */ - it('ActsAccountChangeOnOff_1100', 0, async function (done) { - console.debug("====>ActsAccountChangeOnOff_1100 start===="); - let dataMap = new Map(); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat appAccountManager finish"); - console.debug("====>add account ActsAccountChangeOnOff_1100 start"); - await appAccountManager.addAccount("onoff_same"); - console.debug("====>on ActsAccountChangeOnOff_1100 start"); - var sameSign = 0; - function onCallBack(data){ - console.debug("====>receive change 1100 data:" + JSON.stringify(data)); - sameSign = sameSign + 1; - console.debug("====>data.length:" + data.length); - for (let i = 0, len = data.length; i < len; i++) { - dataMap.set(data[i].name, data[i].owner) - } - expect(dataMap.has("onoff_same")).assertTrue(); - if (dataMap.has("onoff_same")) { - let data = dataMap.get("onoff_same"); - console.debug("====>the account owner is: " + data); - expect(data).assertEqual("com.example.actsaccounttest"); - } - } - try{ - appAccountManager.on('change', ["com.example.actsaccounttest", "com.example.actsaccounttest"], onCallBack); - } - catch(err){ - console.error("====>on ActsAccountChangeOnOff_1100 err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>setAccountExtraInfo start===="); - try{ - await appAccountManager.setAccountExtraInfo("onoff_same", "change_extra"); - } - catch(err){ - console.error("====>setAccountExtraInfo fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - setTimeout(async function (){ - console.debug("====>off 1100 start===="); - expect(sameSign).assertEqual(1); - appAccountManager.off('change', function (){ - console.debug("====>off ActsAccountChangeOnOff_1100 finish===="); - appAccountManager.deleteAccount("onoff_same", (err)=>{ - console.debug("====>delete account ActsAccountChangeOnOff_1100 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountChangeOnOff_1100 end===="); - done(); - }); - }); - }, 1000) - }); - - /* - * @tc.number : ActsAccountChangeOnOff_1200 - * @tc.name : Subscribe/unsubscribe to the change event of application - * @tc.desc : Repeatedly cancel the subscription after the subscription account information is changed - */ - it('ActsAccountChangeOnOff_1200', 0, async function (done) { - console.debug("====>ActsAccountChangeOnOff_1200 start===="); - let dataMap = new Map(); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat appAccountManager finish"); - console.debug("====>add account ActsAccountChangeOnOff_1200 start"); - await appAccountManager.addAccount("onoff_repeatoff"); - console.debug("====>on ActsAccountChangeOnOff_1200 start"); - function changeOnCallback(data){ - console.debug("====>receive change 1200 data:" + JSON.stringify(data)); - console.debug("====>data.length:" + data.length); - for (let i = 0, len = data.length; i < len; i++) { - dataMap.set(data[i].name, data[i].owner) - } - expect(dataMap.has("onoff_repeatoff")).assertTrue(); - if (dataMap.has("onoff_repeatoff")) { - let data = dataMap.get("onoff_repeatoff"); - console.debug("====>the account owner is: " + data); - expect(data).assertEqual("com.example.actsaccounttest"); - } - appAccountManager.off('change', function (){ - console.debug("====>first off ActsAccountChangeOnOff_1200 finish===="); - appAccountManager.off('change', function (){ - console.debug("====>second off ActsAccountChangeOnOff_1200 finish===="); - setTimeout(async function (){ - console.debug("====>delete account 1200 start===="); - appAccountManager.deleteAccount("onoff_repeatoff", (err)=>{ - console.debug("====>delete account ActsAccountChangeOnOff_1200 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountChangeOnOff_1200 end===="); - done(); - }); - }, 1000) - }); - }); - } - try{ - appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnCallback); - } - catch(err){ - console.error("====>on ActsAccountChangeOnOff_1200 err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>setAccountExtraInfo start===="); - try{ - await appAccountManager.setAccountExtraInfo("onoff_repeatoff", "change_extra"); - } - catch(err){ - console.error("====>setAccountExtraInfo fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - }); - - /* - * @tc.number : ActsAccountChangeOnOff_1300 - * @tc.name : Subscribe/unsubscribe to the change event of application - * @tc.desc : There is an unauthorized bundleName in the subscription parameter owners array, and the - * subscription fails - */ - it('ActsAccountChangeOnOff_1300', 0, async function (done) { - console.debug("====>ActsAccountChangeOnOff_1300 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat appAccountManager finish"); - console.debug("====>add account ActsAccountChangeOnOff_1300 start"); - await appAccountManager.addAccount("onoff_same"); - console.debug("====>on ActsAccountChangeOnOff_1300 start"); - function changeOnCallBack(data){ - console.debug("====>receive change 1300 data:" + JSON.stringify(data)); - expect().assertFail(); - done(); - } - var unauthorizedBundle = "com.example.actsaccountsceneonoff"; - try{ - appAccountManager.on('change', ["com.example.actsaccounttest", unauthorizedBundle], changeOnCallBack); - } - catch(err){ - console.error("====>on ActsAccountChangeOnOff_1300 err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>setAccountExtraInfo start===="); - try{ - await appAccountManager.setAccountExtraInfo("onoff_same", "change_extra"); - } - catch(err){ - console.error("====>setAccountExtraInfo fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - setTimeout(async function (){ - console.debug("====>delete account 1300 start===="); - appAccountManager.deleteAccount("onoff_same", (err)=>{ - console.debug("====>delete account ActsAccountChangeOnOff_1300 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountChangeOnOff_1300 end===="); - done(); - }); - }, 1000) - }); - - /* - * @tc.number : ActsAccountChangeOnOff_1400 - * @tc.name : Subscribe/unsubscribe to the change event of application - * @tc.desc : There is a bundleName that does not exist in the subscription parameter owners array, and the - * subscription fails - */ - it('ActsAccountChangeOnOff_1400', 0, async function (done) { - console.debug("====>ActsAccountChangeOnOff_1400 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat appAccountManager finish"); - console.debug("====>add account ActsAccountChangeOnOff_1400 start"); - await appAccountManager.addAccount("onoff_same"); - console.debug("====>on ActsAccountChangeOnOff_1400 start"); - function changeOnCallBack(data){ - console.debug("====>receive change 1300 data:" + JSON.stringify(data)); - expect().assertFail(); - done(); - } - var nonexistentBundle = "com.example.actsaccountnoneexistent"; - try{ - appAccountManager.on('change', ["com.example.actsaccounttest", nonexistentBundle], changeOnCallBack); - } - catch(err){ - console.error("====>on ActsAccountChangeOnOff_1400 err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>setAccountExtraInfo start===="); - try{ - await appAccountManager.setAccountExtraInfo("onoff_same", "change_extra"); - } - catch(err){ - console.error("====>setAccountExtraInfo fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - setTimeout(async function (){ - console.debug("====>delete account 1400 start===="); - appAccountManager.deleteAccount("onoff_same", (err)=>{ - console.debug("====>delete account ActsAccountChangeOnOff_1400 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsAccountChangeOnOff_1400 end===="); - done(); - }); - }, 1000) - }); -}) \ No newline at end of file diff --git a/account/appaccount/actsaccounttest/entry/src/main/config.json b/account/appaccount/actsaccounttest/src/main/config.json old mode 100755 new mode 100644 similarity index 50% rename from account/appaccount/actsaccounttest/entry/src/main/config.json rename to account/appaccount/actsaccounttest/src/main/config.json index b1668694243172afa9bf1b7410df046c4fb941e5..e47e0d633e3b22fa3b1f853a4dd6822a91edd311 --- a/account/appaccount/actsaccounttest/entry/src/main/config.json +++ b/account/appaccount/actsaccounttest/src/main/config.json @@ -48,25 +48,42 @@ ], "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" + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "formsEnabled": false, + "name": ".MainAbility", + "srcLanguage": "js", + "srcPath": "MainAbility", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "label": "$string:MainAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "js", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" } - ], + ], "js": [ { "pages": [ @@ -77,7 +94,21 @@ "designWidth": 720, "autoDesignWidth": false } + }, + { + "pages": [ + "pages/index/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } } - ] + ], + "testRunner": { + "name": "OpenHarmonyTestRunner", + "srcPath": "TestRunner" + } } } \ No newline at end of file diff --git a/account/appaccount/actsaccounttest/entry/src/main/js/default/app.js b/account/appaccount/actsaccounttest/src/main/js/MainAbility/app.js similarity index 100% rename from account/appaccount/actsaccounttest/entry/src/main/js/default/app.js rename to account/appaccount/actsaccounttest/src/main/js/MainAbility/app.js diff --git a/account/appaccount/actsaccounttest/entry/src/main/js/default/i18n/en-US.json b/account/appaccount/actsaccounttest/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from account/appaccount/actsaccounttest/entry/src/main/js/default/i18n/en-US.json rename to account/appaccount/actsaccounttest/src/main/js/MainAbility/i18n/en-US.json diff --git a/account/appaccount/actsaccounttest/entry/src/main/js/default/i18n/zh-CN.json b/account/appaccount/actsaccounttest/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from account/appaccount/actsaccounttest/entry/src/main/js/default/i18n/zh-CN.json rename to account/appaccount/actsaccounttest/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/account/appaccount/actsaccountpressure/entry/src/main/js/test/List.test.js b/account/appaccount/actsaccounttest/src/main/js/MainAbility/pages/index/index.css similarity index 82% rename from account/appaccount/actsaccountpressure/entry/src/main/js/test/List.test.js rename to account/appaccount/actsaccounttest/src/main/js/MainAbility/pages/index/index.css index 489bb9ab541fdb7643843cb454c258398bea4332..2334ecfa2c147f276998e82e2c35f62800cfb031 100644 --- a/account/appaccount/actsaccountpressure/entry/src/main/js/test/List.test.js +++ b/account/appaccount/actsaccounttest/src/main/js/MainAbility/pages/index/index.css @@ -12,4 +12,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -require('./Pressure.test.js') \ No newline at end of file + +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/account/appaccount/actsaccounttest/src/main/js/MainAbility/pages/index/index.hml b/account/appaccount/actsaccounttest/src/main/js/MainAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..f7fa13538134ab88f502a6d53885f46df315d7bf --- /dev/null +++ b/account/appaccount/actsaccounttest/src/main/js/MainAbility/pages/index/index.hml @@ -0,0 +1,20 @@ + + +
+ + {{title}} + +
diff --git a/account/appaccount/actsaccounttest/src/main/js/MainAbility/pages/index/index.js b/account/appaccount/actsaccounttest/src/main/js/MainAbility/pages/index/index.js new file mode 100755 index 0000000000000000000000000000000000000000..78f8ddb742337bd3eb9acb1368a144454870c331 --- /dev/null +++ b/account/appaccount/actsaccounttest/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,27 @@ +/* + * 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. + */ +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') + }, + onReady() { + }, +} \ No newline at end of file diff --git a/account/appaccount/actsaccounttest/src/main/js/TestAbility/app.js b/account/appaccount/actsaccounttest/src/main/js/TestAbility/app.js new file mode 100644 index 0000000000000000000000000000000000000000..cdc31f3dcf031e2f6a7665d9653e53bb649e21c5 --- /dev/null +++ b/account/appaccount/actsaccounttest/src/main/js/TestAbility/app.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('TestApplication onCreate') + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info("TestApplication onDestroy"); + } +}; diff --git a/account/appaccount/actsaccounttest/src/main/js/TestAbility/i18n/en-US.json b/account/appaccount/actsaccounttest/src/main/js/TestAbility/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..3cb24b374b1d919ca8eac0638f361692b603a900 --- /dev/null +++ b/account/appaccount/actsaccounttest/src/main/js/TestAbility/i18n/en-US.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } +} \ No newline at end of file diff --git a/account/appaccount/actsaccounttest/src/main/js/TestAbility/i18n/zh-CN.json b/account/appaccount/actsaccounttest/src/main/js/TestAbility/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..c804e32c0c3103929baca5617cdac70be11fdba1 --- /dev/null +++ b/account/appaccount/actsaccounttest/src/main/js/TestAbility/i18n/zh-CN.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } +} \ No newline at end of file diff --git a/account/appaccount/actsaccounttest/src/main/js/TestAbility/pages/index/index.css b/account/appaccount/actsaccounttest/src/main/js/TestAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..2b45eb97c17e67ef5d63436aad8998113aa95d6d --- /dev/null +++ b/account/appaccount/actsaccounttest/src/main/js/TestAbility/pages/index/index.css @@ -0,0 +1,50 @@ +/* + * 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. + */ + +.container { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + left: 0px; + top: 0px; + width: 100%; + height: 100%; +} + +.title { + font-size: 60px; + text-align: center; + width: 100%; + height: 40%; + margin: 10px; +} +.btn { + width: 50%; + height: 100px; + font-size: 40px; +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} \ No newline at end of file diff --git a/account/appaccount/actsaccounttest/src/main/js/TestAbility/pages/index/index.hml b/account/appaccount/actsaccounttest/src/main/js/TestAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..61ea59d936e5a2971f1ea3d179c44a7f3f596c54 --- /dev/null +++ b/account/appaccount/actsaccounttest/src/main/js/TestAbility/pages/index/index.hml @@ -0,0 +1,21 @@ + + +
+ + {{ $t('strings.hello') }} {{title}} + + +
diff --git a/account/appaccount/actsaccounttest/src/main/js/TestAbility/pages/index/index.js b/account/appaccount/actsaccounttest/src/main/js/TestAbility/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..88b083a7f6b979019d6a2c5ad20b19c5fd43286b --- /dev/null +++ b/account/appaccount/actsaccounttest/src/main/js/TestAbility/pages/index/index.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + } +} + + + diff --git a/account/appaccount/actsaccounttest/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/account/appaccount/actsaccounttest/src/main/js/TestRunner/OpenHarmonyTestRunner.js new file mode 100644 index 0000000000000000000000000000000000000000..c5fa8620ca77d381f20b65a903b833e6e3378c97 --- /dev/null +++ b/account/appaccount/actsaccounttest/src/main/js/TestRunner/OpenHarmonyTestRunner.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package', '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + + export default { + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + }, + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + console.info('debug value : '+debug) + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, (err, data) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + data.stdResult); + console.info('executeShellCommand : data : ' + data.exitCode); + }) + } +}; diff --git a/account/appaccount/actsaccounttest/src/main/js/test/AddAccount.test.js b/account/appaccount/actsaccounttest/src/main/js/test/AddAccount.test.js new file mode 100755 index 0000000000000000000000000000000000000000..378860d17c3d216712b736c6fb05f00e855bcaac --- /dev/null +++ b/account/appaccount/actsaccounttest/src/main/js/test/AddAccount.test.js @@ -0,0 +1,648 @@ +/* + * 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 '@ohos/hypium' + +const NAMELIMIT = 512; +const LENGTHLIMIT = 1024; +export default function ActsAccountAddAccount() { + describe('ActsAccountAddAccount', function () { + + /* + * @tc.number : ActsAccountAddAccount_0100 + * @tc.name : Add account callback form + * @tc.desc : Add account in callback form without additional information + */ + it('ActsAccountAddAccount_0100', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_0100 start===="); + 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 callback form + * @tc.desc : Add account in callback 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 callback 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 callback form + * @tc.desc : The account name exceeds the length limit of 512 characters + */ + it('ActsAccountAddAccount_0700', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_0700 start===="); + var limitAccountName = ''; + for (var i = 0; i < NAMELIMIT + 1; i++) { + limitAccountName += 't'; + } + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount(limitAccountName, "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 512 characters + */ + it('ActsAccountAddAccount_0800', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_0800 start===="); + var limitAccountName = ''; + for (var i = 0; i < NAMELIMIT + 1; i++) { + limitAccountName += 'n'; + } + var appAccountManager = account.createAppAccountManager(); + try{ + await appAccountManager.addAccount(limitAccountName, "account_extraInfo_promise_fourth"); + expect().assertFail(); + done(); + } + 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 callback form + * @tc.desc : Additional information exceeds the length limit of 1024 characters + */ + it('ActsAccountAddAccount_0900', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_0900 start===="); + var limitAccountExtra = ''; + for (var i = 0; i < LENGTHLIMIT + 1; i++) { + limitAccountExtra += 't'; + } + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_name_callback_fifth", limitAccountExtra, (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 characters + */ + it('ActsAccountAddAccount_1000', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_1000 start===="); + var limitAccountExtra = ''; + for (var i = 0; i < LENGTHLIMIT + 1; i++) { + limitAccountExtra += 'e'; + } + var appAccountManager = account.createAppAccountManager(); + try{ + await appAccountManager.addAccount("account_name_promise_fifth", limitAccountExtra); + } + 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 callback 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 callback 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 callback 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 callback 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 callback 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 callback 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 callback 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(); + } + }); + + /* + * @tc.number : ActsAccountAddAccount_2500 + * @tc.name : Add account callback form + * @tc.desc : The account name reaches the limit of 512 characters + */ + it('ActsAccountAddAccount_2500', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_2500 start===="); + var limitName = ''; + for (var i = 0; i < NAMELIMIT; i++) { + limitName += 't'; + } + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount(limitName, "account_extraInfo_callback", (err)=>{ + console.debug("====>add account ActsAccountAddAccount_2500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount(limitName, (err)=>{ + console.debug("====>delete Account ActsAccountAddAccount_2500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAddAccount_2500 end===="); + done(); + }); + }); + }); + + /* + * @tc.number : ActsAccountAddAccount_2600 + * @tc.name : Add account promise form + * @tc.desc : The account name reaches the limit of 512 characters + */ + it('ActsAccountAddAccount_2600', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_2600 start===="); + var nameLimit = ''; + for (var i = 0; i < NAMELIMIT; i++) { + nameLimit += 't'; + } + var appAccountManager = account.createAppAccountManager(); + console.debug("====>add account ActsAccountAddAccount_2600 start===="); + try{ + await appAccountManager.addAccount(nameLimit, "account_extraInfo_promise"); + } + catch(err){ + console.error("====>add account ActsAccountAddAccount_2600 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>delete account ActsAccountAddAccount_2600 start===="); + await appAccountManager.deleteAccount(nameLimit); + console.debug("====>ActsAccountAddAccount_2600 end===="); + done(); + }); + + /* + * @tc.number : ActsAccountAddAccount_2700 + * @tc.name : Add account callback form + * @tc.desc : Additional information reaches the limit of 1024 characters + */ + it('ActsAccountAddAccount_2700', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_2700 start===="); + var limitExtra = ''; + for (var i = 0; i < LENGTHLIMIT; i++) { + limitExtra += 't'; + } + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_extra_callback_limit", limitExtra, (err)=>{ + console.debug("====>add account ActsAccountAddAccount_2700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount("account_extra_callback_limit", (err)=>{ + console.debug("====>delete Account ActsAccountAddAccount_2700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountAddAccount_2700 end===="); + done(); + }); + }); + }); + + /* + * @tc.number : ActsAccountAddAccount_2800 + * @tc.name : Add account promise form + * @tc.desc : Additional information reaches the limit of 1024 characters + */ + it('ActsAccountAddAccount_2800', 0, async function (done) { + console.debug("====>ActsAccountAddAccount_2800 start===="); + var extraLimit = ''; + for (var i = 0; i < LENGTHLIMIT; i++) { + extraLimit += 't'; + } + var appAccountManager = account.createAppAccountManager(); + try{ + await appAccountManager.addAccount("account_extra_promise_limit", extraLimit); + } + catch(err){ + console.error("====>add account ActsAccountAddAccount_2800 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>delete account ActsAccountAddAccount_2800 start===="); + appAccountManager.deleteAccount("account_extra_promise_limit"); + console.debug("====>ActsAccountAddAccount_2800 end===="); + done(); + }); + }) +} \ No newline at end of file diff --git a/account/appaccount/actsaccounttest/src/main/js/test/AppAccess.test.js b/account/appaccount/actsaccounttest/src/main/js/test/AppAccess.test.js new file mode 100755 index 0000000000000000000000000000000000000000..8f5b08c13b01876a5f7a054be669a7bb96faf579 --- /dev/null +++ b/account/appaccount/actsaccounttest/src/main/js/test/AppAccess.test.js @@ -0,0 +1,564 @@ +/* + * 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 '@ohos/hypium' + +const TIMEOUT = 5000; +const STRCOUNT = 1025; +const EACHTIMEOUT = 500; +export default function ActsAccountAppAccess() { + describe('ActsAccountAppAccess', function () { + function sleep(delay) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, delay) + }).then(() => { + console.info(`sleep #{time} over ...`) + }) + } + + beforeAll(async function (done) { + console.debug("====>beforeAll start===="); + await sleep(TIMEOUT); + console.debug("====>beforeAll end===="); + done(); + }) + + beforeEach(async function (done) { + console.debug("====>beforeEach enter===="); + await sleep(EACHTIMEOUT); + 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===="); + try{ + await appAccountManager.addAccount("AppAccess_promise_account"); + } + catch(err){ + console.error("====>addAccount ActsAccountAppAccess_0800 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + 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===="); + try{ + await appAccountManager.addAccount("AppAccess_promise_account"); + } + catch(err){ + console.error("====>addAccount ActsAccountAppAccess_1600 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + 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/src/main/js/test/AssociatedData.test.js b/account/appaccount/actsaccounttest/src/main/js/test/AssociatedData.test.js new file mode 100755 index 0000000000000000000000000000000000000000..3e9bfd628bea744c892bb67175a92f5f614a5cdb --- /dev/null +++ b/account/appaccount/actsaccounttest/src/main/js/test/AssociatedData.test.js @@ -0,0 +1,1165 @@ +/* + * 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 '@ohos/hypium' + +const TIMEOUT = 5000; +const EACHTIMEOUT = 500; +export default function ActsAccountAssociatedData() { + describe('ActsAccountAssociatedData', function () { + function sleep(delay) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, delay) + }).then(() => { + console.info(`sleep #{time} over ...`) + }) + } + + beforeAll(async function (done) { + console.debug("====>beforeAll start===="); + await sleep(TIMEOUT); + console.debug("====>beforeAll end===="); + done(); + }) + + beforeEach(async function (done) { + console.debug("====>beforeEach enter===="); + await sleep(EACHTIMEOUT); + 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().assertFail(); + 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().assertFail(); + 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().assertFail(); + 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().assertFail(); + 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().assertFail(); + 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/src/main/js/test/CreatManager.test.js b/account/appaccount/actsaccounttest/src/main/js/test/CreatManager.test.js new file mode 100755 index 0000000000000000000000000000000000000000..aa45f5ea676b19ef5f1802af0e1cdead85c6d6ed --- /dev/null +++ b/account/appaccount/actsaccounttest/src/main/js/test/CreatManager.test.js @@ -0,0 +1,95 @@ +/* + * 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 '@ohos/hypium' + +const TIMEOUT = 5000; +export default function ActsCreatAppAccountManager() { + describe('ActsCreatAppAccountManager', function () { + function sleep(delay) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, delay) + }).then(() => { + console.info(`sleep #{time} over ...`) + }) + } + + beforeAll(async function (done) { + console.debug("====>beforeAll start===="); + await 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/src/main/js/test/Credential.test.js b/account/appaccount/actsaccounttest/src/main/js/test/Credential.test.js new file mode 100755 index 0000000000000000000000000000000000000000..1940a9f3d44ce93375b9eaec551bfb72c9b27264 --- /dev/null +++ b/account/appaccount/actsaccounttest/src/main/js/test/Credential.test.js @@ -0,0 +1,677 @@ +/* + * 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 '@ohos/hypium' + +const TIMEOUT = 5000; +const EACHTIMEOUT = 500; +export default function ActsAccountCredential() { + describe('ActsAccountCredential', function () { + function sleep(delay) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, delay) + }).then(() => { + console.info(`sleep #{time} over ...`) + }) + } + + beforeAll(async function (done) { + console.debug("====>beforeAll start===="); + await sleep(TIMEOUT); + console.debug("====>beforeAll end===="); + done(); + }) + + beforeEach(async function (done) { + console.debug("====>beforeEach enter===="); + await sleep(EACHTIMEOUT); + 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/src/main/js/test/DeleteAccount.test.js b/account/appaccount/actsaccounttest/src/main/js/test/DeleteAccount.test.js new file mode 100755 index 0000000000000000000000000000000000000000..097c0df09c1c3b7856319383db9b0275e7fa7d71 --- /dev/null +++ b/account/appaccount/actsaccounttest/src/main/js/test/DeleteAccount.test.js @@ -0,0 +1,245 @@ +/* + * 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 '@ohos/hypium' +const NAMELIMIT = 512; +const TIMEOUT = 5000; +export default function ActsAccountDeleteAccount() { + describe('ActsAccountDeleteAccount', function () { + function sleep(delay) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, delay) + }).then(() => { + console.info(`sleep #{time} over ...`) + }) + } + + beforeAll(async function (done) { + console.debug("====>beforeAll start===="); + await sleep(TIMEOUT); + console.debug("====>beforeAll end===="); + done(); + }); + + /* + * @tc.number : ActsAccountDeleteAccount_0100 + * @tc.name : Delete account callback 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 promise form + * @tc.desc : Delete the added account in promise form + */ + it('ActsAccountDeleteAccount_0200',0,async function (done){ + console.debug("====>ActsAccountDeleteAccount_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>add account ActsAccountAddAccount_0200 start===="); + await appAccountManager.addAccount("deleteAccount_name_promise_first","extraInfo_promise_first"); + try{ + await appAccountManager.deleteAccount("deleteAccount_name_promise_first"); + console.debug("====>ActsAccountDeleteAccount_0200 end===="); + done(); + } + catch(err){ + console.error("====>delete account ActsAccountDeleteAccount_0200 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + }); + + /* + * @tc.number : ActsAccountDeleteAccount_0300 + * @tc.name : Delete account callback form + * @tc.desc : Delete unadded account in callback form + */ + it('ActsAccountDeleteAccount_0300', 0, async function (done) { + console.debug("====>ActsAccountDeleteAccount_0300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + appAccountManager.deleteAccount("deleteAccount_name_callback_second", (err)=>{ + console.debug("====>delete Account ActsAccountDeleteAccount_0300 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountDeleteAccount_0300 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsAccountDeleteAccount_0400 + * @tc.name : Delete account promise form + * @tc.desc : Delete unadded account in promise form + */ + it('ActsAccountDeleteAccount_0400', 0, async function(done){ + console.debug("====>ActsAccountDeleteAccount_0400 start===="); + var appAccountManager = account.createAppAccountManager(); + try{ + await appAccountManager.deleteAccount("deleteAccount_name_promise_second"); + } + catch(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 callback form + * @tc.desc : Delete the added account, the first time it can be deleted, the second time the deletion fails + */ + it('ActsAccountDeleteAccount_0500', 0, async function (done) { + console.debug("====>ActsAccountDeleteAccount_0500 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("deleteAccount_name_callback_third", "extraInfo_callback_third", (err)=>{ + console.debug("====>add account ActsAccountDeleteAccount_0500 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_0500 end===="); + done(); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountDeleteAccount_0600 + * @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_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_third", "extraInfo_promise_third"); + console.debug("====>delete Account first time ActsAccountDeleteAccount_0600 start===="); + await appAccountManager.deleteAccount("deleteAccount_name_promise_third"); + console.debug("====>delete Account second time ActsAccountDeleteAccount_0600 start===="); + try{ + await appAccountManager.deleteAccount("deleteAccount_name_promise_third"); + } + catch(err){ + console.debug("====>delete account ActsAccountDeleteAccount_0600 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountDeleteAccount_0600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountDeleteAccount_0700 + * @tc.name : Delete account callback form + * @tc.desc : Delete the account name exceeds the length limit of 512 characters + */ + it('ActsAccountDeleteAccount_0700',0, async function (done){ + console.debug("====>ActsAccountDeleteAccount_0700 start===="); + var nameLimit = ''; + for (var i = 0; i < NAMELIMIT + 1; i++) { + nameLimit += 't'; + } + var appAccountManager = account.createAppAccountManager(); + appAccountManager.deleteAccount(nameLimit, (err)=>{ + console.debug("====>delete Account ActsAccountDeleteAccount_0700 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountDeleteAccount_0700 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsAccountDeleteAccount_0800 + * @tc.name : Delete account promise form + * @tc.desc : Delete the account name exceeds the length limit of 512 characters + */ + it('ActsAccountDeleteAccount_0800', 0, async function (done){ + console.debug("====>ActsAccountDeleteAccount_0800 start===="); + var nameLimit = ''; + for (var i = 0; i < NAMELIMIT + 1; i++) { + nameLimit += 'n'; + } + var appAccountManager = account.createAppAccountManager(); + console.debug("====>delete Account ActsAccountDeleteAccount_0800 start===="); + try{ + await appAccountManager.deleteAccount(nameLimit); + } + catch(err){ + console.debug("====>delete account ActsAccountDeleteAccount_0800 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountDeleteAccount_0800 end===="); + done(); + } + }) + + /* + * @tc.number : ActsAccountDeleteAccount_0900 + * @tc.name : Delete account callback form + * @tc.desc : Delete the account name is an empty string + */ + it('ActsAccountDeleteAccount_0900',0, async function (done){ + console.debug("====>ActsAccountDeleteAccount_0900 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.deleteAccount("", (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/src/main/js/test/ExtraInfo.test.js b/account/appaccount/actsaccounttest/src/main/js/test/ExtraInfo.test.js new file mode 100755 index 0000000000000000000000000000000000000000..00263102f1a43a6303e687d13fc390fcd6cbbf0e --- /dev/null +++ b/account/appaccount/actsaccounttest/src/main/js/test/ExtraInfo.test.js @@ -0,0 +1,518 @@ +/* + * 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 '@ohos/hypium' + +const TIMEOUT = 5000; +const EACHTIMEOUT = 500; +export default function ActsAccountSetGetExtraInfo() { + describe('ActsAccountSetGetExtraInfo', function () { + function sleep(delay) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, delay) + }).then(() => { + console.info(`sleep #{time} over ...`) + }) + } + + beforeAll(async function (done) { + console.debug("====>beforeAll start===="); + await sleep(TIMEOUT); + console.debug("====>beforeAll end===="); + done(); + }) + + beforeEach(async function (done) { + console.debug("====>beforeEach enter===="); + await sleep(EACHTIMEOUT); + 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/src/main/js/test/List.test.js b/account/appaccount/actsaccounttest/src/main/js/test/List.test.js new file mode 100755 index 0000000000000000000000000000000000000000..6c1628bdad19041ba8a7eeafe7225209a58de0a9 --- /dev/null +++ b/account/appaccount/actsaccounttest/src/main/js/test/List.test.js @@ -0,0 +1,36 @@ +/* + * 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 ActsAccountAddAccount from './AddAccount.test.js' +import ActsAccountDeleteAccount from './DeleteAccount.test.js' +import ActsAccountAppAccess from './AppAccess.test.js' +import ActsAccountAssociatedData from './AssociatedData.test.js' +import ActsAccountSetGetExtraInfo from './ExtraInfo.test.js' +import ActsAccountCredential from './Credential.test.js' +import ActsAccountOAuthToken from './OAuthToken.test.js' +import ActsCreatAppAccountManager from './CreatManager.test.js' +import ActsAccountNoPermission from './NoPermission.test.js' +import ActsAccountChangeOnOff from './OnOff.js' +export default function testsuite() { + ActsAccountAddAccount() + ActsAccountAppAccess() + ActsAccountAssociatedData() + ActsCreatAppAccountManager() + ActsAccountCredential() + ActsAccountDeleteAccount() + ActsAccountSetGetExtraInfo() + ActsAccountNoPermission() + ActsAccountOAuthToken() + ActsAccountChangeOnOff() +} \ No newline at end of file diff --git a/account/appaccount/actsaccounttest/src/main/js/test/NoPermission.test.js b/account/appaccount/actsaccounttest/src/main/js/test/NoPermission.test.js new file mode 100755 index 0000000000000000000000000000000000000000..296a1859944965ab5c9c853b65c31211f6d055ef --- /dev/null +++ b/account/appaccount/actsaccounttest/src/main/js/test/NoPermission.test.js @@ -0,0 +1,237 @@ +/* + * 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 '@ohos/hypium' + +const TIMEOUT = 5000; +const ERR_APPACCOUNT_SERVICE_PERMISSION_DENIED = 4521993; +export default function ActsAccountNoPermission() { + describe('ActsAccountNoPermission', function () { + function sleep(delay) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, delay) + }).then(() => { + console.info(`sleep #{time} over ...`) + }) + } + beforeAll(async function (done) { + console.debug("====>beforeAll start===="); + await 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(account.ResultCode.ERROR_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(account.ResultCode.ERROR_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(account.ResultCode.ERROR_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(account.ResultCode.ERROR_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(account.ResultCode.ERROR_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(account.ResultCode.ERROR_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.actsaccounttest"; + 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(account.ResultCode.ERROR_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.actsaccounttest"; + 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(account.ResultCode.ERROR_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/src/main/js/test/OAuthToken.test.js b/account/appaccount/actsaccounttest/src/main/js/test/OAuthToken.test.js new file mode 100644 index 0000000000000000000000000000000000000000..9b73de9e2e21c6d551ab64a69682cb10f3672048 --- /dev/null +++ b/account/appaccount/actsaccounttest/src/main/js/test/OAuthToken.test.js @@ -0,0 +1,3421 @@ +/* + * 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 resmgr from '@ohos.resourceManager' +import featureAbility from '@ohos.ability.featureAbility' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + + +const TIMEOUT = 1000; +const EACHTIMEOUT = 500; +const LENGTHLIMIT = 512; +const TOKENLENGTHLIMIT = 1024; +const AUTHTYPELENGTHLIMIT = 1024; +const OWNERLENGTHLIMIT = 1024; + +const OWNERSELF = "com.example.actsaccounttest"; +export default function ActsAccountOAuthToken() { + describe('ActsAccountOAuthToken', function () { + function sleep(delay) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, delay) + }).then(() => { + console.info(`sleep #{time} over ...`) + }) + } + + beforeAll(async function (done) { + console.debug("====>beforeAll start===="); + await sleep(TIMEOUT); + console.debug("====>beforeAll end===="); + done(); + }); + + beforeEach(async function (done) { + console.debug("====>beforeAll enter===="); + await sleep(EACHTIMEOUT); + done(); + }); + + /* + * @tc.number : testGetEntriesString101 + * @tc.name : Use getEntries get the value by mixing the string key + * @tc.desc : Mixed strings value can be obtained correctly + * @tc.size : MediumTest + * @tc.type : Function + * @tc.level : Level 1 + */ + + + it('ActsAccountOAuthToken_9100', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_9100 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_tokenTest_name",(err,)=>{ + console.debug("====>ActsAccountOAuthToken_9100 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_tokenTest_name","authType1","test_token1",(err)=>{ + console.debug("====>ActsAccountOAuthToken_9100 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_tokenTest_name","authType1","test_token2",(err)=>{ + console.debug("====>ActsAccountOAuthToken_9100 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthTokenVisibility("account_tokenTest_name","authType1","other_app_bundleName",true,(err)=>{ + console.debug("====>ActsAccountOAuthToken_9100 setOAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_tokenTest_name","authType2","test_token2",(err)=>{ + console.debug("====>ActsAccountOAuthToken_9100 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAllOAuthTokens("account_tokenTest_name", OWNERSELF,(err,ArrayData)=>{ + console.debug("====>ActsAccountOAuthToken_9100 getAllOAuthTokens err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_9100 getAllOAuthTokens ArrayData:" + JSON.stringify(ArrayData)); + expect(err.code).assertEqual(0); + expect(ArrayData.length).assertEqual(2); + appAccountManager.deleteOAuthToken("account_tokenTest_name",OWNERSELF,"authType1","test_token2",(err)=>{ + console.debug("====>ActsAccountOAuthToken_9100 deleteOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAllOAuthTokens("account_tokenTest_name", OWNERSELF,(err,ArrayData)=>{ + console.debug("====>ActsAccountOAuthToken_9100 getAllOAuthTokens err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_9100 getAllOAuthTokens ArrayData:" + JSON.stringify(ArrayData)); + expect(err.code).assertEqual(0); + expect(ArrayData.length).assertEqual(2); + appAccountManager.deleteAccount("account_tokenTest_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_9100 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_9100 end===="); + done(); + appAccountManager.getOAuthToken("account_tokenTest_name",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountOAuthToken_9100 getOAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_9100 getOAuthToken data:" + data); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_9100 end===="); + done(); + }); + }); + }); + }); + }); + }); + }); + }); + }); + }); + }); + + + it('ActsAccountOAuthToken_9000', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_9000 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_tokenTest_name",(err,)=>{ + console.debug("====>ActsAccountOAuthToken_9000 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_tokenTest_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_9000 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_tokenTest_name",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountOAuthToken_9000 getOAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_9000 getOAuthToken data:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual("test_token"); + appAccountManager.setOAuthTokenVisibility("account_tokenTest_name","authType","other_app_bundleName",true,(err)=>{ + console.debug("====>ActsAccountOAuthToken_9000 setOAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthList("account_tokenTest_name","authType",(err,dataArray)=>{ + console.debug("====>ActsAccountOAuthToken_9000 getOAuthList err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_9000 getOAuthList dataArray:" + JSON.stringify(dataArray)); + expect(dataArray.length).assertEqual(1); + expect(dataArray[0]).assertEqual("other_app_bundleName"); + appAccountManager.deleteOAuthToken("account_tokenTest_name",OWNERSELF,"authType","test_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_9000 deleteOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAllOAuthTokens("account_tokenTest_name", OWNERSELF,(err,ArrayData)=>{ + console.debug("====>ActsAccountOAuthToken_9000 getAllOAuthTokens err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_9000 getAllOAuthTokens ArrayData:" + JSON.stringify(ArrayData)); + expect(err.code).assertEqual(0); + expect(ArrayData.length).assertEqual(1); + expect(ArrayData[0].authType).assertEqual("authType"); + expect(ArrayData[0].token).assertEqual(""); + appAccountManager.setOAuthTokenVisibility("account_tokenTest_name","authType",OWNERSELF,false,(err)=>{ + console.debug("====>ActsAccountOAuthToken_9000 setOAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_tokenTest_name",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountOAuthToken_9000 getOAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_9000 getOAuthToken data:" + data); + expect(err.code!=0).assertEqual(true); + expect(data).assertEqual(""); + appAccountManager.deleteAccount("account_tokenTest_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_9000 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_9000 end===="); + done(); + }); + }); + }); + }); + }); + }); + }); + }); + }); + }); + }); + + + + it('ActsAccountOAuthToken_7100', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_7100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_7100 addAccount start===="); + appAccountManager.addAccount("account_tokenTest_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_7100 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_tokenTest_name","authType1","test_token1",(err)=>{ + console.debug("====>ActsAccountOAuthToken_7100 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_tokenTest_name","authType1","test_token2",(err)=>{ + console.debug("====>ActsAccountOAuthToken_7100 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_tokenTest_name","authType2","test_token2",(err)=>{ + console.debug("====>ActsAccountOAuthToken_7100 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAllOAuthTokens("account_tokenTest_name", OWNERSELF,(err,ArrayData)=>{ + console.debug("====>ActsAccountOAuthToken_7100 getAllOAuthTokens err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_7100 getAllOAuthTokens ArrayData:" + JSON.stringify(ArrayData)); + expect(err.code).assertEqual(0); + expect(ArrayData.length).assertEqual(2); + expect(ArrayData[0].authType).assertEqual("authType1"); + expect(ArrayData[0].token).assertEqual("test_token2"); + expect(ArrayData[1].authType).assertEqual("authType2"); + expect(ArrayData[1].token).assertEqual("test_token2"); + appAccountManager.deleteOAuthToken("account_tokenTest_name",OWNERSELF,"authType1","test_token2",(err)=>{ + console.debug("====>ActsAccountOAuthToken_7100 deleteOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAllOAuthTokens("account_tokenTest_name", OWNERSELF,(err,ArrayData)=>{ + console.debug("====>ActsAccountOAuthToken_7100 getAllOAuthTokens err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_7100 getAllOAuthTokens ArrayData:" + JSON.stringify(ArrayData)); + expect(err.code).assertEqual(0); + expect(ArrayData.length).assertEqual(1); + expect(ArrayData[0].authType).assertEqual("authType2"); + expect(ArrayData[0].token).assertEqual("test_token2"); + appAccountManager.deleteAccount("account_tokenTest_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_7100 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_tokenTest_name",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountOAuthToken_7100 getOAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_7100 getOAuthToken data:" + data); + expect(err.code!=0).assertEqual(true); + expect(data).assertEqual(""); + console.debug("====>ActsAccountOAuthToken_7100 end===="); + done(); + }); + }); + }); + }); + }); + }); + }); + }); + }); + }); + + + it('ActsAccountOAuthToken_7200', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_7200 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_tokenTest_name",(err,)=>{ + console.debug("====>ActsAccountOAuthToken_7200 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_tokenTest_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_7200 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_tokenTest_name",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountOAuthToken_7200 getOAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_7200 getOAuthToken data:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual("test_token"); + appAccountManager.getOAuthList("account_tokenTest_name","authType",(err,dataArray)=>{ + console.debug("====>ActsAccountOAuthToken_7200 getOAuthList err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_7200 getOAuthList dataArray:" + JSON.stringify(dataArray)); + expect(dataArray.length).assertEqual(0); + appAccountManager.deleteAccount("account_tokenTest_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_7200 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_7200 end===="); + done(); + }); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_7300', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_7300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_7300 addAccount start===="); + appAccountManager.addAccount("account_tokenTest_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_7300 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_tokenTest_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_7300 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_tokenTest_name",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountOAuthToken_7300 getOAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_7300 getOAuthToken data:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual("test_token"); + appAccountManager.checkOAuthTokenVisibility("account_tokenTest_name","authType",OWNERSELF,(err,stateBack)=>{ + console.debug("====>ActsAccountOAuthToken_7300 checkOAuthTokenVisibility err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_7300 checkOAuthTokenVisibility stateBack:" + stateBack); + expect(err.code).assertEqual(0); + expect(stateBack).assertEqual(true); + appAccountManager.setOAuthTokenVisibility("account_tokenTest_name","authType",OWNERSELF,false,(err)=>{ + console.debug("====>ActsAccountOAuthToken_7300 setOAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.checkOAuthTokenVisibility("account_tokenTest_name","authType",OWNERSELF,(err,stateBack)=>{ + console.debug("====>ActsAccountOAuthToken_7300 checkOAuthTokenVisibility err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_7300 checkOAuthTokenVisibility stateBack:" + stateBack); + expect(err.code).assertEqual(0); + expect(stateBack).assertEqual(true); + appAccountManager.deleteOAuthToken("account_tokenTest_name",OWNERSELF,"authType","test_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_7300 deleteOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount("account_tokenTest_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_7300 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_7300 end===="); + done(); + }); + }); + }); + }); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_7400', 0, async function (done) { + var limitAuthType = ''; + for(var i = 0;i < AUTHTYPELENGTHLIMIT + 1; i++){ + limitAuthType += 'c'; + } + console.debug("====>ActsAccountOAuthToken_7400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_7400 addAccount start===="); + appAccountManager.addAccount("account_callback_authType_limit",(err)=>{ + console.debug("====>ActsAccountOAuthToken_7400 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_authType_limit","authType","callback_authType_limit_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_7400 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteOAuthToken("account_callback_authType_limit",OWNERSELF,limitAuthType,"callback_authType_limit_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_7400 getOAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + appAccountManager.deleteAccount("account_callback_authType_limit",(err)=>{ + console.debug("====>ActsAccountOAuthToken_7400 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_7400 end===="); + done(); + }); + }); + }); + }); + }); + + + it('ActsAccountOAuthToken_7500', 0, async function (done) { + var limitAuthType = ''; + for(var i = 0;i < AUTHTYPELENGTHLIMIT + 1; i++){ + limitAuthType += 'c'; + } + console.debug("====>ActsAccountOAuthToken_7500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_7500 addAccount start===="); + await appAccountManager.addAccount("account_promise_authType_limit"); + console.debug("====>ActsAccountOAuthToken_7500 getOAuthToken start===="); + try{ + await appAccountManager.deleteOAuthToken("account_promise_authType_limit",OWNERSELF,limitAuthType,"promise_authType_limit_token"); + } + catch(err){ + console.debug("====>ActsAccountOAuthToken_7500 getOAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_7500 deleteAccount start===="); + await appAccountManager.deleteAccount("account_promise_authType_limit"); + console.debug("====>ActsAccountOAuthToken_7500 end===="); + done(); + } + }); + + + + it('ActsAccountOAuthToken_7600', 0, async function (done) { + var limitAuthType = ''; + for(var i = 0;i < AUTHTYPELENGTHLIMIT; i++){ + limitAuthType += 'c'; + } + console.debug("====>ActsAccountOAuthToken_7600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_7600 addAccount start===="); + appAccountManager.addAccount("account_callback_authType_limit",(err)=>{ + console.debug("====>ActsAccountOAuthToken_7600 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_authType_limit",limitAuthType,"callback_authType_limit_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_7600 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteOAuthToken("account_callback_authType_limit",OWNERSELF,limitAuthType,"callback_authType_limit_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_7600 getOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount("account_callback_authType_limit",(err)=>{ + console.debug("====>ActsAccountOAuthToken_7600 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_7600 end===="); + done(); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_7700', 0, async function (done) { + var limitAuthType = ''; + for(var i = 0;i < AUTHTYPELENGTHLIMIT; i++){ + limitAuthType += 'c'; + } + console.debug("====>ActsAccountOAuthToken_7700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_7700 addAccount start===="); + await appAccountManager.addAccount("account_promise_authType_limit") + console.debug("====>ActsAccountOAuthToken_7700 setOAuthToken start===="); + await appAccountManager.setOAuthToken("account_promise_authType_limit",limitAuthType,"promise_authType_limit_token"); + console.debug("====>ActsAccountOAuthToken_7700 deleteOAuthToken start===="); + await appAccountManager.deleteOAuthToken("account_promise_authType_limit",OWNERSELF,limitAuthType,"promise_authType_limit_token") + console.debug("====>ActsAccountOAuthToken_7700 deleteAccount start===="); + await appAccountManager.deleteAccount("account_promise_authType_limit") + console.debug("====>ActsAccountOAuthToken_7700 end===="); + done(); + + }); + + + + it('ActsAccountOAuthToken_7800', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_7800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_7800 addAccount start===="); + appAccountManager.addAccount("account_callback_empty_authType",(err)=>{ + console.debug("====>ActsAccountOAuthToken_7800 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_empty_authType","authType","callback_empty_authType_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_7800 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteOAuthToken("account_callback_empty_authType",OWNERSELF,"","callback_empty_authType_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_7800 deleteOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_callback_empty_authType",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountOAuthToken_7800 getOAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_7800 getOAuthToken data:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual("callback_empty_authType_token"); + appAccountManager.deleteAccount("account_callback_empty_authType",(err)=>{ + console.debug("====>ActsAccountOAuthToken_7800 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_7800 end===="); + done(); + }); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_7900', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_7900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_7900 addAccount start===="); + await appAccountManager.addAccount("account_promise_empty_authType"); + console.debug("====>ActsAccountOAuthToken_7900 setOAuthToken start===="); + await appAccountManager.setOAuthToken("account_promise_empty_authType","authType","promise_empty_authType_token"); + console.debug("====>ActsAccountOAuthToken_7900 deleteOAuthToken start===="); + await appAccountManager.deleteOAuthToken("account_promise_empty_authType",OWNERSELF,"","promise_empty_authType_token"); + console.debug("====>ActsAccountOAuthToken_7900 getOAuthToken start===="); + var data = await appAccountManager.getOAuthToken("account_promise_empty_authType",OWNERSELF,"authType"); + expect(data).assertEqual("promise_empty_authType_token"); + console.debug("====>ActsAccountOAuthToken_7900 deleteAccount start===="); + await appAccountManager.deleteAccount("account_promise_empty_authType"); + console.debug("====>ActsAccountOAuthToken_7900 end===="); + done(); + + }); + + + it('ActsAccountOAuthToken_8000', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_8000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_8000 addAccount start===="); + appAccountManager.addAccount("account_callback_setSameAuthType",(err)=>{ + console.debug("====>ActsAccountOAuthToken_8000 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_setSameAuthType","authType","callback_setSameAuthType_token1",(err)=>{ + console.debug("====>ActsAccountOAuthToken_8000 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_setSameAuthType","authType","callback_setSameAuthType_token2",(err)=>{ + console.debug("====>ActsAccountOAuthToken_8000 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_callback_setSameAuthType",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountOAuthToken_8000 getOAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_8000 getOAuthToken data:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual("callback_setSameAuthType_token2"); + appAccountManager.deleteOAuthToken("account_callback_setSameAuthType",OWNERSELF,"authType","callback_setSameAuthType_token1",(err,data)=>{ + console.debug("====>ActsAccountOAuthToken_8000 deleteOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount("account_callback_setSameAuthType",(err)=>{ + console.debug("====>ActsAccountOAuthToken_8000 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_8000 end===="); + done(); + }); + }); + }); + }); + }); + }); + }); + + + + + + it('ActsAccountOAuthToken_8100', 0, async function (done) { + var limitName = ''; + for(var i = 0;i < LENGTHLIMIT + 1; i++){ + limitName += 'c'; + } + console.debug("====>ActsAccountOAuthToken_8100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_8100 getAllOAuthTokens start===="); + appAccountManager.getAllOAuthTokens(limitName, OWNERSELF,(err,ArrayData)=>{ + console.debug("====>ActsAccountOAuthToken_8100 getAllOAuthTokens err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_8100 getAllOAuthTokens ArrayData:" + JSON.stringify(ArrayData)); + expect(err.code!=0).assertEqual(true); + expect(ArrayData.length).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_8100 ===="); + done(); + }); + }); + + it('ActsAccountOAuthToken_8200', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_8200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_8200 getAllOAuthTokens start===="); + appAccountManager.getAllOAuthTokens("", OWNERSELF,(err,ArrayData)=>{ + console.debug("====>ActsAccountOAuthToken_8200 getAllOAuthTokens err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_8200 getAllOAuthTokens ArrayData:" + JSON.stringify(ArrayData)); + expect(err.code!=0).assertEqual(true); + expect(ArrayData.length).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_8200 ===="); + done(); + }); + }); + + it('ActsAccountOAuthToken_8300', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_8300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_8300 getAllOAuthTokens start===="); + appAccountManager.getAllOAuthTokens("acount_no_setToken", OWNERSELF,(err,ArrayData)=>{ + console.debug("====>ActsAccountOAuthToken_8300 getAllOAuthTokens err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_8300 getAllOAuthTokens ArrayData:" + JSON.stringify(ArrayData)); + expect(err.code!=0).assertEqual(true); + expect(ArrayData.length).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_8300 end===="); + done(); + }); + }); + + + + it('ActsAccountOAuthToken_8400', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_8400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_8400 addAccount start===="); + appAccountManager.addAccount("acount_no_setToken",(err)=>{ + console.debug("====>ActsAccountOAuthToken_8400 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAllOAuthTokens("acount_no_setToken", OWNERSELF,(err,ArrayData)=>{ + console.debug("====>ActsAccountOAuthToken_8400 getAllOAuthTokens err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_8400 getAllOAuthTokens ArrayData:" + JSON.stringify(ArrayData)); + expect(err.code).assertEqual(0); + expect(ArrayData.length).assertEqual(0); + appAccountManager.deleteAccount("acount_no_setToken",(err)=>{ + console.debug("====>ActsAccountOAuthToken_8400 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_8400 end===="); + done(); + }); + }); + }); + }); + + + + it('ActsAccountOAuthToken_8500', 0, async function (done) { + var limitName = ''; + for(var i = 0;i < LENGTHLIMIT; i++){ + limitName += 'c'; + } + console.debug("====>ActsAccountOAuthToken_8500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_8500 addAccount start===="); + appAccountManager.addAccount(limitName,(err)=>{ + console.debug("====>ActsAccountOAuthToken_8500 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken(limitName,"authType","test_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_8500 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAllOAuthTokens(limitName, OWNERSELF,(err,ArrayData)=>{ + console.debug("====>ActsAccountOAuthToken_8500 getAllOAuthTokens err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_8500 getAllOAuthTokens ArrayData:" + JSON.stringify(ArrayData)); + expect(err.code).assertEqual(0); + expect(ArrayData.length).assertEqual(1); + expect(ArrayData[0].authType).assertEqual("authType"); + expect(ArrayData[0].token).assertEqual("test_token"); + appAccountManager.deleteAccount(limitName,(err)=>{ + console.debug("====>ActsAccountOAuthToken_8500 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_8500 end===="); + done(); + }); + }); + }); + }); + }); + + + it('ActsAccountOAuthToken_8600', 0, async function (done) { + var limitOwner = ''; + for(var i = 0;i < OWNERLENGTHLIMIT + 1; i++){ + limitOwner += 'c'; + } + console.debug("====>ActsAccountOAuthToken_8600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_8600 addAccount start===="); + appAccountManager.addAccount("account_callback_getAllOAuthTokens_test",(err)=>{ + console.debug("====>ActsAccountOAuthToken_8600 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAllOAuthTokens("account_callback_getAllOAuthTokens_test",limitOwner,(err,ArrayData)=>{ + console.debug("====>ActsAccountOAuthToken_8600 getAllOAuthTokens err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_8600 getAllOAuthTokens ArrayData:" + JSON.stringify(ArrayData)); + expect(err.code!=0).assertEqual(true); + expect(ArrayData.length).assertEqual(0); + appAccountManager.deleteAccount("account_callback_getAllOAuthTokens_test",(err)=>{ + console.debug("====>ActsAccountOAuthToken_8600 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_8600 end===="); + done(); + }); + }); + }); + }); + + + it('ActsAccountOAuthToken_8700', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_8700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_8700 addAccount start===="); + appAccountManager.addAccount("account_callback_getAllOAuthTokens_test",(err)=>{ + console.debug("====>ActsAccountOAuthToken_8700 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAllOAuthTokens("account_callback_getAllOAuthTokens_test","",(err,ArrayData)=>{ + console.debug("====>ActsAccountOAuthToken_8700 getAllOAuthTokens err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_8700 getAllOAuthTokens ArrayData:" + JSON.stringify(ArrayData)); + expect(err.code!=0).assertEqual(true); + expect(ArrayData.length).assertEqual(0); + appAccountManager.deleteAccount("account_callback_getAllOAuthTokens_test",(err)=>{ + console.debug("====>ActsAccountOAuthToken_8700 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_8700 end===="); + done(); + }); + }); + }); + }); + + + it('ActsAccountOAuthToken_8800', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_8800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_8800 addAccount start===="); + appAccountManager.addAccount("account_callback_getAllOAuthTokens_test",(err)=>{ + console.debug("====>ActsAccountOAuthToken_8800 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAllOAuthTokens("account_callback_getAllOAuthTokens_test","invalid_owner",(err,ArrayData)=>{ + console.debug("====>ActsAccountOAuthToken_8800 getAllOAuthTokens err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_8800 getAllOAuthTokens ArrayData:" + JSON.stringify(ArrayData)); + expect(err.code!=0).assertEqual(true); + expect(ArrayData.length).assertEqual(0); + appAccountManager.deleteAccount("account_callback_getAllOAuthTokens_test",(err)=>{ + console.debug("====>ActsAccountOAuthToken_8800 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_8800 end===="); + done(); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_8900', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_8900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_8900 addAccount start===="); + appAccountManager.addAccount("account_callback_getAllOAuthTokens_test",(err)=>{ + console.debug("====>ActsAccountOAuthToken_8900 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAllOAuthTokens("account_callback_getAllOAuthTokens_test"," ",(err,ArrayData)=>{ + console.debug("====>ActsAccountOAuthToken_8900 getAllOAuthTokens err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_8900 getAllOAuthTokens ArrayData:" + JSON.stringify(ArrayData)); + expect(err.code!=0).assertEqual(true); + expect(ArrayData.length).assertEqual(0); + appAccountManager.deleteAccount("account_callback_getAllOAuthTokens_test",(err)=>{ + console.debug("====>ActsAccountOAuthToken_8900 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_8900 end===="); + done(); + }); + }); + }); + }); + + + + + it('ActsAccountOAuthToken_0100', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_0100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_0100 addAccount start===="); + appAccountManager.addAccount("account_callback_normal",(err)=>{ + console.debug("====>ActsAccountOAuthToken_0100 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_normal","authType","callback_normal_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_0100 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_callback_normal",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountOAuthToken_0100 getOAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_0100 getOAuthToken data:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual("callback_normal_token"); + appAccountManager.checkOAuthTokenVisibility("account_callback_normal","authType",OWNERSELF,(err,stateBack)=>{ + console.debug("====>ActsAccountOAuthToken_0100 checkOAuthTokenVisibility err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_0100 checkOAuthTokenVisibility stateBack:" + stateBack); + expect(err.code).assertEqual(0); + expect(stateBack).assertEqual(true); + appAccountManager.deleteOAuthToken("account_callback_normal",OWNERSELF,"authType","callback_normal_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_0100 deleteOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount("account_callback_normal",(err)=>{ + console.debug("====>ActsAccountOAuthToken_0100 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_0100 end===="); + done(); + }); + }); + }); + }); + }); + }); + }); + + + it('ActsAccountOAuthToken_0200', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_0200 addAccount start===="); + await appAccountManager.addAccount("account_promise_normal"); + console.debug("====>ActsAccountOAuthToken_0200 setOAuthToken start===="); + await appAccountManager.setOAuthToken("account_promise_normal","authType","promise_normal_token"); + console.debug("====>ActsAccountOAuthToken_0200 getOAuthToken start===="); + var data1 = await appAccountManager.getOAuthToken("account_promise_normal",OWNERSELF,"authType"); + console.debug("====>getOAuthToken ActsAccountOAuthToken_0200 data:" + data1); + expect(data1).assertEqual("promise_normal_token"); + console.debug("====>ActsAccountOAuthToken_0200 checkOAuthTokenVisibility start===="); + var state = await appAccountManager.checkOAuthTokenVisibility("account_promise_normal","authType",OWNERSELF); + console.debug("====>checkOAuthTokenVisibility ActsAccountOAuthToken_0200 state:" + state); + expect(state).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_0200 deleteOAuthToken start===="); + await appAccountManager.deleteOAuthToken("account_promise_normal",OWNERSELF,"authType","promise_normal_token"); + console.debug("====>ActsAccountOAuthToken_0200 deleteAccount start===="); + await appAccountManager.deleteAccount("account_promise_normal"); + console.debug("====>ActsAccountOAuthToken_0200 end===="); + done(); + }); + + + + + it('ActsAccountOAuthToken_0300', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_0300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_0300 getOAuthToken start===="); + appAccountManager.addAccount("account_callback_noSetToken",(err)=>{ + console.debug("====>ActsAccountOAuthToken_0300 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_callback_noSetToken",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountOAuthToken_0300 getOAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_0300 getOAuthToken data:" + data); + expect(err.code!=0).assertEqual(true); + expect(data).assertEqual(""); + appAccountManager.deleteAccount("account_callback_noSetToken",(err)=>{ + console.debug("====>ActsAccountOAuthToken_0300 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_0300 end===="); + done(); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_0400', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_0400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_0400 addAccount start===="); + await appAccountManager.addAccount("account_promise_noSetToken"); + console.debug("====>ActsAccountOAuthToken_0400 getOAuthToken start===="); + try{ + await appAccountManager.getOAuthToken("account_promise_noSetToken",OWNERSELF,"authType"); + } + catch(err){ + console.debug("====>ActsAccountOAuthToken_0400 getOAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_0400 deleteAccount start===="); + await appAccountManager.deleteAccount("account_promise_noSetToken"); + console.debug("====>ActsAccountOAuthToken_0400 end===="); + done(); + } + }); + + + it('ActsAccountOAuthToken_0500', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_0500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_0500 getOAuthToken start===="); + appAccountManager.getOAuthToken("noAdd_account_callback",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountOAuthToken_0500 getOAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_0500 getOAuthToken data:" + data); + expect(err.code!=0).assertEqual(true); + expect(data).assertEqual(""); + done(); + }); + }); + + it('ActsAccountOAuthToken_0600', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_0600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_0600 getOAuthToken start===="); + try{ + await appAccountManager.getOAuthToken("noAdd_account_promise",OWNERSELF,"authType"); + } + catch(err){ + console.debug("====>ActsAccountOAuthToken_0600 getOAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_0600 end===="); + done(); + } + }); + + + it('ActsAccountOAuthToken_0700', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_0700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_0700 addAccount start===="); + appAccountManager.addAccount("account_callback_setSameAuthType",(err)=>{ + console.debug("====>ActsAccountOAuthToken_0700 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_setSameAuthType","authType","callback_setSameAuthType_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_0700 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_setSameAuthType","authType","callback_setSameAuthType_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_0700 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_callback_setSameAuthType",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountOAuthToken_0700 getOAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_0700 getOAuthToken data:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual("callback_setSameAuthType_token"); + appAccountManager.setOAuthToken("account_callback_setSameAuthType","authType","callback_setSameAuthType_DiffToken",(err)=>{ + console.debug("====>ActsAccountOAuthToken_0700 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_callback_setSameAuthType",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountOAuthToken_0700 getOAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_0700 getOAuthToken data:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual("callback_setSameAuthType_DiffToken"); + appAccountManager.deleteAccount("account_callback_setSameAuthType",(err)=>{ + console.debug("====>ActsAccountOAuthToken_0700 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_0700 end===="); + done(); + }); + }); + }); + }); + }); + }); + }); + }); + + + + + it('ActsAccountOAuthToken_0800', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_0800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_0800 addAccount start===="); + await appAccountManager.addAccount("account_promise_setSameAuthType"); + console.debug("====>ActsAccountOAuthToken_0800 setOAuthToken start===="); + await appAccountManager.setOAuthToken("account_promise_setSameAuthType","authType","promise_setSameAuthType_token"); + console.debug("====>ActsAccountOAuthToken_0800 repeat setOAuthToken start===="); + await appAccountManager.setOAuthToken("account_promise_setSameAuthType","authType","promise_setSameAuthType_token"); + var data1 = await appAccountManager.getOAuthToken("account_promise_setSameAuthType",OWNERSELF,"authType"); + console.debug("====>getOAuthToken ActsAccountOAuthToken_0800 data:" + data1); + expect(data1).assertEqual("promise_setSameAuthType_token"); + console.debug("====>ActsAccountOAuthToken_0800 repeat set diffToken setOAuthToken start===="); + await appAccountManager.setOAuthToken("account_promise_setSameAuthType","authType","promise_setSameAuthType_DiffToken"); + var data2 = await appAccountManager.getOAuthToken("account_promise_setSameAuthType",OWNERSELF,"authType"); + console.debug("====>getOAuthToken ActsAccountOAuthToken_0800 data:" + data2); + expect(data2).assertEqual("promise_setSameAuthType_DiffToken"); + console.debug("====>ActsAccountOAuthToken_0800 deleteAccount start===="); + await appAccountManager.deleteAccount("account_promise_setSameAuthType"); + console.debug("====>ActsAccountOAuthToken_0800 end===="); + done(); + }); + + + + it('ActsAccountOAuthToken_0900', 0, async function(done) { + console.debug("====>ActsAccountOAuthToken_0900 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_callback_setDiff", (err)=>{ + console.debug("====>addAccount ActsAccountOAuthToken_0900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_setDiff","authType1","callback_setDiff_token1",(err)=>{ + console.debug("====>getOAuthToken ActsAccountOAuthToken_0900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_setDiff","authType2","callback_setDiff_token2",(err)=>{ + console.debug("====>getOAuthToken ActsAccountOAuthToken_0900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_callback_setDiff",OWNERSELF,"authType1", (err, data)=>{ + console.debug("====>getOAuthToken ActsAccountOAuthToken_0900 err:" + JSON.stringify(err)); + console.debug("====>getOAuthToken ActsAccountOAuthToken_0900 data:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual("callback_setDiff_token1"); + appAccountManager.getOAuthToken("account_callback_setDiff",OWNERSELF,"authType2", (err, data)=>{ + console.debug("====>getOAuthToken ActsAccountOAuthToken_0900 err:" + JSON.stringify(err)); + console.debug("====>getOAuthToken ActsAccountOAuthToken_0900 data:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual("callback_setDiff_token2"); + appAccountManager.deleteAccount("account_callback_setDiff", (err)=>{ + console.debug("====>deleteAccount ActsAccountOAuthToken_0900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_0900 end===="); + done(); + }); + }); + }); + }); + }); + }); + }); + + + + it('ActsAccountOAuthToken_1000', 0, async function(done) { + console.debug("====>ActsAccountOAuthToken_1000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_1000 addAccount start===="); + await appAccountManager.addAccount("account_promise_setDiff"); + console.debug("====>setOAuthToken ActsAccountOAuthToken_1000 start===="); + await appAccountManager.setOAuthToken("account_promise_setDiff","aythType1","promise_setDiff_token1"); + console.debug("====>setOAuthToken ActsAccountOAuthToken_1000 start===="); + await appAccountManager.setOAuthToken("account_promise_setDiff","aythType2","promise_setDiff_token2"); + + console.debug("====>getOAuthToken ActsAccountOAuthToken_1000 start===="); + var data1 = await appAccountManager.getOAuthToken("account_promise_setDiff",OWNERSELF,"aythType1"); + console.debug("====>getOAuthToken getOld ActsAccountOAuthToken_1000 data:" + data1); + expect(data1).assertEqual("promise_setDiff_token1"); + console.debug("====>getOAuthToken ActsAccountOAuthToken_1000 start===="); + var data2 = await appAccountManager.getOAuthToken("account_promise_setDiff",OWNERSELF,"aythType2"); + console.debug("====>getOAuthToken getNew ActsAccountOAuthToken_1000 data:" + data2); + expect(data2).assertEqual("promise_setDiff_token2"); + + console.debug("====>deleteOAuthToken ActsAccountOAuthToken_1000 start===="); + await appAccountManager.deleteOAuthToken("account_promise_setDiff",OWNERSELF,"aythType1","promise_setDiff_token1"); + console.debug("====>deleteOAuthToken ActsAccountOAuthToken_1000 start===="); + await appAccountManager.deleteOAuthToken("account_promise_setDiff",OWNERSELF,"aythType2","promise_setDiff_token2"); + console.debug("====>ActsAccountOAuthToken_1000 deleteAccount start===="); + await appAccountManager.deleteAccount("account_promise_setDiff"); + console.debug("====>ActsAccountOAuthToken_1000 end===="); + done(); + }); + + + + it('ActsAccountOAuthToken_1100', 0, async function(done) { + console.debug("====>ActsAccountOAuthToken_1100 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_callback_setDeleteGet", (err)=>{ + console.debug("====>addAccount ActsAccountOAuthToken_1100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_setDeleteGet","old_authType","callback_setDeleteGet_token",(err)=>{ + console.debug("====>getOAuthToken ActsAccountOAuthToken_1100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_setDeleteGet","new_authType","callback_setDeleteGet_token",(err)=>{ + console.debug("====>getOAuthToken ActsAccountOAuthToken_1100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_callback_setDeleteGet",OWNERSELF,"old_authType", (err, data)=>{ + console.debug("====>getOAuthToken getOld ActsAccountOAuthToken_1100 err:" + JSON.stringify(err)); + console.debug("====>getOAuthToken getOld ActsAccountOAuthToken_1100 data:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual("callback_setDeleteGet_token"); + appAccountManager.getOAuthToken("account_callback_setDeleteGet",OWNERSELF,"new_authType", (err, data)=>{ + console.debug("====>getOAuthToken getNew ActsAccountOAuthToken_1100 err:" + JSON.stringify(err)); + console.debug("====>getOAuthToken getNew ActsAccountOAuthToken_1100 data:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual("callback_setDeleteGet_token"); + appAccountManager.deleteOAuthToken("account_callback_setDeleteGet",OWNERSELF,"old_authType","callback_setDeleteGet_token",(err)=>{ + console.debug("====>deleteOAuthToken deleteOld ActsAccountOAuthToken_1100 err:" + JSON.stringify(err)); + appAccountManager.getOAuthToken("account_callback_setDeleteGet",OWNERSELF,"old_authType", (err, data)=>{ + console.debug("====>getOAuthToken getOld ActsAccountOAuthToken_1100 err:" + JSON.stringify(err)); + console.debug("====>getOAuthToken getOld ActsAccountOAuthToken_1100 data:" + data); + expect(err.code!=0).assertEqual(true); + expect(data).assertEqual(""); + appAccountManager.getOAuthToken("account_callback_setDeleteGet",OWNERSELF,"new_authType", (err, data)=>{ + console.debug("====>getOAuthToken getNew ActsAccountOAuthToken_1100 err:" + JSON.stringify(err)); + console.debug("====>getOAuthToken getNew ActsAccountOAuthToken_1100 data:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual("callback_setDeleteGet_token"); + appAccountManager.deleteOAuthToken("account_callback_setDeleteGet",OWNERSELF,"new_authType","callback_setDeleteGet_token",(err)=>{ + console.debug("====>deleteOAuthToken deleteNew ActsAccountOAuthToken_1100 err:" + JSON.stringify(err)); + appAccountManager.getOAuthToken("account_callback_setDeleteGet",OWNERSELF,"old_authType", (err, data)=>{ + console.debug("====>getOAuthToken getOld ActsAccountOAuthToken_1100 err:" + JSON.stringify(err)); + console.debug("====>getOAuthToken getOld ActsAccountOAuthToken_1100 data:" + data); + expect(err.code!=0).assertEqual(true); + expect(data).assertEqual(""); + appAccountManager.getOAuthToken("account_callback_setDeleteGet",OWNERSELF,"new_authType", (err, data)=>{ + console.debug("====>getOAuthToken getNew ActsAccountOAuthToken_1100 err:" + JSON.stringify(err)); + console.debug("====>getOAuthToken getNew ActsAccountOAuthToken_1100 data:" + data); + expect(err.code!=0).assertEqual(true); + expect(data).assertEqual(""); + appAccountManager.deleteAccount("account_callback_setDeleteGet", (err)=>{ + console.debug("====>deleteAccount ActsAccountOAuthToken_1100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_1100 end===="); + done(); + }); + }); + }) + }); + }); + }); + }); + }); + }); + }); + }); + }); + }); + + + it('ActsAccountOAuthToken_1200', 0, async function(done) { + console.debug("====>ActsAccountOAuthToken_1200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_1200 addAccount start===="); + await appAccountManager.addAccount("account_promise_setDeleteGet"); + + console.debug("====>setOAuthToken setOld ActsAccountOAuthToken_1200 start===="); + await appAccountManager.setOAuthToken("account_promise_setDeleteGet","old_authType","promise_setDeleteGet_token"); + console.debug("====>setOAuthToken setNew ActsAccountOAuthToken_1200 start===="); + await appAccountManager.setOAuthToken("account_promise_setDeleteGet","new_authType","promise_setDeleteGet_token"); + + console.debug("====>getOAuthToken ActsAccountOAuthToken_1200 start===="); + var data1_beforeDel = await appAccountManager.getOAuthToken("account_promise_setDeleteGet",OWNERSELF,"old_authType"); + console.debug("====>getOAuthToken getOld ActsAccountOAuthToken_1200 data:" + data1_beforeDel); + expect(data1_beforeDel).assertEqual("promise_setDeleteGet_token"); + console.debug("====>getOAuthToken ActsAccountOAuthToken_1200 start===="); + var data2_beforeDel = await appAccountManager.getOAuthToken("account_promise_setDeleteGet",OWNERSELF,"new_authType"); + console.debug("====>getOAuthToken getNew ActsAccountOAuthToken_1200 data:" + data2_beforeDel); + expect(data2_beforeDel).assertEqual("promise_setDeleteGet_token"); + + console.debug("====>deleteOAuthToken deleteOld ActsAccountOAuthToken_1200 start===="); + try{ + await appAccountManager.deleteOAuthToken("account_promise_setDeleteGet",OWNERSELF,"old_authType","promise_setDeleteGet_token"); + } + catch(err){ + console.debug("====>deleteOAuthToken ActsAccountOAuthToken_1200 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + } + + console.debug("====>getOAuthToken ActsAccountOAuthToken_1200 start===="); + try{ + var data1_AfterDel = await appAccountManager.getOAuthToken("account_promise_setDeleteGet",OWNERSELF,"old_authType",); + } + catch(err){ + console.debug("====>getOAuthToken getOld ActsAccountOAuthToken_1200 err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>getOAuthToken getOld ActsAccountOAuthToken_1200 data:" + data1_AfterDel); + expect(data1_AfterDel).assertEqual(undefined); + } + console.debug("====>getOAuthToken ActsAccountOAuthToken_1200 start===="); + try{ + var data2_AfterDel = await appAccountManager.getOAuthToken("account_promise_setDeleteGet",OWNERSELF,"new_authType",); + } + catch(err){ + console.debug("====>getOAuthToken getNew ActsAccountOAuthToken_1200 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>getOAuthToken getNew ActsAccountOAuthToken_1200 data:" + data2_AfterDel); + expect(data2_AfterDel).assertEqual("promise_setDeleteGet_token"); + } + console.debug("====>deleteOAuthToken deleteNew ActsAccountOAuthToken_1200 start===="); + try{ + await appAccountManager.deleteOAuthToken("account_promise_setDeleteGet",OWNERSELF,"new_authType","promise_setDeleteGet_token"); + } + catch(err){ + console.debug("====>deleteOAuthToken ActsAccountOAuthToken_1200 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + } + + console.debug("====>getOAuthToken getOld ActsAccountOAuthToken_1200 start===="); + try{ + var data1_AgainDel = await appAccountManager.getOAuthToken("account_promise_setDeleteGet",OWNERSELF,"old_authType",); + } + catch(err){ + console.debug("====>getOAuthToken getOld ActsAccountOAuthToken_1200 err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>getOAuthToken getOld ActsAccountOAuthToken_1200 data:" + data1_AgainDel); + expect(data1_AgainDel).assertEqual(undefined); + } + console.debug("====>getOAuthToken getNew ActsAccountOAuthToken_1200 start===="); + try{ + var data2_AgainDel = await appAccountManager.getOAuthToken("account_promise_setDeleteGet",OWNERSELF,"new_authType",); + } + catch(err){ + console.debug("====>getOAuthToken getNew ActsAccountOAuthToken_1200 err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>getOAuthToken getNew ActsAccountOAuthToken_1200 data:" + data2_AgainDel); + expect(data2_AgainDel).assertEqual(undefined); + } + await appAccountManager.deleteAccount("account_promise_setDeleteGet"); + console.debug("====>ActsAccountOAuthToken_1200 end===="); + done(); + + }); + + + it('ActsAccountOAuthToken_1300', 0, async function(done) { + console.debug("====>ActsAccountOAuthToken_1300 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_callback_setDeleteGet", (err)=>{ + console.debug("====>addAccount ActsAccountOAuthToken_1300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_setDeleteGet","authType","account_callback_setDeleteGet_token",(err)=>{ + console.debug("====>getOAuthToken ActsAccountOAuthToken_1300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteOAuthToken("account_callback_setDeleteGet",OWNERSELF,"authType","account_callback_setDeleteGet_token",(err)=>{ + console.debug("====>deleteOAuthToken ActsAccountOAuthToken_1300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_callback_setDeleteGet",OWNERSELF,"authType", (err, data)=>{ + console.debug("====>getOAuthToken ActsAccountOAuthToken_1300 err:" + JSON.stringify(err)); + console.debug("====>getOAuthToken ActsAccountOAuthToken_1300 data:" + data); + expect(err.code != 0).assertEqual(true); + expect(data).assertEqual(""); + appAccountManager.deleteAccount("account_callback_setDeleteGet", (err)=>{ + console.debug("====>deleteAccount ActsAccountOAuthToken_1300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_1300 end===="); + done(); + }); + }); + }); + }); + }); + }); + + + it('ActsAccountOAuthToken_1400', 0, async function(done) { + console.debug("====>ActsAccountOAuthToken_1400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_1400 addAccount start===="); + await appAccountManager.addAccount("account_promise_setDeleteGet"); + console.debug("====>setOAuthToken ActsAccountOAuthToken_1400 start===="); + await appAccountManager.setOAuthToken("account_promise_setDeleteGet","authType","promise_setDeleteGet_token"); + console.debug("====>deleteOAuthToken ActsAccountOAuthToken_1400 start===="); + await appAccountManager.deleteOAuthToken("account_promise_setDeleteGet",OWNERSELF,"authType","promise_setDeleteGet_token"); + console.debug("====>getOAuthToken ActsAccountOAuthToken_1400 start===="); + try{ + var data = await appAccountManager.getOAuthToken("account_promise_setDeleteGet",OWNERSELF,"authType"); + } + catch(err){ + console.debug("====>getOAuthToken ActsAccountOAuthToken_1400 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>getOAuthToken ActsAccountOAuthToken_1400 data:" + data); + console.debug("====>ActsAccountOAuthToken_1400 deleteAccount start===="); + await appAccountManager.deleteAccount("account_promise_setDeleteGet"); + console.debug("====>ActsAccountOAuthToken_1400 end===="); + done(); + } + }); + + + it('ActsAccountOAuthToken_1500', 0, async function(done) { + console.debug("====>ActsAccountOAuthToken_1500 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.setOAuthToken("account_callback_accountNotExit","authType","account_callback_accountNotExit_token", (err)=>{ + console.debug("====>setOAuthToken ActsAccountOAuthToken_1500 err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_1500 end===="); + done(); + }); + }); + + it('ActsAccountOAuthToken_1600', 0, async function(done) { + console.debug("====>ActsAccountOAuthToken_1600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>setOAuthToken ActsAccountOAuthToken_1600 start===="); + try{ + await appAccountManager.setOAuthToken("account_promise_accountNotExit","authType","account_promise_accountNotExit_token"); + } + catch(err){ + console.debug("====>setOAuthToken ActsAccountOAuthToken_1600 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_1600 end===="); + done(); + } + }); + + + + it('ActsAccountOAuthToken_1700', 0, async function(done) { + console.debug("====>ActsAccountOAuthToken_1700 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.deleteOAuthToken("account_callback_accountNotExit",OWNERSELF,"authType","account_callback_accountNotExit_token", (err)=>{ + console.debug("====>deleteOAuthToken ActsAccountOAuthToken_1700 err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_1700 end===="); + done(); + }); + }); + + it('ActsAccountOAuthToken_1800', 0, async function(done) { + console.debug("====>ActsAccountOAuthToken_1800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>deleteOAuthToken ActsAccountOAuthToken_1800 start===="); + try{ + await appAccountManager.deleteOAuthToken("account_promise_accountNotExit",OWNERSELF,"authType","account_promise_accountNotExit_token"); + } + catch(err){ + console.debug("====>deleteOAuthToken ActsAccountOAuthToken_1800 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_1800 end===="); + done(); + } + }); + + + + it('ActsAccountOAuthToken_1900', 0, async function(done) { + console.debug("====>ActsAccountOAuthToken_1900 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_callback_repeatDelete", (err)=>{ + console.debug("====>addAccount ActsAccountOAuthToken_1900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteOAuthToken("account_callback_repeatDelete",OWNERSELF,"aythType","promise_repeatDelete_token",(err)=>{ + console.debug("====>deleteOAuthToken ActsAccountOAuthToken_1900 err:" + JSON.stringify(err)); + appAccountManager.getOAuthToken("account_callback_repeatDelete",OWNERSELF,"authType", (err, data)=>{ + console.debug("====>getOAuthToken ActsAccountOAuthToken_1900 err:" + JSON.stringify(err)); + console.debug("====>getOAuthToken ActsAccountOAuthToken_1900 data:" + data); + expect(err.code != 0).assertEqual(true); + expect(data).assertEqual(""); + appAccountManager.deleteAccount("account_callback_repeatDelete", (err)=>{ + console.debug("====>deleteAccount ActsAccountOAuthToken_1900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_1900 end===="); + done(); + }); + }); + }); + }); + }); + + + it('ActsAccountOAuthToken_2000', 0, async function(done) { + console.debug("====>ActsAccountOAuthToken_2000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_2000 addAccount start===="); + await appAccountManager.addAccount("account_promise_noExitToken"); + console.debug("====>deleteOAuthToken ActsAccountOAuthToken_2000 start===="); + await appAccountManager.deleteOAuthToken("account_promise_noExitToken",OWNERSELF,"aythType","test_token").catch((err)=>{ + console.debug("====>deleteOAuthToken ActsAccountOAuthToken_2000 err:" + JSON.stringify(err)); + }); + console.debug("====>getOAuthToken ActsAccountOAuthToken_2000 start===="); + try{ + var data = await appAccountManager.getOAuthToken("account_promise_noExitToken",OWNERSELF,"authType"); + } + catch(err){ + console.debug("====>getOAuthToken ActsAccountOAuthToken_2000 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_2000 deleteAccount start===="); + await appAccountManager.deleteAccount("account_promise_noExitToken"); + console.debug("====>ActsAccountOAuthToken_2000 end===="); + done(); + } + }); + + + it('ActsAccountOAuthToken_2100', 0, async function(done) { + console.debug("====>ActsAccountOAuthToken_2100 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_callback_repeatDelete", (err)=>{ + console.debug("====>addAccount ActsAccountOAuthToken_2100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_repeatDelete","authType","",(err)=>{ + console.debug("====>getOAuthToken ActsAccountOAuthToken_2100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteOAuthToken("account_callback_repeatDelete",OWNERSELF,"aythType","promise_repeatDelete_token",(err)=>{ + console.debug("====>deleteOAuthToken first ActsAccountOAuthToken_2100 err:" + JSON.stringify(err)); + appAccountManager.getOAuthToken("account_callback_repeatDelete",OWNERSELF,"authType", (err, data)=>{ + console.debug("====>getOAuthToken first ActsAccountOAuthToken_2100 err:" + JSON.stringify(err)); + console.debug("====>getOAuthToken first ActsAccountOAuthToken_2100 data:" + data); + expect(err.code != 0).assertEqual(true); + expect(data).assertEqual(""); + appAccountManager.deleteOAuthToken("account_callback_repeatDelete",OWNERSELF,"aythType","promise_repeatDelete_token",(err)=>{ + console.debug("====>deleteOAuthToken second ActsAccountOAuthToken_2100 err:" + JSON.stringify(err)); + appAccountManager.getOAuthToken("account_callback_repeatDelete",OWNERSELF,"authType", (err, data)=>{ + console.debug("====>getOAuthToken second ActsAccountOAuthToken_2100 err:" + JSON.stringify(err)); + console.debug("====>getOAuthToken second ActsAccountOAuthToken_2100 data:" + data); + expect(err.code != 0).assertEqual(true); + expect(data).assertEqual(""); + appAccountManager.deleteAccount("account_callback_repeatDelete", (err)=>{ + console.debug("====>deleteAccount ActsAccountOAuthToken_2100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_2100 end===="); + done(); + }); + }); + }); + }); + }); + }); + }); + }); + + + + it('ActsAccountOAuthToken_2200', 0, async function(done) { + console.debug("====>ActsAccountOAuthToken_2200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_2200 addAccount start===="); + await appAccountManager.addAccount("account_promise_repeatDelete"); + console.debug("====>setOAuthToken ActsAccountOAuthToken_2200 start===="); + await appAccountManager.setOAuthToken("account_promise_repeatDelete","aythType","promise_repeatDelete_token"); + console.debug("====>deleteOAuthToken first ActsAccountOAuthToken_2200 start===="); + await appAccountManager.deleteOAuthToken("account_promise_repeatDelete",OWNERSELF,"aythType","promise_repeatDelete_token"); + console.debug("====>deleteOAuthToken second ActsAccountOAuthToken_2200 start===="); + await appAccountManager.deleteOAuthToken("account_promise_repeatDelete",OWNERSELF,"aythType","promise_repeatDelete_token"); + console.debug("====>getOAuthToken ActsAccountOAuthToken_2200 start===="); + try{ + var data = await appAccountManager.getOAuthToken("account_promise_repeatDelete",OWNERSELF,"authType"); + } + catch(err){ + console.debug("====>getOAuthToken ActsAccountOAuthToken_2200 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_2200 deleteAccount start===="); + await appAccountManager.deleteAccount("account_promise_repeatDelete"); + console.debug("====>ActsAccountOAuthToken_2200 end===="); + done(); + } + }); + + + it('ActsAccountOAuthToken_2300', 0, async function(done) { + console.debug("====>ActsAccountOAuthToken_2300 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_callback_setEmptyToken", (err)=>{ + console.debug("====>addAccount ActsAccountOAuthToken_2300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_setEmptyToken","authType","",(err)=>{ + console.debug("====>getOAuthToken ActsAccountOAuthToken_2300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_callback_setEmptyToken",OWNERSELF,"authType", (err, data)=>{ + console.debug("====>getOAuthToken ActsAccountOAuthToken_2300 err:" + JSON.stringify(err)); + console.debug("====>getOAuthToken ActsAccountOAuthToken_2300 data:" + data); + expect(err.code != 0).assertEqual(true); + expect(data).assertEqual(""); + appAccountManager.deleteAccount("account_callback_setEmptyToken", (err)=>{ + console.debug("====>deleteAccount ActsAccountOAuthToken_2300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_2300 end===="); + done(); + }); + }); + }); + }); + }); + + + it('ActsAccountOAuthToken_2400', 0, async function(done) { + console.debug("====>ActsAccountOAuthToken_2400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_2400 addAccount start===="); + await appAccountManager.addAccount("account_promise_setEmptyToken"); + console.debug("====>setOAuthToken ActsAccountOAuthToken_2400 start===="); + await appAccountManager.setOAuthToken("account_promise_setEmptyToken","aythType",""); + console.debug("====>getOAuthToken ActsAccountOAuthToken_2400 start===="); + try{ + await appAccountManager.getOAuthToken("account_promise_setEmptyToken","authType",limitToken); + } + catch(err){ + console.debug("====>getOAuthToken ActsAccountOAuthToken_2400 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_2400 deleteAccount start===="); + await appAccountManager.deleteAccount("account_promise_setEmptyToken"); + console.debug("====>ActsAccountOAuthToken_2400 end===="); + done(); + } + }); + + + + it('ActsAccountOAuthToken_2500', 0, async function(done) { + console.debug("====>ActsAccountOAuthToken_2500 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_callback_spaceToken", (err)=>{ + console.debug("====>addAccount ActsAccountOAuthToken_2500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_spaceToken","authType"," ",(err)=>{ + console.debug("====>getOAuthToken ActsAccountOAuthToken_2500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_callback_spaceToken",OWNERSELF,"authType", (err, data)=>{ + console.debug("====>getOAuthToken ActsAccountOAuthToken_2500 err:" + JSON.stringify(err)); + console.debug("====>getOAuthToken ActsAccountOAuthToken_2500 data:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual(" "); + appAccountManager.deleteAccount("account_callback_spaceToken", (err)=>{ + console.debug("====>deleteAccount ActsAccountOAuthToken_2500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_2500 end===="); + done(); + }); + }); + }); + }); + }); + + + it('ActsAccountOAuthToken_2600', 0, async function(done) { + console.debug("====>ActsAccountOAuthToken_2600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_2600 addAccount start===="); + await appAccountManager.addAccount("account_promise_spaceToken"); + console.debug("====>setOAuthToken ActsAccountOAuthToken_2600 start===="); + await appAccountManager.setOAuthToken("account_promise_spaceToken","aythType"," "); + console.debug("====>getOAuthToken ActsAccountOAuthToken_2600 start===="); + var data = await appAccountManager.getOAuthToken("account_promise_spaceToken",OWNERSELF,"aythType"); + expect(data).assertEqual(" "); + console.debug("====>ActsAccountOAuthToken_2600 deleteAccount start===="); + await appAccountManager.deleteAccount("account_promise_spaceToken"); + console.debug("====>ActsAccountOAuthToken_2600 end===="); + done(); + }); + + + + it('ActsAccountOAuthToken_2700', 0, async function(done) { + var limitToken = ''; + for (let i = 0; i < TOKENLENGTHLIMIT + 1; i++) { + limitToken += 't'; + } + console.debug("====>ActsAccountOAuthToken_2700 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_callback_exceed_limitToken", (err)=>{ + console.debug("====>addAccount ActsAccountOAuthToken_2700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_exceed_limitToken","authType",limitToken,(err)=>{ + console.debug("====>getOAuthToken ActsAccountOAuthToken_2700 err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + appAccountManager.deleteAccount("account_callback_exceed_limitToken", (err)=>{ + console.debug("====>deleteAccount ActsAccountOAuthToken_2700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_2700 end===="); + done(); + }); + }); + }); + }); + + + it('ActsAccountOAuthToken_2800', 0, async function(done) { + var limitToken = ''; + for (let i = 0; i < TOKENLENGTHLIMIT + 1; i++) { + limitToken += 't'; + } + console.debug("====>ActsAccountOAuthToken_2800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_2800 addAccount start===="); + await appAccountManager.addAccount("account_promise_exceed_limitToken"); + console.debug("====>setOAuthToken ActsAccountOAuthToken_2800 start===="); + try{ + await appAccountManager.setOAuthToken("account_promise_exceed_limitToken","authType",limitToken); + } + catch(err){ + console.debug("====>setOAuthToken ActsAccountOAuthToken_2800 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_2800 deleteAccount start===="); + appAccountManager.deleteAccount("account_promise_exceed_limitToken"); + console.debug("====>ActsAccountOAuthToken_2800 end===="); + done(); + } + }); + + + it('ActsAccountOAuthToken_2900', 0, async function(done) { + var limitToken = ''; + for (let i = 0; i < TOKENLENGTHLIMIT; i++) { + limitToken += 't'; + } + console.debug("====>ActsAccountOAuthToken_2900 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_callback_limitToken", (err)=>{ + console.debug("====>addAccount ActsAccountOAuthToken_2900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_limitToken","authType",limitToken,(err)=>{ + console.debug("====>getOAuthToken ActsAccountOAuthToken_2900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_callback_limitToken",OWNERSELF,"authType", (err, data)=>{ + console.debug("====>getOAuthToken ActsAccountOAuthToken_2900 err:" + JSON.stringify(err)); + console.debug("====>getOAuthToken ActsAccountOAuthToken_2900 data:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual(limitToken); + appAccountManager.deleteAccount("account_callback_limitToken", (err)=>{ + console.debug("====>deleteAccount ActsAccountOAuthToken_2900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_2900 end===="); + done(); + }); + }); + }); + }); + }); + + + it('ActsAccountOAuthToken_3000', 0, async function(done) { + var limitToken = ''; + for (let i = 0; i < TOKENLENGTHLIMIT; i++) { + limitToken += 't'; + } + console.debug("====>ActsAccountOAuthToken_3000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_3000 addAccount start===="); + await appAccountManager.addAccount("account_promise_limitToken"); + console.debug("====>setOAuthToken ActsAccountOAuthToken_3000 start===="); + await appAccountManager.setOAuthToken("account_promise_limitToken","authType",limitToken); + console.debug("====>getOAuthToken ActsAccountOAuthToken_3000 start===="); + var data = await appAccountManager.getOAuthToken("account_promise_limitToken",OWNERSELF,"authType"); + expect(data).assertEqual(limitToken); + console.debug("====>ActsAccountOAuthToken_3000 deleteAccount start===="); + await appAccountManager.deleteAccount("account_promise_limitToken"); + console.debug("====>ActsAccountOAuthToken_3000 end===="); + done(); + }); + + + it('ActsAccountOAuthToken_3100', 0, async function(done) { + var limitAuthType = ''; + for (let i = 0; i < AUTHTYPELENGTHLIMIT + 1; i++) { + limitAuthType += 't'; + } + console.debug("====>ActsAccountOAuthToken_3100 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_callback_limitAuthType", (err)=>{ + console.debug("====>addAccount ActsAccountOAuthToken_3100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_limitAuthType",limitAuthType,"account_callback_limitAuthType_token",(err, data)=>{ + console.debug("====>getOAuthToken ActsAccountOAuthToken_3100 err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + appAccountManager.deleteAccount("account_callback_limitAuthType", (err)=>{ + console.debug("====>deleteAccount ActsAccountOAuthToken_3100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_3100 end===="); + done(); + }); + }); + }); + }); + + + it('ActsAccountOAuthToken_3200', 0, async function(done) { + var limitAuthType = ''; + for (let i = 0; i < AUTHTYPELENGTHLIMIT + 1; i++) { + limitAuthType += 't'; + } + console.debug("====>ActsAccountOAuthToken_3400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_3400 addAccount start===="); + await appAccountManager.addAccount("account_promise_exceed_limitAuthType"); + console.debug("====>setOAuthToken ActsAccountOAuthToken_3400 start===="); + try{ + await appAccountManager.setOAuthToken("account_promise_exceed_limitAuthType",limitAuthType,"account_promise_limitAuthType_token"); + } + catch(err){ + console.debug("====>setOAuthToken ActsAccountOAuthToken_3400 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_3400 deleteAccount start===="); + appAccountManager.deleteAccount("account_promise_exceed_limitAuthType"); + console.debug("====>ActsAccountOAuthToken_3400 end===="); + done(); + } + }); + + + + it('ActsAccountOAuthToken_3300', 0, async function(done) { + var limitAuthType = ''; + for (let i = 0; i < AUTHTYPELENGTHLIMIT + 1; i++) { + limitAuthType += 't'; + } + console.debug("====>ActsAccountOAuthToken_3300 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_callback_limitAuthType", (err)=>{ + console.debug("====>addAccount ActsAccountOAuthToken_3300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_callback_limitAuthType","com.example.actsaccounttest",limitAuthType, (err, data)=>{ + console.debug("====>getOAuthToken ActsAccountOAuthToken_3300 err:" + JSON.stringify(err)); + console.debug("====>getOAuthToken ActsAccountOAuthToken_3300 data:" + data); + expect(err.code!=0).assertEqual(true); + appAccountManager.deleteAccount("account_callback_limitAuthType", (err)=>{ + console.debug("====>deleteAccount ActsAccountOAuthToken_3300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_3300 end===="); + done(); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_3400', 0, async function(done) { + var limitAuthType = ''; + for (let i = 0; i < AUTHTYPELENGTHLIMIT + 1; i++) { + limitAuthType += 't'; + } + console.debug("====>ActsAccountOAuthToken_3400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_3400 addAccount start===="); + await appAccountManager.addAccount("account_promise_limitAuthType"); + console.debug("====>getOAuthToken ActsAccountOAuthToken_3400 start===="); + try{ + await appAccountManager.getOAuthToken("account_promise_limitAuthType",OWNERSELF,limitAuthType); + } + catch(err){ + console.debug("====>getOAuthToken ActsAccountOAuthToken_3400 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_3400 deleteAccount start===="); + appAccountManager.deleteAccount("account_promise_limitAuthType"); + console.debug("====>ActsAccountOAuthToken_3400 end===="); + done(); + } + }); + + + + /* + * @tc.number : ActsAccountOAuthToken_2700 + * @tc.name : Test oauth token in callback form + * @tc.desc : 设置一个authType长度刚好为限制长度的token 查询 + */ + it('ActsAccountOAuthToken_3500', 0, async function(done) { + console.debug("====>ActsAccountOAuthToken_3500 start===="); + var limitAuthType = ''; + for (let i = 0; i < AUTHTYPELENGTHLIMIT; i++) { + limitAuthType += 't'; + } + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_3500 create finish===="); + appAccountManager.addAccount("account_callback_limitAuthType", (err)=>{ + console.debug("====>add account ActsAccountOAuthToken_3500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_limitAuthType",limitAuthType,"account_callback_limitAuthType_token", (err)=>{ + console.debug("====>setOAuthToken ActsAccountOAuthToken_3500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_callback_limitAuthType","com.example.actsaccounttest",limitAuthType, (err, data)=>{ + console.debug("====>getOAuthToken ActsAccountOAuthToken_3500 err:" + JSON.stringify(err)); + console.debug("====>getOAuthToken ActsAccountOAuthToken_3500 data:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual("account_callback_limitAuthType_token"); + appAccountManager.deleteAccount("account_callback_limitAuthType", (err)=>{ + console.debug("====>delete Account ActsAccountOAuthToken_3500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_3500 end===="); + done(); + }); + }); + }); + }); + }); + + /* + * @tc.number : ActsAccountOAuthToken_2800 + * @tc.name : Test oauth token in promise form + * @tc.desc : 设置一个authType长度刚好为限制长度的token + */ + + /* + * @tc.number : ActsAccountOAuthToken_2900 + * @tc.name : Test oauth token in callback form + * @tc.desc : Clear token parameter name is an empty string + */ + //测试 删除一个账号名为空的token callback方式 + it('ActsAccountOAuthToken_4100', 0, async function(done) { + console.debug("====>ActsAccountOAuthToken_4100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_4100 create finish===="); + appAccountManager.deleteOAuthToken(" ","com.example.actsaccounttest","authType","account_notExist_token", (err)=>{ + console.debug("====>clearOAuthToken ActsAccountOAuthToken_4100 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_4100 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsAccountOAuthToken_3000 + * @tc.name : Test oauth token in promise form + * @tc.desc : Clear token parameter name is an empty string + */ + //测试 删除一个账号名为空的token promise方式 + it('ActsAccountOAuthToken_4200', 0, async function(done) { + console.debug("====>ActsAccountOAuthToken_4200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_4200 create finish===="); + console.debug("====>clearOAuthToken ActsAccountOAuthToken_4200 start===="); + try{ + await appAccountManager.deleteOAuthToken("","com.example.actsaccounttest","authType","account_notExist_token"); + } + catch(err){ + console.debug("====>deleteOAuthToken ActsAccountOAuthToken_4200 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_4200 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountOAuthToken_3100 + * @tc.name : Test oauth token in callback form + * @tc.desc : The clear token parameter name is a space string + */ + it('ActsAccountOAuthToken_4300', 0, async function(done) { + console.debug("====>ActsAccountOAuthToken_4300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_4300 create finish===="); + appAccountManager.deleteOAuthToken(" ","com.example.actsaccounttest","authType","account_notExist_token", (err)=>{ + console.debug("====>clearOAuthToken ActsAccountOAuthToken_4300 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_4300 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsAccountOAuthToken_3200 + * @tc.name : Test oauth token in promise form + * @tc.desc : The clear token parameter name is a space string + */ + it('ActsAccountOAuthToken_4400', 0, async function(done) { + console.debug("====>ActsAccountOAuthToken_4400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_4400 create finish===="); + console.debug("====>clearOAuthToken ActsAccountOAuthToken_4400 start===="); + try{ + await appAccountManager.deleteOAuthToken(" ","com.example.actsaccounttest","authType","account_notExist_token"); + } + catch(err){ + console.debug("====>deleteOAuthToken ActsAccountOAuthToken_4400 err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_4400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsAccountOAuthToken_3300 + * @tc.name : Test oauth token in callback form + * @tc.desc : Clear the token parameter name exceeds the length limit of 1024 characters + */ + it('ActsAccountOAuthToken_4500', 0, async function(done) { + console.debug("====>ActsAccountOAuthToken_4500 start===="); + var nameLimit = ''; + for (let i = 0; i < LENGTHLIMIT + 1; i++) { + nameLimit += 't'; + } + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_4500 create finish===="); + appAccountManager.deleteOAuthToken(nameLimit,"com.example.actsaccounttest","authType","account_notExist_token", (err)=>{ + console.debug("====>clearOAuthToken ActsAccountOAuthToken_4500 err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_4500 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsAccountOAuthToken_3400 + * @tc.name : Test oauth token in promise form + * @tc.desc : Clear the token parameter name exceeds the length limit of 1024 characters + */ + it('ActsAccountOAuthToken_4600', 0, async function(done) { + console.debug("====>ActsAccountOAuthToken_4600 start===="); + var nameLimit = ''; + for (let i = 0; i < LENGTHLIMIT + 1; i++) { + nameLimit += 't'; + } + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_4600 create finish===="); + console.debug("====>deleteOAuthToken ActsAccountOAuthToken_4600 start===="); + try{ + await appAccountManager.deleteOAuthToken(nameLimit,"com.example.actsaccounttest","authType","account_notExist_token"); + } + catch(err){ + console.debug("====>deleteOAuthToken ActsAccountOAuthToken_4600 err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_4600 end===="); + done(); + } + }); + + //查询无效包名owner(为其他字符串时)账号的token callback方式 + it('ActsAccountOAuthToken_4700', 0, async function(done) { + console.debug("====>ActsAccountOAuthToken_4700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_4700 create finish===="); + appAccountManager.addAccount("account_callback_invalid_owner", (err)=>{ + console.debug("====>add account ActsAccountOAuthToken_4700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_callback_invalid_owner","invalid_owner","authType", (err, data)=>{ + console.debug("====>getOAuthToken ActsAccountOAuthToken_4700 err:" + JSON.stringify(err)); + console.debug("====>getOAuthToken ActsAccountOAuthToken_4700 data:" + data); + expect(err.code!=0).assertEqual(true); + expect(data).assertEqual(""); + appAccountManager.deleteAccount("account_callback_invalid_owner", (err)=>{ + console.debug("====>delete account ActsAccountOAuthToken_4700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_4700 end===="); + done(); + }); + }); + }); + }); + + + it('ActsAccountOAuthToken_3600', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_3600 start===="); + var limitAuthType = ''; + for (var i = 0; i < AUTHTYPELENGTHLIMIT; i++) { + limitAuthType += 't'; + } + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_3600 addAccount start===="); + await appAccountManager.addAccount("account_promise_limitAuthType"); + console.debug("====>ActsAccountOAuthToken_3600 setOAuthToken start===="); + await appAccountManager.setOAuthToken("account_promise_limitAuthType",limitAuthType,"account_promise_limitAuthType_token"); + console.debug("====>ActsAccountOAuthToken_3600 getOAuthToken start===="); + var data = await appAccountManager.getOAuthToken("account_promise_limitAuthType",OWNERSELF,limitAuthType); + expect(data).assertEqual("account_promise_limitAuthType_token"); + console.debug("====>ActsAccountOAuthToken_3600 deleteAccount start===="); + await appAccountManager.deleteAccount("account_promise_limitAuthType"); + console.debug("====>ActsAccountOAuthToken_3600 end===="); + done(); + }); + + + it('ActsAccountOAuthToken_3700', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_3700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_3700 addAccount start===="); + appAccountManager.addAccount("account_callback_authType_empty",(err)=>{ + console.debug("====>ActsAccountOAuthToken_3700 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_authType_empty","","account_callback_authType_empty_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_3700 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_callback_authType_empty",OWNERSELF,"",(err,data)=>{ + console.debug("====>ActsAccountOAuthToken_3700 getOAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_3700 getOAuthToken data:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual("account_callback_authType_empty_token"); + appAccountManager.deleteAccount("account_callback_authType_empty",(err)=>{ + console.debug("====>ActsAccountOAuthToken_3700 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_3700 end===="); + done(); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_3800', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_3800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_3800 addAccount start===="); + await appAccountManager.addAccount("account_promise_authType_empty"); + console.debug("====>ActsAccountOAuthToken_3800 setOAuthToken start===="); + await appAccountManager.setOAuthToken("account_promise_authType_empty","","account_promise_authType_empty_token"); + console.debug("====>ActsAccountOAuthToken_3800 getOAuthToken start===="); + var data = await appAccountManager.getOAuthToken("account_promise_authType_empty",OWNERSELF,""); + expect(data).assertEqual("account_promise_authType_empty_token"); + console.debug("====>ActsAccountOAuthToken_3800 deleteAccount start===="); + await appAccountManager.deleteAccount("account_promise_authType_empty"); + console.debug("====>ActsAccountOAuthToken_3800 end===="); + done(); + }); + + it('ActsAccountOAuthToken_3900', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_3900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_3900 addAccount start===="); + appAccountManager.addAccount("account_callback_authType_space",(err)=>{ + console.debug("====>ActsAccountOAuthToken_3900 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_authType_space"," ","account_callback_authType_space_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_3900 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_callback_authType_space",OWNERSELF," ",(err,data)=>{ + console.debug("====>ActsAccountOAuthToken_3900 getOAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_3900 getOAuthToken data:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual("account_callback_authType_space_token"); + appAccountManager.deleteAccount("account_callback_authType_space",(err)=>{ + console.debug("====>ActsAccountOAuthToken_3900 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_3900 end===="); + done(); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_4000', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_4000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_4000 addAccount start===="); + await appAccountManager.addAccount("account_promise_authType_space"); + console.debug("====>ActsAccountOAuthToken_4000 setOAuthToken start===="); + await appAccountManager.setOAuthToken("account_promise_authType_space"," ","account_promise_authType_space_token"); + console.debug("====>ActsAccountOAuthToken_4000 getOAuthToken start===="); + var data = await appAccountManager.getOAuthToken("account_promise_authType_space",OWNERSELF," "); + expect(data).assertEqual("account_promise_authType_space_token"); + console.debug("====>ActsAccountOAuthToken_4000 deleteAccount start===="); + await appAccountManager.deleteAccount("account_promise_authType_space"); + console.debug("====>ActsAccountOAuthToken_4000 end===="); + done(); + }); + + + it('ActsAccountOAuthToken_4800', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_4800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_4800 addAccount start===="); + await appAccountManager.addAccount("account_promise_invalid_owner"); + console.debug("====>ActsAccountOAuthToken_4800 getOAuthToken start===="); + try{ + var data = await appAccountManager.getOAuthToken("account_promise_invalid_owner","invalid_owner","authType"); + } + catch(err){ + console.debug("====>ActsAccountOAuthToken_4800 getOAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_4800 deleteAccount start===="); + await appAccountManager.deleteAccount("account_promise_invalid_owner"); + console.debug("====>ActsAccountOAuthToken_4800 end===="); + done(); + } + }); + + it('ActsAccountOAuthToken_4900', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_4900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_4900 addAccount start===="); + appAccountManager.addAccount("account_callback_owner_empty",(err)=>{ + console.debug("====>ActsAccountOAuthToken_4900 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_callback_owner_empty","","authType",(err,data)=>{ + console.debug("====>ActsAccountOAuthToken_4900 getOAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_4900 getOAuthToken data:" + data); + expect(err.code!=0).assertEqual(true); + expect(data).assertEqual(""); + appAccountManager.deleteAccount("account_callback_owner_empty",(err)=>{ + console.debug("====>ActsAccountOAuthToken_4900 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_4900 end===="); + done(); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_5000', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_5000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_5000 addAccount start===="); + await appAccountManager.addAccount("account_promise_owner_empty"); + console.debug("====>ActsAccountOAuthToken_5000 getOAuthToken start===="); + try{ + var data = await appAccountManager.getOAuthToken("account_promise_owner_empty","","authType"); + } + catch(err){ + console.debug("====>ActsAccountOAuthToken_5000 getOAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_5000 deleteAccount start===="); + await appAccountManager.deleteAccount("account_promise_owner_empty"); + console.debug("====>ActsAccountOAuthToken_5000 end===="); + done(); + } + }); + + it('ActsAccountOAuthToken_5100', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_5100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_5100 addAccount start===="); + appAccountManager.addAccount("account_callback_owner_space",(err)=>{ + console.debug("====>ActsAccountOAuthToken_5100 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_callback_owner_space"," ","authType",(err,data)=>{ + console.debug("====>ActsAccountOAuthToken_5100 getOAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_5100 getOAuthToken data:" + data); + expect(err.code!=0).assertEqual(true); + expect(data).assertEqual(""); + appAccountManager.deleteAccount("account_callback_owner_space",(err)=>{ + console.debug("====>ActsAccountOAuthToken_5100 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_5100 end===="); + done(); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_5200', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_5200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_5200 addAccount start===="); + await appAccountManager.addAccount("account_callback_owner_space"); + console.debug("====>ActsAccountOAuthToken_5200 getOAuthToken start===="); + try{ + var data = await appAccountManager.getOAuthToken("account_callback_owner_space"," ","authType"); + } + catch(err){ + console.debug("====>ActsAccountOAuthToken_5200 getOAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_5200 deleteAccount start===="); + await appAccountManager.deleteAccount("account_callback_owner_space"); + console.debug("====>ActsAccountOAuthToken_5200 end===="); + done(); + } + }); + + it('ActsAccountOAuthToken_5300', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_5300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_5300 addAccount start===="); + appAccountManager.addAccount("account_callback_authType_invalid",(err)=>{ + console.debug("====>ActsAccountOAuthToken_5300 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_authType_invalid","authType","account_callback_authType_invalid_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_5300 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_callback_authType_invalid",OWNERSELF,"invalid_authType",(err,data)=>{ + console.debug("====>ActsAccountOAuthToken_5300 getOAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_5300 getOAuthToken data:" + data); + expect(err.code!=0).assertEqual(true); + expect(data).assertEqual(""); + appAccountManager.deleteAccount("account_callback_authType_invalid",(err)=>{ + console.debug("====>ActsAccountOAuthToken_5300 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_5300 end===="); + done(); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_5400', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_5400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_5400 addAccount start===="); + await appAccountManager.addAccount("account_promise_authType_invalid"); + console.debug("====>ActsAccountOAuthToken_5400 setOAuthToken start===="); + await appAccountManager.setOAuthToken("account_promise_authType_invalid","authType","account_promise_authType_invalid_token"); + console.debug("====>ActsAccountOAuthToken_5400 getOAuthToken start===="); + try{ + var data = await appAccountManager.getOAuthToken("account_promise_authType_invalid",OWNERSELF,"invalid_authType"); + } + catch(err){ + console.debug("====>ActsAccountOAuthToken_5400 getOAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_5400 deleteAccount start===="); + await appAccountManager.deleteAccount("account_promise_authType_invalid"); + console.debug("====>ActsAccountOAuthToken_5400 end===="); + done(); + } + }); + + it('ActsAccountOAuthToken_5500', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_5500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_5500 addAccount start===="); + appAccountManager.addAccount("account_callback_authType_empty",(err)=>{ + console.debug("====>ActsAccountOAuthToken_5500 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_authType_empty","authType","account_callback_authType_empty_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_5500 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_callback_authType_empty",OWNERSELF,"",(err,data)=>{ + console.debug("====>ActsAccountOAuthToken_5500 getOAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_5500 getOAuthToken data:" + data); + expect(err.code!=0).assertEqual(true); + expect(data).assertEqual(""); + appAccountManager.deleteAccount("account_callback_authType_empty",(err)=>{ + console.debug("====>ActsAccountOAuthToken_5500 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_5500 end===="); + done(); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_5600', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_5600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_5600 addAccount start===="); + await appAccountManager.addAccount("account_promise_authType_empty"); + console.debug("====>ActsAccountOAuthToken_5600 setOAuthToken start===="); + await appAccountManager.setOAuthToken("account_promise_authType_empty","authType","account_promise_authType_empty_token"); + console.debug("====>ActsAccountOAuthToken_5600 getOAuthToken start===="); + try{ + var data = await appAccountManager.getOAuthToken("account_promise_authType_empty",OWNERSELF,""); + } + catch(err){ + console.debug("====>ActsAccountOAuthToken_5600 getOAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_5600 deleteAccount start===="); + await appAccountManager.deleteAccount("account_promise_authType_empty"); + console.debug("====>ActsAccountOAuthToken_5600 end===="); + done(); + } + }); + + it('ActsAccountOAuthToken_5700', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_5700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_5700 addAccount start===="); + appAccountManager.addAccount("account_callback_authType_space",(err)=>{ + console.debug("====>ActsAccountOAuthToken_5700 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_authType_space","authType","account_callback_authType_space_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_5700 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_callback_authType_space",OWNERSELF," ",(err,data)=>{ + console.debug("====>ActsAccountOAuthToken_5700 getOAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_5700 getOAuthToken data:" + data); + expect(err.code!=0).assertEqual(true); + expect(data).assertEqual(""); + appAccountManager.deleteAccount("account_callback_authType_space",(err)=>{ + console.debug("====>ActsAccountOAuthToken_5700 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_5700 end===="); + done(); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_5800', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_5800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_5800 addAccount start===="); + await appAccountManager.addAccount("account_promise_authType_space"); + console.debug("====>ActsAccountOAuthToken_5800 setOAuthToken start===="); + await appAccountManager.setOAuthToken("account_promise_authType_space","authType","account_promise_authType_space_token"); + console.debug("====>ActsAccountOAuthToken_5800 getOAuthToken start===="); + try{ + var data = await appAccountManager.getOAuthToken("account_promise_authType_space",OWNERSELF," "); + } + catch(err){ + console.debug("====>ActsAccountOAuthToken_5800 getOAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_5800 deleteAccount start===="); + await appAccountManager.deleteAccount("account_promise_authType_space"); + console.debug("====>ActsAccountOAuthToken_5800 end===="); + done(); + } + }); + + it('ActsAccountOAuthToken_5900', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_5900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_5900 addAccount start===="); + appAccountManager.addAccount("account_callback_owner_invalid",(err)=>{ + console.debug("====>ActsAccountOAuthToken_5900 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_owner_invalid","authType","account_callback_owner_invalid_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_5900 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteOAuthToken("account_callback_owner_invalid","invalid_owner","authType","account_callback_owner_invalid_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_5900 getOAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + appAccountManager.deleteAccount("account_callback_owner_invalid",(err)=>{ + console.debug("====>ActsAccountOAuthToken_5900 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_5900 end===="); + done(); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_6000', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_6000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_6000 addAccount start===="); + await appAccountManager.addAccount("account_promise_owner_invalid"); + console.debug("====>ActsAccountOAuthToken_6000 setOAuthToken start===="); + await appAccountManager.setOAuthToken("account_promise_owner_invalid","authType","account_promise_owner_invalid_token"); + console.debug("====>ActsAccountOAuthToken_6000 getOAuthToken start===="); + try{ + await appAccountManager.deleteOAuthToken("account_promise_owner_invalid","invalid_owner","authType","account_promise_owner_invalid_token"); + } + catch(err){ + console.debug("====>ActsAccountOAuthToken_6000 getOAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_6000 deleteAccount start===="); + await appAccountManager.deleteAccount("account_promise_owner_invalid"); + console.debug("====>ActsAccountOAuthToken_6000 end===="); + done(); + } + }); + + it('ActsAccountOAuthToken_6100', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_6100 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_6100 addAccount start===="); + appAccountManager.addAccount("account_callback_owner_empty",(err)=>{ + console.debug("====>ActsAccountOAuthToken_6100 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_owner_empty","authType","account_callback_owner_empty_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_6100 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteOAuthToken("account_callback_owner_empty","","authType","account_callback_owner_empty_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_6100 getOAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + appAccountManager.deleteAccount("account_callback_owner_empty",(err)=>{ + console.debug("====>ActsAccountOAuthToken_6100 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_6100 end===="); + done(); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_6200', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_6200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_6200 addAccount start===="); + await appAccountManager.addAccount("account_promise_owner_empty"); + console.debug("====>ActsAccountOAuthToken_6200 setOAuthToken start===="); + await appAccountManager.setOAuthToken("account_promise_owner_empty","authType","account_promise_owner_empty_token"); + console.debug("====>ActsAccountOAuthToken_6200 getOAuthToken start===="); + try{ + await appAccountManager.deleteOAuthToken("account_promise_owner_empty","","authType","account_promise_owner_empty_token"); + } + catch(err){ + console.debug("====>ActsAccountOAuthToken_6200 getOAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_6200 deleteAccount start===="); + await appAccountManager.deleteAccount("account_promise_owner_empty"); + console.debug("====>ActsAccountOAuthToken_6200 end===="); + done(); + } + }); + + it('ActsAccountOAuthToken_6300', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_6300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_6300 addAccount start===="); + appAccountManager.addAccount("account_callback_owner_space",(err)=>{ + console.debug("====>ActsAccountOAuthToken_6300 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_owner_space","authType","account_callback_owner_space_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_6300 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteOAuthToken("account_callback_owner_space"," ","authType","account_callback_owner_space_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_6300 getOAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + appAccountManager.deleteAccount("account_callback_owner_space",(err)=>{ + console.debug("====>ActsAccountOAuthToken_6300 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_6300 end===="); + done(); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_6400', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_6400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_6400 addAccount start===="); + await appAccountManager.addAccount("account_promise_owner_space"); + console.debug("====>ActsAccountOAuthToken_6400 setOAuthToken start===="); + await appAccountManager.setOAuthToken("account_promise_owner_space","authType","account_promise_owner_space_token"); + console.debug("====>ActsAccountOAuthToken_6400 getOAuthToken start===="); + try{ + await appAccountManager.deleteOAuthToken("account_promise_owner_space"," ","authType","account_promise_owner_space_token"); + } + catch(err){ + console.debug("====>ActsAccountOAuthToken_6400 getOAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_6400 deleteAccount start===="); + await appAccountManager.deleteAccount("account_promise_owner_space"); + console.debug("====>ActsAccountOAuthToken_6400 end===="); + done(); + } + }); + + it('ActsAccountOAuthToken_6500', 0, async function (done) { + var limitToken = ''; + for(var i = 0;i < TOKENLENGTHLIMIT + 1; i++){ + limitToken += 'c'; + } + console.debug("====>ActsAccountOAuthToken_6500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_6500 addAccount start===="); + appAccountManager.addAccount("account_callback_token_exceedLimit",(err)=>{ + console.debug("====>ActsAccountOAuthToken_6500 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteOAuthToken("account_callback_token_exceedLimit",OWNERSELF,"authType",limitToken,(err)=>{ + console.debug("====>ActsAccountOAuthToken_6500 getOAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + appAccountManager.deleteAccount("account_callback_token_exceedLimit",(err)=>{ + console.debug("====>ActsAccountOAuthToken_6500 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_6500 end===="); + done(); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_6600', 0, async function (done) { + var limitToken = ''; + for(var i = 0;i < TOKENLENGTHLIMIT + 1; i++){ + limitToken += 'c'; + } + console.debug("====>ActsAccountOAuthToken_6600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_6600 addAccount start===="); + await appAccountManager.addAccount("account_promise_token_exceedLimit"); + console.debug("====>ActsAccountOAuthToken_6600 deleteOAuthToken start===="); + try{ + await appAccountManager.deleteOAuthToken("account_promise_token_exceedLimit",OWNERSELF,"authType",limitToken); + } + catch(err){ + console.debug("====>ActsAccountOAuthToken_6600 getOAuthToken err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_6600 deleteAccount start===="); + await appAccountManager.deleteAccount("account_promise_token_exceedLimit"); + console.debug("====>ActsAccountOAuthToken_6600 end===="); + done(); + } + }); + + it('ActsAccountOAuthToken_6700', 0, async function (done) { + var limitToken = ''; + for(var i = 0;i < TOKENLENGTHLIMIT; i++){ + limitToken += 'c'; + } + console.debug("====>ActsAccountOAuthToken_6700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_6700 addAccount start===="); + appAccountManager.addAccount("account_callback_token_limit",(err)=>{ + console.debug("====>ActsAccountOAuthToken_6700 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_token_limit","authType",limitToken,(err)=>{ + console.debug("====>ActsAccountOAuthToken_6700 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteOAuthToken("account_callback_token_limit",OWNERSELF,"authType",limitToken,(err)=>{ + console.debug("====>ActsAccountOAuthToken_6700 getOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount("account_callback_token_limit",(err)=>{ + console.debug("====>ActsAccountOAuthToken_6700 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_6700 end===="); + done(); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_6800', 0, async function (done) { + var limitToken = ''; + for(var i = 0;i < TOKENLENGTHLIMIT; i++){ + limitToken += 'c'; + } + console.debug("====>ActsAccountOAuthToken_6800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_6800 addAccount start===="); + await appAccountManager.addAccount("account_promise_token_limit"); + console.debug("====>ActsAccountOAuthToken_6800 setOAuthToken start===="); + await appAccountManager.setOAuthToken("account_promise_token_limit","authType",limitToken); + console.debug("====>ActsAccountOAuthToken_6800 deleteOAuthToken start===="); + await appAccountManager.deleteOAuthToken("account_promise_token_limit",OWNERSELF,"authType",limitToken); + console.debug("====>ActsAccountOAuthToken_6800 deleteAccount start===="); + await appAccountManager.deleteAccount("account_promise_token_limit"); + console.debug("====>ActsAccountOAuthToken_6800 end===="); + done(); + }); + + it('ActsAccountOAuthToken_6900', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_6900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_6900 addAccount start===="); + appAccountManager.addAccount("account_callback_delete_space",(err)=>{ + console.debug("====>ActsAccountOAuthToken_6900 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_callback_delete_space","authType","account_callback_delete_space_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_6900 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteOAuthToken("account_callback_delete_space",OWNERSELF,"authType","",(err)=>{ + console.debug("====>ActsAccountOAuthToken_6900 getOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_callback_delete_space",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountOAuthToken_6900 getOAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_6900 getOAuthToken data:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual("account_callback_delete_space_token"); + appAccountManager.deleteAccount("account_callback_delete_space",(err)=>{ + console.debug("====>ActsAccountOAuthToken_6900 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_6900 end===="); + done(); + }); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_7000', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_7000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>ActsAccountOAuthToken_7000 addAccount start===="); + await appAccountManager.addAccount("account_promise_delete_space"); + console.debug("====>ActsAccountOAuthToken_7000 setOAuthToken start===="); + await appAccountManager.setOAuthToken("account_promise_delete_space","authType","account_promise_delete_space_token"); + console.debug("====>ActsAccountOAuthToken_7000 deleteOAuthToken start===="); + await appAccountManager.deleteOAuthToken("account_promise_delete_space",OWNERSELF,"authType",""); + console.debug("====>ActsAccountOAuthToken_7000 getOAuthToken start===="); + var data = await appAccountManager.getOAuthToken("account_promise_delete_space",OWNERSELF,"authType"); + expect(data).assertEqual("account_promise_delete_space_token"); + console.debug("====>ActsAccountOAuthToken_7000 deleteAccount start===="); + await appAccountManager.deleteAccount("account_promise_delete_space"); + console.debug("====>ActsAccountOAuthToken_7000 end===="); + done(); + }); + + it('ActsAccountOAuthToken_9200', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_9200 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.getAuthenticatorCallback("test_sessionId",(err,databack)=>{ + console.debug("====>ActsAccountOAuthToken_9200 getAuthenticatorCallback err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + expect(databack).assertEqual(undefined); + done(); + }); + }); + + it('ActsAccountOAuthToken_9300', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_9300 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.getAuthenticatorCallback("",(err,databack)=>{ + console.debug("====>ActsAccountOAuthToken_9300 getAuthenticatorCallback err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + expect(databack).assertEqual(undefined); + done(); + }); + }); + + it('ActsAccountOAuthToken_9400', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_9400 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.getAuthenticatorCallback(" ",(err,databack)=>{ + console.debug("====>ActsAccountOAuthToken_9400 getAuthenticatorCallback err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + expect(databack).assertEqual(undefined); + done(); + }); + }); + + it('ActsAccountOAuthToken_9500', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_9500 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.getAuthenticatorInfo(OWNERSELF,(err,databack)=>{ + console.debug("====>ActsAccountOAuthToken_9500 getAuthenticatorInfo err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + expect(account.ResultCode.SUCCESS).assertEqual(0); + expect(account.ResultCode.ERROR_ACCOUNT_NOT_EXIST).assertEqual(10001); + expect(account.ResultCode.ERROR_APP_ACCOUNT_SERVICE_EXCEPTION).assertEqual(10002); + expect(account.ResultCode.ERROR_INVALID_PASSWORD).assertEqual(10003); + expect(account.ResultCode.ERROR_INVALID_REQUEST).assertEqual(10004); + expect(account.ResultCode.ERROR_INVALID_RESPONSE).assertEqual(10005); + expect(account.ResultCode.ERROR_NETWORK_EXCEPTION).assertEqual(10006); + expect(account.ResultCode.ERROR_OAUTH_AUTHENTICATOR_NOT_EXIST).assertEqual(10007); + expect(account.ResultCode.ERROR_OAUTH_CANCELED).assertEqual(10008); + expect(account.ResultCode.ERROR_OAUTH_LIST_TOO_LARGE).assertEqual(10009); + expect(account.ResultCode.ERROR_OAUTH_SERVICE_BUSY).assertEqual(10010); + expect(account.ResultCode.ERROR_OAUTH_SERVICE_EXCEPTION).assertEqual(10011); + expect(account.ResultCode.ERROR_OAUTH_SESSION_NOT_EXIST).assertEqual(10012); + expect(account.ResultCode.ERROR_OAUTH_TIMEOUT).assertEqual(10013); + expect(account.ResultCode.ERROR_OAUTH_TOKEN_NOT_EXIST).assertEqual(10014); + expect(account.ResultCode.ERROR_OAUTH_TOKEN_TOO_MANY).assertEqual(10015); + expect(account.ResultCode.ERROR_OAUTH_UNSUPPORT_ACTION).assertEqual(10016); + expect(account.ResultCode.ERROR_OAUTH_UNSUPPORT_AUTH_TYPE).assertEqual(10017); + expect(account.ResultCode.ERROR_PERMISSION_DENIED).assertEqual(10018); + done(); + }); + }); + + it('ActsAccountOAuthToken_9600', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_9600 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.getAuthenticatorInfo("",(err,databack)=>{ + console.debug("====>ActsAccountOAuthToken_9600 getAuthenticatorInfo err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + expect(account.Constants.ACTION_ADD_ACCOUNT_IMPLICITLY).assertEqual('addAccountImplicitly'); + expect(account.Constants.ACTION_AUTHENTICATE).assertEqual('authenticate'); + expect(account.Constants.KEY_NAME).assertEqual('name'); + expect(account.Constants.KEY_OWNER).assertEqual('owner'); + expect(account.Constants.KEY_TOKEN).assertEqual('token'); + expect(account.Constants.KEY_ACTION).assertEqual('action'); + expect(account.Constants.KEY_AUTH_TYPE).assertEqual('authType'); + expect(account.Constants.KEY_SESSION_ID).assertEqual('sessionId'); + expect(account.Constants.KEY_CALLER_PID).assertEqual('callerPid'); + expect(account.Constants.KEY_CALLER_UID).assertEqual('callerUid'); + expect(account.Constants.KEY_CALLER_BUNDLE_NAME).assertEqual('callerBundleName'); + done(); + }); + }); + + it('ActsAccountOAuthToken_9700', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_9700 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.getAuthenticatorInfo(" ",(err,databack)=>{ + console.debug("====>ActsAccountOAuthToken_9700 getAuthenticatorInfo err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + done(); + }); + }); + + it('ActsAccountOAuthToken_9800', 0, async function (done) { + var limiOwner = ''; + for(var i = 0;i < OWNERLENGTHLIMIT + 1; i++){ + limiOwner += 't'; + } + console.debug("====>ActsAccountOAuthToken_9800 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.getAuthenticatorInfo(limiOwner,(err,databack)=>{ + console.debug("====>ActsAccountOAuthToken_9800 getAuthenticatorInfo err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + done(); + }); + }); + + it('ActsAccountOAuthToken_9900', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_9900 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_setOAuthTokenVisibility_name",(err,)=>{ + console.debug("====>ActsAccountOAuthToken_9900 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthTokenVisibility("account_setOAuthTokenVisibility_name","authType","test_BundleName",true,(err)=>{ + console.debug("====>ActsAccountOAuthToken_9900 setOAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_setOAuthTokenVisibility_name",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountOAuthToken_9900 getOAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_9900 getOAuthToken data:" + data); + expect(err.code!=0).assertEqual(true); + expect(data).assertEqual(""); + appAccountManager.getOAuthList("account_setOAuthTokenVisibility_name","authType",(err,dataArray)=>{ + console.debug("====>ActsAccountOAuthToken_9900 getOAuthList err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_9900 getOAuthList dataArray:" + JSON.stringify(dataArray)); + expect(dataArray.length).assertEqual(1); + expect(dataArray[0]).assertEqual("test_BundleName"); + appAccountManager.deleteAccount("account_setOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_9900 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_9900 end===="); + done(); + }); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_10000', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_10000 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_setOAuthTokenVisibility_name",(err,)=>{ + console.debug("====>ActsAccountOAuthToken_10000 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_setOAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_10000 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthTokenVisibility("account_setOAuthTokenVisibility_name","authType","test_BundleName","",(err)=>{ + console.debug("====>ActsAccountOAuthToken_10000 setOAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthList("account_setOAuthTokenVisibility_name","authType",(err,dataArray)=>{ + console.debug("====>ActsAccountOAuthToken_10000 getOAuthList err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_10000 getOAuthList dataArray:" + JSON.stringify(dataArray)); + expect(dataArray.length).assertEqual(0); + appAccountManager.deleteAccount("account_setOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_10000 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_10000 end===="); + done(); + }); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_10100', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_10100 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_setOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_10100 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_setOAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_10100 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthTokenVisibility("account_setOAuthTokenVisibility_name","authType","test_BundleName","invalid_string",(err)=>{ + console.debug("====>ActsAccountOAuthToken_10100 setOAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthList("account_setOAuthTokenVisibility_name","authType",(err,dataArray)=>{ + console.debug("====>ActsAccountOAuthToken_10100 getOAuthList err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_10100 getOAuthList dataArray:" + JSON.stringify(dataArray)); + expect(dataArray.length).assertEqual(0); + appAccountManager.deleteAccount("account_setOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_10100 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_10100 end===="); + done(); + }); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_10200', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_10200 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_setOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_10200 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_setOAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_10200 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthTokenVisibility("account_setOAuthTokenVisibility_name","authType","",true,(err)=>{ + console.debug("====>ActsAccountOAuthToken_10200 setOAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + appAccountManager.deleteAccount("account_setOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_10200 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_10200 end===="); + done(); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_10300', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_10300 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_setOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_10300 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_setOAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_10300 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthTokenVisibility("account_setOAuthTokenVisibility_name","authType"," ",true,(err)=>{ + console.debug("====>ActsAccountOAuthToken_10300 setOAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthList("account_setOAuthTokenVisibility_name","authType",(err,dataArray)=>{ + console.debug("====>ActsAccountOAuthToken_10300 getOAuthList err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_10300 getOAuthList dataArray:" + JSON.stringify(dataArray)); + expect(dataArray.length).assertEqual(1); + expect(dataArray[0]).assertEqual(" "); + appAccountManager.deleteAccount("account_setOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_10300 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_10300 end===="); + done(); + }); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_10400', 0, async function (done) { + var limitBundleName = ''; + for(var i = 0;i < OWNERLENGTHLIMIT + 1; i++){ + limitBundleName += 't'; + } + console.debug("====>ActsAccountOAuthToken_10400 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_setOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_10400 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_setOAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_10400 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthTokenVisibility("account_setOAuthTokenVisibility_name","authType",limitBundleName,true,(err)=>{ + console.debug("====>ActsAccountOAuthToken_10400 setOAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + appAccountManager.deleteAccount("account_setOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_10400 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_10400 end===="); + done(); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_10500', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_10500 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_setOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_10500 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_setOAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_10500 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthTokenVisibility("account_setOAuthTokenVisibility_name","","test_bundleName",true,(err)=>{ + console.debug("====>ActsAccountOAuthToken_10500 setOAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthList("account_setOAuthTokenVisibility_name","",(err,dataArray)=>{ + console.debug("====>ActsAccountOAuthToken_10500 getOAuthList err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_10500 getOAuthList dataArray:" + JSON.stringify(dataArray)); + expect(dataArray.length).assertEqual(1); + expect(dataArray[0]).assertEqual("test_bundleName"); + appAccountManager.getOAuthList("account_setOAuthTokenVisibility_name","authType",(err,dataArray)=>{ + console.debug("====>ActsAccountOAuthToken_10500 getOAuthList authType:\"authType\" err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_10500 getOAuthList authType:\"authType\" dataArray:" + JSON.stringify(dataArray)); + expect(dataArray.length).assertEqual(0); + appAccountManager.deleteAccount("account_setOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_10500 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_10500 end===="); + done(); + }); + }); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_10600', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_10600 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_setOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_10600 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_setOAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_10600 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthTokenVisibility("account_setOAuthTokenVisibility_name"," ","test_bundleName",true,(err)=>{ + console.debug("====>ActsAccountOAuthToken_10600 setOAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthList("account_setOAuthTokenVisibility_name"," ",(err,dataArray)=>{ + console.debug("====>ActsAccountOAuthToken_10600 getOAuthList err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_10600 getOAuthList dataArray:" + JSON.stringify(dataArray)); + expect(dataArray.length).assertEqual(1); + expect(dataArray[0]).assertEqual("test_bundleName"); + appAccountManager.getOAuthList("account_setOAuthTokenVisibility_name","authType",(err,dataArray)=>{ + console.debug("====>ActsAccountOAuthToken_10600 getOAuthList authType:\"authType\" err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_10600 getOAuthList authType:\"authType\" dataArray:" + JSON.stringify(dataArray)); + expect(dataArray.length).assertEqual(0); + appAccountManager.deleteAccount("account_setOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_10600 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_10600 end===="); + done(); + }); + }); + }); + }); + }); + }); + }); + + + it('ActsAccountOAuthToken_10700', 0, async function (done) { + var limitAuthType = ''; + for(var i = 0;i < AUTHTYPELENGTHLIMIT + 1; i++){ + limitAuthType += 't'; + } + console.debug("====>ActsAccountOAuthToken_10700 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_setOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_10700 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_setOAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_10700 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthTokenVisibility("account_setOAuthTokenVisibility_name",limitAuthType,"test_bundleName",true,(err)=>{ + console.debug("====>ActsAccountOAuthToken_10700 setOAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + appAccountManager.getOAuthList("account_setOAuthTokenVisibility_name","authType",(err,dataArray)=>{ + console.debug("====>ActsAccountOAuthToken_10700 getOAuthList authType:\"authType\" err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_10700 getOAuthList authType:\"authType\" dataArray:" + JSON.stringify(dataArray)); + expect(dataArray.length).assertEqual(0); + appAccountManager.deleteAccount("account_setOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_10700 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_10700 end===="); + done(); + }); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_10800', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_10800 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_setOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_10800 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_setOAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_10800 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthTokenVisibility("account_setOAuthTokenVisibility_name","invalid_authType","test_bundleName",true,(err)=>{ + console.debug("====>ActsAccountOAuthToken_10800 setOAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthList("account_setOAuthTokenVisibility_name","invalid_authType",(err,dataArray)=>{ + console.debug("====>ActsAccountOAuthToken_10800 getOAuthList err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_10800 getOAuthList dataArray:" + JSON.stringify(dataArray)); + expect(dataArray.length).assertEqual(1); + expect(dataArray[0]).assertEqual("test_bundleName"); + appAccountManager.getOAuthList("account_setOAuthTokenVisibility_name","authType",(err,dataArray)=>{ + console.debug("====>ActsAccountOAuthToken_10800 getOAuthList authType:\"authType\" err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_10800 getOAuthList authType:\"authType\" dataArray:" + JSON.stringify(dataArray)); + expect(dataArray.length).assertEqual(0); + appAccountManager.deleteAccount("account_setOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_10800 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_10800 end===="); + done(); + }); + }); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_10900', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_10900 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.setOAuthTokenVisibility("","authType","test_bundleName",true,(err)=>{ + console.debug("====>ActsAccountOAuthToken_10900 setOAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + done(); + }); + }); + + it('ActsAccountOAuthToken_11000', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_11000 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.setOAuthTokenVisibility(" ","authType","test_bundleName",true,(err)=>{ + console.debug("====>ActsAccountOAuthToken_11000 setOAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + done(); + }); + }); + + it('ActsAccountOAuthToken_11100', 0, async function (done) { + var limitName = ''; + for(var i = 0; i < LENGTHLIMIT + 1; i++){ + limitName += 't'; + } + console.debug("====>ActsAccountOAuthToken_11100 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.setOAuthTokenVisibility(limitName,"authType","test_bundleName",true,(err)=>{ + console.debug("====>ActsAccountOAuthToken_11100 setOAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + done(); + }); + }); + + it('ActsAccountOAuthToken_11200', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_11200 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.setOAuthTokenVisibility("no_add_account","authType","test_bundleName",true,(err)=>{ + console.debug("====>ActsAccountOAuthToken_11200 setOAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + done(); + }); + }); + + it('ActsAccountOAuthToken_11300', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_11300 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.checkOAuthTokenVisibility("","authType","test_bundleName",(err,stateBack)=>{ + console.debug("====>ActsAccountOAuthToken_11300 checkOAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + done(); + }); + }); + + it('ActsAccountOAuthToken_11400', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_11400 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.checkOAuthTokenVisibility(" ","authType","test_bundleName",(err,stateBack)=>{ + console.debug("====>ActsAccountOAuthToken_11400 checkOAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + done(); + }); + }); + + it('ActsAccountOAuthToken_11500', 0, async function (done) { + var limitName = ''; + for(var i = 0; i < LENGTHLIMIT + 1; i++){ + limitName += 't'; + } + console.debug("====>ActsAccountOAuthToken_11500 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.checkOAuthTokenVisibility(limitName,"authType","test_bundleName",(err,stateBack)=>{ + console.debug("====>ActsAccountOAuthToken_11500 checkOAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + done(); + }); + }); + + it('ActsAccountOAuthToken_11600', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_11600 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.checkOAuthTokenVisibility("no_add_account","authType","test_bundleName",(err,stateBack)=>{ + console.debug("====>ActsAccountOAuthToken_11600 checkOAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + done(); + }); + }); + + it('ActsAccountOAuthToken_11700', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_11700 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_checkOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_11700 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_checkOAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_11700 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.checkOAuthTokenVisibility("account_checkOAuthTokenVisibility_name","","test_bundleName",(err,stateBack)=>{ + console.debug("====>ActsAccountOAuthToken_11700 checkOAuthTokenVisibility err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_11700 checkOAuthTokenVisibility stateBack:" + stateBack); + expect(err.code).assertEqual(0); + expect(stateBack).assertEqual(false); + appAccountManager.checkOAuthTokenVisibility("account_checkOAuthTokenVisibility_name","",OWNERSELF,(err,stateBack)=>{ + console.debug("====>ActsAccountOAuthToken_11700 checkOAuthTokenVisibility err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_11700 checkOAuthTokenVisibility stateBack:" + stateBack); + expect(err.code).assertEqual(0); + expect(stateBack).assertEqual(true); + appAccountManager.deleteAccount("account_checkOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_11700 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_11700 end===="); + done(); + }); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_11800', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_11800 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_checkOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_11800 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_checkOAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_11800 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.checkOAuthTokenVisibility("account_checkOAuthTokenVisibility_name"," ","test_bundleName",(err,stateBack)=>{ + console.debug("====>ActsAccountOAuthToken_11800 checkOAuthTokenVisibility err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_11800 checkOAuthTokenVisibility stateBack:" + stateBack); + expect(err.code).assertEqual(0); + expect(stateBack).assertEqual(false); + appAccountManager.checkOAuthTokenVisibility("account_checkOAuthTokenVisibility_name"," ",OWNERSELF,(err,stateBack)=>{ + console.debug("====>ActsAccountOAuthToken_11800 checkOAuthTokenVisibility err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_11800 checkOAuthTokenVisibility stateBack:" + stateBack); + expect(err.code).assertEqual(0); + expect(stateBack).assertEqual(true); + appAccountManager.deleteAccount("account_checkOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_11800 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_11800 end===="); + done(); + }); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_11900', 0, async function (done) { + var limitAuthType =''; + for(var i = 0; i < AUTHTYPELENGTHLIMIT + 1; i++){ + limitAuthType += 't'; + } + console.debug("====>ActsAccountOAuthToken_11900 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_checkOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_11900 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_checkOAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_11900 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.checkOAuthTokenVisibility("account_checkOAuthTokenVisibility_name",limitAuthType,"test_bundleName",(err,stateBack)=>{ + console.debug("====>ActsAccountOAuthToken_11900 checkOAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + appAccountManager.checkOAuthTokenVisibility("account_checkOAuthTokenVisibility_name",limitAuthType,OWNERSELF,(err,stateBack)=>{ + console.debug("====>ActsAccountOAuthToken_11900 checkOAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + appAccountManager.deleteAccount("account_checkOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_11900 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_11900 end===="); + done(); + }); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_12000', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_12000 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_checkOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_12000 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_checkOAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_12000 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.checkOAuthTokenVisibility("account_checkOAuthTokenVisibility_name","invalid_authType","test_bundleName",(err,stateBack)=>{ + console.debug("====>ActsAccountOAuthToken_12000 checkOAuthTokenVisibility err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_12000 checkOAuthTokenVisibility stateBack:" + stateBack); + expect(err.code).assertEqual(0); + expect(stateBack).assertEqual(false); + appAccountManager.checkOAuthTokenVisibility("account_checkOAuthTokenVisibility_name","invalid_authType",OWNERSELF,(err,stateBack)=>{ + console.debug("====>ActsAccountOAuthToken_12000 checkOAuthTokenVisibility err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_12000 checkOAuthTokenVisibility stateBack:" + stateBack); + expect(err.code).assertEqual(0); + expect(stateBack).assertEqual(true); + appAccountManager.deleteAccount("account_checkOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_12000 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_12000 end===="); + done(); + }); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_12100', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_12100 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_checkOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_12100 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_checkOAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_12100 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.checkOAuthTokenVisibility("account_checkOAuthTokenVisibility_name","authType","",(err,stateBack)=>{ + console.debug("====>ActsAccountOAuthToken_12100 checkOAuthTokenVisibility err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_12100 checkOAuthTokenVisibility stateBack:" + stateBack); + expect(err.code!=0).assertEqual(true); + appAccountManager.deleteAccount("account_checkOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_12100 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_12100 end===="); + done(); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_12200', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_12200 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_checkOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_12200 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_checkOAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_12200 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.checkOAuthTokenVisibility("account_checkOAuthTokenVisibility_name","authType"," ",(err,stateBack)=>{ + console.debug("====>ActsAccountOAuthToken_12200 checkOAuthTokenVisibility err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_12200 checkOAuthTokenVisibility stateBack:" + stateBack); + expect(err.code).assertEqual(0); + expect(stateBack).assertEqual(false); + appAccountManager.deleteAccount("account_checkOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_12200 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_12200 end===="); + done(); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_12300', 0, async function (done) { + var limitBundleName = ''; + for(var i = 0; i < OWNERLENGTHLIMIT + 1; i++){ + limitBundleName += 't'; + } + console.debug("====>ActsAccountOAuthToken_12300 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_checkOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_12300 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_checkOAuthTokenVisibility_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_12300 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.checkOAuthTokenVisibility("account_checkOAuthTokenVisibility_name","authType",limitBundleName,(err,stateBack)=>{ + console.debug("====>ActsAccountOAuthToken_12300 checkOAuthTokenVisibility err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_12300 checkOAuthTokenVisibility stateBack:" + stateBack); + expect(err.code!=0).assertEqual(true); + appAccountManager.deleteAccount("account_checkOAuthTokenVisibility_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_12300 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_12300 end===="); + done(); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_12400', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_12400 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_testGetOAuthList_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_12400 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_testGetOAuthList_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_12400 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthTokenVisibility("account_testGetOAuthList_name","authType","test_bundleName",true,(err)=>{ + console.debug("====>ActsAccountOAuthToken_12400 setOAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthList("account_testGetOAuthList_name","",(err,dataArray)=>{ + console.debug("====>ActsAccountOAuthToken_12400 getOAuthList err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_12400 getOAuthList dataArray:" + JSON.stringify(dataArray)); + expect(dataArray.length).assertEqual(0); + appAccountManager.deleteAccount("account_testGetOAuthList_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_12400 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_12400 end===="); + done(); + }); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_12500', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_12500 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_testGetOAuthList_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_12500 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_testGetOAuthList_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_12500 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthTokenVisibility("account_testGetOAuthList_name","authType","test_bundleName",true,(err)=>{ + console.debug("====>ActsAccountOAuthToken_12500 setOAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthList("account_testGetOAuthList_name"," ",(err,dataArray)=>{ + console.debug("====>ActsAccountOAuthToken_12500 getOAuthList err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_12500 getOAuthList dataArray:" + JSON.stringify(dataArray)); + expect(dataArray.length).assertEqual(0); + appAccountManager.deleteAccount("account_testGetOAuthList_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_12500 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_12500 end===="); + done(); + }); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_12600', 0, async function (done) { + var limitAuthType =''; + for(var i = 0; i < AUTHTYPELENGTHLIMIT + 1; i++){ + limitAuthType += 't'; + } + console.debug("====>ActsAccountOAuthToken_12600 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_testGetOAuthList_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_12600 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_testGetOAuthList_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_12600 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthTokenVisibility("account_testGetOAuthList_name","authType","test_bundleName",true,(err)=>{ + console.debug("====>ActsAccountOAuthToken_12600 setOAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthList("account_testGetOAuthList_name",limitAuthType,(err,dataArray)=>{ + console.debug("====>ActsAccountOAuthToken_12600 getOAuthList err:" + JSON.stringify(err)); + expect(err.code!=0).assertEqual(true); + console.debug("====>ActsAccountOAuthToken_12600 getOAuthList dataArray:" + JSON.stringify(dataArray)); + expect(dataArray.length).assertEqual(0); + appAccountManager.deleteAccount("account_testGetOAuthList_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_12600 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_12600 end===="); + done(); + }); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_12700', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_12700 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.getOAuthList("","authType",(err,dataArray)=>{ + console.debug("====>ActsAccountOAuthToken_12700 getOAuthList err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_12700 getOAuthList dataArray:" + JSON.stringify(dataArray)); + expect(err.code!=0).assertEqual(true); + expect(dataArray.length).assertEqual(0); + done(); + }); + }); + + it('ActsAccountOAuthToken_12800', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_12800 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.getOAuthList(" ","authType",(err,dataArray)=>{ + console.debug("====>ActsAccountOAuthToken_12800 getOAuthList err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_12800 getOAuthList dataArray:" + JSON.stringify(dataArray)); + expect(err.code!=0).assertEqual(true); + expect(dataArray.length).assertEqual(0); + done(); + }); + }); + + it('ActsAccountOAuthToken_12900', 0, async function (done) { + var limitName = ''; + for(var i = 0; i < LENGTHLIMIT + 1; i++){ + limitName += 't'; + } + console.debug("====>ActsAccountOAuthToken_12900 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.getOAuthList(limitName,"authType",(err,dataArray)=>{ + console.debug("====>ActsAccountOAuthToken_12900 getOAuthList err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_12900 getOAuthList dataArray:" + JSON.stringify(dataArray)); + expect(err.code!=0).assertEqual(true); + expect(dataArray.length).assertEqual(0); + done(); + }); + }); + + it('ActsAccountOAuthToken_13000', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_13000 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.getOAuthList("no_add_account","authType",(err,dataArray)=>{ + console.debug("====>ActsAccountOAuthToken_13000 getOAuthList err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_13000 getOAuthList dataArray:" + JSON.stringify(dataArray)); + expect(err.code!=0).assertEqual(true); + expect(dataArray.length).assertEqual(0); + done(); + }); + }); + + it('ActsAccountOAuthToken_13100', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_13100 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccount("account_tokenTest_name",(err,)=>{ + console.debug("====>ActsAccountOAuthToken_13100 addAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.setOAuthToken("account_tokenTest_name","authType","test_token",(err)=>{ + console.debug("====>ActsAccountOAuthToken_13100 setOAuthToken err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getOAuthToken("account_tokenTest_name",OWNERSELF,"authType",(err,data)=>{ + console.debug("====>ActsAccountOAuthToken_13100 getOAuthToken err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_13100 getOAuthToken stateBack:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual("test_token"); + appAccountManager.checkOAuthTokenVisibility("account_tokenTest_name","authType","test_bundleName",(err,stateBack)=>{ + console.debug("====>ActsAccountOAuthToken_13100 checkOAuthTokenVisibility err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_13100 checkOAuthTokenVisibility stateBack:" + stateBack); + expect(err.code).assertEqual(0); + expect(stateBack).assertEqual(false); + appAccountManager.getOAuthList("account_tokenTest_name","authType",(err,dataArray)=>{ + console.debug("====>ActsAccountOAuthToken_13100 getOAuthList err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_13100 getOAuthList dataArray:" + JSON.stringify(dataArray)); + expect(err.code).assertEqual(0); + expect(dataArray.length).assertEqual(0); + appAccountManager.setOAuthTokenVisibility("account_tokenTest_name","authType","test_bundleName",true,(err)=>{ + console.debug("====>ActsAccountOAuthToken_13100 setOAuthTokenVisibility err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.checkOAuthTokenVisibility("account_tokenTest_name","authType","test_bundleName",(err,stateBack)=>{ + console.debug("====>ActsAccountOAuthToken_13100 checkOAuthTokenVisibility err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_13100 checkOAuthTokenVisibility stateBack:" + stateBack); + expect(err.code).assertEqual(0); + expect(stateBack).assertEqual(true); + appAccountManager.getOAuthList("account_tokenTest_name","authType",(err,dataArray)=>{ + console.debug("====>ActsAccountOAuthToken_13100 getOAuthList err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_13100 getOAuthList dataArray:" + JSON.stringify(dataArray)); + expect(err.code).assertEqual(0); + expect(dataArray.length).assertEqual(1); + expect(dataArray[0]).assertEqual("test_bundleName"); + appAccountManager.deleteAccount("account_tokenTest_name",(err)=>{ + console.debug("====>ActsAccountOAuthToken_13100 deleteAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountOAuthToken_13100 end===="); + done(); + }); + }); + }); + }); + }); + }); + }); + }); + }); + }); + + it('ActsAccountOAuthToken_13200', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_13200 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.getAuthenticatorInfo("com.example.actsaccountOauthtoken",(err,dataInfo)=>{ + console.debug("====>ActsAccountOAuthToken_13200 getAuthenticatorInfo err:" + JSON.stringify(err)); + console.debug("====>ActsAccountOAuthToken_13200 getAuthenticatorInfo dataInfo:" + JSON.stringify(dataInfo)); + expect(err.code).assertEqual(0); + expect(isNaN(dataInfo.iconId)).assertFalse(); + expect(isNaN(dataInfo.labelId)).assertFalse(); + done(); + }); + }); + + it('ActsAccountOAuthToken_13300', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_13300 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.authenticate("authenticate_test_account","com.example.actsaccountOauthtoken","authType",{},{ + onResult: (resultCode, resultData)=>{ + console.debug("====>ActsAccountOAuthToken_13300 authenticate resultCode:" + JSON.stringify(resultCode)); + console.debug("====>ActsAccountOAuthToken_13300 authenticate resultData:" + JSON.stringify(resultData)); + expect(resultCode.code).assertEqual(0); + expect(resultData.name).assertEqual("authenticate_test_account"); + expect(resultData.authType).assertEqual("authType"); + expect(resultData.token).assertEqual("serviceApp/authenticate/Token"); + done(); + }, + onRequestRedirected: null + }); + done(); + }); + + it('ActsAccountOAuthToken_13400', 0, async function (done) { + console.debug("====>ActsAccountOAuthToken_13400 start===="); + var appAccountManager = account.createAppAccountManager(); + appAccountManager.addAccountImplicitly("com.example.actsaccountOauthtoken","authType",{},{ + onResult: (resultCode, resultData) =>{ + console.debug("====>ActsAccountOAuthToken_13400 authenticate resultCode:" + JSON.stringify(resultCode)); + console.debug("====>ActsAccountOAuthToken_13400 authenticate resultData:" + JSON.stringify(resultData)); + expect(resultCode.code).assertEqual(0); + expect(resultData.name).assertEqual("authenticate_test_account"); + expect(resultData.authType).assertEqual("authType"); + expect(resultData.token).assertEqual("serviceApp/authenticate/Token"); + done(); + }, + onRequestRedirected: (request) =>{ + console.debug("====>ActsAccountOAuthToken_13400 onRequestRedirected request:" + JSON.stringify(request)); + let abilityStartSetting = { + want:request + } + featureAbility.startAbility(abilityStartSetting, (err, result)=>{ + console.debug("====>ActsAccountOAuthToken_13400 onRequestRedirected err:" + JSON.stringify(err)); + }); + done(); + } + }); + done(); + }); + }) +} diff --git a/account/appaccount/actsaccounttest/src/main/js/test/OnOff.js b/account/appaccount/actsaccounttest/src/main/js/test/OnOff.js new file mode 100755 index 0000000000000000000000000000000000000000..bb8c9ae787de5288161b523c5be186fcd41da27f --- /dev/null +++ b/account/appaccount/actsaccounttest/src/main/js/test/OnOff.js @@ -0,0 +1,918 @@ +/* + * 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 '@ohos/hypium' + +const TIMEOUT = 5000; +export default function ActsAccountChangeOnOff() { + describe('ActsAccountChangeOnOff', async function () { + + function sleep(delay) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, delay) + }).then(() => { + console.info(`sleep #{time} over ...`) + }) + } + 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: + {}, + }, + }, + ); + await sleep(TIMEOUT); + done(); + }); + + /* + * @tc.number : ActsAccountChangeOnOff_0100 + * @tc.name : Subscribe/unsubscribe to the change event of application + * @tc.desc : Received the account information change to the authorized account of the subscription to change + * the additional information + */ + 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_extra"); + console.debug("====>enableAppAccess ActsAccountChangeOnOff_0100 start"); + await appAccountManager.enableAppAccess("changeonoff_extra", "com.example.actsaccountsceneonoff"); + function unSubscriberCallback(err){ + console.debug("====>unsubscribe 0100 err:" + JSON.stringify(err)); + } + function deleteAccountCallback(err){ + console.debug("====>delete account 0100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + done(); + } + function disCallback(err){ + console.debug("====>delete account 0100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount("changeonoff_extra", deleteAccountCallback); + } + function subscriberCallback(err, data){ + console.debug("====>subscriberCallback 0100 data:" + JSON.stringify(data)); + expect(data.event).assertEqual("account_on_change_extra"); + expect(data.data).assertEqual("SUCCESS"); + commonevent.unsubscribe(subscriber, unSubscriberCallback); + appAccountManager.disableAppAccess("changeonoff_extra", "com.example.actsaccountsceneonoff", disCallback); + } + function publishCallback(err){ + console.debug("====>publish call back err:" + JSON.stringify(err)); + setTimeout(async function (){ + console.debug("====>setAccountExtraInfo start===="); + try{ + await appAccountManager.setAccountExtraInfo("changeonoff_extra", "change_extra"); + } + catch(err){ + console.error("====>setAccountExtraInfo fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>setAccountExtraInfo finish===="); + }, 500) + } + var commonEventSubscribeInfo = { + events: ["account_on_change_extra"] + } + 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); + }); + + /* + * @tc.number : ActsAccountChangeOnOff_0200 + * @tc.name : Subscribe/unsubscribe to the change event of application + * @tc.desc : Received the account information change to the authorized account of the subscription to change + * the associatal data + */ + it('ActsAccountChangeOnOff_0200', 0, async function (done) { + console.debug("====>ActsAccountChangeOnOff_0200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add account ActsAccountChangeOnOff_0200 start"); + await appAccountManager.addAccount("onoff_associatedata"); + console.debug("====>enableAppAccess ActsAccountChangeOnOff_0200 start"); + await appAccountManager.enableAppAccess("onoff_associatedata", "com.example.actsaccountsceneonoff"); + function unSubscriberCallback(err){ + console.debug("====>unsubscribe 0200 err:" + JSON.stringify(err)); + } + function deleteAccountCallback(err){ + console.debug("====>delete account 0200 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + done(); + } + function subscriberCallback(err, data){ + console.debug("====>subscriberCallback 0200 data:" + JSON.stringify(data)); + expect(data.event).assertEqual("account_on_change_associatedata"); + expect(data.data).assertEqual("SUCCESS"); + commonevent.unsubscribe(subscriber, unSubscriberCallback); + appAccountManager.deleteAccount("onoff_associatedata", deleteAccountCallback); + } + function publishCallback(err){ + console.debug("====>publish call back err:" + JSON.stringify(err)); + setTimeout(async function (){ + console.debug("====>setAssociatedData start===="); + try{ + await appAccountManager.setAssociatedData("onoff_associatedata", "change_key", "change_value"); + } + catch(err){ + console.error("====>setAssociatedData fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>setAssociatedData finish===="); + }, 500) + } + var commonEventSubscribeInfo = { + events: ["account_on_change_associatedata"] + } + var subscriber + commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){ + subscriber = data; + commonevent.subscribe(subscriber, subscriberCallback); + console.debug("====>subscribe ActsAccountChangeOnOff_0200 finish====") + }); + + var commonEventPublishData = { + code: 2 + } + setTimeout(function (){ + console.debug("====>publish event account_on_change 0200===="); + commonevent.publish("account_on_change", commonEventPublishData, publishCallback); + }, 1000); + }); + + /* + * @tc.number : ActsAccountChangeOnOff_0300 + * @tc.name : Subscribe/unsubscribe to the change event of application + * @tc.desc : Received the account information change to the authorized account of the subscription to change + * the credential + */ + it('ActsAccountChangeOnOff_0300', 0, async function (done) { + console.debug("====>ActsAccountChangeOnOff_0300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add account ActsAccountChangeOnOff_0300 start"); + await appAccountManager.addAccount("onoff_credential"); + console.debug("====>enableAppAccess ActsAccountChangeOnOff_0300 start"); + await appAccountManager.enableAppAccess("onoff_credential", "com.example.actsaccountsceneonoff"); + function unSubscriberCallback(err){ + console.debug("====>unsubscribe 0300 err:" + JSON.stringify(err)); + } + function deleteAccountCallback(err){ + console.debug("====>delete account 0300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + done(); + } + function subscriberCallback(err, data){ + console.debug("====>subscriberCallback 0300 data:" + JSON.stringify(data)); + expect(data.event).assertEqual("account_on_change_credential"); + expect(data.data).assertEqual("SUCCESS"); + commonevent.unsubscribe(subscriber, unSubscriberCallback); + appAccountManager.deleteAccount("onoff_credential", deleteAccountCallback); + } + function publishCallback(err){ + console.debug("====>publish call back err:" + JSON.stringify(err)); + setTimeout(async function (){ + console.debug("====>setAccountCredential start===="); + try{ + await appAccountManager.setAccountCredential("onoff_credential", "credentialType", "credential"); + } + catch(err){ + console.error("====>setAccountCredential fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>setAccountCredential finish===="); + }, 500) + } + var commonEventSubscribeInfo = { + events: ["account_on_change_credential"] + } + var subscriber + commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){ + subscriber = data; + commonevent.subscribe(subscriber, subscriberCallback); + console.debug("====>subscribe ActsAccountChangeOnOff_0300 finish====") + }); + + var commonEventPublishData = { + code: 3 + } + setTimeout(function (){ + console.debug("====>publish event account_on_change 0300===="); + commonevent.publish("account_on_change", commonEventPublishData, publishCallback); + }, 1000); + }); + + /* + * @tc.number : ActsAccountChangeOnOff_0400 + * @tc.name : Subscribe/unsubscribe to the change event of application + * @tc.desc : Received the account information change to the authorized account of the subscription to delete + * authorized account + */ + it('ActsAccountChangeOnOff_0400', 0, async function (done) { + console.debug("====>ActsAccountChangeOnOff_0400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add first account ActsAccountChangeOnOff_0400 start"); + await appAccountManager.addAccount("onoff_deleteFir"); + console.debug("====>add second account ActsAccountChangeOnOff_0400 start"); + await appAccountManager.addAccount("onoff_deleteSec"); + console.debug("====>enableAppAccess first ActsAccountChangeOnOff_0400 start"); + await appAccountManager.enableAppAccess("onoff_deleteFir", "com.example.actsaccountsceneonoff"); + console.debug("====>enableAppAccess second ActsAccountChangeOnOff_0400 start"); + await appAccountManager.enableAppAccess("onoff_deleteSec", "com.example.actsaccountsceneonoff"); + function unSubscriberCallback(err){ + console.debug("====>unsubscribe 0400 err:" + JSON.stringify(err)); + } + function deleteAccountCallback(err){ + console.debug("====>delete account 0400 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + done(); + } + function subscriberCallback(err, data){ + console.debug("====>subscriberCallback 0400 data:" + JSON.stringify(data)); + expect(data.event).assertEqual("account_on_delete_another"); + expect(data.data).assertEqual("SUCCESS"); + commonevent.unsubscribe(subscriber, unSubscriberCallback); + appAccountManager.deleteAccount("onoff_deleteFir", deleteAccountCallback); + } + function publishCallback(err){ + console.debug("====>publish call back err:" + JSON.stringify(err)); + setTimeout(async function (){ + console.debug("====>deleteAccount start===="); + try{ + await appAccountManager.deleteAccount("onoff_deleteSec"); + } + catch(err){ + console.error("====>deleteAccount fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>deleteAccount finish===="); + }, 500) + } + var commonEventSubscribeInfo = { + events: ["account_on_delete_another"] + } + var subscriber + commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){ + subscriber = data; + commonevent.subscribe(subscriber, subscriberCallback); + console.debug("====>subscribe ActsAccountChangeOnOff_0400 finish====") + }); + + var commonEventPublishData = { + code: 4 + } + setTimeout(function (){ + console.debug("====>publish event account_on_change 0400===="); + commonevent.publish("account_on_change", commonEventPublishData, publishCallback); + }, 1000); + }); + + /* + * @tc.number : ActsAccountChangeOnOff_0500 + * @tc.name : Subscribe/unsubscribe to the change event of application + * @tc.desc : Received the account information change to the authorized account of the subscription to delete + * the only authorized account + */ + it('ActsAccountChangeOnOff_0500', 0, async function (done) { + console.debug("====>ActsAccountChangeOnOff_0500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add account ActsAccountChangeOnOff_0500 start"); + await appAccountManager.addAccount("onoff_delete"); + console.debug("====>enableAppAccess ActsAccountChangeOnOff_0500 start"); + await appAccountManager.enableAppAccess("onoff_delete", "com.example.actsaccountsceneonoff"); + function unSubscriberCallback(err){ + console.debug("====>unsubscribe 0500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + done(); + } + function subscriberCallback(err, data){ + console.debug("====>subscriberCallback 0500 data:" + JSON.stringify(data)); + expect(data.event).assertEqual("account_on_change_delete"); + expect(data.data).assertEqual("SUCCESS"); + commonevent.unsubscribe(subscriber, unSubscriberCallback); + } + function publishCallback(err){ + console.debug("====>publish call back err:" + JSON.stringify(err)); + setTimeout(async function (){ + console.debug("====>deleteAccount start===="); + try{ + await appAccountManager.deleteAccount("onoff_delete"); + } + catch(err){ + console.error("====>deleteAccount fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>deleteAccount finish===="); + }, 500) + } + var commonEventSubscribeInfo = { + events: ["account_on_change_delete"] + } + var subscriber + commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){ + subscriber = data; + commonevent.subscribe(subscriber, subscriberCallback); + console.debug("====>subscribe ActsAccountChangeOnOff_0500 finish====") + }); + + var commonEventPublishData = { + code: 5 + } + setTimeout(function (){ + console.debug("====>publish event account_on_change 0500===="); + commonevent.publish("account_on_change", commonEventPublishData, publishCallback); + }, 1000); + }); + + /* + * @tc.number : ActsAccountChangeOnOff_0600 + * @tc.name : Subscribe/unsubscribe to the change event of application + * @tc.desc : Received the account information change to the authorized account of the subscription to cancel + * authorized account + */ + it('ActsAccountChangeOnOff_0600', 0, async function (done) { + console.debug("====>ActsAccountChangeOnOff_0600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add first account ActsAccountChangeOnOff_0600 start"); + await appAccountManager.addAccount("onoff_enableFir"); + console.debug("====>add second account ActsAccountChangeOnOff_0600 start"); + await appAccountManager.addAccount("onoff_enableSec"); + console.debug("====>enableAppAccess first ActsAccountChangeOnOff_0600 start"); + await appAccountManager.enableAppAccess("onoff_enableFir", "com.example.actsaccountsceneonoff"); + console.debug("====>enableAppAccess second ActsAccountChangeOnOff_0600 start"); + await appAccountManager.enableAppAccess("onoff_enableSec", "com.example.actsaccountsceneonoff"); + function unSubscriberCallback(err){ + console.debug("====>unsubscribe 0600 err:" + JSON.stringify(err)); + } + function deleteAccountCallback(err){ + console.debug("====>delete first account 0600 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount("onoff_enableSec", (err)=>{ + console.debug("====>delete second account 0600 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + done(); + }); + } + function subscriberCallback(err, data){ + console.debug("====>subscriberCallback 0600 data:" + JSON.stringify(data)); + expect(data.event).assertEqual("account_on_disable_another"); + expect(data.data).assertEqual("SUCCESS"); + commonevent.unsubscribe(subscriber, unSubscriberCallback); + appAccountManager.deleteAccount("onoff_enableFir", deleteAccountCallback); + } + function publishCallback(err){ + console.debug("====>publish call back err:" + JSON.stringify(err)); + setTimeout(async function (){ + console.debug("====>disableAppAccess start===="); + try{ + await appAccountManager.disableAppAccess("onoff_enableSec", "com.example.actsaccountsceneonoff"); + } + catch(err){ + console.error("====>disableAppAccess fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>disableAppAccess finish===="); + }, 500) + } + var commonEventSubscribeInfo = { + events: ["account_on_disable_another"] + } + var subscriber + commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){ + subscriber = data; + commonevent.subscribe(subscriber, subscriberCallback); + console.debug("====>subscribe ActsAccountChangeOnOff_0600 finish====") + }); + + var commonEventPublishData = { + code: 6 + } + setTimeout(function (){ + console.debug("====>publish event account_on_change 0600===="); + commonevent.publish("account_on_change", commonEventPublishData, publishCallback); + }, 1000); + }); + + /* + * @tc.number : ActsAccountChangeOnOff_0700 + * @tc.name : Subscribe/unsubscribe to the change event of application + * @tc.desc : Received the account information change to the authorized account of the subscription to cancel + * the only authorized account + */ + it('ActsAccountChangeOnOff_0700', 0, async function (done) { + console.debug("====>ActsAccountChangeOnOff_0700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add account ActsAccountChangeOnOff_0700 start"); + await appAccountManager.addAccount("onoff_disable"); + console.debug("====>enableAppAccess ActsAccountChangeOnOff_0700 start"); + await appAccountManager.enableAppAccess("onoff_disable", "com.example.actsaccountsceneonoff"); + function unSubscriberCallback(err){ + console.debug("====>unsubscribe 0700 err:" + JSON.stringify(err)); + } + function deleteAccountCallback(err){ + console.debug("====>delete account 0700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + done(); + } + function subscriberCallback(err, data){ + console.debug("====>subscriberCallback 0700 data:" + JSON.stringify(data)); + expect(data.event).assertEqual("account_on_change_disable"); + expect(data.data).assertEqual("SUCCESS"); + commonevent.unsubscribe(subscriber, unSubscriberCallback); + appAccountManager.deleteAccount("onoff_disable", deleteAccountCallback); + } + function publishCallback(err){ + console.debug("====>publish call back err:" + JSON.stringify(err)); + setTimeout(async function (){ + console.debug("====>disableAppAccess start===="); + try{ + await appAccountManager.disableAppAccess("onoff_disable", "com.example.actsaccountsceneonoff"); + } + catch(err){ + console.error("====>disableAppAccess fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>disableAppAccess finish===="); + }, 500) + } + var commonEventSubscribeInfo = { + events: ["account_on_change_disable"] + } + var subscriber + commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){ + subscriber = data; + commonevent.subscribe(subscriber, subscriberCallback); + console.debug("====>subscribe ActsAccountChangeOnOff_0700 finish====") + }); + + var commonEventPublishData = { + code: 7 + } + setTimeout(function (){ + console.debug("====>publish event account_on_change 0700===="); + commonevent.publish("account_on_change", commonEventPublishData, publishCallback); + }, 1000); + }); + + /* + * @tc.number : ActsAccountChangeOnOff_0800 + * @tc.name : Subscribe/unsubscribe to the change event of application + * @tc.desc : Receive account information after the app subscribes to itself and changes additional information + */ + it('ActsAccountChangeOnOff_0800', 0, async function (done) { + console.debug("====>ActsAccountChangeOnOff_0800 start===="); + let dataMap = new Map(); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add account ActsAccountChangeOnOff_0800 start"); + await appAccountManager.addAccount("onoff_self"); + console.debug("====>on ActsAccountChangeOnOff_0800 start"); + function changeOnCallback(data){ + console.debug("====>receive change 0800 data:" + JSON.stringify(data)); + console.debug("====>data.length:" + data.length); + for (let i = 0, len = data.length; i < len; i++) { + dataMap.set(data[i].name, data[i].owner) + } + expect(dataMap.has("onoff_self")).assertTrue(); + if (dataMap.has("onoff_self")) { + let data = dataMap.get("onoff_self"); + console.debug("====>the account owner is: " + data); + expect(data).assertEqual("com.example.actsaccounttest"); + } + appAccountManager.off('change', function (){ + console.debug("====>off ActsAccountChangeOnOff_0800 finish===="); + appAccountManager.deleteAccount("onoff_self", (err)=>{ + console.debug("====>delete account ActsAccountChangeOnOff_0800 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountChangeOnOff_0800 end===="); + done(); + }); + }); + } + try{ + appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnCallback); + } + catch(err){ + console.error("====>on ActsAccountChangeOnOff_0800 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>setAccountExtraInfo start===="); + try{ + await appAccountManager.setAccountExtraInfo("onoff_self", "change_extra"); + } + catch(err){ + console.error("====>setAccountExtraInfo fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + }); + + /* + * @tc.number : ActsAccountChangeOnOff_0900 + * @tc.name : Subscribe/unsubscribe to the change event of application + * @tc.desc : Receiving account information after adding two accounts to the app, subscribing to itself, + * and changing one of the associatal data + */ + it('ActsAccountChangeOnOff_0900', 0, async function (done) { + console.debug("====>ActsAccountChangeOnOff_0900 start===="); + let dataMap = new Map(); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add first account ActsAccountChangeOnOff_0900 start"); + await appAccountManager.addAccount("onoff_self_first"); + console.debug("====>add second account ActsAccountChangeOnOff_0900 start"); + await appAccountManager.addAccount("onoff_self_second"); + console.debug("====>on ActsAccountChangeOnOff_0900 start"); + function changeOnCallback(data){ + console.debug("====>receive change 0900 data:" + JSON.stringify(data)); + console.debug("====>data.length:" + data.length); + for (let i = 0, len = data.length; i < len; i++) { + dataMap.set(data[i].name, data[i].owner) + } + expect(dataMap.has("onoff_self_first")).assertTrue(); + if (dataMap.has("onoff_self_first")) { + let data = dataMap.get("onoff_self_first"); + console.debug("====>the account owner is: " + data); + expect(data).assertEqual("com.example.actsaccounttest"); + } + expect(dataMap.has("onoff_self_second")).assertTrue(); + if (dataMap.has("onoff_self_second")) { + let data = dataMap.get("onoff_self_second"); + console.debug("====>the account owner is: " + data); + expect(data).assertEqual("com.example.actsaccounttest"); + } + appAccountManager.off('change', function (){ + console.debug("====>off ActsAccountChangeOnOff_0900 finish===="); + appAccountManager.deleteAccount("onoff_self_first", (err)=>{ + console.debug("====>delete first account 0900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.deleteAccount("onoff_self_second", (err)=>{ + console.debug("====>delete second account 0900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountChangeOnOff_0900 end===="); + done(); + }); + }); + }); + } + try{ + appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnCallback); + } + catch(err){ + console.error("====>on ActsAccountChangeOnOff_0900 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>setAssociatedData start===="); + try{ + await appAccountManager.setAssociatedData("onoff_self_second", "change_key", "change_value"); + } + catch(err){ + console.error("====>setAssociatedData fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + }); + + /* + * @tc.number : ActsAccountChangeOnOff_1000 + * @tc.name : Subscribe/unsubscribe to the change event of application + * @tc.desc : Repeat subscription account information changes, the subscription behavior is independent + */ + it('ActsAccountChangeOnOff_1000', 0, async function (done) { + console.debug("====>ActsAccountChangeOnOff_1000 start===="); + let dataMapFir = new Map(); + let dataMapSec = new Map(); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add account ActsAccountChangeOnOff_1000 start"); + await appAccountManager.addAccount("onoff_twice"); + console.debug("====>on ActsAccountChangeOnOff_1000 start"); + var twiceSign = 0; + function changeOnFirstCallback(data){ + console.debug("====>first receive change 1000 data:" + JSON.stringify(data)); + console.debug("====>data.length:" + data.length); + for (let i = 0, len = data.length; i < len; i++) { + dataMapFir.set(data[i].name, data[i].owner) + } + expect(dataMapFir.has("onoff_twice")).assertTrue(); + if (dataMapFir.has("onoff_twice")) { + let data = dataMapFir.get("onoff_twice"); + console.debug("====>the account owner is: " + data); + expect(data).assertEqual("com.example.actsaccounttest"); + } + twiceSign = twiceSign + 1; + } + function changeOnSecondCallback(data){ + console.debug("====>second receive change 1000 data:" + JSON.stringify(data)); + console.debug("====>data.length:" + data.length); + for (let i = 0, len = data.length; i < len; i++) { + dataMapSec.set(data[i].name, data[i].owner) + } + expect(dataMapSec.has("onoff_twice")).assertTrue(); + if (dataMapSec.has("onoff_twice")) { + let data = dataMapSec.get("onoff_twice"); + console.debug("====>the account owner is: " + data); + expect(data).assertEqual("com.example.actsaccounttest"); + } + twiceSign = twiceSign + 1; + setTimeout(async function (){ + console.debug("====>off start===="); + appAccountManager.off('change', function (){ + console.debug("====>off ActsAccountChangeOnOff_1000 finish===="); + appAccountManager.deleteAccount("onoff_twice", (err)=>{ + console.debug("====>delete account ActsAccountChangeOnOff_1000 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + expect(twiceSign).assertEqual(2); + console.debug("====>ActsAccountChangeOnOff_1000 end===="); + done(); + }); + }); + }, 1000) + } + try{ + appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnFirstCallback); + appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnSecondCallback); + } + catch(err){ + console.error("====>on ActsAccountChangeOnOff_1000 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>setAccountExtraInfo start===="); + try{ + await appAccountManager.setAccountExtraInfo("onoff_twice", "change_extra"); + } + catch(err){ + console.error("====>setAccountExtraInfo fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + }); + + /* + * @tc.number : ActsAccountChangeOnOff_1100 + * @tc.name : Subscribe/unsubscribe to the change event of application + * @tc.desc : Subscription account information changes, where the bundleName in the parameter owners is + * duplicated + */ + it('ActsAccountChangeOnOff_1100', 0, async function (done) { + console.debug("====>ActsAccountChangeOnOff_1100 start===="); + let dataMap = new Map(); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add account ActsAccountChangeOnOff_1100 start"); + await appAccountManager.addAccount("onoff_same"); + console.debug("====>on ActsAccountChangeOnOff_1100 start"); + var sameSign = 0; + function onCallBack(data){ + console.debug("====>receive change 1100 data:" + JSON.stringify(data)); + sameSign = sameSign + 1; + console.debug("====>data.length:" + data.length); + for (let i = 0, len = data.length; i < len; i++) { + dataMap.set(data[i].name, data[i].owner) + } + expect(dataMap.has("onoff_same")).assertTrue(); + if (dataMap.has("onoff_same")) { + let data = dataMap.get("onoff_same"); + console.debug("====>the account owner is: " + data); + expect(data).assertEqual("com.example.actsaccounttest"); + } + } + try{ + appAccountManager.on('change', ["com.example.actsaccounttest", "com.example.actsaccounttest"], onCallBack); + } + catch(err){ + console.error("====>on ActsAccountChangeOnOff_1100 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>setAccountExtraInfo start===="); + try{ + await appAccountManager.setAccountExtraInfo("onoff_same", "change_extra"); + } + catch(err){ + console.error("====>setAccountExtraInfo fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + setTimeout(async function (){ + console.debug("====>off 1100 start===="); + expect(sameSign).assertEqual(1); + appAccountManager.off('change', function (){ + console.debug("====>off ActsAccountChangeOnOff_1100 finish===="); + appAccountManager.deleteAccount("onoff_same", (err)=>{ + console.debug("====>delete account ActsAccountChangeOnOff_1100 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountChangeOnOff_1100 end===="); + done(); + }); + }); + }, 1000) + }); + + /* + * @tc.number : ActsAccountChangeOnOff_1200 + * @tc.name : Subscribe/unsubscribe to the change event of application + * @tc.desc : Repeatedly cancel the subscription after the subscription account information is changed + */ + it('ActsAccountChangeOnOff_1200', 0, async function (done) { + console.debug("====>ActsAccountChangeOnOff_1200 start===="); + let dataMap = new Map(); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add account ActsAccountChangeOnOff_1200 start"); + await appAccountManager.addAccount("onoff_repeatoff"); + console.debug("====>on ActsAccountChangeOnOff_1200 start"); + function changeOnCallback(data){ + console.debug("====>receive change 1200 data:" + JSON.stringify(data)); + console.debug("====>data.length:" + data.length); + for (let i = 0, len = data.length; i < len; i++) { + dataMap.set(data[i].name, data[i].owner) + } + expect(dataMap.has("onoff_repeatoff")).assertTrue(); + if (dataMap.has("onoff_repeatoff")) { + let data = dataMap.get("onoff_repeatoff"); + console.debug("====>the account owner is: " + data); + expect(data).assertEqual("com.example.actsaccounttest"); + } + appAccountManager.off('change', function (){ + console.debug("====>first off ActsAccountChangeOnOff_1200 finish===="); + appAccountManager.off('change', function (){ + console.debug("====>second off ActsAccountChangeOnOff_1200 finish===="); + setTimeout(async function (){ + console.debug("====>delete account 1200 start===="); + appAccountManager.deleteAccount("onoff_repeatoff", (err)=>{ + console.debug("====>delete account ActsAccountChangeOnOff_1200 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountChangeOnOff_1200 end===="); + done(); + }); + }, 1000) + }); + }); + } + try{ + appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnCallback); + } + catch(err){ + console.error("====>on ActsAccountChangeOnOff_1200 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>setAccountExtraInfo start===="); + try{ + await appAccountManager.setAccountExtraInfo("onoff_repeatoff", "change_extra"); + } + catch(err){ + console.error("====>setAccountExtraInfo fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + }); + + /* + * @tc.number : ActsAccountChangeOnOff_1300 + * @tc.name : Subscribe/unsubscribe to the change event of application + * @tc.desc : There is an unauthorized bundleName in the subscription parameter owners array, and the + * subscription fails + */ + it('ActsAccountChangeOnOff_1300', 0, async function (done) { + console.debug("====>ActsAccountChangeOnOff_1300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add account ActsAccountChangeOnOff_1300 start"); + await appAccountManager.addAccount("onoff_same"); + console.debug("====>on ActsAccountChangeOnOff_1300 start"); + function changeOnCallBack(data){ + console.debug("====>receive change 1300 data:" + JSON.stringify(data)); + expect().assertFail(); + done(); + } + var unauthorizedBundle = "com.example.actsaccountsceneonoff"; + try{ + appAccountManager.on('change', ["com.example.actsaccounttest", unauthorizedBundle], changeOnCallBack); + } + catch(err){ + console.error("====>on ActsAccountChangeOnOff_1300 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>setAccountExtraInfo start===="); + try{ + await appAccountManager.setAccountExtraInfo("onoff_same", "change_extra"); + } + catch(err){ + console.error("====>setAccountExtraInfo fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + setTimeout(async function (){ + console.debug("====>delete account 1300 start===="); + appAccountManager.deleteAccount("onoff_same", (err)=>{ + console.debug("====>delete account ActsAccountChangeOnOff_1300 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountChangeOnOff_1300 end===="); + done(); + }); + }, 1000) + }); + + /* + * @tc.number : ActsAccountChangeOnOff_1400 + * @tc.name : Subscribe/unsubscribe to the change event of application + * @tc.desc : There is a bundleName that does not exist in the subscription parameter owners array, and the + * subscription fails + */ + it('ActsAccountChangeOnOff_1400', 0, async function (done) { + console.debug("====>ActsAccountChangeOnOff_1400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat appAccountManager finish"); + console.debug("====>add account ActsAccountChangeOnOff_1400 start"); + await appAccountManager.addAccount("onoff_same"); + console.debug("====>on ActsAccountChangeOnOff_1400 start"); + function changeOnCallBack(data){ + console.debug("====>receive change 1300 data:" + JSON.stringify(data)); + expect().assertFail(); + done(); + } + var nonexistentBundle = "com.example.actsaccountnoneexistent"; + try{ + appAccountManager.on('change', ["com.example.actsaccounttest", nonexistentBundle], changeOnCallBack); + } + catch(err){ + console.error("====>on ActsAccountChangeOnOff_1400 err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>setAccountExtraInfo start===="); + try{ + await appAccountManager.setAccountExtraInfo("onoff_same", "change_extra"); + } + catch(err){ + console.error("====>setAccountExtraInfo fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + setTimeout(async function (){ + console.debug("====>delete account 1400 start===="); + appAccountManager.deleteAccount("onoff_same", (err)=>{ + console.debug("====>delete account ActsAccountChangeOnOff_1400 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsAccountChangeOnOff_1400 end===="); + done(); + }); + }, 1000) + }); + }) +} \ No newline at end of file diff --git a/account/appaccount/actsaccounttest/src/main/resources/base/element/string.json b/account/appaccount/actsaccounttest/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..5a685e30cae1638fb9c5fd966b9ab40b6b80b341 --- /dev/null +++ b/account/appaccount/actsaccounttest/src/main/resources/base/element/string.json @@ -0,0 +1,28 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ActsAccountTest" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" + } + ] +} \ 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/src/main/resources/base/media/icon.png similarity index 100% rename from account/appaccount/actsaccounttest/entry/src/main/js/resources/base/media/icon.png rename to account/appaccount/actsaccounttest/src/main/resources/base/media/icon.png diff --git a/account/appaccount/actsgetallaccounts/BUILD.gn b/account/appaccount/actsgetallaccounts/BUILD.gn old mode 100755 new mode 100644 index 62339ff1eb287e54a50d09c848bca72140f5cbfd..1255d4006237033230e47715cc8cda0141723e16 --- a/account/appaccount/actsgetallaccounts/BUILD.gn +++ b/account/appaccount/actsgetallaccounts/BUILD.gn @@ -14,7 +14,7 @@ import("//test/xts/tools/build/suite.gni") ohos_js_hap_suite("ActsGetAllAccountsTest") { - hap_profile = "./entry/src/main/config.json" + hap_profile = "./src/main/config.json" deps = [ ":hjs_demo_js_assets", ":hjs_demo_resources", @@ -23,9 +23,12 @@ ohos_js_hap_suite("ActsGetAllAccountsTest") { hap_name = "ActsGetAllAccountsTest" } ohos_js_assets("hjs_demo_js_assets") { - source_dir = "./entry/src/main/js/default" + js2abc = true + hap_profile = "./src/main/config.json" + source_dir = "./src/main/js" } + ohos_resources("hjs_demo_resources") { - sources = [ "./entry/src/main/js/resources" ] - hap_profile = "./entry/src/main/config.json" + sources = [ "./src/main/resources" ] + hap_profile = "./src/main/config.json" } diff --git a/account/appaccount/actsgetallaccounts/Test.json b/account/appaccount/actsgetallaccounts/Test.json old mode 100755 new mode 100644 index 78e10a62acb781cb6cd7f6a4a7dff19a3b2be4a4..309f568ea4c540c1a6a0cdf642b61f927ea4fb54 --- a/account/appaccount/actsgetallaccounts/Test.json +++ b/account/appaccount/actsgetallaccounts/Test.json @@ -1,9 +1,10 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "60000", - "package": "com.example.actsgetallaaccounts", + "bundle-name": "com.example.actsgetallaaccounts", + "package-name": "com.example.actsgetallaaccounts", "shell-timeout": "60000" }, "kits": [ 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 deleted file mode 100755 index 6fda792753f2e15f22b529c7b90a82185b2770bf..0000000000000000000000000000000000000000 --- a/account/appaccount/actsgetallaccounts/entry/src/main/js/default/pages/index/index.css +++ /dev/null @@ -1,9 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.title { - font-size: 100px; -} diff --git a/account/appaccount/actsgetallaccounts/entry/src/main/js/default/pages/index/index.hml b/account/appaccount/actsgetallaccounts/entry/src/main/js/default/pages/index/index.hml deleted file mode 100755 index c45422b42d0bf788a1c2c0eb299a981f07ce8613..0000000000000000000000000000000000000000 --- a/account/appaccount/actsgetallaccounts/entry/src/main/js/default/pages/index/index.hml +++ /dev/null @@ -1,5 +0,0 @@ -
- - {{title}} - -
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 deleted file mode 100755 index b50238a04201f2c134fb640b84189e89bd2b75fa..0000000000000000000000000000000000000000 --- a/account/appaccount/actsgetallaccounts/entry/src/main/js/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "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/test/Getallaccounts.test.js b/account/appaccount/actsgetallaccounts/entry/src/main/js/test/Getallaccounts.test.js deleted file mode 100755 index dcf06f897445e6b0d59e9744ed0df31aaf193f77..0000000000000000000000000000000000000000 --- a/account/appaccount/actsgetallaccounts/entry/src/main/js/test/Getallaccounts.test.js +++ /dev/null @@ -1,651 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import account from '@ohos.account.appAccount' -import featureAbility from '@ohos.ability.featureAbility' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' - -const TIMEOUT = 2000; -const LENGTHLIMIT = 1024; -describe('ActsGetAllAccounts', function () { - - /* - * @tc.number : ActsGetAllAccounts_0100 - * @tc.name : getAllAccounts callback - * @tc.desc : This application gets its own application information after adding an account - */ - it('ActsGetAllAccounts_0100', 0, async function (done) { - console.debug("====>ActsGetAllAccounts_0100 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - var selfBundle = "com.example.actsgetallaaccounts"; - appAccountManager.addAccount("Account_this_application_callback", (err)=>{ - console.debug("====>add account 0100 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getAllAccounts(selfBundle, (err, data)=>{ - console.debug("====>getAllAccounts 0100 err:" + JSON.stringify(err)); - console.debug("====>getAllAccounts 0100 data:" + JSON.stringify(data)); - expect(err.code).assertEqual(0); - try{ - expect(data[0].name).assertEqual("Account_this_application_callback"); - expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); - } - catch(err){ - console.error("====>getAllAccounts 0100 fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - appAccountManager.deleteAccount("Account_this_application_callback", (err)=>{ - console.debug("====>delete account 0100 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsGetAllAccounts_0100 end===="); - done(); - }); - }) - }); - }); - - /* - * @tc.number : ActsGetAllAccounts_0200 - * @tc.name : getAllAccounts promise - * @tc.desc : This application gets its own application information after adding an account - */ - it('ActsGetAllAccounts_0200', 0, async function (done) { - console.debug("====>ActsGetAllAccounts_0200 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - console.debug("====>getAllAccounts for clean===="); - var selfBundle = "com.example.actsgetallaaccounts"; - try{ - var acclist = await appAccountManager.getAllAccounts(selfBundle); - } - catch(err){ - console.error("====>getAllAccounts err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>account list length: " + acclist.length); - if(acclist.length > 0){ - for(var i = 0;i < acclist.length; i++){ - await appAccountManager.deleteAccount(acclist[i].name); - } - } - 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===="); - console.debug("====>getAllAccounts for clean===="); - var selfBundle = "com.example.actsgetallaaccounts"; - try{ - var acclist = await appAccountManager.getAllAccounts(selfBundle); - } - catch(err){ - console.error("====>getAllAccounts err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>account list length: " + acclist.length); - if(acclist.length > 0){ - for(var i = 0;i < acclist.length; i++){ - await appAccountManager.deleteAccount(acclist[i].name); - } - } - var data = await appAccountManager.getAllAccounts(selfBundle); - console.debug("====>getAllAccounts 0400 data:" + JSON.stringify(data)); - expect(data.length).assertEqual(0); - console.debug("====>ActsGetAllAccounts_0400 end===="); - done(); - }); - - /* - * @tc.number : ActsGetAllAccounts_0500 - * @tc.name : getAllAccounts callback - * @tc.desc : The parameter owner is an empty string - */ - it('ActsGetAllAccounts_0500', 0, async function (done) { - console.debug("====>ActsGetAllAccounts_0500 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - var emptyBundle = ""; - appAccountManager.getAllAccounts(emptyBundle, (err, data)=>{ - console.debug("====>getAllAccounts 0500 err:" + JSON.stringify(err)); - expect(err.code != 0).assertEqual(true); - console.debug("====>ActsGetAllAccounts_0500 end===="); - done(); - }) - }); - - /* - * @tc.number : ActsGetAllAccounts_0600 - * @tc.name : getAllAccounts promise - * @tc.desc : The parameter owner is an empty string - */ - it('ActsGetAllAccounts_0600', 0, async function (done) { - console.debug("====>ActsGetAllAccounts_0600 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - var emptyBundle = ""; - try{ - var data = await appAccountManager.getAllAccounts(emptyBundle); - } - catch(err){ - console.debug("====>getAllAccounts 0600 err:" + JSON.stringify(err)); - expect(err.code != 0).assertEqual(true); - console.debug("====>ActsGetAllAccounts_0600 end===="); - done(); - } - }); - - /* - * @tc.number : ActsGetAllAccounts_0700 - * @tc.name : getAllAccounts callback - * @tc.desc : The parameter owner is a string that exceeds the length limit - */ - it('ActsGetAllAccounts_0700', 0, async function (done) { - console.debug("====>ActsGetAllAccounts_0700 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - var limitBundle = ''; - for (var i = 0; i < LENGTHLIMIT + 1; i++) { - limitBundle += 't'; - } - appAccountManager.getAllAccounts(limitBundle, (err, data)=>{ - console.debug("====>getAllAccounts 0700 err:" + JSON.stringify(err)); - expect(err.code != 0).assertEqual(true); - console.debug("====>ActsGetAllAccounts_0700 end===="); - done(); - }) - }); - - /* - * @tc.number : ActsGetAllAccounts_0800 - * @tc.name : getAllAccounts promise - * @tc.desc : The parameter owner is a string that exceeds the length limit - */ - it('ActsGetAllAccounts_0800', 0, async function (done) { - console.debug("====>ActsGetAllAccounts_0800 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - var limitBundle = ''; - for (var i = 0; i < LENGTHLIMIT + 1; i++) { - limitBundle += 'n'; - } - try{ - var data = await appAccountManager.getAllAccounts(limitBundle); - } - catch(err){ - console.debug("====>getAllAccounts 0800 err:" + JSON.stringify(err)); - expect(err.code != 0).assertEqual(true); - console.debug("====>ActsGetAllAccounts_0800 end===="); - done(); - } - }); - - /* - * @tc.number : ActsGetAllAccounts_0900 - * @tc.name : getAllAccounts callback - * @tc.desc : This application adds an account, and after other applications authorize an account to this - * application, this application obtains the information of its own application - */ - it('ActsGetAllAccounts_0900', 0, async function (done) { - console.debug("====>ActsGetAllAccounts_0900 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - var selfBundle = "com.example.actsgetallaaccounts"; - console.debug("====>add account 0900 start===="); - await appAccountManager.addAccount("Account_application_callback"); - console.debug("====>startAbility 0900 start===="); - await featureAbility.startAbility( - { - want: - { - deviceId: "", - bundleName: "com.example.actsscenegetallaccounts", - abilityName: "com.example.actsscenegetallaccounts.MainAbility", - action: "action1", - parameters: - {}, - }, - }, - ); - function getAllCallback(err, data){ - console.debug("====>getAllAccounts 0900 err:" + JSON.stringify(err)); - console.debug("====>getAllAccounts 0900 data:" + JSON.stringify(data)); - expect(err.code).assertEqual(0); - expect(data[0].name).assertEqual("Account_application_callback"); - expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); - appAccountManager.deleteAccount("Account_application_callback", (err)=>{ - console.debug("====>delete account 0900 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsGetAllAccounts_0900 end===="); - done(); - }); - } - setTimeout(async function(){ - console.debug("====>getAllAccounts 0900 start===="); - appAccountManager.getAllAccounts(selfBundle, getAllCallback); - }, TIMEOUT); - }); - - /* - * @tc.number : ActsGetAllAccounts_1000 - * @tc.name : getAllAccounts promise - * @tc.desc : This application adds an account, and after other applications authorize an account to this - * application, this application obtains the information of its own application - */ - it('ActsGetAllAccounts_1000', 0, async function (done) { - console.debug("====>ActsGetAllAccounts_1000 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - var selfBundle = "com.example.actsgetallaaccounts"; - console.debug("====>add account 1000 start===="); - await appAccountManager.addAccount("Account_application_promise"); - console.debug("====>startAbility 1000 start===="); - await featureAbility.startAbility( - { - want: - { - deviceId: "", - bundleName: "com.example.actsscenegetallaccounts", - abilityName: "com.example.actsscenegetallaccounts.MainAbility", - action: "action1", - parameters: - {}, - }, - }, - ); - setTimeout(async function(){ - console.debug("====>getAllAccounts 1000 start===="); - try{ - var data = await appAccountManager.getAllAccounts(selfBundle); - } - catch(err){ - console.error("====>getAllAccounts 1000 fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>getAllAccounts 1000 data:" + JSON.stringify(data)); - try{ - expect(data[0].name).assertEqual("Account_application_promise"); - expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); - } - catch(err){ - console.error("====>check data 1000 fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>delete account 1000 start===="); - await appAccountManager.deleteAccount("Account_application_promise"); - console.debug("====>ActsGetAllAccounts_1000 end===="); - done(); - }, TIMEOUT); - }); - - /* - * @tc.number : ActsGetAllAccounts_1100 - * @tc.name : getAllAccounts callback - * @tc.desc : This application adds an account, and after other applications authorize an account to this - * application, this application obtains the information of its own application - */ - it('ActsGetAllAccounts_1100', 0, async function (done) { - console.debug("====>ActsGetAllAccounts_0900 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - var specifiedBundle = "com.example.actsscenegetallaccounts"; - console.debug("====>startAbility 1100 start===="); - await featureAbility.startAbility( - { - want: - { - deviceId: "", - bundleName: "com.example.actsscenegetallaccounts", - abilityName: "com.example.actsscenegetallaccounts.MainAbility", - action: "action1", - parameters: - {}, - }, - }, - ); - function getAllCallback(err, data){ - console.debug("====>getAllAccounts 1100 err:" + JSON.stringify(err)); - console.debug("====>getAllAccounts 1100 data:" + JSON.stringify(data)); - expect(err.code).assertEqual(0); - expect(data[0].name).assertEqual("account_name_scene_single"); - expect(data[0].owner).assertEqual("com.example.actsscenegetallaccounts"); - console.debug("====>ActsGetAllAccounts_1100 end===="); - done(); - } - setTimeout(async function(){ - console.debug("====>getAllAccounts 1100 start===="); - appAccountManager.getAllAccounts(specifiedBundle, getAllCallback); - }, TIMEOUT); - }); - - /* - * @tc.number : ActsGetAllAccounts_1200 - * @tc.name : getAllAccounts promise - * @tc.desc : This application adds an account, and after other applications authorize an account to this - * application, this application obtains the information of its own application - */ - it('ActsGetAllAccounts_1200', 0, async function (done) { - console.debug("====>ActsGetAllAccounts_1200 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - var specifiedBundle = "com.example.actsscenegetallaccounts"; - console.debug("====>startAbility 1200 start===="); - await featureAbility.startAbility( - { - want: - { - deviceId: "", - bundleName: "com.example.actsscenegetallaccounts", - abilityName: "com.example.actsscenegetallaccounts.MainAbility", - action: "action1", - parameters: - {}, - }, - }, - ); - setTimeout(async function(){ - console.debug("====>getAllAccounts 1200 start===="); - try{ - var data = await appAccountManager.getAllAccounts(specifiedBundle); - } - catch(err){ - console.error("====>getAllAccounts 1200 fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>getAllAccounts 1200 data:" + JSON.stringify(data)); - expect(data[0].name).assertEqual("account_name_scene_single"); - expect(data[0].owner).assertEqual("com.example.actsscenegetallaccounts"); - console.debug("====>ActsGetAllAccounts_1200 end===="); - done(); - }, TIMEOUT); - }); - - /* - * @tc.number : ActsGetAllAccounts_1300 - * @tc.name : getAllAccounts callback - * @tc.desc : The parameter owner is a bundlename that does not exist - */ - it('ActsGetAllAccounts_1300', 0, async function (done) { - console.debug("====>ActsGetAllAccounts_1300 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - var nonexistentBundle = "com.example.actsgetallaccountsnonexistent"; - appAccountManager.getAllAccounts(nonexistentBundle, (err, data)=>{ - console.debug("====>getAllAccounts 1300 err:" + JSON.stringify(err)); - expect(err.code != 0).assertEqual(true); - console.debug("====>ActsGetAllAccounts_1300 end===="); - done(); - }) - }); - - /* - * @tc.number : ActsGetAllAccounts_1400 - * @tc.name : getAllAccounts promise - * @tc.desc : The parameter owner is a bundlename that does not exist - */ - it('ActsGetAllAccounts_1400', 0, async function (done) { - console.debug("====>ActsGetAllAccounts_1400 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - var nonexistentBundle = "com.example.actsgetallaccountsnonexistent"; - try{ - var data = await appAccountManager.getAllAccounts(nonexistentBundle); - } - catch(err){ - console.debug("====>getAllAccounts 1400 err:" + JSON.stringify(err)); - expect(err.code != 0).assertEqual(true); - console.debug("====>ActsGetAllAccounts_1400 end===="); - done(); - } - }); - - /* - * @tc.number : ActsGetAllAccounts_1500 - * @tc.name : getAllAccounts callback - * @tc.desc : Get account information after adding and deleting account - */ - it('ActsGetAllAccounts_1500', 0, async function (done) { - console.debug("====>ActsGetAllAccounts_1500 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - var selfBundle = "com.example.actsgetallaaccounts"; - appAccountManager.addAccount("account_callback_delete", (err)=>{ - console.debug("====>add account 1500 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getAllAccounts(selfBundle, (err, data)=>{ - console.debug("====>getAllAccounts 1500 err:" + JSON.stringify(err)); - console.debug("====>getAllAccounts 1500 data:" + JSON.stringify(data)); - expect(err.code).assertEqual(0); - expect(data[0].name).assertEqual("account_callback_delete"); - expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); - appAccountManager.deleteAccount("account_callback_delete", (err)=>{ - console.debug("====>delete account 1500 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getAllAccounts(selfBundle, (err, data)=>{ - console.debug("====>getAllAccounts 1500 err:" + JSON.stringify(err)); - console.debug("====>getAllAccounts 1500 data:" + JSON.stringify(data)); - expect(err.code).assertEqual(0); - expect(data.length).assertEqual(0); - console.debug("====>ActsGetAllAccounts_1500 end===="); - done(); - }) - }); - }) - }); - }); - - /* - * @tc.number : ActsGetAllAccounts_1600 - * @tc.name : getAllAccounts promise - * @tc.desc : Get account information after adding and deleting account - */ - it('ActsGetAllAccounts_1600', 0, async function (done) { - console.debug("====>ActsGetAllAccounts_1600 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - console.debug("====>getAllAccounts for clean===="); - var selfBundle = "com.example.actsgetallaaccounts"; - try{ - var acclist = await appAccountManager.getAllAccounts(selfBundle); - } - catch(err){ - console.error("====>getAllAccounts err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>account list length: " + acclist.length); - if(acclist.length > 0){ - for(var i = 0;i < acclist.length; i++){ - await appAccountManager.deleteAccount(acclist[i].name); - } - } - console.debug("====>add account 1600 start===="); - await appAccountManager.addAccount("account_promise_delete"); - console.debug("====>first getAllAccounts 1600 start===="); - try{ - var data = await appAccountManager.getAllAccounts(selfBundle); - } - catch(err){ - console.error("====>getAllAccounts 1600 fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - expect(data[0].name).assertEqual("account_promise_delete"); - expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); - console.debug("====>delete account 1600 start===="); - await appAccountManager.deleteAccount("account_promise_delete"); - console.debug("====>second getAllAccounts 1600 start===="); - try{ - var dataDelete = await appAccountManager.getAllAccounts(selfBundle); - } - catch(err){ - console.error("====>second getAllAccounts 1600 fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - expect(dataDelete.length).assertEqual(0); - console.debug("====>ActsGetAllAccounts_1600 end===="); - done(); - }); - - /* - * @tc.number : ActsGetAllAccounts_1700 - * @tc.name : getAllAccounts callback - * @tc.desc : Get account information after adding an account with additional information and deleting an - * account - */ - it('ActsGetAllAccounts_1700', 0, async function (done) { - console.debug("====>ActsGetAllAccounts_1700 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - var selfBundle = "com.example.actsgetallaaccounts"; - appAccountManager.addAccount("account_callback_additional", "account_extrainfo", (err)=>{ - console.debug("====>add account 1700 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getAllAccounts(selfBundle, (err, data)=>{ - console.debug("====>getAllAccounts 1700 err:" + JSON.stringify(err)); - console.debug("====>getAllAccounts 1700 data:" + JSON.stringify(data)); - expect(err.code).assertEqual(0); - expect(data[0].name).assertEqual("account_callback_additional"); - expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); - appAccountManager.deleteAccount("account_callback_additional", (err)=>{ - console.debug("====>delete account 1700 err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - appAccountManager.getAllAccounts(selfBundle, (err, data)=>{ - console.debug("====>getAllAccounts 1700 err:" + JSON.stringify(err)); - console.debug("====>getAllAccounts 1700 data:" + JSON.stringify(data)); - expect(err.code).assertEqual(0); - expect(data.length).assertEqual(0); - console.debug("====>ActsGetAllAccounts_1700 end===="); - done(); - }) - }); - }) - }); - }); - - /* - * @tc.number : ActsGetAllAccounts_1800 - * @tc.name : getAllAccounts promise - * @tc.desc : Get account information after adding an account with additional information and deleting an - * account - */ - it('ActsGetAllAccounts_1800', 0, async function (done) { - console.debug("====>ActsGetAllAccounts_1800 start===="); - var appAccountManager = account.createAppAccountManager(); - console.debug("====>creat finish===="); - console.debug("====>getAllAccounts for clean===="); - var selfBundle = "com.example.actsgetallaaccounts"; - try{ - var acclist = await appAccountManager.getAllAccounts(selfBundle); - } - catch(err){ - console.error("====>getAllAccounts err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>account list length: " + acclist.length); - if(acclist.length > 0){ - for(var i = 0;i < acclist.length; i++){ - await appAccountManager.deleteAccount(acclist[i].name); - } - } - console.debug("====>add account 1800 start===="); - await appAccountManager.addAccount("account_promise_additional", "account_extrainfo"); - console.debug("====>first getAllAccounts 1800 start===="); - try{ - var data = await appAccountManager.getAllAccounts(selfBundle); - } - catch(err){ - console.error("====>getAllAccounts 1800 fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>first getAllAccounts 1800 data:" + JSON.stringify(data)); - expect(data[0].name).assertEqual("account_promise_additional"); - expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); - console.debug("====>delete account 1800 start===="); - await appAccountManager.deleteAccount("account_promise_additional"); - console.debug("====>second getAllAccounts 1800 start===="); - try{ - var dataDelete = await appAccountManager.getAllAccounts(selfBundle); - } - catch(err){ - console.error("====>second getAllAccounts 1800 fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>second getAllAccounts 1800 data:" + JSON.stringify(data)); - expect(dataDelete.length).assertEqual(0); - console.debug("====>ActsGetAllAccounts_1800 end===="); - done(); - }); -}) \ No newline at end of file diff --git a/account/appaccount/actsgetallaccounts/entry/src/main/config.json b/account/appaccount/actsgetallaccounts/src/main/config.json old mode 100755 new mode 100644 similarity index 52% rename from account/appaccount/actsgetallaccounts/entry/src/main/config.json rename to account/appaccount/actsgetallaccounts/src/main/config.json index 16393adc2a7e3f560ce122a121bcd71d45aa1e2d..96bc2a2bb660c048e17515080ba1c2cb6fc372c5 --- a/account/appaccount/actsgetallaccounts/entry/src/main/config.json +++ b/account/appaccount/actsgetallaccounts/src/main/config.json @@ -15,7 +15,9 @@ "deviceConfig": {}, "module": { "package": "com.example.actsgetallaaccounts", - "name": ".MyApplication", + "name": ".entry", + "mainAbility": ".MainAbility", + "srcPath":"", "deviceType": [ "phone" ], @@ -59,25 +61,42 @@ ], "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" + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "formsEnabled": false, + "name": ".MainAbility", + "srcLanguage": "js", + "srcPath": "MainAbility", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "label": "$string:MainAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "js", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" } - ], + ], "js": [ { "pages": [ @@ -88,7 +107,21 @@ "designWidth": 720, "autoDesignWidth": false } + }, + { + "pages": [ + "pages/index/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } } - ] + ], + "testRunner": { + "name": "OpenHarmonyTestRunner", + "srcPath": "TestRunner" + } } } \ No newline at end of file diff --git a/account/appaccount/actsgetallaccounts/entry/src/main/js/default/app.js b/account/appaccount/actsgetallaccounts/src/main/js/MainAbility/app.js similarity index 100% rename from account/appaccount/actsgetallaccounts/entry/src/main/js/default/app.js rename to account/appaccount/actsgetallaccounts/src/main/js/MainAbility/app.js diff --git a/account/appaccount/actsgetallaccounts/entry/src/main/js/default/i18n/en-US.json b/account/appaccount/actsgetallaccounts/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from account/appaccount/actsgetallaccounts/entry/src/main/js/default/i18n/en-US.json rename to account/appaccount/actsgetallaccounts/src/main/js/MainAbility/i18n/en-US.json diff --git a/account/appaccount/actsgetallaccounts/entry/src/main/js/default/i18n/zh-CN.json b/account/appaccount/actsgetallaccounts/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from account/appaccount/actsgetallaccounts/entry/src/main/js/default/i18n/zh-CN.json rename to account/appaccount/actsgetallaccounts/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/account/appaccount/actsgetallaccounts/src/main/js/MainAbility/pages/index/index.css b/account/appaccount/actsgetallaccounts/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..2334ecfa2c147f276998e82e2c35f62800cfb031 --- /dev/null +++ b/account/appaccount/actsgetallaccounts/src/main/js/MainAbility/pages/index/index.css @@ -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. + */ + +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/account/appaccount/actsgetallaccounts/src/main/js/MainAbility/pages/index/index.hml b/account/appaccount/actsgetallaccounts/src/main/js/MainAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..58fdc144440ca578003fa3982fb8d0029cc2cdc7 --- /dev/null +++ b/account/appaccount/actsgetallaccounts/src/main/js/MainAbility/pages/index/index.hml @@ -0,0 +1,19 @@ + +
+ + {{title}} + +
diff --git a/account/appaccount/actsgetallaccounts/entry/src/main/js/default/pages/index/index.js b/account/appaccount/actsgetallaccounts/src/main/js/MainAbility/pages/index/index.js similarity index 69% rename from account/appaccount/actsgetallaccounts/entry/src/main/js/default/pages/index/index.js rename to account/appaccount/actsgetallaccounts/src/main/js/MainAbility/pages/index/index.js index dd93588f4e962bb765d3719f0861caa798f35f77..0c25c846b99ffeba372e8ad4c25d6d4c10c67498 100755 --- a/account/appaccount/actsgetallaccounts/entry/src/main/js/default/pages/index/index.js +++ b/account/appaccount/actsgetallaccounts/src/main/js/MainAbility/pages/index/index.js @@ -12,8 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {Core, ExpectExtend} from 'deccjsunit/index' - const injectRef = Object.getPrototypeOf(global) || global injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') @@ -26,18 +24,6 @@ export default { }, 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() { }, diff --git a/account/appaccount/actsgetallaccounts/src/main/js/TestAbility/app.js b/account/appaccount/actsgetallaccounts/src/main/js/TestAbility/app.js new file mode 100644 index 0000000000000000000000000000000000000000..cdc31f3dcf031e2f6a7665d9653e53bb649e21c5 --- /dev/null +++ b/account/appaccount/actsgetallaccounts/src/main/js/TestAbility/app.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('TestApplication onCreate') + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info("TestApplication onDestroy"); + } +}; diff --git a/account/appaccount/actsgetallaccounts/src/main/js/TestAbility/i18n/en-US.json b/account/appaccount/actsgetallaccounts/src/main/js/TestAbility/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..3cb24b374b1d919ca8eac0638f361692b603a900 --- /dev/null +++ b/account/appaccount/actsgetallaccounts/src/main/js/TestAbility/i18n/en-US.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } +} \ No newline at end of file diff --git a/account/appaccount/actsgetallaccounts/src/main/js/TestAbility/i18n/zh-CN.json b/account/appaccount/actsgetallaccounts/src/main/js/TestAbility/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..c804e32c0c3103929baca5617cdac70be11fdba1 --- /dev/null +++ b/account/appaccount/actsgetallaccounts/src/main/js/TestAbility/i18n/zh-CN.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } +} \ No newline at end of file diff --git a/account/appaccount/actsgetallaccounts/src/main/js/TestAbility/pages/index/index.css b/account/appaccount/actsgetallaccounts/src/main/js/TestAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..2b45eb97c17e67ef5d63436aad8998113aa95d6d --- /dev/null +++ b/account/appaccount/actsgetallaccounts/src/main/js/TestAbility/pages/index/index.css @@ -0,0 +1,50 @@ +/* + * 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. + */ + +.container { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + left: 0px; + top: 0px; + width: 100%; + height: 100%; +} + +.title { + font-size: 60px; + text-align: center; + width: 100%; + height: 40%; + margin: 10px; +} +.btn { + width: 50%; + height: 100px; + font-size: 40px; +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} \ No newline at end of file diff --git a/account/appaccount/actsgetallaccounts/src/main/js/TestAbility/pages/index/index.hml b/account/appaccount/actsgetallaccounts/src/main/js/TestAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..61ea59d936e5a2971f1ea3d179c44a7f3f596c54 --- /dev/null +++ b/account/appaccount/actsgetallaccounts/src/main/js/TestAbility/pages/index/index.hml @@ -0,0 +1,21 @@ + + +
+ + {{ $t('strings.hello') }} {{title}} + + +
diff --git a/account/appaccount/actsgetallaccounts/src/main/js/TestAbility/pages/index/index.js b/account/appaccount/actsgetallaccounts/src/main/js/TestAbility/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..88b083a7f6b979019d6a2c5ad20b19c5fd43286b --- /dev/null +++ b/account/appaccount/actsgetallaccounts/src/main/js/TestAbility/pages/index/index.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + } +} + + + diff --git a/account/appaccount/actsgetallaccounts/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/account/appaccount/actsgetallaccounts/src/main/js/TestRunner/OpenHarmonyTestRunner.js new file mode 100644 index 0000000000000000000000000000000000000000..c5fa8620ca77d381f20b65a903b833e6e3378c97 --- /dev/null +++ b/account/appaccount/actsgetallaccounts/src/main/js/TestRunner/OpenHarmonyTestRunner.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package', '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + + export default { + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + }, + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + console.info('debug value : '+debug) + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, (err, data) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + data.stdResult); + console.info('executeShellCommand : data : ' + data.exitCode); + }) + } +}; diff --git a/account/appaccount/actsgetallaccounts/src/main/js/test/Getallaccounts.test.js b/account/appaccount/actsgetallaccounts/src/main/js/test/Getallaccounts.test.js new file mode 100755 index 0000000000000000000000000000000000000000..73ab6372b8fccf4eebf2a206de6ad8c7532487de --- /dev/null +++ b/account/appaccount/actsgetallaccounts/src/main/js/test/Getallaccounts.test.js @@ -0,0 +1,653 @@ +/* + * 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 '@ohos/hypium' + +const TIMEOUT = 2000; +const LENGTHLIMIT = 1024; +export default function ActsGetAllAccounts() { + 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===="); + console.debug("====>getAllAccounts for clean===="); + var selfBundle = "com.example.actsgetallaaccounts"; + try{ + var acclist = await appAccountManager.getAllAccounts(selfBundle); + } + catch(err){ + console.error("====>getAllAccounts err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>account list length: " + acclist.length); + if(acclist.length > 0){ + for(var i = 0;i < acclist.length; i++){ + await appAccountManager.deleteAccount(acclist[i].name); + } + } + 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===="); + console.debug("====>getAllAccounts for clean===="); + var selfBundle = "com.example.actsgetallaaccounts"; + try{ + var acclist = await appAccountManager.getAllAccounts(selfBundle); + } + catch(err){ + console.error("====>getAllAccounts err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>account list length: " + acclist.length); + if(acclist.length > 0){ + for(var i = 0;i < acclist.length; i++){ + await appAccountManager.deleteAccount(acclist[i].name); + } + } + var data = await appAccountManager.getAllAccounts(selfBundle); + console.debug("====>getAllAccounts 0400 data:" + JSON.stringify(data)); + expect(data.length).assertEqual(0); + console.debug("====>ActsGetAllAccounts_0400 end===="); + done(); + }); + + /* + * @tc.number : ActsGetAllAccounts_0500 + * @tc.name : getAllAccounts callback + * @tc.desc : The parameter owner is an empty string + */ + it('ActsGetAllAccounts_0500', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_0500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var emptyBundle = ""; + appAccountManager.getAllAccounts(emptyBundle, (err, data)=>{ + console.debug("====>getAllAccounts 0500 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsGetAllAccounts_0500 end===="); + done(); + }) + }); + + /* + * @tc.number : ActsGetAllAccounts_0600 + * @tc.name : getAllAccounts promise + * @tc.desc : The parameter owner is an empty string + */ + it('ActsGetAllAccounts_0600', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_0600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var emptyBundle = ""; + try{ + var data = await appAccountManager.getAllAccounts(emptyBundle); + } + catch(err){ + console.debug("====>getAllAccounts 0600 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsGetAllAccounts_0600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsGetAllAccounts_0700 + * @tc.name : getAllAccounts callback + * @tc.desc : The parameter owner is a string that exceeds the length limit + */ + it('ActsGetAllAccounts_0700', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_0700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var limitBundle = ''; + for (var i = 0; i < LENGTHLIMIT + 1; i++) { + limitBundle += 't'; + } + appAccountManager.getAllAccounts(limitBundle, (err, data)=>{ + console.debug("====>getAllAccounts 0700 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsGetAllAccounts_0700 end===="); + done(); + }) + }); + + /* + * @tc.number : ActsGetAllAccounts_0800 + * @tc.name : getAllAccounts promise + * @tc.desc : The parameter owner is a string that exceeds the length limit + */ + it('ActsGetAllAccounts_0800', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_0800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var limitBundle = ''; + for (var i = 0; i < LENGTHLIMIT + 1; i++) { + limitBundle += 'n'; + } + try{ + var data = await appAccountManager.getAllAccounts(limitBundle); + } + catch(err){ + console.debug("====>getAllAccounts 0800 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsGetAllAccounts_0800 end===="); + done(); + } + }); + + /* + * @tc.number : ActsGetAllAccounts_0900 + * @tc.name : getAllAccounts callback + * @tc.desc : This application adds an account, and after other applications authorize an account to this + * application, this application obtains the information of its own application + */ + it('ActsGetAllAccounts_0900', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_0900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var selfBundle = "com.example.actsgetallaaccounts"; + console.debug("====>add account 0900 start===="); + await appAccountManager.addAccount("Account_application_callback"); + console.debug("====>startAbility 0900 start===="); + await featureAbility.startAbility( + { + want: + { + deviceId: "", + bundleName: "com.example.actsscenegetallaccounts", + abilityName: "com.example.actsscenegetallaccounts.MainAbility", + action: "action1", + parameters: + {}, + }, + }, + ); + function getAllCallback(err, data){ + console.debug("====>getAllAccounts 0900 err:" + JSON.stringify(err)); + console.debug("====>getAllAccounts 0900 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data[0].name).assertEqual("Account_application_callback"); + expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); + appAccountManager.deleteAccount("Account_application_callback", (err)=>{ + console.debug("====>delete account 0900 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsGetAllAccounts_0900 end===="); + done(); + }); + } + setTimeout(async function(){ + console.debug("====>getAllAccounts 0900 start===="); + appAccountManager.getAllAccounts(selfBundle, getAllCallback); + }, TIMEOUT); + }); + + /* + * @tc.number : ActsGetAllAccounts_1000 + * @tc.name : getAllAccounts promise + * @tc.desc : This application adds an account, and after other applications authorize an account to this + * application, this application obtains the information of its own application + */ + it('ActsGetAllAccounts_1000', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_1000 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var selfBundle = "com.example.actsgetallaaccounts"; + console.debug("====>add account 1000 start===="); + await appAccountManager.addAccount("Account_application_promise"); + console.debug("====>startAbility 1000 start===="); + await featureAbility.startAbility( + { + want: + { + deviceId: "", + bundleName: "com.example.actsscenegetallaccounts", + abilityName: "com.example.actsscenegetallaccounts.MainAbility", + action: "action1", + parameters: + {}, + }, + }, + ); + setTimeout(async function(){ + console.debug("====>getAllAccounts 1000 start===="); + try{ + var data = await appAccountManager.getAllAccounts(selfBundle); + } + catch(err){ + console.error("====>getAllAccounts 1000 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAllAccounts 1000 data:" + JSON.stringify(data)); + try{ + expect(data[0].name).assertEqual("Account_application_promise"); + expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); + } + catch(err){ + console.error("====>check data 1000 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>delete account 1000 start===="); + await appAccountManager.deleteAccount("Account_application_promise"); + console.debug("====>ActsGetAllAccounts_1000 end===="); + done(); + }, TIMEOUT); + }); + + /* + * @tc.number : ActsGetAllAccounts_1100 + * @tc.name : getAllAccounts callback + * @tc.desc : This application adds an account, and after other applications authorize an account to this + * application, this application obtains the information of its own application + */ + it('ActsGetAllAccounts_1100', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_0900 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var specifiedBundle = "com.example.actsscenegetallaccounts"; + console.debug("====>startAbility 1100 start===="); + await featureAbility.startAbility( + { + want: + { + deviceId: "", + bundleName: "com.example.actsscenegetallaccounts", + abilityName: "com.example.actsscenegetallaccounts.MainAbility", + action: "action1", + parameters: + {}, + }, + }, + ); + function getAllCallback(err, data){ + console.debug("====>getAllAccounts 1100 err:" + JSON.stringify(err)); + console.debug("====>getAllAccounts 1100 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data[0].name).assertEqual("account_name_scene_single"); + expect(data[0].owner).assertEqual("com.example.actsscenegetallaccounts"); + console.debug("====>ActsGetAllAccounts_1100 end===="); + done(); + } + setTimeout(async function(){ + console.debug("====>getAllAccounts 1100 start===="); + appAccountManager.getAllAccounts(specifiedBundle, getAllCallback); + }, TIMEOUT); + }); + + /* + * @tc.number : ActsGetAllAccounts_1200 + * @tc.name : getAllAccounts promise + * @tc.desc : This application adds an account, and after other applications authorize an account to this + * application, this application obtains the information of its own application + */ + it('ActsGetAllAccounts_1200', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_1200 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var specifiedBundle = "com.example.actsscenegetallaccounts"; + console.debug("====>startAbility 1200 start===="); + await featureAbility.startAbility( + { + want: + { + deviceId: "", + bundleName: "com.example.actsscenegetallaccounts", + abilityName: "com.example.actsscenegetallaccounts.MainAbility", + action: "action1", + parameters: + {}, + }, + }, + ); + setTimeout(async function(){ + console.debug("====>getAllAccounts 1200 start===="); + try{ + var data = await appAccountManager.getAllAccounts(specifiedBundle); + } + catch(err){ + console.error("====>getAllAccounts 1200 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>getAllAccounts 1200 data:" + JSON.stringify(data)); + expect(data[0].name).assertEqual("account_name_scene_single"); + expect(data[0].owner).assertEqual("com.example.actsscenegetallaccounts"); + console.debug("====>ActsGetAllAccounts_1200 end===="); + done(); + }, TIMEOUT); + }); + + /* + * @tc.number : ActsGetAllAccounts_1300 + * @tc.name : getAllAccounts callback + * @tc.desc : The parameter owner is a bundlename that does not exist + */ + it('ActsGetAllAccounts_1300', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_1300 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var nonexistentBundle = "com.example.actsgetallaccountsnonexistent"; + appAccountManager.getAllAccounts(nonexistentBundle, (err, data)=>{ + console.debug("====>getAllAccounts 1300 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsGetAllAccounts_1300 end===="); + done(); + }) + }); + + /* + * @tc.number : ActsGetAllAccounts_1400 + * @tc.name : getAllAccounts promise + * @tc.desc : The parameter owner is a bundlename that does not exist + */ + it('ActsGetAllAccounts_1400', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_1400 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var nonexistentBundle = "com.example.actsgetallaccountsnonexistent"; + try{ + var data = await appAccountManager.getAllAccounts(nonexistentBundle); + } + catch(err){ + console.debug("====>getAllAccounts 1400 err:" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.debug("====>ActsGetAllAccounts_1400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsGetAllAccounts_1500 + * @tc.name : getAllAccounts callback + * @tc.desc : Get account information after adding and deleting account + */ + it('ActsGetAllAccounts_1500', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_1500 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var selfBundle = "com.example.actsgetallaaccounts"; + appAccountManager.addAccount("account_callback_delete", (err)=>{ + console.debug("====>add account 1500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAllAccounts(selfBundle, (err, data)=>{ + console.debug("====>getAllAccounts 1500 err:" + JSON.stringify(err)); + console.debug("====>getAllAccounts 1500 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data[0].name).assertEqual("account_callback_delete"); + expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); + appAccountManager.deleteAccount("account_callback_delete", (err)=>{ + console.debug("====>delete account 1500 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAllAccounts(selfBundle, (err, data)=>{ + console.debug("====>getAllAccounts 1500 err:" + JSON.stringify(err)); + console.debug("====>getAllAccounts 1500 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data.length).assertEqual(0); + console.debug("====>ActsGetAllAccounts_1500 end===="); + done(); + }) + }); + }) + }); + }); + + /* + * @tc.number : ActsGetAllAccounts_1600 + * @tc.name : getAllAccounts promise + * @tc.desc : Get account information after adding and deleting account + */ + it('ActsGetAllAccounts_1600', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_1600 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>getAllAccounts for clean===="); + var selfBundle = "com.example.actsgetallaaccounts"; + try{ + var acclist = await appAccountManager.getAllAccounts(selfBundle); + } + catch(err){ + console.error("====>getAllAccounts err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>account list length: " + acclist.length); + if(acclist.length > 0){ + for(var i = 0;i < acclist.length; i++){ + await appAccountManager.deleteAccount(acclist[i].name); + } + } + console.debug("====>add account 1600 start===="); + await appAccountManager.addAccount("account_promise_delete"); + console.debug("====>first getAllAccounts 1600 start===="); + try{ + var data = await appAccountManager.getAllAccounts(selfBundle); + } + catch(err){ + console.error("====>getAllAccounts 1600 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + expect(data[0].name).assertEqual("account_promise_delete"); + expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); + console.debug("====>delete account 1600 start===="); + await appAccountManager.deleteAccount("account_promise_delete"); + console.debug("====>second getAllAccounts 1600 start===="); + try{ + var dataDelete = await appAccountManager.getAllAccounts(selfBundle); + } + catch(err){ + console.error("====>second getAllAccounts 1600 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + expect(dataDelete.length).assertEqual(0); + console.debug("====>ActsGetAllAccounts_1600 end===="); + done(); + }); + + /* + * @tc.number : ActsGetAllAccounts_1700 + * @tc.name : getAllAccounts callback + * @tc.desc : Get account information after adding an account with additional information and deleting an + * account + */ + it('ActsGetAllAccounts_1700', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_1700 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + var selfBundle = "com.example.actsgetallaaccounts"; + appAccountManager.addAccount("account_callback_additional", "account_extrainfo", (err)=>{ + console.debug("====>add account 1700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAllAccounts(selfBundle, (err, data)=>{ + console.debug("====>getAllAccounts 1700 err:" + JSON.stringify(err)); + console.debug("====>getAllAccounts 1700 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data[0].name).assertEqual("account_callback_additional"); + expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); + appAccountManager.deleteAccount("account_callback_additional", (err)=>{ + console.debug("====>delete account 1700 err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + appAccountManager.getAllAccounts(selfBundle, (err, data)=>{ + console.debug("====>getAllAccounts 1700 err:" + JSON.stringify(err)); + console.debug("====>getAllAccounts 1700 data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data.length).assertEqual(0); + console.debug("====>ActsGetAllAccounts_1700 end===="); + done(); + }) + }); + }) + }); + }); + + /* + * @tc.number : ActsGetAllAccounts_1800 + * @tc.name : getAllAccounts promise + * @tc.desc : Get account information after adding an account with additional information and deleting an + * account + */ + it('ActsGetAllAccounts_1800', 0, async function (done) { + console.debug("====>ActsGetAllAccounts_1800 start===="); + var appAccountManager = account.createAppAccountManager(); + console.debug("====>creat finish===="); + console.debug("====>getAllAccounts for clean===="); + var selfBundle = "com.example.actsgetallaaccounts"; + try{ + var acclist = await appAccountManager.getAllAccounts(selfBundle); + } + catch(err){ + console.error("====>getAllAccounts err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>account list length: " + acclist.length); + if(acclist.length > 0){ + for(var i = 0;i < acclist.length; i++){ + await appAccountManager.deleteAccount(acclist[i].name); + } + } + console.debug("====>add account 1800 start===="); + await appAccountManager.addAccount("account_promise_additional", "account_extrainfo"); + console.debug("====>first getAllAccounts 1800 start===="); + try{ + var data = await appAccountManager.getAllAccounts(selfBundle); + } + catch(err){ + console.error("====>getAllAccounts 1800 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>first getAllAccounts 1800 data:" + JSON.stringify(data)); + expect(data[0].name).assertEqual("account_promise_additional"); + expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts"); + console.debug("====>delete account 1800 start===="); + await appAccountManager.deleteAccount("account_promise_additional"); + console.debug("====>second getAllAccounts 1800 start===="); + try{ + var dataDelete = await appAccountManager.getAllAccounts(selfBundle); + } + catch(err){ + console.error("====>second getAllAccounts 1800 fail err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>second getAllAccounts 1800 data:" + JSON.stringify(data)); + expect(dataDelete.length).assertEqual(0); + console.debug("====>ActsGetAllAccounts_1800 end===="); + done(); + }); + }) +} \ No newline at end of file diff --git a/account/appaccount/actsgetallaccounts/src/main/js/test/List.test.js b/account/appaccount/actsgetallaccounts/src/main/js/test/List.test.js new file mode 100755 index 0000000000000000000000000000000000000000..70b68168e70f2b5e0484dba90d8608c4ba165c02 --- /dev/null +++ b/account/appaccount/actsgetallaccounts/src/main/js/test/List.test.js @@ -0,0 +1,19 @@ +/* + * 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 ActsGetAllAccounts from './Getallaccounts.test.js' + +export default function testsuite() { + ActsGetAllAccounts() +} \ No newline at end of file diff --git a/account/appaccount/actsgetallaccounts/src/main/resources/base/element/string.json b/account/appaccount/actsgetallaccounts/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..6e2452f1a3264fe13ac62b7949e4776513ba5e9a --- /dev/null +++ b/account/appaccount/actsgetallaccounts/src/main/resources/base/element/string.json @@ -0,0 +1,28 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ActsGetAllAccounts" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" + } + ] +} \ 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/src/main/resources/base/media/icon.png similarity index 100% rename from account/appaccount/actsgetallaccounts/entry/src/main/js/resources/base/media/icon.png rename to account/appaccount/actsgetallaccounts/src/main/resources/base/media/icon.png diff --git a/account/appaccount/actssetchecksyncenable/BUILD.gn b/account/appaccount/actssetchecksyncenable/BUILD.gn old mode 100755 new mode 100644 index a00df5595637b292659e9fe383860445599b4da5..2685a3a9d222842748502cafdd622189569e05ec --- a/account/appaccount/actssetchecksyncenable/BUILD.gn +++ b/account/appaccount/actssetchecksyncenable/BUILD.gn @@ -14,7 +14,7 @@ import("//test/xts/tools/build/suite.gni") ohos_js_hap_suite("ActsSetCheckSyncEnableTest") { - hap_profile = "./entry/src/main/config.json" + hap_profile = "./src/main/config.json" deps = [ ":hjs_demo_js_assets", ":hjs_demo_resources", @@ -23,9 +23,12 @@ ohos_js_hap_suite("ActsSetCheckSyncEnableTest") { hap_name = "ActsSetCheckSyncEnableTest" } ohos_js_assets("hjs_demo_js_assets") { - source_dir = "./entry/src/main/js/default" + js2abc = true + hap_profile = "./src/main/config.json" + source_dir = "./src/main/js" } + ohos_resources("hjs_demo_resources") { - sources = [ "./entry/src/main/js/resources" ] - hap_profile = "./entry/src/main/config.json" + sources = [ "./src/main/resources" ] + hap_profile = "./src/main/config.json" } diff --git a/account/appaccount/actssetchecksyncenable/Test.json b/account/appaccount/actssetchecksyncenable/Test.json old mode 100755 new mode 100644 index e9fe505081a3443b2fbe142916b486b14103dc45..5fe66209b7091cc06ef75b4386ffc8a206d8662c --- a/account/appaccount/actssetchecksyncenable/Test.json +++ b/account/appaccount/actssetchecksyncenable/Test.json @@ -1,9 +1,10 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "60000", - "package": "com.example.actssetchecksyncenable", + "bundle-name": "com.example.actssetchecksyncenable", + "package-name": "com.example.actssetchecksyncenable", "shell-timeout": "60000" }, "kits": [ 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 deleted file mode 100755 index 6fda792753f2e15f22b529c7b90a82185b2770bf..0000000000000000000000000000000000000000 --- a/account/appaccount/actssetchecksyncenable/entry/src/main/js/default/pages/index/index.css +++ /dev/null @@ -1,9 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.title { - font-size: 100px; -} diff --git a/account/appaccount/actssetchecksyncenable/entry/src/main/js/default/pages/index/index.hml b/account/appaccount/actssetchecksyncenable/entry/src/main/js/default/pages/index/index.hml deleted file mode 100755 index c45422b42d0bf788a1c2c0eb299a981f07ce8613..0000000000000000000000000000000000000000 --- a/account/appaccount/actssetchecksyncenable/entry/src/main/js/default/pages/index/index.hml +++ /dev/null @@ -1,5 +0,0 @@ -
- - {{title}} - -
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 deleted file mode 100755 index 52efec27776c61fecdfd7bd9c8f9bbb6e7e5e234..0000000000000000000000000000000000000000 --- a/account/appaccount/actssetchecksyncenable/entry/src/main/js/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "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/test/Syncenable.test.js b/account/appaccount/actssetchecksyncenable/entry/src/main/js/test/Syncenable.test.js deleted file mode 100755 index 28717aeb0cb307c9c2af367ab88eb55c2913fb36..0000000000000000000000000000000000000000 --- a/account/appaccount/actssetchecksyncenable/entry/src/main/js/test/Syncenable.test.js +++ /dev/null @@ -1,573 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import abilityAccessCtrl from '@ohos.abilityAccessCtrl' -import account from '@ohos.account.appAccount' -import bundle from '@ohos.bundle' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' - -const TIMEOUT = 2000; -const PERMISSION_USER_SET = 1; -const PERMISSION_USER_NAME = "ohos.permission.DISTRIBUTED_DATASYNC"; -var tokenID = undefined; -describe('ActsSetCheckSyncEnable', function () { - beforeAll(async function (done) { - console.debug("====>beforeAll start===="); - var appInfo = await bundle.getApplicationInfo('com.example.actssetchecksyncenable', 0, 100); - tokenID = appInfo.accessTokenId; - console.debug("accessTokenId" + appInfo.accessTokenId + " bundleName:" + appInfo.bundleName); - var atManager = abilityAccessCtrl.createAtManager(); - var result = await atManager.grantUserGrantedPermission(tokenID, PERMISSION_USER_NAME, PERMISSION_USER_SET); - console.debug("tokenId" + tokenID + " result:" + result); - sleep(TIMEOUT); - console.debug("====>beforeAll end===="); - done(); - }) - - function sleep(delay) { - var start = (new Date()).getTime(); - while((new Date()).getTime() - start < delay) { - continue; - } - } - - /* - * @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/config.json b/account/appaccount/actssetchecksyncenable/src/main/config.json old mode 100755 new mode 100644 similarity index 54% rename from account/appaccount/actssetchecksyncenable/entry/src/main/config.json rename to account/appaccount/actssetchecksyncenable/src/main/config.json index ff2b444eb672b7aeb4b9ec215db5a5eb13e56882..b0165606aae85d240e2eafa83def35d3283edd77 --- a/account/appaccount/actssetchecksyncenable/entry/src/main/config.json +++ b/account/appaccount/actssetchecksyncenable/src/main/config.json @@ -15,7 +15,9 @@ "deviceConfig": {}, "module": { "package": "com.example.actssetchecksyncenable", - "name": ".MyApplication", + "name": ".entry", + "mainAbility": ".MainAbility", + "srcPath":"", "deviceType": [ "phone" ], @@ -63,25 +65,42 @@ ], "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" + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "formsEnabled": false, + "name": ".MainAbility", + "srcLanguage": "js", + "srcPath": "MainAbility", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "label": "$string:MainAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "js", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" } - ], + ], "js": [ { "pages": [ @@ -92,7 +111,21 @@ "designWidth": 720, "autoDesignWidth": false } + }, + { + "pages": [ + "pages/index/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } } - ] + ], + "testRunner": { + "name": "OpenHarmonyTestRunner", + "srcPath": "TestRunner" + } } } \ No newline at end of file diff --git a/account/appaccount/actssetchecksyncenable/entry/src/main/js/default/app.js b/account/appaccount/actssetchecksyncenable/src/main/js/MainAbility/app.js similarity index 100% rename from account/appaccount/actssetchecksyncenable/entry/src/main/js/default/app.js rename to account/appaccount/actssetchecksyncenable/src/main/js/MainAbility/app.js diff --git a/account/appaccount/actssetchecksyncenable/entry/src/main/js/default/i18n/en-US.json b/account/appaccount/actssetchecksyncenable/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from account/appaccount/actssetchecksyncenable/entry/src/main/js/default/i18n/en-US.json rename to account/appaccount/actssetchecksyncenable/src/main/js/MainAbility/i18n/en-US.json diff --git a/account/appaccount/actssetchecksyncenable/entry/src/main/js/default/i18n/zh-CN.json b/account/appaccount/actssetchecksyncenable/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from account/appaccount/actssetchecksyncenable/entry/src/main/js/default/i18n/zh-CN.json rename to account/appaccount/actssetchecksyncenable/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/account/appaccount/actssetchecksyncenable/src/main/js/MainAbility/pages/index/index.css b/account/appaccount/actssetchecksyncenable/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..2334ecfa2c147f276998e82e2c35f62800cfb031 --- /dev/null +++ b/account/appaccount/actssetchecksyncenable/src/main/js/MainAbility/pages/index/index.css @@ -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. + */ + +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/account/appaccount/actssetchecksyncenable/src/main/js/MainAbility/pages/index/index.hml b/account/appaccount/actssetchecksyncenable/src/main/js/MainAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..58fdc144440ca578003fa3982fb8d0029cc2cdc7 --- /dev/null +++ b/account/appaccount/actssetchecksyncenable/src/main/js/MainAbility/pages/index/index.hml @@ -0,0 +1,19 @@ + +
+ + {{title}} + +
diff --git a/account/appaccount/actssetchecksyncenable/entry/src/main/js/default/pages/index/index.js b/account/appaccount/actssetchecksyncenable/src/main/js/MainAbility/pages/index/index.js old mode 100755 new mode 100644 similarity index 71% rename from account/appaccount/actssetchecksyncenable/entry/src/main/js/default/pages/index/index.js rename to account/appaccount/actssetchecksyncenable/src/main/js/MainAbility/pages/index/index.js index 833a9bb4aa89f758ccc76f5f665d1783f1d68127..8406ae5685de38b44c93e31e36d151e91bd45765 --- a/account/appaccount/actssetchecksyncenable/entry/src/main/js/default/pages/index/index.js +++ b/account/appaccount/actssetchecksyncenable/src/main/js/MainAbility/pages/index/index.js @@ -12,7 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {Core, ExpectExtend} from 'deccjsunit/index' const injectRef = Object.getPrototypeOf(global) || global injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') @@ -26,18 +25,7 @@ export default { }, 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() { }, diff --git a/account/appaccount/actssetchecksyncenable/src/main/js/TestAbility/app.js b/account/appaccount/actssetchecksyncenable/src/main/js/TestAbility/app.js new file mode 100644 index 0000000000000000000000000000000000000000..cdc31f3dcf031e2f6a7665d9653e53bb649e21c5 --- /dev/null +++ b/account/appaccount/actssetchecksyncenable/src/main/js/TestAbility/app.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('TestApplication onCreate') + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info("TestApplication onDestroy"); + } +}; diff --git a/account/appaccount/actssetchecksyncenable/src/main/js/TestAbility/i18n/en-US.json b/account/appaccount/actssetchecksyncenable/src/main/js/TestAbility/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..3cb24b374b1d919ca8eac0638f361692b603a900 --- /dev/null +++ b/account/appaccount/actssetchecksyncenable/src/main/js/TestAbility/i18n/en-US.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } +} \ No newline at end of file diff --git a/account/appaccount/actssetchecksyncenable/src/main/js/TestAbility/i18n/zh-CN.json b/account/appaccount/actssetchecksyncenable/src/main/js/TestAbility/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..c804e32c0c3103929baca5617cdac70be11fdba1 --- /dev/null +++ b/account/appaccount/actssetchecksyncenable/src/main/js/TestAbility/i18n/zh-CN.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } +} \ No newline at end of file diff --git a/account/appaccount/actssetchecksyncenable/src/main/js/TestAbility/pages/index/index.css b/account/appaccount/actssetchecksyncenable/src/main/js/TestAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..2b45eb97c17e67ef5d63436aad8998113aa95d6d --- /dev/null +++ b/account/appaccount/actssetchecksyncenable/src/main/js/TestAbility/pages/index/index.css @@ -0,0 +1,50 @@ +/* + * 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. + */ + +.container { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + left: 0px; + top: 0px; + width: 100%; + height: 100%; +} + +.title { + font-size: 60px; + text-align: center; + width: 100%; + height: 40%; + margin: 10px; +} +.btn { + width: 50%; + height: 100px; + font-size: 40px; +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} \ No newline at end of file diff --git a/account/appaccount/actssetchecksyncenable/src/main/js/TestAbility/pages/index/index.hml b/account/appaccount/actssetchecksyncenable/src/main/js/TestAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..61ea59d936e5a2971f1ea3d179c44a7f3f596c54 --- /dev/null +++ b/account/appaccount/actssetchecksyncenable/src/main/js/TestAbility/pages/index/index.hml @@ -0,0 +1,21 @@ + + +
+ + {{ $t('strings.hello') }} {{title}} + + +
diff --git a/account/appaccount/actssetchecksyncenable/src/main/js/TestAbility/pages/index/index.js b/account/appaccount/actssetchecksyncenable/src/main/js/TestAbility/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..88b083a7f6b979019d6a2c5ad20b19c5fd43286b --- /dev/null +++ b/account/appaccount/actssetchecksyncenable/src/main/js/TestAbility/pages/index/index.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + } +} + + + diff --git a/account/appaccount/actssetchecksyncenable/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/account/appaccount/actssetchecksyncenable/src/main/js/TestRunner/OpenHarmonyTestRunner.js new file mode 100644 index 0000000000000000000000000000000000000000..c5fa8620ca77d381f20b65a903b833e6e3378c97 --- /dev/null +++ b/account/appaccount/actssetchecksyncenable/src/main/js/TestRunner/OpenHarmonyTestRunner.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package', '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + + export default { + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + }, + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + console.info('debug value : '+debug) + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, (err, data) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + data.stdResult); + console.info('executeShellCommand : data : ' + data.exitCode); + }) + } +}; diff --git a/account/appaccount/actssetchecksyncenable/src/main/js/test/List.test.js b/account/appaccount/actssetchecksyncenable/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..05e8923741b667e1950d05116da8a76e39f61f05 --- /dev/null +++ b/account/appaccount/actssetchecksyncenable/src/main/js/test/List.test.js @@ -0,0 +1,19 @@ +/* + * 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 ActsSetCheckSyncEnable from './Syncenable.test.js' + +export default function testsuite() { + ActsSetCheckSyncEnable() +} \ No newline at end of file diff --git a/account/appaccount/actssetchecksyncenable/src/main/js/test/Syncenable.test.js b/account/appaccount/actssetchecksyncenable/src/main/js/test/Syncenable.test.js new file mode 100644 index 0000000000000000000000000000000000000000..744c7eed203a6630db12471259bd5ad3b7c508bc --- /dev/null +++ b/account/appaccount/actssetchecksyncenable/src/main/js/test/Syncenable.test.js @@ -0,0 +1,575 @@ +/* + * 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 abilityAccessCtrl from '@ohos.abilityAccessCtrl' +import account from '@ohos.account.appAccount' +import bundle from '@ohos.bundle' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +const TIMEOUT = 2000; +const PERMISSION_USER_SET = 1; +const PERMISSION_USER_NAME = "ohos.permission.DISTRIBUTED_DATASYNC"; +var tokenID = undefined; +export default function ActsSetCheckSyncEnable() { + describe('ActsSetCheckSyncEnable', function () { + beforeAll(async function (done) { + console.debug("====>beforeAll start===="); + var appInfo = await bundle.getApplicationInfo('com.example.actssetchecksyncenable', 0, 100); + tokenID = appInfo.accessTokenId; + console.debug("accessTokenId" + appInfo.accessTokenId + " bundleName:" + appInfo.bundleName); + var atManager = abilityAccessCtrl.createAtManager(); + var result = await atManager.grantUserGrantedPermission(tokenID, PERMISSION_USER_NAME, PERMISSION_USER_SET); + console.debug("tokenId" + tokenID + " result:" + result); + sleep(TIMEOUT); + console.debug("====>beforeAll end===="); + done(); + }) + + function sleep(delay) { + var start = (new Date()).getTime(); + while((new Date()).getTime() - start < delay) { + continue; + } + } + + /* + * @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/src/main/resources/base/element/string.json b/account/appaccount/actssetchecksyncenable/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..89f90a73a8b24448128dffdbcc82cd52cf23b287 --- /dev/null +++ b/account/appaccount/actssetchecksyncenable/src/main/resources/base/element/string.json @@ -0,0 +1,28 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ActsSetCheckSyncEnable" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" + } + ] +} \ 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/src/main/resources/base/media/icon.png similarity index 100% rename from account/appaccount/actssetchecksyncenable/entry/src/main/js/resources/base/media/icon.png rename to account/appaccount/actssetchecksyncenable/src/main/resources/base/media/icon.png diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/BUILD.gn b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/BUILD.gn old mode 100755 new mode 100644 index bd5eb5c50e21fdd29492e042e78090d1cee16ad7..d4715915c84eef6893b37b23e9ebb8d09b9fc024 --- a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/BUILD.gn +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/BUILD.gn @@ -14,7 +14,7 @@ import("//test/xts/tools/build/suite.gni") ohos_js_hap_suite("ActsGetAllAccessibleAccountsTest") { - hap_profile = "./entry/src/main/config.json" + hap_profile = "./src/main/config.json" deps = [ ":hjs_demo_js_assets", ":hjs_demo_resources", @@ -23,9 +23,12 @@ ohos_js_hap_suite("ActsGetAllAccessibleAccountsTest") { hap_name = "ActsGetAllAccessibleAccountsTest" } ohos_js_assets("hjs_demo_js_assets") { - source_dir = "./entry/src/main/js/default" + js2abc = true + hap_profile = "./src/main/config.json" + source_dir = "./src/main/js" } + ohos_resources("hjs_demo_resources") { - sources = [ "./entry/src/main/js/resources" ] - hap_profile = "./entry/src/main/config.json" + sources = [ "./src/main/resources" ] + hap_profile = "./src/main/config.json" } diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/Test.json b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/Test.json old mode 100755 new mode 100644 index 5d4ffe786f92dff3cb890571c3d039541e3dc4df..6fb55ad4a9239f9da111387d444d334aaa30c26e --- a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/Test.json +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/Test.json @@ -1,9 +1,10 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "60000", - "package": "com.example.actsgetallaccessibleaccounts", + "bundle-name": "com.example.actsgetallaccessibleaccounts", + "package-name": "com.example.actsgetallaccessibleaccounts", "shell-timeout": "60000" }, "kits": [ 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 deleted file mode 100755 index 6fda792753f2e15f22b529c7b90a82185b2770bf..0000000000000000000000000000000000000000 --- a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/default/pages/index/index.css +++ /dev/null @@ -1,9 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.title { - font-size: 100px; -} diff --git a/account/appaccount/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 deleted file mode 100755 index c45422b42d0bf788a1c2c0eb299a981f07ce8613..0000000000000000000000000000000000000000 --- a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/default/pages/index/index.hml +++ /dev/null @@ -1,5 +0,0 @@ -
- - {{title}} - -
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 deleted file mode 100755 index 9df422fd35d93a0806182ffcfea798416104bb52..0000000000000000000000000000000000000000 --- a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "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/test/Getallaccessible.test.js b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/test/Getallaccessible.test.js deleted file mode 100755 index 29f0b71f9c3f8c2944891c800bb99c08b660a30a..0000000000000000000000000000000000000000 --- a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/test/Getallaccessible.test.js +++ /dev/null @@ -1,601 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import account from '@ohos.account.appAccount' -import featureAbility from '@ohos.ability.featureAbility' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' - -const TIMEOUT = 2000; -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===="); - var selfBundle = "com.example.actsgetallaccessibleaccounts"; - console.debug("====>getAllAccounts for clean===="); - try{ - var acclist = await appAccountManager.getAllAccounts(selfBundle); - } - catch(err){ - console.error("====>getAllAccounts err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>account list length: " + acclist.length); - if(acclist.length > 0){ - for(var i = 0;i < acclist.length; i++){ - await appAccountManager.deleteAccount(acclist[i].name); - } - } - 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("====>getAllAccounts for clean===="); - var selfBundle = "com.example.actsgetallaccessibleaccounts"; - try{ - var acclist = await appAccountManager.getAllAccounts(selfBundle); - } - catch(err){ - console.error("====>getAllAccounts err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>account list length: " + acclist.length); - if(acclist.length > 0){ - for(var i = 0;i < acclist.length; i++){ - await appAccountManager.deleteAccount(acclist[i].name); - } - } - 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("====>getAllAccounts for clean===="); - var selfBundle = "com.example.actsgetallaccessibleaccounts"; - try{ - var acclist = await appAccountManager.getAllAccounts(selfBundle); - } - catch(err){ - console.error("====>getAllAccounts err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>account list length: " + acclist.length); - if(acclist.length > 0){ - for(var i = 0;i < acclist.length; i++){ - await appAccountManager.deleteAccount(acclist[i].name); - } - } - 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("====>getAllAccounts for clean===="); - var selfBundle = "com.example.actsgetallaccessibleaccounts"; - try{ - var acclist = await appAccountManager.getAllAccounts(selfBundle); - } - catch(err){ - console.error("====>getAllAccounts err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>account list length: " + acclist.length); - if(acclist.length > 0){ - for(var i = 0;i < acclist.length; i++){ - await appAccountManager.deleteAccount(acclist[i].name); - } - } - 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); - }); -}) \ No newline at end of file diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/config.json b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/config.json old mode 100755 new mode 100644 similarity index 53% rename from account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/config.json rename to account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/config.json index 6b3c6d02c8a795f74fc9d1cd11b5796a9d0c3d21..ab9f8fb4255b8f2077c367f9c199b9dff3e07e7a --- a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/config.json +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/config.json @@ -15,7 +15,9 @@ "deviceConfig": {}, "module": { "package": "com.example.actsgetallaccessibleaccounts", - "name": ".MyApplication", + "name": ".entry", + "mainAbility": ".MainAbility", + "srcPath":"", "deviceType": [ "phone" ], @@ -59,25 +61,42 @@ ], "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" + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "formsEnabled": false, + "name": ".MainAbility", + "srcLanguage": "js", + "srcPath": "MainAbility", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "label": "$string:MainAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "js", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" } - ], + ], "js": [ { "pages": [ @@ -88,7 +107,21 @@ "designWidth": 720, "autoDesignWidth": false } + }, + { + "pages": [ + "pages/index/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } } - ] + ], + "testRunner": { + "name": "OpenHarmonyTestRunner", + "srcPath": "TestRunner" + } } } \ 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/src/main/js/MainAbility/app.js similarity index 100% rename from account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/default/app.js rename to account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/MainAbility/app.js diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/default/i18n/en-US.json b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/default/i18n/en-US.json rename to account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/MainAbility/i18n/en-US.json diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/default/i18n/zh-CN.json b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/default/i18n/zh-CN.json rename to account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/MainAbility/pages/index/index.css b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..2334ecfa2c147f276998e82e2c35f62800cfb031 --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/MainAbility/pages/index/index.css @@ -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. + */ + +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/MainAbility/pages/index/index.hml b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/MainAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..58fdc144440ca578003fa3982fb8d0029cc2cdc7 --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/MainAbility/pages/index/index.hml @@ -0,0 +1,19 @@ + +
+ + {{title}} + +
diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/default/pages/index/index.js b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/MainAbility/pages/index/index.js similarity index 69% rename from account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/default/pages/index/index.js rename to account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/MainAbility/pages/index/index.js index 5a876ba0a720d83d5e8b404671860ea95571dcd0..7ffbf87eadfca5fc7efc9873d5d6875ac40d68b2 100755 --- a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/default/pages/index/index.js +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/MainAbility/pages/index/index.js @@ -12,7 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {Core, ExpectExtend} from 'deccjsunit/index' const injectRef = Object.getPrototypeOf(global) || global injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') @@ -26,18 +25,6 @@ export default { }, 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() { }, diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/TestAbility/app.js b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/TestAbility/app.js new file mode 100644 index 0000000000000000000000000000000000000000..cdc31f3dcf031e2f6a7665d9653e53bb649e21c5 --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/TestAbility/app.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('TestApplication onCreate') + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info("TestApplication onDestroy"); + } +}; diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/TestAbility/i18n/en-US.json b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/TestAbility/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..3cb24b374b1d919ca8eac0638f361692b603a900 --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/TestAbility/i18n/en-US.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } +} \ No newline at end of file diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/TestAbility/i18n/zh-CN.json b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/TestAbility/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..c804e32c0c3103929baca5617cdac70be11fdba1 --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/TestAbility/i18n/zh-CN.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } +} \ No newline at end of file diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/TestAbility/pages/index/index.css b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/TestAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..1ba8e4e82ace01dad36c1279ea520b4903c57e8f --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/TestAbility/pages/index/index.css @@ -0,0 +1,37 @@ +/* + * 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. + */ + +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} + + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} \ No newline at end of file diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/TestAbility/pages/index/index.hml b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/TestAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..61ea59d936e5a2971f1ea3d179c44a7f3f596c54 --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/TestAbility/pages/index/index.hml @@ -0,0 +1,21 @@ + + +
+ + {{ $t('strings.hello') }} {{title}} + + +
diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/TestAbility/pages/index/index.js b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/TestAbility/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..88b083a7f6b979019d6a2c5ad20b19c5fd43286b --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/TestAbility/pages/index/index.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + } +} + + + diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/TestRunner/OpenHarmonyTestRunner.js new file mode 100644 index 0000000000000000000000000000000000000000..c5fa8620ca77d381f20b65a903b833e6e3378c97 --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/TestRunner/OpenHarmonyTestRunner.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package', '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + + export default { + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + }, + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + console.info('debug value : '+debug) + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, (err, data) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + data.stdResult); + console.info('executeShellCommand : data : ' + data.exitCode); + }) + } +}; diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/test/Getallaccessible.test.js b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/test/Getallaccessible.test.js new file mode 100755 index 0000000000000000000000000000000000000000..98c2a602ac392cdde954ddf1efc17a50b26ee775 --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/test/Getallaccessible.test.js @@ -0,0 +1,603 @@ +/* + * 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 '@ohos/hypium' + +const TIMEOUT = 2000; +export default function ActsGetAllAccessibleAccounts() { + 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===="); + var selfBundle = "com.example.actsgetallaccessibleaccounts"; + console.debug("====>getAllAccounts for clean===="); + try{ + var acclist = await appAccountManager.getAllAccounts(selfBundle); + } + catch(err){ + console.error("====>getAllAccounts err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>account list length: " + acclist.length); + if(acclist.length > 0){ + for(var i = 0;i < acclist.length; i++){ + await appAccountManager.deleteAccount(acclist[i].name); + } + } + 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("====>getAllAccounts for clean===="); + var selfBundle = "com.example.actsgetallaccessibleaccounts"; + try{ + var acclist = await appAccountManager.getAllAccounts(selfBundle); + } + catch(err){ + console.error("====>getAllAccounts err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>account list length: " + acclist.length); + if(acclist.length > 0){ + for(var i = 0;i < acclist.length; i++){ + await appAccountManager.deleteAccount(acclist[i].name); + } + } + 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("====>getAllAccounts for clean===="); + var selfBundle = "com.example.actsgetallaccessibleaccounts"; + try{ + var acclist = await appAccountManager.getAllAccounts(selfBundle); + } + catch(err){ + console.error("====>getAllAccounts err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>account list length: " + acclist.length); + if(acclist.length > 0){ + for(var i = 0;i < acclist.length; i++){ + await appAccountManager.deleteAccount(acclist[i].name); + } + } + 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("====>getAllAccounts for clean===="); + var selfBundle = "com.example.actsgetallaccessibleaccounts"; + try{ + var acclist = await appAccountManager.getAllAccounts(selfBundle); + } + catch(err){ + console.error("====>getAllAccounts err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>account list length: " + acclist.length); + if(acclist.length > 0){ + for(var i = 0;i < acclist.length; i++){ + await appAccountManager.deleteAccount(acclist[i].name); + } + } + 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); + }); + }) +} \ No newline at end of file diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/test/List.test.js b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/test/List.test.js new file mode 100755 index 0000000000000000000000000000000000000000..31116b121a79588c735cfdbb13140ca9a17bdece --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/js/test/List.test.js @@ -0,0 +1,19 @@ +/* + * 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 ActsGetAllAccessibleAccounts from './Getallaccessible.test.js' + +export default function testsuite() { + ActsGetAllAccessibleAccounts() +} \ No newline at end of file diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/resources/base/element/string.json b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..b8c402107250a58e8ea8b91a03c84ad0c91af068 --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/resources/base/element/string.json @@ -0,0 +1,28 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ActsGetAllAccessibleAccounts" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" + } + ] +} \ 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/src/main/resources/base/media/icon.png similarity index 100% rename from account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/entry/src/main/js/resources/base/media/icon.png rename to account/appaccount/getallaccessibleaccounts/actsgetallaccessibleaccounts/src/main/resources/base/media/icon.png diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/BUILD.gn b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/BUILD.gn old mode 100755 new mode 100644 index 2ccd7f0f29a5015aeca1cd3c533c7d085fae902c..18df6bf1491733c06d562f90e8b903fa99a396b4 --- a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/BUILD.gn +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/BUILD.gn @@ -14,7 +14,7 @@ import("//test/xts/tools/build/suite.gni") ohos_js_hap_suite("ActsGetAllAccessibleMultipleTest") { - hap_profile = "./entry/src/main/config.json" + hap_profile = "./src/main/config.json" deps = [ ":hjs_demo_js_assets", ":hjs_demo_resources", @@ -23,9 +23,12 @@ ohos_js_hap_suite("ActsGetAllAccessibleMultipleTest") { hap_name = "ActsGetAllAccessibleMultipleTest" } ohos_js_assets("hjs_demo_js_assets") { - source_dir = "./entry/src/main/js/default" + js2abc = true + hap_profile = "./src/main/config.json" + source_dir = "./src/main/js" } + ohos_resources("hjs_demo_resources") { - sources = [ "./entry/src/main/js/resources" ] - hap_profile = "./entry/src/main/config.json" + sources = [ "./src/main/resources" ] + hap_profile = "./src/main/config.json" } diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/Test.json b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/Test.json old mode 100755 new mode 100644 index 368cc37534f087d6cf1bf703996968060eadf175..1e685b5a2ec82b7b232bd44cf24374c85940e20e --- a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/Test.json +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/Test.json @@ -1,9 +1,10 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "60000", - "package": "com.example.actsgetallaccessiblemultiple", + "bundle-name": "com.example.actsgetallaccessiblemultiple", + "package-name": "com.example.actsgetallaccessiblemultiple", "shell-timeout": "60000" }, "kits": [ 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 deleted file mode 100755 index 6fda792753f2e15f22b529c7b90a82185b2770bf..0000000000000000000000000000000000000000 --- a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/default/pages/index/index.css +++ /dev/null @@ -1,9 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.title { - font-size: 100px; -} diff --git a/account/appaccount/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 deleted file mode 100755 index c45422b42d0bf788a1c2c0eb299a981f07ce8613..0000000000000000000000000000000000000000 --- a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/default/pages/index/index.hml +++ /dev/null @@ -1,5 +0,0 @@ -
- - {{title}} - -
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 deleted file mode 100755 index 1835ed9344ce3ded8e53ef4267311fb1f07254bc..0000000000000000000000000000000000000000 --- a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "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/test/Getmultiple.test.js b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/test/Getmultiple.test.js deleted file mode 100755 index 47e0a82c7dc8b623a0d6a1d67f1f8f19d90d1bd5..0000000000000000000000000000000000000000 --- a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/test/Getmultiple.test.js +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import account from '@ohos.account.appAccount' -import featureAbility from '@ohos.ability.featureAbility' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' - -const TIMEOUT = 5000; -describe('ActsGetAllAccessibleMultiple', function () { - beforeAll(async function (done) { - console.debug("====>startAbility first start===="); - await featureAbility.startAbility( - { - want: - { - deviceId: "", - bundleName: "com.example.actsaccountaccessiblefirst", - abilityName: "com.example.actsaccountaccessiblefirst.MainAbility", - action: "action1", - parameters: - {}, - }, - }, - ); - sleep(TIMEOUT); - done(); - }); - - function sleep(delay) { - var start = (new Date()).getTime(); - while((new Date()).getTime() - start < delay) { - continue; - } - } - - /* - * @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===="); - let dataMap = new Map(); - 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("====>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); - console.debug("====>data.length:" + data.length); - for (let i = 0, len = data.length; i < len; i++) { - dataMap.set(data[i].name, data[i].owner) - } - expect(dataMap.has("account_name_scene_first_first")).assertTrue(); - if (dataMap.has("account_name_scene_first_first")) { - let data = dataMap.get("account_name_scene_first_first"); - console.debug("====>first account owner is: " + data); - expect(data).assertEqual("com.example.actsaccountaccessiblefirst"); - } - expect(dataMap.has("account_name_scene_first_second")).assertTrue(); - if (dataMap.has("account_name_scene_first_second")) { - let data = dataMap.get("account_name_scene_first_second"); - console.debug("====>second account owner is: " + data); - expect(data).assertEqual("com.example.actsaccountaccessiblefirst"); - } - expect(dataMap.has("account_name_scene_second_first")).assertTrue(); - if (dataMap.has("account_name_scene_second_first")) { - let data = dataMap.get("account_name_scene_second_first"); - console.debug("====>third account owner is: " + data); - expect(data).assertEqual("com.example.actsaccountaccessiblesecond"); - } - expect(dataMap.has("account_name_scene_second_second")).assertTrue(); - if (dataMap.has("account_name_scene_second_second")) { - let data = dataMap.get("account_name_scene_second_second"); - console.debug("====>fourth account owner is: " + data); - expect(data).assertEqual("com.example.actsaccountaccessiblesecond"); - } - expect(dataMap.has("accessibleAccount_this_application_first")).assertTrue(); - if (dataMap.has("accessibleAccount_this_application_first")) { - let data = dataMap.get("accessibleAccount_this_application_first"); - console.debug("====>fifth account owner is: " + data); - expect(data).assertEqual("com.example.actsgetallaccessiblemultiple"); - } - expect(dataMap.has("accessibleAccount_this_application_second")).assertTrue(); - if (dataMap.has("accessibleAccount_this_application_second")) { - let data = dataMap.get("accessibleAccount_this_application_second"); - console.debug("====>sixth account owner is: " + data); - expect(data).assertEqual("com.example.actsgetallaccessiblemultiple"); - } - expect(dataMap.has("accessibleAccount_this_application_third")).assertTrue(); - if (dataMap.has("accessibleAccount_this_application_third")) { - let data = dataMap.get("accessibleAccount_this_application_third"); - console.debug("====>seventh account owner is: " + data); - expect(data).assertEqual("com.example.actsgetallaccessiblemultiple"); - } - console.debug("====>delete account 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(); - }); -}) \ 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 deleted file mode 100755 index 8d14530a57213b2cb91c030c960702328ef95a1a..0000000000000000000000000000000000000000 --- a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/test/List.test.js +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -require('./Getmultiple.test.js') \ No newline at end of file diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/config.json b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/config.json old mode 100755 new mode 100644 similarity index 53% rename from account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/config.json rename to account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/config.json index 9292314f6ec020c09fe65d40e0ab5098fd4a1a69..ae92671ab59bf880e98bde100618bfac61ba5ec0 --- a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/config.json +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/config.json @@ -15,7 +15,9 @@ "deviceConfig": {}, "module": { "package": "com.example.actsgetallaccessiblemultiple", - "name": ".MyApplication", + "name": ".entry", + "mainAbility": ".MainAbility", + "srcPath":"", "deviceType": [ "phone" ], @@ -59,25 +61,42 @@ ], "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" + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "formsEnabled": false, + "name": ".MainAbility", + "srcLanguage": "js", + "srcPath": "MainAbility", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "label": "$string:MainAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "js", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" } - ], + ], "js": [ { "pages": [ @@ -88,7 +107,21 @@ "designWidth": 720, "autoDesignWidth": false } + }, + { + "pages": [ + "pages/index/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } } - ] + ], + "testRunner": { + "name": "OpenHarmonyTestRunner", + "srcPath": "TestRunner" + } } } \ 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/src/main/js/MainAbility/app.js similarity index 100% rename from account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/default/app.js rename to account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/MainAbility/app.js diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/default/i18n/en-US.json b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/default/i18n/en-US.json rename to account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/MainAbility/i18n/en-US.json diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/default/i18n/zh-CN.json b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/default/i18n/zh-CN.json rename to account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/MainAbility/pages/index/index.css b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..2334ecfa2c147f276998e82e2c35f62800cfb031 --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/MainAbility/pages/index/index.css @@ -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. + */ + +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/MainAbility/pages/index/index.hml b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/MainAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..58fdc144440ca578003fa3982fb8d0029cc2cdc7 --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/MainAbility/pages/index/index.hml @@ -0,0 +1,19 @@ + +
+ + {{title}} + +
diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/default/pages/index/index.js b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/MainAbility/pages/index/index.js similarity index 68% rename from account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/default/pages/index/index.js rename to account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/MainAbility/pages/index/index.js index 39daa07dd32edf8d3db972d4fdd7f1584f67c18f..c4ec231829b3b39bbd75ff2411792dd9f3a4bc6e 100755 --- a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/default/pages/index/index.js +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/MainAbility/pages/index/index.js @@ -12,8 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {Core, ExpectExtend} from 'deccjsunit/index' - const injectRef = Object.getPrototypeOf(global) || global injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') @@ -26,19 +24,6 @@ export default { }, onShow() { console.info('onShow finish') - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - core.init() - - const configService = core.getDefaultService('config') - this.timeout = 20000; - configService.setConfig(this) - - require('../../../test/List.test') - core.execute() }, onReady() { }, diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/TestAbility/app.js b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/TestAbility/app.js new file mode 100644 index 0000000000000000000000000000000000000000..cdc31f3dcf031e2f6a7665d9653e53bb649e21c5 --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/TestAbility/app.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('TestApplication onCreate') + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info("TestApplication onDestroy"); + } +}; diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/TestAbility/i18n/en-US.json b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/TestAbility/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..3cb24b374b1d919ca8eac0638f361692b603a900 --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/TestAbility/i18n/en-US.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } +} \ No newline at end of file diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/TestAbility/i18n/zh-CN.json b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/TestAbility/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..c804e32c0c3103929baca5617cdac70be11fdba1 --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/TestAbility/i18n/zh-CN.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } +} \ No newline at end of file diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/TestAbility/pages/index/index.css b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/TestAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..1ba8e4e82ace01dad36c1279ea520b4903c57e8f --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/TestAbility/pages/index/index.css @@ -0,0 +1,37 @@ +/* + * 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. + */ + +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} + + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} \ No newline at end of file diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/TestAbility/pages/index/index.hml b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/TestAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..61ea59d936e5a2971f1ea3d179c44a7f3f596c54 --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/TestAbility/pages/index/index.hml @@ -0,0 +1,21 @@ + + +
+ + {{ $t('strings.hello') }} {{title}} + + +
diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/TestAbility/pages/index/index.js b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/TestAbility/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..88b083a7f6b979019d6a2c5ad20b19c5fd43286b --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/TestAbility/pages/index/index.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + } +} + + + diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/TestRunner/OpenHarmonyTestRunner.js new file mode 100644 index 0000000000000000000000000000000000000000..c5fa8620ca77d381f20b65a903b833e6e3378c97 --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/TestRunner/OpenHarmonyTestRunner.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package', '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + + export default { + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + }, + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + console.info('debug value : '+debug) + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, (err, data) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + data.stdResult); + console.info('executeShellCommand : data : ' + data.exitCode); + }) + } +}; diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/test/Getmultiple.test.js b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/test/Getmultiple.test.js new file mode 100755 index 0000000000000000000000000000000000000000..3f206507bbcd3123bbaebd4d70175cae60395326 --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/test/Getmultiple.test.js @@ -0,0 +1,130 @@ +/* + * 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 '@ohos/hypium' + +const TIMEOUT = 5000; +export default function ActsGetAllAccessibleMultiple() { + describe('ActsGetAllAccessibleMultiple', function () { + beforeAll(async function (done) { + console.debug("====>startAbility first start===="); + await featureAbility.startAbility( + { + want: + { + deviceId: "", + bundleName: "com.example.actsaccountaccessiblefirst", + abilityName: "com.example.actsaccountaccessiblefirst.MainAbility", + action: "action1", + parameters: + {}, + }, + }, + ); + sleep(TIMEOUT); + done(); + }); + + function sleep(delay) { + var start = (new Date()).getTime(); + while((new Date()).getTime() - start < delay) { + continue; + } + } + + /* + * @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===="); + let dataMap = new Map(); + 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("====>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); + console.debug("====>data.length:" + data.length); + for (let i = 0, len = data.length; i < len; i++) { + dataMap.set(data[i].name, data[i].owner) + } + expect(dataMap.has("account_name_scene_first_first")).assertTrue(); + if (dataMap.has("account_name_scene_first_first")) { + let data = dataMap.get("account_name_scene_first_first"); + console.debug("====>first account owner is: " + data); + expect(data).assertEqual("com.example.actsaccountaccessiblefirst"); + } + expect(dataMap.has("account_name_scene_first_second")).assertTrue(); + if (dataMap.has("account_name_scene_first_second")) { + let data = dataMap.get("account_name_scene_first_second"); + console.debug("====>second account owner is: " + data); + expect(data).assertEqual("com.example.actsaccountaccessiblefirst"); + } + expect(dataMap.has("account_name_scene_second_first")).assertTrue(); + if (dataMap.has("account_name_scene_second_first")) { + let data = dataMap.get("account_name_scene_second_first"); + console.debug("====>third account owner is: " + data); + expect(data).assertEqual("com.example.actsaccountaccessiblesecond"); + } + expect(dataMap.has("account_name_scene_second_second")).assertTrue(); + if (dataMap.has("account_name_scene_second_second")) { + let data = dataMap.get("account_name_scene_second_second"); + console.debug("====>fourth account owner is: " + data); + expect(data).assertEqual("com.example.actsaccountaccessiblesecond"); + } + expect(dataMap.has("accessibleAccount_this_application_first")).assertTrue(); + if (dataMap.has("accessibleAccount_this_application_first")) { + let data = dataMap.get("accessibleAccount_this_application_first"); + console.debug("====>fifth account owner is: " + data); + expect(data).assertEqual("com.example.actsgetallaccessiblemultiple"); + } + expect(dataMap.has("accessibleAccount_this_application_second")).assertTrue(); + if (dataMap.has("accessibleAccount_this_application_second")) { + let data = dataMap.get("accessibleAccount_this_application_second"); + console.debug("====>sixth account owner is: " + data); + expect(data).assertEqual("com.example.actsgetallaccessiblemultiple"); + } + expect(dataMap.has("accessibleAccount_this_application_third")).assertTrue(); + if (dataMap.has("accessibleAccount_this_application_third")) { + let data = dataMap.get("accessibleAccount_this_application_third"); + console.debug("====>seventh account owner is: " + data); + expect(data).assertEqual("com.example.actsgetallaccessiblemultiple"); + } + console.debug("====>delete account 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(); + }); + }) +} \ No newline at end of file diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/test/List.test.js b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/test/List.test.js new file mode 100755 index 0000000000000000000000000000000000000000..8e3c24929372dae95f4df0aaed50f0b83bf6ab46 --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/js/test/List.test.js @@ -0,0 +1,19 @@ +/* + * 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 ActsGetAllAccessibleMultiple from './Getmultiple.test.js' + +export default function testsuite() { + ActsGetAllAccessibleMultiple() +} \ No newline at end of file diff --git a/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/resources/base/element/string.json b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..e2244febf6ffbfb2333c2c3ac0b78ae972b2bf1f --- /dev/null +++ b/account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/resources/base/element/string.json @@ -0,0 +1,28 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ActsGetAllAccessibleMultiple" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" + } + ] +} \ 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/src/main/resources/base/media/icon.png similarity index 100% rename from account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/entry/src/main/js/resources/base/media/icon.png rename to account/appaccount/getallaccessibleaccounts/actsgetallaccessiblemultiple/src/main/resources/base/media/icon.png diff --git a/account/osaccount/actsosaccountthirdpartytest/BUILD.gn b/account/osaccount/actsosaccountthirdpartytest/BUILD.gn old mode 100755 new mode 100644 index 3a9095a448d2f961217e03eee65088ac5f04822c..943c29304526bc6dc40ea9b01d960236884b7afd --- a/account/osaccount/actsosaccountthirdpartytest/BUILD.gn +++ b/account/osaccount/actsosaccountthirdpartytest/BUILD.gn @@ -14,7 +14,7 @@ import("//test/xts/tools/build/suite.gni") ohos_js_hap_suite("ActsOsAccountThirdPartyTest") { - hap_profile = "./entry/src/main/config.json" + hap_profile = "./src/main/config.json" deps = [ ":hjs_demo_js_assets", ":hjs_demo_resources", @@ -23,9 +23,12 @@ ohos_js_hap_suite("ActsOsAccountThirdPartyTest") { hap_name = "ActsOsAccountThirdPartyTest" } ohos_js_assets("hjs_demo_js_assets") { - source_dir = "./entry/src/main/js/default" + js2abc = true + hap_profile = "./src/main/config.json" + source_dir = "./src/main/js" } + ohos_resources("hjs_demo_resources") { - sources = [ "./entry/src/main/js/resources" ] - hap_profile = "./entry/src/main/config.json" + sources = [ "./src/main/resources" ] + hap_profile = "./src/main/config.json" } diff --git a/account/osaccount/actsosaccountthirdpartytest/Test.json b/account/osaccount/actsosaccountthirdpartytest/Test.json old mode 100755 new mode 100644 index 3be64f7ae8ad799c9533dd44adf0e1c8a4f3c55a..72697e7e100c9ea232a9945f82065d26c7bf3328 --- a/account/osaccount/actsosaccountthirdpartytest/Test.json +++ b/account/osaccount/actsosaccountthirdpartytest/Test.json @@ -1,9 +1,10 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "300000", - "package": "com.example.actsosaccountthirdpartytest", + "bundle-name": "com.example.actsosaccountthirdpartytest", + "package-name": "com.example.actsosaccountthirdpartytest", "shell-timeout": "60000" }, "kits": [ diff --git a/account/osaccount/actsosaccountthirdpartytest/entry/src/main/config.json b/account/osaccount/actsosaccountthirdpartytest/entry/src/main/config.json deleted file mode 100755 index eadb59a2523d4dff7e17936983b2767312db3977..0000000000000000000000000000000000000000 --- a/account/osaccount/actsosaccountthirdpartytest/entry/src/main/config.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "app": { - "bundleName": "com.example.actsosaccountthirdpartytest", - "vendor": "example", - "version": { - "code": 1, - "name": "1.0" - }, - "apiVersion": { - "compatible": 4, - "target": 5, - "releaseType": "Beta1" - } - }, - "deviceConfig": {}, - "module": { - "package": "com.example.actsosaccountthirdpartytest", - "name": ".MyApplication", - "deviceType": [ - "phone" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry" - }, - "defPermissions": [ - { - "availableScope": [], - "grantMode": "system_grant", - "name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS" - }, - { - "availableScope": [], - "grantMode": "system_grant", - "name": "ohos.permission.DISTRIBUTED_DATASYNC" - } - ], - "reqPermissions": [ - { - "name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS", - "reason": "ceshi" - }, - { - "name": "ohos.permission.DISTRIBUTED_DATASYNC", - "reason": "ceshi" - } - ], - "abilities": [ - { - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "name": "com.example.actsosaccountthirdpartytest.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/osaccount/actsosaccountthirdpartytest/entry/src/main/js/default/pages/index/index.css b/account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/default/pages/index/index.css deleted file mode 100755 index 6724ec055a554cf3f9c7be83780c30df2274875b..0000000000000000000000000000000000000000 --- a/account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/default/pages/index/index.css +++ /dev/null @@ -1,12 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.title { - font-size: 100px; -} -.titleST { - font-size: 32px; -} \ No newline at end of file diff --git a/account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/default/pages/index/index.hml b/account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/default/pages/index/index.hml deleted file mode 100755 index 718ac61d26ea06296527a29ad23d4e6f761865a6..0000000000000000000000000000000000000000 --- a/account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/default/pages/index/index.hml +++ /dev/null @@ -1,8 +0,0 @@ -
- - {{ $t('strings.hello') }} {{ title }} - - - STActsOsAccountThirdPartyTest - -
diff --git a/account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/resources/base/element/string.json b/account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/resources/base/element/string.json deleted file mode 100755 index 33e22aa3af86be72867076efc4c950899185b180..0000000000000000000000000000000000000000 --- a/account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "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/osaccount/actsosaccountthirdpartytest/entry/src/main/js/test/List.test.js b/account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/test/List.test.js deleted file mode 100755 index 0d2e50ff5806ac8b795a566b3fafb5dccf3cc8af..0000000000000000000000000000000000000000 --- a/account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/test/List.test.js +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -require('./OsAccountIs.test.js') -require('./OsAccountGet.test.js') \ No newline at end of file diff --git a/account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/test/OsAccountGet.test.js b/account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/test/OsAccountGet.test.js deleted file mode 100755 index 55ee7641a3b6d03125ec31a4c0b76e9c88d9d4c0..0000000000000000000000000000000000000000 --- a/account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/test/OsAccountGet.test.js +++ /dev/null @@ -1,469 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import osaccount from '@ohos.account.osAccount' -import bundle from '@ohos.bundle' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' - -const ERR_OS_ACCOUNT_SERVICE_MANAGER_BAD_UID_ERR = 4653057; -describe('ActsOsAccountThirdPartyTest_third_2', function () { - - /* - * @tc.number : ActsOsAccountGetIdFormUid_0100 - * @tc.name : getOsAccountLocalIdFromUid callback - * @tc.desc : Verify that the user localId is obtained by uid - */ - it('ActsOsAccountGetIdFormUid_0100', 0, async function (done) { - console.debug("====>ActsOsAccountGetIdFormUid_0100 start===="); - var osAccountManager = osaccount.getAccountManager(); - console.debug("====>get AccountManager finish===="); - var bundleName = "com.example.actsosaccountthirdpartytest"; - var bundleInfo = await bundle.getBundleInfo(bundleName, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES); - var uid = bundleInfo.uid; - console.debug("====>obtained uid:" + uid); - osAccountManager.getOsAccountLocalIdFromUid(uid, (err, localId)=>{ - console.debug("====>get localId err: " + JSON.stringify(err)); - console.debug("====>localId obtained by uid:" + localId); - expect(err.code).assertEqual(0); - expect(localId).assertEqual(100); - console.debug("====>ActsOsAccountGetIdFormUid_0100 end===="); - done(); - }); - }); - - /* - * @tc.number : ActsOsAccountGetIdFormUid_0200 - * @tc.name : getOsAccountLocalIdFromUid promise - * @tc.desc : Verify that the user localId is obtained by uid - */ - it('ActsOsAccountGetIdFormUid_0200', 0, async function (done) { - console.debug("====>ActsOsAccountGetIdFormUid_0200 start===="); - var osAccountManager = osaccount.getAccountManager(); - console.debug("====>get AccountManager finish===="); - var bundleName = "com.example.actsosaccountthirdpartytest"; - var bundleInfo = await bundle.getBundleInfo(bundleName, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES); - var uid = bundleInfo.uid; - console.debug("====>obtained uid:" + uid); - var localId = await osAccountManager.getOsAccountLocalIdFromUid(uid); - console.debug("====>localId obtained by uid:" + localId); - expect(localId).assertEqual(100); - console.debug("====>ActsOsAccountGetIdFormUid_0200 end===="); - done(); - }); - - /* - * @tc.number : ActsOsAccountGetIdFormUid_0300 - * @tc.name : getOsAccountLocalIdFromUid callback - * @tc.desc : Authentication failed to query user by uid -1 - */ - it('ActsOsAccountGetIdFormUid_0300', 0, async function (done) { - console.debug("====>ActsOsAccountGetIdFormUid_0300 start===="); - var osAccountManager = osaccount.getAccountManager(); - console.debug("====>get AccountManager finish===="); - var incorrectUid = -1; - osAccountManager.getOsAccountLocalIdFromUid(incorrectUid, (err, localId)=>{ - console.debug("====>get localId err: " + JSON.stringify(err)); - console.debug("====>localId obtained by uid:" + localId); - expect(err.code).assertEqual(ERR_OS_ACCOUNT_SERVICE_MANAGER_BAD_UID_ERR); - expect(localId).assertEqual(0); - console.debug("====>ActsOsAccountGetIdFormUid_0300 end===="); - done(); - }); - }); - - /* - * @tc.number : ActsOsAccountGetIdFormUid_0400 - * @tc.name : getOsAccountLocalIdFromUid promise - * @tc.desc : Authentication failed to query user by uid -1 - */ - it('ActsOsAccountGetIdFormUid_0400', 0, async function (done) { - console.debug("====>ActsOsAccountGetIdFormUid_0400 start===="); - var osAccountManager = osaccount.getAccountManager(); - console.debug("====>get AccountManager finish===="); - var incorrectUid = -1; - try{ - await osAccountManager.getOsAccountLocalIdFromUid(incorrectUid); - }catch(err){ - console.debug("====>get localId by uid err:" +JSON.stringify(err)); - expect(err.code).assertEqual(ERR_OS_ACCOUNT_SERVICE_MANAGER_BAD_UID_ERR); - console.debug("====>ActsOsAccountGetIdFormUid_0400 end===="); - done(); - } - }); - - /* - * @tc.number : ActsOsAccountGetIdFormUid_0500 - * @tc.name : getOsAccountLocalIdFromUid callback - * @tc.desc : Authentication failed to query user by uid 2147483648 - */ - it('ActsOsAccountGetIdFormUid_0500', 0, async function (done) { - console.debug("====>ActsOsAccountGetIdFormUid_0500 start===="); - var osAccountManager = osaccount.getAccountManager(); - console.debug("====>get AccountManager finish===="); - var incorrectUid = 2147483648; - osAccountManager.getOsAccountLocalIdFromUid(incorrectUid, (err, localId)=>{ - console.debug("====>get localId err: " + JSON.stringify(err)); - console.debug("====>localId obtained by uid:" + localId); - expect(err.code).assertEqual(ERR_OS_ACCOUNT_SERVICE_MANAGER_BAD_UID_ERR); - expect(localId).assertEqual(0); - console.debug("====>ActsOsAccountGetIdFormUid_0500 end===="); - done(); - }); - }); - - /* - * @tc.number : ActsOsAccountGetIdFormUid_0600 - * @tc.name : getOsAccountLocalIdFromUid promise - * @tc.desc : Authentication failed to query user by uid 2147483648 - */ - it('ActsOsAccountGetIdFormUid_0600', 0, async function (done) { - console.debug("====>ActsOsAccountGetIdFormUid_0600 start===="); - var osAccountManager = osaccount.getAccountManager(); - console.debug("====>get AccountManager finish===="); - var incorrectUid = 2147483648; - try{ - await osAccountManager.getOsAccountLocalIdFromUid(incorrectUid); - }catch(err){ - console.debug("====>get localId by uid err:" +JSON.stringify(err)); - expect(err.code).assertEqual(ERR_OS_ACCOUNT_SERVICE_MANAGER_BAD_UID_ERR); - console.debug("====>ActsOsAccountGetIdFormUid_0600 end===="); - done(); - } - }); - - /* - * @tc.number : ActsOsAccountGetIdFormProcess_0100 - * @tc.name : getOsAccountLocalIdFromProcess callback - * @tc.desc : Verify that the user localId obtained from the current process uid - */ - it('ActsOsAccountGetIdFormProcess_0100', 0, async function (done) { - console.debug("====>ActsOsAccountGetIdFormProcess_0100 start===="); - var osAccountManager = osaccount.getAccountManager(); - console.debug("====>get AccountManager finish===="); - osAccountManager.getOsAccountLocalIdFromProcess((err, localId)=>{ - console.debug("====>get localId err: " + JSON.stringify(err)); - console.debug("====>localId obtained by process:" + localId); - expect(err.code).assertEqual(0); - expect(localId).assertEqual(100); - console.debug("====>ActsOsAccountGetIdFormProcess_0100 end===="); - done(); - }); - }); - - /* - * @tc.number : ActsOsAccountGetIdFormProcess_0200 - * @tc.name : getOsAccountLocalIdFromProcess promise - * @tc.desc : Verify that the user localId obtained from the current process uid - */ - it('ActsOsAccountGetIdFormProcess_0200', 0, async function (done) { - console.debug("====>ActsOsAccountGetIdFormProcess_0200 start===="); - var osAccountManager = osaccount.getAccountManager(); - console.debug("====>get AccountManager finish===="); - var localId = await osAccountManager.getOsAccountLocalIdFromProcess(); - console.debug("====>localId obtained by process:" + localId); - expect(localId).assertEqual(100); - console.debug("====>ActsOsAccountGetIdFormProcess_0200 end===="); - done(); - }); - - /* - * @tc.number : ActsOsAccountGetTypeFormProcess_0100 - * @tc.name : getOsAccountTypeFromProcess callback - * @tc.desc : Verify that the user type obtained from the current process uid - */ - it('ActsOsAccountGetTypeFormProcess_0100', 0, async function (done) { - console.debug("====>ActsOsAccountGetTypeFormProcess_0100 start===="); - var osAccountManager = osaccount.getAccountManager(); - console.debug("====>get AccountManager finish===="); - osAccountManager.getOsAccountTypeFromProcess((err, accountType)=>{ - console.debug("====>get type err: " + JSON.stringify(err)); - console.debug("====>type obtained by process:" + JSON.stringify(accountType)); - expect(err.code).assertEqual(0); - expect(accountType.ADMIN).assertEqual(0); - console.debug("====>ActsOsAccountGetTypeFormProcess_0100 end===="); - done(); - }); - }); - - /* - * @tc.number : ActsOsAccountGetTypeFormProcess_0200 - * @tc.name : getOsAccountTypeFromProcess promise - * @tc.desc : Verify that the user type obtained from the current process uid - */ - it('ActsOsAccountGetTypeFormProcess_0200', 0, async function (done) { - console.debug("====>ActsOsAccountGetTypeFormProcess_0200 start===="); - var osAccountManager = osaccount.getAccountManager(); - console.debug("====>get AccountManager finish===="); - var accountType = await osAccountManager.getOsAccountTypeFromProcess(); - console.debug("====>type obtained by process:" + JSON.stringify(accountType)); - expect(accountType.ADMIN).assertEqual(0); - console.debug("====>ActsOsAccountGetTypeFormProcess_0200 end===="); - done(); - }); - - /* - * @tc.number : ActsOsAccountLocalIdSerial_0100 - * @tc.name : getSerialNumberByOsAccountLocalId callback - * @tc.desc : Verify query serialNumber by 100 user and query 100 user by serialNumber - */ - it('ActsOsAccountLocalIdSerial_0100', 0, async function (done) { - console.debug("====>ActsOsAccountLocalIdSerial_0100 start===="); - var osAccountManager = osaccount.getAccountManager(); - console.debug("====>get AccountManager finish===="); - osAccountManager.getSerialNumberByOsAccountLocalId(100, (err, serialNumber)=>{ - console.debug("====>ger serialNumber err:" + JSON.stringify(err)); - console.debug("====>get serialNumber:" + serialNumber + " by localId: 100" ); - expect(err.code).assertEqual(0); - var serialNumberStr = serialNumber.toString(); - var serialIntercept = serialNumberStr.substring(8); - console.debug("====>truncate the last eight characters: " + serialIntercept); - expect(serialIntercept).assertEqual("00000001"); - osAccountManager.getOsAccountLocalIdBySerialNumber(serialNumber, (err, localId)=>{ - console.debug("====>ger localId err:" + JSON.stringify(err)); - console.debug("====>get localId:" + localId + " by serialNumber: " + serialNumber); - expect(err.code).assertEqual(0); - expect(localId).assertEqual(100); - console.debug("====>ActsOsAccountLocalIdSerial_0100 end===="); - done(); - }) - }) - }); - - /* - * @tc.number : ActsOsAccountLocalIdSerial_0200 - * @tc.name : getSerialNumberByOsAccountLocalId promise - * @tc.desc : Verify query serialNumber by 100 user and query 100 user by serialNumber - */ - it('ActsOsAccountLocalIdSerial_0200', 0, async function (done) { - console.debug("====>ActsOsAccountLocalIdSerial_0200 start===="); - var osAccountManager = osaccount.getAccountManager(); - console.debug("====>get AccountManager finish===="); - var serialNumber = await osAccountManager.getSerialNumberByOsAccountLocalId(100); - console.debug("====>get serialNumber:" + serialNumber + " by localId: 100" ); - var serialNumberStr = serialNumber.toString(); - var serialIntercept = serialNumberStr.substring(8); - console.debug("====>truncate the last eight characters: " + serialIntercept); - expect(serialIntercept).assertEqual("00000001"); - var localId = await osAccountManager.getOsAccountLocalIdBySerialNumber(serialNumber); - console.debug("====>get localId:" + localId + " by serialNumber: " + serialNumber); - expect(localId).assertEqual(100); - console.debug("====>ActsOsAccountLocalIdSerial_0200 end===="); - done(); - }); - - /* - * @tc.number : ActsOsAccountLocalIdSerial_0300 - * @tc.name : getOsAccountLocalIdBySerialNumber callback - * @tc.desc : Verify query serialNumber by 0 user and query 0 user by serialNumber - */ - it('ActsOsAccountLocalIdSerial_0300', 0, async function (done) { - console.debug("====>ActsOsAccountLocalIdSerial_0300 start===="); - var osAccountManager = osaccount.getAccountManager(); - console.debug("====>get AccountManager finish===="); - osAccountManager.getSerialNumberByOsAccountLocalId(0, (err, serialNumber)=>{ - console.debug("====>ger serialNumber err:" + JSON.stringify(err)); - console.debug("====>get serialNumber:" + serialNumber + " by localId: 0" ); - expect(err.code).assertEqual(0); - var serialNumberStr = serialNumber.toString(); - var serialIntercept = serialNumberStr.substring(8); - console.debug("====>truncate the last eight characters: " + serialIntercept); - expect(serialIntercept).assertEqual("00000000"); - osAccountManager.getOsAccountLocalIdBySerialNumber(serialNumber, (err, localId)=>{ - console.debug("====>ger localId err:" + JSON.stringify(err)); - console.debug("====>get localId:" + localId + " by serialNumber: " + serialNumber); - expect(err.code).assertEqual(0); - expect(localId).assertEqual(0); - console.debug("====>ActsOsAccountLocalIdSerial_0300 end===="); - done(); - }) - }) - }); - - /* - * @tc.number : ActsOsAccountLocalIdSerial_0400 - * @tc.name : getOsAccountLocalIdBySerialNumber promise - * @tc.desc : Verify query serialNumber by 0 user and query 0 user by serialNumber - */ - it('ActsOsAccountLocalIdSerial_0400', 0, async function (done) { - console.debug("====>ActsOsAccountLocalIdSerial_0400 start===="); - var osAccountManager = osaccount.getAccountManager(); - console.debug("====>get AccountManager finish===="); - var serialNumber = await osAccountManager.getSerialNumberByOsAccountLocalId(0); - console.debug("====>get serialNumber:" + serialNumber + " by localId: 0" ); - var serialNumberStr = serialNumber.toString(); - var serialIntercept = serialNumberStr.substring(8); - console.debug("====>truncate the last eight characters: " + serialIntercept); - expect(serialIntercept).assertEqual("00000000"); - var localId = await osAccountManager.getOsAccountLocalIdBySerialNumber(serialNumber); - console.debug("====>get localId:" + localId + " by serialNumber: " + serialNumber); - expect(localId).assertEqual(0); - console.debug("====>ActsOsAccountLocalIdSerial_0400 end===="); - done(); - }); - - /* - * @tc.number : ActsOsAccountLocalIdSerial_0500 - * @tc.name : getSerialNumberByOsAccountLocalId callback - * @tc.desc : Verify the query for the newly created user serialNumber and query the owning user through the - * serialNumber - */ - it('ActsOsAccountLocalIdSerial_0500', 0, async function (done) { - console.debug("====>ActsOsAccountLocalIdSerial_0500 start===="); - var osAccountManager = osaccount.getAccountManager(); - console.debug("====>get AccountManager finish===="); - var localId; - osAccountManager.createOsAccount("osAccountNameIdSerialA", osaccount.OsAccountType.NORMAL, (err, data)=>{ - console.debug("====>create os account err: " + JSON.stringify(err)); - console.debug("====>create os account OsAccountInfo: " + JSON.stringify(data)); - expect(err.code).assertEqual(0); - expect(data.localName).assertEqual("osAccountNameIdSerialA"); - localId = data.localId; - osAccountManager.getSerialNumberByOsAccountLocalId(localId, (err, serialNumber)=>{ - console.debug("====>queryOsAccountById err:" + JSON.stringify(err)); - console.debug("====>get serialNumber:" + serialNumber + " by localId: " + localId); - expect(err.code).assertEqual(0); - osAccountManager.getOsAccountLocalIdBySerialNumber(serialNumber, (err, getlocalId)=>{ - console.debug("====>ger localId err:" + JSON.stringify(err)); - console.debug("====>get localId:" + getlocalId + " by serialNumber: " + serialNumber); - expect(err.code).assertEqual(0); - expect(getlocalId).assertEqual(localId); - osAccountManager.removeOsAccount(localId, (err)=>{ - console.debug("====>remove localId: " + localId + " err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsOsAccountLocalIdSerial_0500 end===="); - done(); - }) - }) - }) - }) - }); - - /* - * @tc.number : ActsOsAccountLocalIdSerial_0600 - * @tc.name : getOsAccountLocalIdBySerialNumber promise - * @tc.desc : Verify the query for the newly created user serialNumber and query the owning user through the - * serialNumber - */ - it('ActsOsAccountLocalIdSerial_0600', 0, async function (done) { - console.debug("====>ActsOsAccountLocalIdSerial_0600 start===="); - var osAccountManager = osaccount.getAccountManager(); - console.debug("====>get AccountManager finish===="); - var localId; - var OsAccountInfo = await osAccountManager.createOsAccount("accountIdSerialB", osaccount.OsAccountType.NORMAL); - console.debug("====>create os account OsAccountInfo: " + JSON.stringify(OsAccountInfo)); - expect(OsAccountInfo.localName).assertEqual("accountIdSerialB"); - localId = OsAccountInfo.localId; - var serialNumber = await osAccountManager.getSerialNumberByOsAccountLocalId(localId); - console.debug("====>get serialNumber:" + serialNumber + " by localId: " + localId); - var getlocalId = await osAccountManager.getOsAccountLocalIdBySerialNumber(serialNumber); - console.debug("====>get localId:" + getlocalId + " by serialNumber: " + serialNumber); - expect(getlocalId).assertEqual(localId); - await osAccountManager.removeOsAccount(localId); - console.debug("====>ActsOsAccountLocalIdSerial_0600 end===="); - done(); - }); - - /* - * @tc.number : ActsOsAccountGetCount_0100 - * @tc.name : getCreatedOsAccountsCount callback - * @tc.desc : Verify to obtain the number os all os accounts created - */ - it('ActsOsAccountGetCount_0100', 0, async function (done) { - console.debug("====>ActsOsAccountGetCount_0100 start===="); - var osAccountManager = osaccount.getAccountManager(); - console.debug("====>get AccountManager finish===="); - var obtainCount = 0; - var localIdFir; - var localIdSec; - osAccountManager.getCreatedOsAccountsCount((err, data)=>{ - console.debug("====>obtains the number of all os accounts created err:" + JSON.stringify(err)); - console.debug("====>obtains the number of all os accounts created data:" + data); - expect(err.code).assertEqual(0); - obtainCount = data; - osAccountManager.createOsAccount("osAccountNameIdSerialE", osaccount.OsAccountType.NORMAL, (err, data)=>{ - console.debug("====>create first os account err: " + JSON.stringify(err)); - console.debug("====>create first os account OsAccountInfo: " + JSON.stringify(data)); - localIdFir = data.localId; - expect(err.code).assertEqual(0); - expect(data.localName).assertEqual("osAccountNameIdSerialE"); - osAccountManager.createOsAccount("osAccountIdSerialF", osaccount.OsAccountType.NORMAL, (err, data)=>{ - console.debug("====>create second os account err: " + JSON.stringify(err)); - console.debug("====>create second os account OsAccountInfo: " + JSON.stringify(data)); - localIdSec = data.localId; - expect(err.code).assertEqual(0); - expect(data.localName).assertEqual("osAccountIdSerialF"); - osAccountManager.getCreatedOsAccountsCount((err, count)=>{ - console.debug("====>obtains the number of all os accounts created err:" + JSON.stringify(err)); - console.debug("====>obtains the number of all os accounts created count:" + count); - expect(err.code).assertEqual(0); - count = count - 2; - expect(count).assertEqual(obtainCount); - osAccountManager.removeOsAccount(localIdFir, (err)=>{ - console.debug("====>remove localId: " + localIdFir + " err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - osAccountManager.getCreatedOsAccountsCount((err, data)=>{ - console.debug("====>obtains the number accounts created err:" + JSON.stringify(err)); - console.debug("====>obtains the number accounts created data:" + data); - expect(err.code).assertEqual(0); - data = data - 1; - expect(data).assertEqual(obtainCount); - osAccountManager.removeOsAccount(localIdSec, (err)=>{ - console.debug("====>remove localId: " + localIdSec + " err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - console.debug("====>ActsOsAccountGetCount_0100 end===="); - done(); - }) - }) - }) - }) - }) - }) - }) - }) - - /* - * @tc.number : ActsOsAccountGetCount_0200 - * @tc.name : getCreatedOsAccountsCount promise - * @tc.desc : Verify to obtain the number os all os accounts created - */ - it('ActsOsAccountGetCount_0200', 0, async function (done) { - console.debug("====>ActsOsAccountGetCount_0200 start===="); - var osAccountManager = osaccount.getAccountManager(); - console.debug("====>get AccountManager finish===="); - var obtainCount = await osAccountManager.getCreatedOsAccountsCount(); - console.debug("====>obtains the number of all os accounts created:" + obtainCount); - var osAccountFir = await osAccountManager.createOsAccount("osAccountIdSerialG", osaccount.OsAccountType.NORMAL); - console.debug("====>create first os account OsAccountInfo: " + JSON.stringify(osAccountFir)); - var localIdFir = osAccountFir.localId; - expect(osAccountFir.localName).assertEqual("osAccountIdSerialG"); - var osAccountSec = await osAccountManager.createOsAccount("osAccountIdSerialH", osaccount.OsAccountType.NORMAL); - console.debug("====>create second os account OsAccountInfo: " + JSON.stringify(osAccountSec)); - var localIdSec = osAccountSec.localId; - expect(osAccountSec.localName).assertEqual("osAccountIdSerialH"); - var countFir = await osAccountManager.getCreatedOsAccountsCount(); - console.debug("====>obtains the number of all os accounts created count:" + countFir); - countFir = countFir - 2; - expect(countFir).assertEqual(obtainCount); - await osAccountManager.removeOsAccount(localIdFir); - console.debug("====>remove localId: " + localIdFir); - var countSec = await osAccountManager.getCreatedOsAccountsCount(); - console.debug("====>obtains the number accounts created count:" + countSec); - countSec = countSec - 1; - expect(countSec).assertEqual(obtainCount); - await osAccountManager.removeOsAccount(localIdSec); - console.debug("====>remove localId: " + localIdSec); - console.debug("====>ActsOsAccountGetCount_0200 end===="); - done(); - }) -}) \ No newline at end of file diff --git a/account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/test/OsAccountIs.test.js b/account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/test/OsAccountIs.test.js deleted file mode 100755 index 6aca3382bfb1f7115edf821aec0a9d4adc3f5ae9..0000000000000000000000000000000000000000 --- a/account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/test/OsAccountIs.test.js +++ /dev/null @@ -1,505 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import osAccount from '@ohos.account.osAccount' -import distributedAccount from '@ohos.account.distributedAccount' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' - -const TIMEOUT = 1000; -const ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_ACTIVED_ERROR = 4587542; -const ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_VERIFIED_ERROR = 4587545; -describe('ActsOsAccountThirdPartyTest_third_1', function () { - - /* - * @tc.number : ActsOsAccountDeviceId_0100 - * @tc.name : getDistributedVirtualDeviceId callback - * @tc.desc : get distributed virtual device ID - */ - it('ActsOsAccountDeviceId_0100', 0, async function(done){ - console.debug("====>ActsOsAccountDeviceId_0100 start===="); - var AccountManager = osAccount.getAccountManager(); - console.debug("====>get os AccountManager finish===="); - const deviceId = '5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5'; - const accountAbility = distributedAccount.getDistributedAccountAbility(); - accountAbility.updateOsAccountDistributedInfo( - { - name: 'ZhangSan', - id: '12345', - event: "Ohos.account.event.LOGIN" - }, (err)=>{ - console.debug("====>update distributedInfo err:" + JSON.stringify(err)); - AccountManager.getDistributedVirtualDeviceId((err, id)=>{ - console.debug("====>getDistributedVirtualDeviceId err:" + JSON.stringify(err)); - console.debug("====>getDistributedVirtualDeviceId deviceId:" + id); - expect(err.code).assertEqual(0); - expect(id).assertEqual(deviceId); - console.debug("====>ActsOsAccountDeviceId_0100 end===="); - done(); - }) - }) - }) - - /* - * @tc.number : ActsOsAccountDeviceId_0200 - * @tc.name : getDistributedVirtualDeviceId promise - * @tc.desc : get distributed virtual device ID - */ - it('ActsOsAccountDeviceId_0200', 0, async function(done){ - console.debug("====>ActsOsAccountDeviceId_0200 start===="); - var AccountManager = osAccount.getAccountManager(); - console.debug("====>get os AccountManager finish===="); - const deviceId = '5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5'; - const accountAbility = distributedAccount.getDistributedAccountAbility(); - accountAbility.updateOsAccountDistributedInfo( - { - name: 'ZhangSan', - id: '12345', - event: "Ohos.account.event.LOGIN" - }, async (err)=>{ - console.debug("====>update distributedInfo err:" + JSON.stringify(err)); - console.debug("====>getDistributedVirtualDeviceId start===="); - var id = await AccountManager.getDistributedVirtualDeviceId(); - console.debug("====>getDistributedVirtualDeviceId:" + id); - expect(id).assertEqual(deviceId); - console.debug("====>ActsOsAccountDeviceId_0200 end===="); - done(); - }) - }) - - /* - * @tc.number : ActsOsAccountIsActived_0100 - * @tc.name : isOsAccountActived callback - * @tc.desc : Verify query 0 user status is true - */ - it('ActsOsAccountIsActived_0100', 0, async function(done){ - console.debug("====>ActsOsAccountIsActived_0100 start===="); - var AccountManager = osAccount.getAccountManager(); - console.debug("====>get os AccountManager finish===="); - AccountManager.isOsAccountActived(0, (err, isActived)=>{ - console.debug("====>isOsAccountActived err:" + JSON.stringify(err)); - console.debug("====>isOsAccountActived isActived:" + isActived); - expect(err.code).assertEqual(0); - expect(isActived).assertEqual(true); - console.debug("====>ActsOsAccountIsActived_0100 end"); - done(); - }) - }) - - /* - * @tc.number : ActsOsAccountIsActived_0200 - * @tc.name : isOsAccountActived promise - * @tc.desc : Verify query 0 user status is true - */ - it('ActsOsAccountIsActived_0200', 0, async function(done){ - console.debug("====>ActsOsAccountIsActived_0200 start===="); - var AccountManager = osAccount.getAccountManager(); - console.debug("====>get os AccountManager finish===="); - try{ - var isActived = await AccountManager.isOsAccountActived(0); - } - catch(err){ - console.debug("====>catch isOsAccountActived err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>isOsAccountActived:" + isActived); - expect(isActived).assertEqual(true); - console.debug("====>ActsOsAccountIsActived_0200 end"); - done(); - }) - - /* - * @tc.number : ActsOsAccountIsActived_0300 - * @tc.name : isOsAccountActived callback - * @tc.desc : Authentication failed to query the active status of the user that does not exist - */ - it('ActsOsAccountIsActived_0300', 0, async function(done){ - console.debug("====>ActsOsAccountIsActived_0300 start"); - var AccountManager = osAccount.getAccountManager(); - console.debug("====>get os AccountManager finish===="); - var nonExistLocalId = 1000; - AccountManager.isOsAccountActived(nonExistLocalId, (err)=>{ - console.debug("====>isOsAccountActived err:" + JSON.stringify(err)); - expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_ACTIVED_ERROR); - console.debug("====>ActsOsAccountIsActived_0300 end"); - done(); - }) - }) - - /* - * @tc.number : ActsOsAccountIsActived_0400 - * @tc.name : isOsAccountActived promise - * @tc.desc : Authentication failed to query the active status of the user that does not exist - */ - it('ActsOsAccountIsActived_0400', 0, async function(done){ - console.debug("====>ActsOsAccountIsActived_0400 start===="); - var AccountManager = osAccount.getAccountManager(); - console.debug("====>get os AccountManager finish===="); - var nonExistLocalId = 1000; - try{ - await AccountManager.isOsAccountActived(nonExistLocalId); - } - catch(err){ - console.debug("====>isOsAccountActived err:" + JSON.stringify(err)); - expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_ACTIVED_ERROR); - console.debug("====>ActsOsAccountIsActived_0400 end"); - done(); - } - }) - - /* - * @tc.number : ActsOsAccountIsActived_0500 - * @tc.name : isOsAccountActived callback - * @tc.desc : Verify that the query active state is not received with parameter type mismatch - */ - it('ActsOsAccountIsActived_0500', 0, async function(done){ - console.debug("====>ActsOsAccountIsActived_0500 start"); - var AccountManager = osAccount.getAccountManager(); - console.debug("====>get os AccountManager finish===="); - var localIdStr = "100"; - function funcIsActived(err, data){ - console.debug("====>error received callback===="); - console.debug("====>receive isOsAccountActived err: " + JSON.stringify(err)); - console.debug("====>receive isOsAccountActived data: " + JSON.stringify(data)); - expect().assertFail(); - done(); - } - AccountManager.isOsAccountActived(localIdStr, funcIsActived); - setTimeout(()=>{ - console.debug("====>ActsOsAccountIsActived_0500 end===="); - done(); - }, TIMEOUT); - }) - - /* - * @tc.number : ActsOsAccountIsActived_0600 - * @tc.name : isOsAccountActived promise - * @tc.desc : Verify that the query active state is not received with parameter type mismatch - */ - it('ActsOsAccountIsActived_0600', 0, async function(done){ - console.debug("====>ActsOsAccountIsActived_0600 start===="); - var AccountManager = osAccount.getAccountManager(); - console.debug("====>get os AccountManager finish===="); - var localIdStr = "100"; - var isActived = await AccountManager.isOsAccountActived(localIdStr); - console.debug("====>get active status is: " + isActived); - expect(isActived).assertEqual(null); - console.debug("====>ActsOsAccountIsActived_0600 end===="); - done(); - }) - - /* - * @tc.number : ActsOsAccountIsActived_0700 - * @tc.name : isOsAccountActived callback - * @tc.desc : Verify that the query active state is not received with parameter undefined - */ - it('ActsOsAccountIsActived_0700', 0, async function(done){ - console.debug("====>ActsOsAccountIsActived_0700 start"); - var AccountManager = osAccount.getAccountManager(); - console.debug("====>get os AccountManager finish===="); - function funcIsActived(err, data){ - console.debug("====>error received callback===="); - console.debug("====>receive isOsAccountActived err: " + JSON.stringify(err)); - console.debug("====>receive isOsAccountActived data: " + JSON.stringify(data)); - expect().assertFail(); - done(); - } - AccountManager.isOsAccountActived(undefined, funcIsActived); - setTimeout(()=>{ - console.debug("====>ActsOsAccountIsActived_0700 end===="); - done(); - }, TIMEOUT); - }) - - /* - * @tc.number : ActsOsAccountIsActived_0800 - * @tc.name : isOsAccountActived promise - * @tc.desc : Verify that the query active state is not received with parameter undefined - */ - it('ActsOsAccountIsActived_0800', 0, async function(done){ - console.debug("====>ActsOsAccountIsActived_0800 start===="); - var AccountManager = osAccount.getAccountManager(); - console.debug("====>get os AccountManager finish===="); - var isActived = await AccountManager.isOsAccountActived(undefined); - console.debug("====>get active status is: " + isActived); - expect(isActived).assertEqual(null); - console.debug("====>ActsOsAccountIsActived_0800 end===="); - done(); - }) - - /* - * @tc.number : ActsOsAccountIsMulty_0100 - * @tc.name : isMultiOsAccountEnable callback - * @tc.desc : Check whether the function of supporting multiple os account is enabled - */ - it('ActsOsAccountIsMulty_0100', 0, async function(done){ - console.debug("====>ActsOsAccountIsMulty_0100 start===="); - var AccountManager = osAccount.getAccountManager(); - console.debug("====>get os AccountManager finish===="); - AccountManager.isMultiOsAccountEnable((err, data)=>{ - console.debug("====>isMultiOsAccountEnable err:" + JSON.stringify(err)); - console.debug("====>isMultiOsAccountEnable data:" + data); - expect(err.code).assertEqual(0); - expect(data).assertEqual(true); - console.debug("====>ActsOsAccountIsMulty_0100 end===="); - done(); - }) - }) - - /* - * @tc.number : ActsOsAccountIsMulty_0200 - * @tc.name : isMultiOsAccountEnable promise - * @tc.desc : Check whether the function of supporting multiple os account is enabled - */ - it('ActsOsAccountIsMulty_0200', 0, async function(done){ - console.debug("====>ActsOsAccountIsMulty_0200 start===="); - var AccountManager = osAccount.getAccountManager(); - console.debug("====>get os AccountManager finish===="); - try{ - var data = await AccountManager.isMultiOsAccountEnable(); - } - catch(err){ - console.debug("====>catch isMultiOsAccountEnable err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>isMultiOsAccountEnable data:" + JSON.stringify(data)); - expect(data).assertEqual(true); - console.debug("====>ActsOsAccountIsMulty_0200 end===="); - done(); - }) - - /* - * @tc.number : ActsOsAccountVerified_0100 - * @tc.name : isOsAccountVerified callback - * @tc.desc : Verify that the initial state query is unlocked to false - */ - it('ActsOsAccountVerified_0100', 0, async function(done){ - console.debug("====>isOsAccountVerified_0100 start===="); - var AccountManager = osAccount.getAccountManager(); - console.debug("====>get os AccountManager finish===="); - AccountManager.isOsAccountVerified((err, data)=>{ - console.debug("====>isOsAccountVerified err:" + JSON.stringify(err)); - console.debug("====>isOsAccountVerified data:" + data); - expect(err.code).assertEqual(0); - expect(data).assertEqual(false); - console.debug("====>ActsOsAccountVerified_0100 end===="); - done(); - }) - }) - - /* - * @tc.number : ActsOsAccountVerified_0200 - * @tc.name : isOsAccountVerified promise - * @tc.desc : Verify that the initial state query is unlocked to false - */ - it('ActsOsAccountVerified_0200', 0, async function(done){ - console.debug("====>isOsAccountVerified_0200 start===="); - var AccountManager = osAccount.getAccountManager(); - console.debug("====>get os AccountManager finish===="); - var isVerified = await AccountManager.isOsAccountVerified(); - console.debug("====>isOsAccountVerified data:" + isVerified); - expect(isVerified).assertEqual(false); - console.debug("====>ActsOsAccountVerified_0200 end===="); - done(); - }) - - /* - * @tc.number : ActsOsAccountIsVerified_0300 - * @tc.name : isOsAccountVerified callback - * @tc.desc : Verify that the initial state query 0 user is unlocked to false - */ - it('ActsOsAccountIsVerified_0300', 0, async function(done){ - console.debug("====>ActsOsAccountIsVerified_0300 start===="); - var AccountManager = osAccount.getAccountManager(); - console.debug("====>get os AccountManager finish===="); - AccountManager.isOsAccountVerified(0, (err, data)=>{ - console.debug("====>isOsAccountVerified err:" + JSON.stringify(err)); - expect(err.code).assertEqual(0); - expect(data).assertFalse(); - console.debug("====>ActsOsAccountIsVerified_0300 end===="); - done(); - }) - }) - - /* - * @tc.number : ActsOsAccountIsVerified_0400 - * @tc.name : isOsAccountVerified promise - * @tc.desc : Verify that the initial state query 0 user is unlocked to false - */ - it('ActsOsAccountIsVerified_0400', 0, async function(done){ - console.debug("====>ActsOsAccountIsVerified_0400 start===="); - var AccountManager = osAccount.getAccountManager(); - console.debug("====>get os AccountManager finish===="); - var isVerified = await AccountManager.isOsAccountVerified(0); - expect(isVerified).assertFalse(); - console.debug("====>ActsOsAccountIsVerified_0400 end===="); - done(); - }) - - /* - * @tc.number : ActsOsAccountIsVerified_0500 - * @tc.name : isOsAccountVerified callback - * @tc.desc : Verify query "100" user is unlocked failed - */ - it('ActsOsAccountIsVerified_0500', 0, async function(done){ - console.debug("====>ActsOsAccountIsVerified_0500 start===="); - var AccountManager = osAccount.getAccountManager(); - console.debug("====>get os AccountManager finish===="); - var localIdStr = "100"; - function funcIsVerified(err, data){ - console.debug("====>error received callback===="); - console.debug("====>receive isOsAccountVerified err: " + JSON.stringify(err)); - console.debug("====>receive isOsAccountVerified data: " + JSON.stringify(data)); - expect().assertFail(); - done(); - } - AccountManager.isOsAccountVerified(localIdStr, funcIsVerified); - setTimeout(()=>{ - console.debug("====>ActsOsAccountIsVerified_0500 end===="); - done(); - }, TIMEOUT); - }) - - /* - * @tc.number : ActsOsAccountIsVerified_0600 - * @tc.name : isOsAccountVerified promise - * @tc.desc : Verify query "100" user is unlocked failed - */ - it('ActsOsAccountIsVerified_0600', 0, async function(done){ - console.debug("====>ActsOsAccountIsVerified_0600 start===="); - var AccountManager = osAccount.getAccountManager(); - console.debug("====>get os AccountManager finish===="); - var localIdStr = "100"; - var isVerified = await AccountManager.isOsAccountVerified(localIdStr); - console.debug("====>get verified status is: " + isVerified); - expect(isVerified).assertEqual(null); - console.debug("====>ActsOsAccountIsVerified_0600 end===="); - done(); - }) - - /* - * @tc.number : ActsOsAccountIsVerified_0700 - * @tc.name : isOsAccountVerified callback - * @tc.desc : Verify query undefined user is unlocked failed - */ - it('ActsOsAccountIsVerified_0700', 0, async function(done){ - console.debug("====>ActsOsAccountIsVerified_0700 start===="); - var AccountManager = osAccount.getAccountManager(); - console.debug("====>get os AccountManager finish===="); - var localIdUndefined = undefined; - function funcIsVerified(err, data){ - console.debug("====>error received callback===="); - console.debug("====>receive isOsAccountVerified err: " + JSON.stringify(err)); - console.debug("====>receive isOsAccountVerified data: " + JSON.stringify(data)); - expect().assertFail(); - done(); - } - AccountManager.isOsAccountVerified(localIdUndefined, funcIsVerified); - setTimeout(()=>{ - console.debug("====>ActsOsAccountIsVerified_0700 end===="); - done(); - }, TIMEOUT); - }) - - /* - * @tc.number : ActsOsAccountIsVerified_0800 - * @tc.name : isOsAccountVerified promise - * @tc.desc : Verify query undefined user is unlocked failed - */ - it('ActsOsAccountIsVerified_0800', 0, async function(done){ - console.debug("====>ActsOsAccountIsVerified_0800 start===="); - var AccountManager = osAccount.getAccountManager(); - console.debug("====>get os AccountManager finish===="); - var localIdUndefined = undefined; - var isVerified = await AccountManager.isOsAccountVerified(localIdUndefined); - console.debug("====>get verified status is: " + isVerified); - expect(isVerified).assertEqual(null); - console.debug("====>ActsOsAccountIsVerified_0800 end===="); - done(); - }) - - /* - * @tc.number : ActsOsAccountIsVerified_0900 - * @tc.name : isOsAccountVerified callback - * @tc.desc : Verify query does not exist user unlock failed - */ - it('ActsOsAccountIsVerified_0900', 0, async function(done){ - console.debug("====>ActsOsAccountIsVerified_0900 start===="); - var AccountManager = osAccount.getAccountManager(); - console.debug("====>get os AccountManager finish===="); - var osAccountLocalId = 1000; - AccountManager.isOsAccountVerified(osAccountLocalId, (err)=>{ - console.debug("====>isOsAccountVerified err:" + JSON.stringify(err)); - expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_VERIFIED_ERROR); - console.debug("====>ActsOsAccountIsVerified_0900 end===="); - done(); - }) - }) - - /* - * @tc.number : ActsOsAccountIsVerified_1000 - * @tc.name : isOsAccountVerified promise - * @tc.desc : Verify query does not exist user unlock failed - */ - it('ActsOsAccountIsVerified_1000', 0, async function(done){ - console.debug("====>ActsOsAccountIsVerified_1000 start===="); - var AccountManager = osAccount.getAccountManager(); - console.debug("====>get os AccountManager finish===="); - var osAccountLocalId = 1000; - try{ - await AccountManager.isOsAccountVerified(osAccountLocalId); - } - catch(err){ - console.debug("====>isOsAccountVerified err:" + JSON.stringify(err)); - expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_VERIFIED_ERROR); - console.debug("====>ActsOsAccountIsVerified_1000 end===="); - done(); - } - }) - - /* - * @tc.number : ActsOsAccountIsTest_0100 - * @tc.name : isTestOsAccount callback - * @tc.desc : check whether this OS account is a test OS account - */ - it('ActsOsAccountIsTest_0100', 0, async function(done){ - console.debug("====>ActsOsAccountIsTest_0100 start===="); - var AccountManager = osAccount.getAccountManager(); - console.debug("====>get os AccountManager finish===="); - AccountManager.isTestOsAccount((err, data)=>{ - console.debug("====>isTestOsAccount err:" + JSON.stringify(err)); - console.debug("====>isTestOsAccount data:" + JSON.stringify(data)); - expect(err.code).assertEqual(0); - expect(data).assertEqual(false); - console.debug("====>ActsOsAccountIsTest_0100 end===="); - done(); - }) - }) - - /* - * @tc.number : ActsOsAccountIsTest_0200 - * @tc.name : isTestOsAccount promise - * @tc.desc : check whether this OS account is a test OS account - */ - it('ActsOsAccountIsTest_0200', 0, async function(done){ - console.debug("====>ActsOsAccountIsTest_0200 start===="); - var AccountManager = osAccount.getAccountManager(); - console.debug("====>get os AccountManager finish===="); - var isTest = await AccountManager.isTestOsAccount(); - expect(isTest).assertFalse(); - console.debug("====>ActsOsAccountIsTest_0200 end===="); - done(); - }) -}) \ No newline at end of file diff --git a/account/osaccount/actsosaccountthirdpartytest/src/main/config.json b/account/osaccount/actsosaccountthirdpartytest/src/main/config.json new file mode 100755 index 0000000000000000000000000000000000000000..5a0e9c58625b0ffd5f5b9f2978d6ac152807e29e --- /dev/null +++ b/account/osaccount/actsosaccountthirdpartytest/src/main/config.json @@ -0,0 +1,116 @@ +{ + "app": { + "bundleName": "com.example.actsosaccountthirdpartytest", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsosaccountthirdpartytest", + "name": ".entry", + "mainAbility": ".MainAbility", + "srcPath":"", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "defPermissions": [ + { + "availableScope": [], + "grantMode": "system_grant", + "name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "ohos.permission.DISTRIBUTED_DATASYNC" + } + ], + "reqPermissions": [ + { + "name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS", + "reason": "ceshi" + }, + { + "name": "ohos.permission.DISTRIBUTED_DATASYNC", + "reason": "ceshi" + } + ], + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "formsEnabled": false, + "name": ".MainAbility", + "srcLanguage": "js", + "srcPath": "MainAbility", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "label": "$string:MainAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "js", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "pages": [ + "pages/index/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "testRunner": { + "name": "OpenHarmonyTestRunner", + "srcPath": "TestRunner" + } + } +} \ No newline at end of file diff --git a/account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/default/app.js b/account/osaccount/actsosaccountthirdpartytest/src/main/js/MainAbility/app.js similarity index 100% rename from account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/default/app.js rename to account/osaccount/actsosaccountthirdpartytest/src/main/js/MainAbility/app.js diff --git a/account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/default/i18n/en-US.json b/account/osaccount/actsosaccountthirdpartytest/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/default/i18n/en-US.json rename to account/osaccount/actsosaccountthirdpartytest/src/main/js/MainAbility/i18n/en-US.json diff --git a/account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/default/i18n/zh-CN.json b/account/osaccount/actsosaccountthirdpartytest/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/default/i18n/zh-CN.json rename to account/osaccount/actsosaccountthirdpartytest/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/account/osaccount/actsosaccountthirdpartytest/src/main/js/MainAbility/pages/index/index.css b/account/osaccount/actsosaccountthirdpartytest/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..a76c6e2a38e5f83876fd19a643cbd1f7e553373a --- /dev/null +++ b/account/osaccount/actsosaccountthirdpartytest/src/main/js/MainAbility/pages/index/index.css @@ -0,0 +1,27 @@ +/* + * 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. + */ + +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} +.titleST { + font-size: 32px; +} \ No newline at end of file diff --git a/account/osaccount/actsosaccountthirdpartytest/src/main/js/MainAbility/pages/index/index.hml b/account/osaccount/actsosaccountthirdpartytest/src/main/js/MainAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..a7fccdac56fb0ff096d457b11a1d4f7a3da2a3ef --- /dev/null +++ b/account/osaccount/actsosaccountthirdpartytest/src/main/js/MainAbility/pages/index/index.hml @@ -0,0 +1,22 @@ + +
+ + {{ $t('strings.hello') }} {{ title }} + + + STActsOsAccountThirdPartyTest + +
diff --git a/account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/default/pages/index/index.js b/account/osaccount/actsosaccountthirdpartytest/src/main/js/MainAbility/pages/index/index.js similarity index 68% rename from account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/default/pages/index/index.js rename to account/osaccount/actsosaccountthirdpartytest/src/main/js/MainAbility/pages/index/index.js index 671e280834b6fb3f62c354c3c3a12754f8e0259a..64488943fe3d142b456a2e06bb1c370280cb16f5 100755 --- a/account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/default/pages/index/index.js +++ b/account/osaccount/actsosaccountthirdpartytest/src/main/js/MainAbility/pages/index/index.js @@ -13,7 +13,6 @@ * 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') @@ -27,19 +26,6 @@ export default { }, onShow() { console.info('onShow finish'); - const core = Core.getInstance(); - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend); - core.init(); - - const configService = core.getDefaultService('config'); - this.timeout = 120000; - configService.setConfig(this); - - require('../../../test/List.test'); - core.execute(); }, onReady() { }, diff --git a/account/osaccount/actsosaccountthirdpartytest/src/main/js/TestAbility/app.js b/account/osaccount/actsosaccountthirdpartytest/src/main/js/TestAbility/app.js new file mode 100644 index 0000000000000000000000000000000000000000..cdc31f3dcf031e2f6a7665d9653e53bb649e21c5 --- /dev/null +++ b/account/osaccount/actsosaccountthirdpartytest/src/main/js/TestAbility/app.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('TestApplication onCreate') + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info("TestApplication onDestroy"); + } +}; diff --git a/account/osaccount/actsosaccountthirdpartytest/src/main/js/TestAbility/i18n/en-US.json b/account/osaccount/actsosaccountthirdpartytest/src/main/js/TestAbility/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..3cb24b374b1d919ca8eac0638f361692b603a900 --- /dev/null +++ b/account/osaccount/actsosaccountthirdpartytest/src/main/js/TestAbility/i18n/en-US.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } +} \ No newline at end of file diff --git a/account/osaccount/actsosaccountthirdpartytest/src/main/js/TestAbility/i18n/zh-CN.json b/account/osaccount/actsosaccountthirdpartytest/src/main/js/TestAbility/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..c804e32c0c3103929baca5617cdac70be11fdba1 --- /dev/null +++ b/account/osaccount/actsosaccountthirdpartytest/src/main/js/TestAbility/i18n/zh-CN.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } +} \ No newline at end of file diff --git a/account/osaccount/actsosaccountthirdpartytest/src/main/js/TestAbility/pages/index/index.css b/account/osaccount/actsosaccountthirdpartytest/src/main/js/TestAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..1ba8e4e82ace01dad36c1279ea520b4903c57e8f --- /dev/null +++ b/account/osaccount/actsosaccountthirdpartytest/src/main/js/TestAbility/pages/index/index.css @@ -0,0 +1,37 @@ +/* + * 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. + */ + +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} + + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} \ No newline at end of file diff --git a/account/osaccount/actsosaccountthirdpartytest/src/main/js/TestAbility/pages/index/index.hml b/account/osaccount/actsosaccountthirdpartytest/src/main/js/TestAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..61ea59d936e5a2971f1ea3d179c44a7f3f596c54 --- /dev/null +++ b/account/osaccount/actsosaccountthirdpartytest/src/main/js/TestAbility/pages/index/index.hml @@ -0,0 +1,21 @@ + + +
+ + {{ $t('strings.hello') }} {{title}} + + +
diff --git a/account/osaccount/actsosaccountthirdpartytest/src/main/js/TestAbility/pages/index/index.js b/account/osaccount/actsosaccountthirdpartytest/src/main/js/TestAbility/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..88b083a7f6b979019d6a2c5ad20b19c5fd43286b --- /dev/null +++ b/account/osaccount/actsosaccountthirdpartytest/src/main/js/TestAbility/pages/index/index.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + } +} + + + diff --git a/account/osaccount/actsosaccountthirdpartytest/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/account/osaccount/actsosaccountthirdpartytest/src/main/js/TestRunner/OpenHarmonyTestRunner.js new file mode 100644 index 0000000000000000000000000000000000000000..c5fa8620ca77d381f20b65a903b833e6e3378c97 --- /dev/null +++ b/account/osaccount/actsosaccountthirdpartytest/src/main/js/TestRunner/OpenHarmonyTestRunner.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package', '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + + export default { + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + }, + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + console.info('debug value : '+debug) + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, (err, data) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + data.stdResult); + console.info('executeShellCommand : data : ' + data.exitCode); + }) + } +}; diff --git a/account/osaccount/actsosaccountthirdpartytest/src/main/js/test/List.test.js b/account/osaccount/actsosaccountthirdpartytest/src/main/js/test/List.test.js new file mode 100755 index 0000000000000000000000000000000000000000..714b5ea8f578803b64958c698e402815bf128caa --- /dev/null +++ b/account/osaccount/actsosaccountthirdpartytest/src/main/js/test/List.test.js @@ -0,0 +1,20 @@ +/* + * 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 ActsOsAccountThirdPartyTest_third_2 from './OsAccountGet.test.js' +import ActsOsAccountThirdPartyTest_third_1 from './OsAccountIs.test.js' +export default function testsuite() { + ActsOsAccountThirdPartyTest_third_2() + ActsOsAccountThirdPartyTest_third_1() +} \ No newline at end of file diff --git a/account/osaccount/actsosaccountthirdpartytest/src/main/js/test/OsAccountGet.test.js b/account/osaccount/actsosaccountthirdpartytest/src/main/js/test/OsAccountGet.test.js new file mode 100755 index 0000000000000000000000000000000000000000..fc9fc6bde2ffe450a6a52a2219f9f3f4265c4fc2 --- /dev/null +++ b/account/osaccount/actsosaccountthirdpartytest/src/main/js/test/OsAccountGet.test.js @@ -0,0 +1,471 @@ +/* + * 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 osaccount from '@ohos.account.osAccount' +import bundle from '@ohos.bundle' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +const ERR_OS_ACCOUNT_SERVICE_MANAGER_BAD_UID_ERR = 4653057; +export default function ActsOsAccountThirdPartyTest_third_2() { + describe('ActsOsAccountThirdPartyTest_third_2', function () { + + /* + * @tc.number : ActsOsAccountGetIdFormUid_0100 + * @tc.name : getOsAccountLocalIdFromUid callback + * @tc.desc : Verify that the user localId is obtained by uid + */ + it('ActsOsAccountGetIdFormUid_0100', 0, async function (done) { + console.debug("====>ActsOsAccountGetIdFormUid_0100 start===="); + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + var bundleName = "com.example.actsosaccountthirdpartytest"; + var bundleInfo = await bundle.getBundleInfo(bundleName, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES); + var uid = bundleInfo.uid; + console.debug("====>obtained uid:" + uid); + osAccountManager.getOsAccountLocalIdFromUid(uid, (err, localId)=>{ + console.debug("====>get localId err: " + JSON.stringify(err)); + console.debug("====>localId obtained by uid:" + localId); + expect(err.code).assertEqual(0); + expect(localId).assertEqual(100); + console.debug("====>ActsOsAccountGetIdFormUid_0100 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsOsAccountGetIdFormUid_0200 + * @tc.name : getOsAccountLocalIdFromUid promise + * @tc.desc : Verify that the user localId is obtained by uid + */ + it('ActsOsAccountGetIdFormUid_0200', 0, async function (done) { + console.debug("====>ActsOsAccountGetIdFormUid_0200 start===="); + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + var bundleName = "com.example.actsosaccountthirdpartytest"; + var bundleInfo = await bundle.getBundleInfo(bundleName, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES); + var uid = bundleInfo.uid; + console.debug("====>obtained uid:" + uid); + var localId = await osAccountManager.getOsAccountLocalIdFromUid(uid); + console.debug("====>localId obtained by uid:" + localId); + expect(localId).assertEqual(100); + console.debug("====>ActsOsAccountGetIdFormUid_0200 end===="); + done(); + }); + + /* + * @tc.number : ActsOsAccountGetIdFormUid_0300 + * @tc.name : getOsAccountLocalIdFromUid callback + * @tc.desc : Authentication failed to query user by uid -1 + */ + it('ActsOsAccountGetIdFormUid_0300', 0, async function (done) { + console.debug("====>ActsOsAccountGetIdFormUid_0300 start===="); + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + var incorrectUid = -1; + osAccountManager.getOsAccountLocalIdFromUid(incorrectUid, (err, localId)=>{ + console.debug("====>get localId err: " + JSON.stringify(err)); + console.debug("====>localId obtained by uid:" + localId); + expect(err.code).assertEqual(ERR_OS_ACCOUNT_SERVICE_MANAGER_BAD_UID_ERR); + expect(localId).assertEqual(0); + console.debug("====>ActsOsAccountGetIdFormUid_0300 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsOsAccountGetIdFormUid_0400 + * @tc.name : getOsAccountLocalIdFromUid promise + * @tc.desc : Authentication failed to query user by uid -1 + */ + it('ActsOsAccountGetIdFormUid_0400', 0, async function (done) { + console.debug("====>ActsOsAccountGetIdFormUid_0400 start===="); + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + var incorrectUid = -1; + try{ + await osAccountManager.getOsAccountLocalIdFromUid(incorrectUid); + }catch(err){ + console.debug("====>get localId by uid err:" +JSON.stringify(err)); + expect(err.code).assertEqual(ERR_OS_ACCOUNT_SERVICE_MANAGER_BAD_UID_ERR); + console.debug("====>ActsOsAccountGetIdFormUid_0400 end===="); + done(); + } + }); + + /* + * @tc.number : ActsOsAccountGetIdFormUid_0500 + * @tc.name : getOsAccountLocalIdFromUid callback + * @tc.desc : Authentication failed to query user by uid 2147483648 + */ + it('ActsOsAccountGetIdFormUid_0500', 0, async function (done) { + console.debug("====>ActsOsAccountGetIdFormUid_0500 start===="); + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + var incorrectUid = 2147483648; + osAccountManager.getOsAccountLocalIdFromUid(incorrectUid, (err, localId)=>{ + console.debug("====>get localId err: " + JSON.stringify(err)); + console.debug("====>localId obtained by uid:" + localId); + expect(err.code).assertEqual(ERR_OS_ACCOUNT_SERVICE_MANAGER_BAD_UID_ERR); + expect(localId).assertEqual(0); + console.debug("====>ActsOsAccountGetIdFormUid_0500 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsOsAccountGetIdFormUid_0600 + * @tc.name : getOsAccountLocalIdFromUid promise + * @tc.desc : Authentication failed to query user by uid 2147483648 + */ + it('ActsOsAccountGetIdFormUid_0600', 0, async function (done) { + console.debug("====>ActsOsAccountGetIdFormUid_0600 start===="); + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + var incorrectUid = 2147483648; + try{ + await osAccountManager.getOsAccountLocalIdFromUid(incorrectUid); + }catch(err){ + console.debug("====>get localId by uid err:" +JSON.stringify(err)); + expect(err.code).assertEqual(ERR_OS_ACCOUNT_SERVICE_MANAGER_BAD_UID_ERR); + console.debug("====>ActsOsAccountGetIdFormUid_0600 end===="); + done(); + } + }); + + /* + * @tc.number : ActsOsAccountGetIdFormProcess_0100 + * @tc.name : getOsAccountLocalIdFromProcess callback + * @tc.desc : Verify that the user localId obtained from the current process uid + */ + it('ActsOsAccountGetIdFormProcess_0100', 0, async function (done) { + console.debug("====>ActsOsAccountGetIdFormProcess_0100 start===="); + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + osAccountManager.getOsAccountLocalIdFromProcess((err, localId)=>{ + console.debug("====>get localId err: " + JSON.stringify(err)); + console.debug("====>localId obtained by process:" + localId); + expect(err.code).assertEqual(0); + expect(localId).assertEqual(100); + console.debug("====>ActsOsAccountGetIdFormProcess_0100 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsOsAccountGetIdFormProcess_0200 + * @tc.name : getOsAccountLocalIdFromProcess promise + * @tc.desc : Verify that the user localId obtained from the current process uid + */ + it('ActsOsAccountGetIdFormProcess_0200', 0, async function (done) { + console.debug("====>ActsOsAccountGetIdFormProcess_0200 start===="); + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + var localId = await osAccountManager.getOsAccountLocalIdFromProcess(); + console.debug("====>localId obtained by process:" + localId); + expect(localId).assertEqual(100); + console.debug("====>ActsOsAccountGetIdFormProcess_0200 end===="); + done(); + }); + + /* + * @tc.number : ActsOsAccountGetTypeFormProcess_0100 + * @tc.name : getOsAccountTypeFromProcess callback + * @tc.desc : Verify that the user type obtained from the current process uid + */ + it('ActsOsAccountGetTypeFormProcess_0100', 0, async function (done) { + console.debug("====>ActsOsAccountGetTypeFormProcess_0100 start===="); + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + osAccountManager.getOsAccountTypeFromProcess((err, accountType)=>{ + console.debug("====>get type err: " + JSON.stringify(err)); + console.debug("====>type obtained by process:" + JSON.stringify(accountType)); + expect(err.code).assertEqual(0); + expect(accountType.ADMIN).assertEqual(0); + console.debug("====>ActsOsAccountGetTypeFormProcess_0100 end===="); + done(); + }); + }); + + /* + * @tc.number : ActsOsAccountGetTypeFormProcess_0200 + * @tc.name : getOsAccountTypeFromProcess promise + * @tc.desc : Verify that the user type obtained from the current process uid + */ + it('ActsOsAccountGetTypeFormProcess_0200', 0, async function (done) { + console.debug("====>ActsOsAccountGetTypeFormProcess_0200 start===="); + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + var accountType = await osAccountManager.getOsAccountTypeFromProcess(); + console.debug("====>type obtained by process:" + JSON.stringify(accountType)); + expect(accountType.ADMIN).assertEqual(0); + console.debug("====>ActsOsAccountGetTypeFormProcess_0200 end===="); + done(); + }); + + /* + * @tc.number : ActsOsAccountLocalIdSerial_0100 + * @tc.name : getSerialNumberByOsAccountLocalId callback + * @tc.desc : Verify query serialNumber by 100 user and query 100 user by serialNumber + */ + it('ActsOsAccountLocalIdSerial_0100', 0, async function (done) { + console.debug("====>ActsOsAccountLocalIdSerial_0100 start===="); + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + osAccountManager.getSerialNumberByOsAccountLocalId(100, (err, serialNumber)=>{ + console.debug("====>ger serialNumber err:" + JSON.stringify(err)); + console.debug("====>get serialNumber:" + serialNumber + " by localId: 100" ); + expect(err.code).assertEqual(0); + var serialNumberStr = serialNumber.toString(); + var serialIntercept = serialNumberStr.substring(8); + console.debug("====>truncate the last eight characters: " + serialIntercept); + expect(serialIntercept).assertEqual("00000001"); + osAccountManager.getOsAccountLocalIdBySerialNumber(serialNumber, (err, localId)=>{ + console.debug("====>ger localId err:" + JSON.stringify(err)); + console.debug("====>get localId:" + localId + " by serialNumber: " + serialNumber); + expect(err.code).assertEqual(0); + expect(localId).assertEqual(100); + console.debug("====>ActsOsAccountLocalIdSerial_0100 end===="); + done(); + }) + }) + }); + + /* + * @tc.number : ActsOsAccountLocalIdSerial_0200 + * @tc.name : getSerialNumberByOsAccountLocalId promise + * @tc.desc : Verify query serialNumber by 100 user and query 100 user by serialNumber + */ + it('ActsOsAccountLocalIdSerial_0200', 0, async function (done) { + console.debug("====>ActsOsAccountLocalIdSerial_0200 start===="); + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + var serialNumber = await osAccountManager.getSerialNumberByOsAccountLocalId(100); + console.debug("====>get serialNumber:" + serialNumber + " by localId: 100" ); + var serialNumberStr = serialNumber.toString(); + var serialIntercept = serialNumberStr.substring(8); + console.debug("====>truncate the last eight characters: " + serialIntercept); + expect(serialIntercept).assertEqual("00000001"); + var localId = await osAccountManager.getOsAccountLocalIdBySerialNumber(serialNumber); + console.debug("====>get localId:" + localId + " by serialNumber: " + serialNumber); + expect(localId).assertEqual(100); + console.debug("====>ActsOsAccountLocalIdSerial_0200 end===="); + done(); + }); + + /* + * @tc.number : ActsOsAccountLocalIdSerial_0300 + * @tc.name : getOsAccountLocalIdBySerialNumber callback + * @tc.desc : Verify query serialNumber by 0 user and query 0 user by serialNumber + */ + it('ActsOsAccountLocalIdSerial_0300', 0, async function (done) { + console.debug("====>ActsOsAccountLocalIdSerial_0300 start===="); + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + osAccountManager.getSerialNumberByOsAccountLocalId(0, (err, serialNumber)=>{ + console.debug("====>ger serialNumber err:" + JSON.stringify(err)); + console.debug("====>get serialNumber:" + serialNumber + " by localId: 0" ); + expect(err.code).assertEqual(0); + var serialNumberStr = serialNumber.toString(); + var serialIntercept = serialNumberStr.substring(8); + console.debug("====>truncate the last eight characters: " + serialIntercept); + expect(serialIntercept).assertEqual("00000000"); + osAccountManager.getOsAccountLocalIdBySerialNumber(serialNumber, (err, localId)=>{ + console.debug("====>ger localId err:" + JSON.stringify(err)); + console.debug("====>get localId:" + localId + " by serialNumber: " + serialNumber); + expect(err.code).assertEqual(0); + expect(localId).assertEqual(0); + console.debug("====>ActsOsAccountLocalIdSerial_0300 end===="); + done(); + }) + }) + }); + + /* + * @tc.number : ActsOsAccountLocalIdSerial_0400 + * @tc.name : getOsAccountLocalIdBySerialNumber promise + * @tc.desc : Verify query serialNumber by 0 user and query 0 user by serialNumber + */ + it('ActsOsAccountLocalIdSerial_0400', 0, async function (done) { + console.debug("====>ActsOsAccountLocalIdSerial_0400 start===="); + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + var serialNumber = await osAccountManager.getSerialNumberByOsAccountLocalId(0); + console.debug("====>get serialNumber:" + serialNumber + " by localId: 0" ); + var serialNumberStr = serialNumber.toString(); + var serialIntercept = serialNumberStr.substring(8); + console.debug("====>truncate the last eight characters: " + serialIntercept); + expect(serialIntercept).assertEqual("00000000"); + var localId = await osAccountManager.getOsAccountLocalIdBySerialNumber(serialNumber); + console.debug("====>get localId:" + localId + " by serialNumber: " + serialNumber); + expect(localId).assertEqual(0); + console.debug("====>ActsOsAccountLocalIdSerial_0400 end===="); + done(); + }); + + /* + * @tc.number : ActsOsAccountLocalIdSerial_0500 + * @tc.name : getSerialNumberByOsAccountLocalId callback + * @tc.desc : Verify the query for the newly created user serialNumber and query the owning user through the + * serialNumber + */ + it('ActsOsAccountLocalIdSerial_0500', 0, async function (done) { + console.debug("====>ActsOsAccountLocalIdSerial_0500 start===="); + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + var localId; + osAccountManager.createOsAccount("osAccountNameIdSerialA", osaccount.OsAccountType.NORMAL, (err, data)=>{ + console.debug("====>create os account err: " + JSON.stringify(err)); + console.debug("====>create os account OsAccountInfo: " + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data.localName).assertEqual("osAccountNameIdSerialA"); + localId = data.localId; + osAccountManager.getSerialNumberByOsAccountLocalId(localId, (err, serialNumber)=>{ + console.debug("====>queryOsAccountById err:" + JSON.stringify(err)); + console.debug("====>get serialNumber:" + serialNumber + " by localId: " + localId); + expect(err.code).assertEqual(0); + osAccountManager.getOsAccountLocalIdBySerialNumber(serialNumber, (err, getlocalId)=>{ + console.debug("====>ger localId err:" + JSON.stringify(err)); + console.debug("====>get localId:" + getlocalId + " by serialNumber: " + serialNumber); + expect(err.code).assertEqual(0); + expect(getlocalId).assertEqual(localId); + osAccountManager.removeOsAccount(localId, (err)=>{ + console.debug("====>remove localId: " + localId + " err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsOsAccountLocalIdSerial_0500 end===="); + done(); + }) + }) + }) + }) + }); + + /* + * @tc.number : ActsOsAccountLocalIdSerial_0600 + * @tc.name : getOsAccountLocalIdBySerialNumber promise + * @tc.desc : Verify the query for the newly created user serialNumber and query the owning user through the + * serialNumber + */ + it('ActsOsAccountLocalIdSerial_0600', 0, async function (done) { + console.debug("====>ActsOsAccountLocalIdSerial_0600 start===="); + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + var localId; + var OsAccountInfo = await osAccountManager.createOsAccount("accountIdSerialB", osaccount.OsAccountType.NORMAL); + console.debug("====>create os account OsAccountInfo: " + JSON.stringify(OsAccountInfo)); + expect(OsAccountInfo.localName).assertEqual("accountIdSerialB"); + localId = OsAccountInfo.localId; + var serialNumber = await osAccountManager.getSerialNumberByOsAccountLocalId(localId); + console.debug("====>get serialNumber:" + serialNumber + " by localId: " + localId); + var getlocalId = await osAccountManager.getOsAccountLocalIdBySerialNumber(serialNumber); + console.debug("====>get localId:" + getlocalId + " by serialNumber: " + serialNumber); + expect(getlocalId).assertEqual(localId); + await osAccountManager.removeOsAccount(localId); + console.debug("====>ActsOsAccountLocalIdSerial_0600 end===="); + done(); + }); + + /* + * @tc.number : ActsOsAccountGetCount_0100 + * @tc.name : getCreatedOsAccountsCount callback + * @tc.desc : Verify to obtain the number os all os accounts created + */ + it('ActsOsAccountGetCount_0100', 0, async function (done) { + console.debug("====>ActsOsAccountGetCount_0100 start===="); + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + var obtainCount = 0; + var localIdFir; + var localIdSec; + osAccountManager.getCreatedOsAccountsCount((err, data)=>{ + console.debug("====>obtains the number of all os accounts created err:" + JSON.stringify(err)); + console.debug("====>obtains the number of all os accounts created data:" + data); + expect(err.code).assertEqual(0); + obtainCount = data; + osAccountManager.createOsAccount("osAccountNameIdSerialE", osaccount.OsAccountType.NORMAL, (err, data)=>{ + console.debug("====>create first os account err: " + JSON.stringify(err)); + console.debug("====>create first os account OsAccountInfo: " + JSON.stringify(data)); + localIdFir = data.localId; + expect(err.code).assertEqual(0); + expect(data.localName).assertEqual("osAccountNameIdSerialE"); + osAccountManager.createOsAccount("osAccountIdSerialF", osaccount.OsAccountType.NORMAL, (err, data)=>{ + console.debug("====>create second os account err: " + JSON.stringify(err)); + console.debug("====>create second os account OsAccountInfo: " + JSON.stringify(data)); + localIdSec = data.localId; + expect(err.code).assertEqual(0); + expect(data.localName).assertEqual("osAccountIdSerialF"); + osAccountManager.getCreatedOsAccountsCount((err, count)=>{ + console.debug("====>obtains the number of all os accounts created err:" + JSON.stringify(err)); + console.debug("====>obtains the number of all os accounts created count:" + count); + expect(err.code).assertEqual(0); + count = count - 2; + expect(count).assertEqual(obtainCount); + osAccountManager.removeOsAccount(localIdFir, (err)=>{ + console.debug("====>remove localId: " + localIdFir + " err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + osAccountManager.getCreatedOsAccountsCount((err, data)=>{ + console.debug("====>obtains the number accounts created err:" + JSON.stringify(err)); + console.debug("====>obtains the number accounts created data:" + data); + expect(err.code).assertEqual(0); + data = data - 1; + expect(data).assertEqual(obtainCount); + osAccountManager.removeOsAccount(localIdSec, (err)=>{ + console.debug("====>remove localId: " + localIdSec + " err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsOsAccountGetCount_0100 end===="); + done(); + }) + }) + }) + }) + }) + }) + }) + }) + + /* + * @tc.number : ActsOsAccountGetCount_0200 + * @tc.name : getCreatedOsAccountsCount promise + * @tc.desc : Verify to obtain the number os all os accounts created + */ + it('ActsOsAccountGetCount_0200', 0, async function (done) { + console.debug("====>ActsOsAccountGetCount_0200 start===="); + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + var obtainCount = await osAccountManager.getCreatedOsAccountsCount(); + console.debug("====>obtains the number of all os accounts created:" + obtainCount); + var osAccountFir = await osAccountManager.createOsAccount("osAccountIdSerialG", osaccount.OsAccountType.NORMAL); + console.debug("====>create first os account OsAccountInfo: " + JSON.stringify(osAccountFir)); + var localIdFir = osAccountFir.localId; + expect(osAccountFir.localName).assertEqual("osAccountIdSerialG"); + var osAccountSec = await osAccountManager.createOsAccount("osAccountIdSerialH", osaccount.OsAccountType.NORMAL); + console.debug("====>create second os account OsAccountInfo: " + JSON.stringify(osAccountSec)); + var localIdSec = osAccountSec.localId; + expect(osAccountSec.localName).assertEqual("osAccountIdSerialH"); + var countFir = await osAccountManager.getCreatedOsAccountsCount(); + console.debug("====>obtains the number of all os accounts created count:" + countFir); + countFir = countFir - 2; + expect(countFir).assertEqual(obtainCount); + await osAccountManager.removeOsAccount(localIdFir); + console.debug("====>remove localId: " + localIdFir); + var countSec = await osAccountManager.getCreatedOsAccountsCount(); + console.debug("====>obtains the number accounts created count:" + countSec); + countSec = countSec - 1; + expect(countSec).assertEqual(obtainCount); + await osAccountManager.removeOsAccount(localIdSec); + console.debug("====>remove localId: " + localIdSec); + console.debug("====>ActsOsAccountGetCount_0200 end===="); + done(); + }) + }) +} \ No newline at end of file diff --git a/account/osaccount/actsosaccountthirdpartytest/src/main/js/test/OsAccountIs.test.js b/account/osaccount/actsosaccountthirdpartytest/src/main/js/test/OsAccountIs.test.js new file mode 100755 index 0000000000000000000000000000000000000000..9f1904166e9acaf2ac7c210b39e4fc19468330bd --- /dev/null +++ b/account/osaccount/actsosaccountthirdpartytest/src/main/js/test/OsAccountIs.test.js @@ -0,0 +1,507 @@ +/* + * 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 osAccount from '@ohos.account.osAccount' +import distributedAccount from '@ohos.account.distributedAccount' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +const TIMEOUT = 1000; +const ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_ACTIVED_ERROR = 4587542; +const ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_VERIFIED_ERROR = 4587545; +export default function ActsOsAccountThirdPartyTest_third_1() { + describe('ActsOsAccountThirdPartyTest_third_1', function () { + + /* + * @tc.number : ActsOsAccountDeviceId_0100 + * @tc.name : getDistributedVirtualDeviceId callback + * @tc.desc : get distributed virtual device ID + */ + it('ActsOsAccountDeviceId_0100', 0, async function(done){ + console.debug("====>ActsOsAccountDeviceId_0100 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + const deviceId = '5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5'; + const accountAbility = distributedAccount.getDistributedAccountAbility(); + accountAbility.updateOsAccountDistributedInfo( + { + name: 'ZhangSan', + id: '12345', + event: "Ohos.account.event.LOGIN" + }, (err)=>{ + console.debug("====>update distributedInfo err:" + JSON.stringify(err)); + AccountManager.getDistributedVirtualDeviceId((err, id)=>{ + console.debug("====>getDistributedVirtualDeviceId err:" + JSON.stringify(err)); + console.debug("====>getDistributedVirtualDeviceId deviceId:" + id); + expect(err.code).assertEqual(0); + expect(id).assertEqual(deviceId); + console.debug("====>ActsOsAccountDeviceId_0100 end===="); + done(); + }) + }) + }) + + /* + * @tc.number : ActsOsAccountDeviceId_0200 + * @tc.name : getDistributedVirtualDeviceId promise + * @tc.desc : get distributed virtual device ID + */ + it('ActsOsAccountDeviceId_0200', 0, async function(done){ + console.debug("====>ActsOsAccountDeviceId_0200 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + const deviceId = '5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5'; + const accountAbility = distributedAccount.getDistributedAccountAbility(); + accountAbility.updateOsAccountDistributedInfo( + { + name: 'ZhangSan', + id: '12345', + event: "Ohos.account.event.LOGIN" + }, async (err)=>{ + console.debug("====>update distributedInfo err:" + JSON.stringify(err)); + console.debug("====>getDistributedVirtualDeviceId start===="); + var id = await AccountManager.getDistributedVirtualDeviceId(); + console.debug("====>getDistributedVirtualDeviceId:" + id); + expect(id).assertEqual(deviceId); + console.debug("====>ActsOsAccountDeviceId_0200 end===="); + done(); + }) + }) + + /* + * @tc.number : ActsOsAccountIsActived_0100 + * @tc.name : isOsAccountActived callback + * @tc.desc : Verify query 0 user status is true + */ + it('ActsOsAccountIsActived_0100', 0, async function(done){ + console.debug("====>ActsOsAccountIsActived_0100 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + AccountManager.isOsAccountActived(0, (err, isActived)=>{ + console.debug("====>isOsAccountActived err:" + JSON.stringify(err)); + console.debug("====>isOsAccountActived isActived:" + isActived); + expect(err.code).assertEqual(0); + expect(isActived).assertEqual(true); + console.debug("====>ActsOsAccountIsActived_0100 end"); + done(); + }) + }) + + /* + * @tc.number : ActsOsAccountIsActived_0200 + * @tc.name : isOsAccountActived promise + * @tc.desc : Verify query 0 user status is true + */ + it('ActsOsAccountIsActived_0200', 0, async function(done){ + console.debug("====>ActsOsAccountIsActived_0200 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + try{ + var isActived = await AccountManager.isOsAccountActived(0); + } + catch(err){ + console.debug("====>catch isOsAccountActived err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>isOsAccountActived:" + isActived); + expect(isActived).assertEqual(true); + console.debug("====>ActsOsAccountIsActived_0200 end"); + done(); + }) + + /* + * @tc.number : ActsOsAccountIsActived_0300 + * @tc.name : isOsAccountActived callback + * @tc.desc : Authentication failed to query the active status of the user that does not exist + */ + it('ActsOsAccountIsActived_0300', 0, async function(done){ + console.debug("====>ActsOsAccountIsActived_0300 start"); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + var nonExistLocalId = 1000; + AccountManager.isOsAccountActived(nonExistLocalId, (err)=>{ + console.debug("====>isOsAccountActived err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_ACTIVED_ERROR); + console.debug("====>ActsOsAccountIsActived_0300 end"); + done(); + }) + }) + + /* + * @tc.number : ActsOsAccountIsActived_0400 + * @tc.name : isOsAccountActived promise + * @tc.desc : Authentication failed to query the active status of the user that does not exist + */ + it('ActsOsAccountIsActived_0400', 0, async function(done){ + console.debug("====>ActsOsAccountIsActived_0400 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + var nonExistLocalId = 1000; + try{ + await AccountManager.isOsAccountActived(nonExistLocalId); + } + catch(err){ + console.debug("====>isOsAccountActived err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_ACTIVED_ERROR); + console.debug("====>ActsOsAccountIsActived_0400 end"); + done(); + } + }) + + /* + * @tc.number : ActsOsAccountIsActived_0500 + * @tc.name : isOsAccountActived callback + * @tc.desc : Verify that the query active state is not received with parameter type mismatch + */ + it('ActsOsAccountIsActived_0500', 0, async function(done){ + console.debug("====>ActsOsAccountIsActived_0500 start"); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + var localIdStr = "100"; + function funcIsActived(err, data){ + console.debug("====>error received callback===="); + console.debug("====>receive isOsAccountActived err: " + JSON.stringify(err)); + console.debug("====>receive isOsAccountActived data: " + JSON.stringify(data)); + expect().assertFail(); + done(); + } + AccountManager.isOsAccountActived(localIdStr, funcIsActived); + setTimeout(()=>{ + console.debug("====>ActsOsAccountIsActived_0500 end===="); + done(); + }, TIMEOUT); + }) + + /* + * @tc.number : ActsOsAccountIsActived_0600 + * @tc.name : isOsAccountActived promise + * @tc.desc : Verify that the query active state is not received with parameter type mismatch + */ + it('ActsOsAccountIsActived_0600', 0, async function(done){ + console.debug("====>ActsOsAccountIsActived_0600 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + var localIdStr = "100"; + var isActived = await AccountManager.isOsAccountActived(localIdStr); + console.debug("====>get active status is: " + isActived); + expect(isActived).assertEqual(null); + console.debug("====>ActsOsAccountIsActived_0600 end===="); + done(); + }) + + /* + * @tc.number : ActsOsAccountIsActived_0700 + * @tc.name : isOsAccountActived callback + * @tc.desc : Verify that the query active state is not received with parameter undefined + */ + it('ActsOsAccountIsActived_0700', 0, async function(done){ + console.debug("====>ActsOsAccountIsActived_0700 start"); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + function funcIsActived(err, data){ + console.debug("====>error received callback===="); + console.debug("====>receive isOsAccountActived err: " + JSON.stringify(err)); + console.debug("====>receive isOsAccountActived data: " + JSON.stringify(data)); + expect().assertFail(); + done(); + } + AccountManager.isOsAccountActived(undefined, funcIsActived); + setTimeout(()=>{ + console.debug("====>ActsOsAccountIsActived_0700 end===="); + done(); + }, TIMEOUT); + }) + + /* + * @tc.number : ActsOsAccountIsActived_0800 + * @tc.name : isOsAccountActived promise + * @tc.desc : Verify that the query active state is not received with parameter undefined + */ + it('ActsOsAccountIsActived_0800', 0, async function(done){ + console.debug("====>ActsOsAccountIsActived_0800 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + var isActived = await AccountManager.isOsAccountActived(undefined); + console.debug("====>get active status is: " + isActived); + expect(isActived).assertEqual(null); + console.debug("====>ActsOsAccountIsActived_0800 end===="); + done(); + }) + + /* + * @tc.number : ActsOsAccountIsMulty_0100 + * @tc.name : isMultiOsAccountEnable callback + * @tc.desc : Check whether the function of supporting multiple os account is enabled + */ + it('ActsOsAccountIsMulty_0100', 0, async function(done){ + console.debug("====>ActsOsAccountIsMulty_0100 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + AccountManager.isMultiOsAccountEnable((err, data)=>{ + console.debug("====>isMultiOsAccountEnable err:" + JSON.stringify(err)); + console.debug("====>isMultiOsAccountEnable data:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual(true); + console.debug("====>ActsOsAccountIsMulty_0100 end===="); + done(); + }) + }) + + /* + * @tc.number : ActsOsAccountIsMulty_0200 + * @tc.name : isMultiOsAccountEnable promise + * @tc.desc : Check whether the function of supporting multiple os account is enabled + */ + it('ActsOsAccountIsMulty_0200', 0, async function(done){ + console.debug("====>ActsOsAccountIsMulty_0200 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + try{ + var data = await AccountManager.isMultiOsAccountEnable(); + } + catch(err){ + console.debug("====>catch isMultiOsAccountEnable err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.debug("====>isMultiOsAccountEnable data:" + JSON.stringify(data)); + expect(data).assertEqual(true); + console.debug("====>ActsOsAccountIsMulty_0200 end===="); + done(); + }) + + /* + * @tc.number : ActsOsAccountVerified_0100 + * @tc.name : isOsAccountVerified callback + * @tc.desc : Verify that the initial state query is unlocked to false + */ + it('ActsOsAccountVerified_0100', 0, async function(done){ + console.debug("====>isOsAccountVerified_0100 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + AccountManager.isOsAccountVerified((err, data)=>{ + console.debug("====>isOsAccountVerified err:" + JSON.stringify(err)); + console.debug("====>isOsAccountVerified data:" + data); + expect(err.code).assertEqual(0); + expect(data).assertEqual(false); + console.debug("====>ActsOsAccountVerified_0100 end===="); + done(); + }) + }) + + /* + * @tc.number : ActsOsAccountVerified_0200 + * @tc.name : isOsAccountVerified promise + * @tc.desc : Verify that the initial state query is unlocked to false + */ + it('ActsOsAccountVerified_0200', 0, async function(done){ + console.debug("====>isOsAccountVerified_0200 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + var isVerified = await AccountManager.isOsAccountVerified(); + console.debug("====>isOsAccountVerified data:" + isVerified); + expect(isVerified).assertEqual(false); + console.debug("====>ActsOsAccountVerified_0200 end===="); + done(); + }) + + /* + * @tc.number : ActsOsAccountIsVerified_0300 + * @tc.name : isOsAccountVerified callback + * @tc.desc : Verify that the initial state query 0 user is unlocked to false + */ + it('ActsOsAccountIsVerified_0300', 0, async function(done){ + console.debug("====>ActsOsAccountIsVerified_0300 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + AccountManager.isOsAccountVerified(0, (err, data)=>{ + console.debug("====>isOsAccountVerified err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + expect(data).assertFalse(); + console.debug("====>ActsOsAccountIsVerified_0300 end===="); + done(); + }) + }) + + /* + * @tc.number : ActsOsAccountIsVerified_0400 + * @tc.name : isOsAccountVerified promise + * @tc.desc : Verify that the initial state query 0 user is unlocked to false + */ + it('ActsOsAccountIsVerified_0400', 0, async function(done){ + console.debug("====>ActsOsAccountIsVerified_0400 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + var isVerified = await AccountManager.isOsAccountVerified(0); + expect(isVerified).assertFalse(); + console.debug("====>ActsOsAccountIsVerified_0400 end===="); + done(); + }) + + /* + * @tc.number : ActsOsAccountIsVerified_0500 + * @tc.name : isOsAccountVerified callback + * @tc.desc : Verify query "100" user is unlocked failed + */ + it('ActsOsAccountIsVerified_0500', 0, async function(done){ + console.debug("====>ActsOsAccountIsVerified_0500 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + var localIdStr = "100"; + function funcIsVerified(err, data){ + console.debug("====>error received callback===="); + console.debug("====>receive isOsAccountVerified err: " + JSON.stringify(err)); + console.debug("====>receive isOsAccountVerified data: " + JSON.stringify(data)); + expect().assertFail(); + done(); + } + AccountManager.isOsAccountVerified(localIdStr, funcIsVerified); + setTimeout(()=>{ + console.debug("====>ActsOsAccountIsVerified_0500 end===="); + done(); + }, TIMEOUT); + }) + + /* + * @tc.number : ActsOsAccountIsVerified_0600 + * @tc.name : isOsAccountVerified promise + * @tc.desc : Verify query "100" user is unlocked failed + */ + it('ActsOsAccountIsVerified_0600', 0, async function(done){ + console.debug("====>ActsOsAccountIsVerified_0600 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + var localIdStr = "100"; + var isVerified = await AccountManager.isOsAccountVerified(localIdStr); + console.debug("====>get verified status is: " + isVerified); + expect(isVerified).assertEqual(null); + console.debug("====>ActsOsAccountIsVerified_0600 end===="); + done(); + }) + + /* + * @tc.number : ActsOsAccountIsVerified_0700 + * @tc.name : isOsAccountVerified callback + * @tc.desc : Verify query undefined user is unlocked failed + */ + it('ActsOsAccountIsVerified_0700', 0, async function(done){ + console.debug("====>ActsOsAccountIsVerified_0700 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + var localIdUndefined = undefined; + function funcIsVerified(err, data){ + console.debug("====>error received callback===="); + console.debug("====>receive isOsAccountVerified err: " + JSON.stringify(err)); + console.debug("====>receive isOsAccountVerified data: " + JSON.stringify(data)); + expect().assertFail(); + done(); + } + AccountManager.isOsAccountVerified(localIdUndefined, funcIsVerified); + setTimeout(()=>{ + console.debug("====>ActsOsAccountIsVerified_0700 end===="); + done(); + }, TIMEOUT); + }) + + /* + * @tc.number : ActsOsAccountIsVerified_0800 + * @tc.name : isOsAccountVerified promise + * @tc.desc : Verify query undefined user is unlocked failed + */ + it('ActsOsAccountIsVerified_0800', 0, async function(done){ + console.debug("====>ActsOsAccountIsVerified_0800 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + var localIdUndefined = undefined; + var isVerified = await AccountManager.isOsAccountVerified(localIdUndefined); + console.debug("====>get verified status is: " + isVerified); + expect(isVerified).assertEqual(null); + console.debug("====>ActsOsAccountIsVerified_0800 end===="); + done(); + }) + + /* + * @tc.number : ActsOsAccountIsVerified_0900 + * @tc.name : isOsAccountVerified callback + * @tc.desc : Verify query does not exist user unlock failed + */ + it('ActsOsAccountIsVerified_0900', 0, async function(done){ + console.debug("====>ActsOsAccountIsVerified_0900 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + var osAccountLocalId = 1000; + AccountManager.isOsAccountVerified(osAccountLocalId, (err)=>{ + console.debug("====>isOsAccountVerified err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_VERIFIED_ERROR); + console.debug("====>ActsOsAccountIsVerified_0900 end===="); + done(); + }) + }) + + /* + * @tc.number : ActsOsAccountIsVerified_1000 + * @tc.name : isOsAccountVerified promise + * @tc.desc : Verify query does not exist user unlock failed + */ + it('ActsOsAccountIsVerified_1000', 0, async function(done){ + console.debug("====>ActsOsAccountIsVerified_1000 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + var osAccountLocalId = 1000; + try{ + await AccountManager.isOsAccountVerified(osAccountLocalId); + } + catch(err){ + console.debug("====>isOsAccountVerified err:" + JSON.stringify(err)); + expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_VERIFIED_ERROR); + console.debug("====>ActsOsAccountIsVerified_1000 end===="); + done(); + } + }) + + /* + * @tc.number : ActsOsAccountIsTest_0100 + * @tc.name : isTestOsAccount callback + * @tc.desc : check whether this OS account is a test OS account + */ + it('ActsOsAccountIsTest_0100', 0, async function(done){ + console.debug("====>ActsOsAccountIsTest_0100 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + AccountManager.isTestOsAccount((err, data)=>{ + console.debug("====>isTestOsAccount err:" + JSON.stringify(err)); + console.debug("====>isTestOsAccount data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + expect(data).assertEqual(false); + console.debug("====>ActsOsAccountIsTest_0100 end===="); + done(); + }) + }) + + /* + * @tc.number : ActsOsAccountIsTest_0200 + * @tc.name : isTestOsAccount promise + * @tc.desc : check whether this OS account is a test OS account + */ + it('ActsOsAccountIsTest_0200', 0, async function(done){ + console.debug("====>ActsOsAccountIsTest_0200 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + var isTest = await AccountManager.isTestOsAccount(); + expect(isTest).assertFalse(); + console.debug("====>ActsOsAccountIsTest_0200 end===="); + done(); + }) + }) +} \ No newline at end of file diff --git a/account/osaccount/actsosaccountthirdpartytest/src/main/resources/base/element/string.json b/account/osaccount/actsosaccountthirdpartytest/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..5a685e30cae1638fb9c5fd966b9ab40b6b80b341 --- /dev/null +++ b/account/osaccount/actsosaccountthirdpartytest/src/main/resources/base/element/string.json @@ -0,0 +1,28 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ActsAccountTest" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/resources/base/media/icon.png b/account/osaccount/actsosaccountthirdpartytest/src/main/resources/base/media/icon.png similarity index 100% rename from account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/resources/base/media/icon.png rename to account/osaccount/actsosaccountthirdpartytest/src/main/resources/base/media/icon.png