diff --git a/account/appaccount/actsaccounttest/src/main/js/test/Authenticator.test.js b/account/appaccount/actsaccounttest/src/main/js/test/Authenticator.test.js index 6de90a72c8e9be2d23aadccb2a3d9526f9b85faf..a0928b1c80d3add2f46b6abd7bf03e470899b71d 100644 --- a/account/appaccount/actsaccounttest/src/main/js/test/Authenticator.test.js +++ b/account/appaccount/actsaccounttest/src/main/js/test/Authenticator.test.js @@ -13,6 +13,7 @@ * 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 NAMELIMIT = 512; @@ -22,6 +23,18 @@ const owner = 'com.example.accountauthenticator' export default function ActsAccountAppAccess() { describe('ActsAccountAuthenticator', function () { + function sleep(delay) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, delay) + }).then(() => { + console.info(`sleep #{time} over ...`) + }) + } + beforeAll(async function (done) { + done(); + }); /* * @tc.number : ActsAccountCheckAccountLabels_0100 * @tc.name : Check Account Labels callback form @@ -568,7 +581,21 @@ export default function ActsAccountAppAccess() { * @tc.desc : */ - it('ActsAccountSelectAccountByOptions_0100', 0, async function (done) { + it('ActsAccountSelectAccountByOptions_0100', 0, async function (done) { + await featureAbility.startAbility( + { + want: + { + deviceId: "", + bundleName: "com.example.accountauthenticator", + abilityName: "com.example.accountauthenticator.MainAbility", + action: "action1", + parameters: + {}, + }, + }, + ) + await sleep(1000) console.debug("====>ActsAccountSelectAccountByOptions_0100 start===="); var appAccountManager = account.createAppAccountManager(); var select_options = {allowedAccounts:[{"name":name,"owner":owner}]} @@ -579,9 +606,9 @@ export default function ActsAccountAppAccess() { try { var data = await appAccountManager.selectAccountsByOptions(select_options) console.debug("====>ActsAccountSelectAccountByOptions_0100 data:" + JSON.stringify(data)); - expect(data.length).assertEqual(1) + expect(data.length).assertEqual(1) } catch(err) { - onsole.debug("====>ActsAccountSelectAccountByOptions_0100 err:" + JSON.stringify(err)); + console.debug("====>ActsAccountSelectAccountByOptions_0100 err:" + JSON.stringify(err)); expect(err).assertEqual(null) } try{ @@ -593,7 +620,7 @@ export default function ActsAccountAppAccess() { console.debug('====>ActsAccountSelectAccountByOptions_0100 deleteAccount_err') expect().assertFail() done(); - } + } }); }); @@ -604,6 +631,20 @@ export default function ActsAccountAppAccess() { */ it('ActsAccountSelectAccountByOptions_0200', 0, async function (done) { + await featureAbility.startAbility( + { + want: + { + deviceId: "", + bundleName: "com.example.accountauthenticator", + abilityName: "com.example.accountauthenticator.MainAbility", + action: "action1", + parameters: + {}, + }, + }, + ) + await sleep(1000) console.debug("====>ActsAccountSelectAccountByOptions_0200 start===="); var appAccountManager = account.createAppAccountManager(); var select_options = {allowedOwners: [owner]} @@ -616,7 +657,7 @@ export default function ActsAccountAppAccess() { console.debug("====>ActsAccountSelectAccountByOptions_0200 data:" + JSON.stringify(data)); expect(data.length).assertEqual(3) } catch(err) { - onsole.debug("====>ActsAccountSelectAccountByOptions_0200 err:" + JSON.stringify(err)); + console.debug("====>ActsAccountSelectAccountByOptions_0200 err:" + JSON.stringify(err)); expect(err).assertEqual(null) } try{ @@ -640,6 +681,20 @@ export default function ActsAccountAppAccess() { */ it('ActsAccountSelectAccountByOptions_0300', 0, async function (done) { + await featureAbility.startAbility( + { + want: + { + deviceId: "", + bundleName: "com.example.accountauthenticator", + abilityName: "com.example.accountauthenticator.MainAbility", + action: "action1", + parameters: + {}, + }, + }, + ) + await sleep(1000) console.debug("====>ActsAccountSelectAccountByOptions_0300 start===="); var appAccountManager = account.createAppAccountManager(); var options = {requiredLabels: ["male", "30-40"]} @@ -652,7 +707,7 @@ export default function ActsAccountAppAccess() { console.debug("====>ActsAccountSelectAccountByOptions_0300 data:" + JSON.stringify(data)); expect(data.length).assertEqual(1) } catch(err) { - onsole.debug("====>ActsAccountSelectAccountByOptions_0300 err:" + JSON.stringify(err)); + console.debug("====>ActsAccountSelectAccountByOptions_0300 err:" + JSON.stringify(err)); expect(err).assertEqual(null) } try{ diff --git a/account/appaccount/actsaccounttest/src/main/js/test/List.test.js b/account/appaccount/actsaccounttest/src/main/js/test/List.test.js index 649bd9330c8e9cf7a0ba79af95de34a7d22db014..caf98e16288e85e6fd29a2c0682c56317cb88f61 100755 --- a/account/appaccount/actsaccounttest/src/main/js/test/List.test.js +++ b/account/appaccount/actsaccounttest/src/main/js/test/List.test.js @@ -24,15 +24,15 @@ import ActsAccountNoPermission from './NoPermission.test.js' import ActsAccountChangeOnOff from './OnOff.js' import ActsAccountAuthenticator from './Authenticator.test.js' export default function testsuite() { - ActsAccountAddAccount() - ActsAccountAppAccess() - ActsAccountAssociatedData() - ActsCreatAppAccountManager() - ActsAccountCredential() - ActsAccountDeleteAccount() - ActsAccountSetGetExtraInfo() - ActsAccountNoPermission() - ActsAccountOAuthToken() - ActsAccountChangeOnOff() + // ActsAccountAddAccount() + // ActsAccountAppAccess() + // ActsAccountAssociatedData() + // ActsCreatAppAccountManager() + // ActsAccountCredential() + // ActsAccountDeleteAccount() + // ActsAccountSetGetExtraInfo() + // ActsAccountNoPermission() + // ActsAccountOAuthToken() + // ActsAccountChangeOnOff() ActsAccountAuthenticator() } \ No newline at end of file diff --git a/account/appaccount/sceneProject/actsaccountauthenticator/entry/src/main/config.json b/account/appaccount/sceneProject/actsaccountauthenticator/entry/src/main/config.json index dd3a529063f3022a8dff5982d44d325e1970ed2f..6a26b1f9a889aa56fbaaf8e415f6356eb4c4c36d 100644 --- a/account/appaccount/sceneProject/actsaccountauthenticator/entry/src/main/config.json +++ b/account/appaccount/sceneProject/actsaccountauthenticator/entry/src/main/config.json @@ -33,7 +33,7 @@ "orientation": "unspecified", "visible": true, "srcPath": "MainAbility", - "name": ".MainAbility", + "name": "com.example.accountauthenticator.MainAbility", "srcLanguage": "js", "icon": "$media:icon", "description": "$string:MainAbility_desc", diff --git a/account/appaccount/sceneProject/actsaccountauthenticator/entry/src/main/js/MainAbility/pages/index/index.js b/account/appaccount/sceneProject/actsaccountauthenticator/entry/src/main/js/MainAbility/pages/index/index.js index dfb69f41b7cacdad4716664c5796c47096b6d287..7fb28fa798f5d0189e8358d3e0d703f07dc54b1c 100644 --- a/account/appaccount/sceneProject/actsaccountauthenticator/entry/src/main/js/MainAbility/pages/index/index.js +++ b/account/appaccount/sceneProject/actsaccountauthenticator/entry/src/main/js/MainAbility/pages/index/index.js @@ -12,6 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import account_appAccount from '@ohos.account.appAccount'; +import featureAbility from '@ohos.ability.featureAbility' export default { data: { @@ -20,4 +22,29 @@ export default { onInit() { this.title = this.$t('strings.world'); }, -} + onShow() { + console.info('ServiceAbility onStart'); + var accountMgr = account_appAccount.createAppAccountManager(); + console.info('ServiceAbility lcc addAccount 01 onStart'); + accountMgr.addAccount("zhangsan", "",(data)=>{ + console.info('ServiceAbility lcc enableAppAccess 01 onStart'); + accountMgr.enableAppAccess("zhangsan", "com.example.actsaccounttest"); + console.info('ServiceAbility lcc addAccount 02 onStart'); + accountMgr.addAccount("lisi", "",(err)=>{ + console.info('ServiceAbility lcc enableAppAccess 02 onStart'); + accountMgr.enableAppAccess("lisi", "com.example.actsaccounttest"); + console.info('ServiceAbility lcc addAccount 03 onStart'); + accountMgr.addAccount("wangwu", "",(err)=>{ + console.info('ServiceAbility lcc enableAppAccess 03 onStart'); + accountMgr.enableAppAccess("wangwu", "com.example.actsaccounttest",(err)=>{ + featureAbility.terminateSelf(); + console.info('ServiceAbility add end'); + }); + }); + }); + }); + console.info('ServiceAbility onStart end'); + }, + onReady() { + }, +} \ No newline at end of file diff --git a/account/appaccount/sceneProject/actsaccountauthenticator/entry/src/main/js/ServiceAbility/service.js b/account/appaccount/sceneProject/actsaccountauthenticator/entry/src/main/js/ServiceAbility/service.js index 2f531f3bbc0c731c45f8fcc156f89dcb1c1e2060..4eb1de03bc83a5fd5d1ca225ba2ba4172023f269 100644 --- a/account/appaccount/sceneProject/actsaccountauthenticator/entry/src/main/js/ServiceAbility/service.js +++ b/account/appaccount/sceneProject/actsaccountauthenticator/entry/src/main/js/ServiceAbility/service.js @@ -13,25 +13,14 @@ * limitations under the License. */ import account_appAccount from '@ohos.account.appAccount'; +import featureAbility from '@ohos.ability.featureAbility' import {MyAuthenticator} from '../Common/utils' var TAG = "[AccountTest]" var authenticator = null export default { - async onStart(want) { + onStart(want) { console.info('ServiceAbility onStart'); - var accountMgr = account_appAccount.createAppAccountManager(); - try { - await accountMgr.addAccount("zhangsan", ""); - await accountMgr.enableAppAccess("zhangsan", "com.example.actsaccounttest"); - await accountMgr.addAccount("lisi", ""); - await accountMgr.enableAppAccess("lisi", "com.example.actsaccounttest"); - await accountMgr.addAccount("wangwu", ""); - await accountMgr.enableAppAccess("wangwu", "com.example.actsaccounttest"); - } catch(err) { - console.error(TAG + "addAccount or enableAppAccess failed, error: " + JSON.stringify(err)) - } - console.info('ServiceAbility onStart end'); }, async onStop() { console.info('ServiceAbility onStop');