提交 6c04446f 编写于 作者: Z zhaoyuan17

Fix appaccount test bug

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