未验证 提交 9c02dfe3 编写于 作者: O openharmony_ci 提交者: Gitee

!1559 Update osaccount test code

Merge pull request !1559 from 高曦/master_account_0113
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
import osaccount from '@ohos.account.osAccount' import osaccount from '@ohos.account.osAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const TIMEOUT = 1000;
const ERR_OSACCOUNT_KIT_ACTIVATE_OS_ACCOUNT_ERROR = 4587571;
describe('ActsOsAccountSystemTest', function () { describe('ActsOsAccountSystemTest', function () {
/* /*
...@@ -26,17 +28,29 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -26,17 +28,29 @@ describe('ActsOsAccountSystemTest', function () {
console.debug("====>ActsOsAccountActivate_0100 start===="); console.debug("====>ActsOsAccountActivate_0100 start====");
var osAccountManager = osaccount.getAccountManager(); var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish===="); console.debug("====>get AccountManager finish====");
osAccountManager.isOsAccountActived(100, (err, data)=>{ osAccountManager.isOsAccountActived(100, (err, isActived)=>{
console.debug("====>isOsAccountActived err:" + JSON.stringify(err)); console.debug("====>isOsAccountActived err:" + JSON.stringify(err));
console.debug("====>isOsAccountActived data:" + data); console.debug("====>isOsAccountActived data:" + isActived);
expect(err.code).assertEqual(0); expect(err.code).assertEqual(0);
expect(data).assertTrue(); if(isActived){
osAccountManager.activateOsAccount(100, (err)=>{ osAccountManager.activateOsAccount(100, (err)=>{
console.debug("====>activateOsAccount err:" + JSON.stringify(err)); console.debug("====>activateOsAccount err:" + JSON.stringify(err));
expect(err.code != 0).assertTrue(); expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_ACTIVATE_OS_ACCOUNT_ERROR);
console.debug("====>ActsOsAccountActivate_0100 end===="); console.debug("====>ActsOsAccountActivate_0100 end====");
done(); done();
}) })
}else{
osAccountManager.activateOsAccount(100, (err)=>{
console.debug("====>activateOsAccount first err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
osAccountManager.activateOsAccount(100, (err)=>{
console.debug("====>activateOsAccount second err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_ACTIVATE_OS_ACCOUNT_ERROR);
console.debug("====>ActsOsAccountActivate_0100 end====");
done();
})
})
}
}) })
}); });
...@@ -49,23 +63,29 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -49,23 +63,29 @@ describe('ActsOsAccountSystemTest', function () {
console.debug("====>ActsOsAccountActivate_0200 start===="); console.debug("====>ActsOsAccountActivate_0200 start====");
var osAccountManager = osaccount.getAccountManager(); var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish===="); console.debug("====>get AccountManager finish====");
try{
var isActived = await osAccountManager.isOsAccountActived(100); var isActived = await osAccountManager.isOsAccountActived(100);
console.debug("====>isOsAccountActived err:" + JSON.stringify(isActived));
if(isActived){
try{
await osAccountManager.activateOsAccount(100);
}catch(err){ }catch(err){
console.error("====>catch isOsAccountActived 0200 err:" + JSON.stringify(err)); console.debug("====>catch activateOsAccount 0200 err:" + JSON.stringify(err));
expect().assertFail(); expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_ACTIVATE_OS_ACCOUNT_ERROR);
console.debug("====>ActsOsAccountActivate_0200 end====");
done(); done();
} }
console.debug("====>isOsAccountActived err:" + JSON.stringify(isActived)); }else{
expect(isActived).assertTrue(); console.debug("====>switch to 100 user====");
await osAccountManager.activateOsAccount(100);
try{ try{
await osAccountManager.activateOsAccount(100); await osAccountManager.activateOsAccount(100);
}catch(err){ }catch(err){
console.debug("====>catch activateOsAccount 0200 err:" + JSON.stringify(err)); console.debug("====>catch activateOsAccount 0200 err:" + JSON.stringify(err));
expect(err.code != 0).assertTrue(); expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_ACTIVATE_OS_ACCOUNT_ERROR);
console.debug("====>ActsOsAccountActivate_0200 end===="); console.debug("====>ActsOsAccountActivate_0200 end====");
done(); done();
} }
}
}); });
/* /*
...@@ -158,7 +178,7 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -158,7 +178,7 @@ describe('ActsOsAccountSystemTest', function () {
console.debug("====>get AccountManager finish===="); console.debug("====>get AccountManager finish====");
osAccountManager.activateOsAccount(0, (err)=>{ osAccountManager.activateOsAccount(0, (err)=>{
console.debug("====>activateOsAccount to 0 user err:" + JSON.stringify(err)); console.debug("====>activateOsAccount to 0 user err:" + JSON.stringify(err));
expect(err.code != 0).assertTrue(); expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_ACTIVATE_OS_ACCOUNT_ERROR);
console.debug("====>ActsOsAccountActivate_0500 end===="); console.debug("====>ActsOsAccountActivate_0500 end====");
done(); done();
}) })
...@@ -177,7 +197,7 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -177,7 +197,7 @@ describe('ActsOsAccountSystemTest', function () {
await osAccountManager.activateOsAccount(0); await osAccountManager.activateOsAccount(0);
}catch(err){ }catch(err){
console.debug("====>activateOsAccount to 0 user err:" + JSON.stringify(err)); console.debug("====>activateOsAccount to 0 user err:" + JSON.stringify(err));
expect(err.code != 0).assertTrue(); expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_ACTIVATE_OS_ACCOUNT_ERROR);
console.debug("====>ActsOsAccountActivate_0600 end===="); console.debug("====>ActsOsAccountActivate_0600 end====");
done(); done();
} }
...@@ -194,7 +214,7 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -194,7 +214,7 @@ describe('ActsOsAccountSystemTest', function () {
console.debug("====>get AccountManager finish===="); console.debug("====>get AccountManager finish====");
osAccountManager.activateOsAccount(-1, (err)=>{ osAccountManager.activateOsAccount(-1, (err)=>{
console.debug("====>activateOsAccount to -1 user err:" + JSON.stringify(err)); console.debug("====>activateOsAccount to -1 user err:" + JSON.stringify(err));
expect(err.code != 0).assertTrue(); expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_ACTIVATE_OS_ACCOUNT_ERROR);
console.debug("====>ActsOsAccountActivate_0700 end===="); console.debug("====>ActsOsAccountActivate_0700 end====");
done(); done();
}) })
...@@ -213,7 +233,7 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -213,7 +233,7 @@ describe('ActsOsAccountSystemTest', function () {
await osAccountManager.activateOsAccount(-1); await osAccountManager.activateOsAccount(-1);
}catch(err){ }catch(err){
console.debug("====>activateOsAccount to -1 user err:" + JSON.stringify(err)); console.debug("====>activateOsAccount to -1 user err:" + JSON.stringify(err));
expect(err.code != 0).assertTrue(); expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_ACTIVATE_OS_ACCOUNT_ERROR);
console.debug("====>ActsOsAccountActivate_0800 end===="); console.debug("====>ActsOsAccountActivate_0800 end====");
done(); done();
} }
...@@ -228,12 +248,18 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -228,12 +248,18 @@ describe('ActsOsAccountSystemTest', function () {
console.debug("====>ActsOsAccountActivate_0900 start===="); console.debug("====>ActsOsAccountActivate_0900 start====");
var osAccountManager = osaccount.getAccountManager(); var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish===="); console.debug("====>get AccountManager finish====");
osAccountManager.activateOsAccount("Abc", (err)=>{ var localIdStr = "100";
console.debug("====>activateOsAccount to 'Abc' user err:" + JSON.stringify(err)); function funcActivateCallback(err){
expect(err.code != 0).assertTrue(); console.debug("====>error received callback====");
console.debug("====>receive activateOsAccount err: " + JSON.stringify(err));
expect().assertFail();
done();
}
osAccountManager.activateOsAccount(localIdStr, funcActivateCallback);
setTimeout(()=>{
console.debug("====>ActsOsAccountActivate_0900 end===="); console.debug("====>ActsOsAccountActivate_0900 end====");
done(); done();
}) }, TIMEOUT);
}); });
/* /*
...@@ -245,14 +271,11 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -245,14 +271,11 @@ describe('ActsOsAccountSystemTest', function () {
console.debug("====>ActsOsAccountActivate_1000 start===="); console.debug("====>ActsOsAccountActivate_1000 start====");
var osAccountManager = osaccount.getAccountManager(); var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish===="); console.debug("====>get AccountManager finish====");
try{ var localIdStr = "100";
await osAccountManager.activateOsAccount("Abc"); var activateResult = await osAccountManager.activateOsAccount(localIdStr);
}catch(err){ expect(activateResult).assertEqual(null);
console.debug("====>activateOsAccount to 'Abc' user err:" + JSON.stringify(err));
expect(err.code != 0).assertTrue();
console.debug("====>ActsOsAccountActivate_1000 end===="); console.debug("====>ActsOsAccountActivate_1000 end====");
done(); done();
}
}); });
/* /*
...@@ -264,12 +287,17 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -264,12 +287,17 @@ describe('ActsOsAccountSystemTest', function () {
console.debug("====>ActsOsAccountActivate_1100 start===="); console.debug("====>ActsOsAccountActivate_1100 start====");
var osAccountManager = osaccount.getAccountManager(); var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish===="); console.debug("====>get AccountManager finish====");
osAccountManager.activateOsAccount(undefined, (err)=>{ function funcActivateCallback(err){
console.debug("====>activateOsAccount to undefined user err:" + JSON.stringify(err)); console.debug("====>error received callback====");
expect(err.code != 0).assertTrue(); console.debug("====>receive activateOsAccount err: " + JSON.stringify(err));
expect().assertFail();
done();
}
osAccountManager.activateOsAccount(undefined, funcActivateCallback);
setTimeout(()=>{
console.debug("====>ActsOsAccountActivate_1100 end===="); console.debug("====>ActsOsAccountActivate_1100 end====");
done(); done();
}) }, TIMEOUT);
}); });
/* /*
...@@ -281,14 +309,10 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -281,14 +309,10 @@ describe('ActsOsAccountSystemTest', function () {
console.debug("====>ActsOsAccountActivate_1200 start===="); console.debug("====>ActsOsAccountActivate_1200 start====");
var osAccountManager = osaccount.getAccountManager(); var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish===="); console.debug("====>get AccountManager finish====");
try{ var activateResult = await osAccountManager.activateOsAccount(undefined);
await osAccountManager.activateOsAccount(undefined); expect(activateResult).assertEqual(null);
}catch(err){
console.debug("====>activateOsAccount to undefined user err:" + JSON.stringify(err));
expect(err.code != 0).assertTrue();
console.debug("====>ActsOsAccountActivate_1200 end===="); console.debug("====>ActsOsAccountActivate_1200 end====");
done(); done();
}
}); });
/* /*
...@@ -303,7 +327,7 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -303,7 +327,7 @@ describe('ActsOsAccountSystemTest', function () {
console.debug("====>get AccountManager finish===="); console.debug("====>get AccountManager finish====");
osAccountManager.activateOsAccount(nonExistentLocalId, (err)=>{ osAccountManager.activateOsAccount(nonExistentLocalId, (err)=>{
console.debug("====>activateOsAccount to nonexist user err:" + JSON.stringify(err)); console.debug("====>activateOsAccount to nonexist user err:" + JSON.stringify(err));
expect(err.code != 0).assertTrue(); expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_ACTIVATE_OS_ACCOUNT_ERROR);
console.debug("====>ActsOsAccountActivate_1300 end===="); console.debug("====>ActsOsAccountActivate_1300 end====");
done(); done();
}) })
...@@ -323,7 +347,7 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -323,7 +347,7 @@ describe('ActsOsAccountSystemTest', function () {
await osAccountManager.activateOsAccount(nonExistentLocalId); await osAccountManager.activateOsAccount(nonExistentLocalId);
}catch(err){ }catch(err){
console.debug("====>activateOsAccount to nonexist user err:" + JSON.stringify(err)); console.debug("====>activateOsAccount to nonexist user err:" + JSON.stringify(err));
expect(err.code != 0).assertTrue(); expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_ACTIVATE_OS_ACCOUNT_ERROR);
console.debug("====>ActsOsAccountActivate_1400 end===="); console.debug("====>ActsOsAccountActivate_1400 end====");
done(); done();
} }
......
...@@ -245,7 +245,7 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -245,7 +245,7 @@ describe('ActsOsAccountSystemTest', function () {
/* /*
* @tc.number : ActsOsAccountOnOff_0700 * @tc.number : ActsOsAccountOnOff_0700
* @tc.name : Subscribe and unsubscribing local multi-user * @tc.name : Subscribe and unsubscribing local multi-user
* @tc.desc : Verification cannot cancel activating type not subscribed * @tc.desc : Validate subscription callback with parameter name as empty string
*/ */
it('ActsOsAccountOnOff_0700', 0, async function (done) { it('ActsOsAccountOnOff_0700', 0, async function (done) {
console.debug("====>ActsOsAccountOnOff_0700 start===="); console.debug("====>ActsOsAccountOnOff_0700 start====");
...@@ -269,7 +269,7 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -269,7 +269,7 @@ describe('ActsOsAccountSystemTest', function () {
expect(err.code).assertEqual(0); expect(err.code).assertEqual(0);
expect(osAccountInfo.localName).assertEqual("osAccountNameE"); expect(osAccountInfo.localName).assertEqual("osAccountNameE");
osAccountManager.activateOsAccount(localId, (err)=>{ osAccountManager.activateOsAccount(localId, (err)=>{
console.debug("====>activateOsAccount err:" + JSON.stringify(err)); console.debug("====>activateOsAccount errcode:" + JSON.stringify(err));
expect(err.code).assertEqual(0); expect(err.code).assertEqual(0);
setTimeout(()=>{ setTimeout(()=>{
osAccountManager.removeOsAccount(localId, (err)=>{ osAccountManager.removeOsAccount(localId, (err)=>{
...@@ -286,7 +286,7 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -286,7 +286,7 @@ describe('ActsOsAccountSystemTest', function () {
/* /*
* @tc.number : ActsOsAccountOnOff_0800 * @tc.number : ActsOsAccountOnOff_0800
* @tc.name : Subscribe and unsubscribing local multi-user * @tc.name : Subscribe and unsubscribing local multi-user
* @tc.desc : Verification cannot cancel activating type not subscribed * @tc.desc : Validate subscription promise with parameter name as empty string
*/ */
it('ActsOsAccountOnOff_0800', 0, async function (done) { it('ActsOsAccountOnOff_0800', 0, async function (done) {
console.debug("====>ActsOsAccountOnOff_0800 start===="); console.debug("====>ActsOsAccountOnOff_0800 start====");
......
...@@ -15,7 +15,9 @@ ...@@ -15,7 +15,9 @@
import osAccount from '@ohos.account.osAccount' import osAccount from '@ohos.account.osAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' 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;
describe('ActsOsAccountThirdPartyTest', function () { describe('ActsOsAccountThirdPartyTest', function () {
/* /*
...@@ -63,13 +65,13 @@ describe('ActsOsAccountThirdPartyTest', function () { ...@@ -63,13 +65,13 @@ describe('ActsOsAccountThirdPartyTest', function () {
/* /*
* @tc.number : ActsOsAccountIsActived_0100 * @tc.number : ActsOsAccountIsActived_0100
* @tc.name : isOsAccountActived callback * @tc.name : isOsAccountActived callback
* @tc.desc : Verify that users are not switched and query 100 users as active * @tc.desc : Verify query 0 user status is true
*/ */
it('ActsOsAccountIsActived_0100', 0, async function(done){ it('ActsOsAccountIsActived_0100', 0, async function(done){
console.debug("====>ActsOsAccountIsActived_0100 start===="); console.debug("====>ActsOsAccountIsActived_0100 start====");
var AccountManager = osAccount.getAccountManager(); var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish===="); console.debug("====>get os AccountManager finish====");
AccountManager.isOsAccountActived(100, (err, isActived)=>{ AccountManager.isOsAccountActived(0, (err, isActived)=>{
console.debug("====>isOsAccountActived err:" + JSON.stringify(err)); console.debug("====>isOsAccountActived err:" + JSON.stringify(err));
console.debug("====>isOsAccountActived isActived:" + isActived); console.debug("====>isOsAccountActived isActived:" + isActived);
expect(err.code).assertEqual(0); expect(err.code).assertEqual(0);
...@@ -82,14 +84,14 @@ describe('ActsOsAccountThirdPartyTest', function () { ...@@ -82,14 +84,14 @@ describe('ActsOsAccountThirdPartyTest', function () {
/* /*
* @tc.number : ActsOsAccountIsActived_0200 * @tc.number : ActsOsAccountIsActived_0200
* @tc.name : isOsAccountActived promise * @tc.name : isOsAccountActived promise
* @tc.desc : Verify that users are not switched and query 100 users as active * @tc.desc : Verify query 0 user status is true
*/ */
it('ActsOsAccountIsActived_0200', 0, async function(done){ it('ActsOsAccountIsActived_0200', 0, async function(done){
console.debug("====>ActsOsAccountIsActived_0200 start===="); console.debug("====>ActsOsAccountIsActived_0200 start====");
var AccountManager = osAccount.getAccountManager(); var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish===="); console.debug("====>get os AccountManager finish====");
try{ try{
var isActived = await AccountManager.isOsAccountActived(100); var isActived = await AccountManager.isOsAccountActived(0);
} }
catch(err){ catch(err){
console.debug("====>catch isOsAccountActived err:" + JSON.stringify(err)); console.debug("====>catch isOsAccountActived err:" + JSON.stringify(err));
...@@ -105,15 +107,16 @@ describe('ActsOsAccountThirdPartyTest', function () { ...@@ -105,15 +107,16 @@ describe('ActsOsAccountThirdPartyTest', function () {
/* /*
* @tc.number : ActsOsAccountIsActived_0300 * @tc.number : ActsOsAccountIsActived_0300
* @tc.name : isOsAccountActived callback * @tc.name : isOsAccountActived callback
* @tc.desc : Authentication query 0 user active status failed * @tc.desc : Authentication failed to query the active status of the user that does not exist
*/ */
it('ActsOsAccountIsActived_0300', 0, async function(done){ it('ActsOsAccountIsActived_0300', 0, async function(done){
console.debug("====>ActsOsAccountIsActived_0300 start"); console.debug("====>ActsOsAccountIsActived_0300 start");
var AccountManager = osAccount.getAccountManager(); var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish===="); console.debug("====>get os AccountManager finish====");
AccountManager.isOsAccountActived(0, (err)=>{ var nonExistLocalId = 1000;
AccountManager.isOsAccountActived(nonExistLocalId, (err)=>{
console.debug("====>isOsAccountActived err:" + JSON.stringify(err)); console.debug("====>isOsAccountActived err:" + JSON.stringify(err));
expect(err.code !=0 ).assertEqual(true); expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_ACTIVED_ERROR);
console.debug("====>ActsOsAccountIsActived_0300 end"); console.debug("====>ActsOsAccountIsActived_0300 end");
done(); done();
}) })
...@@ -122,18 +125,20 @@ describe('ActsOsAccountThirdPartyTest', function () { ...@@ -122,18 +125,20 @@ describe('ActsOsAccountThirdPartyTest', function () {
/* /*
* @tc.number : ActsOsAccountIsActived_0400 * @tc.number : ActsOsAccountIsActived_0400
* @tc.name : isOsAccountActived promise * @tc.name : isOsAccountActived promise
* @tc.desc : Authentication query 0 user active status failed * @tc.desc : Authentication failed to query the active status of the user that does not exist
*/ */
it('ActsOsAccountIsActived_0400', 0, async function(done){ it('ActsOsAccountIsActived_0400', 0, async function(done){
console.debug("====>isOsAccountActived_0400 start===="); console.debug("====>ActsOsAccountIsActived_0400 start====");
var AccountManager = osAccount.getAccountManager(); var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish===="); console.debug("====>get os AccountManager finish====");
var nonExistLocalId = 1000;
try{ try{
await AccountManager.isOsAccountActived(0); await AccountManager.isOsAccountActived(nonExistLocalId);
} }
catch(err){ catch(err){
console.debug("====>isOsAccountActived err:" + JSON.stringify(err)); console.debug("====>isOsAccountActived err:" + JSON.stringify(err));
expect(err.code !=0 ).assertTrue(); expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_ACTIVED_ERROR);
console.debug("====>ActsOsAccountIsActived_0400 end");
done(); done();
} }
}) })
...@@ -141,40 +146,81 @@ describe('ActsOsAccountThirdPartyTest', function () { ...@@ -141,40 +146,81 @@ describe('ActsOsAccountThirdPartyTest', function () {
/* /*
* @tc.number : ActsOsAccountIsActived_0500 * @tc.number : ActsOsAccountIsActived_0500
* @tc.name : isOsAccountActived callback * @tc.name : isOsAccountActived callback
* @tc.desc : Authentication failed to query the active status of the user that does not exist * @tc.desc : Verify that the query active state is not received with parameter type mismatch
*/ */
it('ActsOsAccountIsActived_0500', 0, async function(done){ it('ActsOsAccountIsActived_0500', 0, async function(done){
console.debug("====>ActsOsAccountIsActived_0500 start"); console.debug("====>ActsOsAccountIsActived_0500 start");
var AccountManager = osAccount.getAccountManager(); var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish===="); console.debug("====>get os AccountManager finish====");
var nonExistLocalId = 1000; var localIdStr = "100";
AccountManager.isOsAccountActived(nonExistLocalId, (err)=>{ function funcIsActived(err, data){
console.debug("====>isOsAccountActived err:" + JSON.stringify(err)); console.debug("====>error received callback====");
expect(err.code !=0).assertEqual(true); console.debug("====>receive isOsAccountActived err: " + JSON.stringify(err));
console.debug("====>ActsOsAccountIsActived_0500 end"); console.debug("====>receive isOsAccountActived data: " + JSON.stringify(data));
expect().assertFail();
done(); done();
}) }
AccountManager.isOsAccountActived(localIdStr, funcIsActived);
setTimeout(()=>{
console.debug("====>ActsOsAccountIsActived_0500 end====");
done();
}, TIMEOUT);
}) })
/* /*
* @tc.number : ActsOsAccountIsActived_0600 * @tc.number : ActsOsAccountIsActived_0600
* @tc.name : isOsAccountActived promise * @tc.name : isOsAccountActived promise
* @tc.desc : Authentication failed to query the active status of the user that does not exist * @tc.desc : Verify that the query active state is not received with parameter type mismatch
*/ */
it('ActsOsAccountIsActived_0600', 0, async function(done){ it('ActsOsAccountIsActived_0600', 0, async function(done){
console.debug("====>ActsOsAccountIsActived_0600 start===="); console.debug("====>ActsOsAccountIsActived_0600 start====");
var AccountManager = osAccount.getAccountManager(); var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish===="); console.debug("====>get os AccountManager finish====");
var nonExistLocalId = 1000; var localIdStr = "100";
try{ var isActived = await AccountManager.isOsAccountActived(localIdStr);
await AccountManager.isOsAccountActived(nonExistLocalId); console.debug("====>get active status is: " + isActived);
} expect(isActived).assertEqual(null);
catch(err){ console.debug("====>ActsOsAccountIsActived_0600 end====");
console.debug("====>isOsAccountActived err:" + JSON.stringify(err)); done();
expect(err.code !=0 ).assertTrue(); })
console.debug("====>ActsOsAccountIsActived_0600 end");
/*
* @tc.number : ActsOsAccountIsActived_0700
* @tc.name : isOsAccountActived callback
* @tc.desc : Verify that the query active state is not received with parameter undefined
*/
it('ActsOsAccountIsActived_0700', 0, async function(done){
console.debug("====>ActsOsAccountIsActived_0700 start");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
function funcIsActived(err, data){
console.debug("====>error received callback====");
console.debug("====>receive isOsAccountActived err: " + JSON.stringify(err));
console.debug("====>receive isOsAccountActived data: " + JSON.stringify(data));
expect().assertFail();
done(); done();
} }
AccountManager.isOsAccountActived(undefined, funcIsActived);
setTimeout(()=>{
console.debug("====>ActsOsAccountIsActived_0700 end====");
done();
}, TIMEOUT);
})
/*
* @tc.number : ActsOsAccountIsActived_0800
* @tc.name : isOsAccountActived promise
* @tc.desc : Verify that the query active state is not received with parameter undefined
*/
it('ActsOsAccountIsActived_0800', 0, async function(done){
console.debug("====>ActsOsAccountIsActived_0800 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
var isActived = await AccountManager.isOsAccountActived(undefined);
console.debug("====>get active status is: " + isActived);
expect(isActived).assertEqual(null);
console.debug("====>ActsOsAccountIsActived_0800 end====");
done();
}) })
/* /*
...@@ -219,18 +265,54 @@ describe('ActsOsAccountThirdPartyTest', function () { ...@@ -219,18 +265,54 @@ describe('ActsOsAccountThirdPartyTest', function () {
done(); done();
}) })
/*
* @tc.number : ActsOsAccountVerified_0100
* @tc.name : isOsAccountVerified callback
* @tc.desc : Verify that the initial state query is unlocked to false
*/
it('ActsOsAccountVerified_0100', 0, async function(done){
console.debug("====>isOsAccountVerified_0100 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.isOsAccountVerified((err, data)=>{
console.debug("====>isOsAccountVerified err:" + JSON.stringify(err));
console.debug("====>isOsAccountVerified data:" + data);
expect(err.code).assertEqual(0);
expect(data).assertEqual(false);
console.debug("====>ActsOsAccountVerified_0100 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountVerified_0200
* @tc.name : isOsAccountVerified promise
* @tc.desc : Verify that the initial state query is unlocked to false
*/
it('ActsOsAccountVerified_0200', 0, async function(done){
console.debug("====>isOsAccountVerified_0200 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
var isVerified = await AccountManager.isOsAccountVerified();
console.debug("====>isOsAccountVerified data:" + isVerified);
expect(isVerified).assertEqual(false);
console.debug("====>ActsOsAccountVerified_0200 end====");
done();
})
/* /*
* @tc.number : ActsOsAccountIsVerified_0300 * @tc.number : ActsOsAccountIsVerified_0300
* @tc.name : isOsAccountVerified callback * @tc.name : isOsAccountVerified callback
* @tc.desc : Verify query 0 user is unlocked failed * @tc.desc : Verify that the initial state query 0 user is unlocked to false
*/ */
it('ActsOsAccountIsVerified_0300', 0, async function(done){ it('ActsOsAccountIsVerified_0300', 0, async function(done){
console.debug("====>ActsOsAccountIsVerified_0300 start===="); console.debug("====>ActsOsAccountIsVerified_0300 start====");
var AccountManager = osAccount.getAccountManager(); var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish===="); console.debug("====>get os AccountManager finish====");
AccountManager.isOsAccountVerified(0, (err)=>{ AccountManager.isOsAccountVerified(0, (err, data)=>{
console.debug("====>isOsAccountVerified err:" + JSON.stringify(err)); console.debug("====>isOsAccountVerified err:" + JSON.stringify(err));
expect(err.code !=0 ).assertEqual(true); expect(err.code).assertEqual(0);
expect(data).assertFalse();
console.debug("====>ActsOsAccountIsVerified_0300 end===="); console.debug("====>ActsOsAccountIsVerified_0300 end====");
done(); done();
}) })
...@@ -239,21 +321,16 @@ describe('ActsOsAccountThirdPartyTest', function () { ...@@ -239,21 +321,16 @@ describe('ActsOsAccountThirdPartyTest', function () {
/* /*
* @tc.number : ActsOsAccountIsVerified_0400 * @tc.number : ActsOsAccountIsVerified_0400
* @tc.name : isOsAccountVerified promise * @tc.name : isOsAccountVerified promise
* @tc.desc : Verify query 0 user is unlocked failed * @tc.desc : Verify that the initial state query 0 user is unlocked to false
*/ */
it('ActsOsAccountIsVerified_0400', 0, async function(done){ it('ActsOsAccountIsVerified_0400', 0, async function(done){
console.debug("====>ActsOsAccountIsVerified_0400 start===="); console.debug("====>ActsOsAccountIsVerified_0400 start====");
var AccountManager = osAccount.getAccountManager(); var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish===="); console.debug("====>get os AccountManager finish====");
try{ var isVerified = await AccountManager.isOsAccountVerified(0);
await AccountManager.isOsAccountVerified(0); expect(isVerified).assertFalse();
}
catch(err){
console.debug("====>isOsAccountVerified err:" + JSON.stringify(err));
expect(err.code !=0 ).assertTrue();
console.debug("====>ActsOsAccountIsVerified_0400 end===="); console.debug("====>ActsOsAccountIsVerified_0400 end====");
done(); done();
}
}) })
/* /*
...@@ -265,12 +342,19 @@ describe('ActsOsAccountThirdPartyTest', function () { ...@@ -265,12 +342,19 @@ describe('ActsOsAccountThirdPartyTest', function () {
console.debug("====>ActsOsAccountIsVerified_0500 start===="); console.debug("====>ActsOsAccountIsVerified_0500 start====");
var AccountManager = osAccount.getAccountManager(); var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish===="); console.debug("====>get os AccountManager finish====");
AccountManager.isOsAccountVerified("100", (err)=>{ var localIdStr = "100";
console.debug("====>isOsAccountVerified err:" + JSON.stringify(err)); function funcIsVerified(err, data){
expect(err.code !=0 ).assertEqual(true); console.debug("====>error received callback====");
console.debug("====>receive isOsAccountVerified err: " + JSON.stringify(err));
console.debug("====>receive isOsAccountVerified data: " + JSON.stringify(data));
expect().assertFail();
done();
}
AccountManager.isOsAccountVerified(localIdStr, funcIsVerified);
setTimeout(()=>{
console.debug("====>ActsOsAccountIsVerified_0500 end===="); console.debug("====>ActsOsAccountIsVerified_0500 end====");
done(); done();
}) }, TIMEOUT);
}) })
/* /*
...@@ -282,15 +366,12 @@ describe('ActsOsAccountThirdPartyTest', function () { ...@@ -282,15 +366,12 @@ describe('ActsOsAccountThirdPartyTest', function () {
console.debug("====>ActsOsAccountIsVerified_0600 start===="); console.debug("====>ActsOsAccountIsVerified_0600 start====");
var AccountManager = osAccount.getAccountManager(); var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish===="); console.debug("====>get os AccountManager finish====");
try{ var localIdStr = "100";
await AccountManager.isOsAccountVerified("100"); var isVerified = await AccountManager.isOsAccountVerified(localIdStr);
} console.debug("====>get verified status is: " + isVerified);
catch(err){ expect(isVerified).assertEqual(null);
console.debug("====>isOsAccountVerified err:" + JSON.stringify(err));
expect(err.code !=0 ).assertTrue();
console.debug("====>ActsOsAccountIsVerified_0600 end===="); console.debug("====>ActsOsAccountIsVerified_0600 end====");
done(); done();
}
}) })
/* /*
...@@ -302,12 +383,19 @@ describe('ActsOsAccountThirdPartyTest', function () { ...@@ -302,12 +383,19 @@ describe('ActsOsAccountThirdPartyTest', function () {
console.debug("====>ActsOsAccountIsVerified_0700 start===="); console.debug("====>ActsOsAccountIsVerified_0700 start====");
var AccountManager = osAccount.getAccountManager(); var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish===="); console.debug("====>get os AccountManager finish====");
AccountManager.isOsAccountVerified(undefined, (err)=>{ var localIdUndefined = undefined;
console.debug("====>isOsAccountVerified err:" + JSON.stringify(err)); function funcIsVerified(err, data){
expect(err.code !=0 ).assertEqual(true); console.debug("====>error received callback====");
console.debug("====>receive isOsAccountVerified err: " + JSON.stringify(err));
console.debug("====>receive isOsAccountVerified data: " + JSON.stringify(data));
expect().assertFail();
done();
}
AccountManager.isOsAccountVerified(localIdUndefined, funcIsVerified);
setTimeout(()=>{
console.debug("====>ActsOsAccountIsVerified_0700 end===="); console.debug("====>ActsOsAccountIsVerified_0700 end====");
done(); done();
}) }, TIMEOUT);
}) })
/* /*
...@@ -319,15 +407,12 @@ describe('ActsOsAccountThirdPartyTest', function () { ...@@ -319,15 +407,12 @@ describe('ActsOsAccountThirdPartyTest', function () {
console.debug("====>ActsOsAccountIsVerified_0800 start===="); console.debug("====>ActsOsAccountIsVerified_0800 start====");
var AccountManager = osAccount.getAccountManager(); var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish===="); console.debug("====>get os AccountManager finish====");
try{ var localIdUndefined = undefined;
await AccountManager.isOsAccountVerified(undefined); var isVerified = await AccountManager.isOsAccountVerified(localIdUndefined);
} console.debug("====>get verified status is: " + isVerified);
catch(err){ expect(isVerified).assertEqual(null);
console.debug("====>ActsOsAccountIsVerified_0800 err:" + JSON.stringify(err));
expect(err.code !=0 ).assertTrue();
console.debug("====>ActsOsAccountIsVerified_0800 end===="); console.debug("====>ActsOsAccountIsVerified_0800 end====");
done(); done();
}
}) })
/* /*
...@@ -342,7 +427,7 @@ describe('ActsOsAccountThirdPartyTest', function () { ...@@ -342,7 +427,7 @@ describe('ActsOsAccountThirdPartyTest', function () {
var osAccountLocalId = 1000; var osAccountLocalId = 1000;
AccountManager.isOsAccountVerified(osAccountLocalId, (err)=>{ AccountManager.isOsAccountVerified(osAccountLocalId, (err)=>{
console.debug("====>isOsAccountVerified err:" + JSON.stringify(err)); console.debug("====>isOsAccountVerified err:" + JSON.stringify(err));
expect(err.code !=0 ).assertEqual(true); expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_VERIFIED_ERROR);
console.debug("====>ActsOsAccountIsVerified_0900 end===="); console.debug("====>ActsOsAccountIsVerified_0900 end====");
done(); done();
}) })
...@@ -363,7 +448,7 @@ describe('ActsOsAccountThirdPartyTest', function () { ...@@ -363,7 +448,7 @@ describe('ActsOsAccountThirdPartyTest', function () {
} }
catch(err){ catch(err){
console.debug("====>isOsAccountVerified err:" + JSON.stringify(err)); console.debug("====>isOsAccountVerified err:" + JSON.stringify(err));
expect(err.code !=0 ).assertTrue(); expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_VERIFIED_ERROR);
console.debug("====>ActsOsAccountIsVerified_1000 end===="); console.debug("====>ActsOsAccountIsVerified_1000 end====");
done(); done();
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册