提交 eca76e80 编写于 作者: Z zhaoyuan17

Update xts account test 1213

Signed-off-by: Nzhaoyuan17 <zhaoyuan17@huawei.com>
上级 a8dd248a
...@@ -475,7 +475,7 @@ describe('ActsAccountOAuthToken', function () { ...@@ -475,7 +475,7 @@ describe('ActsAccountOAuthToken', function () {
* @tc.desc : Obtain the oauth token after clearing the unset oauth token * @tc.desc : Obtain the oauth token after clearing the unset oauth token
*/ */
it('ActsAccountOAuthToken_1800', 0, async function (done) { it('ActsAccountOAuthToken_1800', 0, async function (done) {
console.debug("====>ActsAccountOAuthToken_1200 start===="); console.debug("====>ActsAccountOAuthToken_1800 start====");
var appAccountManager = account.createAppAccountManager(); var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish===="); console.debug("====>creat finish====");
console.debug("====>add account ActsAccountOAuthToken_1800 start===="); console.debug("====>add account ActsAccountOAuthToken_1800 start====");
...@@ -609,7 +609,7 @@ describe('ActsAccountOAuthToken', function () { ...@@ -609,7 +609,7 @@ describe('ActsAccountOAuthToken', function () {
var data = await appAccountManager.getOAuthToken("accountToken_promise_empty"); var data = await appAccountManager.getOAuthToken("accountToken_promise_empty");
expect(data).assertEqual(""); expect(data).assertEqual("");
await appAccountManager.deleteAccount("accountToken_promise_empty"); await appAccountManager.deleteAccount("accountToken_promise_empty");
console.debug("====>ActsAccountOAuthToken_2000 end===="); console.debug("====>ActsAccountOAuthToken_2200 end====");
done(); done();
}); });
...@@ -773,7 +773,7 @@ describe('ActsAccountOAuthToken', function () { ...@@ -773,7 +773,7 @@ describe('ActsAccountOAuthToken', function () {
console.debug("====>creat finish===="); console.debug("====>creat finish====");
console.debug("====>add account ActsAccountOAuthToken_2800 start===="); console.debug("====>add account ActsAccountOAuthToken_2800 start====");
await appAccountManager.addAccount("accountToken_promise_limit"); await appAccountManager.addAccount("accountToken_promise_limit");
console.debug("====>setOAuthToken 2400 start===="); console.debug("====>setOAuthToken 2800 start====");
await appAccountManager.setOAuthToken("accountToken_promise_limit", tokenLimit); await appAccountManager.setOAuthToken("accountToken_promise_limit", tokenLimit);
console.debug("====>getOAuthToken ActsAccountOAuthToken_2800 start===="); console.debug("====>getOAuthToken ActsAccountOAuthToken_2800 start====");
var data = await appAccountManager.getOAuthToken("accountToken_promise_limit"); var data = await appAccountManager.getOAuthToken("accountToken_promise_limit");
...@@ -795,7 +795,7 @@ describe('ActsAccountOAuthToken', function () { ...@@ -795,7 +795,7 @@ describe('ActsAccountOAuthToken', function () {
appAccountManager.clearOAuthToken("", (err)=>{ appAccountManager.clearOAuthToken("", (err)=>{
console.debug("====>clearOAuthToken 2900 err:" + JSON.stringify(err)); console.debug("====>clearOAuthToken 2900 err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true); expect(err.code != 0).assertEqual(true);
console.debug("====>ActsAccountOAuthToken_1900 end===="); console.debug("====>ActsAccountOAuthToken_2900 end====");
done(); done();
}); });
}); });
......
...@@ -16,10 +16,10 @@ import account from '@ohos.account.appAccount' ...@@ -16,10 +16,10 @@ import account from '@ohos.account.appAccount'
import featureAbility from '@ohos.ability.featureability' import featureAbility from '@ohos.ability.featureability'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const TIMEOUT = 3000; const TIMEOUT = 5000;
describe('ActsGetAllAccessibleMultiple', function () { describe('ActsGetAllAccessibleMultiple', function () {
beforeAll(async function (done) { beforeAll(async function (done) {
console.debug("====>startAbility first 0100 start===="); console.debug("====>startAbility first start====");
await featureAbility.startAbility( await featureAbility.startAbility(
{ {
want: want:
...@@ -33,9 +33,17 @@ describe('ActsGetAllAccessibleMultiple', function () { ...@@ -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.number : ActsGetAllAccessibleMultiple_0100
* @tc.name : getAllAccessibleAccounts * @tc.name : getAllAccessibleAccounts
...@@ -44,6 +52,7 @@ describe('ActsGetAllAccessibleMultiple', function () { ...@@ -44,6 +52,7 @@ describe('ActsGetAllAccessibleMultiple', function () {
*/ */
it('ActsGetAllAccessibleMultiple_0100', 0, async function (done) { it('ActsGetAllAccessibleMultiple_0100', 0, async function (done) {
console.debug("====>ActsGetAllAccessibleMultiple_0100 start===="); console.debug("====>ActsGetAllAccessibleMultiple_0100 start====");
let dataMap = new Map();
var appAccountManager = account.createAppAccountManager(); var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish===="); console.debug("====>creat finish====");
console.debug("====>add first account 0100 start===="); console.debug("====>add first account 0100 start====");
...@@ -52,21 +61,6 @@ describe('ActsGetAllAccessibleMultiple', function () { ...@@ -52,21 +61,6 @@ describe('ActsGetAllAccessibleMultiple', function () {
await appAccountManager.addAccount("accessibleAccount_this_application_second"); await appAccountManager.addAccount("accessibleAccount_this_application_second");
console.debug("====>add third account 0100 start===="); console.debug("====>add third account 0100 start====");
await appAccountManager.addAccount("accessibleAccount_this_application_third"); 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===="); console.debug("====>getAllAccessibleAccounts 0100 start====");
try{ try{
var data = await appAccountManager.getAllAccessibleAccounts(); var data = await appAccountManager.getAllAccessibleAccounts();
...@@ -78,33 +72,57 @@ describe('ActsGetAllAccessibleMultiple', function () { ...@@ -78,33 +72,57 @@ describe('ActsGetAllAccessibleMultiple', function () {
} }
console.debug("====>getAllAccessibleAccounts 0100 data:" + JSON.stringify(data)); console.debug("====>getAllAccessibleAccounts 0100 data:" + JSON.stringify(data));
expect(data.length).assertEqual(7); expect(data.length).assertEqual(7);
try{ console.debug("====>data.length:" + data.length);
expect(data[0].name).assertEqual("account_name_scene_first_first"); for (let i = 0, len = data.length; i < len; i++) {
expect(data[0].owner).assertEqual("com.example.actsaccountaccessiblefirst"); dataMap.set(data[i].name, data[i].owner)
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){ expect(dataMap.has("account_name_scene_first_first")).assertTrue();
console.error("====>check data 0100 fail err:" + JSON.stringify(err)); if (dataMap.has("account_name_scene_first_first")) {
expect().assertFail(); let data = dataMap.get("account_name_scene_first_first");
done(); 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 0100 start===="); console.debug("====>delete account start====");
await appAccountManager.deleteAccount("accessibleAccount_this_application_first"); await appAccountManager.deleteAccount("accessibleAccount_this_application_first");
await appAccountManager.deleteAccount("accessibleAccount_this_application_second"); await appAccountManager.deleteAccount("accessibleAccount_this_application_second");
await appAccountManager.deleteAccount("accessibleAccount_this_application_third"); await appAccountManager.deleteAccount("accessibleAccount_this_application_third");
console.debug("====>ActsGetAllAccessibleAccounts_0100 end===="); console.debug("====>ActsGetAllAccessibleAccounts_0100 end====");
done(); done();
}, TIMEOUT);
}); });
}) })
\ No newline at end of file
...@@ -38,10 +38,20 @@ export default { ...@@ -38,10 +38,20 @@ export default {
console.debug("====>add second account err:" + JSON.stringify(err)); console.debug("====>add second account err:" + JSON.stringify(err));
appAccountManager.enableAppAccess("account_name_scene_first_second", enableBundle, (err)=>{ appAccountManager.enableAppAccess("account_name_scene_first_second", enableBundle, (err)=>{
console.debug("====>enableAppAccess second account err:" + JSON.stringify(err)); console.debug("====>enableAppAccess second account err:" + JSON.stringify(err));
featureAbility.terminateSelf( console.debug("====>startAbility second start====");
(err, data)=>{ featureAbility.startAbility(
console.debug('====>Terminate Ability Success====') {
}); want:
{
deviceId: "",
bundleName: "com.example.actsaccountaccessiblesecond",
abilityName: "com.example.actsaccountaccessiblesecond.MainAbility",
action: "action1",
parameters:
{},
},
}
);
}) })
}) })
}) })
......
...@@ -24,6 +24,13 @@ export default { ...@@ -24,6 +24,13 @@ export default {
this.title = "scene accessible second application"; this.title = "scene accessible second application";
}, },
onShow() { onShow() {
function sleep(delay) {
var start = (new Date()).getTime();
while((new Date()).getTime() - start < delay) {
continue;
}
}
console.debug('====>scene accessible second application start===='); console.debug('====>scene accessible second application start====');
var appAccountManager = account.createAppAccountManager(); var appAccountManager = account.createAppAccountManager();
console.debug("====>creat second scene manager finish===="); console.debug("====>creat second scene manager finish====");
...@@ -37,6 +44,7 @@ export default { ...@@ -37,6 +44,7 @@ export default {
console.debug("====>add second account err:" + JSON.stringify(err)); console.debug("====>add second account err:" + JSON.stringify(err));
appAccountManager.enableAppAccess("account_name_scene_second_second", enableBundle, (err)=>{ appAccountManager.enableAppAccess("account_name_scene_second_second", enableBundle, (err)=>{
console.debug("====>enableAppAccess second account err:" + JSON.stringify(err)); console.debug("====>enableAppAccess second account err:" + JSON.stringify(err));
sleep(3000);
featureAbility.terminateSelf( featureAbility.terminateSelf(
(err, data)=>{ (err, data)=>{
console.debug('====>Terminate Ability Success====') console.debug('====>Terminate Ability Success====')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册