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

!1292 VerifyPermission modify

Merge pull request !1292 from blackleon/master_xts_1206
......@@ -6,6 +6,5 @@
</div>
<div>
<input class="btn" type="button" value="permissionTest" on:click="clickAction"></input>
<input class="btn" type="button" value="changeTitle" on:click="titleAction"></input>
</div>
</div>
......@@ -23,28 +23,28 @@ div{
margin-bottom: 10px;
width: 200px;
height: 50px;
justify-content: center;
}
.log {
font-size: 20px;
text-align: center;
width: 100%;
height: 400px;
height: 250px;
}
.todo-wraper {
width: 450px;
height: 450px;
width: 100%;
height: 600px;
justify-content: center;
}
.todo-item {
width: 450px;
flex-direction: column;
width: 100%;
justify-content: center;
}
.text {
margin: 20%;
}
.menu-wraper {
width: 450px;
width: 100%;
height: 100px;
justify-content: center;
}
\ No newline at end of file
......@@ -10,17 +10,10 @@
</textarea>
</div>
<div>
<!-- <input class="btn" type="button" onclick="ShowMenu" class="text">Select Case</input>-->
<select class="menu-wraper" id="menu-wraper" onchange="CaseChange">
<option for="{{testcase}}" value="{{$item}}">abc</option>
</select>
<button type="capsule" class="btn" value="RunSelectCase" on:click="RunSelectCase"></button>
<list class="todo-wraper">
<list-item for="{{testcase}}" class="todo-item">
<input class="btn" type="button" value="{{$item}}" on:click="runCase({{$item}})"></input>
</list-item>
</list>
<button type="capsule" class="btn" value="RunTest" on:click="testAction"></button>
<input class="btn" type="button" value="Back" on:click="clickAction"></input>
</div>
</div>
......@@ -17,8 +17,7 @@ import file from '@system.file'
import app from '@system.app'
import router from '@system.router';
import featureAbility from '@ohos.ability.featureability'
import abilityManager from '@ohos.app.abilitymanager'
import bundle from '@ohos.bundle'
import { Core, ExpectExtend, ReportExtend } from 'deccjsunit/index'
export default {
......@@ -27,37 +26,34 @@ export default {
title: "AbilityA1",
logmessage: "this is log message",
testcase: [
"AppPermission_0100",
"AppPermission_0200",
"AppPermission_0300",
"AppPermission_0400",
"AppPermission_0500",
"AppPermission_0600",
"AppPermission_0700",
"AppPermission_0800",
"AppPermission_0900",
"AppPermission_1000",
"AppPermission_1100",
"AppPermission_1200",
"AppPermission_1300",
"AppPermission_1400",
"AppPermission_1500",
"AppPermission_1600",
"AppPermission_1700",
"AppPermission_1800",
"AppPermission_1900",
"AppPermission_2000",
"AppPermission_2100",
"AppPermission_2200",
"AppPermission_2300",
"AppPermission_2400",
"AppPermission_2500",
"AppPermission_2600_ResPermission",
"AppPermission_2600",
"AppPermission_2700_ResPermission",
"AppPermission_2700",
"AppPermission_2800_ResPermission",
"AppPermission_2800",
"ACTS_AppPermission_0100",
"ACTS_AppPermission_0200",
"ACTS_AppPermission_0300",
"ACTS_AppPermission_0400",
"ACTS_AppPermission_0500",
"ACTS_AppPermission_0600",
"ACTS_AppPermission_0700",
"ACTS_AppPermission_0800",
"ACTS_AppPermission_0900",
"ACTS_AppPermission_1000",
"ACTS_AppPermission_1100",
"ACTS_AppPermission_1200",
"ACTS_AppPermission_1300",
"ACTS_AppPermission_1400",
"ACTS_AppPermission_1500",
"ACTS_AppPermission_1600",
"ACTS_AppPermission_1700",
"ACTS_AppPermission_1800",
"ACTS_AppPermission_1900",
"ACTS_AppPermission_2000",
"ACTS_AppPermission_2100",
"ACTS_AppPermission_2200",
"ACTS_AppPermission_2300",
"ACTS_AppPermission_2400",
"ACTS_AppPermission_2500",
"ACTS_AppPermission_2600",
"ACTS_AppPermission_2700",
"ACTS_AppPermission_2800",
],
},
onInit() {
......@@ -81,22 +77,6 @@ export default {
uri: 'pages/index/index'
})
},
testAction() {
console.info('===========per testAction===========>')
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
const reportExtend = new ReportExtend(file)
core.addService('expect', expectExtend)
core.addService('report', reportExtend)
core.init()
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
},
runCase(caseName) {
console.debug("======per runCase======>:" + JSON.stringify(caseName))
this.logmessage += caseName + "\n"
......@@ -104,19 +84,5 @@ export default {
let { runAllCase } = require('./permissioncase.js')
runAllCase(caseName, this)
},
CaseChange(newValue) {
let { GetCaseInfo } = require('./permissioncase.js')
this.logmessage = newValue.value
this.logmessage += GetCaseInfo(newValue.value)
this.currentCase = newValue.value
},
RunSelectCase() {
let { runAllCase } = require('./permissioncase.js')
runAllCase(this.currentCase, this)
},
ShowMenu() {
this.logmessage = "show"
this.$element("menu-wraper").show({ x: 200, y: 200 })
}
}
......@@ -22,519 +22,543 @@ export function runAllCase(caseName, obj) {
console.debug("====runAllCase2====>:" + JSON.stringify(allCase))
allCase[caseName].func(obj)
}
export function GetCaseInfo(caseName) {
console.debug("====GetCaseInfo====>:" + JSON.stringify(caseName))
export function getCaseInfo(caseName) {
console.debug("====getCaseInfo====>:" + JSON.stringify(caseName))
return allCase[caseName].info;
}
var MY_PERMISSIONS_REQUEST_PERMISSION = 1;
var allCase = {
AppPermission_0100: {
func: AppPermission_0100,
info: "Verify that a system_grand system`s permission(ohos.permission.GET_NETWORK_INFO) is automatically requested during installation."
},
AppPermission_0200: {
func: AppPermission_0200,
info: "Verify that a system_grand system`s permission(ohos.permission.GET_NETWORK_INFO) is automatically requested during installation."
},
AppPermission_0300: {
func: AppPermission_0300,
info: "Verify that a user_grand system`s permission(ohos.permission.CAMERA) is not automatically requested during installation."
},
AppPermission_0400: {
func: AppPermission_0400,
info: "Verify that a user_grand system`s permission(ohos.permission.CAMERA) is not automatically requested during installation."
},
AppPermission_0500: {
func: AppPermission_0500,
info: "Verify that a system_grand user`s permission(com.amsst.permission.SYSPERMISSION) is automatically requested during installation."
},
AppPermission_0600: {
func: AppPermission_0600,
info: "Verify that a system_grand user`s permission(com.amsst.permission.SYSPERMISSION) is automatically requested during installation."
},
AppPermission_0700: {
func: AppPermission_0700,
info: "Verify that a system_grand system`s permission(ohos.permission.GET_NETWORK_INFO) is automatically requested during installation."
},
AppPermission_0800: {
func: AppPermission_0800,
info: "Verify that a system_grand system`s permission(ohos.permission.GET_NETWORK_INFO) is automatically requested during installation."
},
AppPermission_0900: {
func: AppPermission_0900,
info: "Verify that a user_grand system`s permission(ohos.permission.CAMERA) is not automatically requested during installation."
},
AppPermission_1000: {
func: AppPermission_1000,
info: "Verify that a user_grand system`s permission(ohos.permission.CAMERA) is not automatically requested during installation."
},
AppPermission_1100: {
func: AppPermission_1100,
info: "Verify that a system_grand user`s permission(com.amsst.permission.SYSPERMISSION) is automatically requested during installation."
},
AppPermission_1200: {
func: AppPermission_1200,
info: "Verify that a system_grand user`s permission(com.amsst.permission.SYSPERMISSION) is automatically requested during installation."
},
AppPermission_1300: {
func: AppPermission_1300,
info: "Verify that calling application(different application in the same device) is requested the system_grand system`s permission(ohos.permission.GET_NETWORK_INFO)"
},
AppPermission_1400: {
func: AppPermission_1400,
info: "Verify that calling application(different application in the same device) is requested the system_grand system`s permission(ohos.permission.GET_NETWORK_INFO)"
},
AppPermission_1500: {
func: AppPermission_1500,
info: "Verify that calling application(different application in the same device) is not requested the user_grand system`s permission(ohos.permission.CAMERA)"
},
AppPermission_1600: {
func: AppPermission_1600,
info: "Verify that calling application(different application in the same device) is not requested the user_grand system`s permission(ohos.permission.CAMERA)"
},
AppPermission_1700: {
func: AppPermission_1700,
info: "Verify that calling application(different application in the same device) is requested the system_grand user`s permission(com.amsst.permission.SYSPERMISSION)"
},
AppPermission_1800: {
func: AppPermission_1800,
info: "Verify that calling application(different application in the same device) is requested the system_grand user`s permission(com.amsst.permission.SYSPERMISSION)"
},
AppPermission_1900: {
func: AppPermission_1900,
info: "Verify that application without calling application(other device) is requested the system_grand system`s permission(ohos.permission.GET_NETWORK_INFO)"
},
AppPermission_2000: {
func: AppPermission_2000,
info: "Verify that application without calling application(other device) is requested the system_grand system`s permission(ohos.permission.GET_NETWORK_INFO)"
},
AppPermission_2100: {
func: AppPermission_2100,
info: "Verify that application without calling application(other device) is not requested the system_grand system`s permission(ohos.permission.GET_WIFI_INFO)"
},
AppPermission_2200: {
func: AppPermission_2200,
info: "Verify that application without calling application(other device) is not requested the system_grand system`s permission(ohos.permission.GET_WIFI_INFO)"
},
AppPermission_2300: {
func: AppPermission_2300,
info: "Verify that a system_grand system`s permission(ohos.permission.GET_NETWORK_INFO) can not requested during runtime."
},
AppPermission_2400: {
func: AppPermission_2400,
info: "Verify that a system_grand system`s permission(ohos.permission.GET_NETWORK_INFO) can not requested during runtime."
},
AppPermission_2500: {
func: AppPermission_2500,
info: "Verify that a user_grand system`s permission(ohos.permission.CAMERA) can requested during runtime."
},
AppPermission_2600_ResPermission: {
func: AppPermission_2600_ResPermission,
info: "Request Permission CAMERA."
},
AppPermission_2600: {
func: AppPermission_2600,
info: "Verify that a user_grand system`s permission(ohos.permission.PERMISSIONA) can requested during runtime."
},
AppPermission_2700_ResPermission: {
func: AppPermission_2700_ResPermission,
info: "Request Permission ohos.permission.PERMISSIONA."
},
AppPermission_2700: {
func: AppPermission_2700,
info: "Verify that a user_grand system`s permission(ohos.permission.PERMISSIONA) can requested during runtime."
},
AppPermission_2800_ResPermission: {
func: AppPermission_2800_ResPermission,
info: "Request Permission ohos.permission.PERMISSIONB, ohos.permission.PERMISSIONC."
},
AppPermission_2800: {
func: AppPermission_2800,
info: "Verify that a user_grand system`s permission(ohos.permission.PERMISSIONB, ohos.permission.PERMISSIONC) can requested during runtime."
},
}
async function GetThisProcessInfo() {
console.debug("====GetThisProcessInfo:begin====<");
var processInfoArray = await abilityManager.getAllRunningProcesses()
console.debug("====processInfoArray====>:" + JSON.stringify(processInfoArray.length) + " , " + JSON.stringify(processInfoArray))
var thisProcessInfo = processInfoArray[0]
"ACTS_AppPermission_0100": {
func: ACTS_AppPermission_0100,
info: "Verify that a system_grant system`s permission(ohos.permission.GET_NETWORK_INFO) "
+ "is automatically requested during installation."
},
"ACTS_AppPermission_0200": {
func: ACTS_AppPermission_0200,
info: "Verify that a system_grant system`s permission(ohos.permission.GET_NETWORK_INFO) "
+ "is automatically requested during installation."
},
"ACTS_AppPermission_0300": {
func: ACTS_AppPermission_0300,
info: "Verify that a user_grant system`s permission(ohos.permission.CAMERA) "
+ "is not automatically requested during installation."
},
"ACTS_AppPermission_0400": {
func: ACTS_AppPermission_0400,
info: "Verify that a user_grant system`s permission(ohos.permission.CAMERA) "
+ "is not automatically requested during installation."
},
"ACTS_AppPermission_0500": {
func: ACTS_AppPermission_0500,
info: "Verify that a system_grant user`s permission(com.amsst.permission.SYSPERMISSION) "
+ "is automatically requested during installation."
},
"ACTS_AppPermission_0600": {
func: ACTS_AppPermission_0600,
info: "Verify that a system_grant user`s permission(com.amsst.permission.SYSPERMISSION) "
+ "is automatically requested during installation."
},
"ACTS_AppPermission_0700": {
func: ACTS_AppPermission_0700,
info: "Verify that a system_grant system`s permission(ohos.permission.GET_NETWORK_INFO) "
+ "is automatically requested during installation."
},
"ACTS_AppPermission_0800": {
func: ACTS_AppPermission_0800,
info: "Verify that a system_grant system`s permission(ohos.permission.GET_NETWORK_INFO) "
+ "is automatically requested during installation."
},
"ACTS_AppPermission_0900": {
func: ACTS_AppPermission_0900,
info: "Verify that a user_grant system`s permission(ohos.permission.CAMERA) "
+ "is not automatically requested during installation."
},
"ACTS_AppPermission_1000": {
func: ACTS_AppPermission_1000,
info: "Verify that a user_grant system`s permission(ohos.permission.CAMERA) "
+ "is not automatically requested during installation."
},
"ACTS_AppPermission_1100": {
func: ACTS_AppPermission_1100,
info: "Verify that a system_grant user`s permission(com.amsst.permission.SYSPERMISSION) "
+ "is automatically requested during installation."
},
"ACTS_AppPermission_1200": {
func: ACTS_AppPermission_1200,
info: "Verify that a system_grant user`s permission(com.amsst.permission.SYSPERMISSION) "
+ "is automatically requested during installation."
},
"ACTS_AppPermission_1300": {
func: ACTS_AppPermission_1300,
info: "Verify that calling application(different application in the same device) "
+ "is requested the system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)"
},
"ACTS_AppPermission_1400": {
func: ACTS_AppPermission_1400,
info: "Verify that calling application(different application in the same device) "
+ "is requested the system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)"
},
"ACTS_AppPermission_1500": {
func: ACTS_AppPermission_1500,
info: "Verify that calling application(different application in the same device) "
+ "is not requested the user_grant system`s permission(ohos.permission.CAMERA)"
},
"ACTS_AppPermission_1600": {
func: ACTS_AppPermission_1600,
info: "Verify that calling application(different application in the same device) "
+ "is not requested the user_grant system`s permission(ohos.permission.CAMERA)"
},
"ACTS_AppPermission_1700": {
func: ACTS_AppPermission_1700,
info: "Verify that calling application(different application in the same device) "
+ "is requested the system_grant user`s permission(com.amsst.permission.SYSPERMISSION)"
},
"ACTS_AppPermission_1800": {
func: ACTS_AppPermission_1800,
info: "Verify that calling application(different application in the same device) "
+ "is requested the system_grant user`s permission(com.amsst.permission.SYSPERMISSION)"
},
"ACTS_AppPermission_1900": {
func: ACTS_AppPermission_1900,
info: "Verify that application without calling application(other device) "
+ "is requested the system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)"
},
"ACTS_AppPermission_2000": {
func: ACTS_AppPermission_2000,
info: "Verify that application without calling application(other device) "
+ "is requested the system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)"
},
"ACTS_AppPermission_2100": {
func: ACTS_AppPermission_2100,
info: "Verify that application without calling application(other device) "
+ "is not requested the system_grant system`s permission(ohos.permission.GET_WIFI_INFO)"
},
"ACTS_AppPermission_2200": {
func: ACTS_AppPermission_2200,
info: "Verify that application without calling application(other device) "
+ "is not requested the system_grant system`s permission(ohos.permission.GET_WIFI_INFO)"
},
"ACTS_AppPermission_2300": {
func: ACTS_AppPermission_2300,
info: "Verify that a system_grant system`s permission(ohos.permission.GET_NETWORK_INFO) "
+ "can not requested during runtime."
},
"ACTS_AppPermission_2400": {
func: ACTS_AppPermission_2400,
info: "Verify that a system_grant system`s permission(ohos.permission.GET_NETWORK_INFO) "
+ "can not requested during runtime."
},
"ACTS_AppPermission_2500": {
func: ACTS_AppPermission_2500,
info: "Verify that a user_grant system`s permission(ohos.permission.CAMERA) "
+ "can requested during runtime."
},
"ACTS_AppPermission_2600": {
func: ACTS_AppPermission_2600,
info: "Verify that a user_grant system`s permission(ohos.permission.CAMERA) can requested during runtime."
},
"ACTS_AppPermission_2700": {
func: ACTS_AppPermission_2700,
info: "Verify that a user_grant system`s permission(ohos.permission.PERMISSIOND) can requested during runtime."
},
"ACTS_AppPermission_2800": {
func: ACTS_AppPermission_2800,
info: "Verify that a user_grant system`s permission(2 permissions) can requested during runtime."
},
}
async function getThisProcessInfo() {
console.debug("====getThisProcessInfo:begin====<");
var processInfoArray = await abilityManager.getAllRunningProcesses();
var thisProcessInfo = processInfoArray[0];
for (let i = 0; i < processInfoArray.length; i++) {
if (processInfoArray[i].processName == "com.amsst.amsjsstmain") {
thisProcessInfo = processInfoArray[i]
break
}
}
console.debug("======GetThisProcessInfo:end======<");
console.debug("======getThisProcessInfo:end======<");
return thisProcessInfo;
}
/*
* @tc.number : AppPermission_0100
* @tc.number : ACTS_AppPermission_0100
* @tc.name : Verify that ohos.permission.GET_NETWORK_INFO is requested
* @tc.desc : Verify that a system_grand system`s permission(ohos.permission.GET_NETWORK_INFO)
* @tc.desc : Verify that a system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)
* is automatically requested during installation.
*/
async function AppPermission_0100(thisobj) {
var thisFunctionName = AppPermission_0100.name
async function ACTS_AppPermission_0100(thisobj) {
var thisFunctionName = ACTS_AppPermission_0100.name;
thisobj.logmessage = "";
thisobj.logmessage += "run test case " + thisFunctionName + "\n";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var thisProcessInfo = await GetThisProcessInfo()
var context = await featureAbility.getContext()
await context.verifyPermission("ohos.permission.GET_NETWORK_INFO", {
options: {
pid: thisProcessInfo.pid,
uid: thisProcessInfo.uid,
}
},
var thisProcessInfo = await getThisProcessInfo();
var context = await featureAbility.getContext();
await context.verifyPermission("ohos.permission.GET_NETWORK_INFO",
{
options: {
pid: thisProcessInfo.pid,
uid: thisProcessInfo.uid,
}
},
(err, data) => {
console.debug("====verifyPermission:data====>:" + JSON.stringify(data))
thisobj.logmessage += JSON.stringify(data) + "\n"
thisobj.logmessage += "result: " + JSON.stringify(data) + "\n";
if (data == 0) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n";
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n";
} else {
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
})
}
);
}
/*
* @tc.number : AppPermission_0200
* @tc.number : ACTS_AppPermission_0200
* @tc.name : Verify that ohos.permission.GET_NETWORK_INFO is requested
* @tc.desc : Verify that a system_grand system`s permission(ohos.permission.GET_NETWORK_INFO)
* @tc.desc : Verify that a system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)
* is automatically requested during installation.
*/
async function AppPermission_0200(thisobj) {
var thisFunctionName = AppPermission_0200.name
async function ACTS_AppPermission_0200(thisobj) {
var thisFunctionName = ACTS_AppPermission_0200.name;
thisobj.logmessage = "";
thisobj.logmessage += "run test case " + thisFunctionName + "\n";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var thisProcessInfo = await GetThisProcessInfo()
var context = await featureAbility.getContext()
await context.verifyPermission("ohos.permission.GET_NETWORK_INFO", {
var thisProcessInfo = await getThisProcessInfo();
var context = await featureAbility.getContext();
var result = await context.verifyPermission("ohos.permission.GET_NETWORK_INFO", {
options: {
pid: thisProcessInfo.pid,
uid: thisProcessInfo.uid,
}
},
(err, data) => {
console.debug("====verifyPermission:data====>:" + JSON.stringify(data));
console.debug("======verifyPermission:result======>:" + JSON.stringify(data));
thisobj.logmessage += JSON.stringify(data) + "\n"
if (data == 0) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n";
return -1;
}
});
});
thisobj.logmessage += "result: " + JSON.stringify(result) + "\n";
if (result == 0) {
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
} else {
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
}
/*
* @tc.number : AppPermission_0300
* @tc.number : ACTS_AppPermission_0300
* @tc.name : Verify that ohos.permission.CAMERA is not requested
* @tc.desc : Verify that a user_grand system`s permission(ohos.permission.CAMERA)
* @tc.desc : Verify that a user_grant system`s permission(ohos.permission.CAMERA)
* is not automatically requested during installation.
*/
async function AppPermission_0300(thisobj) {
var thisFunctionName = AppPermission_0300.name
async function ACTS_AppPermission_0300(thisobj) {
var thisFunctionName = ACTS_AppPermission_0300.name;
thisobj.logmessage = "";
thisobj.logmessage += "run test case " + thisFunctionName + "\n";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var thisProcessInfo = await GetThisProcessInfo()
var context = await featureAbility.getContext()
await context.verifyPermission("ohos.permission.CAMERA", {
options: {
pid: thisProcessInfo.pid,
uid: thisProcessInfo.uid,
}
},
var thisProcessInfo = await getThisProcessInfo();
var context = await featureAbility.getContext();
await context.verifyPermission("ohos.permission.CAMERA",
{
options: {
pid: thisProcessInfo.pid,
uid: thisProcessInfo.uid,
}
},
(err, data) => {
console.debug("======verifyPermission:data======>:" + JSON.stringify(data))
thisobj.logmessage += JSON.stringify(data) + "\n";
thisobj.logmessage += "result: " + JSON.stringify(data) + "\n";
if (data == -1) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n";
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n";
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
})
}
);
}
/*
* @tc.number : AppPermission_0400
* @tc.number : ACTS_AppPermission_0400
* @tc.name : Verify that ohos.permission.CAMERA is requested
* @tc.desc : Verify that a user_grand system`s permission(ohos.permission.CAMERA)
* @tc.desc : Verify that a user_grant system`s permission(ohos.permission.CAMERA)
* is automatically requested during installation.
*/
async function AppPermission_0400(thisobj) {
var thisFunctionName = AppPermission_0400.name
async function ACTS_AppPermission_0400(thisobj) {
var thisFunctionName = ACTS_AppPermission_0400.name;
thisobj.logmessage = "";
thisobj.logmessage += "run test case " + thisFunctionName + "\n";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var thisProcessInfo = await GetThisProcessInfo()
var context = await featureAbility.getContext()
var thisProcessInfo = await getThisProcessInfo();
var context = await featureAbility.getContext();
var result = await context.verifyPermission("ohos.permission.CAMERA", {
options: {
pid: thisProcessInfo.pid,
uid: thisProcessInfo.uid,
}
})
});
console.debug("======verifyPermission:result======>:" + JSON.stringify(result));
thisobj.logmessage += JSON.stringify(result) + "\n";
thisobj.logmessage += "result: " + JSON.stringify(result) + "\n";
if (result == -1) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n";
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n";
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
}
/*
* @tc.number : AppPermission_0500
* @tc.number : ACTS_AppPermission_0500
* @tc.name : Verify that com.amsst.permission.SYSPERMISSION is requested
* @tc.desc : Verify that a system_grand user`s permission(com.amsst.permission.SYSPERMISSION)
* @tc.desc : Verify that a system_grant user`s permission(com.amsst.permission.SYSPERMISSION)
* is automatically requested during installation.
*/
async function AppPermission_0500(thisobj) {
var thisFunctionName = AppPermission_0500.name
async function ACTS_AppPermission_0500(thisobj) {
var thisFunctionName = ACTS_AppPermission_0500.name;
thisobj.logmessage = "";
thisobj.logmessage += "run test case " + thisFunctionName + "\n";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var thisProcessInfo = await GetThisProcessInfo()
var context = await featureAbility.getContext()
await context.verifyPermission("com.amsst.permission.SYSPERMISSION", {
options: {
pid: thisProcessInfo.pid,
uid: thisProcessInfo.uid,
}
},
var thisProcessInfo = await getThisProcessInfo();
var context = await featureAbility.getContext();
await context.verifyPermission("com.amsst.permission.SYSPERMISSION",
{
options: {
pid: thisProcessInfo.pid,
uid: thisProcessInfo.uid,
}
},
(err, data) => {
console.debug("======verifyPermission:data======>:" + JSON.stringify(data));
thisobj.logmessage += JSON.stringify(data) + "\n";
thisobj.logmessage += "result: " + JSON.stringify(data) + "\n";
if (data == 0) {
;
thisobj.logmessage += "case " + thisFunctionName + " successed\n";
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n";
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
})
}
/*
* @tc.number : AppPermission_0600
* @tc.number : ACTS_AppPermission_0600
* @tc.name : Verify that com.amsst.permission.SYSPERMISSION is requested
* @tc.desc : Verify that a system_grand user`s permission(com.amsst.permission.SYSPERMISSION)
* @tc.desc : Verify that a system_grant user`s permission(com.amsst.permission.SYSPERMISSION)
* is automatically requested during installation.
*/
async function AppPermission_0600(thisobj) {
var thisFunctionName = AppPermission_0600.name
async function ACTS_AppPermission_0600(thisobj) {
var thisFunctionName = ACTS_AppPermission_0600.name;
thisobj.logmessage = "";
thisobj.logmessage += "run test case " + thisFunctionName + "\n";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var thisProcessInfo = await GetThisProcessInfo()
var thisProcessInfo = await getThisProcessInfo();
var context = await featureAbility.getContext();
var result = await context.verifyPermission("com.amsst.permission.SYSPERMISSION", {
options: {
pid: thisProcessInfo.pid,
uid: thisProcessInfo.uid,
}
})
});
console.debug("======verifyPermission:result======>:" + JSON.stringify(result));
thisobj.logmessage += JSON.stringify(result) + "\n";
thisobj.logmessage += "result: " + JSON.stringify(result) + "\n";
if (result == 0) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n";
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n";
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
}
/*
* @tc.number : AppPermission_0700
* @tc.number : ACTS_AppPermission_0700
* @tc.name : Verify that ohos.permission.GET_NETWORK_INFO is requested
* @tc.desc : Verify that a system_grand system`s permission(ohos.permission.GET_NETWORK_INFO)
* @tc.desc : Verify that a system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)
* is automatically requested during installation.
*/
async function AppPermission_0700(thisobj) {
var thisFunctionName = AppPermission_0700.name
async function ACTS_AppPermission_0700(thisobj) {
var thisFunctionName = ACTS_AppPermission_0700.name;
thisobj.logmessage = "";
thisobj.logmessage += "run test case " + thisFunctionName + "\n";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext()
var context = await featureAbility.getContext();
await context.verifySelfPermission("ohos.permission.GET_NETWORK_INFO",
(err, data) => {
console.debug("======verifySelfPermission:data======>:" + JSON.stringify(data));
thisobj.logmessage += JSON.stringify(data) + "\n";
thisobj.logmessage += "result: " + JSON.stringify(data) + "\n";
if (data == 0) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n";
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n";
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
})
}
/*
* @tc.number : AppPermission_0800
* @tc.number : ACTS_AppPermission_0800
* @tc.name : Verify that ohos.permission.GET_NETWORK_INFO is requested by self
* @tc.desc : Verify that a system_grand system`s permission(ohos.permission.GET_NETWORK_INFO)
* @tc.desc : Verify that a system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)
* is automatically requested during installation.
*/
async function AppPermission_0800(thisobj) {
var thisFunctionName = AppPermission_0800.name
async function ACTS_AppPermission_0800(thisobj) {
var thisFunctionName = ACTS_AppPermission_0800.name;
thisobj.logmessage = "";
thisobj.logmessage += "run test case " + thisFunctionName + "\n";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext()
var result = await context.verifySelfPermission("ohos.permission.GET_NETWORK_INFO")
var context = await featureAbility.getContext();
var result = await context.verifySelfPermission("ohos.permission.GET_NETWORK_INFO");
console.debug("======verifySelfPermission:result======>:" + JSON.stringify(result));
thisobj.logmessage += JSON.stringify(result) + "\n";
thisobj.logmessage += "result: " + JSON.stringify(result) + "\n";
if (result == 0) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n";
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n";
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
}
/*
* @tc.number : AppPermission_0900
* @tc.number : ACTS_AppPermission_0900
* @tc.name : Verify that ohos.permission.CAMERA is not requested by self
* @tc.desc : Verify that a user_grand system`s permission(ohos.permission.CAMERA)
* @tc.desc : Verify that a user_grant system`s permission(ohos.permission.CAMERA)
* is not automatically requested during installation.
*/
async function AppPermission_0900(thisobj) {
var thisFunctionName = AppPermission_0900.name
async function ACTS_AppPermission_0900(thisobj) {
var thisFunctionName = ACTS_AppPermission_0900.name;
thisobj.logmessage = "";
thisobj.logmessage += "run test case " + thisFunctionName + "\n";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext()
var context = await featureAbility.getContext();
await context.verifySelfPermission("ohos.permission.CAMERA",
(err, data) => {
console.debug("======verifySelfPermission:data======>:" + JSON.stringify(data));
thisobj.logmessage += JSON.stringify(data) + "\n";
thisobj.logmessage += "result: " + JSON.stringify(data) + "\n";
if (data == -1) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n";
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n";
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
})
}
/*
* @tc.number : AppPermission_1000
* @tc.number : ACTS_AppPermission_1000
* @tc.name : Verify that ohos.permission.CAMERA is requested by self
* @tc.desc : Verify that a user_grand system`s permission(ohos.permission.CAMERA)
* @tc.desc : Verify that a user_grant system`s permission(ohos.permission.CAMERA)
* is automatically requested during installation.
*/
async function AppPermission_1000(thisobj) {
var thisFunctionName = AppPermission_1000.name
async function ACTS_AppPermission_1000(thisobj) {
var thisFunctionName = ACTS_AppPermission_1000.name;
thisobj.logmessage = "";
thisobj.logmessage += "run test case " + thisFunctionName + "\n";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext()
var context = await featureAbility.getContext();
var result = await context.verifySelfPermission("ohos.permission.CAMERA")
console.debug("======verifySelfPermission:result======>:" + JSON.stringify(result));
thisobj.logmessage += JSON.stringify(result) + "\n";
thisobj.logmessage += "result: " + JSON.stringify(result) + "\n";
if (result == -1) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n";
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n";
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
}
/*
* @tc.number : AppPermission_1100
* @tc.number : ACTS_AppPermission_1100
* @tc.name : Verify that com.amsst.permission.SYSPERMISSION is requested by self
* @tc.desc : Verify that a system_grand user`s permission(com.amsst.permission.SYSPERMISSION)
* @tc.desc : Verify that a system_grant user`s permission(com.amsst.permission.SYSPERMISSION)
* is automatically requested during installation.
*/
async function AppPermission_1100(thisobj) {
var thisFunctionName = AppPermission_1100.name
async function ACTS_AppPermission_1100(thisobj) {
var thisFunctionName = ACTS_AppPermission_1100.name;
thisobj.logmessage = "";
thisobj.logmessage += "run test case " + thisFunctionName + "\n";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext()
var context = await featureAbility.getContext();
await context.verifySelfPermission("com.amsst.permission.SYSPERMISSION",
(err, data) => {
console.debug("======verifySelfPermission:data======>:" + JSON.stringify(data));
thisobj.logmessage += JSON.stringify(data) + "\n";
thisobj.logmessage += "result: " + JSON.stringify(data) + "\n";
if (data == 0) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n";
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n";
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
})
}
/*
* @tc.number : AppPermission_1200
* @tc.number : ACTS_AppPermission_1200
* @tc.name : Verify that com.amsst.permission.SYSPERMISSION is requested by self
* @tc.desc : Verify that a system_grand user`s permission(com.amsst.permission.SYSPERMISSION)
* @tc.desc : Verify that a system_grant user`s permission(com.amsst.permission.SYSPERMISSION)
* is automatically requested during installation.
*/
async function AppPermission_1200(thisobj) {
var thisFunctionName = AppPermission_1200.name
async function ACTS_AppPermission_1200(thisobj) {
var thisFunctionName = ACTS_AppPermission_1200.name;
thisobj.logmessage = "";
thisobj.logmessage += "run test case " + thisFunctionName + "\n";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext()
var result = await context.verifySelfPermission("com.amsst.permission.SYSPERMISSION")
var context = await featureAbility.getContext();
var result = await context.verifySelfPermission("com.amsst.permission.SYSPERMISSION");
console.debug("======verifySelfPermission:result======>:" + JSON.stringify(result));
thisobj.logmessage += JSON.stringify(result) + "\n";
thisobj.logmessage += "result: " + JSON.stringify(result) + "\n";
if (result == 0) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n";
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n"
thisobj.logmessage += "case " + thisFunctionName + " failure\n"
return -1;;
}
}
/*
* @tc.number : AppPermission_1300
* @tc.name : Verify that calling application(different application in the same device) have requested ohos.permission.GET_NETWORK_INFO
* @tc.number : ACTS_AppPermission_1300
* @tc.name : Verify that calling application(different application in the same device)
* have requested ohos.permission.GET_NETWORK_INFO
* @tc.desc : Verify that calling application(different application in the same device) is requested
* the system_grand system`s permission(ohos.permission.GET_NETWORK_INFO)
* the system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)
*/
async function AppPermission_1300(thisobj) {
var thisFunctionName = AppPermission_1300.name
async function ACTS_AppPermission_1300(thisobj) {
var thisFunctionName = ACTS_AppPermission_1300.name;
thisobj.logmessage = "";
thisobj.logmessage += "run test case " + thisFunctionName + "\n";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
featureAbility.startAbility(
{
......@@ -549,15 +573,17 @@ async function AppPermission_1300(thisobj) {
}
/*
* @tc.number : AppPermission_1400
* @tc.name : Verify that calling application(different application in the same device) have requested ohos.permission.GET_NETWORK_INFO
* @tc.number : ACTS_AppPermission_1400
* @tc.name : Verify that calling application(different application in the same device)
* have requested ohos.permission.GET_NETWORK_INFO
* @tc.desc : Verify that calling application(different application in the same device) is requested
* the system_grand system`s permission(ohos.permission.GET_NETWORK_INFO)
* the system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)
*/
async function AppPermission_1400(thisobj) {
var thisFunctionName = AppPermission_1400.name
async function ACTS_AppPermission_1400(thisobj) {
var thisFunctionName = ACTS_AppPermission_1400.name;
thisobj.logmessage = "";
thisobj.logmessage += "run test case " + thisFunctionName + "\n";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
featureAbility.startAbility(
{
......@@ -572,15 +598,17 @@ async function AppPermission_1400(thisobj) {
}
/*
* @tc.number : AppPermission_1500
* @tc.name : Verify that calling application(different application in the same device) have not requested ohos.permission.CAMERA
* @tc.number : ACTS_AppPermission_1500
* @tc.name : Verify that calling application(different application in the same device)
* have not requested ohos.permission.CAMERA
* @tc.desc : Verify that calling application(different application in the same device)
* is not requested the user_grand system`s permission(ohos.permission.CAMERA)
* is not requested the user_grant system`s permission(ohos.permission.CAMERA)
*/
async function AppPermission_1500(thisobj) {
var thisFunctionName = AppPermission_1500.name
async function ACTS_AppPermission_1500(thisobj) {
var thisFunctionName = ACTS_AppPermission_1500.name;
thisobj.logmessage = "";
thisobj.logmessage += "run test case " + thisFunctionName + "\n";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
featureAbility.startAbility(
{
......@@ -595,15 +623,17 @@ async function AppPermission_1500(thisobj) {
}
/*
* @tc.number : AppPermission_1600
* @tc.name : Verify that calling application(different application in the same device) have not requested ohos.permission.CAMERA
* @tc.number : ACTS_AppPermission_1600
* @tc.name : Verify that calling application(different application in the same device)
* have not requested ohos.permission.CAMERA
* @tc.desc : Verify that calling application(different application in the same device)
* is not requested the user_grand system`s permission(ohos.permission.CAMERA)
* is not requested the user_grant system`s permission(ohos.permission.CAMERA)
*/
async function AppPermission_1600(thisobj) {
var thisFunctionName = AppPermission_1600.name
async function ACTS_AppPermission_1600(thisobj) {
var thisFunctionName = ACTS_AppPermission_1600.name;
thisobj.logmessage = "";
thisobj.logmessage += "run test case " + thisFunctionName + "\n";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
featureAbility.startAbility(
{
......@@ -613,23 +643,23 @@ async function AppPermission_1600(thisobj) {
abilityName: "com.amsst.amsjsstsubpermission.MainAbility"
}
}
)
);
return 0;
}
/*
* @tc.number : AppPermission_1700
* @tc.name : Verify that calling application(different application in the same device) have requested com.amsst.permission.SYSPERMISSION
* @tc.number : ACTS_AppPermission_1700
* @tc.name : Verify that calling application(different application in the same device)
* have requested com.amsst.permission.SYSPERMISSION
* @tc.desc : Verify that calling application(different application in the same device)
* is requested the system_grand user`s permission(com.amsst.permission.SYSPERMISSION)
* is requested the system_grant user`s permission(com.amsst.permission.SYSPERMISSION)
*/
async function AppPermission_1700(thisobj) {
var thisFunctionName = AppPermission_1700.name
async function ACTS_AppPermission_1700(thisobj) {
var thisFunctionName = ACTS_AppPermission_1700.name;
thisobj.logmessage = "";
thisobj.logmessage += "run test case " + thisFunctionName + "\n";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext()
var result = await context.verifySelfPermission("com.amsst.permission.SYSPERMISSION")
await featureAbility.startAbility(
{
want:
......@@ -638,22 +668,23 @@ async function AppPermission_1700(thisobj) {
abilityName: "com.amsst.amsjsstsubpermission.MainAbility"
}
}
)
);
return 0;
}
/*
* @tc.number : AppPermission_1800
* @tc.name : Verify that calling application(different application in the same device) have requested com.amsst.permission.SYSPERMISSION
* @tc.number : ACTS_AppPermission_1800
* @tc.name : Verify that calling application(different application in the same device)
* have requested com.amsst.permission.SYSPERMISSION
* @tc.desc : Verify that calling application(different application in the same device)
* is requested the system_grand user`s permission(com.amsst.permission.SYSPERMISSION)
* is requested the system_grant user`s permission(com.amsst.permission.SYSPERMISSION)
*/
async function AppPermission_1800(thisobj) {
var thisFunctionName = AppPermission_1800.name
async function ACTS_AppPermission_1800(thisobj) {
var thisFunctionName = ACTS_AppPermission_1800.name;
thisobj.logmessage = "";
thisobj.logmessage += "run test case " + thisFunctionName + "\n";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext()
await featureAbility.startAbility(
{
want:
......@@ -667,386 +698,303 @@ async function AppPermission_1800(thisobj) {
}
/*
* @tc.number : AppPermission_1900
* @tc.name : Verify that application without calling application(other device) have requested ohos.permission.GET_NETWORK_INFO
* @tc.number : ACTS_AppPermission_1900
* @tc.name : Verify that application without calling application(other device)
* have requested ohos.permission.GET_NETWORK_INFO
* @tc.desc : Verify that application without calling application(other device)
* is requested the system_grand system`s permission(ohos.permission.GET_NETWORK_INFO)
* is requested the system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)
*/
async function AppPermission_1900(thisobj) {
var thisFunctionName = AppPermission_1900.name
async function ACTS_AppPermission_1900(thisobj) {
var thisFunctionName = ACTS_AppPermission_1900.name;
thisobj.logmessage = "";
thisobj.logmessage += "run test case " + thisFunctionName + "\n";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var thisProcessInfo = await GetThisProcessInfo()
var context = await featureAbility.getContext()
var context = await featureAbility.getContext();
await context.verifyCallingOrSelfPermission("ohos.permission.GET_NETWORK_INFO",
(err, data) => {
console.debug("======verifyCallingOrSelfPermission:data======>:" + JSON.stringify(data));
thisobj.logmessage += JSON.stringify(data) + "\n";
thisobj.logmessage += "result: " + JSON.stringify(data) + "\n";
if (data == 0) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n";
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n";
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
})
}
/*
* @tc.number : AppPermission_2000
* @tc.name : Verify that application without calling application(other device) have requested ohos.permission.GET_NETWORK_INFO
* @tc.number : ACTS_AppPermission_2000
* @tc.name : Verify that application without calling application(other device)
* have requested ohos.permission.GET_NETWORK_INFO
* @tc.desc : Verify that application without calling application(other device)
* is requested the system_grand system`s permission(ohos.permission.GET_NETWORK_INFO)
* is requested the system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)
*/
async function AppPermission_2000(thisobj) {
var thisFunctionName = AppPermission_2000.name
async function ACTS_AppPermission_2000(thisobj) {
var thisFunctionName = ACTS_AppPermission_2000.name;
thisobj.logmessage = "";
thisobj.logmessage += "run test case " + thisFunctionName + "\n";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var thisProcessInfo = await GetThisProcessInfo()
var context = await featureAbility.getContext()
var result = await context.verifyCallingOrSelfPermission("ohos.permission.GET_NETWORK_INFO")
var thisProcessInfo = await getThisProcessInfo();
var context = await featureAbility.getContext();
var result = await context.verifyCallingOrSelfPermission("ohos.permission.GET_NETWORK_INFO");
console.debug("======verifyCallingOrSelfPermission:result======>:" + JSON.stringify(result));
thisobj.logmessage += JSON.stringify(result) + "\n";
thisobj.logmessage += "result: " + JSON.stringify(result) + "\n";
if (result == 0) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n";
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n";
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
}
/*
* @tc.number : AppPermission_2100
* @tc.name : Verify that application without calling application(other device) have not requested .GET_WIFI_INFO
* @tc.number : ACTS_AppPermission_2100
* @tc.name : Verify that application without calling application(other device)
* have not requested .GET_WIFI_INFO
* @tc.desc : Verify that application without calling application(other device)
* is requested the system_grand system`s permission(ohos.permission..GET_WIFI_INFO)
* is requested the system_grant system`s permission(ohos.permission..GET_WIFI_INFO)
*/
async function AppPermission_2100(thisobj) {
var thisFunctionName = AppPermission_2100.name
async function ACTS_AppPermission_2100(thisobj) {
var thisFunctionName = ACTS_AppPermission_2100.name;
thisobj.logmessage = "";
thisobj.logmessage += "run test case " + thisFunctionName + "\n";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var thisProcessInfo = await GetThisProcessInfo()
var context = await featureAbility.getContext()
var thisProcessInfo = await getThisProcessInfo();
var context = await featureAbility.getContext();
await context.verifyCallingOrSelfPermission("ohos.permission.GET_WIFI_INFO",
(err, data) => {
console.debug("======verifyCallingOrSelfPermission:data======>:" + JSON.stringify(data));
thisobj.logmessage += JSON.stringify(data) + "\n";
thisobj.logmessage += "result: " + JSON.stringify(data) + "\n";
if (data == -1) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n";
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n";
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
})
}
/*
* @tc.number : AppPermission_2200
* @tc.number : ACTS_AppPermission_2200
* @tc.name : Verify that application without calling application(other device) have not requested .GET_WIFI_INFO
* @tc.desc : Verify that application without calling application(other device)
* is requested the system_grand system`s permission(ohos.permission..GET_WIFI_INFO)
* is requested the system_grant system`s permission(ohos.permission..GET_WIFI_INFO)
*/
async function AppPermission_2200(thisobj) {
var thisFunctionName = AppPermission_2200.name
async function ACTS_AppPermission_2200(thisobj) {
var thisFunctionName = ACTS_AppPermission_2200.name;
thisobj.logmessage = "";
thisobj.logmessage += "run test case " + thisFunctionName + "\n";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var thisProcessInfo = await GetThisProcessInfo()
var context = await featureAbility.getContext()
var thisProcessInfo = await getThisProcessInfo();
var context = await featureAbility.getContext();
var result = await context.verifyCallingOrSelfPermission("ohos.permission.GET_WIFI_INFO")
console.debug("======verifyCallingOrSelfPermission:result======>:" + JSON.stringify(result));
thisobj.logmessage += JSON.stringify(result) + "\n";
thisobj.logmessage += "result: " + JSON.stringify(result) + "\n";
if (result == -1) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n";
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n";
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
}
/*
* @tc.number : AppPermission_2300
* @tc.number : ACTS_AppPermission_2300
* @tc.name : Verify that ohos.permission.GET_NETWORK_INFO can not requested by user
* @tc.desc : Verify that a system_grand system`s permission(ohos.permission.GET_NETWORK_INFO)
* @tc.desc : Verify that a system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)
* can not requested during runtime.
*/
async function AppPermission_2300(thisobj) {
var thisFunctionName = AppPermission_2300.name
async function ACTS_AppPermission_2300(thisobj) {
var thisFunctionName = ACTS_AppPermission_2300.name;
thisobj.logmessage = "";
thisobj.logmessage += "run test case " + thisFunctionName + "\n";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext()
var context = await featureAbility.getContext();
await context.canRequestPermission("ohos.permission.GET_NETWORK_INFO",
(err, data) => {
console.debug("======canRequestPermission:data======>:" + JSON.stringify(data));
thisobj.logmessage += JSON.stringify(data) + "\n"
thisobj.logmessage += "result: " + JSON.stringify(data) + "\n"
if (data == false) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n";
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n";
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
})
}
/*
* @tc.number : AppPermission_2400
* @tc.number : ACTS_AppPermission_2400
* @tc.name : Verify that ohos.permission.GET_NETWORK_INFO can not requested by user
* @tc.desc : Verify that a system_grand system`s permission(ohos.permission.GET_NETWORK_INFO)
* @tc.desc : Verify that a system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)
* can not requested during runtime.
*/
async function AppPermission_2400(thisobj) {
var thisFunctionName = AppPermission_2400.name
async function ACTS_AppPermission_2400(thisobj) {
var thisFunctionName = ACTS_AppPermission_2400.name;
thisobj.logmessage = "";
thisobj.logmessage += "run test case " + thisFunctionName + "\n";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext()
var result = await context.canRequestPermission("ohos.permission.GET_NETWORK_INFO")
var context = await featureAbility.getContext();
var result = await context.canRequestPermission("ohos.permission.GET_NETWORK_INFO");
console.debug("======canRequestPermission:result======>:" + JSON.stringify(result));
thisobj.logmessage += JSON.stringify(result) + "\n"
thisobj.logmessage += "result: " + JSON.stringify(result) + "\n"
if (result == false) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n";
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n";
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
}
/*
* @tc.number : AppPermission_2500
* @tc.number : ACTS_AppPermission_2500
* @tc.name : Verify that ohos.permission.CAMERA can requested by user
* @tc.desc : Verify that a user_grand system`s permission(ohos.permission.CAMERA)
* @tc.desc : Verify that a user_grant system`s permission(ohos.permission.CAMERA)
* can requested during runtime.
*/
async function AppPermission_2500(thisobj) {
var thisFunctionName = AppPermission_2500.name
async function ACTS_AppPermission_2500(thisobj) {
var thisFunctionName = ACTS_AppPermission_2500.name;
thisobj.logmessage = "";
thisobj.logmessage += "run test case " + thisFunctionName + "\n";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext()
var context = await featureAbility.getContext();
await context.canRequestPermission("ohos.permission.CAMERA",
(err, data) => {
console.debug("======canRequestPermission:data======>:" + JSON.stringify(data));;
thisobj.logmessage += JSON.stringify(data) + "\n";
thisobj.logmessage += "result: " + JSON.stringify(data) + "\n";
if (data == true) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n";
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n";
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
})
}
async function AppPermission_2600_ResPermission(thisobj) {
var thisFunctionName = AppPermission_2600_ResPermission.name
/*
* @tc.number : ACTS_AppPermission_2600
* @tc.name : Verify that ohos.permission.CAMERA can requested by user
* @tc.desc : Verify that a user_grant system`s permission(ohos.permission.CAMERA)
* can requested during runtime.
*/
async function ACTS_AppPermission_2600(thisobj) {
var thisFunctionName = ACTS_AppPermission_2600.name;
thisobj.logmessage = "";
thisobj.logmessage += "run test case " + thisFunctionName + "\n";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext()
var result = await context.canRequestPermission("ohos.permission.PERMISSIOND")
console.debug("======canRequestPermission:result======>:" + JSON.stringify(result));
thisobj.logmessage += JSON.stringify(result) + "\n";
var context = await featureAbility.getContext();
var result = await context.canRequestPermission("ohos.permission.CAMERA");
thisobj.logmessage += "result: " + JSON.stringify(result) + "\n"
if (result == true) {
await context.requestPermissionsFromUser(["ohos.permission.PERMISSIOND"], 1,
(err, data) => {
console.log("RequestPermissionForUser:requestCode=" + data.requestCode);
for (var j = 0; j < data.permissions.length; j++) {
console.log("RequestPermissionForUser permissions : " + data.permissions[j]);
}
for (var j = 0; j < data.grantResults.length; j++) {
console.log("RequestPermissionForUser grantResults : " + data.grantResults[j]);
}
});
thisobj.logmessage += "case " + thisFunctionName + " successed\n";
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n";
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
}
/*
* @tc.number : AppPermission_2600
* @tc.name : Verify that ohos.permission.CAMERA can requested by user
* @tc.desc : Verify that a user_grand system`s permission(ohos.permission.CAMERA)
* @tc.number : ACTS_AppPermission_2700
* @tc.name : Verify that ohos.permission.PERMISSIOND can requested by user
* @tc.desc : Verify that a user_grant system`s permission(ohos.permission.PERMISSIOND)
* can requested during runtime.
*/
async function AppPermission_2600(thisobj) {
var thisFunctionName = AppPermission_2600.name
thisobj.logmessage = "";
thisobj.logmessage += "run test case " + thisFunctionName + "\n";
var context = await featureAbility.getContext()
await context.verifyPermission("ohos.permission.PERMISSIOND",
(err, data) => {
console.debug("====verifyPermission:data====>:" + JSON.stringify(data));
thisobj.logmessage += JSON.stringify(data) + "\n"
if (data == 0) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n";
return -1;
}
})
}
async function AppPermission_2700_ResPermission(thisobj) {
var thisFunctionName = AppPermission_2700_ResPermission.name
async function ACTS_AppPermission_2700(thisobj) {
var thisFunctionName = ACTS_AppPermission_2700.name
thisobj.logmessage = "";
thisobj.logmessage += "run test case " + thisFunctionName + "\n";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext()
var result = await context.canRequestPermission("ohos.permission.PERMISSIONA")
console.debug("======canRequestPermission:result======>:" + JSON.stringify(result));
thisobj.logmessage += JSON.stringify(result) + "\n"
var result = await context.canRequestPermission("ohos.permission.PERMISSIOND")
thisobj.logmessage += "result: " + JSON.stringify(result) + "\n";
if (result == true) {
await context.requestPermissionsFromUser(["ohos.permission.PERMISSIONA"], 1,
await context.requestPermissionsFromUser(["ohos.permission.PERMISSIOND"],
MY_PERMISSIONS_REQUEST_PERMISSION,
(err, data) => {
console.log("RequestPermissionForUser:requestCode=" + data.requestCode);
for (var j = 0; j < data.permissions.length; j++) {
console.log("RequestPermissionForUser permissions : " + data.permissions[j]);
}
for (var j = 0; j < data.grantResults.length; j++) {
console.log("RequestPermissionForUser grantResults : " + data.grantResults[j]);
thisobj.logmessage += "data = " + JSON.stringify(data) + "\n";
thisobj.logmessage += "err = " + JSON.stringify(err) + "\n";
if (data.requestCode == MY_PERMISSIONS_REQUEST_PERMISSION
&& data.authResults.length > 0
&& data.permissions.length > 0
&& data.permissions[0] == "ohos.permission.PERMISSIOND"
&& data.authResults[0] == 0) {
thisobj.logmessage += "case " + thisFunctionName + " success\n";
} else {
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
}
});
thisobj.logmessage += "case " + thisFunctionName + " successed\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n";
} else {
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
}
/*
* @tc.number : AppPermission_2700
* @tc.name : Verify that ohos.permission.PERMISSIONA can requested by user
* @tc.desc : Verify that a user_grand system`s permission(ohos.permission.CAMERA)
* can requested during runtime.
* @tc.number : ACTS_AppPermission_2800
* @tc.name : Verify that ohos.permission.PERMISSIONB, ohos.permission.PERMISSIONC, can requested by user
* @tc.desc : Verify that a user_grant system`s permission
* (ohos.permission.PERMISSIONB, ohos.permission.PERMISSIONC) can requested during runtime.
*/
async function AppPermission_2700(thisobj) {
var thisFunctionName = AppPermission_2700.name
async function ACTS_AppPermission_2800(thisobj) {
var thisFunctionName = ACTS_AppPermission_2800.name
thisobj.logmessage = "";
thisobj.logmessage += "run test case " + thisFunctionName + "\n";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext()
var thisProcessInfo = await GetThisProcessInfo()
var context = await featureAbility.getContext()
var data = await context.verifyPermission("ohos.permission.PERMISSIONA", {
options: {
pid: thisProcessInfo.pid,
uid: thisProcessInfo.uid,
}
});
if (data == 0) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n";
return -1;
}
}
async function AppPermission_2800_ResPermission(thisobj) {
var thisFunctionName = AppPermission_2800_ResPermission.name
thisobj.logmessage = "";
thisobj.logmessage += "run test case " + thisFunctionName + "\n";
var context = await featureAbility.getContext()
var result1 = await context.canRequestPermission("ohos.permission.PERMISSIONB")
var result2 = await context.canRequestPermission("ohos.permission.PERMISSIONC")
console.debug("======canRequestPermission:result1======>:" + JSON.stringify(result1));
console.debug("======canRequestPermission:result2======>:" + JSON.stringify(result2));
var context = await featureAbility.getContext();
var result1 = await context.canRequestPermission("ohos.permission.PERMISSIONB");
var result2 = await context.canRequestPermission("ohos.permission.PERMISSIONC");
thisobj.logmessage += JSON.stringify(result1) + "\n";
thisobj.logmessage += JSON.stringify(result2) + "\n";
if (result1 && result2) {
await context.requestPermissionsFromUser(["ohos.permission.PERMISSIONB", "ohos.permission.PERMISSIONC"], 1,
await context.requestPermissionsFromUser(["ohos.permission.PERMISSIONB", "ohos.permission.PERMISSIONC"],
MY_PERMISSIONS_REQUEST_PERMISSION,
(err, data) => {
console.log("RequestPermissionForUser:requestCode=" + data.requestCode);
for (var j = 0; j < data.permissions.length; j++) {
console.log("RequestPermissionForUser permissions : " + data.permissions[j]);
}
for (var j = 0; j < data.grantResults.length; j++) {
console.log("RequestPermissionForUser grantResults : " + data.grantResults[j]);
thisobj.logmessage += "data = " + JSON.stringify(data) + "\n";
thisobj.logmessage += "err = " + JSON.stringify(err) + "\n";
if (data.requestCode == MY_PERMISSIONS_REQUEST_PERMISSION
&& data.authResults.length == 2
&& data.permissions.length == 2
&& data.permissions[0] == "ohos.permission.PERMISSIONB"
&& data.authResults[0] == 0
&& data.permissions[1] == "ohos.permission.PERMISSIONC"
&& data.authResults[1] == 0) {
thisobj.logmessage += "case " + thisFunctionName + " success\n";
} else {
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
}
});
thisobj.logmessage += "case " + thisFunctionName + " successed\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n";
} else {
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
}
/*
* @tc.number : AppPermission_2800
* @tc.name : Verify that ohos.permission.PERMISSIONB, ohos.permission.PERMISSIONB, can requested by user
* @tc.desc : Verify that a user_grand system`s permission(ohos.permission.CAMERA)
* can requested during runtime.
*/
async function AppPermission_2800(thisobj) {
var thisFunctionName = AppPermission_2800.name
thisobj.logmessage = "";
thisobj.logmessage += "run test case " + thisFunctionName + "\n";
var thisProcessInfo = await GetThisProcessInfo()
var context = await featureAbility.getContext()
await context.verifyPermission("ohos.permission.PERMISSIONB", {
options: {
pid: thisProcessInfo.pid,
uid: thisProcessInfo.uid,
}
},
(err, data) => {
console.debug("====verifyPermission:data====>:" + JSON.stringify(data));
thisobj.logmessage += JSON.stringify(data) + "\n";
if (data == 0) {
context.verifyPermission("ohos.permission.PERMISSIONC", {
options: {
pid: thisProcessInfo.pid,
uid: thisProcessInfo.uid,
}
},
(err, data) => {
if (data == 0) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n";
return -1;
}
})
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n";
return -1;
}
})
}
\ 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 bundle from '@ohos.bundle'
import featureAbility from '@ohos.ability.featureability'
import abilityManager from '@ohos.app.abilitymanager'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe ('AmsSystemTest_AppPermission', function () {
it('AppPermission_0100', 0, async function (done) {
console.info('=====================AppPermission_0100==================<');
var dataInfo = await bundle.getBundleInfo('com.amsst.amsjsstmain',1);
console.debug("======dataInfo======>:" + JSON.stringify(dataInfo));
var processInfoArray = await abilityManager.getAllRunningProcesses();
console.debug("======processInfoArray======>:" + JSON.stringify(processInfoArray));
var thisProcessInfo = processInfoArray[0];
for(let i=0; i<processInfoArray.length;i++) {
if(processInfoArray[i].processName == "com.amsst.amsjsstmain") {
thisProcessInfo = processInfoArray[i]
break
}
}
console.debug("======thisProcessInfo======>:" + JSON.stringify(thisProcessInfo));
var context = await featureAbility.getContext();
await context.verifyPermission("ohos.permission.GET_NETWORK_INFO", thisProcessInfo.pid, thisProcessInfo.uid,
(err, data) => {
console.debug("======verifyPermission:data======>:" + JSON.stringify(data));
expect(err.code).assertEqual(0)
expect(data).assertEqual(0)
done()
})
done()
})
it('AppPermission_0200', 0, async function (done) {
console.info('=====================AppPermission_0200==================<');
var processInfoArray = await abilityManager.getAllRunningProcesses();
console.debug("======processInfoArray======>:" + JSON.stringify(processInfoArray));
var thisProcessInfo = processInfoArray[0];
for(let i=0; i<processInfoArray.length;i++) {
if(processInfoArray[i].processName == "com.amsst.amsjsstmain") {
thisProcessInfo = processInfoArray[i]
break
}
}
console.debug("======thisProcessInfo======>:" + JSON.stringify(thisProcessInfo));
var context = await featureAbility.getContext();
var result = await context.verifyPermission("ohos.permission.GET_NETWORK_INFO", thisProcessInfo.pid, thisProcessInfo.uid)
console.debug("======result======>:" + JSON.stringify(result));
expect(result).assertEqual(0);
done()
})
it('AppPermission_0300', 0, async function (done) {
console.info('=====================AppPermission_0300==================<');
var processInfoArray = await abilityManager.getAllRunningProcesses();
console.debug("======processInfoArray======>:" + JSON.stringify(processInfoArray));
var thisProcessInfo = processInfoArray[0];
for(let i=0; i<processInfoArray.length;i++) {
if(processInfoArray[i].processName == "com.amsst.amsjsstmain") {
thisProcessInfo = processInfoArray[i]
break
}
}
console.debug("======thisProcessInfo======>:" + JSON.stringify(thisProcessInfo));
var context = await featureAbility.getContext();
await context.verifyPermission("ohos.permission.GET_NETWORK_INFO", thisProcessInfo.pid, thisProcessInfo.uid,
(err, data) => {
expect(err.code).assertEqual(0)
expect(data).assertEqual(0)
done()
})
done()
})
it('AppPermission_0400', 0, async function (done) {
console.info('=====================AppPermission_0400==================<');
var processInfoArray = await abilityManager.getAllRunningProcesses();
console.debug("======processInfoArray======>:" + JSON.stringify(processInfoArray));
var thisProcessInfo = processInfoArray[0];
for(let i=0; i<processInfoArray.length;i++) {
if(processInfoArray[i].processName == "com.amsst.amsjsstmain") {
thisProcessInfo = processInfoArray[i]
break
}
}
console.debug("======thisProcessInfo======>:" + JSON.stringify(thisProcessInfo));
var context = await featureAbility.getContext();
var result = await context.verifyPermission("com.amsst.permission.SYSPERMISSION", thisProcessInfo.pid, thisProcessInfo.uid)
console.debug("======result======>:" + JSON.stringify(result));
expect(result).assertEqual(0);
done()
})
it('AppPermission_0500', 0, async function (done) {
console.info('=====================AppPermission_0500==================<');
var processInfoArray = await abilityManager.getAllRunningProcesses();
console.debug("======processInfoArray======>:" + JSON.stringify(processInfoArray));
var thisProcessInfo = processInfoArray[0];
for(let i=0; i<processInfoArray.length;i++) {
if(processInfoArray[i].processName == "com.amsst.amsjsstmain") {
thisProcessInfo = processInfoArray[i]
break
}
}
console.debug("======thisProcessInfo======>:" + JSON.stringify(thisProcessInfo));
var context = await featureAbility.getContext();
var result = await context.verifySelfPermission("com.amsst.permission.SYSPERMISSION")
console.debug("======com.amsst.permission.SYSPERMISSION:result======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.GET_NETWORK_INFO")
console.debug("======ohos.permission.GET_NETWORK_INFO======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.GET_WIFI_INFO")
console.debug("======ohos.permission.GET_WIFI_INFO:result======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.USE_BLUETOOTH")
console.debug("======ohos.permission.USE_BLUETOOTH:result======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.DISCOVER_BLUETOOTH")
console.debug("======ohos.permission.DISCOVER_BLUETOOTH:result======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.SET_NETWORK_INFO")
console.debug("======ohos.permission.SET_NETWORK_INFO:result======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.SET_WIFI_INFO")
console.debug("======ohos.permission.SET_WIFI_INFO:result======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.SPREAD_STATUS_BAR")
console.debug("======ohos.permission.SPREAD_STATUS_BAR:result======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.INTERNET")
console.debug("======ohos.permission.INTERNET:result======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.MODIFY_AUDIO_SETTINGS")
console.debug("======ohos.permission.MODIFY_AUDIO_SETTINGS:result======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.RECEIVER_STARTUP_COMPLETED")
console.debug("======ohos.permission.RECEIVER_STARTUP_COMPLETED:result======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.RUNNING_LOCK")
console.debug("======ohos.permission.RUNNING_LOCK:result======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.ACCESS_BIOMETRIC")
console.debug("======ohos.permission.ACCESS_BIOMETRIC:result======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.RCV_NFC_TRANSACTION_EVENT")
console.debug("======ohos.permission.RCV_NFC_TRANSACTION_EVENT:result======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.COMMONEVENT_STICKY")
console.debug("======ohos.permission.COMMONEVENT_STICKY:result======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.SYSTEM_FLOAT_WINDOW")
console.debug("======ohos.permission.SYSTEM_FLOAT_WINDOW:result======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.VIBRATE")
console.debug("======ohos.permission.VIBRATE:result======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.USE_TRUSTCIRCLE_MANAGER")
console.debug("======ohos.permission.USE_TRUSTCIRCLE_MANAGER:result======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.USE_WHOLE_SCREEN")
console.debug("======ohos.permission.USE_WHOLE_SCREEN:result======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.SET_WALLPAPER")
console.debug("======ohos.permission.SET_WALLPAPER:result======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.SET_WALLPAPER_DIMENSION")
console.debug("======ohos.permission.SET_WALLPAPER_DIMENSION:result======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.REARRANGE_MISSIONS")
console.debug("======ohos.permission.REARRANGE_MISSIONS:result======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.CLEAN_BACKGROUND_PROCESSES")
console.debug("======ohos.permission.CLEAN_BACKGROUND_PROCESSES:result======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.KEEP_BACKGROUND_RUNNING")
console.debug("======ohos.permission.KEEP_BACKGROUND_RUNNING:result======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.GET_BUNDLE_INFO")
console.debug("======ohos.permission.GET_BUNDLE_INFO:result======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.ACCELEROMETER")
console.debug("======ohos.permission.ACCELEROMETER:result======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.GYROSCOPE")
console.debug("======ohos.permission.GYROSCOPE:result======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.MULTIMODAL_INTERACTIVE")
console.debug("======ohos.permission.MULTIMODAL_INTERACTIVE:result======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.radio.ACCESS_FM_AM")
console.debug("======ohos.permission.radio.ACCESS_FM_AM:result======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.NFC_TAG")
console.debug("======ohos.permission.NFC_TAG:result======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.NFC_CARD_EMULATION")
console.debug("======ohos.permission.NFC_CARD_EMULATION:result======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.DISTRIBUTED_DEVICE_STATE_CHANGE")
console.debug("======ohos.permission.DISTRIBUTED_DEVICE_STATE_CHANGE:result======>:" + JSON.stringify(result));
result = await context.verifySelfPermission("ohos.permission.GET_DISTRIBUTED_DEVICE_INFO")
console.debug("======ohos.permission.GET_DISTRIBUTED_DEVICE_INFO:result======>:" + JSON.stringify(result));
expect(result).assertEqual(0);
done()
})
it('AppPermission_5000', 0, async function (done) {
console.info('=====================AppPermission_5000==================<');
var dataInfo = await bundle.getBundleInfo('com.amsst.amsjsstmain',1);
var context = await featureAbility.getContext();
await context.requestPermissionsFromUser(["ohos.permission.CAMERA"], 580).then(
data => console.log("then : " + data))
.catch(error => console.log("catch : " + error));
await context.verifyPermission("ohos.permission.CAMERA",0,dataInfo.uid,
(err, data) => {
expect(err.code).assertEqual(0);
expect(data).assertEqual(0);
done();
});
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('./AmsJsunit.test.js')
\ No newline at end of file
......@@ -26,12 +26,12 @@ export default {
title: "AbilityA1",
logmessage: "this is log message",
testcase: [
"AppPermission_1300",
"AppPermission_1400",
"AppPermission_1500",
"AppPermission_1600",
"AppPermission_1700",
"AppPermission_1800",
"ACTS_AppPermission_1300",
"ACTS_AppPermission_1400",
"ACTS_AppPermission_1500",
"ACTS_AppPermission_1600",
"ACTS_AppPermission_1700",
"ACTS_AppPermission_1800",
],
},
onInit() {
......
......@@ -29,40 +29,41 @@ export function GetCaseInfo(caseName) {
}
var allCase = {
AppPermission_1300: {
func: AppPermission_1300,
info: "Verify that a system_grand system`s permission(ohos.permission.GET_NETWORK_INFO) is automatically requested during installation."
ACTS_AppPermission_1300: {
func: ACTS_AppPermission_1300,
info: "Verify that calling application(different application in the same device) is requested the system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)."
},
AppPermission_1400: {
func: AppPermission_1400,
info: ""
ACTS_AppPermission_1400: {
func: ACTS_AppPermission_1400,
info: "Verify that calling application(different application in the same device) is requested the system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)."
},
AppPermission_1500: {
func: AppPermission_1500,
info: ""
ACTS_AppPermission_1500: {
func: ACTS_AppPermission_1500,
info: "Verify that calling application(different application in the same device) is not requested the user_grant system`s permission(ohos.permission.CAMERA)."
},
AppPermission_1600: {
func: AppPermission_1600,
info: ""
ACTS_AppPermission_1600: {
func: ACTS_AppPermission_1600,
info: "Verify that calling application(different application in the same device) is not requested the user_grant system`s permission(ohos.permission.CAMERA)."
},
AppPermission_1700: {
func: AppPermission_1700,
info: ""
ACTS_AppPermission_1700: {
func: ACTS_AppPermission_1700,
info: "Verify that calling application(different application in the same device) is requested the system_grant user`s permission(com.amsst.permission.SYSPERMISSION)."
},
AppPermission_1800: {
func: AppPermission_1800,
info: ""
ACTS_AppPermission_1800: {
func: ACTS_AppPermission_1800,
info: "Verify that calling application(different application in the same device) is requested the system_grant user`s permission(com.amsst.permission.SYSPERMISSION)."
},
}
async function AppPermission_1300(thisobj) {
var thisFunctionName = AppPermission_1300.name
async function ACTS_AppPermission_1300(thisobj) {
var thisFunctionName = ACTS_AppPermission_1300.name
thisobj.logmessage = ""
thisobj.logmessage += "run test case " + thisFunctionName + "\n"
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += GetCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext()
await context.verifyPermission("ohos.permission.GET_NETWORK_INFO",
await context.verifyCallingPermission("ohos.permission.GET_NETWORK_INFO",
(err, data) => {
console.debug("======verifyCallingPermission:data======>:" + JSON.stringify(data));
thisobj.logmessage += JSON.stringify(data) + "\n"
......@@ -75,14 +76,14 @@ async function AppPermission_1300(thisobj) {
})
}
async function AppPermission_1400(thisobj) {
var thisFunctionName = AppPermission_1400.name
async function ACTS_AppPermission_1400(thisobj) {
var thisFunctionName = ACTS_AppPermission_1400.name
thisobj.logmessage = ""
thisobj.logmessage += "run test case " + thisFunctionName + "\n"
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += GetCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext()
console.log("<======verfyPermissiom pass=====>")
var result = await context.verifyPermission("ohos.permission.GET_NETWORK_INFO")
var result = await context.verifyCallingPermission("ohos.permission.GET_NETWORK_INFO")
console.debug("======verifyCallingPermission:result======>:" + JSON.stringify(result))
thisobj.logmessage += JSON.stringify(result) + "\n"
if (result == 0) {
......@@ -93,13 +94,14 @@ async function AppPermission_1400(thisobj) {
}
}
async function AppPermission_1500(thisobj) {
var thisFunctionName = AppPermission_1500.name
async function ACTS_AppPermission_1500(thisobj) {
var thisFunctionName = ACTS_AppPermission_1500.name
thisobj.logmessage = ""
thisobj.logmessage += "run test case " + thisFunctionName + "\n"
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += GetCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext()
await context.verifyPermission("ohos.permission.CAMERA",
await context.verifyCallingPermission("ohos.permission.CAMERA",
(err, data) => {
console.debug("======verifyCallingPermission:data======>:" + JSON.stringify(data));
thisobj.logmessage += JSON.stringify(data) + "\n"
......@@ -112,13 +114,14 @@ async function AppPermission_1500(thisobj) {
})
}
async function AppPermission_1600(thisobj) {
var thisFunctionName = AppPermission_1600.name
async function ACTS_AppPermission_1600(thisobj) {
var thisFunctionName = ACTS_AppPermission_1600.name
thisobj.logmessage = ""
thisobj.logmessage += "run test case " + thisFunctionName + "\n"
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += GetCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext()
var result = await context.verifyPermission("ohos.permission.CAMERA")
var result = await context.verifyCallingPermission("ohos.permission.CAMERA")
console.debug("======verifyCallingPermission:result======>:" + JSON.stringify(result))
thisobj.logmessage += JSON.stringify(result) + "\n"
if (result == -1) {
......@@ -129,13 +132,14 @@ async function AppPermission_1600(thisobj) {
}
}
async function AppPermission_1700(thisobj) {
var thisFunctionName = AppPermission_1700.name
async function ACTS_AppPermission_1700(thisobj) {
var thisFunctionName = ACTS_AppPermission_1700.name
thisobj.logmessage = ""
thisobj.logmessage += "run test case " + thisFunctionName + "\n"
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += GetCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext()
await context.verifyPermission("com.amsst.permission.SYSPERMISSION",
await context.verifyCallingPermission("com.amsst.permission.SYSPERMISSION",
(err, data) => {
console.debug("======verifyCallingPermission:data======>:" + JSON.stringify(data));
thisobj.logmessage += JSON.stringify(data) + "\n"
......@@ -148,13 +152,14 @@ async function AppPermission_1700(thisobj) {
})
}
async function AppPermission_1800(thisobj) {
var thisFunctionName = AppPermission_1800.name
async function ACTS_AppPermission_1800(thisobj) {
var thisFunctionName = ACTS_AppPermission_1800.name
thisobj.logmessage = ""
thisobj.logmessage += "run test case " + thisFunctionName + "\n"
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += GetCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext()
var result = await context.verifyPermission("com.amsst.permission.SYSPERMISSION")
var result = await context.verifyCallingPermission("com.amsst.permission.SYSPERMISSION")
console.debug("======verifyCallingPermission:result======>:" + JSON.stringify(result))
thisobj.logmessage += JSON.stringify(result) + "\n"
if (result == 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册