提交 a9d0c554 编写于 作者: C chengxingzhen

XTS元能力api覆盖

Signed-off-by: Nchengxingzhen <chengxingzhen@huawei.com>
上级 c5ff91ae
......@@ -34,8 +34,6 @@ export default function verificationTest(){
TAG = 'SUB_AA_OpenHarmony_Test_HasWindowFocus_0100 ==>';
try {
let stageMode:any = ability_featureAbility.getContext
console.info(TAG + "stageMode = " + stageMode.stageMode)
let flags = false
let subscriber = null
let subscribeInfo = {
......@@ -368,5 +366,60 @@ export default function verificationTest(){
done();
}
})
/*
* @tc.number SUB_AA_OpenHarmony_Test_TerminateSelfWithResult_0100
* @tc.name CTerminate ability through TerminateSelfWithResult.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_Test_TerminateSelfWithResult_0100', 0, async function(done) {
TAG = 'SUB_AA_OpenHarmony_Test_TerminateSelfWithResult_0100 ==>';
try {
let stageMode = ability_featureAbility.getContext().stageMode
let resultCode = undefined
let subscriber = null
let subscribeInfo = {
events: ["Fa_Auxiliary_MainAbility6_onDestroy"]
}
function SubscribeInfoCallback(err, data) {
console.info(TAG + "===SubscribeInfoCallback===" + JSON.stringify(data))
if (data.event == "Fa_Auxiliary_MainAbility6_onDestroy") {
setTimeout(()=>{
expect(stageMode).assertFalse()
expect(resultCode).assertEqual(661);
commonEvent.unsubscribe(subscriber, UnSubscribeInfoCallback)
}, 1000)
}
}
function UnSubscribeInfoCallback(err, data) {
console.info(TAG + "===UnSubscribeInfoCallback===")
done()
}
commonEvent.createSubscriber(subscribeInfo, (err, data) => {
console.info(TAG + "===CreateSubscriberCallback===")
subscriber = data
commonEvent.subscribe(subscriber, SubscribeInfoCallback)
})
let wantNum = {
want: {
bundleName: 'ohos.acts.aafwk.test.faauxiliary',
abilityName: 'ohos.acts.aafwk.test.faauxiliary.MainAbility6'
}
}
ability_featureAbility.startAbilityForResult(wantNum).then((data) => {
console.info(TAG + "startAbilityForResult data = " + JSON.stringify(data));
resultCode = data.resultCode
}).catch((err) => {
console.info(TAG + "startAbilityForResult err = " + JSON.stringify(err));
expect().assertFail();
done();
});
} catch (err) {
console.info(TAG + "getWindow catch err = " + JSON.stringify(err));
done();
}
})
})
}
......@@ -107,19 +107,6 @@
"type": "page",
"launchType": "singleton"
},
{
"orientation": "unspecified",
"visible": true,
"srcPath": "MainAbility7",
"name": ".MainAbility7",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:MainAbility7_desc",
"formsEnabled": false,
"label": "$string:MainAbility7_label",
"type": "page",
"launchType": "singleton"
},
{
"srcPath": "ServiceAbility",
"name": ".ServiceAbility",
......@@ -232,20 +219,6 @@
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".MainAbility7",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"reqPermissions": [
......
......@@ -21,9 +21,20 @@ export default {
onCreate() {
console.info(printLog1 + 'onCreate');
commonEvent.publish(listPush1 + "onCreate", (err) => {
console.info(printLog1 + listPush1 + "onCreate");
});
setTimeout(()=>{
let wantNum = {
want: {
bundleName: 'ohos.acts.aafwk.test.faauxiliary',
abilityName: 'ohos.acts.aafwk.test.faauxiliary.MainAbility'
},
resultCode: 661
}
ability_featureAbility.terminateSelfWithResult(wantNum).then((data) => {
console.info(printLog1 + "terminateSelfWithResult data = " + JSON.stringify(data));
}).catch((err) => {
console.info(printLog1 + "terminateSelfWithResult err = " + JSON.stringify(err));
});
}, 3000)
},
onDestroy() {
console.info(printLog1 + 'onDestroy');
......@@ -51,20 +62,5 @@ export default {
commonEvent.publish(listPush1 + "onNewWant", (err) => {
console.info(printLog1 + listPush1 + "onNewWant");
});
setTimeout(()=>{
let wantNum = {
want: {
bundleName: 'ohos.acts.aafwk.test.faauxiliary',
abilityName: 'ohos.acts.aafwk.test.faauxiliary.MainAbility'
},
resultCode: 661
}
ability_featureAbility.terminateSelfWithResult(wantNum).then((data) => {
console.info(printLog1 + "terminateSelfWithResult data = " + JSON.stringify(data));
}).catch((err) => {
console.info(printLog1 + "terminateSelfWithResult err = " + JSON.stringify(err));
});
}, 3000)
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import ability_featureAbility from '@ohos.ability.featureAbility';
import commonEvent from '@ohos.commonEvent';
var printLog1 = "Fa:Auxiliary:MainAbility7:";
var listPush1 = "Fa_Auxiliary_MainAbility7_";
export default {
onCreate() {
console.info(printLog1 + 'onCreate');
commonEvent.publish(listPush1 + "onCreate", (err) => {
console.info(printLog1 + listPush1 + "onCreate");
});
setTimeout(()=>{
ability_featureAbility.terminateSelf().then((data) => {
console.info(printLog1 + "terminateSelf data = " + JSON.stringify(data));
}).catch((err) => {
console.info(printLog1 + "terminateSelf err = " + JSON.stringify(err));
});
}, 3000)
},
onDestroy() {
console.info(printLog1 + 'onDestroy');
commonEvent.publish(listPush1 + "onDestroy", (err) => {
console.info(printLog1 + listPush1 + "onDestroy");
});
},
onActive() {
console.info(printLog1 + 'onActive');
},
onInactive() {
console.info(printLog1 + 'onInactive');
},
onShow() {
console.info(printLog1 + 'onShow');
},
onHide() {
console.info(printLog1 + 'onHide');
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Entry
@Component
struct Index {
@State message: string = 'Hello World Test Fa 7'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
......@@ -52,14 +52,6 @@
"name": "MainAbility6_label",
"value": "label"
},
{
"name": "MainAbility7_desc",
"value": "description"
},
{
"name": "MainAbility7_label",
"value": "label"
},
{
"name": "ServiceAbility_desc",
"value": "hap sample empty service"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册