提交 6d01f9c6 编写于 作者: O openharmony_ci 提交者: Gitee

!1242 Update account xts code 1130

Merge pull request !1242 from blackleon/master_1130_foraccount
......@@ -17,7 +17,6 @@ group("appaccount_hap") {
testonly = true
if (is_standard_system) {
deps = [
"actsaccountchangeonoff:ActsAccountChangeOnOff",
"actsaccounttest:ActsAccountTest",
"actsgetallaccounts:ActsGetAllAccounts",
"actssetchecksyncenable:ActsSetCheckSyncEnable",
......
# 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAccountChangeOnOff") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAccountChangeOnOff"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "60000",
"package": "com.example.actsaccountchangeonoff",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsAccountChangeOnOff.hap",
"ActsAccountSceneOnOff.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.actsaccountchangeonoff",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsaccountchangeonoff",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.actsaccountchangeonoff.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ 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.
*/
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
/*
* 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 file from '@system.file'
import {Core, ExpectExtend} from 'deccjsunit/index'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: "测试on/off接口"
},
onInit() {
this.title = "测试on/off接口";
},
onShow() {
console.info('onShow finish')
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
},
onReady() {
},
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "ActsAccountChangeOnOff"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ 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.
*/
require('./ExampleJsunit.test.js')
\ No newline at end of file
......@@ -2,7 +2,7 @@
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "200000",
"test-timeout": "300000",
"package": "com.example.actsaccounttest",
"shell-timeout": "60000"
},
......@@ -10,7 +10,8 @@
{
"test-file-name": [
"ActsAccountTest.hap",
"ActsAccountSceneAppAccess.hap"
"ActsAccountSceneAppAccess.hap",
"ActsAccountSceneOnOff.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
......
......@@ -21,8 +21,8 @@ describe('ActsAccountAddAccount', function () {
/*
* @tc.number : ActsAccountAddAccount_0100
* @tc.name : Add account calllback form
* @tc.desc : Add account in calllback form without additional information
* @tc.name : Add account callback form
* @tc.desc : Add account in callback form without additional information
*/
it('ActsAccountAddAccount_0100', 0, async function (done) {
console.debug("====>ActsAccountAddAccount_0100 start====");
......@@ -66,8 +66,8 @@ describe('ActsAccountAddAccount', function () {
/*
* @tc.number : ActsAccountAddAccount_0300
* @tc.name : Add account calllback form
* @tc.desc : Add account in calllback form with additional information
* @tc.name : Add account callback form
* @tc.desc : Add account in callback form with additional information
*/
it('ActsAccountAddAccount_0300', 0, async function (done) {
console.debug("====>ActsAccountAddAccount_0300 start====");
......@@ -112,7 +112,7 @@ describe('ActsAccountAddAccount', function () {
/*
* @tc.number : ActsAccountAddAccount_0500
* @tc.name : Add account calllback form
* @tc.name : Add account callback form
* @tc.desc : Repeatedly add the same name account and the same additional information
*/
it('ActsAccountAddAccount_0500', 0, async function (done) {
......@@ -159,7 +159,7 @@ describe('ActsAccountAddAccount', function () {
/*
* @tc.number : ActsAccountAddAccount_0700
* @tc.name : Add account calllback form
* @tc.name : Add account callback form
* @tc.desc : The account name exceeds the length limit of 512 characters
*/
it('ActsAccountAddAccount_0700', 0, async function (done) {
......@@ -202,7 +202,7 @@ describe('ActsAccountAddAccount', function () {
/*
* @tc.number : ActsAccountAddAccount_0900
* @tc.name : Add account calllback form
* @tc.name : Add account callback form
* @tc.desc : Additional information exceeds the length limit of 1024 characters
*/
it('ActsAccountAddAccount_0900', 0, async function (done) {
......@@ -245,7 +245,7 @@ describe('ActsAccountAddAccount', function () {
/*
* @tc.number : ActsAccountAddAccount_1100
* @tc.name : Add account calllback form
* @tc.name : Add account callback form
* @tc.desc : The account name is an empty string
*/
it('ActsAccountAddAccount_1100', 0, async function (done) {
......@@ -281,7 +281,7 @@ describe('ActsAccountAddAccount', function () {
/*
* @tc.number : ActsAccountAddAccount_1300
* @tc.name : Add account calllback form
* @tc.name : Add account callback form
* @tc.desc : Additional information is an empty string
*/
it('ActsAccountAddAccount_1300', 0, async function (done) {
......@@ -323,7 +323,7 @@ describe('ActsAccountAddAccount', function () {
/*
* @tc.number : ActsAccountAddAccount_1500
* @tc.name : Add account calllback form
* @tc.name : Add account callback form
* @tc.desc : The account name is a special character such as a space
*/
it('ActsAccountAddAccount_1500', 0, async function (done) {
......@@ -361,7 +361,7 @@ describe('ActsAccountAddAccount', function () {
/*
* @tc.number : ActsAccountAddAccount_1700
* @tc.name : Add account calllback form
* @tc.name : Add account callback form
* @tc.desc : The account name is a special string
*/
it('ActsAccountAddAccount_1700', 0, async function (done) {
......@@ -406,7 +406,7 @@ describe('ActsAccountAddAccount', function () {
/*
* @tc.number : ActsAccountAddAccount_1900
* @tc.name : Add account calllback form
* @tc.name : Add account callback form
* @tc.desc : Additional information is a special character such as a space
*/
it('ActsAccountAddAccount_1900', 0, async function (done) {
......@@ -451,7 +451,7 @@ describe('ActsAccountAddAccount', function () {
/*
* @tc.number : ActsAccountAddAccount_2100
* @tc.name : Add account calllback form
* @tc.name : Add account callback form
* @tc.desc : Additional information is a special string
*/
it('ActsAccountAddAccount_2100', 0, async function (done) {
......@@ -496,7 +496,7 @@ describe('ActsAccountAddAccount', function () {
/*
* @tc.number : ActsAccountAddAccount_2300
* @tc.name : Add account calllback form
* @tc.name : Add account callback form
* @tc.desc : Repeatedly add accounts with the same name and different additional information
*/
it('ActsAccountAddAccount_2300', 0, async function (done) {
......@@ -543,7 +543,7 @@ describe('ActsAccountAddAccount', function () {
/*
* @tc.number : ActsAccountAddAccount_2500
* @tc.name : Add account calllback form
* @tc.name : Add account callback form
* @tc.desc : The account name reaches the limit of 512 characters
*/
it('ActsAccountAddAccount_2500', 0, async function (done) {
......@@ -594,7 +594,7 @@ describe('ActsAccountAddAccount', function () {
/*
* @tc.number : ActsAccountAddAccount_2700
* @tc.name : Add account calllback form
* @tc.name : Add account callback form
* @tc.desc : Additional information reaches the limit of 1024 characters
*/
it('ActsAccountAddAccount_2700', 0, async function (done) {
......
......@@ -15,8 +15,8 @@
import account from '@ohos.account.appAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const NAMELIMIT = 512;
const TIMEOUT = 1000;
const STRCOUNT = 1025;
describe('ActsAccountDeleteAccount', function () {
function sleep(delay) {
var start = (new Date()).getTime();
......@@ -34,7 +34,7 @@ describe('ActsAccountDeleteAccount', function () {
/*
* @tc.number : ActsAccountDeleteAccount_0100
* @tc.name : Delete account calllback form
* @tc.name : Delete account callback form
* @tc.desc : Delete the added account in callback form
*/
it('ActsAccountDeleteAccount_0100', 0, async function (done) {
......@@ -77,7 +77,7 @@ describe('ActsAccountDeleteAccount', function () {
/*
* @tc.number : ActsAccountDeleteAccount_0300
* @tc.name : Delete account calllback form
* @tc.name : Delete account callback form
* @tc.desc : Delete unadded account in callback form
*/
it('ActsAccountDeleteAccount_0300', 0, async function (done) {
......@@ -113,7 +113,7 @@ describe('ActsAccountDeleteAccount', function () {
/*
* @tc.number : ActsAccountDeleteAccount_0500
* @tc.name : Delete account calllback form
* @tc.name : Delete account callback form
* @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) {
......@@ -161,17 +161,17 @@ describe('ActsAccountDeleteAccount', function () {
/*
* @tc.number : ActsAccountDeleteAccount_0700
* @tc.name : Delete account calllback form
* @tc.desc : Delete the account name exceeds the length limit of 1024
* @tc.name : Delete account callback form
* @tc.desc : Delete the account name exceeds the length limit of 512 characters
*/
it('ActsAccountDeleteAccount_0700',0, async function (done){
console.debug("====>ActsAccountDeleteAccount_0700 start====");
var bigStr = '';
for (var i = 0; i < STRCOUNT; i++) {
bigStr += 't';
var nameLimit = '';
for (var i = 0; i < NAMELIMIT + 1; i++) {
nameLimit += 't';
}
var appAccountManager = account.createAppAccountManager();
appAccountManager.deleteAccount(bigStr, (err)=>{
appAccountManager.deleteAccount(nameLimit, (err)=>{
console.debug("====>delete Account ActsAccountDeleteAccount_0700 err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsAccountDeleteAccount_0700 end====");
......@@ -182,18 +182,18 @@ describe('ActsAccountDeleteAccount', function () {
/*
* @tc.number : ActsAccountDeleteAccount_0800
* @tc.name : Delete account promise form
* @tc.desc : Delete the account name exceeds the length limit of 1024
* @tc.desc : Delete the account name exceeds the length limit of 512 characters
*/
it('ActsAccountDeleteAccount_0800', 0, async function (done){
console.debug("====>ActsAccountDeleteAccount_0800 start====");
var bigStr = '';
for (var i = 0; i < STRCOUNT; i++) {
bigStr += 't';
var nameLimit = '';
for (var i = 0; i < NAMELIMIT + 1; i++) {
nameLimit += 'n';
}
var appAccountManager = account.createAppAccountManager();
console.debug("====>delete Account ActsAccountDeleteAccount_0800 start====");
try{
await appAccountManager.deleteAccount(bigStr);
await appAccountManager.deleteAccount(nameLimit);
}
catch(err){
console.debug("====>delete account ActsAccountDeleteAccount_0800 err:" + JSON.stringify(err));
......@@ -205,7 +205,7 @@ describe('ActsAccountDeleteAccount', function () {
/*
* @tc.number : ActsAccountDeleteAccount_0900
* @tc.name : Delete account calllback form
* @tc.name : Delete account callback form
* @tc.desc : Delete the account name is an empty string
*/
it('ActsAccountDeleteAccount_0900',0, async function (done){
......
......@@ -20,4 +20,5 @@ require('./AssociatedData.test.js')
require('./Credential.test.js')
require('./OAuthToken.test.js')
require('./CreatManager.test.js')
require('./NoPermission.test.js')
\ No newline at end of file
require('./NoPermission.test.js')
require('./OnOff.js')
\ No newline at end of file
......@@ -16,7 +16,7 @@ import account from '@ohos.account.appAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const TIMEOUT = 1000;
const ERR_APPACCOUNT_SERVICE_PERMISSION_DENIED = 4521990;
const ERR_APPACCOUNT_SERVICE_PERMISSION_DENIED = 4521992;
describe('ActsAccountNoPermission', function () {
function sleep(delay) {
var start = (new Date()).getTime();
......
......@@ -17,7 +17,7 @@ import featureAbility from '@ohos.ability.featureability'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const TIMEOUT = 2000;
const STRCOUNT = 1025;
const LENGTHLIMIT = 1024;
describe('ActsGetAllAccounts', function () {
/*
......@@ -179,11 +179,11 @@ describe('ActsGetAllAccounts', function () {
console.debug("====>ActsGetAllAccounts_0700 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
var bigBundleName = '';
for (var i = 0; i < STRCOUNT; i++) {
bigBundleName += 't';
var limitBundle = '';
for (var i = 0; i < LENGTHLIMIT + 1; i++) {
limitBundle += 't';
}
appAccountManager.getAllAccounts(bigBundleName, (err, data)=>{
appAccountManager.getAllAccounts(limitBundle, (err, data)=>{
console.debug("====>getAllAccounts 0700 err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsGetAllAccounts_0700 end====");
......@@ -200,12 +200,12 @@ describe('ActsGetAllAccounts', function () {
console.debug("====>ActsGetAllAccounts_0800 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
var bigBundleName = '';
for (var i = 0; i < STRCOUNT; i++) {
bigBundleName += 't';
var limitBundle = '';
for (var i = 0; i < LENGTHLIMIT + 1; i++) {
limitBundle += 'n';
}
try{
var data = await appAccountManager.getAllAccounts(bigBundleName);
var data = await appAccountManager.getAllAccounts(limitBundle);
}
catch(err){
console.debug("====>getAllAccounts 0800 err:" + JSON.stringify(err));
......@@ -217,7 +217,7 @@ describe('ActsGetAllAccounts', function () {
/*
* @tc.number : ActsGetAllAccounts_0900
* @tc.name : getAllAccounts
* @tc.name : getAllAccounts callback
* @tc.desc : This application adds an account, and after other applications authorize an account to this
* application, this application obtains the information of its own application
*/
......@@ -227,7 +227,7 @@ describe('ActsGetAllAccounts', function () {
console.debug("====>creat finish====");
var selfBundle = "com.example.actsgetallaaccounts";
console.debug("====>add account 0900 start====");
await appAccountManager.addAccount("Account_this_application");
await appAccountManager.addAccount("Account_application_callback");
console.debug("====>startAbility 0900 start====");
await featureAbility.startAbility(
{
......@@ -242,30 +242,350 @@ describe('ActsGetAllAccounts', function () {
},
},
);
function getAllCallback(err, data){
console.debug("====>getAllAccounts 0900 err:" + JSON.stringify(err));
console.debug("====>getAllAccounts 0900 data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
expect(data[0].name).assertEqual("Account_application_callback");
expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts");
appAccountManager.deleteAccount("Account_application_callback", (err)=>{
console.debug("====>delete account 0900 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsGetAllAccounts_0900 end====");
done();
});
}
setTimeout(async function(){
console.debug("====>getAllAccounts 0900 start====");
appAccountManager.getAllAccounts(selfBundle, getAllCallback);
}, TIMEOUT);
});
/*
* @tc.number : ActsGetAllAccounts_1000
* @tc.name : getAllAccounts promise
* @tc.desc : This application adds an account, and after other applications authorize an account to this
* application, this application obtains the information of its own application
*/
it('ActsGetAllAccounts_1000', 0, async function (done) {
console.debug("====>ActsGetAllAccounts_1000 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
var selfBundle = "com.example.actsgetallaaccounts";
console.debug("====>add account 1000 start====");
await appAccountManager.addAccount("Account_application_promise");
console.debug("====>startAbility 1000 start====");
await featureAbility.startAbility(
{
want:
{
deviceId: "",
bundleName: "com.example.actsscenegetallaccounts",
abilityName: "com.example.actsscenegetallaccounts.MainAbility",
action: "action1",
parameters:
{},
},
},
);
setTimeout(async function(){
console.debug("====>getAllAccounts 1000 start====");
try{
var data = await appAccountManager.getAllAccounts(selfBundle);
}
catch(err){
console.error("====>getAllAccounts 0900 fail err:" + JSON.stringify(err));
console.error("====>getAllAccounts 1000 fail err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>getAllAccounts 0900 data:" + JSON.stringify(data));
console.debug("====>getAllAccounts 1000 data:" + JSON.stringify(data));
try{
expect(data[0].name).assertEqual("Account_this_application");
expect(data[0].name).assertEqual("Account_application_promise");
expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts");
}
catch(err){
console.error("====>check data 0900 fail err:" + JSON.stringify(err));
console.error("====>check data 1000 fail err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>delete account 0900 start====");
await appAccountManager.deleteAccount("Account_this_application");
console.debug("====>ActsGetAllAccounts_0900 end====");
console.debug("====>delete account 1000 start====");
await appAccountManager.deleteAccount("Account_application_promise");
console.debug("====>ActsGetAllAccounts_1000 end====");
done();
}, TIMEOUT);
});
/*
* @tc.number : ActsGetAllAccounts_1100
* @tc.name : getAllAccounts callback
* @tc.desc : This application adds an account, and after other applications authorize an account to this
* application, this application obtains the information of its own application
*/
it('ActsGetAllAccounts_1100', 0, async function (done) {
console.debug("====>ActsGetAllAccounts_0900 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
var specifiedBundle = "com.example.actsscenegetallaccounts";
console.debug("====>startAbility 1100 start====");
await featureAbility.startAbility(
{
want:
{
deviceId: "",
bundleName: "com.example.actsscenegetallaccounts",
abilityName: "com.example.actsscenegetallaccounts.MainAbility",
action: "action1",
parameters:
{},
},
},
);
function getAllCallback(err, data){
console.debug("====>getAllAccounts 1100 err:" + JSON.stringify(err));
console.debug("====>getAllAccounts 1100 data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
expect(data[0].name).assertEqual("account_name_scene_single");
expect(data[0].owner).assertEqual("com.example.actsscenegetallaccounts");
console.debug("====>ActsGetAllAccounts_1100 end====");
done();
}
setTimeout(async function(){
console.debug("====>getAllAccounts 1100 start====");
appAccountManager.getAllAccounts(specifiedBundle, getAllCallback);
}, TIMEOUT);
});
/*
* @tc.number : ActsGetAllAccounts_1200
* @tc.name : getAllAccounts promise
* @tc.desc : This application adds an account, and after other applications authorize an account to this
* application, this application obtains the information of its own application
*/
it('ActsGetAllAccounts_1200', 0, async function (done) {
console.debug("====>ActsGetAllAccounts_1200 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
var specifiedBundle = "com.example.actsscenegetallaccounts";
console.debug("====>startAbility 1200 start====");
await featureAbility.startAbility(
{
want:
{
deviceId: "",
bundleName: "com.example.actsscenegetallaccounts",
abilityName: "com.example.actsscenegetallaccounts.MainAbility",
action: "action1",
parameters:
{},
},
},
);
setTimeout(async function(){
console.debug("====>getAllAccounts 1200 start====");
try{
var data = await appAccountManager.getAllAccounts(specifiedBundle);
}
catch(err){
console.error("====>getAllAccounts 1200 fail err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>getAllAccounts 1200 data:" + JSON.stringify(data));
expect(data[0].name).assertEqual("account_name_scene_single");
expect(data[0].owner).assertEqual("com.example.actsscenegetallaccounts");
console.debug("====>ActsGetAllAccounts_1200 end====");
done();
}, TIMEOUT);
});
/*
* @tc.number : ActsGetAllAccounts_1300
* @tc.name : getAllAccounts callback
* @tc.desc : The parameter owner is a bundlename that does not exist
*/
it('ActsGetAllAccounts_1300', 0, async function (done) {
console.debug("====>ActsGetAllAccounts_1300 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
var nonexistentBundle = "com.example.actsgetallaccountsnonexistent";
appAccountManager.getAllAccounts(nonexistentBundle, (err, data)=>{
console.debug("====>getAllAccounts 1300 err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsGetAllAccounts_1300 end====");
done();
})
});
/*
* @tc.number : ActsGetAllAccounts_1400
* @tc.name : getAllAccounts promise
* @tc.desc : The parameter owner is a bundlename that does not exist
*/
it('ActsGetAllAccounts_1400', 0, async function (done) {
console.debug("====>ActsGetAllAccounts_1400 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
var nonexistentBundle = "com.example.actsgetallaccountsnonexistent";
try{
var data = await appAccountManager.getAllAccounts(nonexistentBundle);
}
catch(err){
console.debug("====>getAllAccounts 1400 err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsGetAllAccounts_1400 end====");
done();
}
});
/*
* @tc.number : ActsGetAllAccounts_1500
* @tc.name : getAllAccounts callback
* @tc.desc : Get account information after adding and deleting account
*/
it('ActsGetAllAccounts_1500', 0, async function (done) {
console.debug("====>ActsGetAllAccounts_1500 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
var selfBundle = "com.example.actsgetallaaccounts";
appAccountManager.addAccount("account_callback_delete", (err)=>{
console.debug("====>add account 1500 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
appAccountManager.getAllAccounts(selfBundle, (err, data)=>{
console.debug("====>getAllAccounts 1500 err:" + JSON.stringify(err));
console.debug("====>getAllAccounts 1500 data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
expect(data[0].name).assertEqual("account_callback_delete");
expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts");
appAccountManager.deleteAccount("account_callback_delete", (err)=>{
console.debug("====>delete account 1500 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
appAccountManager.getAllAccounts(selfBundle, (err, data)=>{
console.debug("====>getAllAccounts 1500 err:" + JSON.stringify(err));
console.debug("====>getAllAccounts 1500 data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
expect(data.length).assertEqual(0);
console.debug("====>ActsGetAllAccounts_1500 end====");
done();
})
});
})
});
});
/*
* @tc.number : ActsGetAllAccounts_1600
* @tc.name : getAllAccounts promise
* @tc.desc : Get account information after adding and deleting account
*/
it('ActsGetAllAccounts_1600', 0, async function (done) {
console.debug("====>ActsGetAllAccounts_1600 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
var selfBundle = "com.example.actsgetallaaccounts";
console.debug("====>add account 1600 start====");
await appAccountManager.addAccount("account_promise_delete");
console.debug("====>first getAllAccounts 1600 start====");
try{
var data = await appAccountManager.getAllAccounts(selfBundle);
}
catch(err){
console.error("====>getAllAccounts 1600 fail err:" + JSON.stringify(err));
expect().assertFail();
done();
}
expect(data[0].name).assertEqual("account_promise_delete");
expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts");
console.debug("====>delete account 1600 start====");
await appAccountManager.deleteAccount("account_promise_delete");
console.debug("====>second getAllAccounts 1600 start====");
try{
var dataDelete = await appAccountManager.getAllAccounts(selfBundle);
}
catch(err){
console.error("====>second getAllAccounts 1600 fail err:" + JSON.stringify(err));
expect().assertFail();
done();
}
expect(dataDelete.length).assertEqual(0);
console.debug("====>ActsGetAllAccounts_1600 end====");
done();
});
/*
* @tc.number : ActsGetAllAccounts_1700
* @tc.name : getAllAccounts callback
* @tc.desc : Get account information after adding an account with additional information and deleting an
* account
*/
it('ActsGetAllAccounts_1700', 0, async function (done) {
console.debug("====>ActsGetAllAccounts_1700 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
var selfBundle = "com.example.actsgetallaaccounts";
appAccountManager.addAccount("account_callback_additional", "account_extrainfo", (err)=>{
console.debug("====>add account 1700 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
appAccountManager.getAllAccounts(selfBundle, (err, data)=>{
console.debug("====>getAllAccounts 1700 err:" + JSON.stringify(err));
console.debug("====>getAllAccounts 1700 data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
expect(data[0].name).assertEqual("account_callback_additional");
expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts");
appAccountManager.deleteAccount("account_callback_additional", (err)=>{
console.debug("====>delete account 1700 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
appAccountManager.getAllAccounts(selfBundle, (err, data)=>{
console.debug("====>getAllAccounts 1700 err:" + JSON.stringify(err));
console.debug("====>getAllAccounts 1700 data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
expect(data.length).assertEqual(0);
console.debug("====>ActsGetAllAccounts_1700 end====");
done();
})
});
})
});
});
/*
* @tc.number : ActsGetAllAccounts_1800
* @tc.name : getAllAccounts promise
* @tc.desc : Get account information after adding an account with additional information and deleting an
* account
*/
it('ActsGetAllAccounts_1800', 0, async function (done) {
console.debug("====>ActsGetAllAccounts_1800 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
var selfBundle = "com.example.actsgetallaaccounts";
console.debug("====>add account 1800 start====");
await appAccountManager.addAccount("account_promise_additional", "account_extrainfo");
console.debug("====>first getAllAccounts 1800 start====");
try{
var data = await appAccountManager.getAllAccounts(selfBundle);
}
catch(err){
console.error("====>getAllAccounts 1800 fail err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>first getAllAccounts 1800 data:" + JSON.stringify(data));
expect(data[0].name).assertEqual("account_promise_additional");
expect(data[0].owner).assertEqual("com.example.actsgetallaaccounts");
console.debug("====>delete account 1800 start====");
await appAccountManager.deleteAccount("account_promise_additional");
console.debug("====>second getAllAccounts 1800 start====");
try{
var dataDelete = await appAccountManager.getAllAccounts(selfBundle);
}
catch(err){
console.error("====>second getAllAccounts 1800 fail err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>second getAllAccounts 1800 data:" + JSON.stringify(data));
expect(dataDelete.length).assertEqual(0);
console.debug("====>ActsGetAllAccounts_1800 end====");
done();
});
})
\ No newline at end of file
......@@ -12,4 +12,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('./ExampleJsunit.test.js')
\ No newline at end of file
require('./Getallaccounts.test.js')
\ No newline at end of file
......@@ -12,4 +12,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('./ExampleJsunit.test.js')
\ No newline at end of file
require('./Syncenable.test.js')
\ No newline at end of file
......@@ -17,7 +17,6 @@ import featureAbility from '@ohos.ability.featureability'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const TIMEOUT = 2000;
const TIMEOUTEND = 4000;
describe('ActsGetAllAccessibleAccounts', function () {
/*
......@@ -534,8 +533,5 @@ describe('ActsGetAllAccessibleAccounts', function () {
console.debug("====>ActsGetAllAccessibleAccounts_1100 end====");
done();
}, TIMEOUT);
setTimeout(function(){
console.debug("====>time out ActsGetAllAccessibleAccounts_1100====");
}, TIMEOUTEND);
});
})
\ No newline at end of file
......@@ -12,4 +12,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('./ExampleJsunit.test.js')
\ No newline at end of file
require('./Getallaccessible.test.js')
\ No newline at end of file
......@@ -17,8 +17,6 @@ import featureAbility from '@ohos.ability.featureability'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const TIMEOUT = 3000;
const TIMEOUTEND = 5000;
describe('ActsGetAllAccessibleMultiple', function () {
beforeAll(async function (done) {
console.debug("====>startAbility first 0100 start====");
......@@ -108,8 +106,5 @@ describe('ActsGetAllAccessibleMultiple', function () {
console.debug("====>ActsGetAllAccessibleAccounts_0100 end====");
done();
}, TIMEOUT);
setTimeout(function(){
console.debug("====>time out ActsGetAllAccessibleMultiple_0100====>");
}, TIMEOUTEND);
});
})
\ No newline at end of file
......@@ -12,4 +12,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('./ExampleJsunit.test.js')
\ No newline at end of file
require('./Getmultiple.test.js')
\ No newline at end of file
......@@ -10,17 +10,20 @@
# 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAccountAccessibleFirst") {
ohos_hap("ActsAccountAccessibleFirst") {
hap_profile = "./entry/src/main/config.json"
hap_name = "ActsAccountAccessibleFirst"
subsystem_name = XTS_SUITENAME
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAccountAccessibleFirst"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
......
......@@ -10,17 +10,20 @@
# 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAccountAccessibleSecond") {
ohos_hap("ActsAccountAccessibleSecond") {
hap_profile = "./entry/src/main/config.json"
hap_name = "ActsAccountAccessibleSecond"
subsystem_name = XTS_SUITENAME
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAccountAccessibleSecond"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
......
......@@ -10,17 +10,20 @@
# 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAccountSceneAccessible") {
ohos_hap("ActsAccountSceneAccessible") {
hap_profile = "./entry/src/main/config.json"
hap_name = "ActsAccountSceneAccessible"
subsystem_name = XTS_SUITENAME
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAccountSceneAccessible"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
......
......@@ -10,17 +10,20 @@
# 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAccountSceneAppAccess") {
ohos_hap("ActsAccountSceneAppAccess") {
hap_profile = "./entry/src/main/config.json"
hap_name = "ActsAccountSceneAppAccess"
subsystem_name = XTS_SUITENAME
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAccountSceneAppAccess"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
......
......@@ -10,17 +10,20 @@
# 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAccountSceneOnOff") {
ohos_hap("ActsAccountSceneOnOff") {
hap_profile = "./entry/src/main/config.json"
hap_name = "ActsAccountSceneOnOff"
subsystem_name = XTS_SUITENAME
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAccountSceneOnOff"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
......
......@@ -14,6 +14,14 @@
*/
import account from '@ohos.account.appAccount'
import commonevent from '@ohos.commonevent'
const ACCOUNT_TEST_ONOFF_EXTRA = 1
const ACCOUNT_TEST_ONOFF_ASSOCIATEDDATA = 2
const ACCOUNT_TEST_ONOFF_CREDENTIAL = 3
const ACCOUNT_TEST_ONOFF_DELETE = 4
const ACCOUNT_TEST_ONOFF_DELETEONLY = 5
const ACCOUNT_TEST_ONOFF_DISABLE = 6
const ACCOUNT_TEST_ONOFF_DISABLEONLY = 7
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
......@@ -29,6 +37,9 @@ export default {
var commonEventSubscribeInfo = {
events: ["account_on_change"]
}
// The callback of the event that publishes the verification result to the test application, and unsubscribe
// the change of account information
function publishCallback(err){
console.debug("====>publish call back scene err:" + JSON.stringify(err));
console.debug("====>scene off start====");
......@@ -36,10 +47,13 @@ export default {
console.debug("====>scene off finish====");
});
}
// Subscribe to the callback of account information changes, verify the received account information, and send
// an event with the verification result to the test application
function changeOnExtra(data){
console.debug("====>receive change 0100 data:" + JSON.stringify(data));
try{
if(data[0].owner == "com.example.actsaccountchangeonoff" && data[0].name == "changeonoff_extra"){
if(data[0].owner == "com.example.actsaccounttest" && data[0].name == "changeonoff_extra"){
var commonEventPublishData = {
data: "SUCCESS"
}
......@@ -58,10 +72,11 @@ export default {
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"){
if(data[0].owner == "com.example.actsaccounttest" && data[0].name == "onoff_associatedata"){
var commonEventPublishData = {
data: "SUCCESS"
}
......@@ -80,10 +95,11 @@ export default {
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"){
if(data[0].owner == "com.example.actsaccounttest" && data[0].name == "onoff_credential"){
var commonEventPublishData = {
data: "SUCCESS"
}
......@@ -102,10 +118,11 @@ export default {
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"){
if(data[0].owner == "com.example.actsaccounttest" && data[0].name == "onoff_deleteFir"){
var commonEventPublishData = {
data: "SUCCESS"
}
......@@ -124,6 +141,7 @@ export default {
commonevent.publish("account_on_delete_another", commonEventPublishData, publishCallback);
}
}
function changeOnDelete(data){
console.debug("====>receive change 0500 data:" + JSON.stringify(data));
try{
......@@ -146,10 +164,11 @@ export default {
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"){
if(data[0].owner == "com.example.actsaccounttest" && data[0].name == "onoff_enableFir"){
var commonEventPublishData = {
data: "SUCCESS"
}
......@@ -168,6 +187,7 @@ export default {
commonevent.publish("account_on_disable_another", commonEventPublishData, publishCallback);
}
}
function changeOnDisable(data){
console.debug("====>receive change 0700 data:" + JSON.stringify(data));
try{
......@@ -190,37 +210,39 @@ export default {
commonevent.publish("account_on_change_disable", commonEventPublishData, publishCallback);
}
}
// Receive events sent by the test application to correspond to different test cases
function subscriberCallback(err, data){
console.debug("====>receive event err:" + JSON.stringify(err));
console.debug("====>receive event data:" + JSON.stringify(data));
switch(data.code){
case 1:
case ACCOUNT_TEST_ONOFF_EXTRA:
console.debug("====>receive event 0100 event:" + data.event);
appAccountManager.on('change', ["com.example.actsaccountchangeonoff"], changeOnExtra);
appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnExtra);
break;
case 2:
case ACCOUNT_TEST_ONOFF_ASSOCIATEDDATA:
console.debug("====>receive event 0200 event:" + data.event);
appAccountManager.on('change', ["com.example.actsaccountchangeonoff"], changeOnAssociateData);
appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnAssociateData);
break;
case 3:
case ACCOUNT_TEST_ONOFF_CREDENTIAL:
console.debug("====>receive event 0300 event:" + data.event);
appAccountManager.on('change', ["com.example.actsaccountchangeonoff"], changeOnCredential);
appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnCredential);
break;
case 4:
case ACCOUNT_TEST_ONOFF_DELETE:
console.debug("====>receive event 0400 event:" + data.event);
appAccountManager.on('change', ["com.example.actsaccountchangeonoff"], changeOnDeleteAnother);
appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnDeleteAnother);
break;
case 5:
case ACCOUNT_TEST_ONOFF_DELETEONLY:
console.debug("====>receive event 0500 event:" + data.event);
appAccountManager.on('change', ["com.example.actsaccountchangeonoff"], changeOnDelete);
appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnDelete);
break;
case 6:
case ACCOUNT_TEST_ONOFF_DISABLE:
console.debug("====>receive event 0600 event:" + data.event);
appAccountManager.on('change', ["com.example.actsaccountchangeonoff"], changeOnDisableAnother);
appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnDisableAnother);
break;
case 7:
case ACCOUNT_TEST_ONOFF_DISABLEONLY:
console.debug("====>receive event 0700 event:" + data.event);
appAccountManager.on('change', ["com.example.actsaccountchangeonoff"], changeOnDisable);
appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnDisable);
break;
default:
console.debug("====>receive event enter default====");
......
......@@ -10,17 +10,20 @@
# 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsSceneGetAllAccounts") {
ohos_hap("ActsSceneGetAllAccounts") {
hap_profile = "./entry/src/main/config.json"
hap_name = "ActsSceneGetAllAccounts"
subsystem_name = XTS_SUITENAME
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsSceneGetAllAccounts"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册