提交 41345099 编写于 作者: G gaoxi785

Add permission test cases 0216

Signed-off-by: Ngaoxi785 <gaoxi785@huawei.com>
上级 cbf22139
...@@ -17,8 +17,10 @@ group("osaccount_hap") { ...@@ -17,8 +17,10 @@ group("osaccount_hap") {
testonly = true testonly = true
if (is_standard_system) { if (is_standard_system) {
deps = [ deps = [
"actsosaccountpermissiontest:osaccount_permission",
"actsosaccountsystemtest:ActsOsAccountSystemTest", "actsosaccountsystemtest:ActsOsAccountSystemTest",
"actsosaccountthirdpartytest:ActsOsAccountThirdPartyTest", "actsosaccountthirdpartytest:ActsOsAccountThirdPartyTest",
"sceneProject:osaccount_scene",
] ]
} }
} }
# 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("osaccount_permission") {
testonly = true
if (is_standard_system) {
deps = [
"actsosaccountconstrainttest:ActsOsAccountConstraintTest",
"actsosaccountpermissioninteracttest:ActsOsAccountPermissionInteractTest",
"actsosaccountpermissionmanagetest:ActsOsAccountPermissionManageTest",
"actsosaccountpermissionnotest:ActsOsAccountPermissionNoTest",
]
}
}
# 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("ActsOsAccountConstraintTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsOsAccountConstraintTest"
}
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": "200000",
"package": "com.example.actsosaccountconstrainttest",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsOsAccountConstraintTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.actsosaccountconstrainttest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsosaccountconstrainttest",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"defPermissions": [
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS"
}
],
"reqPermissions": [
{
"name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION",
"reason": "ceshi"
},
{
"name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS",
"reason": "ceshi"
}
],
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.actsosaccountconstrainttest.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;
}
.titleST {
font-size: 32px;
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
<text class="titleST">
STActsOsAccountConstraintTest
</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.
*/
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: ""
},
onInit() {
this.title = this.$t('strings.world');
},
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')
this.timeout = 20000;
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
},
onReady() {
},
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "ActsOsAccountPermissionSystemNoTest"
},
{
"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.
*/
import osAccount from '@ohos.account.osAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const EACHTIMEOUT = 2000;
const ERR_OSACCOUNT_KIT_CREATE_OS_ACCOUNT_ERROR = 4587523;
const ERR_OSACCOUNT_KIT_REMOVE_OSACCOUNT_ERROR = 4587529;
const ERR_OSACCOUNT_KIT_ACTIVATE_OS_ACCOUNT_ERROR = 4587571;
describe('ActsOsAccountPermissionTest', function () {
function sleep(delay) {
var start = (new Date()).getTime();
while((new Date()).getTime() - start < delay) {
continue;
}
}
beforeEach(async function (done) {
console.debug("====>beforeEach enter====");
sleep(EACHTIMEOUT);
done();
})
/*
* @tc.number : ActsOsAccountConstraint_0100
* @tc.name : createOsAccount callback
* @tc.desc : failed to create local user local user after adding constraint
*/
it('ActsOsAccountConstraint_0100', 0, async function(done){
console.debug("====>ActsOsAccountConstraint_0100 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.setOsAccountConstraints(100, ["constraint.os.account.create"], true, (err)=>{
console.debug("====>add Constraints err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
AccountManager.createOsAccount("aaa", osAccount.OsAccountType.NORMAL, (err, info)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount info:" + JSON.stringify(info));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_CREATE_OS_ACCOUNT_ERROR);
AccountManager.setOsAccountConstraints(100, ["constraint.os.account.create"], false, (err)=>{
console.debug("====>delete Constraints err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountPermission_0100 end====");
done();
})
})
})
})
/*
* @tc.number : ActsOsAccountConstraint_0200
* @tc.name : createOsAccount promise
* @tc.desc : failed to create local user local user after adding constraint
*/
it('ActsOsAccountConstraint_0200', 0, async function(done){
console.debug("====>ActsOsAccountConstraint_0200 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
await AccountManager.setOsAccountConstraints(100, ["constraint.os.account.create"], true);
try{
await AccountManager.createOsAccount("aaa", osAccount.OsAccountType.NORMAL);
}
catch(err){
console.debug("====>createOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_CREATE_OS_ACCOUNT_ERROR);
await AccountManager.setOsAccountConstraints(100, ["constraint.os.account.create"], false);
console.debug("====>ActsOsAccountConstraint_0200 end====");
done();
}
})
/*
* @tc.number : ActsOsAccountConstraint_0300
* @tc.name : removeOsAccount callback
* @tc.desc : failed to delete local user local user after adding constraint
*/
it('ActsOsAccountConstraint_0300', 0, async function(done){
console.debug("====>ActsOsAccountConstraint_0300 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
var localId;
AccountManager.createOsAccount("aaa", osAccount.OsAccountType.NORMAL, (err, info)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount info:" + JSON.stringify(info));
expect(err.code).assertEqual(0);
expect(info.localName).assertEqual("aaa");
localId = info.localId;
AccountManager.setOsAccountConstraints(100, ["constraint.os.account.remove"], true, (err)=>{
console.debug("====>add Constraints err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
AccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>removeOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_REMOVE_OSACCOUNT_ERROR);
AccountManager.setOsAccountConstraints(100, ["constraint.os.account.remove"], false, (err)=>{
console.debug("====>delete Constraints err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
AccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>removeOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountConstraint_0300 end====");
done();
})
})
})
})
})
})
/*
* @tc.number : ActsOsAccountConstraint_0400
* @tc.name : removeOsAccount promise
* @tc.desc : failed to delete local user local user after adding constraint
*/
it('ActsOsAccountConstraint_0400', 0, async function(done){
console.debug("====>ActsOsAccountConstraint_0400 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
var localId;
var info = await AccountManager.createOsAccount("aaa", osAccount.OsAccountType.NORMAL);
console.debug("====>createOsAccount info:" + JSON.stringify(info));
expect(info.localName).assertEqual("aaa");
localId = info.localId;
await AccountManager.setOsAccountConstraints(100, ["constraint.os.account.remove"], true);
try{
await AccountManager.removeOsAccount(localId);
}
catch(err){
console.debug("====>removeOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_REMOVE_OSACCOUNT_ERROR);
await AccountManager.setOsAccountConstraints(100, ["constraint.os.account.remove"], false);
console.debug("====>delete Constraint finish====");
await AccountManager.removeOsAccount(localId);
console.debug("====>ActsOsAccountConstraint_0400 end====");
done();
}
})
/*
* @tc.number : ActsOsAccountConstraint_0500
* @tc.name : activateOsAccount callback
* @tc.desc : switching local users fails after adding constraints
*/
it('ActsOsAccountConstraint_0500', 0, async function(done){
console.debug("====>ActsOsAccountConstraint_0500 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
var localId;
AccountManager.createOsAccount("aaa", osAccount.OsAccountType.NORMAL, (err, info)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount info:" + JSON.stringify(info));
expect(err.code).assertEqual(0);
expect(info.localName).assertEqual("aaa");
localId = info.localId;
AccountManager.setOsAccountConstraints(100, ["constraint.os.account.start"], true, (err)=>{
console.debug("====>add Constraints err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
AccountManager.activateOsAccount(localId, (err)=>{
console.debug("====>activateOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_ACTIVATE_OS_ACCOUNT_ERROR);
AccountManager.setOsAccountConstraints(100, ["constraint.os.account.start"], false, (err)=>{
console.debug("====>delete Constraints err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
AccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>removeOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountConstraint_0500 end====");
done();
})
})
})
})
})
})
/*
* @tc.number : ActsOsAccountConstraint_0600
* @tc.name : activateOsAccount promise
* @tc.desc : switching local users fails after adding constraints
*/
it('ActsOsAccountConstraint_0600', 0, async function(done){
console.debug("====>ActsOsAccountConstraint_0600 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
var localId;
var info = await AccountManager.createOsAccount("aaa", osAccount.OsAccountType.NORMAL);
console.debug("====>createOsAccount info:" + JSON.stringify(info));
expect(info.localName).assertEqual("aaa");
localId = info.localId;
await AccountManager.setOsAccountConstraints(100, ["constraint.os.account.start"], true);
try{
await AccountManager.activateOsAccount(localId);
}
catch(err){
console.debug("====>activateOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_ACTIVATE_OS_ACCOUNT_ERROR);
await AccountManager.setOsAccountConstraints(100, ["constraint.os.account.start"], false);
console.debug("====>delete Constraint finish====");
await AccountManager.removeOsAccount(localId);
console.debug("====>ActsOsAccountConstraint_0600 end====");
done();
}
})
/*
* @tc.number : ActsOsAccountConstraint_0700
* @tc.name : setOsAccountProfilePhoto callback
* @tc.desc : failed to set profile photo for local user after adding constraint
*/
it('ActsOsAccountConstraint_0700', 0, async function(done){
console.debug("====>ActsOsAccountConstraint_0700 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
var localId;
var photo = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMD"+
"AsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUF"+
"BQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAARCAALAAwDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAA"+
"gEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTV"+
"FVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5"+
"ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBU"+
"QdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEh"+
"YaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAP"+
"wD2v4p+OPEXwz+LN3rvivwn4nh0bV9dsP7Oe51nRLOC7EF0kpEkL6psLRLDGsVwFhZkm8ucFljc/R1z8SPiZqBjl0n4SXljb7cPD4g1iwiuA"+
"+TyBbTzoVxtwd+c5yBwT1/hv4W+F/CupalqVjpSy6rqQaO81PUJpL28niLFvJaednkMKljti3bEzhVArQ8H+CtE+H+iro/h7T49J0mORpIbC"+
"3ZvIt9xyUiQnbFGO0aAIMnAGaxlTcqPsnJrrdb7Jfpv1vt1eilap7Syfk/n/nt09NF//9k=";
AccountManager.createOsAccount("aaa", osAccount.OsAccountType.NORMAL, (err, info)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount info:" + JSON.stringify(info));
expect(err.code).assertEqual(0);
expect(info.localName).assertEqual("aaa");
localId = info.localId;
AccountManager.setOsAccountConstraints(100, ["constraint.os.account.set.icon"], true, (err)=>{
console.debug("====>add Constraints err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
AccountManager.setOsAccountProfilePhoto(localId, photo, (err)=>{
console.debug("====>setOsAccountProfilePhoto err:" + JSON.stringify(err));
expect(err.code !=0 ).assertEqual(true);
AccountManager.setOsAccountConstraints(100, ["constraint.os.account.set.icon"], false, (err)=>{
console.debug("====>delete Constraints err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
AccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>removeOsAccount err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountConstraint_0700 end====");
done();
})
})
})
})
})
})
/*
* @tc.number : ActsOsAccountConstraint_0800
* @tc.name : setOsAccountProfilePhoto promise
* @tc.desc : failed to set profile photo for local user after adding constraint
*/
it('ActsOsAccountConstraint_0800', 0, async function(done){
console.debug("====>ActsOsAccountConstraint_0800 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
var localId;
var photo = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMD"+
"AsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUF"+
"BQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAARCAALAAwDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAA"+
"gEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTV"+
"FVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5"+
"ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBU"+
"QdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEh"+
"YaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAP"+
"wD2v4p+OPEXwz+LN3rvivwn4nh0bV9dsP7Oe51nRLOC7EF0kpEkL6psLRLDGsVwFhZkm8ucFljc/R1z8SPiZqBjl0n4SXljb7cPD4g1iwiuA"+
"+TyBbTzoVxtwd+c5yBwT1/hv4W+F/CupalqVjpSy6rqQaO81PUJpL28niLFvJaednkMKljti3bEzhVArQ8H+CtE+H+iro/h7T49J0mORpIbC"+
"3ZvIt9xyUiQnbFGO0aAIMnAGaxlTcqPsnJrrdb7Jfpv1vt1eilap7Syfk/n/nt09NF//9k=";
var info = await AccountManager.createOsAccount("aaa", osAccount.OsAccountType.NORMAL);
console.debug("====>createOsAccount info:" + JSON.stringify(info));
expect(info.localName).assertEqual("aaa");
localId = info.localId;
await AccountManager.setOsAccountConstraints(100, ["constraint.os.account.set.icon"], true);
try{
await AccountManager.setOsAccountProfilePhoto(localId, photo);
}
catch(err){
console.debug("====>setOsAccountProfilePhoto err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
await AccountManager.setOsAccountConstraints(100, ["constraint.os.account.set.icon"], false);
console.debug("====>delete Constraints finish====");
await AccountManager.removeOsAccount(localId);
console.debug("====>ActsOsAccountConstraint_0800 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.
*/
require('./Constraint.test.js')
\ 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("ActsOsAccountPermissionInteractTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsOsAccountPermissionInteractTest"
}
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.actsosaccountpermissioninteracttest",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsOsAccountPermissionInteractTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.actsosaccountpermissioninteracttest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsosaccountpermissioninteracttest",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"defPermissions": [
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION"
}
],
"reqPermissions": [
{
"name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION",
"reason": "ceshi"
}
],
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.actsosaccountpermissioninteracttest.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');
}
};
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
.titleST {
font-size: 32px;
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
<text class="titleST">
STActsOsAccountPermissionInteractTest
</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.
*/
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: ""
},
onInit() {
this.title = this.$t('strings.world');
},
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": "ActsAccountTest"
},
{
"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.
*/
import osAccount from '@ohos.account.osAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('ActsOsAccountPermissionTest', function () {
/*
* @tc.number : ActsOsAccountPermissionInteract_0100
* @tc.name : isOsAccountActived callback
* @tc.desc : only satisfies the INTERACT permission
*/
it('ActsOsAccountPermissionInteract_0100', 0, async function(done){
console.debug("====>ActsOsAccountPermissionInteract_0100 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.isOsAccountActived(100, (err, isActived)=>{
console.debug("====>isOsAccountActived err:" + JSON.stringify(err));
console.debug("====>isOsAccountActived isActived:" + isActived);
expect(err.code).assertEqual(0);
expect(isActived).assertEqual(true);
console.debug("====>ActsOsAccountPermissionInteract_0100 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountPermissionInteract_0200
* @tc.name : isOsAccountActived promise
* @tc.desc : only satisfies the INTERACT permission
*/
it('ActsOsAccountPermissionInteract_0200', 0, async function(done){
console.debug("====>ActsOsAccountPermissionInteract_0200 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
try{
var isActived = await AccountManager.isOsAccountActived(100);
}
catch(err){
console.debug("====>isOsAccountActived err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>isOsAccountActived isActived:" + isActived);
expect(isActived).assertEqual(true);
console.debug("====>ActsOsAccountPermissionInteract_0200 end====");
done();
})
/*
* @tc.number : ActsOsAccountPermissionInteract_0300
* @tc.name : isOsAccountVerified callback
* @tc.desc : only satisfies the INTERACT permission
*/
it('ActsOsAccountPermissionInteract_0300', 0, async function(done){
console.debug("====>ActsOsAccountPermissionInteract_0300 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.isOsAccountVerified(100, (err, isVerified)=>{
console.debug("====>isOsAccountVerified err:" + JSON.stringify(err));
console.debug("====>isOsAccountVerified isVerified:" + isVerified);
expect(err.code).assertEqual(0);
expect(isVerified).assertEqual(false);
console.debug("====>ActsOsAccountPermissionInteract_0300 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountPermissionInteract_0400
* @tc.name : isOsAccountVerified promise
* @tc.desc : only satisfies the INTERACT permission
*/
it('ActsOsAccountPermissionInteract_0400', 0, async function(done){
console.debug("====>ActsOsAccountPermissionInteract_0400 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
try{
var isVerified = await AccountManager.isOsAccountVerified(100);
}
catch(err){
console.debug("====>isOsAccountVerified err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>isOsAccountVerified isVerified:" + isVerified);
expect(isVerified).assertEqual(false);
console.debug("====>ActsOsAccountPermissionInteract_0400 end====");
done();
})
/*
* @tc.number : ActsOsAccountPermissionInteract_0500
* @tc.name : queryOsAccountById callback
* @tc.desc : only satisfies the INTERACT permission
*/
it('ActsOsAccountPermissionInteract_0500', 0, async function(done){
console.debug("====>ActsOsAccountPermissionInteract_0500 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.queryOsAccountById(100, (err, data)=>{
console.debug("====>queryOsAccountById err:" + JSON.stringify(err));
console.debug("====>queryOsAccountById data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
expect(data.localId).assertEqual(100);
expect(data.type.ADMIN).assertEqual(0);
var serialNumberStr = data.serialNumber.toString();
var serialIntercept = serialNumberStr.substring(8);
console.debug("====>truncate the last eight characters: " + serialIntercept);
expect(serialIntercept).assertEqual("00000001");
expect(data.isCreateCompleted).assertTrue();
console.debug("====>ActsOsAccountPermissionInteract_0500 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountPermissionInteract_0600
* @tc.name : queryOsAccountById promise
* @tc.desc : only satisfies the INTERACT permission
*/
it('ActsOsAccountPermissionInteract_0600', 0, async function(done){
console.debug("====>ActsOsAccountPermissionInteract_0600 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
var osAccountInfo = await AccountManager.queryOsAccountById(100);
console.debug("====>queryOsAccountById osAccountInfo:" + JSON.stringify(osAccountInfo));
expect(osAccountInfo.localId).assertEqual(100);
expect(osAccountInfo.type.ADMIN).assertEqual(0);
var serialNumberStr = osAccountInfo.serialNumber.toString();
var serialIntercept = serialNumberStr.substring(8);
console.debug("====>truncate the last eight characters: " + serialIntercept);
expect(serialIntercept).assertEqual("00000001");
expect(osAccountInfo.isCreateCompleted).assertTrue();
console.debug("====>ActsOsAccountPermissionInteract_0600 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.
*/
require('./Interact.test.js')
\ 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("ActsOsAccountPermissionManageTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsOsAccountPermissionManageTest"
}
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.actsosaccountpermissionmanagetest",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsOsAccountPermissionManageTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.actsosaccountpermissionmanagetest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsosaccountpermissionmanagetest",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"defPermissions": [
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS"
}
],
"reqPermissions": [
{
"name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS",
"reason": "ceshi"
}
],
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.actsosaccountpermissionmanagetest.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');
}
};
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
.titleST {
font-size: 32px;
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
<text class="titleST">
STActsOsAccountPermissionManageTest
</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.
*/
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: ""
},
onInit() {
this.title = this.$t('strings.world');
},
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": "ActsAccountTest"
},
{
"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('./Manage.test.js')
\ No newline at end of file
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import osAccount from '@ohos.account.osAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('ActsOsAccountPermissionTest', function () {
/*
* @tc.number : ActsOsAccountPermissionManage_0100
* @tc.name : isOsAccountActived callback
* @tc.desc : only satisfies the MANAGE permission
*/
it('ActsOsAccountPermissionManage_0100', 0, async function(done){
console.debug("====>ActsOsAccountPermissionManage_0100 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.isOsAccountActived(100, (err, isActived)=>{
console.debug("====>isOsAccountActived err:" + JSON.stringify(err));
console.debug("====>isOsAccountActived isActived:" + isActived);
expect(err.code).assertEqual(0);
expect(isActived).assertEqual(true);
console.debug("====>ActsOsAccountPermissionManage_0100 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountPermissionManage_0200
* @tc.name : isOsAccountActived promise
* @tc.desc : only satisfies the MANAGE permission
*/
it('ActsOsAccountPermissionManage_0200', 0, async function(done){
console.debug("====>ActsOsAccountPermissionManage_0200 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
try{
var isActived = await AccountManager.isOsAccountActived(100);
}
catch(err){
console.debug("====>isOsAccountActived err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>isOsAccountActived isActived:" + isActived);
expect(isActived).assertEqual(true);
console.debug("====>ActsOsAccountPermissionManage_0200 end====");
done();
})
/*
* @tc.number : ActsOsAccountPermissionManage_0300
* @tc.name : isOsAccountVerified callback
* @tc.desc : only satisfies the MANAGE permission
*/
it('ActsOsAccountPermissionManage_0300', 0, async function(done){
console.debug("====>ActsOsAccountPermissionManage_0300 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.isOsAccountVerified(100, (err, isVerified)=>{
console.debug("====>isOsAccountVerified err:" + JSON.stringify(err));
console.debug("====>isOsAccountVerified isVerified:" + isVerified);
expect(err.code).assertEqual(0);
expect(isVerified).assertEqual(false);
console.debug("====>ActsOsAccountPermissionManage_0300 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountPermissionManage_0400
* @tc.name : isOsAccountVerified promise
* @tc.desc : only satisfies the MANAGE permission
*/
it('ActsOsAccountPermissionManage_0400', 0, async function(done){
console.debug("====>ActsOsAccountPermissionManage_0400 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
try{
var isVerified = await AccountManager.isOsAccountVerified(100);
}
catch(err){
console.debug("====>isOsAccountVerified err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>isOsAccountVerified isVerified:" + isVerified);
expect(isVerified).assertEqual(false);
console.debug("====>ActsOsAccountPermissionManage_0400 end====");
done();
})
/*
* @tc.number : ActsOsAccountPermissionManage_0500
* @tc.name : queryOsAccountById callback
* @tc.desc : only satisfies the MANAGE permission
*/
it('ActsOsAccountPermissionManage_0500', 0, async function(done){
console.debug("====>ActsOsAccountPermissionManage_0500 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.queryOsAccountById(100, (err, data)=>{
console.debug("====>queryOsAccountById err:" + JSON.stringify(err));
console.debug("====>queryOsAccountById data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
expect(data.localId).assertEqual(100);
expect(data.type.ADMIN).assertEqual(0);
var serialNumberStr = data.serialNumber.toString();
var serialIntercept = serialNumberStr.substring(8);
console.debug("====>truncate the last eight characters: " + serialIntercept);
expect(serialIntercept).assertEqual("00000001");
expect(data.isCreateCompleted).assertTrue();
console.debug("====>ActsOsAccountPermissionManage_0500 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountPermissionManage_0600
* @tc.name : queryOsAccountById promise
* @tc.desc : only satisfies the MANAGE permission
*/
it('ActsOsAccountPermissionManage_0600', 0, async function(done){
console.debug("====>ActsOsAccountPermissionManage_0600 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
var osAccountInfo = await AccountManager.queryOsAccountById(100);
console.debug("====>queryOsAccountById osAccountInfo:" + JSON.stringify(osAccountInfo));
expect(osAccountInfo.localId).assertEqual(100);
expect(osAccountInfo.type.ADMIN).assertEqual(0);
var serialNumberStr = osAccountInfo.serialNumber.toString();
var serialIntercept = serialNumberStr.substring(8);
console.debug("====>truncate the last eight characters: " + serialIntercept);
expect(serialIntercept).assertEqual("00000001");
expect(osAccountInfo.isCreateCompleted).assertTrue();
console.debug("====>ActsOsAccountPermissionManage_0600 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsOsAccountPermissionNoTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsOsAccountPermissionNoTest"
}
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": "150000",
"package": "com.example.actsosaccountpermissionnotest",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsOsAccountPermissionNoTest.hap",
"ActsOsAccountScenePermission"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.actsosaccountpermissionnotest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsosaccountpermissionnotest",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"reqPermissions": [
{
"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"
]
}
],
"name": "com.example.actsosaccountpermissionnotest.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": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
.titleST {
font-size: 32px;
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
<text class="titleST">
STActsOsAccountPermissionNoTest
</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.
*/
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: ""
},
onInit() {
this.title = this.$t('strings.world');
},
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": "ActsOsAccountPermissionSystemNoTest"
},
{
"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('./Permission.test.js')
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"description": "Configuration for hjunit demo Tests", "description": "Configuration for hjunit demo Tests",
"driver": { "driver": {
"type": "JSUnitTest", "type": "JSUnitTest",
"test-timeout": "800000", "test-timeout": "1000000",
"package": "com.example.actsosaccountsystemtest", "package": "com.example.actsosaccountsystemtest",
"shell-timeout": "60000" "shell-timeout": "60000"
}, },
......
...@@ -20,7 +20,7 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -20,7 +20,7 @@ describe('ActsOsAccountSystemTest', function () {
/* /*
* @tc.number : ActsOsAccountConstraints_0100 * @tc.number : ActsOsAccountConstraints_0100
* @tc.name : Constraints callback * @tc.name : Constraints callback
* @tc.desc : get 100 local user all constraints * @tc.desc : get constraints for users of the same type as 100 user
*/ */
it('ActsOsAccountConstraints_0100', 0, async function(done){ it('ActsOsAccountConstraints_0100', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_0100 start===="); console.debug("====>ActsOsAccountConstraints_0100 start====");
...@@ -30,12 +30,18 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -30,12 +30,18 @@ describe('ActsOsAccountSystemTest', function () {
"constraint.app.accounts","constraint.apps.install","constraint.apps.uninstall","constraint.location.shared", "constraint.app.accounts","constraint.apps.install","constraint.apps.uninstall","constraint.location.shared",
"constraint.unknown.sources.install","constraint.global.unknown.app.install","constraint.bluetooth.set", "constraint.unknown.sources.install","constraint.global.unknown.app.install","constraint.bluetooth.set",
"constraint.bluetooth"]; "constraint.bluetooth"];
AccountManager.getOsAccountAllConstraints(100, (err, constraints)=>{ var localId;
AccountManager.createOsAccount("osAccountNameCreate", osAccount.OsAccountType.ADMIN, (err, osAccountInfo)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount:" + JSON.stringify(osAccountInfo));
localId = osAccountInfo.localId;
AccountManager.getOsAccountAllConstraints(localId, (err, constraints)=>{
console.debug("====>getOsAccountAllConstraints err:" + JSON.stringify(err)); console.debug("====>getOsAccountAllConstraints err:" + JSON.stringify(err));
console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(constraints)); console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(constraints));
expect(err.code).assertEqual(0); expect(err.code).assertEqual(0);
expect(constraints.length).assertEqual(adminConstraints.length); expect(constraints.length).assertEqual(adminConstraints.length);
var succeed = 0, failed = 0; var succeed = 0;
var failed = 0;
for(var j = 0; j<constraints.length; j++){ for(var j = 0; j<constraints.length; j++){
if(adminConstraints.indexOf(constraints[j]) == -1){ if(adminConstraints.indexOf(constraints[j]) == -1){
failed++; failed++;
...@@ -46,17 +52,20 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -46,17 +52,20 @@ describe('ActsOsAccountSystemTest', function () {
} }
console.debug("====>the number of constraints obtained:" + succeed); console.debug("====>the number of constraints obtained:" + succeed);
console.debug("====>number of constraints not fetched:" + failed); console.debug("====>number of constraints not fetched:" + failed);
if(failed == 0){ expect(failed).assertEqual(0);
AccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>removeOsAccount err:" + JSON.stringify(err));
console.debug("====>ActsOsAccountConstraints_0100 end===="); console.debug("====>ActsOsAccountConstraints_0100 end====");
done(); done();
} })
})
}) })
}) })
/* /*
* @tc.number : ActsOsAccountConstraints_0200 * @tc.number : ActsOsAccountConstraints_0200
* @tc.name : Constraints promise * @tc.name : Constraints promise
* @tc.desc : get 100 local user all constraints * @tc.desc : get constraints for users of the same type as 100 user
*/ */
it('ActsOsAccountConstraints_0200', 0, async function(done){ it('ActsOsAccountConstraints_0200', 0, async function(done){
console.debug("====>ActsOsAccountConstraints_0200 start===="); console.debug("====>ActsOsAccountConstraints_0200 start====");
...@@ -66,10 +75,15 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -66,10 +75,15 @@ describe('ActsOsAccountSystemTest', function () {
"constraint.app.accounts","constraint.apps.install","constraint.apps.uninstall","constraint.location.shared", "constraint.app.accounts","constraint.apps.install","constraint.apps.uninstall","constraint.location.shared",
"constraint.unknown.sources.install","constraint.global.unknown.app.install","constraint.bluetooth.set", "constraint.unknown.sources.install","constraint.global.unknown.app.install","constraint.bluetooth.set",
"constraint.bluetooth"]; "constraint.bluetooth"];
var constraints = await AccountManager.getOsAccountAllConstraints(100); var localId;
var osAccountInfo = await AccountManager.createOsAccount("osAccountNameCreate", osAccount.OsAccountType.ADMIN);
console.debug("====>createOsAccount:" + JSON.stringify(osAccountInfo));
localId = osAccountInfo.localId;
var constraints = await AccountManager.getOsAccountAllConstraints(localId);
console.debug("====>getAccountManager constraints:" + JSON.stringify(constraints)); console.debug("====>getAccountManager constraints:" + JSON.stringify(constraints));
expect(constraints.length).assertEqual(adminConstraints.length); expect(constraints.length).assertEqual(adminConstraints.length);
var succeed = 0, failed = 0; var succeed = 0;
var failed = 0;
for(var j = 0; j<constraints.length; j++){ for(var j = 0; j<constraints.length; j++){
if(adminConstraints.indexOf(constraints[j]) == -1){ if(adminConstraints.indexOf(constraints[j]) == -1){
failed++; failed++;
...@@ -80,10 +94,8 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -80,10 +94,8 @@ describe('ActsOsAccountSystemTest', function () {
} }
console.debug("====>the number of constraints obtained:" + succeed); console.debug("====>the number of constraints obtained:" + succeed);
console.debug("====>number of constraints not fetched:" + failed); console.debug("====>number of constraints not fetched:" + failed);
if(failed == 0){ expect(failed).assertEqual(0);
console.debug("====>ActsOsAccountConstraints_0100 end===="); await AccountManager.removeOsAccount(localId);
done();
}
console.debug("====>ActsOsAccountConstraints_0200 end===="); console.debug("====>ActsOsAccountConstraints_0200 end====");
done(); done();
}) })
...@@ -743,10 +755,10 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -743,10 +755,10 @@ describe('ActsOsAccountSystemTest', function () {
console.debug("====>get AccountManager finish===="); console.debug("====>get AccountManager finish====");
var localId; var localId;
var normalConstraint = ["constraint.global.unknown.app.install","constraint.bluetooth.set", var normalConstraint = ["constraint.global.unknown.app.install","constraint.bluetooth.set",
"constraint.bluetooth","constraint.bluetooth.share","constraint.usb.file.transfer","constraint.credentials.set", "constraint.bluetooth","constraint.bluetooth.share","constraint.usb.file.transfer",
"constraint.os.account.remove","constraint.managed.profile.remove","constraint.debug.features.use", "constraint.credentials.set","constraint.managed.profile.remove","constraint.debug.features.use",
"constraint.vpn.set","constraint.date.time.set","constraint.tethering.config","constraint.network.reset", "constraint.vpn.set","constraint.date.time.set","constraint.tethering.config",
"constraint.factory.reset","constraint.os.account.create","constraint.add.managed.profile", "constraint.network.reset","constraint.factory.reset","constraint.add.managed.profile",
"constraint.apps.verify.disable","constraint.cell.broadcasts.set"]; "constraint.apps.verify.disable","constraint.cell.broadcasts.set"];
AccountManager.createOsAccount('NameConstraintsC', osAccount.OsAccountType.NORMAL, (err, data)=>{ AccountManager.createOsAccount('NameConstraintsC', osAccount.OsAccountType.NORMAL, (err, data)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err)); console.debug("====>createOsAccount err:" + JSON.stringify(err));
...@@ -759,7 +771,8 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -759,7 +771,8 @@ describe('ActsOsAccountSystemTest', function () {
console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(allConstraints)); console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(allConstraints));
expect(err.code).assertEqual(0); expect(err.code).assertEqual(0);
expect(allConstraints.length).assertEqual(normalConstraint.length); expect(allConstraints.length).assertEqual(normalConstraint.length);
var succeed = 0, failed = 0; var succeed = 0;
var failed = 0;
for(var j = 0; j<allConstraints.length; j++){ for(var j = 0; j<allConstraints.length; j++){
if(normalConstraint.indexOf(allConstraints[j]) == -1){ if(normalConstraint.indexOf(allConstraints[j]) == -1){
failed++; failed++;
...@@ -801,10 +814,10 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -801,10 +814,10 @@ describe('ActsOsAccountSystemTest', function () {
console.debug("====>get AccountManager finish===="); console.debug("====>get AccountManager finish====");
var localId; var localId;
var normalConstraint = ["constraint.global.unknown.app.install","constraint.bluetooth.set", var normalConstraint = ["constraint.global.unknown.app.install","constraint.bluetooth.set",
"constraint.bluetooth","constraint.bluetooth.share","constraint.usb.file.transfer","constraint.credentials.set", "constraint.bluetooth","constraint.bluetooth.share","constraint.usb.file.transfer",
"constraint.os.account.remove","constraint.managed.profile.remove","constraint.debug.features.use", "constraint.credentials.set","constraint.managed.profile.remove","constraint.debug.features.use",
"constraint.vpn.set","constraint.date.time.set","constraint.tethering.config","constraint.network.reset", "constraint.vpn.set","constraint.date.time.set","constraint.tethering.config",
"constraint.factory.reset","constraint.os.account.create","constraint.add.managed.profile", "constraint.network.reset","constraint.factory.reset","constraint.add.managed.profile",
"constraint.apps.verify.disable","constraint.cell.broadcasts.set"]; "constraint.apps.verify.disable","constraint.cell.broadcasts.set"];
var info = await AccountManager.createOsAccount("NameConstraintsP", osAccount.OsAccountType.NORMAL); var info = await AccountManager.createOsAccount("NameConstraintsP", osAccount.OsAccountType.NORMAL);
console.debug("====>createOsAccount info:" + JSON.stringify(info)); console.debug("====>createOsAccount info:" + JSON.stringify(info));
...@@ -813,7 +826,8 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -813,7 +826,8 @@ describe('ActsOsAccountSystemTest', function () {
var allConstraints = await AccountManager.getOsAccountAllConstraints(localId); var allConstraints = await AccountManager.getOsAccountAllConstraints(localId);
console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(allConstraints)); console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(allConstraints));
expect(allConstraints.length).assertEqual(normalConstraint.length); expect(allConstraints.length).assertEqual(normalConstraint.length);
var succeed = 0, failed = 0; var succeed = 0;
var failed = 0;
for(var j = 0; j<allConstraints.length; j++){ for(var j = 0; j<allConstraints.length; j++){
if(normalConstraint.indexOf(allConstraints[j]) == -1){ if(normalConstraint.indexOf(allConstraints[j]) == -1){
failed++; failed++;
...@@ -847,10 +861,9 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -847,10 +861,9 @@ describe('ActsOsAccountSystemTest', function () {
console.debug("====>get AccountManager finish===="); console.debug("====>get AccountManager finish====");
var localId; var localId;
var guestConstraints = ["constraint.tethering.config","constraint.network.reset","constraint.factory.reset", var guestConstraints = ["constraint.tethering.config","constraint.network.reset","constraint.factory.reset",
"constraint.os.account.create","constraint.add.managed.profile","constraint.apps.verify.disable", "constraint.add.managed.profile","constraint.apps.verify.disable","constraint.cell.broadcasts.set",
"constraint.cell.broadcasts.set","constraint.mobile.networks.set","constraint.control.apps", "constraint.mobile.networks.set","constraint.control.apps","constraint.physical.media","constraint.microphone",
"constraint.physical.media","constraint.microphone","constraint.microphone.unmute","constraint.volume.adjust", "constraint.microphone.unmute","constraint.volume.adjust","constraint.calls.outgoing","constraint.sms.use"];
"constraint.calls.outgoing","constraint.sms.use"];
AccountManager.createOsAccount('NameConstraintsC', osAccount.OsAccountType.GUEST, (err, data)=>{ AccountManager.createOsAccount('NameConstraintsC', osAccount.OsAccountType.GUEST, (err, data)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err)); console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount data:" + JSON.stringify(data)); console.debug("====>createOsAccount data:" + JSON.stringify(data));
...@@ -862,7 +875,8 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -862,7 +875,8 @@ describe('ActsOsAccountSystemTest', function () {
console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(allConstraints)); console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(allConstraints));
expect(err.code).assertEqual(0); expect(err.code).assertEqual(0);
expect(allConstraints.length).assertEqual(guestConstraints.length); expect(allConstraints.length).assertEqual(guestConstraints.length);
var succeed = 0, failed = 0; var succeed = 0;
var failed = 0;
for(var j = 0; j<allConstraints.length; j++){ for(var j = 0; j<allConstraints.length; j++){
if(guestConstraints.indexOf(allConstraints[j]) == -1){ if(guestConstraints.indexOf(allConstraints[j]) == -1){
failed++; failed++;
...@@ -904,10 +918,9 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -904,10 +918,9 @@ describe('ActsOsAccountSystemTest', function () {
console.debug("====>get AccountManager finish===="); console.debug("====>get AccountManager finish====");
var localId; var localId;
var guestConstraints = ["constraint.tethering.config","constraint.network.reset","constraint.factory.reset", var guestConstraints = ["constraint.tethering.config","constraint.network.reset","constraint.factory.reset",
"constraint.os.account.create","constraint.add.managed.profile","constraint.apps.verify.disable", "constraint.add.managed.profile","constraint.apps.verify.disable","constraint.cell.broadcasts.set",
"constraint.cell.broadcasts.set","constraint.mobile.networks.set","constraint.control.apps", "constraint.mobile.networks.set","constraint.control.apps","constraint.physical.media","constraint.microphone",
"constraint.physical.media","constraint.microphone","constraint.microphone.unmute","constraint.volume.adjust", "constraint.microphone.unmute","constraint.volume.adjust","constraint.calls.outgoing","constraint.sms.use"];
"constraint.calls.outgoing","constraint.sms.use"];
var info = await AccountManager.createOsAccount("NameConstraintsP", osAccount.OsAccountType.GUEST); var info = await AccountManager.createOsAccount("NameConstraintsP", osAccount.OsAccountType.GUEST);
console.debug("====>createOsAccount info:" + JSON.stringify(info)); console.debug("====>createOsAccount info:" + JSON.stringify(info));
expect(info.localName).assertEqual("NameConstraintsP"); expect(info.localName).assertEqual("NameConstraintsP");
...@@ -915,7 +928,8 @@ describe('ActsOsAccountSystemTest', function () { ...@@ -915,7 +928,8 @@ describe('ActsOsAccountSystemTest', function () {
var allConstraints = await AccountManager.getOsAccountAllConstraints(localId); var allConstraints = await AccountManager.getOsAccountAllConstraints(localId);
console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(allConstraints)); console.debug("====>getOsAccountAllConstraints:" + JSON.stringify(allConstraints));
expect(allConstraints.length).assertEqual(guestConstraints.length); expect(allConstraints.length).assertEqual(guestConstraints.length);
var succeed = 0, failed = 0; var succeed = 0;
var failed = 0;
for(var j = 0; j<allConstraints.length; j++){ for(var j = 0; j<allConstraints.length; j++){
if(guestConstraints.indexOf(allConstraints[j]) == -1){ if(guestConstraints.indexOf(allConstraints[j]) == -1){
failed++; failed++;
......
# 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("osaccount_scene") {
testonly = true
if (is_standard_system) {
deps = [ "actsosaccountscenepermission:ActsOsAccountScenePermission" ]
}
}
# 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_hap("ActsOsAccountScenePermission") {
hap_profile = "./entry/src/main/config.json"
hap_name = "ActsOsAccountScenePermission"
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"
}
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",
}
{
"app": {
"bundleName": "com.example.actsosaccountscenepermission",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsosaccountscenepermission",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"defPermissions": [
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS"
}
],
"reqPermissions": [
{
"name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION",
"reason": "ceshi"
},
{
"name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS",
"reason": "ceshi"
}
],
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.actsosaccountscenepermission.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;
}
.titleST {
font-size: 32px;
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
<text class="titleST">
STActsOsAccountScenePermission
</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.
*/
import osaccount from '@ohos.account.osAccount'
import commonevent from '@ohos.commonevent'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
},
onInit() {
this.title = "";
},
onShow() {
var createIocalId;
var commonEventSubscribeInfo = {
events: ["osaccount_event_delete_permission"]
}
var subscriber;
function subscriberCallback(err, data){
console.debug("====>subscriberCallback data:" + JSON.stringify(data));
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
osAccountManager.removeOsAccount(createIocalId);
commonevent.unsubscribe(subscriber, unSubscriberCallback);
}
function unSubscriberCallback(err){
console.debug("====>unsubscribe err:" + JSON.stringify(err));
}
commonevent.createSubscriber(commonEventSubscribeInfo).then(function (data){
subscriber = data;
commonevent.subscribe(subscriber, subscriberCallback);
console.debug("====>subscribe finish====")
});
async function sceneCreatOsAccount(){
console.debug("====>scene start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var osAccountInfo = await osAccountManager.createOsAccount("osAccountName", osaccount.OsAccountType.NORMAL);
createIocalId = osAccountInfo.localId;
function publishCallback(err){
console.debug("====>publish call back scene err:" + JSON.stringify(err));
}
var commonEventPublishData = {
code: createIocalId,
data: "SUCCESS"
}
commonevent.publish("osaccount_event_create_permission", commonEventPublishData, publishCallback);
}
sceneCreatOsAccount();
},
onReady() {
},
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "ActsOsAccountScenePermission"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册