未验证 提交 72a2fbb0 编写于 作者: O openharmony_ci 提交者: Gitee

!1657 Update account xts case and fix appaccount bug

Merge pull request !1657 from 高曦/master_osaccount_0121
......@@ -2,7 +2,7 @@
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "3000000",
"test-timeout": "1500000",
"package": "com.example.actsaccountpressure",
"shell-timeout": "60000"
},
......
......@@ -189,7 +189,7 @@ describe('ActsAccountNoPermission', function () {
console.debug("====>ActsAccountNoPermission_0700 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
var selfBundle = "com.example.actsaccountnopermission";
var selfBundle = "com.example.actsaccounttest";
appAccountManager.addAccount("getAll_callback_nopermission", (err)=>{
console.debug("====>add account 0700 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
......@@ -215,7 +215,7 @@ describe('ActsAccountNoPermission', function () {
console.debug("====>ActsAccountNoPermission_0800 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
var selfBundle = "com.example.actsaccountnopermission";
var selfBundle = "com.example.actsaccounttest";
console.debug("====>add account 0800 start====");
await appAccountManager.addAccount("getAll_promise_nopermission");
console.debug("====>getAllAccounts 0800 start====");
......
......@@ -655,16 +655,19 @@ describe('ActsAccountChangeOnOff', async function () {
expect(data).assertEqual("com.example.actsaccounttest");
}
twiceSign = twiceSign + 1;
appAccountManager.off('change', function (){
console.debug("====>off ActsAccountChangeOnOff_1000 finish====");
appAccountManager.deleteAccount("onoff_twice", (err)=>{
console.debug("====>delete account ActsAccountChangeOnOff_1000 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
expect(twiceSign).assertEqual(2);
console.debug("====>ActsAccountChangeOnOff_1000 end====");
done();
setTimeout(async function (){
console.debug("====>off start====");
appAccountManager.off('change', function (){
console.debug("====>off ActsAccountChangeOnOff_1000 finish====");
appAccountManager.deleteAccount("onoff_twice", (err)=>{
console.debug("====>delete account ActsAccountChangeOnOff_1000 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
expect(twiceSign).assertEqual(2);
console.debug("====>ActsAccountChangeOnOff_1000 end====");
done();
});
});
});
}, 1000)
}
try{
appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnFirstCallback);
......
......@@ -2,7 +2,7 @@
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "300000",
"test-timeout": "800000",
"package": "com.example.actsosaccountsystemtest",
"shell-timeout": "60000"
},
......
......@@ -16,7 +16,7 @@ import osaccount from '@ohos.account.osAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const TIMEOUT = 1000;
const ERR_OSACCOUNT_KIT_ACTIVATE_OS_ACCOUNT_ERROR = 4587571;
const ERR_OSACCOUNT_KIT_ACTIVATE_OS_ACCOUNT_ERROR = 4587574;
describe('ActsOsAccountSystemTest', function () {
/*
......
......@@ -14,4 +14,8 @@
*/
require('./Query.test.js')
require('./Activate.test.js')
require('./OnOff.test.js')
\ No newline at end of file
require('./OnOff.test.js')
require('./Set.test.js')
require('./Constraints.test.js')
require('./Photo.test.js')
require('./Create.test.js')
\ No newline at end of file
......@@ -25,47 +25,6 @@ describe('ActsOsAccountSystemTest', function () {
}
}
/*
* @tc.number : ActsOsAccountOnOff_0100
* @tc.name : Subscribe and unsubscribing local multi-user
* @tc.desc : Verify that the activating type subscription can receive user switching
*/
it('ActsOsAccountOnOff_0100', 0, async function (done) {
console.debug("====>ActsOsAccountOnOff_0100 start====");
var osAccountManager = osaccount.getAccountManager();
var localId;
console.debug("====>get AccountManager finish====");
function onCallback(receiveLocalId){
console.debug("====>receive localId:" + receiveLocalId);
if(receiveLocalId == localId){
osAccountManager.off("activating", "osAccountOnOffNameA", offCallback);
}
}
function removeCallback(err){
console.debug("====>remove localId: " + localId + " err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountOnOff_0100 end====");
done();
}
function offCallback(){
console.debug("====>off enter")
osAccountManager.removeOsAccount(localId, removeCallback);
}
osAccountManager.on("activating", "osAccountOnOffNameA", onCallback);
sleep(TIMEOUT);
osAccountManager.createOsAccount("osAccountNameA", 1, (err, osAccountInfo)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo));
localId = osAccountInfo.localId;
expect(err.code).assertEqual(0);
expect(osAccountInfo.localName).assertEqual("osAccountNameA");
osAccountManager.activateOsAccount(localId, (err)=>{
console.debug("====>activateOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
});
});
});
/*
* @tc.number : ActsOsAccountOnOff_0200
* @tc.name : Subscribe and unsubscribing local multi-user
......@@ -217,7 +176,7 @@ describe('ActsOsAccountSystemTest', function () {
setTimeout(()=>{
console.debug("====>ActsOsAccountOnOff_0500 end====");
done();
}, TIMEOUT);
}, TIMEOUT);
});
/*
......@@ -271,6 +230,7 @@ describe('ActsOsAccountSystemTest', function () {
osAccountManager.activateOsAccount(localId, (err)=>{
console.debug("====>activateOsAccount errcode:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
sleep(TIMEOUT);
setTimeout(()=>{
osAccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>remove localId: " + localId + " err:" + JSON.stringify(err));
......@@ -714,7 +674,7 @@ describe('ActsOsAccountSystemTest', function () {
setTimeout(()=>{
console.debug("====>ActsOsAccountOnOff_1700 end====");
done();
}, TIMEOUT);
}, TIMEOUT);
});
/*
......@@ -735,7 +695,7 @@ describe('ActsOsAccountSystemTest', function () {
setTimeout(()=>{
console.debug("====>ActsOsAccountOnOff_1800 end====");
done();
}, TIMEOUT);
}, TIMEOUT);
});
/*
......@@ -756,7 +716,59 @@ describe('ActsOsAccountSystemTest', function () {
setTimeout(()=>{
console.debug("====>ActsOsAccountOnOff_1900 end====");
done();
}, TIMEOUT);
}, TIMEOUT);
});
/*
* @tc.number : ActsOsAccountOnOff_2000
* @tc.name : Subscribe and unsubscribing local multi-user
* @tc.desc : Authenticate switch back after switching user subscription receives two callbacks
*/
it('ActsOsAccountOnOff_2000', 0, async function (done) {
console.debug("====>ActsOsAccountOnOff_2000 start====");
var osAccountManager = osaccount.getAccountManager();
var localId;
var enterSign = 0;
var localHundredId = 100;
console.debug("====>get AccountManager finish====");
function onCallback(receiveLocalId){
console.debug("====>receive localId:" + receiveLocalId);
if(receiveLocalId == localId){
enterSign = enterSign + 1;
}
if(receiveLocalId == localHundredId){
enterSign = enterSign + 1;
osAccountManager.off("activate", "osAccountOnOffNameQ", offCallback);
}
}
function offCallback(){
console.debug("====>off enter")
osAccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>remove localId: " + localId + " err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>the enterSign is: " + enterSign);
expect(enterSign).assertEqual(2);
console.debug("====>ActsOsAccountOnOff_2000 end====");
done();
})
}
osAccountManager.on("activate", "osAccountOnOffNameQ", onCallback);
sleep(TIMEOUT);
osAccountManager.createOsAccount("osAccountNameQ", 1, (err, osAccountInfo)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo));
localId = osAccountInfo.localId;
expect(err.code).assertEqual(0);
expect(osAccountInfo.localName).assertEqual("osAccountNameQ");
osAccountManager.activateOsAccount(localId, (err)=>{
console.debug("====>activateOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
osAccountManager.activateOsAccount(localHundredId, (err)=>{
console.debug("====>activateOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
});
});
});
})
})
\ No newline at end of file
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import osaccount from '@ohos.account.osaccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const TIMEOUT = 1000;
const ERR_OSACCOUNT_KIT_GET_OS_ACCOUNT_PROFILE_PHOTO_ERROR = 4587558;
describe('ActsOsAccountSystemTest', function () {
/*
* @tc.number : ActsOsAccountProfilePhoto_0100
* @tc.name : getOsAccountProfilePhoto callback
* @tc.desc : Verify that the newly created user photo is an empty string
*/
it('ActsOsAccountProfilePhoto_0100', 0, async function (done) {
console.debug("====>ActsOsAccountProfilePhoto_0100 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
osAccountManager.createOsAccount("osAccountNameIdSerialC", osaccount.OsAccountType.NORMAL, (err, data)=>{
console.debug("====>create os account err: " + JSON.stringify(err));
console.debug("====>create os account OsAccountInfo: " + JSON.stringify(data));
expect(err.code).assertEqual(0);
expect(data.localName).assertEqual("osAccountNameIdSerialC");
localId = data.localId;
osAccountManager.getOsAccountProfilePhoto(localId, (err, photo)=>{
console.debug("====>getOsAccountProfilePhoto err:" + JSON.stringify(err));
console.debug("====>get photo:" + photo + " by localId: " + localId);
expect(err.code).assertEqual(0);
expect(photo).assertEqual("");
osAccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>remove localId: " + localId + " err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountProfilePhoto_0100 end====");
done();
})
})
})
});
/*
* @tc.number : ActsOsAccountProfilePhoto_0200
* @tc.name : getOsAccountProfilePhoto promise
* @tc.desc : Verify that the newly created user photo is an empty string
*/
it('ActsOsAccountProfilePhoto_0200', 0, async function (done) {
console.debug("====>ActsOsAccountProfilePhoto_0200 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
var data = await osAccountManager.createOsAccount("osAccountNameIdSerialD", osaccount.OsAccountType.NORMAL);
console.debug("====>create os account OsAccountInfo: " + JSON.stringify(data));
expect(data.localName).assertEqual("osAccountNameIdSerialD");
localId = data.localId;
var photo = await osAccountManager.getOsAccountProfilePhoto(localId);
console.debug("====>get photo:" + photo + " by localId: " + localId);
expect(photo).assertEqual("");
await osAccountManager.removeOsAccount(localId);
console.debug("====>ActsOsAccountProfilePhoto_0200 end====");
done();
});
/*
* @tc.number : ActsOsAccountProfilePhoto_0300
* @tc.name : getOsAccountProfilePhoto callback
* @tc.desc : Verify to ger the photo of the user that does not exist
*/
it('ActsOsAccountProfilePhoto_0300', 0, async function (done) {
console.debug("====>ActsOsAccountProfilePhoto_0300 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var nonExistentId = 1000;
osAccountManager.getOsAccountProfilePhoto(nonExistentId, (err)=>{
console.debug("====>getOsAccountProfilePhoto err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_GET_OS_ACCOUNT_PROFILE_PHOTO_ERROR);
console.debug("====>ActsOsAccountProfilePhoto_0300 end====");
done();
})
});
/*
* @tc.number : ActsOsAccountProfilePhoto_0400
* @tc.name : getOsAccountProfilePhoto promise
* @tc.desc : Verify to get the photo of the user that does not exist
*/
it('ActsOsAccountProfilePhoto_0400', 0, async function (done) {
console.debug("====>ActsOsAccountProfilePhoto_0400 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var nonExistentId = 1000;
try{
await osAccountManager.getOsAccountProfilePhoto(nonExistentId);
}catch(err){
console.debug("====>getOsAccountProfilePhoto err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_GET_OS_ACCOUNT_PROFILE_PHOTO_ERROR);
console.debug("====>ActsOsAccountProfilePhoto_0400 end====");
done();
}
});
/*
* @tc.number : ActsOsAccountProfilePhoto_0500
* @tc.name : getOsAccountProfilePhoto callback
* @tc.desc : Verify to get photo with parameter type mismatch
*/
it('ActsOsAccountProfilePhoto_0500', 0, async function (done) {
console.debug("====>ActsOsAccountProfilePhoto_0500 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localIdStr = "100";
function gerPhotoCallback(err, data){
console.debug("====>getOsAccountProfilePhoto err:" + JSON.stringify(err));
expect().assertFail();
done();
}
osAccountManager.getOsAccountProfilePhoto(localIdStr, gerPhotoCallback);
setTimeout(()=>{
console.debug("====>ActsOsAccountProfilePhoto_0500 end====");
done();
}, TIMEOUT);
});
/*
* @tc.number : ActsOsAccountProfilePhoto_0600
* @tc.name : getOsAccountProfilePhoto promise
* @tc.desc : Verify to the get photo with parameter type mismatch
*/
it('ActsOsAccountProfilePhoto_0600', 0, async function (done) {
console.debug("====>ActsOsAccountProfilePhoto_0600 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localIdStr = "100";
var data = await osAccountManager.getOsAccountProfilePhoto(localIdStr);
expect(data).assertEqual(null);
console.debug("====>ActsOsAccountProfilePhoto_0600 end====");
done();
});
/*
* @tc.number : ActsOsAccountProfilePhoto_0700
* @tc.name : getOsAccountProfilePhoto callback
* @tc.desc : Verify to get photo with parameter undefined
*/
it('ActsOsAccountProfilePhoto_0700', 0, async function (done) {
console.debug("====>ActsOsAccountProfilePhoto_0700 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var undefinedId = undefined;
function gerPhotoCallback(err, data){
console.debug("====>getOsAccountProfilePhoto err:" + JSON.stringify(err));
expect().assertFail();
done();
}
osAccountManager.getOsAccountProfilePhoto(undefinedId,gerPhotoCallback);
setTimeout(()=>{
console.debug("====>ActsOsAccountProfilePhoto_0700 end====");
done();
}, TIMEOUT);
});
/*
* @tc.number : ActsOsAccountProfilePhoto_0800
* @tc.name : getOsAccountProfilePhoto promise
* @tc.desc : Verify to get photo with parameter undefined
*/
it('ActsOsAccountProfilePhoto_0800', 0, async function (done) {
console.debug("====>ActsOsAccountProfilePhoto_0800 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var undefinedId = undefined;
var data = await osAccountManager.getOsAccountProfilePhoto(undefinedId);
expect(data).assertEqual(null);
console.debug("====>ActsOsAccountProfilePhoto_0800 end====");
done();
});
})
\ No newline at end of file
......@@ -17,7 +17,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
const TIMEOUT = 1000;
const OSACCOUNTMAXNUMBER = 999;
const ERR_OSACCOUNT_KIT_QUERY_OS_ACCOUNT_BY_ID_ERROR = 4587554;
const ERR_OSACCOUNT_KIT_QUERY_OS_ACCOUNT_BY_ID_ERROR = 4587556;
describe('ActsOsAccountSystemTest', function () {
/*
......
......@@ -2,7 +2,7 @@
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "100000",
"test-timeout": "200000",
"package": "com.example.actsosaccountthirdpartytest",
"shell-timeout": "60000"
},
......
......@@ -35,6 +35,7 @@ export default {
core.init()
const configService = core.getDefaultService('config')
this.timeout = 8000;
configService.setConfig(this)
require('../../../test/List.test')
......
......@@ -12,4 +12,5 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('./OsAccountIs.test.js')
\ No newline at end of file
require('./OsAccountIs.test.js')
require('./OsAccountGet.test.js')
\ No newline at end of file
......@@ -16,8 +16,8 @@ import osAccount from '@ohos.account.osAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const TIMEOUT = 1000;
const ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_ACTIVED_ERROR = 4587543;
const ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_VERIFIED_ERROR = 4587546;
const ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_ACTIVED_ERROR = 4587545;
const ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_VERIFIED_ERROR = 4587548;
describe('ActsOsAccountThirdPartyTest', function () {
/*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册