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

!1162 Update account xts code

Merge pull request !1162 from blackleon/xts_master_account_1124
......@@ -15,7 +15,8 @@
import account from '@ohos.account.appAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const STRCOUNT = 1025;
const NAMELIMIT = 512;
const LENGTHLIMIT = 1024;
describe('ActsAccountAddAccount', function () {
/*
......@@ -159,16 +160,16 @@ describe('ActsAccountAddAccount', function () {
/*
* @tc.number : ActsAccountAddAccount_0700
* @tc.name : Add account calllback form
* @tc.desc : The account name exceeds the length limit of 1024
* @tc.desc : The account name exceeds the length limit of 512 characters
*/
it('ActsAccountAddAccount_0700', 0, async function (done) {
console.debug("====>ActsAccountAddAccount_0700 start====");
var bigAccountName = '';
for (var i = 0; i < STRCOUNT; i++) {
bigAccountName += 't';
var limitAccountName = '';
for (var i = 0; i < NAMELIMIT + 1; i++) {
limitAccountName += 't';
}
var appAccountManager = account.createAppAccountManager();
appAccountManager.addAccount(bigAccountName, "account_extraInfo_callback_fourth", (err)=>{
appAccountManager.addAccount(limitAccountName, "account_extraInfo_callback_fourth", (err)=>{
console.debug("====>add account ActsAccountAddAccount_0700 err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsAccountAddAccount_0700 end====");
......@@ -179,17 +180,17 @@ describe('ActsAccountAddAccount', function () {
/*
* @tc.number : ActsAccountAddAccount_0800
* @tc.name : Add account promise form
* @tc.desc : The account name exceeds the length limit of 1024
* @tc.desc : The account name exceeds the length limit of 512 characters
*/
it('ActsAccountAddAccount_0800', 0, async function (done) {
console.debug("====>ActsAccountAddAccount_0800 start====");
var bigStr = '';
for (var i = 0; i < STRCOUNT; i++) {
bigStr += 't';
var limitAccountName = '';
for (var i = 0; i < NAMELIMIT + 1; i++) {
limitAccountName += 'n';
}
var appAccountManager = account.createAppAccountManager();
try{
await appAccountManager.addAccount(bigStr, "account_extraInfo_promise_fourth");
await appAccountManager.addAccount(limitAccountName, "account_extraInfo_promise_fourth");
}
catch(err){
console.debug("====>add account ActsAccountAddAccount_0800 err:" + JSON.stringify(err));
......@@ -202,16 +203,16 @@ describe('ActsAccountAddAccount', function () {
/*
* @tc.number : ActsAccountAddAccount_0900
* @tc.name : Add account calllback form
* @tc.desc : Additional information exceeds the length limit of 1024
* @tc.desc : Additional information exceeds the length limit of 1024 characters
*/
it('ActsAccountAddAccount_0900', 0, async function (done) {
console.debug("====>ActsAccountAddAccount_0900 start====");
var bigExtraInfo = '';
for (var i = 0; i < STRCOUNT; i++) {
bigExtraInfo += 't';
var limitAccountExtra = '';
for (var i = 0; i < LENGTHLIMIT + 1; i++) {
limitAccountExtra += 't';
}
var appAccountManager = account.createAppAccountManager();
appAccountManager.addAccount("account_name_callback_fifth", bigExtraInfo, (err)=>{
appAccountManager.addAccount("account_name_callback_fifth", limitAccountExtra, (err)=>{
console.debug("====>add account ActsAccountAddAccount_0900 err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsAccountAddAccount_0900 end====");
......@@ -222,17 +223,17 @@ describe('ActsAccountAddAccount', function () {
/*
* @tc.number : ActsAccountAddAccount_1000
* @tc.name : Add account promise form
* @tc.desc : Additional information exceeds the length limit of 1024
* @tc.desc : Additional information exceeds the length limit of 1024 characters
*/
it('ActsAccountAddAccount_1000', 0, async function (done) {
console.debug("====>ActsAccountAddAccount_1000 start====");
var bigStrExtra = '';
for (var i = 0; i < STRCOUNT; i++) {
bigStrExtra += 't';
var limitAccountExtra = '';
for (var i = 0; i < LENGTHLIMIT + 1; i++) {
limitAccountExtra += 'e';
}
var appAccountManager = account.createAppAccountManager();
try{
await appAccountManager.addAccount("account_name_promise_fifth", bigStrExtra);
await appAccountManager.addAccount("account_name_promise_fifth", limitAccountExtra);
}
catch(err){
console.debug("====>add account ActsAccountAddAccount_1000 err:" + JSON.stringify(err));
......@@ -539,4 +540,105 @@ describe('ActsAccountAddAccount', function () {
done();
}
});
/*
* @tc.number : ActsAccountAddAccount_2500
* @tc.name : Add account calllback form
* @tc.desc : The account name reaches the limit of 512 characters
*/
it('ActsAccountAddAccount_2500', 0, async function (done) {
console.debug("====>ActsAccountAddAccount_2500 start====");
var limitName = '';
for (var i = 0; i < NAMELIMIT; i++) {
limitName += 't';
}
var appAccountManager = account.createAppAccountManager();
appAccountManager.addAccount(limitName, "account_extraInfo_callback", (err)=>{
console.debug("====>add account ActsAccountAddAccount_2500 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
appAccountManager.deleteAccount(limitName, (err)=>{
console.debug("====>delete Account ActsAccountAddAccount_2500 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsAccountAddAccount_2500 end====");
done();
});
});
});
/*
* @tc.number : ActsAccountAddAccount_2600
* @tc.name : Add account promise form
* @tc.desc : The account name reaches the limit of 512 characters
*/
it('ActsAccountAddAccount_2600', 0, async function (done) {
console.debug("====>ActsAccountAddAccount_2600 start====");
var nameLimit = '';
for (var i = 0; i < NAMELIMIT; i++) {
nameLimit += 't';
}
var appAccountManager = account.createAppAccountManager();
console.debug("====>add account ActsAccountAddAccount_2600 start====");
try{
await appAccountManager.addAccount(nameLimit, "account_extraInfo_promise");
}
catch(err){
console.error("====>add account ActsAccountAddAccount_2600 err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>delete account ActsAccountAddAccount_2600 start====");
await appAccountManager.deleteAccount(nameLimit);
console.debug("====>ActsAccountAddAccount_2600 end====");
done();
});
/*
* @tc.number : ActsAccountAddAccount_2700
* @tc.name : Add account calllback form
* @tc.desc : Additional information reaches the limit of 1024 characters
*/
it('ActsAccountAddAccount_2700', 0, async function (done) {
console.debug("====>ActsAccountAddAccount_2700 start====");
var limitExtra = '';
for (var i = 0; i < LENGTHLIMIT; i++) {
limitExtra += 't';
}
var appAccountManager = account.createAppAccountManager();
appAccountManager.addAccount("account_extra_callback_limit", limitExtra, (err)=>{
console.debug("====>add account ActsAccountAddAccount_2700 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
appAccountManager.deleteAccount("account_extra_callback_limit", (err)=>{
console.debug("====>delete Account ActsAccountAddAccount_2700 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsAccountAddAccount_2700 end====");
done();
});
});
});
/*
* @tc.number : ActsAccountAddAccount_2800
* @tc.name : Add account promise form
* @tc.desc : Additional information reaches the limit of 1024 characters
*/
it('ActsAccountAddAccount_2800', 0, async function (done) {
console.debug("====>ActsAccountAddAccount_2800 start====");
var extraLimit = '';
for (var i = 0; i < LENGTHLIMIT; i++) {
extraLimit += 't';
}
var appAccountManager = account.createAppAccountManager();
try{
await appAccountManager.addAccount("account_extra_promise_limit", extraLimit);
}
catch(err){
console.error("====>add account ActsAccountAddAccount_2800 err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>delete account ActsAccountAddAccount_2800 start====");
appAccountManager.deleteAccount("account_extra_promise_limit");
console.debug("====>ActsAccountAddAccount_2800 end====");
done();
});
})
\ No newline at end of file
......@@ -15,7 +15,7 @@
import account from '@ohos.account.appAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const TIMEOUT = 10000;
const TIMEOUT = 1000;
const STRCOUNT = 1025;
describe('ActsAccountAppAccess', function () {
function sleep(delay) {
......
......@@ -15,7 +15,7 @@
import account from '@ohos.account.appAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const TIMEOUT = 10000;
const TIMEOUT = 1000;
describe('ActsAccountAssociatedData', function () {
function sleep(delay) {
var start = (new Date()).getTime();
......
......@@ -15,7 +15,7 @@
import account from '@ohos.account.appAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const TIMEOUT = 10000;
const TIMEOUT = 1000;
describe('ActsCreatAppAccountManager', function () {
function sleep(delay) {
var start = (new Date()).getTime();
......
......@@ -15,7 +15,7 @@
import account from '@ohos.account.appAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const TIMEOUT = 10000;
const TIMEOUT = 1000;
describe('ActsAccountCredential', function () {
function sleep(delay) {
var start = (new Date()).getTime();
......
......@@ -15,7 +15,7 @@
import account from '@ohos.account.appAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const TIMEOUT = 10000;
const TIMEOUT = 1000;
const STRCOUNT = 1025;
describe('ActsAccountDeleteAccount', function () {
function sleep(delay) {
......@@ -55,169 +55,169 @@ describe('ActsAccountDeleteAccount', function () {
/*
* @tc.number : ActsAccountDeleteAccount_0200
* @tc.name : Delete account calllback form
* @tc.desc : Delete unadded account in callback form
* @tc.name : Delete account promise form
* @tc.desc : Delete the added account in promise form
*/
it('ActsAccountDeleteAccount_0200', 0, async function (done) {
it('ActsAccountDeleteAccount_0200',0,async function (done){
console.debug("====>ActsAccountDeleteAccount_0200 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
appAccountManager.deleteAccount("deleteAccount_name_callback_second", (err)=>{
console.debug("====>delete Account ActsAccountDeleteAccount_0200 err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>add account ActsAccountAddAccount_0200 start====");
await appAccountManager.addAccount("deleteAccount_name_promise_first","extraInfo_promise_first");
try{
await appAccountManager.deleteAccount("deleteAccount_name_promise_first");
console.debug("====>ActsAccountDeleteAccount_0200 end====");
done();
});
}
catch(err){
console.error("====>delete account ActsAccountDeleteAccount_0200 err:" + JSON.stringify(err));
expect().assertFail();
done();
}
});
/*
* @tc.number : ActsAccountDeleteAccount_0300
* @tc.name : Delete account calllback form
* @tc.desc : Delete the added account, the first time it can be deleted, the second time the deletion fails
* @tc.desc : Delete unadded account in callback form
*/
it('ActsAccountDeleteAccount_0300', 0, async function (done) {
console.debug("====>ActsAccountDeleteAccount_0300 start====");
var appAccountManager = account.createAppAccountManager();
appAccountManager.addAccount("deleteAccount_name_callback_third", "extraInfo_callback_third", (err)=>{
console.debug("====>add account ActsAccountDeleteAccount_0300 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
appAccountManager.deleteAccount("deleteAccount_name_callback_third", (err)=>{
console.debug("====>delete account first time err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
appAccountManager.deleteAccount("deleteAccount_name_callback_third", (err)=>{
console.debug("====>delete Account second time err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsAccountDeleteAccount_0300 end====");
done();
});
});
console.debug("====>creat finish====");
appAccountManager.deleteAccount("deleteAccount_name_callback_second", (err)=>{
console.debug("====>delete Account ActsAccountDeleteAccount_0300 err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsAccountDeleteAccount_0300 end====");
done();
});
});
/*
* @tc.number : ActsAccountDeleteAccount_0400
* @tc.name : Delete account calllback form
* @tc.desc : Delete the account name exceeds the length limit of 1024
* @tc.name : Delete account promise form
* @tc.desc : Delete unadded account in promise form
*/
it('ActsAccountDeleteAccount_0400',0, async function (done){
it('ActsAccountDeleteAccount_0400', 0, async function(done){
console.debug("====>ActsAccountDeleteAccount_0400 start====");
var bigStr = '';
for (var i = 0; i < STRCOUNT; i++) {
bigStr += 't';
}
var appAccountManager = account.createAppAccountManager();
appAccountManager.deleteAccount(bigStr, (err)=>{
console.debug("====>delete Account ActsAccountDeleteAccount_0400 err:" + JSON.stringify(err));
try{
await appAccountManager.deleteAccount("deleteAccount_name_promise_second");
}
catch(err){
console.debug("====>delete account ActsAccountDeleteAccount_0400 err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsAccountDeleteAccount_0400 end====");
done();
});
}
});
/*
* @tc.number : ActsAccountDeleteAccount_0500
* @tc.name : Delete account calllback form
* @tc.desc : Delete the account name is an empty string
* @tc.desc : Delete the added account, the first time it can be deleted, the second time the deletion fails
*/
it('ActsAccountDeleteAccount_0500',0, async function (done){
it('ActsAccountDeleteAccount_0500', 0, async function (done) {
console.debug("====>ActsAccountDeleteAccount_0500 start====");
var appAccountManager = account.createAppAccountManager();
appAccountManager.deleteAccount("", (err)=>{
console.debug("====>delete Account ActsAccountDeleteAccount_0500 err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsAccountDeleteAccount_0500 end====");
done();
appAccountManager.addAccount("deleteAccount_name_callback_third", "extraInfo_callback_third", (err)=>{
console.debug("====>add account ActsAccountDeleteAccount_0500 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
appAccountManager.deleteAccount("deleteAccount_name_callback_third", (err)=>{
console.debug("====>delete account first time err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
appAccountManager.deleteAccount("deleteAccount_name_callback_third", (err)=>{
console.debug("====>delete Account second time err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsAccountDeleteAccount_0500 end====");
done();
});
});
});
});
/*
* @tc.number : ActsAccountDeleteAccount_0600
* @tc.name : Delete account promise form
* @tc.desc : Delete the added account in promise form
* @tc.desc : Delete the added account, the first time it can be deleted, the second time the deletion fails
*/
it('ActsAccountDeleteAccount_0600',0,async function (done){
it('ActsAccountDeleteAccount_0600', 0, async function (done){
console.debug("====>ActsAccountDeleteAccount_0600 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>add account ActsAccountAddAccount_0600 start====");
await appAccountManager.addAccount("deleteAccount_name_promise_first","extraInfo_promise_first");
await appAccountManager.addAccount("deleteAccount_name_promise_third", "extraInfo_promise_third");
console.debug("====>delete Account first time ActsAccountDeleteAccount_0600 start====");
await appAccountManager.deleteAccount("deleteAccount_name_promise_third");
console.debug("====>delete Account second time ActsAccountDeleteAccount_0600 start====");
try{
await appAccountManager.deleteAccount("deleteAccount_name_promise_first");
console.debug("====>ActsAccountDeleteAccount_0600 end====");
done();
await appAccountManager.deleteAccount("deleteAccount_name_promise_third");
}
catch(err){
console.error("====>delete account ActsAccountDeleteAccount_0600 err:" + JSON.stringify(err));
expect().assertFail();
console.debug("====>delete account ActsAccountDeleteAccount_0600 err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsAccountDeleteAccount_0600 end====");
done();
}
});
/*
* @tc.number : ActsAccountDeleteAccount_0700
* @tc.name : Delete account promise form
* @tc.desc : Delete unadded account in promise form
* @tc.name : Delete account calllback form
* @tc.desc : Delete the account name exceeds the length limit of 1024
*/
it('ActsAccountDeleteAccount_0700', 0, async function(done){
it('ActsAccountDeleteAccount_0700',0, async function (done){
console.debug("====>ActsAccountDeleteAccount_0700 start====");
var appAccountManager = account.createAppAccountManager();
try{
await appAccountManager.deleteAccount("deleteAccount_name_promise_second");
var bigStr = '';
for (var i = 0; i < STRCOUNT; i++) {
bigStr += 't';
}
catch(err){
console.debug("====>delete account ActsAccountDeleteAccount_0700 err:" + JSON.stringify(err));
var appAccountManager = account.createAppAccountManager();
appAccountManager.deleteAccount(bigStr, (err)=>{
console.debug("====>delete Account ActsAccountDeleteAccount_0700 err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsAccountDeleteAccount_0700 end====");
done();
}
});
});
/*
* @tc.number : ActsAccountDeleteAccount_0800
* @tc.name : Delete account promise form
* @tc.desc : Delete the added account, the first time it can be deleted, the second time the deletion fails
* @tc.desc : Delete the account name exceeds the length limit of 1024
*/
it('ActsAccountDeleteAccount_0800', 0, async function (done){
console.debug("====>ActsAccountDeleteAccount_0800 start====");
var bigStr = '';
for (var i = 0; i < STRCOUNT; i++) {
bigStr += 't';
}
var appAccountManager = account.createAppAccountManager();
console.debug("====>add account ActsAccountAddAccount_0800 start====");
await appAccountManager.addAccount("deleteAccount_name_promise_third", "extraInfo_promise_third");
console.debug("====>delete Account first time ActsAccountDeleteAccount_0800 start====");
await appAccountManager.deleteAccount("deleteAccount_name_promise_third");
console.debug("====>delete Account second time ActsAccountDeleteAccount_0800 start====");
console.debug("====>delete Account ActsAccountDeleteAccount_0800 start====");
try{
await appAccountManager.deleteAccount("deleteAccount_name_promise_third");
await appAccountManager.deleteAccount(bigStr);
}
catch(err){
console.debug("====>delete account ActsAccountDeleteAccount_0700 err:" + JSON.stringify(err));
console.debug("====>delete account ActsAccountDeleteAccount_0800 err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsAccountDeleteAccount_0700 end====");
console.debug("====>ActsAccountDeleteAccount_0800 end====");
done();
}
});
})
/*
* @tc.number : ActsAccountDeleteAccount_0900
* @tc.name : Delete account promise form
* @tc.desc : Delete the account name exceeds the length limit of 1024
* @tc.name : Delete account calllback form
* @tc.desc : Delete the account name is an empty string
*/
it('ActsAccountDeleteAccount_0900', 0, async function (done){
it('ActsAccountDeleteAccount_0900',0, async function (done){
console.debug("====>ActsAccountDeleteAccount_0900 start====");
var bigStr = '';
for (var i = 0; i < STRCOUNT; i++) {
bigStr += 't';
}
var appAccountManager = account.createAppAccountManager();
console.debug("====>delete Account ActsAccountDeleteAccount_0900 start====");
try{
await appAccountManager.deleteAccount(bigStr);
}
catch(err){
console.debug("====>delete account ActsAccountDeleteAccount_0900 err:" + JSON.stringify(err));
appAccountManager.deleteAccount("", (err)=>{
console.debug("====>delete Account ActsAccountDeleteAccount_0900 err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsAccountDeleteAccount_0900 end====");
done();
}
})
});
});
/*
* @tc.number : ActsAccountDeleteAccount_1000
......
......@@ -15,7 +15,7 @@
import account from '@ohos.account.appAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const TIMEOUT = 10000;
const TIMEOUT = 1000;
describe('ActsAccountSetGetExtraInfo', function () {
function sleep(delay) {
var start = (new Date()).getTime();
......
......@@ -15,7 +15,7 @@
import account from '@ohos.account.appAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const TIMEOUT = 10000;
const TIMEOUT = 1000;
const ERR_APPACCOUNT_SERVICE_PERMISSION_DENIED = 4521990;
describe('ActsAccountNoPermission', function () {
function sleep(delay) {
......
......@@ -15,7 +15,8 @@
import account from '@ohos.account.appAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const TIMEOUT = 10000;
const TIMEOUT = 1000;
const LENGTHLIMIT = 1024;
describe('ActsAccountOAuthToken', function () {
function sleep(delay) {
var start = (new Date()).getTime();
......@@ -559,4 +560,348 @@ describe('ActsAccountOAuthToken', function () {
console.debug("====>ActsAccountOAuthToken_2000 end====");
done();
});
/*
* @tc.number : ActsAccountOAuthToken_2100
* @tc.name : Test oauth token in callback form
* @tc.desc : Get the token after setting the token to an empty string
*/
it('ActsAccountOAuthToken_2100', 0, async function (done) {
console.debug("====>ActsAccountOAuthToken_2100 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
appAccountManager.addAccount("account_callback_empty", (err)=>{
console.debug("====>add account ActsAccountOAuthToken_2100 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
appAccountManager.setOAuthToken("account_callback_empty", "", (err)=>{
console.debug("====>setOAuthToken 2100 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
appAccountManager.getOAuthToken("account_callback_empty", (err, data)=>{
console.debug("====>getOAuthToken 2100 err:" + JSON.stringify(err));
console.debug("====>getOAuthToken 2100 data:" + data);
expect(err.code).assertEqual(0);
expect(data).assertEqual("");
appAccountManager.deleteAccount("account_callback_empty", (err)=>{
console.debug("====>delete Account 2100 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsAccountOAuthToken_2100 end====");
done();
});
});
});
});
});
/*
* @tc.number : ActsAccountOAuthToken_2200
* @tc.name : Test oauth token in promise form
* @tc.desc : Get the token after setting the token to an empty string
*/
it('ActsAccountOAuthToken_2200', 0, async function (done) {
console.debug("====>ActsAccountOAuthToken_2200 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
console.debug("====>add account ActsAccountOAuthToken_2200 start====");
await appAccountManager.addAccount("accountToken_promise_empty");
console.debug("====>setOAuthToken 2200 start====");
await appAccountManager.setOAuthToken("accountToken_promise_empty", "");
console.debug("====>getOAuthToken ActsAccountOAuthToken_2200 start====");
var data = await appAccountManager.getOAuthToken("accountToken_promise_empty");
expect(data).assertEqual("");
await appAccountManager.deleteAccount("accountToken_promise_empty");
console.debug("====>ActsAccountOAuthToken_2000 end====");
done();
});
/*
* @tc.number : ActsAccountOAuthToken_2300
* @tc.name : Test oauth token in callback form
* @tc.desc : Get the token after setting the token to a space string
*/
it('ActsAccountOAuthToken_2300', 0, async function (done) {
console.debug("====>ActsAccountOAuthToken_2300 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
appAccountManager.addAccount("account_callback_space", (err)=>{
console.debug("====>add account ActsAccountOAuthToken_2300 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
appAccountManager.setOAuthToken("account_callback_space", " ", (err)=>{
console.debug("====>setOAuthToken 2300 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
appAccountManager.getOAuthToken("account_callback_space", (err, data)=>{
console.debug("====>getOAuthToken 2300 err:" + JSON.stringify(err));
console.debug("====>getOAuthToken 2300 data:" + data);
expect(err.code).assertEqual(0);
expect(data).assertEqual(" ");
appAccountManager.deleteAccount("account_callback_space", (err)=>{
console.debug("====>delete Account 2300 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsAccountOAuthToken_2300 end====");
done();
});
});
});
});
});
/*
* @tc.number : ActsAccountOAuthToken_2400
* @tc.name : Test oauth token in promise form
* @tc.desc : Get the token after setting the token to a space string
*/
it('ActsAccountOAuthToken_2400', 0, async function (done) {
console.debug("====>ActsAccountOAuthToken_2400 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
console.debug("====>add account ActsAccountOAuthToken_2400 start====");
await appAccountManager.addAccount("accountToken_promise_space");
console.debug("====>setOAuthToken 2400 start====");
await appAccountManager.setOAuthToken("accountToken_promise_space", " ");
console.debug("====>getOAuthToken ActsAccountOAuthToken_2400 start====");
var data = await appAccountManager.getOAuthToken("accountToken_promise_space");
expect(data).assertEqual(" ");
await appAccountManager.deleteAccount("accountToken_promise_space");
console.debug("====>ActsAccountOAuthToken_2400 end====");
done();
});
/*
* @tc.number : ActsAccountOAuthToken_2500
* @tc.name : Test oauth token in callback form
* @tc.desc : Set the length of the token to exceed the length limit of 1024 characters
*/
it('ActsAccountOAuthToken_2500', 0, async function (done) {
console.debug("====>ActsAccountOAuthToken_2500 start====");
var limitToken = '';
for (var i = 0; i < LENGTHLIMIT + 1; i++) {
limitToken += 't';
}
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
appAccountManager.addAccount("account_callback_lengthlimit", (err)=>{
console.debug("====>add account ActsAccountOAuthToken_2500 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
appAccountManager.setOAuthToken("account_callback_lengthlimit", limitToken, (err)=>{
console.debug("====>setOAuthToken 2500 err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
appAccountManager.deleteAccount("account_callback_lengthlimit", (err)=>{
console.debug("====>delete Account 2500 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsAccountOAuthToken_2500 end====");
done();
});
});
});
});
/*
* @tc.number : ActsAccountOAuthToken_2600
* @tc.name : Test oauth token in promise form
* @tc.desc : Set the length of the token to exceed the length limit of 1024 characters
*/
it('ActsAccountOAuthToken_2600', 0, async function (done) {
console.debug("====>ActsAccountOAuthToken_2600 start====");
var limitToken = '';
for (var i = 0; i < LENGTHLIMIT + 1; i++) {
limitToken += 't';
}
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
console.debug("====>add account ActsAccountOAuthToken_2600 start====");
await appAccountManager.addAccount("account_promise_lengthlimit");
console.debug("====>setOAuthToken 2600 start====");
try{
await appAccountManager.setOAuthToken("account_promise_lengthlimit", limitToken);
}
catch(err){
console.debug("====>setOAuthToken ActsAccountOAuthToken_2600 err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>delete account ActsAccountOAuthToken_2600 start====");
await appAccountManager.deleteAccount("account_promise_lengthlimit");
console.debug("====>ActsAccountOAuthToken_2600 end====");
done();
}
});
/*
* @tc.number : ActsAccountOAuthToken_2700
* @tc.name : Test oauth token in callback form
* @tc.desc : Set the length of the token to just reach the length limit of 1024 characters
*/
it('ActsAccountOAuthToken_2700', 0, async function (done) {
console.debug("====>ActsAccountOAuthToken_2700 start====");
var tokenLimit = '';
for (var i = 0; i < LENGTHLIMIT; i++) {
tokenLimit += 't';
}
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
appAccountManager.addAccount("account_callback_limit", (err)=>{
console.debug("====>add account ActsAccountOAuthToken_2700 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
appAccountManager.setOAuthToken("account_callback_limit", tokenLimit, (err)=>{
console.debug("====>setOAuthToken 2700 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
appAccountManager.getOAuthToken("account_callback_limit", (err, data)=>{
console.debug("====>getOAuthToken 2700 err:" + JSON.stringify(err));
console.debug("====>getOAuthToken 2700 data:" + data);
expect(err.code).assertEqual(0);
expect(data).assertEqual(tokenLimit);
appAccountManager.deleteAccount("account_callback_limit", (err)=>{
console.debug("====>delete Account 2700 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsAccountOAuthToken_2700 end====");
done();
});
});
});
});
});
/*
* @tc.number : ActsAccountOAuthToken_2800
* @tc.name : Test oauth token in promise form
* @tc.desc : Set the length of the token to just reach the length limit of 1024 characters
*/
it('ActsAccountOAuthToken_2800', 0, async function (done) {
console.debug("====>ActsAccountOAuthToken_2800 start====");
var tokenLimit = '';
for (var i = 0; i < LENGTHLIMIT; i++) {
tokenLimit += 't';
}
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
console.debug("====>add account ActsAccountOAuthToken_2800 start====");
await appAccountManager.addAccount("accountToken_promise_limit");
console.debug("====>setOAuthToken 2400 start====");
await appAccountManager.setOAuthToken("accountToken_promise_limit", tokenLimit);
console.debug("====>getOAuthToken ActsAccountOAuthToken_2800 start====");
var data = await appAccountManager.getOAuthToken("accountToken_promise_limit");
expect(data).assertEqual(tokenLimit);
await appAccountManager.deleteAccount("accountToken_promise_limit");
console.debug("====>ActsAccountOAuthToken_2800 end====");
done();
});
/*
* @tc.number : ActsAccountOAuthToken_2900
* @tc.name : Test oauth token in callback form
* @tc.desc : Clear token parameter name is an empty string
*/
it('ActsAccountOAuthToken_2900', 0, async function (done) {
console.debug("====>ActsAccountOAuthToken_2900 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
appAccountManager.clearOAuthToken("", (err)=>{
console.debug("====>clearOAuthToken 2900 err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsAccountOAuthToken_1900 end====");
done();
});
});
/*
* @tc.number : ActsAccountOAuthToken_3000
* @tc.name : Test oauth token in promise form
* @tc.desc : Clear token parameter name is an empty string
*/
it('ActsAccountOAuthToken_3000', 0, async function (done) {
console.debug("====>ActsAccountOAuthToken_3000 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
console.debug("====>clearOAuthToken 3000 start====");
try{
await appAccountManager.clearOAuthToken("");
}
catch(err){
console.debug("====>clearOAuthToken ActsAccountOAuthToken_3000 err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsAccountOAuthToken_3000 end====");
done();
}
});
/*
* @tc.number : ActsAccountOAuthToken_3100
* @tc.name : Test oauth token in callback form
* @tc.desc : The clear token parameter name is a space string
*/
it('ActsAccountOAuthToken_3100', 0, async function (done) {
console.debug("====>ActsAccountOAuthToken_3100 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
appAccountManager.clearOAuthToken(" ", (err)=>{
console.debug("====>clearOAuthToken 3100 err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsAccountOAuthToken_3100 end====");
done();
});
});
/*
* @tc.number : ActsAccountOAuthToken_3200
* @tc.name : Test oauth token in promise form
* @tc.desc : The clear token parameter name is a space string
*/
it('ActsAccountOAuthToken_3200', 0, async function (done) {
console.debug("====>ActsAccountOAuthToken_3200 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
console.debug("====>clearOAuthToken 3200 start====");
try{
await appAccountManager.clearOAuthToken(" ");
}
catch(err){
console.debug("====>clearOAuthToken ActsAccountOAuthToken_3200 err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsAccountOAuthToken_3200 end====");
done();
}
});
/*
* @tc.number : ActsAccountOAuthToken_3300
* @tc.name : Test oauth token in callback form
* @tc.desc : Clear the token parameter name exceeds the length limit of 1024 characters
*/
it('ActsAccountOAuthToken_3300', 0, async function (done) {
console.debug("====>ActsAccountOAuthToken_3300 start====");
var nameLimit = '';
for (var i = 0; i < LENGTHLIMIT + 1; i++) {
nameLimit += 't';
}
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
appAccountManager.clearOAuthToken(nameLimit, (err)=>{
console.debug("====>clearOAuthToken first 3300 err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsAccountOAuthToken_3300 end====");
done();
});
});
/*
* @tc.number : ActsAccountOAuthToken_3400
* @tc.name : Test oauth token in promise form
* @tc.desc : Clear the token parameter name exceeds the length limit of 1024 characters
*/
it('ActsAccountOAuthToken_3400', 0, async function (done) {
console.debug("====>ActsAccountOAuthToken_3400 start====");
var nameLimit = '';
for (var i = 0; i < LENGTHLIMIT + 1; i++) {
nameLimit += 't';
}
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
console.debug("====>clearOAuthToken first 3400 start====");
try{
await appAccountManager.clearOAuthToken(nameLimit);
}
catch(err){
console.debug("====>clearOAuthToken ActsAccountOAuthToken_3400 err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsAccountOAuthToken_3400 end====");
done();
}
});
})
\ No newline at end of file
......@@ -36,26 +36,158 @@ export default {
console.debug("====>scene off finish====");
});
}
function changeOnCallbackFirst(data){
function changeOnExtra(data){
console.debug("====>receive change 0100 data:" + JSON.stringify(data));
try{
if(data[0].owner == "com.example.actsaccountchangeonoff" && data[0].name == "changeonoff_first"){
if(data[0].owner == "com.example.actsaccountchangeonoff" && data[0].name == "changeonoff_extra"){
var commonEventPublishData = {
data: "SUCCESS"
}
commonevent.publish("account_on_change_first", commonEventPublishData, publishCallback);
commonevent.publish("account_on_change_extra", commonEventPublishData, publishCallback);
}else{
var commonEventPublishData = {
data: "FAIL"
}
commonevent.publish("account_on_change_first", commonEventPublishData, publishCallback);
commonevent.publish("account_on_change_extra", commonEventPublishData, publishCallback);
}
}
catch(err){
var commonEventPublishData = {
data: "FAIL"
}
commonevent.publish("account_on_change_first", commonEventPublishData, publishCallback);
commonevent.publish("account_on_change_extra", commonEventPublishData, publishCallback);
}
}
function changeOnAssociateData(data){
console.debug("====>receive change 0200 data:" + JSON.stringify(data));
try{
if(data[0].owner == "com.example.actsaccountchangeonoff" && data[0].name == "onoff_associatedata"){
var commonEventPublishData = {
data: "SUCCESS"
}
commonevent.publish("account_on_change_associatedata", commonEventPublishData, publishCallback);
}else{
var commonEventPublishData = {
data: "FAIL"
}
commonevent.publish("account_on_change_associatedata", commonEventPublishData, publishCallback);
}
}
catch(err){
var commonEventPublishData = {
data: "FAIL"
}
commonevent.publish("account_on_change_associatedata", commonEventPublishData, publishCallback);
}
}
function changeOnCredential(data){
console.debug("====>receive change 0300 data:" + JSON.stringify(data));
try{
if(data[0].owner == "com.example.actsaccountchangeonoff" && data[0].name == "onoff_credential"){
var commonEventPublishData = {
data: "SUCCESS"
}
commonevent.publish("account_on_change_credential", commonEventPublishData, publishCallback);
}else{
var commonEventPublishData = {
data: "FAIL"
}
commonevent.publish("account_on_change_credential", commonEventPublishData, publishCallback);
}
}
catch(err){
var commonEventPublishData = {
data: "FAIL"
}
commonevent.publish("account_on_change_credential", commonEventPublishData, publishCallback);
}
}
function changeOnDeleteAnother(data){
console.debug("====>receive change 0400 data:" + JSON.stringify(data));
try{
if(data[0].owner == "com.example.actsaccountchangeonoff" && data[0].name == "onoff_deleteFir"){
var commonEventPublishData = {
data: "SUCCESS"
}
commonevent.publish("account_on_delete_another", commonEventPublishData, publishCallback);
}else{
var commonEventPublishData = {
data: "FAIL"
}
commonevent.publish("account_on_delete_another", commonEventPublishData, publishCallback);
}
}
catch(err){
var commonEventPublishData = {
data: "FAIL"
}
commonevent.publish("account_on_delete_another", commonEventPublishData, publishCallback);
}
}
function changeOnDelete(data){
console.debug("====>receive change 0500 data:" + JSON.stringify(data));
try{
if(data.length == 0){
var commonEventPublishData = {
data: "SUCCESS"
}
commonevent.publish("account_on_change_delete", commonEventPublishData, publishCallback);
}else{
var commonEventPublishData = {
data: "FAIL"
}
commonevent.publish("account_on_change_delete", commonEventPublishData, publishCallback);
}
}
catch(err){
var commonEventPublishData = {
data: "FAIL"
}
commonevent.publish("account_on_change_delete", commonEventPublishData, publishCallback);
}
}
function changeOnDisableAnother(data){
console.debug("====>receive change 0600 data:" + JSON.stringify(data));
try{
if(data[0].owner == "com.example.actsaccountchangeonoff" && data[0].name == "onoff_enableFir"){
var commonEventPublishData = {
data: "SUCCESS"
}
commonevent.publish("account_on_disable_another", commonEventPublishData, publishCallback);
}else{
var commonEventPublishData = {
data: "FAIL"
}
commonevent.publish("account_on_disable_another", commonEventPublishData, publishCallback);
}
}
catch(err){
var commonEventPublishData = {
data: "FAIL"
}
commonevent.publish("account_on_disable_another", commonEventPublishData, publishCallback);
}
}
function changeOnDisable(data){
console.debug("====>receive change 0700 data:" + JSON.stringify(data));
try{
if(data.length == 0){
var commonEventPublishData = {
data: "SUCCESS"
}
commonevent.publish("account_on_change_disable", commonEventPublishData, publishCallback);
}else{
var commonEventPublishData = {
data: "FAIL"
}
commonevent.publish("account_on_change_disable", commonEventPublishData, publishCallback);
}
}
catch(err){
var commonEventPublishData = {
data: "FAIL"
}
commonevent.publish("account_on_change_disable", commonEventPublishData, publishCallback);
}
}
function subscriberCallback(err, data){
......@@ -64,13 +196,36 @@ export default {
switch(data.code){
case 1:
console.debug("====>receive event 0100 event:" + data.event);
appAccountManager.on('change', ["com.example.actsaccountchangeonoff"], changeOnCallbackFirst);
appAccountManager.on('change', ["com.example.actsaccountchangeonoff"], changeOnExtra);
break;
case 2:
console.debug("====>receive event 0200 event:" + data.event);
appAccountManager.on('change', ["com.example.actsaccountchangeonoff"], changeOnAssociateData);
break;
case 3:
console.debug("====>receive event 0300 event:" + data.event);
appAccountManager.on('change', ["com.example.actsaccountchangeonoff"], changeOnCredential);
break;
case 4:
console.debug("====>receive event 0400 event:" + data.event);
appAccountManager.on('change', ["com.example.actsaccountchangeonoff"], changeOnDeleteAnother);
break;
case 5:
console.debug("====>receive event 0500 event:" + data.event);
appAccountManager.on('change', ["com.example.actsaccountchangeonoff"], changeOnDelete);
break;
case 6:
console.debug("====>receive event 0600 event:" + data.event);
appAccountManager.on('change', ["com.example.actsaccountchangeonoff"], changeOnDisableAnother);
break;
case 7:
console.debug("====>receive event 0700 event:" + data.event);
appAccountManager.on('change', ["com.example.actsaccountchangeonoff"], changeOnDisable);
break;
default:
console.debug("====>receive event enter default====");
break;
}
}
var subscriber
commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册