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

!1050 Modify test code

Merge pull request !1050 from blackleon/update_code_1107
......@@ -22,6 +22,8 @@ group("aafwk_standard") {
"featureability:featureability",
"formmanager:formmanager",
"want:want",
#"verifypermission:verifypermission"
]
}
}
......@@ -39,6 +39,12 @@ describe('ActsAmsCallBackSixth Scene', function () {
);
sleep(5000)
});
function sleep(delay) {
var start = (new Date()).getTime();
while((new Date()).getTime() - start < delay) {}
}
/*
* @tc.number : Acts_Ams_test_12200
* @tc.name : clearMissions : Clear Missions
......
......@@ -42,9 +42,7 @@ describe('ActsAmsCallBackSixth Scene', function () {
function sleep(delay) {
var start = (new Date()).getTime();
while((new Date()).getTime() - start < delay) {
continue;
}
while((new Date()).getTime() - start < delay) {}
}
/*
......
# 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("AmsJsStMain") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "AmsJsStMain"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests",
}
{
"app": {
"bundleName": "com.amsst.amsjsstmain",
"vendor": "amsst",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"defPermissions": [
{
"name": "com.amsst.permission.SYSPERMISSION",
"grantMode": "system_grant",
"availableScope": []
},
{
"name": "ohos.permission.GET_NETWORK_INFO",
"grantMode": "system_grant",
"availableScope": []
},
{
"name": "ohos.permission.GET_WIFI_INFO",
"grantMode": "system_grant",
"availableScope": []
},
{
"name": "ohos.permission.SET_NETWORK_INFO",
"grantMode": "system_grant",
"availableScope": []
},
{
"name": "ohos.permission.SET_WIFI_INFO",
"grantMode": "system_grant",
"availableScope": []
},
{
"name": "ohos.permission.CAMERA",
"grantMode": "user_grant",
"availableScope": []
},
{
"name": "ohos.permission.PERMISSIONA",
"grantMode": "user_grant",
"availableScope": []
},
{
"name": "ohos.permission.PERMISSIONB",
"grantMode": "user_grant",
"availableScope": []
},
{
"name": "ohos.permission.PERMISSIONC",
"grantMode": "user_grant",
"availableScope": []
},
{
"name": "ohos.permission.PERMISSIOND",
"grantMode": "user_grant",
"availableScope": []
}
],
"reqPermissions": [
{
"name": "ohos.permission.CAMERA",
"reason": "$string:permreason_camera",
"usedScene": {
"ability": [
"com.amsst.amsjsstmain.MainAbility"
],
"when": "always"
}
},
{
"name": "com.amsst.permission.SYSPERMISSION",
"reason": "$string:permreason_sys",
"usedScene": {
"ability": [
"com.amsst.amsjsstmain.MainAbility"
],
"when": "always"
}
},
{
"name": "ohos.permission.PERMISSIONA",
"reason": "NEED ohos.permission.PERMISSIONA",
"usedScene": {
"ability": [
"com.amsst.amsjsstmain.MainAbility"
],
"when": "always"
}
},
{
"name": "ohos.permission.PERMISSIONB",
"reason": "NEED ohos.permission.PERMISSIONB",
"usedScene": {
"ability": [
"com.amsst.amsjsstmain.MainAbility"
],
"when": "always"
}
},
{
"name": "ohos.permission.PERMISSIONC",
"reason": "NEED ohos.permission.PERMISSIONC",
"usedScene": {
"ability": [
"com.amsst.amsjsstmain.MainAbility"
],
"when": "always"
}
},
{
"name": "ohos.permission.PERMISSIOND",
"reason": "NEED ohos.permission.PERMISSIOND",
"usedScene": {
"ability": [
"com.amsst.amsjsstmain.MainAbility"
],
"when": "always"
}
},
{
"name": "ohos.permission.GET_NETWORK_INFO",
"reason": "$string:permreason_getnetworkinfo",
"usedScene": {
"ability": [
"com.amsst.amsjsstmain.MainAbility"
],
"when": "always"
}
},
{
"name": "ohos.permission.USE_BLUETOOTH"
},
{
"name": "ohos.permission.DISCOVER_BLUETOOTH"
},
{
"name": "ohos.permission.SET_NETWORK_INFO"
},
{
"name": "ohos.permission.SET_WIFI_INFO"
},
{
"name": "ohos.permission.SPREAD_STATUS_BAR"
},
{
"name": "ohos.permission.INTERNET"
},
{
"name": "ohos.permission.MODIFY_AUDIO_SETTINGS"
},
{
"name": "ohos.permission.RECEIVER_STARTUP_COMPLETED"
},
{
"name": "ohos.permission.RUNNING_LOCK"
},
{
"name": "ohos.permission.ACCESS_BIOMETRIC"
},
{
"name": "ohos.permission.RCV_NFC_TRANSACTION_EVENT"
},
{
"name": "ohos.permission.COMMONEVENT_STICKY"
},
{
"name": "ohos.permission.SYSTEM_FLOAT_WINDOW"
},
{
"name": "ohos.permission.VIBRATE"
},
{
"name": "ohos.permission.USE_TRUSTCIRCLE_MANAGER"
},
{
"name": "ohos.permission.USE_WHOLE_SCREEN"
},
{
"name": "ohos.permission.SET_WALLPAPER"
},
{
"name": "ohos.permission.SET_WALLPAPER_DIMENSION"
},
{
"name": "ohos.permission.REARRANGE_MISSIONS"
},
{
"name": "ohos.permission.CLEAN_BACKGROUND_PROCESSES"
},
{
"name": "ohos.permission.KEEP_BACKGROUND_RUNNING"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO"
},
{
"name": "ohos.permission.ACCELEROMETER"
},
{
"name": "ohos.permission.GYROSCOPE"
},
{
"name": "ohos.permission.MULTIMODAL_INTERACTIVE"
},
{
"name": "ohos.permission.radio.ACCESS_FM_AM"
},
{
"name": "ohos.permission.NFC_TAG"
},
{
"name": "ohos.permission.NFC_CARD_EMULATION"
},
{
"name": "ohos.permission.DISTRIBUTED_DEVICE_STATE_CHANGE"
},
{
"name": "ohos.permission.GET_DISTRIBUTED_DEVICE_INFO"
}
],
"package": "com.amsst.amsjsstmain",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.amsst.amsjsstmain.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard",
"visible": true
}
],
"js": [
{
"pages": [
"pages/index/index",
"pages/permissionPage/permissionPage"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": true
}
}
]
}
}
\ 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: 32px;
color: #000000;
opacity: 0.9;
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
@media screen and (device-type: wearable) {
.title {
font-size: 28px;
color: #FFFFFF;
}
}
@media screen and (device-type: tv) {
.container {
background-image: url("../../common/images/Wallpaper.png");
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}
.title {
font-size: 100px;
color: #FFFFFF;
}
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
div>div{
width: 100%;
height: 200px;
flex-direction: column;
align-items: center;
justify-content: center;
}
.btn{
margin-bottom: 20px;
}
\ No newline at end of file
<div class="container">
<div>
<text class="title">
{{ title }}
</text>
</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>
/*
* 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 app from '@system.app'
import router from '@system.router';
import featureAbility from '@ohos.ability.featureability'
export default {
data: {
title: "AmsJsStMain"
},
onInit() {
console.debug('====onInit()====<')
this.title = "AmsJsStMain";
},
onShow() {
console.debug('====onShow()====<')
},
onReady() {
console.debug('====onReady finish====<')
},
onBackPress(){
console.debug('====onBackPress()====<')
},
async stopAbility(){
console.debug('====close====<')
await featureAbility.terminateAbility();
},
clickAction(){
console.debug('====clickAction====<')
router.replace({
uri: 'pages/permissionPage/permissionPage'
})
},
titleAction(){
console.debug('====titleAction()====<')
this.title += "\nMyTest"
},
}
.container {
justify-content: center;
align-items: center;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
.title {
font-size: 30px;
text-align: center;
width: 100%;
height: 80px;
}
div{
flex-direction: column;
align-items: center;
justify-content: center;
}
.btn{
margin-bottom: 10px;
width: 200px;
height: 50px;
}
.log {
font-size: 20px;
text-align: center;
width: 100%;
height: 400px;
}
.todo-wraper {
width: 450px;
height: 450px;
justify-content: center;
}
.todo-item {
width: 450px;
flex-direction: column;
justify-content: center;
}
.text {
margin: 20%;
}
.menu-wraper {
width: 450px;
height: 100px;
justify-content: center;
}
\ No newline at end of file
<div class="container">
<div>
<text class="title">
{{ title }}
</text>
</div>
<div class="log">
<textarea class="log">
{{logmessage}}
</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>
/*
* 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 app from '@system.app'
import router from '@system.router';
import featureAbility from '@ohos.ability.featureability'
import abilityManager from '@ohos.app.abilitymanager'
import { Core, ExpectExtend, ReportExtend } from 'deccjsunit/index'
export default {
currentCase: "",
data: {
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",
],
},
onInit() {
this.title = "AbilityA1";
this.logmessage = "this is log message";
},
onShow() {
},
onReady() {
console.info('====per onReady finish====>')
},
onBackPress() {
},
async stopAbility() {
console.info('===========per close===========>')
await featureAbility.terminateAbility();
await app.killProcessesByBundleName();
},
clickAction() {
router.replace({
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"
console.debug("======per runallcase======<:")
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 })
}
}
/*
* 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
{
"string": [
{
"name": "app_name",
"value": "AmsStMain"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
},
{
"name": "permreason_camera",
"value": "请求使用摄像头"
},
{
"name": "permreason_sys",
"value": "自定义system_grand权限"
},
{
"name": "permreason_getnetworkinfo",
"value": "请求访问网络信息"
},
{
"name": "secondability_description",
"value": "JS_Empty Ability"
},
{
"name": "entry_SecondAbility",
"value": "entry_SecondAbility"
}
]
}
\ 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("AmsJsStSubPermission") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "AmsJsStSubPermission"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests",
}
{
"app": {
"bundleName": "com.amsst.amsjsstsubpermission",
"vendor": "amsst",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.amsst.amsjsstsubpermission",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.amsst.amsjsstsubpermission.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard",
"visible": true
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": true
}
}
],
"reqPermissions": [
{
"name": "com.amsst.permission.SYSPERMISSION",
"reason": "$string:permreason_sys",
"usedScene": {
"ability": [
"com.amsst.amsjsstmain.MainAbility"
],
"when": "always"
}
},
{
"name": "ohos.permission.GET_NETWORK_INFO",
"reason": "$string:permreason_getnetworkinfo",
"usedScene": {
"ability": [
"com.amsst.amsjsstmain.MainAbility"
],
"when": "always"
}
}]
}
}
\ 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: 40px;
color: #000000;
opacity: 0.9;
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
@media screen and (device-type: wearable) {
.title {
font-size: 28px;
color: #FFFFFF;
}
}
@media screen and (device-type: tv) {
.container {
background-image: url("../../common/images/Wallpaper.png");
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}
.title {
font-size: 100px;
color: #FFFFFF;
}
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
.log {
font-size: 20px;
text-align: center;
width: 100%;
height: 400px;
}
\ No newline at end of file
<div class="container">
<text>{{title}}</text>
<div class="log">
<textarea class="log">
{{logmessage}}
</textarea>
</div>
<div>
<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="back" on:click="stopAbility"></button>
</div>
</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 app from '@system.app'
import router from '@system.router';
import featureAbility from '@ohos.ability.featureability'
import { Core, ExpectExtend, ReportExtend } from 'deccjsunit/index'
export default {
currentCase: "",
data: {
title: "AbilityA1",
logmessage: "this is log message",
testcase: [
"AppPermission_1300",
"AppPermission_1400",
"AppPermission_1500",
"AppPermission_1600",
"AppPermission_1700",
"AppPermission_1800",
],
},
onInit() {
this.title = "AbilityA1";
this.logmessage = "this is log message";
},
onShow() {
},
onReady() {
console.info('onReady finish')
},
onBackPress() {
},
async stopAbility() {
console.info('===========AmsJsStSubPermission close===========<')
await featureAbility.terminateAbility();
await app.killProcessesByBundleName();
},
runCase(caseName) {
console.debug("======runCase======>:" + JSON.stringify(caseName))
this.logmessage += caseName + "\n"
console.debug("======runallcase======<:")
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
},
}
/*
* 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'
export function runAllCase(caseName, obj) {
console.debug("======runAllCase1======>:" + JSON.stringify(caseName))
console.debug("======runAllCase2======>:" + JSON.stringify(allCase))
allCase[caseName].func(obj)
}
export function GetCaseInfo(caseName) {
console.debug("======GetCaseInfo======>:" + JSON.stringify(caseName))
return allCase[caseName].info;
}
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."
},
AppPermission_1400: {
func: AppPermission_1400,
info: ""
},
AppPermission_1500: {
func: AppPermission_1500,
info: ""
},
AppPermission_1600: {
func: AppPermission_1600,
info: ""
},
AppPermission_1700: {
func: AppPermission_1700,
info: ""
},
AppPermission_1800: {
func: AppPermission_1800,
info: ""
},
}
async function AppPermission_1300(thisobj) {
var thisFunctionName = AppPermission_1300.name
thisobj.logmessage = ""
thisobj.logmessage += "run test case " + thisFunctionName + "\n"
var context = await featureAbility.getContext()
await context.verifyPermission("ohos.permission.GET_NETWORK_INFO",
(err, data) => {
console.debug("======verifyCallingPermission:data======>:" + JSON.stringify(data));
thisobj.logmessage += JSON.stringify(data) + "\n"
if (data == 0) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n"
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n"
}
})
}
async function AppPermission_1400(thisobj) {
var thisFunctionName = AppPermission_1400.name
thisobj.logmessage = ""
thisobj.logmessage += "run test case " + thisFunctionName + "\n"
var context = await featureAbility.getContext()
console.log("<======verfyPermissiom pass=====>")
var result = await context.verifyPermission("ohos.permission.GET_NETWORK_INFO")
console.debug("======verifyCallingPermission:result======>:" + JSON.stringify(result))
thisobj.logmessage += JSON.stringify(result) + "\n"
if (result == 0) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n"
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n"
}
}
async function AppPermission_1500(thisobj) {
var thisFunctionName = AppPermission_1500.name
thisobj.logmessage = ""
thisobj.logmessage += "run test case " + thisFunctionName + "\n"
var context = await featureAbility.getContext()
await context.verifyPermission("ohos.permission.CAMERA",
(err, data) => {
console.debug("======verifyCallingPermission:data======>:" + JSON.stringify(data));
thisobj.logmessage += JSON.stringify(data) + "\n"
if (data == -1) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n"
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n"
}
})
}
async function AppPermission_1600(thisobj) {
var thisFunctionName = AppPermission_1600.name
thisobj.logmessage = ""
thisobj.logmessage += "run test case " + thisFunctionName + "\n"
var context = await featureAbility.getContext()
var result = await context.verifyPermission("ohos.permission.CAMERA")
console.debug("======verifyCallingPermission:result======>:" + JSON.stringify(result))
thisobj.logmessage += JSON.stringify(result) + "\n"
if (result == -1) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n"
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n"
}
}
async function AppPermission_1700(thisobj) {
var thisFunctionName = AppPermission_1700.name
thisobj.logmessage = ""
thisobj.logmessage += "run test case " + thisFunctionName + "\n"
var context = await featureAbility.getContext()
await context.verifyPermission("com.amsst.permission.SYSPERMISSION",
(err, data) => {
console.debug("======verifyCallingPermission:data======>:" + JSON.stringify(data));
thisobj.logmessage += JSON.stringify(data) + "\n"
if (data == 0) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n"
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n"
}
})
}
async function AppPermission_1800(thisobj) {
var thisFunctionName = AppPermission_1800.name
thisobj.logmessage = ""
thisobj.logmessage += "run test case " + thisFunctionName + "\n"
var context = await featureAbility.getContext()
var result = await context.verifyPermission("com.amsst.permission.SYSPERMISSION")
console.debug("======verifyCallingPermission:result======>:" + JSON.stringify(result))
thisobj.logmessage += JSON.stringify(result) + "\n"
if (result == 0) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n"
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n"
}
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "Permission"
},
{
"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("//test/xts/tools/build/suite.gni")
group("verifypermission") {
testonly = true
if (is_standard_system) {
deps = [
"AmsJsStMain:AmsJsStMain",
"AmsJsStSubPermission:AmsJsStSubPermission",
]
}
}
......@@ -63,6 +63,7 @@ describe('ActsBmsKitTest', function () {
}
)
})
/*
* @tc.number: ActsBmsKit_getAllShortcutInfo_0100
* @tc.name: Pressure test interface getAllShortcutInfo by promise
......
......@@ -104,6 +104,7 @@ describe('ActsBmsModuleUsageRecordTest', function () {
}
});
})
/*
* @tc.number: bms_getModuleUsageRecordTest_0100
* @tc.name: getModuleUsageRecord(maxNum)
......@@ -414,6 +415,7 @@ describe('ActsBmsModuleUsageRecordTest', function () {
});
});
})
/*
* @tc.number: bms_getModuleUsageRecordTest_1300
* @tc.name: getModuleUsageRecord(maxNum, callback: AsyncCallback<Array<ModuleUsageRecord>>)
......@@ -483,6 +485,7 @@ describe('ActsBmsModuleUsageRecordTest', function () {
});
});
})
/*
* @tc.number: bms_getModuleUsageRecordTest_1400
* @tc.name: getModuleUsageRecord(maxNum, callback: AsyncCallback<Array<ModuleUsageRecord>>)
......@@ -551,10 +554,10 @@ describe('ActsBmsModuleUsageRecordTest', function () {
})
/*
* @tc.number: bms_getModuleUsageRecordTest_1500
* @tc.name: getModuleUsageRecord(maxNum, callback: AsyncCallback<Array<ModuleUsageRecord>>)
* @tc.desc: test getModuleUsageRecord with the critical value
*/
* @tc.number: bms_getModuleUsageRecordTest_1500
* @tc.name: getModuleUsageRecord(maxNum, callback: AsyncCallback<Array<ModuleUsageRecord>>)
* @tc.desc: test getModuleUsageRecord with the critical value
*/
it('bms_getModuleUsageRecordTest_1500', 0, async function (done) {
console.debug('=====================bms_getModuleUsageRecordTest_1500==================');
await bundle.getModuleUsageRecords(1000, (err, records) => {
......
......@@ -305,7 +305,7 @@ describe('ActsBundleManagerTest', function () {
done();
}
let installData = await demo.getBundleInstaller();
installData.install([PATH + BMSJSTEST1], {
installData.install([PATH + BMSJSTEST8], {
param: {
userId: 0,
installFlag: 1,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册