未验证 提交 201b77cf 编写于 作者: O openharmony_ci 提交者: Gitee

!8199 【account】【OpenHarmony-3.2-Release】setTimeout内存泄露

Merge pull request !8199 from 郭永强/324haha
...@@ -20,29 +20,6 @@ const EACHTIMEOUT = 500; ...@@ -20,29 +20,6 @@ const EACHTIMEOUT = 500;
const ERR_JS_CREDENTIAL_NOT_EXIST = 12300102; const ERR_JS_CREDENTIAL_NOT_EXIST = 12300102;
export default function ActsAppAccountCredential() { export default function ActsAppAccountCredential() {
describe('ActsAppAccountCredential', function () { describe('ActsAppAccountCredential', 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 : ActsAppAccountCredential_0100 * @tc.number : ActsAppAccountCredential_0100
* @tc.name : The correct calls setAssociatedData and getCredential get the credential * @tc.name : The correct calls setAssociatedData and getCredential get the credential
......
...@@ -15,26 +15,8 @@ ...@@ -15,26 +15,8 @@
import account from '@ohos.account.appAccount' import account from '@ohos.account.appAccount'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
const TIMEOUT = 5000;
export default function ActsAccountManager() { export default function ActsAccountManager() {
describe('ActsAccountManager', function () { describe('ActsAccountManager', 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 : ActsAccountManager_0100 * @tc.number : ActsAccountManager_0100
* @tc.name : createAppAccountManager * @tc.name : createAppAccountManager
......
...@@ -19,9 +19,6 @@ import featureAbility from '@ohos.ability.featureAbility' ...@@ -19,9 +19,6 @@ import featureAbility from '@ohos.ability.featureAbility'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import {AccountErrCode} from './AccountErrCode.test.js' import {AccountErrCode} from './AccountErrCode.test.js'
const TIMEOUT = 1000;
const EACHTIMEOUT = 500;
const LENGTHLIMIT = 512; const LENGTHLIMIT = 512;
const TOKENLENGTHLIMIT = 1024; const TOKENLENGTHLIMIT = 1024;
const AUTHTYPELENGTHLIMIT = 1024; const AUTHTYPELENGTHLIMIT = 1024;
...@@ -30,28 +27,6 @@ const ERR_JS_AUTH_TYPE_NOT_FOUND = 12300107; ...@@ -30,28 +27,6 @@ const ERR_JS_AUTH_TYPE_NOT_FOUND = 12300107;
const OWNERSELF = "com.example.actsaccountoperatetest"; const OWNERSELF = "com.example.actsaccountoperatetest";
export default function ActsAccountAuthToken() { export default function ActsAccountAuthToken() {
describe('ActsAccountAuthToken', function () { describe('ActsAccountAuthToken', 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.number : testGetEntriesString101
......
...@@ -23,16 +23,6 @@ const owner = 'com.example.accountauthenticator' ...@@ -23,16 +23,6 @@ const owner = 'com.example.accountauthenticator'
const createAccountOptions = {customData:{age:'12'}} const createAccountOptions = {customData:{age:'12'}}
export default function ActsAccountAppAccess() { export default function ActsAccountAppAccess() {
describe('ActsAccountAuthenticator', function () { describe('ActsAccountAuthenticator', function () {
function sleep(delay) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve()
}, delay)
}).then(() => {
console.info(`sleep #{time} over ...`)
})
}
beforeAll(async function (done) { beforeAll(async function (done) {
console.debug("====>ActsAccountAuthenticator beforeAll start===="); console.debug("====>ActsAccountAuthenticator beforeAll start====");
await featureAbility.startAbilityForResult( await featureAbility.startAbilityForResult(
...@@ -167,6 +157,8 @@ export default function ActsAccountAppAccess() { ...@@ -167,6 +157,8 @@ export default function ActsAccountAppAccess() {
done(); done();
}).catch((err) =>{ }).catch((err) =>{
console.debug("====>ActsAccountCheckAccountLabels_0400 delete_account_err"); console.debug("====>ActsAccountCheckAccountLabels_0400 delete_account_err");
expect().assertFail();
done();
}); });
}).catch((err) =>{ }).catch((err) =>{
console.debug("====>ActsAccountCheckAccountLabels_0400 err:" + JSON.stringify(err)) console.debug("====>ActsAccountCheckAccountLabels_0400 err:" + JSON.stringify(err))
...@@ -197,10 +189,12 @@ export default function ActsAccountAppAccess() { ...@@ -197,10 +189,12 @@ export default function ActsAccountAppAccess() {
expect(account.Constants.KEY_BOOLEAN_RESULT).assertEqual('booleanResult') expect(account.Constants.KEY_BOOLEAN_RESULT).assertEqual('booleanResult')
appAccountManager.removeAccount(name).then((data) =>{ appAccountManager.removeAccount(name).then((data) =>{
console.debug("====>ActsAccountCheckAccountLabels_0500 delete_account_success"); console.debug("====>ActsAccountCheckAccountLabels_0500 delete_account_success");
done();
}).catch((err) =>{ }).catch((err) =>{
console.debug("====>ActsAccountCheckAccountLabels_0500 delete_account_err"); console.debug("====>ActsAccountCheckAccountLabels_0500 delete_account_err");
expect().assertFail();
done();
}); });
done()
}).catch((err) =>{ }).catch((err) =>{
console.debug("====>ActsAccountCheckAccountLabels_0500 err:" + JSON.stringify(err)) console.debug("====>ActsAccountCheckAccountLabels_0500 err:" + JSON.stringify(err))
expect(typeof(err) != undefined).assertTrue(); expect(typeof(err) != undefined).assertTrue();
...@@ -228,10 +222,12 @@ export default function ActsAccountAppAccess() { ...@@ -228,10 +222,12 @@ export default function ActsAccountAppAccess() {
console.debug("====>ActsAccountCheckAccountLabels_0600 data:" + JSON.stringify(data)); console.debug("====>ActsAccountCheckAccountLabels_0600 data:" + JSON.stringify(data));
appAccountManager.removeAccount('CheckAccountLabels_0600').then((data) =>{ appAccountManager.removeAccount('CheckAccountLabels_0600').then((data) =>{
console.debug("====>ActsAccountCheckAccountLabels_0600 delete_account_success"); console.debug("====>ActsAccountCheckAccountLabels_0600 delete_account_success");
done();
}).catch((err) =>{ }).catch((err) =>{
console.debug("====>ActsAccountCheckAccountLabels_0600 delete_account_err"); console.debug("====>ActsAccountCheckAccountLabels_0600 delete_account_err");
expect().assertFail();
done();
}); });
done()
}).catch((err) =>{ }).catch((err) =>{
console.debug("====>ActsAccountCheckAccountLabels_0600 err:" + JSON.stringify(err)) console.debug("====>ActsAccountCheckAccountLabels_0600 err:" + JSON.stringify(err))
expect().assertFail(); expect().assertFail();
...@@ -271,19 +267,19 @@ export default function ActsAccountAppAccess() { ...@@ -271,19 +267,19 @@ export default function ActsAccountAppAccess() {
appAccountManager.setAppAccess(name, owner, false, (err, data) =>{ appAccountManager.setAppAccess(name, owner, false, (err, data) =>{
console.debug("====>ActsAccountCheckAppAccess_0100 disableAppAccount_err:" + JSON.stringify(err)); console.debug("====>ActsAccountCheckAppAccess_0100 disableAppAccount_err:" + JSON.stringify(err));
expect(err).assertEqual(null); expect(err).assertEqual(null);
appAccountManager.checkAppAccess(name, owner,(err, data)=>{ appAccountManager.checkAppAccess(name, owner, async (err, data)=>{
console.debug("====>ActsAccountCheckAppAccess_0100 third_err:" + JSON.stringify(err)) console.debug("====>ActsAccountCheckAppAccess_0100 third_err:" + JSON.stringify(err))
expect(err).assertEqual(null) expect(err).assertEqual(null)
expect(data).assertEqual(false) expect(data).assertEqual(false)
try { try {
appAccountManager.removeAccount(name) await appAccountManager.removeAccount(name)
console.debug('====>ActsAccountCheckAppAccess_0100 removeAccount_success') console.debug('====>ActsAccountCheckAppAccess_0100 removeAccount_success')
done();
} }
catch{ catch{
console.debug('====>ActsAccountCheckAppAccess_0100 removeAccount_err') console.debug('====>ActsAccountCheckAppAccess_0100 removeAccount_err')
expect().assertFail() expect().assertFail()
} }
done();
}) })
}) })
...@@ -315,18 +311,18 @@ export default function ActsAccountAppAccess() { ...@@ -315,18 +311,18 @@ export default function ActsAccountAppAccess() {
expect(data).assertEqual(true); expect(data).assertEqual(true);
appAccountManager.setAppAccess(name, owner, false).then((data)=>{ appAccountManager.setAppAccess(name, owner, false).then((data)=>{
console.debug("====>ActsAccountCheckAppAccess_0200 disabAppAccess_data:" + JSON.stringify(data)); console.debug("====>ActsAccountCheckAppAccess_0200 disabAppAccess_data:" + JSON.stringify(data));
appAccountManager.checkAppAccess(name, owner).then((data) =>{ appAccountManager.checkAppAccess(name, owner).then(async (data) =>{
console.debug("====>ActsAccountCheckAppAccess_0200 third_data:" + JSON.stringify(data)); console.debug("====>ActsAccountCheckAppAccess_0200 third_data:" + JSON.stringify(data));
expect(data).assertEqual(false); expect(data).assertEqual(false);
try{ try{
appAccountManager.removeAccount(name) await appAccountManager.removeAccount(name)
console.debug('====>ActsAccountCheckAppAccess_0200 removeAccount_success') console.debug('====>ActsAccountCheckAppAccess_0200 removeAccount_success')
done();
} }
catch{ catch{
console.debug('====>ActsAccountCheckAppAccess_0100 removeAccount_err') console.debug('====>ActsAccountCheckAppAccess_0100 removeAccount_err')
expect().assertFail() expect().assertFail()
} }
done();
}).catch((err)=>{ }).catch((err)=>{
console.debug("====>ActsAccountCheckAppAccess_0200 third_err:" + JSON.stringify(err)); console.debug("====>ActsAccountCheckAppAccess_0200 third_err:" + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
...@@ -381,21 +377,20 @@ export default function ActsAccountAppAccess() { ...@@ -381,21 +377,20 @@ export default function ActsAccountAppAccess() {
console.debug("====>ActsAccountDeleteCredential_0100 getAccountCredential_err:" + JSON.stringify(err)) console.debug("====>ActsAccountDeleteCredential_0100 getAccountCredential_err:" + JSON.stringify(err))
expect(err).assertEqual(null); expect(err).assertEqual(null);
console.debug("====>ActsAccountDeleteCredential_0100 getAccountCredential_success:" + JSON.stringify(data)); console.debug("====>ActsAccountDeleteCredential_0100 getAccountCredential_success:" + JSON.stringify(data));
appAccountManager.deleteCredential(name, "PIN", (err, data)=>{ appAccountManager.deleteCredential(name, "PIN", async (err, data)=>{
console.debug("====>ActsAccountDeleteCredential_0100 deleteCredential_err:" + JSON.stringify(err)); console.debug("====>ActsAccountDeleteCredential_0100 deleteCredential_err:" + JSON.stringify(err));
expect(err).assertEqual(null); expect(err).assertEqual(null);
console.debug("====>ActsAccountDeleteCredential_0100 deleteCredential_data:" + JSON.stringify(data)); console.debug("====>ActsAccountDeleteCredential_0100 deleteCredential_data:" + JSON.stringify(data));
expect(data).assertEqual(null); expect(data).assertEqual(null);
try{ try{
appAccountManager.removeAccount(name) await appAccountManager.removeAccount(name)
console.debug('====>ActsAccountDeleteCredential_0100 removeAccount_success') console.debug('====>ActsAccountDeleteCredential_0100 removeAccount_success')
done();
} }
catch{ catch{
console.debug('====>ActsAccountDeleteCredential_0100 removeAccount_err') console.debug('====>ActsAccountDeleteCredential_0100 removeAccount_err')
expect().assertFail() expect().assertFail()
done(); }
} done();
}) })
}) })
}); });
...@@ -417,17 +412,17 @@ export default function ActsAccountAppAccess() { ...@@ -417,17 +412,17 @@ export default function ActsAccountAppAccess() {
console.debug("====>ActsAccountDeleteCredential_0200 setAccountCredential_success"); console.debug("====>ActsAccountDeleteCredential_0200 setAccountCredential_success");
appAccountManager.getCredential(name, "PIN").then((data) =>{ appAccountManager.getCredential(name, "PIN").then((data) =>{
console.debug("====>ActsAccountDeleteCredential_0200 getAccountCredential_data:" + JSON.stringify(data)); console.debug("====>ActsAccountDeleteCredential_0200 getAccountCredential_data:" + JSON.stringify(data));
appAccountManager.deleteCredential(name, "PIN").then((data) =>{ appAccountManager.deleteCredential(name, "PIN").then(async (data) =>{
console.debug("====>ActsAccountDeleteCredential_0200 data:" + JSON.stringify(data)); console.debug("====>ActsAccountDeleteCredential_0200 data:" + JSON.stringify(data));
try{ try{
appAccountManager.removeAccount(name) await appAccountManager.removeAccount(name)
console.debug('====>ActsAccountDeleteCredential_0200 removeAccount_success') console.debug('====>ActsAccountDeleteCredential_0200 removeAccount_success')
done();
} }
catch{ catch{
console.debug('====>ActsAccountDeleteCredential_0200 removeAccount_err') console.debug('====>ActsAccountDeleteCredential_0200 removeAccount_err')
expect().assertFail() expect().assertFail()
} }
done();
}).catch((err) =>{ }).catch((err) =>{
console.debug("====>ActsAccountDeleteCredential_0200 err:" + JSON.stringify(err)); console.debug("====>ActsAccountDeleteCredential_0200 err:" + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
...@@ -473,12 +468,10 @@ export default function ActsAccountAppAccess() { ...@@ -473,12 +468,10 @@ export default function ActsAccountAppAccess() {
try{ try{
await appAccountManager.removeAccount(name) await appAccountManager.removeAccount(name)
console.debug('====>ActsAccountVerifyCredential_0100 removeAccount_success') console.debug('====>ActsAccountVerifyCredential_0100 removeAccount_success')
done(); } catch{
}
catch{
console.debug('====>ActsAccountVerifyCredential_0100 removeAccount_err') console.debug('====>ActsAccountVerifyCredential_0100 removeAccount_err')
expect().assertFail() expect().assertFail()
} }
done(); done();
}, },
onRequestRedirected:null, onRequestRedirected:null,
...@@ -511,7 +504,6 @@ export default function ActsAccountAppAccess() { ...@@ -511,7 +504,6 @@ export default function ActsAccountAppAccess() {
try{ try{
await appAccountManager.removeAccount(name) await appAccountManager.removeAccount(name)
console.debug('====>ActsAccountVerifyCredential_0200 removeAccount_success') console.debug('====>ActsAccountVerifyCredential_0200 removeAccount_success')
done();
} }
catch{ catch{
console.debug('====>ActsAccountVerifyCredential_0200 removeAccount_err') console.debug('====>ActsAccountVerifyCredential_0200 removeAccount_err')
...@@ -549,7 +541,6 @@ export default function ActsAccountAppAccess() { ...@@ -549,7 +541,6 @@ export default function ActsAccountAppAccess() {
try{ try{
await appAccountManager.removeAccount(name) await appAccountManager.removeAccount(name)
console.debug('====>ActsAccountSetAuthenticatorProperties_0100 removeAccount_success') console.debug('====>ActsAccountSetAuthenticatorProperties_0100 removeAccount_success')
done();
} }
catch{ catch{
console.debug('====>ActsAccountSetAuthenticatorProperties_0100 removeAccount_err') console.debug('====>ActsAccountSetAuthenticatorProperties_0100 removeAccount_err')
...@@ -586,7 +577,6 @@ export default function ActsAccountAppAccess() { ...@@ -586,7 +577,6 @@ export default function ActsAccountAppAccess() {
try{ try{
await appAccountManager.removeAccount(name) await appAccountManager.removeAccount(name)
console.debug('====>ActsAccountSetAuthenticatorProperties_0200 removeAccount_success') console.debug('====>ActsAccountSetAuthenticatorProperties_0200 removeAccount_success')
done();
} }
catch{ catch{
console.debug('====>ActsAccountSetAuthenticatorProperties_0200 removeAccount_err') console.debug('====>ActsAccountSetAuthenticatorProperties_0200 removeAccount_err')
...@@ -625,17 +615,18 @@ export default function ActsAccountAppAccess() { ...@@ -625,17 +615,18 @@ export default function ActsAccountAppAccess() {
await appAccountManager.removeAccount(name); await appAccountManager.removeAccount(name);
expect(err).assertEqual(null) expect(err).assertEqual(null)
done(); done();
return
} }
try{ try{
await appAccountManager.removeAccount(name) await appAccountManager.removeAccount(name)
console.debug('====>ActsAccountSelectAccountByOptions_0100 removeAccount_success') console.debug('====>ActsAccountSelectAccountByOptions_0100 removeAccount_success')
done();
} }
catch{ catch{
console.debug('====>ActsAccountSelectAccountByOptions_0100 removeAccount_err') console.debug('====>ActsAccountSelectAccountByOptions_0100 removeAccount_err')
expect().assertFail() expect().assertFail()
done(); done();
} }
done();
}); });
}); });
...@@ -662,17 +653,17 @@ export default function ActsAccountAppAccess() { ...@@ -662,17 +653,17 @@ export default function ActsAccountAppAccess() {
await appAccountManager.removeAccount(name); await appAccountManager.removeAccount(name);
expect(err).assertEqual(null) expect(err).assertEqual(null)
done(); done();
return;
} }
try{ try{
await appAccountManager.removeAccount(name) await appAccountManager.removeAccount(name)
console.debug('====>ActsAccountSelectAccountByOptions_0200 removeAccount_success') console.debug('====>ActsAccountSelectAccountByOptions_0200 removeAccount_success')
done();
} }
catch{ catch{
console.debug('====>ActsAccountSelectAccountByOptions_0200 removeAccount_err') console.debug('====>ActsAccountSelectAccountByOptions_0200 removeAccount_err')
expect().assertFail() expect().assertFail()
done(); }
} done();
}); });
}); });
...@@ -700,17 +691,17 @@ export default function ActsAccountAppAccess() { ...@@ -700,17 +691,17 @@ export default function ActsAccountAppAccess() {
await appAccountManager.removeAccount(name); await appAccountManager.removeAccount(name);
expect(err).assertEqual(null) expect(err).assertEqual(null)
done(); done();
return;
} }
try{ try{
await appAccountManager.removeAccount(name) await appAccountManager.removeAccount(name)
console.debug('====>ActsAccountSelectAccountByOptions_0300 removeAccount_success') console.debug('====>ActsAccountSelectAccountByOptions_0300 removeAccount_success')
done();
} }
catch{ catch{
console.debug('====>ActsAccountSelectAccountByOptions_0300 removeAccount_err') console.debug('====>ActsAccountSelectAccountByOptions_0300 removeAccount_err')
expect().assertFail() expect().assertFail()
done(); }
} done();
}); });
}); });
......
...@@ -21,18 +21,14 @@ const TIMEOUT = 2000; ...@@ -21,18 +21,14 @@ const TIMEOUT = 2000;
export default function ActsAccountOnOff() { export default function ActsAccountOnOff() {
describe('ActsAccountOnOff', async function () { describe('ActsAccountOnOff', async function () {
function sleep(delay) { async function sleep(delay) {
return new Promise((resolve, reject) => { let timeoutId = null;
setTimeout(() => { var promise = new Promise((resolve, reject) => {
resolve() timeoutId = setTimeout(() => resolve("done!"), delay);
}, delay) });
}).then(() => { await promise
console.info(`sleep #{time} over ...`) clearTimeout(timeoutId)
})
} }
beforeAll(async function (done) {
done();
});
async function testInit(){ async function testInit(){
console.debug("====>startAbility start===="); console.debug("====>startAbility start====");
...@@ -83,9 +79,9 @@ export default function ActsAccountOnOff() { ...@@ -83,9 +79,9 @@ export default function ActsAccountOnOff() {
commonevent.unsubscribe(subscriber, unSubscriberCallback); commonevent.unsubscribe(subscriber, unSubscriberCallback);
appAccountManager.removeAccount("onoff_setcredential", removeAccountCallback); appAccountManager.removeAccount("onoff_setcredential", removeAccountCallback);
} }
function publishCallback(err){ async function publishCallback(err){
console.debug("====>publish call back err:" + JSON.stringify(err)); console.debug("====>publish call back err:" + JSON.stringify(err));
setTimeout(async function (){ await sleep(500)
console.debug("====>setCredential start===="); console.debug("====>setCredential start====");
try{ try{
await appAccountManager.setCredential("onoff_setcredential", "credentialType", "credential"); await appAccountManager.setCredential("onoff_setcredential", "credentialType", "credential");
...@@ -96,7 +92,6 @@ export default function ActsAccountOnOff() { ...@@ -96,7 +92,6 @@ export default function ActsAccountOnOff() {
done(); done();
} }
console.debug("====>setCredential finish===="); console.debug("====>setCredential finish====");
}, 500)
} }
var commonEventSubscribeInfo = { var commonEventSubscribeInfo = {
events: ["account_on_change_setcredential"] events: ["account_on_change_setcredential"]
...@@ -111,10 +106,9 @@ export default function ActsAccountOnOff() { ...@@ -111,10 +106,9 @@ export default function ActsAccountOnOff() {
var commonEventPublishData = { var commonEventPublishData = {
code: 9 code: 9
} }
setTimeout(function (){ await sleep(1000)
console.debug("====>publish event account_on_change 0300===="); console.debug("====>publish event account_on_change 0300====");
commonevent.publish("account_on_change", commonEventPublishData, publishCallback); commonevent.publish("account_on_change", commonEventPublishData, publishCallback);
}, 1000);
}); });
/* /*
...@@ -152,9 +146,9 @@ export default function ActsAccountOnOff() { ...@@ -152,9 +146,9 @@ export default function ActsAccountOnOff() {
commonevent.unsubscribe(subscriber, unSubscriberCallback); commonevent.unsubscribe(subscriber, unSubscriberCallback);
appAccountManager.removeAccount("onoff_removeFir", removeAccountCallback); appAccountManager.removeAccount("onoff_removeFir", removeAccountCallback);
} }
function publishCallback(err){ async function publishCallback(err){
console.debug("====>publish call back err:" + JSON.stringify(err)); console.debug("====>publish call back err:" + JSON.stringify(err));
setTimeout(async function (){ await sleep(500)
console.debug("====>removeAccount start===="); console.debug("====>removeAccount start====");
try{ try{
await appAccountManager.removeAccount("onoff_removeSec"); await appAccountManager.removeAccount("onoff_removeSec");
...@@ -165,7 +159,6 @@ export default function ActsAccountOnOff() { ...@@ -165,7 +159,6 @@ export default function ActsAccountOnOff() {
done(); done();
} }
console.debug("====>removeAccount finish===="); console.debug("====>removeAccount finish====");
}, 500)
} }
var commonEventSubscribeInfo = { var commonEventSubscribeInfo = {
events: ["account_on_remove_another"] events: ["account_on_remove_another"]
...@@ -180,10 +173,9 @@ export default function ActsAccountOnOff() { ...@@ -180,10 +173,9 @@ export default function ActsAccountOnOff() {
var commonEventPublishData = { var commonEventPublishData = {
code: 10 code: 10
} }
setTimeout(function (){ await sleep(1000)
console.debug("====>publish event account_on_change 0400===="); console.debug("====>publish event account_on_change 0400====");
commonevent.publish("account_on_change", commonEventPublishData, publishCallback); commonevent.publish("account_on_change", commonEventPublishData, publishCallback);
}, 1000);
}); });
/* /*
...@@ -212,9 +204,9 @@ export default function ActsAccountOnOff() { ...@@ -212,9 +204,9 @@ export default function ActsAccountOnOff() {
commonevent.unsubscribe(subscriber, unSubscriberCallback); commonevent.unsubscribe(subscriber, unSubscriberCallback);
done(); done();
} }
function publishCallback(err){ async function publishCallback(err){
console.debug("====>publish call back err:" + JSON.stringify(err)); console.debug("====>publish call back err:" + JSON.stringify(err));
setTimeout(async function (){ await sleep(500)
console.debug("====>removeAccount start===="); console.debug("====>removeAccount start====");
try{ try{
await appAccountManager.removeAccount("onoff_remove"); await appAccountManager.removeAccount("onoff_remove");
...@@ -225,7 +217,6 @@ export default function ActsAccountOnOff() { ...@@ -225,7 +217,6 @@ export default function ActsAccountOnOff() {
done(); done();
} }
console.debug("====>removeAccount finish===="); console.debug("====>removeAccount finish====");
}, 500)
} }
var commonEventSubscribeInfo = { var commonEventSubscribeInfo = {
events: ["account_on_change_remove"] events: ["account_on_change_remove"]
...@@ -240,10 +231,9 @@ export default function ActsAccountOnOff() { ...@@ -240,10 +231,9 @@ export default function ActsAccountOnOff() {
var commonEventPublishData = { var commonEventPublishData = {
code: 11 code: 11
} }
setTimeout(function (){ await sleep(1000)
console.debug("====>publish event account_on_change 0500===="); console.debug("====>publish event account_on_change 0500====");
commonevent.publish("account_on_change", commonEventPublishData, publishCallback); commonevent.publish("account_on_change", commonEventPublishData, publishCallback);
}, 1000);
}); });
/* /*
...@@ -285,9 +275,9 @@ export default function ActsAccountOnOff() { ...@@ -285,9 +275,9 @@ export default function ActsAccountOnOff() {
commonevent.unsubscribe(subscriber, unSubscriberCallback); commonevent.unsubscribe(subscriber, unSubscriberCallback);
appAccountManager.removeAccount("onoff_disableFir", removeAccountCallback); appAccountManager.removeAccount("onoff_disableFir", removeAccountCallback);
} }
function publishCallback(err){ async function publishCallback(err){
console.debug("====>publish call back err:" + JSON.stringify(err)); console.debug("====>publish call back err:" + JSON.stringify(err));
setTimeout(async function (){ await sleep(500)
console.debug("====>disableAppAccess start===="); console.debug("====>disableAppAccess start====");
try{ try{
await appAccountManager.setAppAccess("onoff_disableSec", "com.example.actsaccountsceneonoff", false); await appAccountManager.setAppAccess("onoff_disableSec", "com.example.actsaccountsceneonoff", false);
...@@ -298,7 +288,6 @@ export default function ActsAccountOnOff() { ...@@ -298,7 +288,6 @@ export default function ActsAccountOnOff() {
done(); done();
} }
console.debug("====>disableAppAccess finish===="); console.debug("====>disableAppAccess finish====");
}, 500)
} }
var commonEventSubscribeInfo = { var commonEventSubscribeInfo = {
events: ["account_on_set_another_disable"] events: ["account_on_set_another_disable"]
...@@ -313,10 +302,9 @@ export default function ActsAccountOnOff() { ...@@ -313,10 +302,9 @@ export default function ActsAccountOnOff() {
var commonEventPublishData = { var commonEventPublishData = {
code: 12 code: 12
} }
setTimeout(function (){ await sleep(1000)
console.debug("====>publish event account_on_change 0600===="); console.debug("====>publish event account_on_change 0600====");
commonevent.publish("account_on_change", commonEventPublishData, publishCallback); commonevent.publish("account_on_change", commonEventPublishData, publishCallback);
}, 1000);
}); });
}) })
......
...@@ -15,32 +15,8 @@ ...@@ -15,32 +15,8 @@
import account from '@ohos.account.appAccount' import account from '@ohos.account.appAccount'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
const TIMEOUT = 5000;
const EACHTIMEOUT = 500;
export default function ActsAccountCustomData() { export default function ActsAccountCustomData() {
describe('ActsAccountCustomData', function () { describe('ActsAccountCustomData', 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 : ActsAccountCustomData_0100 * @tc.number : ActsAccountCustomData_0100
......
...@@ -20,28 +20,6 @@ const STRCOUNT = 1025; ...@@ -20,28 +20,6 @@ const STRCOUNT = 1025;
const EACHTIMEOUT = 500; const EACHTIMEOUT = 500;
export default function ActsAccountErrCode() { export default function ActsAccountErrCode() {
describe('ActsAccountErrCode', function () { describe('ActsAccountErrCode', 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 : ActsAccountErrCode_0100 * @tc.number : ActsAccountErrCode_0100
......
...@@ -15,26 +15,9 @@ ...@@ -15,26 +15,9 @@
import account from '@ohos.account.appAccount' import account from '@ohos.account.appAccount'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
const TIMEOUT = 5000;
const ERR_PERMISSION_DENIED = 201; const ERR_PERMISSION_DENIED = 201;
export default function ActsAccountErrPermission() { export default function ActsAccountErrPermission() {
describe('ActsAccountErrPermission', function () { describe('ActsAccountErrPermission', 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 : ActsAccountErrPermission_0100 * @tc.number : ActsAccountErrPermission_0100
* @tc.name : setDataSyncEnabled callback * @tc.name : setDataSyncEnabled callback
......
...@@ -15,28 +15,11 @@ ...@@ -15,28 +15,11 @@
import account from '@ohos.account.appAccount' import account from '@ohos.account.appAccount'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
const NAMELIMIT = 512; const NAMELIMIT = 512;
const TIMEOUT = 5000;
const ERR_INVALID_PARAMETER = 12300002 const ERR_INVALID_PARAMETER = 12300002
const ERR_ACCOUNT_NO_EXIST = 12300003 const ERR_ACCOUNT_NO_EXIST = 12300003
const createAccountOptions = {customData:{age:'12'}} const createAccountOptions = {customData:{age:'12'}}
export default function ActsAccountRemoveAccount() { export default function ActsAccountRemoveAccount() {
describe('ActsAccountRemoveAccount', function () { describe('ActsAccountRemoveAccount', 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 : ActsAccountRemoveAccount_0100 * @tc.number : ActsAccountRemoveAccount_0100
......
...@@ -15,34 +15,10 @@ ...@@ -15,34 +15,10 @@
import account from '@ohos.account.appAccount' import account from '@ohos.account.appAccount'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
const TIMEOUT = 5000;
const STRCOUNT = 513; const STRCOUNT = 513;
const EACHTIMEOUT = 500;
const createAccountOptions = {customData:{age:'12'}} const createAccountOptions = {customData:{age:'12'}}
export default function ActsAccountSetAppAccess() { export default function ActsAccountSetAppAccess() {
describe('ActsAccountSetAppAccess', function () { describe('ActsAccountSetAppAccess', 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 : ActsAccountSetAppAccess_0100 * @tc.number : ActsAccountSetAppAccess_0100
......
...@@ -20,28 +20,6 @@ const STRCOUNT = 1025; ...@@ -20,28 +20,6 @@ const STRCOUNT = 1025;
const EACHTIMEOUT = 500; const EACHTIMEOUT = 500;
export default function ActsAccountAppAccess() { export default function ActsAccountAppAccess() {
describe('ActsAccountAppAccess', function () { 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.number : ActsAccountAppAccess_0100
......
...@@ -19,29 +19,6 @@ const TIMEOUT = 5000; ...@@ -19,29 +19,6 @@ const TIMEOUT = 5000;
const EACHTIMEOUT = 500; const EACHTIMEOUT = 500;
export default function ActsAccountAssociatedData() { export default function ActsAccountAssociatedData() {
describe('ActsAccountAssociatedData', function () { 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.number : ActsAccountAssociatedData_0100
* @tc.name : The correct calls setAssociatedData and getAssociatedData get the value * @tc.name : The correct calls setAssociatedData and getAssociatedData get the value
......
...@@ -20,18 +20,8 @@ const NAMELIMIT = 512; ...@@ -20,18 +20,8 @@ const NAMELIMIT = 512;
const LENGTHLIMIT = 1024; const LENGTHLIMIT = 1024;
const name = 'zhangsan' const name = 'zhangsan'
const owner = 'com.example.accountauthenticator' const owner = 'com.example.accountauthenticator'
export default function ActsAccountAppAccess() { export default function ActsAccountAuthenticator() {
describe('ActsAccountAuthenticator', function () { describe('ActsAccountAuthenticator', function () {
function sleep(delay) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve()
}, delay)
}).then(() => {
console.info(`sleep #{time} over ...`)
})
}
beforeAll(async function (done) { beforeAll(async function (done) {
console.debug("====>accountauthenticatorbeforeAll start===="); console.debug("====>accountauthenticatorbeforeAll start====");
await featureAbility.startAbility( await featureAbility.startAbility(
...@@ -607,7 +597,6 @@ export default function ActsAccountAppAccess() { ...@@ -607,7 +597,6 @@ export default function ActsAccountAppAccess() {
*/ */
it('ActsAccountSelectAccountByOptions_0100', 0, async function (done) { it('ActsAccountSelectAccountByOptions_0100', 0, async function (done) {
await sleep(1000)
console.debug("====>ActsAccountSelectAccountByOptions_0100 start===="); console.debug("====>ActsAccountSelectAccountByOptions_0100 start====");
var appAccountManager = account.createAppAccountManager(); var appAccountManager = account.createAppAccountManager();
var select_options = {allowedAccounts:[{"name":name,"owner":owner}]} var select_options = {allowedAccounts:[{"name":name,"owner":owner}]}
......
...@@ -17,24 +17,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from ...@@ -17,24 +17,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
const TIMEOUT = 5000; const TIMEOUT = 5000;
export default function ActsCreatAppAccountManager() { export default function ActsCreatAppAccountManager() {
describe('ActsCreatAppAccountManager', function () { 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.number : ActsCreatAppAccountManager_0100
* @tc.name : createAppAccountManager * @tc.name : createAppAccountManager
......
...@@ -19,28 +19,6 @@ const TIMEOUT = 5000; ...@@ -19,28 +19,6 @@ const TIMEOUT = 5000;
const EACHTIMEOUT = 500; const EACHTIMEOUT = 500;
export default function ActsAccountCredential() { export default function ActsAccountCredential() {
describe('ActsAccountCredential', function () { 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.number : ActsAccountCredential_0100
......
...@@ -18,22 +18,6 @@ const NAMELIMIT = 512; ...@@ -18,22 +18,6 @@ const NAMELIMIT = 512;
const TIMEOUT = 5000; const TIMEOUT = 5000;
export default function ActsAccountDeleteAccount() { export default function ActsAccountDeleteAccount() {
describe('ActsAccountDeleteAccount', function () { 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.number : ActsAccountDeleteAccount_0100
......
...@@ -19,28 +19,6 @@ const TIMEOUT = 5000; ...@@ -19,28 +19,6 @@ const TIMEOUT = 5000;
const EACHTIMEOUT = 500; const EACHTIMEOUT = 500;
export default function ActsAccountSetGetExtraInfo() { export default function ActsAccountSetGetExtraInfo() {
describe('ActsAccountSetGetExtraInfo', function () { 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.number : ActsAccountSetGetExtraInfo_0100
......
...@@ -19,21 +19,6 @@ const TIMEOUT = 5000; ...@@ -19,21 +19,6 @@ const TIMEOUT = 5000;
const ERR_APPACCOUNT_SERVICE_PERMISSION_DENIED = 4521993; const ERR_APPACCOUNT_SERVICE_PERMISSION_DENIED = 4521993;
export default function ActsAccountNoPermission() { export default function ActsAccountNoPermission() {
describe('ActsAccountNoPermission', function () { 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.number : ActsAccountNoPermission_0100
......
...@@ -29,28 +29,6 @@ const OWNERLENGTHLIMIT = 1024; ...@@ -29,28 +29,6 @@ const OWNERLENGTHLIMIT = 1024;
const OWNERSELF = "com.example.actsaccounttest"; const OWNERSELF = "com.example.actsaccounttest";
export default function ActsAccountOAuthToken() { export default function ActsAccountOAuthToken() {
describe('ActsAccountOAuthToken', function () { 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.number : testGetEntriesString101
......
...@@ -49,6 +49,10 @@ ...@@ -49,6 +49,10 @@
{ {
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE", "name":"ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE" "reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE"
},
{
"name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND",
"reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND"
} }
], ],
"abilities": [ "abilities": [
......
...@@ -22,6 +22,16 @@ const SELFBUNDLE = 'com.example.actsgetaccountsbyowner' ...@@ -22,6 +22,16 @@ const SELFBUNDLE = 'com.example.actsgetaccountsbyowner'
const createAccountOptions = {customData:{age:'12'}} const createAccountOptions = {customData:{age:'12'}}
export default function GetAccountsByOwner() { export default function GetAccountsByOwner() {
describe('GetAccountsByOwner', function () { describe('GetAccountsByOwner', function () {
async function sleep(delay) {
let timeoutId = null;
var promise = new Promise((resolve, reject) => {
timeoutId = setTimeout(() => {
resolve("done")
}, delay)
})
await promise
clearTimeout(timeoutId)
}
/* /*
* @tc.number : GetAccountsByOwner_0100 * @tc.number : GetAccountsByOwner_0100
...@@ -283,10 +293,9 @@ export default function GetAccountsByOwner() { ...@@ -283,10 +293,9 @@ export default function GetAccountsByOwner() {
done(); done();
}); });
} }
setTimeout(async function(){ await sleep(TIMEOUT)
console.debug("====>getAccountsByOwner 0900 start===="); console.debug("====>getAccountsByOwner 0900 start====");
appAccountManager.getAccountsByOwner(SELFBUNDLE, getAllCallback); appAccountManager.getAccountsByOwner(SELFBUNDLE, getAllCallback);
}, TIMEOUT);
}); });
/* /*
...@@ -315,31 +324,30 @@ export default function GetAccountsByOwner() { ...@@ -315,31 +324,30 @@ export default function GetAccountsByOwner() {
}, },
}, },
); );
setTimeout(async function(){ sleep(TIMEOUT)
console.debug("====>getAccountsByOwner 1000 start===="); console.debug("====>getAccountsByOwner 1000 start====");
try{ try{
var data = await appAccountManager.getAccountsByOwner(SELFBUNDLE); var data = await appAccountManager.getAccountsByOwner(SELFBUNDLE);
} }
catch(err){ catch(err){
console.error("====>getAccountsByOwner 1000 fail err:" + JSON.stringify(err)); console.error("====>getAccountsByOwner 1000 fail err:" + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done();
}
console.debug("====>getAccountsByOwner 1000 data:" + JSON.stringify(data));
try{
expect(data[0].name).assertEqual("Account_application_promise");
expect(data[0].owner).assertEqual("com.example.actsgetaccountsbyowner");
}
catch(err){
console.error("====>check data 1000 fail err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>delete account 1000 start====");
await appAccountManager.removeAccount("Account_application_promise");
console.debug("====>GetAccountsByOwner_1000 end====");
done(); done();
}, TIMEOUT); }
console.debug("====>getAccountsByOwner 1000 data:" + JSON.stringify(data));
try{
expect(data[0].name).assertEqual("Account_application_promise");
expect(data[0].owner).assertEqual("com.example.actsgetaccountsbyowner");
}
catch(err){
console.error("====>check data 1000 fail err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>delete account 1000 start====");
await appAccountManager.removeAccount("Account_application_promise");
console.debug("====>GetAccountsByOwner_1000 end====");
done();
}); });
/* /*
...@@ -376,10 +384,9 @@ export default function GetAccountsByOwner() { ...@@ -376,10 +384,9 @@ export default function GetAccountsByOwner() {
console.debug("====>GetAccountsByOwner_1100 end===="); console.debug("====>GetAccountsByOwner_1100 end====");
done(); done();
} }
setTimeout(async function(){ sleep(TIMEOUT)
console.debug("====>getAccountsByOwner 1100 start===="); console.debug("====>getAccountsByOwner 1100 start====");
appAccountManager.getAccountsByOwner(specifiedBundle, getAllCallback); appAccountManager.getAccountsByOwner(specifiedBundle, getAllCallback);
}, TIMEOUT);
}); });
/* /*
...@@ -407,22 +414,21 @@ export default function GetAccountsByOwner() { ...@@ -407,22 +414,21 @@ export default function GetAccountsByOwner() {
}, },
}, },
); );
setTimeout(async function(){ await sleep(TIMEOUT)
console.debug("====>getAccountsByOwner 1200 start===="); console.debug("====>getAccountsByOwner 1200 start====");
try{ try{
var data = await appAccountManager.getAccountsByOwner(specifiedBundle); var data = await appAccountManager.getAccountsByOwner(specifiedBundle);
} }
catch(err){ catch(err){
console.error("====>getAccountsByOwner 1200 fail err:" + JSON.stringify(err)); console.error("====>getAccountsByOwner 1200 fail err:" + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done();
}
console.debug("====>getAccountsByOwner 1200 data:" + JSON.stringify(data));
expect(data[0].name).assertEqual("account_name_scene_single");
expect(data[0].owner).assertEqual("com.example.actsscenegetallaccounts");
console.debug("====>GetAccountsByOwner_1200 end====");
done(); done();
}, TIMEOUT); }
console.debug("====>getAccountsByOwner 1200 data:" + JSON.stringify(data));
expect(data[0].name).assertEqual("account_name_scene_single");
expect(data[0].owner).assertEqual("com.example.actsscenegetallaccounts");
console.debug("====>GetAccountsByOwner_1200 end====");
done();
}); });
/* /*
......
...@@ -20,6 +20,16 @@ const TIMEOUT = 2000; ...@@ -20,6 +20,16 @@ const TIMEOUT = 2000;
const LENGTHLIMIT = 1024; const LENGTHLIMIT = 1024;
export default function ActsGetAllAccounts() { export default function ActsGetAllAccounts() {
describe('ActsGetAllAccounts', function () { describe('ActsGetAllAccounts', function () {
async function sleep(delay) {
let timeoutId = null;
var promise = new Promise((resolve, reject) => {
timeoutId = setTimeout(() => {
resolve("done")
}, delay)
})
await promise
clearTimeout(timeoutId)
}
/* /*
* @tc.number : ActsGetAllAccounts_0100 * @tc.number : ActsGetAllAccounts_0100
...@@ -286,10 +296,9 @@ export default function ActsGetAllAccounts() { ...@@ -286,10 +296,9 @@ export default function ActsGetAllAccounts() {
done(); done();
}); });
} }
setTimeout(async function(){ await sleep(TIMEOUT)
console.debug("====>getAllAccounts 0900 start===="); console.debug("====>getAllAccounts 0900 start====");
appAccountManager.getAllAccounts(selfBundle, getAllCallback); appAccountManager.getAllAccounts(selfBundle, getAllCallback);
}, TIMEOUT);
}); });
/* /*
...@@ -319,32 +328,31 @@ export default function ActsGetAllAccounts() { ...@@ -319,32 +328,31 @@ export default function ActsGetAllAccounts() {
}, },
}, },
); );
setTimeout(async function(){ await sleep(TIMEOUT)
console.debug("====>getAllAccounts 1000 start===="); console.debug("====>getAllAccounts 1000 start====");
try{ try{
var data = await appAccountManager.getAllAccounts(selfBundle); var data = await appAccountManager.getAllAccounts(selfBundle);
} }
catch(err){ catch(err){
console.error("====>getAllAccounts 1000 fail err:" + JSON.stringify(err)); console.error("====>getAllAccounts 1000 fail err:" + JSON.stringify(err));
expect().assertFail(); 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.actsgetallaccounts");
}
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(); done();
}, TIMEOUT); }
}); console.debug("====>getAllAccounts 1000 data:" + JSON.stringify(data));
try{
expect(data[0].name).assertEqual("Account_application_promise");
expect(data[0].owner).assertEqual("com.example.actsgetallaccounts");
}
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();
});
/* /*
* @tc.number : ActsGetAllAccounts_1300 * @tc.number : ActsGetAllAccounts_1300
......
...@@ -20,6 +20,16 @@ const TIMEOUT = 2000; ...@@ -20,6 +20,16 @@ const TIMEOUT = 2000;
const SELFBUNDLE = 'com.example.getallaccountsnoparameter' const SELFBUNDLE = 'com.example.getallaccountsnoparameter'
export default function ActsGetAllAccountsNoParameter() { export default function ActsGetAllAccountsNoParameter() {
describe('ActsGetAllAccountsNoParameter', function () { describe('ActsGetAllAccountsNoParameter', function () {
async function sleep(delay) {
let timeoutId = null;
var promise = new Promise((resolve, reject) => {
timeoutId = setTimeout(() => {
resolve("done")
}, delay)
})
await promise
clearTimeout(timeoutId)
}
/* /*
* @tc.number : ActsGetAllAccountsNoParameter_0100 * @tc.number : ActsGetAllAccountsNoParameter_0100
...@@ -567,34 +577,33 @@ export default function ActsGetAllAccountsNoParameter() { ...@@ -567,34 +577,33 @@ export default function ActsGetAllAccountsNoParameter() {
}, },
}, },
); );
setTimeout(async function(){ await sleep(TIMEOUT)
console.debug("====>getAllAccounts 1100 start===="); console.debug("====>getAllAccounts 1100 start====");
try{ try{
var data = await appAccountManager.getAllAccounts(); var data = await appAccountManager.getAllAccounts();
} }
catch(err){ catch(err){
console.error("====>getAllAccounts 1100 fail err:" + JSON.stringify(err)); console.error("====>getAllAccounts 1100 fail err:" + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done();
}
console.debug("====>getAllAccounts 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.getallaccountsnoparameter");
}
catch(err){
console.error("====>check data 1100 fail err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>delete account 1100 start====");
await appAccountManager.removeAccount("accessibleAccount_this_application");
console.debug("====>ActsGetAllAccountsNoParameter_1100 end====");
done(); done();
}, TIMEOUT); }
console.debug("====>getAllAccounts 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.getallaccountsnoparameter");
}
catch(err){
console.error("====>check data 1100 fail err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>delete account 1100 start====");
await appAccountManager.removeAccount("accessibleAccount_this_application");
console.debug("====>ActsGetAllAccountsNoParameter_1100 end====");
done();
}); });
}) })
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册