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 index 4b39db2c7fea5da65f4edb6057d6d510a50e75fd..d140986b2a3b3eb11512077f0e582b10a2f58798 100755 --- a/account/appaccount/actsaccounttest/entry/src/main/js/test/OAuthToken.test.js +++ b/account/appaccount/actsaccounttest/entry/src/main/js/test/OAuthToken.test.js @@ -475,7 +475,7 @@ describe('ActsAccountOAuthToken', function () { * @tc.desc : Obtain the oauth token after clearing the unset oauth token */ it('ActsAccountOAuthToken_1800', 0, async function (done) { - console.debug("====>ActsAccountOAuthToken_1200 start===="); + console.debug("====>ActsAccountOAuthToken_1800 start===="); var appAccountManager = account.createAppAccountManager(); console.debug("====>creat finish===="); console.debug("====>add account ActsAccountOAuthToken_1800 start===="); @@ -609,7 +609,7 @@ describe('ActsAccountOAuthToken', function () { var data = await appAccountManager.getOAuthToken("accountToken_promise_empty"); expect(data).assertEqual(""); await appAccountManager.deleteAccount("accountToken_promise_empty"); - console.debug("====>ActsAccountOAuthToken_2000 end===="); + console.debug("====>ActsAccountOAuthToken_2200 end===="); done(); }); @@ -773,7 +773,7 @@ describe('ActsAccountOAuthToken', function () { console.debug("====>creat finish===="); console.debug("====>add account ActsAccountOAuthToken_2800 start===="); await appAccountManager.addAccount("accountToken_promise_limit"); - console.debug("====>setOAuthToken 2400 start===="); + console.debug("====>setOAuthToken 2800 start===="); await appAccountManager.setOAuthToken("accountToken_promise_limit", tokenLimit); console.debug("====>getOAuthToken ActsAccountOAuthToken_2800 start===="); var data = await appAccountManager.getOAuthToken("accountToken_promise_limit"); @@ -795,7 +795,7 @@ describe('ActsAccountOAuthToken', function () { appAccountManager.clearOAuthToken("", (err)=>{ console.debug("====>clearOAuthToken 2900 err:" + JSON.stringify(err)); expect(err.code != 0).assertEqual(true); - console.debug("====>ActsAccountOAuthToken_1900 end===="); + console.debug("====>ActsAccountOAuthToken_2900 end===="); done(); }); }); 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 index ff650ef2fefec4481c7805a9b669858ef7491d7b..a044de06bc74a4dbe22b785689a35a0a3b7324ac 100755 --- 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 @@ -16,10 +16,10 @@ import account from '@ohos.account.appAccount' import featureAbility from '@ohos.ability.featureability' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' -const TIMEOUT = 3000; +const TIMEOUT = 5000; describe('ActsGetAllAccessibleMultiple', function () { beforeAll(async function (done) { - console.debug("====>startAbility first 0100 start===="); + console.debug("====>startAbility first start===="); await featureAbility.startAbility( { want: @@ -33,9 +33,17 @@ describe('ActsGetAllAccessibleMultiple', function () { }, }, ); - setTimeout(done(), 5000); + 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 @@ -44,6 +52,7 @@ describe('ActsGetAllAccessibleMultiple', function () { */ 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===="); @@ -52,59 +61,68 @@ describe('ActsGetAllAccessibleMultiple', function () { await appAccountManager.addAccount("accessibleAccount_this_application_second"); console.debug("====>add third account 0100 start===="); await appAccountManager.addAccount("accessibleAccount_this_application_third"); - console.debug("====>startAbility second 0100 start===="); - await featureAbility.startAbility( - { - want: - { - deviceId: "", - bundleName: "com.example.actsaccountaccessiblesecond", - abilityName: "com.example.actsaccountaccessiblesecond.MainAbility", - action: "action1", - parameters: - {}, - }, - } - ); - setTimeout(async function(){ - console.debug("====>getAllAccessibleAccounts 0100 start===="); - try{ - var data = await appAccountManager.getAllAccessibleAccounts(); - } - catch(err){ - console.error("====>getAllAccessibleAccounts 0100 fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>getAllAccessibleAccounts 0100 data:" + JSON.stringify(data)); - expect(data.length).assertEqual(7); - try{ - expect(data[0].name).assertEqual("account_name_scene_first_first"); - expect(data[0].owner).assertEqual("com.example.actsaccountaccessiblefirst"); - expect(data[1].name).assertEqual("account_name_scene_first_second"); - expect(data[1].owner).assertEqual("com.example.actsaccountaccessiblefirst"); - expect(data[2].name).assertEqual("account_name_scene_second_first"); - expect(data[2].owner).assertEqual("com.example.actsaccountaccessiblesecond"); - expect(data[3].name).assertEqual("account_name_scene_second_second"); - expect(data[3].owner).assertEqual("com.example.actsaccountaccessiblesecond"); - expect(data[4].name).assertEqual("accessibleAccount_this_application_first"); - expect(data[4].owner).assertEqual("com.example.actsgetallaccessiblemultiple"); - expect(data[5].name).assertEqual("accessibleAccount_this_application_second"); - expect(data[5].owner).assertEqual("com.example.actsgetallaccessiblemultiple"); - expect(data[6].name).assertEqual("accessibleAccount_this_application_third"); - expect(data[6].owner).assertEqual("com.example.actsgetallaccessiblemultiple"); - } - catch(err){ - console.error("====>check data 0100 fail err:" + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.debug("====>delete account 0100 start===="); - await appAccountManager.deleteAccount("accessibleAccount_this_application_first"); - await appAccountManager.deleteAccount("accessibleAccount_this_application_second"); - await appAccountManager.deleteAccount("accessibleAccount_this_application_third"); - console.debug("====>ActsGetAllAccessibleAccounts_0100 end===="); + 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(); - }, TIMEOUT); + } + 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/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/default/pages/index/index.js b/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/default/pages/index/index.js index f8be6e7a9c4fa98d46c83bb32a991e3577cb4998..7275bde5c5e15051f038f759b474f28645e45b84 100755 --- a/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/default/pages/index/index.js +++ b/account/appaccount/sceneProject/actsaccountaccessibleFirst/entry/src/main/js/default/pages/index/index.js @@ -38,10 +38,20 @@ export default { console.debug("====>add second account err:" + JSON.stringify(err)); appAccountManager.enableAppAccess("account_name_scene_first_second", enableBundle, (err)=>{ console.debug("====>enableAppAccess second account err:" + JSON.stringify(err)); - featureAbility.terminateSelf( - (err, data)=>{ - console.debug('====>Terminate Ability Success====') - }); + console.debug("====>startAbility second start===="); + featureAbility.startAbility( + { + want: + { + deviceId: "", + bundleName: "com.example.actsaccountaccessiblesecond", + abilityName: "com.example.actsaccountaccessiblesecond.MainAbility", + action: "action1", + parameters: + {}, + }, + } + ); }) }) }) diff --git a/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/default/pages/index/index.js b/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/default/pages/index/index.js index 3c2f93f24017b7c035bbf1c85cc65397088b0f72..6e4591a430de8aa264a4a6eda34735ec60fdb9aa 100755 --- a/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/default/pages/index/index.js +++ b/account/appaccount/sceneProject/actsaccountaccessibleSecond/entry/src/main/js/default/pages/index/index.js @@ -24,6 +24,13 @@ export default { this.title = "scene accessible second application"; }, onShow() { + function sleep(delay) { + var start = (new Date()).getTime(); + while((new Date()).getTime() - start < delay) { + continue; + } + } + console.debug('====>scene accessible second application start===='); var appAccountManager = account.createAppAccountManager(); console.debug("====>creat second scene manager finish===="); @@ -37,6 +44,7 @@ export default { console.debug("====>add second account err:" + JSON.stringify(err)); appAccountManager.enableAppAccess("account_name_scene_second_second", enableBundle, (err)=>{ console.debug("====>enableAppAccess second account err:" + JSON.stringify(err)); + sleep(3000); featureAbility.terminateSelf( (err, data)=>{ console.debug('====>Terminate Ability Success====')