未验证 提交 583b5665 编写于 作者: O openharmony_ci 提交者: Gitee

!8882 防止测试套被资源管控冻结

Merge pull request !8882 from 于文泽/master
......@@ -19,7 +19,6 @@ group("ActsUriPermission") {
deps = [
"actsassistanthap:ActsAssistantHap",
"actsassistanthap:ActsAssistantHap4",
"actsassistanthap2:ActsAssistantHap2",
"actsfasupporturi:ActsFaSupportUri",
"actstempuripermissionhaptest:ActsTempUriPermissionHapTest",
]
......
......@@ -30,12 +30,6 @@ export default class Hap2MainAbility1 extends Ability {
onDestroy() {
console.log('[Demo] Hap2MainAbility1 onDestroy')
if (caseNumber === 16) {
let eventName : string = 'TerminateNotify_Hap3MainAbility1';
commonEvent.publish(eventName, (err) => {
console.log('Hap2MainAbility1' + eventName);
});
}
}
onWindowStageCreate(windowStage) {
......@@ -346,58 +340,6 @@ export default class Hap2MainAbility1 extends Ability {
break;
}
case 16: {
console.log('[Demo] Hap2MainAbility1 case 16 call.');
let eventName : string = 'RevicedFrom_Hap3MainAbility1';
let subscribeInfo16_1 = {
events: [eventName]
}
let subscriber16_1;
function UnSubscribeInfoCallback16_1(err, data) {
console.info("Hap2MainAbility1 ===UnSubscribeInfoCallback16_1===")
}
function SubscribeCallBackContext16_1(err, data) {
console.log('Hap2MainAbility1 Subscribe CallBack data:' + JSON.stringify(data));
caseNumber = 16;
if (data.event === eventName) {
commonEvent.unsubscribe(subscriber16_1, UnSubscribeInfoCallback16_1)
globalThis.hap2MainAbility1Context.terminateSelf();
}
}
commonEvent.createSubscriber(subscribeInfo16_1).then(async (data) => {
subscriber16_1 = data;
console.debug('====>Create Subscriber====>');
await commonEvent.subscribe(subscriber16_1, SubscribeCallBackContext16_1);
});
let filePath : string = this.context.filesDir + '/test_ability1_2.txt';
fs.open(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE, (err, file) => {
if (err) {
console.info('mkdir failed with error message: ' + err.message + ', error code: ' + err.code);
} else {
console.info('Hap2MainAbility1 file created, fd: ' + file.fd);
}
});
let uri : string = fileUri.getUriFromPath(filePath);
console.info('[Demo] Hap2MainAbility1 uri is ' + JSON.stringify(uri));
let want = {
flags : wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
bundleName : 'com.example.timeout',
abilityName : 'Hap3MainAbility1',
uri : uri
}
this.context.startAbility(want).then(() => {
console.log('TAG + startAbility succeed');
}).catch((error) => {
console.log('error.code: ' + JSON.stringify(error.code) + ' error.message: ' +
JSON.stringify(error.message));
});
break;
}
case 17: {
console.log('[Demo] Hap2MainAbility1 case 17 call.');
let uri : string = globalThis.abilityWant1.uri;
......
{
"app": {
"bundleName": "com.example.timeout",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon": "$media:icon",
"label": "$string:app_name",
"description": "$string:description_application",
"distributedNotificationEnabled": true,
"keepAlive": true,
"singleUser": true,
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
{
"string":[
{
"name":"app_name",
"value":"UriPermissionAssistanthap2Test"
}
]
}
\ No newline at end of file
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_hap_assist_suite("ActsAssistantHap2") {
hap_name = "ActsAssistantHap2"
js_build_mode = "debug"
hap_profile = "entry/src/main/module.json"
testonly = true
deps = [
":actsassistanthap2_js_assets",
":actsassistanthap2_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("actsassistanthap2_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actsassistanthap2_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actsassistanthap2_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actsassistanthap2_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
/*
* Copyright (c) 2023 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 Ability from '@ohos.app.ability.UIAbility'
import commonEvent from '@ohos.commonEvent';
import fs from '@ohos.file.fs'
function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time))
}
export default class Hap3MainAbility1 extends Ability {
onCreate(want, launchParam) {
console.log('[Demo] Hap3MainAbility1 onCreate')
globalThis.abilityWant = want;
}
onDestroy() {
console.log('[Demo] Hap3MainAbility1 onDestroy')
}
onWindowStageCreate(windowStage) {
console.log('[Demo] Hap3MainAbility1 onWindowStageCreate')
windowStage.setUIContent(this.context, 'pages/Hap3MainAbility1_pages', null)
}
onWindowStageDestroy() {
console.log('[Demo] Hap3MainAbility1 onWindowStageDestroy')
}
onForeground() {
console.log('[Demo] Hap3MainAbility1 onForeground')
let eventName : string = 'TerminateNotify_Hap3MainAbility1';
let subscribeInfo = {
events: [eventName]
}
let subscriber_1;
function UnSubscribeInfoCallback_1(err, data) {
console.info("Hap2MainAbility1 ===UnSubscribeInfoCallback_1===")
}
async function SubscribeCallBackContext(err, data) {
console.log('Hap3MainAbility1 Subscribe CallBack data:' + JSON.stringify(data));
if (data.event === eventName) {
await sleep(1000);
let uri : string = globalThis.abilityWant.uri;
if (uri == null) {
console.log('[Demo] Hap3MainAbility1 uri is invalid');
return;
}
console.info('[Demo] Hap3MainAbility1 uri is ' + JSON.stringify(uri));
let eventName13_1 : string = 'Temp_UriPermissionTest_1300_Read_Successfully';
let eventName13_2 : string = 'Temp_UriPermissionTest_1300_Read_Failed';
fs.open(uri, fs.OpenMode.READ_ONLY).then((file) => {
console.info('file fd: ' + file.fd);
commonEvent.publish(eventName13_1, (err) => {
console.log('Hap3MainAbility1' + eventName13_1);
});
}).catch((err) => {
console.info('open file failed with error message: ' + err.message + ', error code: ' + err.code);
commonEvent.publish(eventName13_2, (err) => {
console.log('Hap3MainAbility1' + eventName13_2);
});
});
let eventName13_3 : string = 'Temp_UriPermissionTest_1300_Write_Successfully';
let eventName13_4 : string = 'Temp_UriPermissionTest_1300_Write_Failed';
fs.open(uri, fs.OpenMode.READ_WRITE).then((file) => {
console.info('file fd: ' + file.fd);
commonEvent.publish(eventName13_3, (err) => {
console.log('Hap3MainAbility1' + eventName13_3);
});
}).catch((err) => {
console.info('open file failed with error message: ' + err.message + ', error code: ' + err.code);
commonEvent.publish(eventName13_4, (err) => {
console.log('Hap3MainAbility1' + eventName13_4);
});
});
}
commonEvent.unsubscribe(subscriber_1, UnSubscribeInfoCallback_1)
}
commonEvent.createSubscriber(subscribeInfo).then(async (data) => {
subscriber_1 = data;
console.debug('====>Create Subscriber====>');
await commonEvent.subscribe(subscriber_1, SubscribeCallBackContext);
});
let eventName1 : string = 'RevicedFrom_Hap3MainAbility1';
commonEvent.publish(eventName1, (err) => {
console.log('Hap3MainAbility1' + eventName1);
});
}
onBackground() {
console.log('[Demo] Hap3MainAbility1 onBackground')
}
};
/*
* Copyright (c) 2023 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.
*/
@Entry
@Component
struct Hap3MainAbility1_pages {
@State message: string = 'Hap3MainAbility1'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
{
"module": {
"name": "hap3",
"type": "feature",
"description": "$string:hap3_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "Hap3MainAbility1",
"srcEntrance": "./ets/Hap3MainAbility1/Hap3MainAbility1.ts",
"description": "$string:Hap3MainAbility1_desc",
"icon": "$media:icon",
"label": "$string:Hap3MainAbility1_label",
"visible": true,
"orientation": "portrait"
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "hap3_desc",
"value": "description"
},
{
"name": "Hap3MainAbility1_desc",
"value": "description"
},
{
"name": "Hap3MainAbility1_label",
"value": "label"
}
]
}
......@@ -13,7 +13,6 @@
"test-file-name": [
"ActsTempUriPermissionHapTest.hap",
"ActsAssistantHap.hap",
"ActsAssistantHap2.hap",
"ActsAssistantHap4.hap",
"ActsFaSupportUri.hap"
],
......
......@@ -30,13 +30,22 @@ export default function UriPermissionTest() {
done()
});
let abilityContext = globalThis.abilityContext;
afterEach(async function (done) {
console.info('UriPermissionTest after each called');
let wantInfo = {
bundleName: 'com.example.stageautosign',
abilityName: 'com.example.stageautosign.MainAbility'
}
await abilityContext.startAbility(wantInfo).then(() => {
console.info('afterEach startAbility succeed');
}).catch((error) => {
console.info('afterEach error.code: ' + JSON.stringify(error.code) + ' error.message: ' +
JSON.stringify(error.message));
});
done();
});
let abilityContext = globalThis.abilityContext;
function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time))
}
......@@ -1362,97 +1371,6 @@ export default function UriPermissionTest() {
console.info("---------------Temp_UriPermissionTest_1200 is end---------------")
});
/*
* @tc.number Temp_UriPermissionTest_1300
* @tc.name The ability of HAP A grant uri permission to the ability of HAP B
* @tc.desc Function test
* @tc.level 0
*/
it("Temp_UriPermissionTest_1300", 0, async function (done) {
console.info("---------------Temp_UriPermissionTest_1300 is start---------------")
let TAG13 = "Temp_UriPermissionTest_1300";
let flag13_1 = false;
let flag13_2 = false;
let eventName13_1 : string = 'Temp_UriPermissionTest_1300_Read_Successfully';
let eventName13_2 : string = 'Temp_UriPermissionTest_1300_Read_Failed';
let subscribeInfo13_1 = {
events: [eventName13_1, eventName13_2]
}
let subscriber13_1;
function UnSubscribeInfoCallback13_1(err, data) {
console.info(TAG13 + "===UnSubscribeInfoCallback13_1===")
}
function SubscribeCallBackContext13_1(err, data) {
console.info(TAG13 + ' Subscribe CallBack data:' + JSON.stringify(data));
if (data.event === eventName13_1) {
console.info(TAG13 + 'read file succeed.');
commonEvent.unsubscribe(subscriber13_1, UnSubscribeInfoCallback13_1)
flag13_1 = true;
}
if (data.event === eventName13_2) {
console.info(TAG13 + 'read file failed.');
expect().assertFail();
}
}
commonEvent.createSubscriber(subscribeInfo13_1).then(async (data) => {
subscriber13_1 = data;
console.info('====>Create subscriber13_1====>');
await commonEvent.subscribe(subscriber13_1, SubscribeCallBackContext13_1);
});
let eventName13_3 : string = 'Temp_UriPermissionTest_1300_Write_Successfully';
let eventName13_4 : string = 'Temp_UriPermissionTest_1300_Write_Failed';
let subscribeInfo13_2 = {
events: [eventName13_3, eventName13_4]
}
let subscriber13_2;
function UnSubscribeInfoCallback13_2(err, data) {
console.info(TAG13 + "===UnSubscribeInfoCallback13_2===")
}
function SubscribeCallBackContext13_2(err, data) {
console.info(TAG13 + ' Subscribe CallBack data:' + JSON.stringify(data));
if (data.event === eventName13_3) {
console.info(TAG13 + 'write file succeed.');
expect().assertFail();
}
if (data.event === eventName13_4) {
console.info(TAG13 + 'write file failed.');
commonEvent.unsubscribe(subscriber13_2, UnSubscribeInfoCallback13_2)
flag13_2 = true;
}
}
commonEvent.createSubscriber(subscribeInfo13_2).then(async (data) => {
subscriber13_2 = data;
console.info('====>Create subscriber13_2====>');
await commonEvent.subscribe(subscriber13_2, SubscribeCallBackContext13_2);
});
let want = {
bundleName : "com.acts.authorizeduriapplication",
abilityName : "Hap2MainAbility1",
parameters : {
'number' : 16
}
}
await abilityContext.startAbility(want).then(() => {
console.info(TAG13 + ' startAbility succeed');
}).catch((error) => {
console.info(TAG13 + 'error.code: ' + JSON.stringify(error.code) + ' error.message: ' +
JSON.stringify(error.message));
});
while (!flag13_1 || !flag13_2) {
console.info(TAG13 + 'waiting callback');
await sleep(1000);
}
done()
console.info("---------------Temp_UriPermissionTest_1300 is end---------------")
});
/*
* @tc.number Temp_UriPermissionTest_1400
* @tc.name The ability of HAP A grant uri permission to the ability of HAP B
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册