提交 a2b833ba 编写于 作者: 1 15829070344

【monthly_20221018】【账号】bundlename修改和normal权限修改,适配get_all_app_accounts

Signed-off-by: N15829070344 <hehaitao5@huawei.com>
上级 2474ba8a
...@@ -24,7 +24,6 @@ group("appaccount_hap") { ...@@ -24,7 +24,6 @@ group("appaccount_hap") {
"actsgetallaccounts:ActsGetAllAccountsTest", "actsgetallaccounts:ActsGetAllAccountsTest",
"actssetcheckdatasyncenable:ActsSetCheckDataSyncEnableTest", "actssetcheckdatasyncenable:ActsSetCheckDataSyncEnableTest",
"actssetchecksyncenable:ActsSetCheckSyncEnableTest", "actssetchecksyncenable:ActsSetCheckSyncEnableTest",
"getallaccessibleaccounts:accessibleaccounts",
"getallaccounts:getallaccounts", "getallaccounts:getallaccounts",
"sceneProject:appaccount_scene", "sceneProject:appaccount_scene",
] ]
......
...@@ -144,11 +144,13 @@ export default function ActsAccountErrPermission() { ...@@ -144,11 +144,13 @@ export default function ActsAccountErrPermission() {
var appAccountManager = account.createAppAccountManager(); var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish===="); console.debug("====>creat finish====");
appAccountManager.createAccount("accessibleAccount_callback_nopermission", (err)=>{ appAccountManager.createAccount("accessibleAccount_callback_nopermission", (err)=>{
console.debug("====> add account ActsAccountErrPermission_0500 err:" + JSON.stringify(err)); console.debug("====>add account ActsAccountErrPermission_0500 err:" + JSON.stringify(err));
expect(err).assertEqual(null); expect(err).assertEqual(null);
appAccountManager.getAllAccounts((err, data)=>{ appAccountManager.getAllAccounts((err, data)=>{
console.debug("====>getAllAccounts 0500 err:" + JSON.stringify(err)); console.debug("====>getAllAccounts 0500 err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_PERMISSION_DENIED); expect(data.length).assertEqual(1);
expect(data[0].name).assertEqual("accessibleAccount_callback_nopermission");
expect(data[0].owner).assertEqual("com.example.actsaccountoperatetest");
appAccountManager.removeAccount("accessibleAccount_callback_nopermission", (err)=>{ appAccountManager.removeAccount("accessibleAccount_callback_nopermission", (err)=>{
console.debug("====>delete Account ActsAccountErrPermission_0500 err:" + JSON.stringify(err)); console.debug("====>delete Account ActsAccountErrPermission_0500 err:" + JSON.stringify(err));
expect(err).assertEqual(null); expect(err).assertEqual(null);
...@@ -173,12 +175,17 @@ export default function ActsAccountErrPermission() { ...@@ -173,12 +175,17 @@ export default function ActsAccountErrPermission() {
console.debug("====>getAllAccounts 0600 start===="); console.debug("====>getAllAccounts 0600 start====");
try{ try{
var data = await appAccountManager.getAllAccounts(); var data = await appAccountManager.getAllAccounts();
expect(data.length).assertEqual(1);
expect(data[0].name).assertEqual("accessibleAccount_promise_nopermission");
expect(data[0].owner).assertEqual("com.example.actsaccountoperatetest");
console.debug("====>getAllAccounts 0600 err:" + JSON.stringify(data));
await appAccountManager.removeAccount("accessibleAccount_promise_nopermission");
console.debug("====>ActsAccountErrPermission_0600 end====");
done();
} }
catch(err){ catch(err){
console.debug("====>getAllAccounts 0600 err:" + JSON.stringify(err)); console.debug("====>getAllAccounts 0600 err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_PERMISSION_DENIED); expect().assertFail();
await appAccountManager.removeAccount("accessibleAccount_promise_nopermission");
console.debug("====>ActsAccountErrPermission_0600 end====");
done(); done();
} }
}); });
......
...@@ -28,17 +28,8 @@ ...@@ -28,17 +28,8 @@
"moduleType": "entry" "moduleType": "entry"
}, },
"defPermissions": [ "defPermissions": [
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.GET_ALL_APP_ACCOUNTS"
}
], ],
"reqPermissions": [ "reqPermissions": [
{
"name": "ohos.permission.GET_ALL_APP_ACCOUNTS",
"reason": "ceshi"
},
{ {
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
......
...@@ -29,17 +29,8 @@ ...@@ -29,17 +29,8 @@
"moduleType": "entry" "moduleType": "entry"
}, },
"defPermissions": [ "defPermissions": [
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.GET_ALL_APP_ACCOUNTS"
}
], ],
"reqPermissions": [ "reqPermissions": [
{
"name": "ohos.permission.GET_ALL_APP_ACCOUNTS",
"reason": "ceshi"
},
{ {
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
......
...@@ -346,89 +346,6 @@ export default function ActsGetAllAccounts() { ...@@ -346,89 +346,6 @@ export default function ActsGetAllAccounts() {
}, TIMEOUT); }, 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).assertEqual(null);
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.number : ActsGetAllAccounts_1300
* @tc.name : getAllAccounts callback * @tc.name : getAllAccounts callback
......
# 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")
group("accessibleaccounts") {
testonly = true
if (is_standard_system) {
deps = [
"actsgetallaccessibleaccounts:ActsGetAllAccessibleAccountsTest",
"actsgetallaccessiblemultiple:ActsGetAllAccessibleMultipleTest",
]
}
}
# 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("ActsGetAllAccessibleAccountsTest") {
hap_profile = "./src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsGetAllAccessibleAccountsTest"
subsystem_name = "account"
part_name = "os_account"
}
ohos_js_assets("hjs_demo_js_assets") {
js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "60000",
"bundle-name": "com.example.actsgetallaccessibleaccounts",
"package-name": "com.example.actsgetallaccessibleaccounts",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsGetAllAccessibleAccountsTest.hap",
"ActsAccountSceneAccessible.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.actsgetallaccessibleaccounts",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsgetallaccessibleaccounts",
"name": ".entry",
"mainAbility": ".MainAbility",
"srcPath":"",
"deviceType": [
"tablet",
"default",
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"defPermissions": [
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.GET_ALL_APP_ACCOUNTS"
}
],
"reqPermissions": [
{
"name": "ohos.permission.GET_ALL_APP_ACCOUNTS",
"reason": "ceshi"
},
{
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name":"ohos.permission.GET_BUNDLE_INFO",
"reason":"need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE",
"reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name":"ohos.permission.REMOVE_CACHE_FILES",
"reason":"need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE"
}
],
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "js",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
},
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".TestAbility",
"srcLanguage": "js",
"srcPath": "TestAbility",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"label": "$string:TestAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
}
}
}
\ 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');
}
};
/*
* 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.
*/
.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.
-->
<div class="container">
<text class="title">
{{title}}
</text>
</div>
/*
* 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.
*/
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: "getAllAccessibleAccounts"
},
onInit() {
this.title = "getAllAccessibleAccounts";
},
onShow() {
console.info('onShow finish')
},
onReady() {
},
}
\ No newline at end of file
/*
* Copyright (c) 2022 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('TestApplication onCreate')
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
onDestroy() {
console.info("TestApplication onDestroy");
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ 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.
*/
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
\ 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.
-->
<div class="container" onswipe="touchMove">
<text class="title">
{{ $t('strings.hello') }} {{title}}
</text>
<input class="btn" type="button" value="{{ $t('strings.next') }}" onclick="onclick"></input>
</div>
/*
* Copyright (c) 2022 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 {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
/*
* Copyright (c) 2022 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package', '-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
export default {
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
},
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility'
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
console.info('debug value : '+debug)
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + data.stdResult);
console.info('executeShellCommand : data : ' + data.exitCode);
})
}
};
/*
* 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 account from '@ohos.account.appAccount'
import featureAbility from '@ohos.ability.featureAbility'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
const TIMEOUT = 2000;
export default function ActsGetAllAccessibleAccounts() {
describe('ActsGetAllAccessibleAccounts', function () {
/*
* @tc.number : ActsGetAllAccessibleAccounts_0100
* @tc.name : getAllAccessibleAccounts callback
* @tc.desc : This application has not added an account and has not been authorized by other applications to
* obtain authorization
*/
it('ActsGetAllAccessibleAccounts_0100', 0, async function (done) {
console.debug("====>ActsGetAllAccessibleAccounts_0100 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
appAccountManager.getAllAccessibleAccounts((err, data)=>{
console.debug("====>getAllAccessibleAccounts 0100 err:" + JSON.stringify(err));
console.debug("====>getAllAccessibleAccounts 0100 data:" + JSON.stringify(data));
console.debug("====>getAllAccessibleAccounts 0100 data.length:" + data.length);
expect(err).assertEqual(null);
expect(data.length).assertEqual(0);
console.debug("====>ActsGetAllAccessibleAccounts_0100 end====");
done();
});
});
/*
* @tc.number : ActsGetAllAccessibleAccounts_0200
* @tc.name : getAllAccessibleAccounts promise
* @tc.desc : This application has not added an account and has not been authorized by other applications to
* obtain authorization
*/
it('ActsGetAllAccessibleAccounts_0200', 0, async function (done) {
console.debug("====>ActsGetAllAccessibleAccounts_0200 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
console.debug("====>getAllAccessibleAccounts 0300 start====");
try{
var data = await appAccountManager.getAllAccessibleAccounts();
}
catch(err){
console.error("====>getAllAccessibleAccounts 0200 err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>getAllAccessibleAccounts 0200 data:" + JSON.stringify(data));
console.debug("====>getAllAccessibleAccounts 0200 data.length:" + data.length);
expect(data.length).assertEqual(0);
console.debug("====>ActsGetAllAccessibleAccounts_0200 end====");
done();
});
/*
* @tc.number : ActsGetAllAccessibleAccounts_0300
* @tc.name : getAllAccessibleAccounts callback
* @tc.desc : This application gets authorization after adding a single account
*/
it('ActsGetAllAccessibleAccounts_0300', 0, async function (done) {
console.debug("====>ActsGetAllAccessibleAccounts_0300 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
appAccountManager.addAccount("accessibleAccount_callback_single", (err)=>{
console.debug("====> add account ActsGetAllAccessibleAccounts_0300 err:" + JSON.stringify(err));
expect(err).assertEqual(null);
appAccountManager.getAllAccessibleAccounts((err, data)=>{
console.debug("====>getAllAccessibleAccounts 0300 err:" + JSON.stringify(err));
console.debug("====>getAllAccessibleAccounts 0300 data:" + JSON.stringify(data));
console.debug("====>getAllAccessibleAccounts 0300 data.length:" + data.length);
expect(err).assertEqual(null);
expect(data.length).assertEqual(1);
try{
expect(data[0].name).assertEqual("accessibleAccount_callback_single");
expect(data[0].owner).assertEqual("com.example.actsgetallaccessibleaccounts");
}
catch(err){
console.error("====>getAllAccessibleAccounts check data 0300 fail err:" + JSON.stringify(err));
expect().assertFail();
done();
}
appAccountManager.deleteAccount("accessibleAccount_callback_single", (err)=>{
console.debug("====>delete Account ActsGetAllAccessibleAccounts_0300 err:" + JSON.stringify(err));
expect(err).assertEqual(null);
console.debug("====>ActsGetAllAccessibleAccounts_0300 end====");
done();
})
});
});
});
/*
* @tc.number : ActsGetAllAccessibleAccounts_0400
* @tc.name : getAllAccessibleAccounts promise
* @tc.desc : This application gets authorization after adding a single account
*/
it('ActsGetAllAccessibleAccounts_0400', 0, async function (done) {
console.debug("====>ActsGetAllAccessibleAccounts_0400 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
var selfBundle = "com.example.actsgetallaccessibleaccounts";
console.debug("====>getAllAccounts for clean====");
try{
var acclist = await appAccountManager.getAllAccounts(selfBundle);
}
catch(err){
console.error("====>getAllAccounts err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>account list length: " + acclist.length);
if(acclist.length > 0){
for(var i = 0;i < acclist.length; i++){
await appAccountManager.deleteAccount(acclist[i].name);
}
}
console.debug("====>add account ActsGetAllAccessibleAccounts_0400 start====");
await appAccountManager.addAccount("accessibleAccount_promise_single");
console.debug("====>getAllAccessibleAccounts 0400 start====");
try{
var data = await appAccountManager.getAllAccessibleAccounts();
}
catch(err){
console.error("====>getAllAccessibleAccounts 0400 err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>getAllAccessibleAccounts 0400 data:" + JSON.stringify(data));
console.debug("====>getAllAccessibleAccounts 0400 data.length:" + data.length);
try{
expect(data[0].name).assertEqual("accessibleAccount_promise_single");
expect(data[0].owner).assertEqual("com.example.actsgetallaccessibleaccounts");
}
catch(err){
console.error("====>getAllAccessibleAccounts check data 0400 fail err:" + JSON.stringify(err));
expect().assertFail();
done();
}
await appAccountManager.deleteAccount("accessibleAccount_promise_single");
console.debug("====>ActsGetAllAccessibleAccounts_0400 end====");
done();
});
/*
* @tc.number : ActsGetAllAccessibleAccounts_0500
* @tc.name : getAllAccessibleAccounts callback
* @tc.desc : This application is added to obtain authorization after adding multiple application accounts
*/
it('ActsGetAllAccessibleAccounts_0500', 0, async function (done) {
console.debug("====>ActsGetAllAccessibleAccounts_0500 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
appAccountManager.addAccount("accessibleAccount_callback_first", (err)=>{
console.debug("====>add account first time 0500 err:" + JSON.stringify(err));
expect(err).assertEqual(null);
appAccountManager.addAccount("accessibleAccount_callback_second", (err)=>{
console.debug("====>add account second time 0500 err:" + JSON.stringify(err));
expect(err).assertEqual(null);
appAccountManager.addAccount("accessibleAccount_callback_third", (err)=>{
console.debug("====>add account third time 0500 err:" + JSON.stringify(err));
expect(err).assertEqual(null);
appAccountManager.getAllAccessibleAccounts((err, data)=>{
console.debug("====>getAllAccessibleAccounts 0500 err:" + JSON.stringify(err));
console.debug("====>getAllAccessibleAccounts 0500 data:" + JSON.stringify(data));
console.debug("====>getAllAccessibleAccounts 0500 data.length:" + data.length);
expect(err).assertEqual(null);
expect(data.length).assertEqual(3);
try{
expect(data[0].name).assertEqual("accessibleAccount_callback_first");
expect(data[0].owner).assertEqual("com.example.actsgetallaccessibleaccounts");
expect(data[1].name).assertEqual("accessibleAccount_callback_second");
expect(data[1].owner).assertEqual("com.example.actsgetallaccessibleaccounts");
expect(data[2].name).assertEqual("accessibleAccount_callback_third");
expect(data[2].owner).assertEqual("com.example.actsgetallaccessibleaccounts");
}
catch(err){
console.error("====>check data 0500 fail err:" + JSON.stringify(err));
expect().assertFail();
done();
}
appAccountManager.deleteAccount("accessibleAccount_callback_first", (err)=>{
console.debug("====>delete Account first 0500 err:" + JSON.stringify(err));
expect(err).assertEqual(null);
appAccountManager.deleteAccount("accessibleAccount_callback_second", (err)=>{
console.debug("====>delete Account second 0500 err:" + JSON.stringify(err));
expect(err).assertEqual(null);
appAccountManager.deleteAccount("accessibleAccount_callback_third", (err)=>{
console.debug("====>delete Account third 0500 err:" + JSON.stringify(err));
expect(err).assertEqual(null);
console.debug("====>ActsGetAllAccessibleAccounts_0500 end====");
done();
})
})
})
});
})
})
});
});
/*
* @tc.number : ActsGetAllAccessibleAccounts_0600
* @tc.name : getAllAccessibleAccounts promise
* @tc.desc : This application is added to obtain authorization after adding multiple application accounts
*/
it('ActsGetAllAccessibleAccounts_0600', 0, async function (done) {
console.debug("====>ActsGetAllAccessibleAccounts_0600 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
console.debug("====>getAllAccounts for clean====");
var selfBundle = "com.example.actsgetallaccessibleaccounts";
try{
var acclist = await appAccountManager.getAllAccounts(selfBundle);
}
catch(err){
console.error("====>getAllAccounts err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>account list length: " + acclist.length);
if(acclist.length > 0){
for(var i = 0;i < acclist.length; i++){
await appAccountManager.deleteAccount(acclist[i].name);
}
}
console.debug("====>add first account 0600 start====");
await appAccountManager.addAccount("accessibleAccount_promise_first");
console.debug("====>add second account 0600 start====");
await appAccountManager.addAccount("accessibleAccount_promise_second");
console.debug("====>add third account 0600 start====");
await appAccountManager.addAccount("accessibleAccount_promise_third");
try{
var data = await appAccountManager.getAllAccessibleAccounts();
}
catch(err){
console.error("====>getAllAccessibleAccounts 0600 fail err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>getAllAccessibleAccounts 0600 data:" + JSON.stringify(data));
expect(data.length).assertEqual(3);
try{
expect(data[0].name).assertEqual("accessibleAccount_promise_first");
expect(data[0].owner).assertEqual("com.example.actsgetallaccessibleaccounts");
expect(data[1].name).assertEqual("accessibleAccount_promise_second");
expect(data[1].owner).assertEqual("com.example.actsgetallaccessibleaccounts");
expect(data[2].name).assertEqual("accessibleAccount_promise_third");
expect(data[2].owner).assertEqual("com.example.actsgetallaccessibleaccounts");
}
catch(err){
console.error("====>check data 0600 fail err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>delete first account 0600 start====");
await appAccountManager.deleteAccount("accessibleAccount_promise_first");
console.debug("====>delete second account 0600 start====");
await appAccountManager.deleteAccount("accessibleAccount_promise_second");
console.debug("====>delete third account 0600 start====");
await appAccountManager.deleteAccount("accessibleAccount_promise_third");
console.debug("====>ActsGetAllAccessibleAccounts_0600 end====");
done();
});
/*
* @tc.number : ActsGetAllAccessibleAccounts_0700
* @tc.name : getAllAccessibleAccounts callback
* @tc.desc : This application adds different application accounts three times in a row, and obtains
* authorization after deleting the account added for the second time
*/
it('ActsGetAllAccessibleAccounts_0700', 0, async function (done) {
console.debug("====>ActsGetAllAccessibleAccounts_0700 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
appAccountManager.addAccount("accessibleAccount_callback_delete_first", (err)=>{
console.debug("====>add first account 0700 err:" + JSON.stringify(err));
expect(err).assertEqual(null);
appAccountManager.addAccount("accessibleAccount_callback_delete_second", (err)=>{
console.debug("====>add second account 0700 err:" + JSON.stringify(err));
expect(err).assertEqual(null);
appAccountManager.addAccount("accessibleAccount_callback_delete_third", (err)=>{
console.debug("====>add third account 0700 err:" + JSON.stringify(err));
expect(err).assertEqual(null);
appAccountManager.deleteAccount("accessibleAccount_callback_delete_second", (err)=>{
console.debug("====>delete second account 0700 err:" + JSON.stringify(err));
expect(err).assertEqual(null);
appAccountManager.getAllAccessibleAccounts((err, data)=>{
console.debug("====>getAllAccessibleAccounts 0700 err:" + JSON.stringify(err));
console.debug("====>getAllAccessibleAccounts 0700 data:" + JSON.stringify(data));
console.debug("====>getAllAccessibleAccounts 0700 data.length:" + data.length);
expect(err).assertEqual(null);
expect(data.length).assertEqual(2);
try{
expect(data[0].name).assertEqual("accessibleAccount_callback_delete_first");
expect(data[0].owner).assertEqual("com.example.actsgetallaccessibleaccounts");
expect(data[1].name).assertEqual("accessibleAccount_callback_delete_third");
expect(data[1].owner).assertEqual("com.example.actsgetallaccessibleaccounts");
}
catch(err){
console.error("====>check data 0700 fail err:" + JSON.stringify(err));
expect().assertFail();
done();
}
appAccountManager.deleteAccount("accessibleAccount_callback_delete_first", (err)=>{
console.debug("====>delete first account 0700 err:" + JSON.stringify(err));
expect(err).assertEqual(null);
appAccountManager.deleteAccount("accessibleAccount_callback_delete_third", (err)=>{
console.debug("====>delete third account 0700 err:" + JSON.stringify(err));
expect(err).assertEqual(null);
console.debug("====>ActsGetAllAccessibleAccounts_0700 end====");
done();
})
})
});
})
})
})
});
});
/*
* @tc.number : ActsGetAllAccessibleAccounts_0800
* @tc.name : getAllAccessibleAccounts promise
* @tc.desc : This application adds different application accounts three times in a row, and obtains
* authorization after deleting the account added for the second time
*/
it('ActsGetAllAccessibleAccounts_0800', 0, async function (done) {
console.debug("====>ActsGetAllAccessibleAccounts_0800 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
console.debug("====>getAllAccounts for clean====");
var selfBundle = "com.example.actsgetallaccessibleaccounts";
try{
var acclist = await appAccountManager.getAllAccounts(selfBundle);
}
catch(err){
console.error("====>getAllAccounts err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>account list length: " + acclist.length);
if(acclist.length > 0){
for(var i = 0;i < acclist.length; i++){
await appAccountManager.deleteAccount(acclist[i].name);
}
}
console.debug("====>add first account 0800 start====");
await appAccountManager.addAccount("accessibleAccount_promise_first");
console.debug("====>add second account 0800 start====");
await appAccountManager.addAccount("accessibleAccount_promise_second");
console.debug("====>add third account 0800 start====");
await appAccountManager.addAccount("accessibleAccount_promise_third");
console.debug("====>delete second account 0800 start====");
await appAccountManager.deleteAccount("accessibleAccount_promise_second");
try{
var data = await appAccountManager.getAllAccessibleAccounts();
}
catch(err){
console.error("====>getAllAccessibleAccounts 0800 fail err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>getAllAccessibleAccounts 0800 data:" + JSON.stringify(data));
expect(data.length).assertEqual(2);
try{
expect(data[0].name).assertEqual("accessibleAccount_promise_first");
expect(data[0].owner).assertEqual("com.example.actsgetallaccessibleaccounts");
expect(data[1].name).assertEqual("accessibleAccount_promise_third");
expect(data[1].owner).assertEqual("com.example.actsgetallaccessibleaccounts");
}
catch(err){
console.error("====>check data 0800 fail err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>delete first account 0800 start====");
await appAccountManager.deleteAccount("accessibleAccount_promise_first");
console.debug("====>delete third account 0800 start====");
await appAccountManager.deleteAccount("accessibleAccount_promise_third");
console.debug("====>ActsGetAllAccessibleAccounts_0800 end====");
done();
});
/*
* @tc.number : ActsGetAllAccessibleAccounts_0900
* @tc.name : getAllAccessibleAccounts callback
* @tc.desc : This application adds different application accounts three times in a row, and then obtains
* authorization multiple times
*/
it('ActsGetAllAccessibleAccounts_0900', 0, async function (done) {
console.debug("====>ActsGetAllAccessibleAccounts_0900 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
appAccountManager.addAccount("accessibleAccount_callback_multiple_first", (err)=>{
console.debug("====>add first account 0900 err:" + JSON.stringify(err));
expect(err).assertEqual(null);
appAccountManager.addAccount("accessibleAccount_callback_multiple_second", (err)=>{
console.debug("====>add third account 0900 err:" + JSON.stringify(err));
expect(err).assertEqual(null);
appAccountManager.getAllAccessibleAccounts((err, data)=>{
console.debug("====>getAllAccessibleAccounts first 0900 err:" + JSON.stringify(err));
console.debug("====>getAllAccessibleAccounts first 0900 data:" + JSON.stringify(data));
console.debug("====>getAllAccessibleAccounts first 0900 data.length:" + data.length);
expect(err).assertEqual(null);
expect(data.length).assertEqual(2);
try{
expect(data[0].name).assertEqual("accessibleAccount_callback_multiple_first");
expect(data[0].owner).assertEqual("com.example.actsgetallaccessibleaccounts");
expect(data[1].name).assertEqual("accessibleAccount_callback_multiple_second");
expect(data[1].owner).assertEqual("com.example.actsgetallaccessibleaccounts");
}
catch(err){
console.error("====>check data first 0900 fail err:" + JSON.stringify(err));
expect().assertFail();
done();
}
appAccountManager.getAllAccessibleAccounts((err, data)=>{
console.debug("====>getAllAccessibleAccounts second 0900 err:" + JSON.stringify(err));
console.debug("====>getAllAccessibleAccounts second 0900 data:" + JSON.stringify(data));
console.debug("====>getAllAccessibleAccounts second 0900 data.length:" + data.length);
expect(err).assertEqual(null);
expect(data.length).assertEqual(2);
try{
expect(data[0].name).assertEqual("accessibleAccount_callback_multiple_first");
expect(data[0].owner).assertEqual("com.example.actsgetallaccessibleaccounts");
expect(data[1].name).assertEqual("accessibleAccount_callback_multiple_second");
expect(data[1].owner).assertEqual("com.example.actsgetallaccessibleaccounts");
}
catch(err){
console.error("====>check data second 0900 fail err:" + JSON.stringify(err));
expect().assertFail();
done();
}
appAccountManager.deleteAccount("accessibleAccount_callback_multiple_first", (err)=>{
console.debug("====>delete first account 0900 err:" + JSON.stringify(err));
expect(err).assertEqual(null);
appAccountManager.deleteAccount("accessibleAccount_callback_multiple_second", (err)=>{
console.debug("====>delete second account 0900 err:" + JSON.stringify(err));
expect(err).assertEqual(null);
console.debug("====>ActsGetAllAccessibleAccounts_0900 end====");
done();
})
})
})
})
})
});
});
/*
* @tc.number : ActsGetAllAccessibleAccounts_1000
* @tc.name : getAllAccessibleAccounts promise
* @tc.desc : This application adds different application accounts three times in a row, and then obtains
* authorization multiple times
*/
it('ActsGetAllAccessibleAccounts_1000', 0, async function (done) {
console.debug("====>ActsGetAllAccessibleAccounts_1000 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
console.debug("====>getAllAccounts for clean====");
var selfBundle = "com.example.actsgetallaccessibleaccounts";
try{
var acclist = await appAccountManager.getAllAccounts(selfBundle);
}
catch(err){
console.error("====>getAllAccounts err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>account list length: " + acclist.length);
if(acclist.length > 0){
for(var i = 0;i < acclist.length; i++){
await appAccountManager.deleteAccount(acclist[i].name);
}
}
console.debug("====>add first account 1000 start====");
await appAccountManager.addAccount("accessibleAccount_promise_multiple_first");
console.debug("====>add second account 1000 start====");
await appAccountManager.addAccount("accessibleAccount_promise_multiple_second");
console.debug("====>getAllAccessibleAccounts first 1000 start====");
try{
var data = await appAccountManager.getAllAccessibleAccounts();
}
catch(err){
console.error("====>getAllAccessibleAccounts first 1000 fail err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>getAllAccessibleAccounts 1000 data:" + JSON.stringify(data));
expect(data.length).assertEqual(2);
try{
expect(data[0].name).assertEqual("accessibleAccount_promise_multiple_first");
expect(data[0].owner).assertEqual("com.example.actsgetallaccessibleaccounts");
expect(data[1].name).assertEqual("accessibleAccount_promise_multiple_second");
expect(data[1].owner).assertEqual("com.example.actsgetallaccessibleaccounts");
}
catch(err){
console.error("====>check data 1000 fail err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>getAllAccessibleAccounts second 1000 start====");
try{
var dataTwo = await appAccountManager.getAllAccessibleAccounts();
}
catch(err){
console.error("====>getAllAccessibleAccounts second 1000 fail err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>getAllAccessibleAccounts 1000 dataTwo:" + JSON.stringify(dataTwo));
expect(data.length).assertEqual(2);
try{
expect(dataTwo[0].name).assertEqual("accessibleAccount_promise_multiple_first");
expect(dataTwo[0].owner).assertEqual("com.example.actsgetallaccessibleaccounts");
expect(dataTwo[1].name).assertEqual("accessibleAccount_promise_multiple_second");
expect(dataTwo[1].owner).assertEqual("com.example.actsgetallaccessibleaccounts");
}
catch(err){
console.error("====>check dataTwo 1000 fail err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>delete first account 1000 start====");
await appAccountManager.deleteAccount("accessibleAccount_promise_multiple_first");
console.debug("====>delete second account 1000 start====");
await appAccountManager.deleteAccount("accessibleAccount_promise_multiple_second");
console.debug("====>ActsGetAllAccessibleAccounts_1000 end====");
done();
});
/*
* @tc.number : ActsGetAllAccessibleAccounts_1100
* @tc.name : getAllAccessibleAccounts
* @tc.desc : This application adds an account, other application authorizes an account to this application
* and this application obtains authorization
*/
it('ActsGetAllAccessibleAccounts_1100', 0, async function (done) {
console.debug("====>ActsGetAllAccessibleAccounts_1100 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
console.debug("====>add account 1100 start====");
await appAccountManager.addAccount("accessibleAccount_this_application");
console.debug("====>startAbility 1100 start====");
await featureAbility.startAbility(
{
want:
{
deviceId: "",
bundleName: "com.example.actsaccountsceneaccessible",
abilityName: "com.example.actsaccountsceneaccessible.MainAbility",
action: "action1",
parameters:
{},
},
},
);
setTimeout(async function(){
console.debug("====>getAllAccessibleAccounts 1100 start====");
try{
var data = await appAccountManager.getAllAccessibleAccounts();
}
catch(err){
console.error("====>getAllAccessibleAccounts 1100 fail err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>getAllAccessibleAccounts 1100 data:" + JSON.stringify(data));
expect(data.length).assertEqual(2);
try{
expect(data[0].name).assertEqual("account_name_scene_single");
expect(data[0].owner).assertEqual("com.example.actsaccountsceneaccessible");
expect(data[1].name).assertEqual("accessibleAccount_this_application");
expect(data[1].owner).assertEqual("com.example.actsgetallaccessibleaccounts");
}
catch(err){
console.error("====>check data 1100 fail err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>delete account 1100 start====");
await appAccountManager.deleteAccount("accessibleAccount_this_application");
console.debug("====>ActsGetAllAccessibleAccounts_1100 end====");
done();
}, TIMEOUT);
});
})
}
\ No newline at end of file
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import ActsGetAllAccessibleAccounts from './Getallaccessible.test.js'
export default function testsuite() {
ActsGetAllAccessibleAccounts()
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "ActsGetAllAccessibleAccounts"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsGetAllAccessibleMultipleTest") {
hap_profile = "./src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsGetAllAccessibleMultipleTest"
subsystem_name = "account"
part_name = "os_account"
}
ohos_js_assets("hjs_demo_js_assets") {
js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "60000",
"bundle-name": "com.example.actsgetallaccessiblemultiple",
"package-name": "com.example.actsgetallaccessiblemultiple",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsGetAllAccessibleMultipleTest.hap",
"ActsAccountAccessibleFirst.hap",
"ActsAccountAccessibleSecond.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.actsgetallaccessiblemultiple",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsgetallaccessiblemultiple",
"name": ".entry",
"mainAbility": ".MainAbility",
"srcPath":"",
"deviceType": [
"tablet",
"default",
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"defPermissions": [
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.GET_ALL_APP_ACCOUNTS"
}
],
"reqPermissions": [
{
"name": "ohos.permission.GET_ALL_APP_ACCOUNTS",
"reason": "ceshi"
},
{
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name":"ohos.permission.GET_BUNDLE_INFO",
"reason":"need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE",
"reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name":"ohos.permission.REMOVE_CACHE_FILES",
"reason":"need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE"
}
],
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "js",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
},
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".TestAbility",
"srcLanguage": "js",
"srcPath": "TestAbility",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"label": "$string:TestAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
}
}
}
\ 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');
}
};
/*
* 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.
*/
.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.
-->
<div class="container">
<text class="title">
{{title}}
</text>
</div>
/*
* 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.
*/
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: "getAllAccessibleAccounts"
},
onInit() {
this.title = "getAllAccessibleAccounts";
},
onShow() {
console.info('onShow finish')
},
onReady() {
},
}
\ No newline at end of file
/*
* Copyright (c) 2022 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('TestApplication onCreate')
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
onDestroy() {
console.info("TestApplication onDestroy");
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ 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.
*/
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
\ 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.
-->
<div class="container" onswipe="touchMove">
<text class="title">
{{ $t('strings.hello') }} {{title}}
</text>
<input class="btn" type="button" value="{{ $t('strings.next') }}" onclick="onclick"></input>
</div>
/*
* Copyright (c) 2022 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 {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
/*
* Copyright (c) 2022 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package', '-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
export default {
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
},
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility'
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
console.info('debug value : '+debug)
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + data.stdResult);
console.info('executeShellCommand : data : ' + data.exitCode);
})
}
};
/*
* 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 account from '@ohos.account.appAccount'
import featureAbility from '@ohos.ability.featureAbility'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
const TIMEOUT = 5000;
export default function ActsGetAllAccessibleMultiple() {
describe('ActsGetAllAccessibleMultiple', function () {
beforeAll(async function (done) {
console.debug("====>startAbility first start====");
await featureAbility.startAbility(
{
want:
{
deviceId: "",
bundleName: "com.example.actsaccountaccessiblefirst",
abilityName: "com.example.actsaccountaccessiblefirst.MainAbility",
action: "action1",
parameters:
{},
},
},
);
sleep(TIMEOUT);
done();
});
function sleep(delay) {
var start = (new Date()).getTime();
while((new Date()).getTime() - start < delay) {
continue;
}
}
/*
* @tc.number : ActsGetAllAccessibleMultiple_0100
* @tc.name : getAllAccessibleAccounts
* @tc.desc : This application adds multiple account, other applications authorizes multiple accounts to this
* application and this application obtains authorization
*/
it('ActsGetAllAccessibleMultiple_0100', 0, async function (done) {
console.debug("====>ActsGetAllAccessibleMultiple_0100 start====");
let dataMap = new Map();
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
console.debug("====>add first account 0100 start====");
await appAccountManager.addAccount("accessibleAccount_this_application_first");
console.debug("====>add second account 0100 start====");
await appAccountManager.addAccount("accessibleAccount_this_application_second");
console.debug("====>add third account 0100 start====");
await appAccountManager.addAccount("accessibleAccount_this_application_third");
console.debug("====>getAllAccessibleAccounts 0100 start====");
try{
var data = await appAccountManager.getAllAccessibleAccounts();
}
catch(err){
console.error("====>getAllAccessibleAccounts 0100 fail err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>getAllAccessibleAccounts 0100 data:" + JSON.stringify(data));
expect(data.length).assertEqual(7);
console.debug("====>data.length:" + data.length);
for (let i = 0, len = data.length; i < len; i++) {
dataMap.set(data[i].name, data[i].owner)
}
expect(dataMap.has("account_name_scene_first_first")).assertTrue();
if (dataMap.has("account_name_scene_first_first")) {
let data = dataMap.get("account_name_scene_first_first");
console.debug("====>first account owner is: " + data);
expect(data).assertEqual("com.example.actsaccountaccessiblefirst");
}
expect(dataMap.has("account_name_scene_first_second")).assertTrue();
if (dataMap.has("account_name_scene_first_second")) {
let data = dataMap.get("account_name_scene_first_second");
console.debug("====>second account owner is: " + data);
expect(data).assertEqual("com.example.actsaccountaccessiblefirst");
}
expect(dataMap.has("account_name_scene_second_first")).assertTrue();
if (dataMap.has("account_name_scene_second_first")) {
let data = dataMap.get("account_name_scene_second_first");
console.debug("====>third account owner is: " + data);
expect(data).assertEqual("com.example.actsaccountaccessiblesecond");
}
expect(dataMap.has("account_name_scene_second_second")).assertTrue();
if (dataMap.has("account_name_scene_second_second")) {
let data = dataMap.get("account_name_scene_second_second");
console.debug("====>fourth account owner is: " + data);
expect(data).assertEqual("com.example.actsaccountaccessiblesecond");
}
expect(dataMap.has("accessibleAccount_this_application_first")).assertTrue();
if (dataMap.has("accessibleAccount_this_application_first")) {
let data = dataMap.get("accessibleAccount_this_application_first");
console.debug("====>fifth account owner is: " + data);
expect(data).assertEqual("com.example.actsgetallaccessiblemultiple");
}
expect(dataMap.has("accessibleAccount_this_application_second")).assertTrue();
if (dataMap.has("accessibleAccount_this_application_second")) {
let data = dataMap.get("accessibleAccount_this_application_second");
console.debug("====>sixth account owner is: " + data);
expect(data).assertEqual("com.example.actsgetallaccessiblemultiple");
}
expect(dataMap.has("accessibleAccount_this_application_third")).assertTrue();
if (dataMap.has("accessibleAccount_this_application_third")) {
let data = dataMap.get("accessibleAccount_this_application_third");
console.debug("====>seventh account owner is: " + data);
expect(data).assertEqual("com.example.actsgetallaccessiblemultiple");
}
console.debug("====>delete account start====");
await appAccountManager.deleteAccount("accessibleAccount_this_application_first");
await appAccountManager.deleteAccount("accessibleAccount_this_application_second");
await appAccountManager.deleteAccount("accessibleAccount_this_application_third");
console.debug("====>ActsGetAllAccessibleAccounts_0100 end====");
done();
});
})
}
\ No newline at end of file
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import ActsGetAllAccessibleMultiple from './Getmultiple.test.js'
export default function testsuite() {
ActsGetAllAccessibleMultiple()
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "ActsGetAllAccessibleMultiple"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
...@@ -28,17 +28,8 @@ ...@@ -28,17 +28,8 @@
"moduleType": "entry" "moduleType": "entry"
}, },
"defPermissions": [ "defPermissions": [
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.GET_ALL_APP_ACCOUNTS"
}
], ],
"reqPermissions": [ "reqPermissions": [
{
"name": "ohos.permission.GET_ALL_APP_ACCOUNTS",
"reason": "ceshi"
},
{ {
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
......
...@@ -28,17 +28,8 @@ ...@@ -28,17 +28,8 @@
"moduleType": "entry" "moduleType": "entry"
}, },
"defPermissions": [ "defPermissions": [
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.GET_ALL_APP_ACCOUNTS"
}
], ],
"reqPermissions": [ "reqPermissions": [
{
"name": "ohos.permission.GET_ALL_APP_ACCOUNTS",
"reason": "ceshi"
},
{ {
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册