未验证 提交 373beb46 编写于 作者: O openharmony_ci 提交者: Gitee

!8579 【Account】【3.1Release】Memory Leak Rectification

Merge pull request !8579 from 翟孟超/memleak0428
...@@ -19,14 +19,13 @@ const TIMEOUT = 5000; ...@@ -19,14 +19,13 @@ const TIMEOUT = 5000;
const STRCOUNT = 1025; const STRCOUNT = 1025;
const EACHTIMEOUT = 500; const EACHTIMEOUT = 500;
describe('ActsAccountAppAccess', function () { describe('ActsAccountAppAccess', 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) { beforeAll(async function (done) {
......
...@@ -18,14 +18,13 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from ' ...@@ -18,14 +18,13 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
const TIMEOUT = 5000; const TIMEOUT = 5000;
const EACHTIMEOUT = 500; const EACHTIMEOUT = 500;
describe('ActsAccountAssociatedData', function () { describe('ActsAccountAssociatedData', 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) { beforeAll(async function (done) {
......
...@@ -17,14 +17,13 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from ' ...@@ -17,14 +17,13 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
const TIMEOUT = 5000; const TIMEOUT = 5000;
describe('ActsCreatAppAccountManager', function () { describe('ActsCreatAppAccountManager', 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) { beforeAll(async function (done) {
......
...@@ -18,14 +18,13 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from ' ...@@ -18,14 +18,13 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
const TIMEOUT = 5000; const TIMEOUT = 5000;
const EACHTIMEOUT = 500; const EACHTIMEOUT = 500;
describe('ActsAccountCredential', function () { describe('ActsAccountCredential', 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) { beforeAll(async function (done) {
......
...@@ -18,14 +18,13 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from ' ...@@ -18,14 +18,13 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
const NAMELIMIT = 512; const NAMELIMIT = 512;
const TIMEOUT = 5000; const TIMEOUT = 5000;
describe('ActsAccountDeleteAccount', function () { describe('ActsAccountDeleteAccount', 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) { beforeAll(async function (done) {
......
...@@ -18,14 +18,13 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from ' ...@@ -18,14 +18,13 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
const TIMEOUT = 5000; const TIMEOUT = 5000;
const EACHTIMEOUT = 500; const EACHTIMEOUT = 500;
describe('ActsAccountSetGetExtraInfo', function () { describe('ActsAccountSetGetExtraInfo', 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) { beforeAll(async function (done) {
......
...@@ -18,15 +18,15 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from ' ...@@ -18,15 +18,15 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
const TIMEOUT = 5000; const TIMEOUT = 5000;
const ERR_APPACCOUNT_SERVICE_PERMISSION_DENIED = 4521993; const ERR_APPACCOUNT_SERVICE_PERMISSION_DENIED = 4521993;
describe('ActsAccountNoPermission', function () { describe('ActsAccountNoPermission', 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) { beforeAll(async function (done) {
console.debug("====>beforeAll start===="); console.debug("====>beforeAll start====");
await sleep(TIMEOUT); await sleep(TIMEOUT);
......
...@@ -29,23 +29,25 @@ const OWNERLENGTHLIMIT = 1024; ...@@ -29,23 +29,25 @@ const OWNERLENGTHLIMIT = 1024;
const OWNERSELF = "com.example.actsaccounttest"; const OWNERSELF = "com.example.actsaccounttest";
describe('ActsAccountOAuthToken', function () { describe('ActsAccountOAuthToken', function () {
function sleep(delay) { async function sleep(delay) {
var start = (new Date()).getTime(); let timeoutId = null;
while((new Date()).getTime() - start < delay) { var promise = new Promise((resolve, reject) => {
continue; timeoutId = setTimeout(() => resolve("done!"), delay);
} });
await promise
clearTimeout(timeoutId)
} }
beforeAll(async function (done) { beforeAll(async function (done) {
console.debug("====>beforeAll start===="); console.debug("====>beforeAll start====");
sleep(TIMEOUT); await sleep(TIMEOUT);
console.debug("====>beforeAll end===="); console.debug("====>beforeAll end====");
done(); done();
}); });
beforeEach(async function (done) { beforeEach(async function (done) {
console.debug("====>beforeAll enter===="); console.debug("====>beforeAll enter====");
sleep(EACHTIMEOUT); await sleep(EACHTIMEOUT);
done(); done();
}); });
......
...@@ -20,6 +20,15 @@ const TIMEOUT = 2000; ...@@ -20,6 +20,15 @@ const TIMEOUT = 2000;
const LENGTHLIMIT = 1024; const LENGTHLIMIT = 1024;
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
* @tc.name : getAllAccounts callback * @tc.name : getAllAccounts callback
...@@ -285,10 +294,9 @@ describe('ActsGetAllAccounts', function () { ...@@ -285,10 +294,9 @@ describe('ActsGetAllAccounts', function () {
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);
}); });
/* /*
...@@ -318,31 +326,30 @@ describe('ActsGetAllAccounts', function () { ...@@ -318,31 +326,30 @@ describe('ActsGetAllAccounts', function () {
}, },
}, },
); );
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.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(); 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.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();
}); });
/* /*
...@@ -379,10 +386,9 @@ describe('ActsGetAllAccounts', function () { ...@@ -379,10 +386,9 @@ describe('ActsGetAllAccounts', function () {
console.debug("====>ActsGetAllAccounts_1100 end===="); console.debug("====>ActsGetAllAccounts_1100 end====");
done(); done();
} }
setTimeout(async function(){ await sleep(TIMEOUT)
console.debug("====>getAllAccounts 1100 start===="); console.debug("====>getAllAccounts 1100 start====");
appAccountManager.getAllAccounts(specifiedBundle, getAllCallback); appAccountManager.getAllAccounts(specifiedBundle, getAllCallback);
}, TIMEOUT);
}); });
/* /*
...@@ -410,22 +416,21 @@ describe('ActsGetAllAccounts', function () { ...@@ -410,22 +416,21 @@ describe('ActsGetAllAccounts', function () {
}, },
}, },
); );
setTimeout(async function(){ await sleep(TIMEOUT)
console.debug("====>getAllAccounts 1200 start===="); console.debug("====>getAllAccounts 1200 start====");
try{ try{
var data = await appAccountManager.getAllAccounts(specifiedBundle); var data = await appAccountManager.getAllAccounts(specifiedBundle);
} }
catch(err){ catch(err){
console.error("====>getAllAccounts 1200 fail err:" + JSON.stringify(err)); console.error("====>getAllAccounts 1200 fail err:" + JSON.stringify(err));
expect().assertFail(); 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(); done();
}, TIMEOUT); }
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();
}); });
/* /*
......
...@@ -30,16 +30,18 @@ describe('ActsSetCheckSyncEnable', function () { ...@@ -30,16 +30,18 @@ describe('ActsSetCheckSyncEnable', function () {
var atManager = abilityAccessCtrl.createAtManager(); var atManager = abilityAccessCtrl.createAtManager();
var result = await atManager.grantUserGrantedPermission(tokenID, PERMISSION_USER_NAME, PERMISSION_USER_SET); var result = await atManager.grantUserGrantedPermission(tokenID, PERMISSION_USER_NAME, PERMISSION_USER_SET);
console.debug("tokenId" + tokenID + " result:" + result); console.debug("tokenId" + tokenID + " result:" + result);
sleep(TIMEOUT); await sleep(TIMEOUT);
console.debug("====>beforeAll end===="); console.debug("====>beforeAll end====");
done(); done();
}) })
function sleep(delay) { async function sleep(delay) {
var start = (new Date()).getTime(); let timeoutId = null;
while((new Date()).getTime() - start < delay) { var promise = new Promise((resolve, reject) => {
continue; timeoutId = setTimeout(() => resolve("done!"), delay);
} });
await promise
clearTimeout(timeoutId)
} }
/* /*
......
...@@ -33,15 +33,17 @@ describe('ActsGetAllAccessibleMultiple', function () { ...@@ -33,15 +33,17 @@ describe('ActsGetAllAccessibleMultiple', function () {
}, },
}, },
); );
sleep(TIMEOUT); await sleep(TIMEOUT);
done(); done();
}); });
function sleep(delay) { async function sleep(delay) {
var start = (new Date()).getTime(); let timeoutId = null;
while((new Date()).getTime() - start < delay) { var promise = new Promise((resolve, reject) => {
continue; timeoutId = setTimeout(() => resolve("done!"), delay);
} });
await promise
clearTimeout(timeoutId)
} }
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册