提交 ffd5691d 编写于 作者: O openharmony_ci 提交者: Gitee

!1378 Fix appaccount test bug

Merge pull request !1378 from blackleon/master_1215_02
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"description": "Configuration for hjunit demo Tests", "description": "Configuration for hjunit demo Tests",
"driver": { "driver": {
"type": "JSUnitTest", "type": "JSUnitTest",
"test-timeout": "2000000", "test-timeout": "3000000",
"package": "com.example.actsaccountpressure", "package": "com.example.actsaccountpressure",
"shell-timeout": "60000" "shell-timeout": "60000"
}, },
......
...@@ -35,7 +35,7 @@ export default { ...@@ -35,7 +35,7 @@ export default {
core.init() core.init()
const configService = core.getDefaultService('config') const configService = core.getDefaultService('config')
this.timeout = 150000; this.timeout = 180000;
configService.setConfig(this) configService.setConfig(this)
require('../../../test/List.test') require('../../../test/List.test')
......
...@@ -113,8 +113,15 @@ describe('ActsAccountPressure', function () { ...@@ -113,8 +113,15 @@ describe('ActsAccountPressure', function () {
console.debug("====>creat finish===="); console.debug("====>creat finish====");
let flag = true; let flag = true;
let count = 0; let count = 0;
for (let i = 0; i < STRESSLEVEL; i++) { let STRESSNUM;
if(STRESSLEVEL > ACCOUNTLIMIT){
STRESSNUM = ACCOUNTLIMIT;
}else{
STRESSNUM = STRESSLEVEL;
}
for (let i = 0; i < STRESSNUM; i++) {
let accountName = "account_pressure_callback" + i; let accountName = "account_pressure_callback" + i;
sleep(TIMEOUT);
appAccountManager.addAccount(accountName, (err)=>{ appAccountManager.addAccount(accountName, (err)=>{
console.debug('====>addAccount name: ' + accountName); console.debug('====>addAccount name: ' + accountName);
expect(err.code).assertEqual(0); expect(err.code).assertEqual(0);
...@@ -124,6 +131,7 @@ describe('ActsAccountPressure', function () { ...@@ -124,6 +131,7 @@ describe('ActsAccountPressure', function () {
flag = false; flag = false;
done(); done();
} }
sleep(TIMEOUT);
appAccountManager.deleteAccount(accountName, (err)=>{ appAccountManager.deleteAccount(accountName, (err)=>{
console.debug('====>deleteAccount name: ' + accountName); console.debug('====>deleteAccount name: ' + accountName);
expect(err.code).assertEqual(0); expect(err.code).assertEqual(0);
...@@ -141,10 +149,8 @@ describe('ActsAccountPressure', function () { ...@@ -141,10 +149,8 @@ describe('ActsAccountPressure', function () {
done(); done();
} }
count++; count++;
sleep(TIMEOUT);
}) })
}); });
sleep(TIMEOUT);
if (!flag) { if (!flag) {
done(); done();
break; break;
...@@ -191,26 +197,43 @@ describe('ActsAccountPressure', function () { ...@@ -191,26 +197,43 @@ describe('ActsAccountPressure', function () {
catch(err){ catch(err){
console.debug("====>add Account that exceed the limit err:" + JSON.stringify(err)); console.debug("====>add Account that exceed the limit err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true); expect(err.code != 0).assertEqual(true);
await appAccountManager.deleteAccount("account_name_limit"); console.debug("====>deleteAccount start====");
} for (count = 0; count < STRESSNUM; count++) {
} let accountName = "account_pressure_limit" + count;
console.debug("====>deleteAccount start===="); console.debug('====>deleteAccount name: ' + accountName);
for (count = 0; count < STRESSNUM; count++) { try{
let accountName = "account_pressure_limit" + count; await appAccountManager.deleteAccount(accountName);
console.debug('====>deleteAccount name: ' + accountName); sleep(TIMEOUT);
try{ }
await appAccountManager.deleteAccount(accountName); catch(err){
sleep(TIMEOUT); console.error("====>deleteAccount fail err:" + JSON.stringify(err));
} expect().assertFail();
catch(err){ done();
console.error("====>deleteAccount fail err:" + JSON.stringify(err)); }
expect().assertFail(); }
console.debug("====>the number of times to complete the stress test is: " + count)
console.debug("====>ActsAccountPressure_0300 end====");
done(); done();
} }
}else{
console.debug("====>deleteAccount start====");
for (count = 0; count < STRESSNUM; count++) {
let accountName = "account_pressure_limit" + count;
console.debug('====>deleteAccount name: ' + accountName);
try{
await appAccountManager.deleteAccount(accountName);
sleep(TIMEOUT);
}
catch(err){
console.error("====>deleteAccount fail err:" + JSON.stringify(err));
expect().assertFail();
done();
}
}
console.debug("====>the number of times to complete the stress test is: " + count)
console.debug("====>ActsAccountPressure_0300 end====");
done();
} }
console.debug("====>the number of times to complete the stress test is: " + count)
console.debug("====>ActsAccountPressure_0300 end====");
done();
}); });
/* /*
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"description": "Configuration for hjunit demo Tests", "description": "Configuration for hjunit demo Tests",
"driver": { "driver": {
"type": "JSUnitTest", "type": "JSUnitTest",
"test-timeout": "300000", "test-timeout": "500000",
"package": "com.example.actsaccounttest", "package": "com.example.actsaccounttest",
"shell-timeout": "60000" "shell-timeout": "60000"
}, },
......
...@@ -17,6 +17,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from ' ...@@ -17,6 +17,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
const TIMEOUT = 5000; const TIMEOUT = 5000;
const STRCOUNT = 1025; const STRCOUNT = 1025;
const EACHTIMEOUT = 500;
describe('ActsAccountAppAccess', function () { describe('ActsAccountAppAccess', function () {
function sleep(delay) { function sleep(delay) {
var start = (new Date()).getTime(); var start = (new Date()).getTime();
...@@ -30,7 +31,13 @@ describe('ActsAccountAppAccess', function () { ...@@ -30,7 +31,13 @@ describe('ActsAccountAppAccess', function () {
sleep(TIMEOUT); sleep(TIMEOUT);
console.debug("====>beforeAll end===="); console.debug("====>beforeAll end====");
done(); done();
}); })
beforeEach(async function (done) {
console.debug("====>beforeEach enter====");
sleep(EACHTIMEOUT);
done();
})
/* /*
* @tc.number : ActsAccountAppAccess_0100 * @tc.number : ActsAccountAppAccess_0100
......
...@@ -16,6 +16,7 @@ import account from '@ohos.account.appAccount' ...@@ -16,6 +16,7 @@ import account from '@ohos.account.appAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const TIMEOUT = 5000; const TIMEOUT = 5000;
const EACHTIMEOUT = 500;
describe('ActsAccountAssociatedData', function () { describe('ActsAccountAssociatedData', function () {
function sleep(delay) { function sleep(delay) {
var start = (new Date()).getTime(); var start = (new Date()).getTime();
...@@ -29,7 +30,13 @@ describe('ActsAccountAssociatedData', function () { ...@@ -29,7 +30,13 @@ describe('ActsAccountAssociatedData', function () {
sleep(TIMEOUT); sleep(TIMEOUT);
console.debug("====>beforeAll end===="); console.debug("====>beforeAll end====");
done(); done();
}); })
beforeEach(async function (done) {
console.debug("====>beforeEach enter====");
sleep(EACHTIMEOUT);
done();
})
/* /*
* @tc.number : ActsAccountAssociatedData_0100 * @tc.number : ActsAccountAssociatedData_0100
......
...@@ -16,6 +16,7 @@ import account from '@ohos.account.appAccount' ...@@ -16,6 +16,7 @@ import account from '@ohos.account.appAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const TIMEOUT = 5000; const TIMEOUT = 5000;
const EACHTIMEOUT = 500;
describe('ActsAccountCredential', function () { describe('ActsAccountCredential', function () {
function sleep(delay) { function sleep(delay) {
var start = (new Date()).getTime(); var start = (new Date()).getTime();
...@@ -29,7 +30,13 @@ describe('ActsAccountCredential', function () { ...@@ -29,7 +30,13 @@ describe('ActsAccountCredential', function () {
sleep(TIMEOUT); sleep(TIMEOUT);
console.debug("====>beforeAll end===="); console.debug("====>beforeAll end====");
done(); done();
}); })
beforeEach(async function (done) {
console.debug("====>beforeEach enter====");
sleep(EACHTIMEOUT);
done();
})
/* /*
* @tc.number : ActsAccountCredential_0100 * @tc.number : ActsAccountCredential_0100
......
...@@ -16,6 +16,7 @@ import account from '@ohos.account.appAccount' ...@@ -16,6 +16,7 @@ import account from '@ohos.account.appAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const TIMEOUT = 5000; const TIMEOUT = 5000;
const EACHTIMEOUT = 500;
describe('ActsAccountSetGetExtraInfo', function () { describe('ActsAccountSetGetExtraInfo', function () {
function sleep(delay) { function sleep(delay) {
var start = (new Date()).getTime(); var start = (new Date()).getTime();
...@@ -29,7 +30,13 @@ describe('ActsAccountSetGetExtraInfo', function () { ...@@ -29,7 +30,13 @@ describe('ActsAccountSetGetExtraInfo', function () {
sleep(TIMEOUT); sleep(TIMEOUT);
console.debug("====>beforeAll end===="); console.debug("====>beforeAll end====");
done(); done();
}); })
beforeEach(async function (done) {
console.debug("====>beforeEach enter====");
sleep(EACHTIMEOUT);
done();
})
/* /*
* @tc.number : ActsAccountSetGetExtraInfo_0100 * @tc.number : ActsAccountSetGetExtraInfo_0100
......
...@@ -17,6 +17,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from ' ...@@ -17,6 +17,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
const TIMEOUT = 5000; const TIMEOUT = 5000;
const LENGTHLIMIT = 1024; const LENGTHLIMIT = 1024;
const EACHTIMEOUT = 500;
describe('ActsAccountOAuthToken', function () { describe('ActsAccountOAuthToken', function () {
function sleep(delay) { function sleep(delay) {
var start = (new Date()).getTime(); var start = (new Date()).getTime();
...@@ -32,6 +33,12 @@ describe('ActsAccountOAuthToken', function () { ...@@ -32,6 +33,12 @@ describe('ActsAccountOAuthToken', function () {
done(); done();
}); });
beforeEach(async function (done) {
console.debug("====>beforeEach enter====");
sleep(EACHTIMEOUT);
done();
})
/* /*
* @tc.number : ActsAccountOAuthToken_0100 * @tc.number : ActsAccountOAuthToken_0100
* @tc.name : Test oauth token in callback form * @tc.name : Test oauth token in callback form
......
...@@ -499,6 +499,7 @@ describe('ActsAccountChangeOnOff', async function () { ...@@ -499,6 +499,7 @@ describe('ActsAccountChangeOnOff', async function () {
*/ */
it('ActsAccountChangeOnOff_0800', 0, async function (done) { it('ActsAccountChangeOnOff_0800', 0, async function (done) {
console.debug("====>ActsAccountChangeOnOff_0800 start===="); console.debug("====>ActsAccountChangeOnOff_0800 start====");
let dataMap = new Map();
var appAccountManager = account.createAppAccountManager(); var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish"); console.debug("====>creat appAccountManager finish");
console.debug("====>add account ActsAccountChangeOnOff_0800 start"); console.debug("====>add account ActsAccountChangeOnOff_0800 start");
...@@ -506,8 +507,16 @@ describe('ActsAccountChangeOnOff', async function () { ...@@ -506,8 +507,16 @@ describe('ActsAccountChangeOnOff', async function () {
console.debug("====>on ActsAccountChangeOnOff_0800 start"); console.debug("====>on ActsAccountChangeOnOff_0800 start");
function changeOnCallback(data){ function changeOnCallback(data){
console.debug("====>receive change 0800 data:" + JSON.stringify(data)); console.debug("====>receive change 0800 data:" + JSON.stringify(data));
expect(data[0].name).assertEqual("onoff_self"); console.debug("====>data.length:" + data.length);
expect(data[0].owner).assertEqual("com.example.actsaccounttest"); for (let i = 0, len = data.length; i < len; i++) {
dataMap.set(data[i].name, data[i].owner)
}
expect(dataMap.has("onoff_self")).assertTrue();
if (dataMap.has("onoff_self")) {
let data = dataMap.get("onoff_self");
console.debug("====>the account owner is: " + data);
expect(data).assertEqual("com.example.actsaccounttest");
}
appAccountManager.off('change', function (){ appAccountManager.off('change', function (){
console.debug("====>off ActsAccountChangeOnOff_0800 finish===="); console.debug("====>off ActsAccountChangeOnOff_0800 finish====");
appAccountManager.deleteAccount("onoff_self", (err)=>{ appAccountManager.deleteAccount("onoff_self", (err)=>{
...@@ -545,6 +554,7 @@ describe('ActsAccountChangeOnOff', async function () { ...@@ -545,6 +554,7 @@ describe('ActsAccountChangeOnOff', async function () {
*/ */
it('ActsAccountChangeOnOff_0900', 0, async function (done) { it('ActsAccountChangeOnOff_0900', 0, async function (done) {
console.debug("====>ActsAccountChangeOnOff_0900 start===="); console.debug("====>ActsAccountChangeOnOff_0900 start====");
let dataMap = new Map();
var appAccountManager = account.createAppAccountManager(); var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish"); console.debug("====>creat appAccountManager finish");
console.debug("====>add first account ActsAccountChangeOnOff_0900 start"); console.debug("====>add first account ActsAccountChangeOnOff_0900 start");
...@@ -554,10 +564,22 @@ describe('ActsAccountChangeOnOff', async function () { ...@@ -554,10 +564,22 @@ describe('ActsAccountChangeOnOff', async function () {
console.debug("====>on ActsAccountChangeOnOff_0900 start"); console.debug("====>on ActsAccountChangeOnOff_0900 start");
function changeOnCallback(data){ function changeOnCallback(data){
console.debug("====>receive change 0900 data:" + JSON.stringify(data)); console.debug("====>receive change 0900 data:" + JSON.stringify(data));
expect(data[0].name).assertEqual("onoff_self_first"); console.debug("====>data.length:" + data.length);
expect(data[0].owner).assertEqual("com.example.actsaccounttest"); for (let i = 0, len = data.length; i < len; i++) {
expect(data[1].name).assertEqual("onoff_self_second"); dataMap.set(data[i].name, data[i].owner)
expect(data[1].owner).assertEqual("com.example.actsaccounttest"); }
expect(dataMap.has("onoff_self_first")).assertTrue();
if (dataMap.has("onoff_self_first")) {
let data = dataMap.get("onoff_self_first");
console.debug("====>the account owner is: " + data);
expect(data).assertEqual("com.example.actsaccounttest");
}
expect(dataMap.has("onoff_self_second")).assertTrue();
if (dataMap.has("onoff_self_second")) {
let data = dataMap.get("onoff_self_second");
console.debug("====>the account owner is: " + data);
expect(data).assertEqual("com.example.actsaccounttest");
}
appAccountManager.off('change', function (){ appAccountManager.off('change', function (){
console.debug("====>off ActsAccountChangeOnOff_0900 finish===="); console.debug("====>off ActsAccountChangeOnOff_0900 finish====");
appAccountManager.deleteAccount("onoff_self_first", (err)=>{ appAccountManager.deleteAccount("onoff_self_first", (err)=>{
...@@ -598,6 +620,8 @@ describe('ActsAccountChangeOnOff', async function () { ...@@ -598,6 +620,8 @@ describe('ActsAccountChangeOnOff', async function () {
*/ */
it('ActsAccountChangeOnOff_1000', 0, async function (done) { it('ActsAccountChangeOnOff_1000', 0, async function (done) {
console.debug("====>ActsAccountChangeOnOff_1000 start===="); console.debug("====>ActsAccountChangeOnOff_1000 start====");
let dataMapFir = new Map();
let dataMapSec = new Map();
var appAccountManager = account.createAppAccountManager(); var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish"); console.debug("====>creat appAccountManager finish");
console.debug("====>add account ActsAccountChangeOnOff_1000 start"); console.debug("====>add account ActsAccountChangeOnOff_1000 start");
...@@ -606,14 +630,30 @@ describe('ActsAccountChangeOnOff', async function () { ...@@ -606,14 +630,30 @@ describe('ActsAccountChangeOnOff', async function () {
var twiceSign = 0; var twiceSign = 0;
function changeOnFirstCallback(data){ function changeOnFirstCallback(data){
console.debug("====>first receive change 1000 data:" + JSON.stringify(data)); console.debug("====>first receive change 1000 data:" + JSON.stringify(data));
expect(data[0].name).assertEqual("onoff_twice"); console.debug("====>data.length:" + data.length);
expect(data[0].owner).assertEqual("com.example.actsaccounttest"); for (let i = 0, len = data.length; i < len; i++) {
dataMapFir.set(data[i].name, data[i].owner)
}
expect(dataMapFir.has("onoff_twice")).assertTrue();
if (dataMapFir.has("onoff_twice")) {
let data = dataMapFir.get("onoff_twice");
console.debug("====>the account owner is: " + data);
expect(data).assertEqual("com.example.actsaccounttest");
}
twiceSign = twiceSign + 1; twiceSign = twiceSign + 1;
} }
function changeOnSecondCallback(data){ function changeOnSecondCallback(data){
console.debug("====>second receive change 1000 data:" + JSON.stringify(data)); console.debug("====>second receive change 1000 data:" + JSON.stringify(data));
expect(data[0].name).assertEqual("onoff_twice"); console.debug("====>data.length:" + data.length);
expect(data[0].owner).assertEqual("com.example.actsaccounttest"); for (let i = 0, len = data.length; i < len; i++) {
dataMapSec.set(data[i].name, data[i].owner)
}
expect(dataMapSec.has("onoff_twice")).assertTrue();
if (dataMapSec.has("onoff_twice")) {
let data = dataMapSec.get("onoff_twice");
console.debug("====>the account owner is: " + data);
expect(data).assertEqual("com.example.actsaccounttest");
}
twiceSign = twiceSign + 1; twiceSign = twiceSign + 1;
appAccountManager.off('change', function (){ appAccountManager.off('change', function (){
console.debug("====>off ActsAccountChangeOnOff_1000 finish===="); console.debug("====>off ActsAccountChangeOnOff_1000 finish====");
...@@ -654,6 +694,7 @@ describe('ActsAccountChangeOnOff', async function () { ...@@ -654,6 +694,7 @@ describe('ActsAccountChangeOnOff', async function () {
*/ */
it('ActsAccountChangeOnOff_1100', 0, async function (done) { it('ActsAccountChangeOnOff_1100', 0, async function (done) {
console.debug("====>ActsAccountChangeOnOff_1100 start===="); console.debug("====>ActsAccountChangeOnOff_1100 start====");
let dataMap = new Map();
var appAccountManager = account.createAppAccountManager(); var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish"); console.debug("====>creat appAccountManager finish");
console.debug("====>add account ActsAccountChangeOnOff_1100 start"); console.debug("====>add account ActsAccountChangeOnOff_1100 start");
...@@ -663,8 +704,16 @@ describe('ActsAccountChangeOnOff', async function () { ...@@ -663,8 +704,16 @@ describe('ActsAccountChangeOnOff', async function () {
function onCallBack(data){ function onCallBack(data){
console.debug("====>receive change 1100 data:" + JSON.stringify(data)); console.debug("====>receive change 1100 data:" + JSON.stringify(data));
sameSign = sameSign + 1; sameSign = sameSign + 1;
expect(data[0].name).assertEqual("onoff_same"); console.debug("====>data.length:" + data.length);
expect(data[0].owner).assertEqual("com.example.actsaccounttest"); for (let i = 0, len = data.length; i < len; i++) {
dataMap.set(data[i].name, data[i].owner)
}
expect(dataMap.has("onoff_same")).assertTrue();
if (dataMap.has("onoff_same")) {
let data = dataMap.get("onoff_same");
console.debug("====>the account owner is: " + data);
expect(data).assertEqual("com.example.actsaccounttest");
}
} }
try{ try{
appAccountManager.on('change', ["com.example.actsaccounttest", "com.example.actsaccounttest"], onCallBack); appAccountManager.on('change', ["com.example.actsaccounttest", "com.example.actsaccounttest"], onCallBack);
...@@ -705,6 +754,7 @@ describe('ActsAccountChangeOnOff', async function () { ...@@ -705,6 +754,7 @@ describe('ActsAccountChangeOnOff', async function () {
*/ */
it('ActsAccountChangeOnOff_1200', 0, async function (done) { it('ActsAccountChangeOnOff_1200', 0, async function (done) {
console.debug("====>ActsAccountChangeOnOff_1200 start===="); console.debug("====>ActsAccountChangeOnOff_1200 start====");
let dataMap = new Map();
var appAccountManager = account.createAppAccountManager(); var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish"); console.debug("====>creat appAccountManager finish");
console.debug("====>add account ActsAccountChangeOnOff_1200 start"); console.debug("====>add account ActsAccountChangeOnOff_1200 start");
...@@ -712,8 +762,16 @@ describe('ActsAccountChangeOnOff', async function () { ...@@ -712,8 +762,16 @@ describe('ActsAccountChangeOnOff', async function () {
console.debug("====>on ActsAccountChangeOnOff_1200 start"); console.debug("====>on ActsAccountChangeOnOff_1200 start");
function changeOnCallback(data){ function changeOnCallback(data){
console.debug("====>receive change 1200 data:" + JSON.stringify(data)); console.debug("====>receive change 1200 data:" + JSON.stringify(data));
expect(data[0].name).assertEqual("onoff_repeatoff"); console.debug("====>data.length:" + data.length);
expect(data[0].owner).assertEqual("com.example.actsaccounttest"); for (let i = 0, len = data.length; i < len; i++) {
dataMap.set(data[i].name, data[i].owner)
}
expect(dataMap.has("onoff_repeatoff")).assertTrue();
if (dataMap.has("onoff_repeatoff")) {
let data = dataMap.get("onoff_repeatoff");
console.debug("====>the account owner is: " + data);
expect(data).assertEqual("com.example.actsaccounttest");
}
appAccountManager.off('change', function (){ appAccountManager.off('change', function (){
console.debug("====>first off ActsAccountChangeOnOff_1200 finish===="); console.debug("====>first off ActsAccountChangeOnOff_1200 finish====");
appAccountManager.off('change', function (){ appAccountManager.off('change', function (){
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册