提交 7410dc63 编写于 作者: C chengxingzhen

XTS元能力用例整改

Signed-off-by: Nchengxingzhen <chengxingzhen@huawei.com>
上级 450d90a7
import commonEvent from '@ohos.commonEvent';
/*
* 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 FormExtension from '@ohos.application.FormExtension';
import formBindingData from '@ohos.application.formBindingData';
import formInfo from '@ohos.application.formInfo';
......@@ -8,29 +22,6 @@ export default class FormAbility extends FormExtension {
onCreate(want) {
// Called to return a FormBindingData object.
let formData = {};
let extensionInfo_currentInfo_name = this.context.currentHapModuleInfo.name
let extensionInfo_currentInfo_description = this.context.currentHapModuleInfo.description
this.context.resourceManager.getConfiguration((err, data) => {
if (err.code != 0 ) {
console.error(`Ability: getConfiguration failed: ${JSON.stringify(err)}`);
} else {
console.log(`Ability: getConfiguration success: ${JSON.stringify(data)}`);
extensionInfo_config_direction = data.direction
}
})
var CommonEventPublishData = {
parameters: {
"extensionInfo_currentInfo_name": extensionInfo_currentInfo_name,
"extensionInfo_currentInfo_description": extensionInfo_currentInfo_description,
"extensionInfo_config_direction": extensionInfo_config_direction,
"key":"value"
}
}
commonEvent.publish("FormAbility_OnCreate", CommonEventPublishData, (err) => {
console.log('FormAbility_OnCreate');
});
console.info("FormAbility onCreate")
return formBindingData.createFormBindingData(formData);
}
......
......@@ -227,19 +227,44 @@ export default function ApiCoverTest(abilityContext) {
expect("/data/storage/el1/bundle").assertEqual(abilityContext.bundleCodeDir)
expect("/data/storage/el2/distributedfiles").assertEqual(abilityContext.distributedFilesDir)
expect(1).assertEqual(abilityContext.area)
let moduleContext = abilityContext.createModuleContext("module1")
expect("/data/storage/el2/base/cache").assertEqual(moduleContext.cacheDir)
abilityContext.resourceManager.getConfiguration((err, data) => {
if (err.code != 0 ) {
console.error(`Ability: getConfiguration failed: ${JSON.stringify(err)}`);
expect(USERID_ERR).assertEqual(err.code);
done()
} else {
if(err == undefined){
console.log(`Ability: getConfiguration success: ${JSON.stringify(data)}`);
expect(1).assertEqual(data.direction)
console.log(`Ability: getConfiguration success: JSON.stringify(data.direction)`);
expect(0).assertEqual(data.direction)
done()
}else{
expect().assertFail()
done()
}
})
let moduleContext = abilityContext.createModuleContext("module1")
expect("/data/storage/el2/base/cache").assertEqual(moduleContext.cacheDir)
})
/*
* @tc.number SUB_AA_AMS_Context_0200
* @tc.name Register the listener of Ability and cancel the listener.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_AMS_Context_0200', 0, async function (done) {
await abilityContext.eventHub.on("contextEvent", func1)
abilityContext.eventHub.emit("contextEvent", "aa", "bb")
await sleep(500)
expect("aa").assertEqual(array[0])
expect("bb").assertEqual(array[1])
array = []
await abilityContext.eventHub.off("contextEvent", func1)
abilityContext.eventHub.emit("contextEvent", "cc", "dd")
await sleep(500)
expect(array.length).assertEqual(0)
array = [];
function func1(a, b){
array.push(a)
array.push(b)
}
await sleep(2000)
done()
})
......@@ -258,7 +283,7 @@ export default function ApiCoverTest(abilityContext) {
expect(0).assertEqual(2)
} else {
for(let i = 0; i < value.length; i++){
if(value[i].bundleName == "com.example.extensionapitest" && value[i].name == "widget"){
if(value[i].bundleName == "com.example.apicoverhaptest" && value[i].name == "widget"){
trueInfo = value[i]
console.info("formProvider::GetFormsInfoTest trueInfo: " + JSON.stringify(trueInfo));
}
......@@ -267,7 +292,6 @@ export default function ApiCoverTest(abilityContext) {
checkFormInfo(trueInfo)
done()
})
done()
})
/*
......@@ -278,7 +302,7 @@ export default function ApiCoverTest(abilityContext) {
*/
it('SUB_AA_Form_provider_getFormsInfo_0200', 0, async function (done) {
console.info("SUB_AA_Form_provider_getFormsInfo_0200");
const filter: formInfo.FormInfoFilter = {
const filter: FormInfo.FormInfoFilter = {
moduleName: "module1"
};
formProvider.getFormsInfo(filter, (err, value) => {
......@@ -291,7 +315,7 @@ export default function ApiCoverTest(abilityContext) {
expect(1).assertEqual(0)
}else{
for(let i = 0; i < value.length; i++){
if(value[i].bundleName == "com.example.extensionapitest" && value[i].name == "widget1"){
if(value[i].bundleName == "com.example.apicoverhaptest" && value[i].name == "widget1"){
trueInfo = value[i]
console.info("formProvider::GetFormsInfoTest trueInfo: " + JSON.stringify(trueInfo));
}
......@@ -301,7 +325,6 @@ export default function ApiCoverTest(abilityContext) {
checkFormInfoModule1(trueInfo)
done();
})
done()
})
/*
......@@ -362,7 +385,7 @@ export default function ApiCoverTest(abilityContext) {
}
function checkFormInfoModule1(formInfo){
console.info("formProvider::GetFormsInfoTest value: " + JSON.stringify(formInfo));
expect("com.example.extensionapitest").assertEqual(formInfo.bundleName)
expect("com.example.apicoverhaptest").assertEqual(formInfo.bundleName)
expect("module1").assertEqual(formInfo.moduleName)
expect("FormAbility").assertEqual(formInfo.abilityName)
expect("widget1").assertEqual(formInfo.name)
......@@ -380,8 +403,8 @@ function checkFormInfoModule1(formInfo){
}
function checkFormInfo(formInfo){
console.info("formProvider::GetFormsInfoTest formInfo: " + JSON.stringify(formInfo));
expect("com.example.extensionapitest").assertEqual(formInfo.bundleName)
expect("entry").assertEqual(formInfo.moduleName)
expect("com.example.apicoverhaptest").assertEqual(formInfo.bundleName)
expect("phone").assertEqual(formInfo.moduleName)
expect("FormAbility").assertEqual(formInfo.abilityName)
expect("widget").assertEqual(formInfo.name)
expect("This is a service widget.").assertEqual(formInfo.description)
......
......@@ -12,11 +12,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import verificationTest from './VerificationTest'
import apiCoverAbility from './ApiCoverAbility.test'
import verificationTest from './VerificationTest'
import wantAgentCover from './WantAgentCover.test'
export default function List(context) {
verificationTest(context)
apiCoverAbility(context)
verificationTest(context)
wantAgentCover(context)
}
\ No newline at end of file
......@@ -16,8 +16,6 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "
import commonEvent from '@ohos.commonEvent';
import AbilityConstant from "@ohos.application.AbilityConstant";
import appManager from "@ohos.application.appManager";
import bundle from '@ohos.bundle';
import uriPermissionManager from '@ohos.application.uriPermissionManager';
import wantConstant from '@ohos.ability.wantConstant';
var TAG
......@@ -217,54 +215,6 @@ export default function verificationTest(abilityContext){
}
})
/*
* @tc.number SUB_AA_OpenHarmony_UriPermissionManager_0100
* @tc.name Verify URI permissions through verifyUriPermission.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_UriPermissionManager_0100', 0, async function(done) {
TAG = 'SUB_AA_OpenHarmony_UriPermissionManager_0100 ==>';
try {
let uri1 = 'fileshare:///com.samples.filesharetest.FileShare/person/10'
let uri2 = 'fileshare:///com.samples.filesharetest.FileShare/person/20'
let number1 = undefined
let number2 = undefined
let accessTokenId = undefined
await bundle.getApplicationInfo('ohos.acts.aafwk.test.stagesupplement', 0, 100).then((data) => {
console.info(TAG + "getApplicationInfo data = " + JSON.stringify(data.accessTokenId));
accessTokenId = data.accessTokenId
}).catch((err) => {
console.info(TAG + "getApplicationInfo err = " + JSON.stringify(err));
});
await uriPermissionManager.verifyUriPermission(uri1, 2, accessTokenId).then((data) => {
console.info(TAG + "verifyUriPermission data = " + JSON.stringify(data));
}).catch((err) => {
console.info(TAG + "verifyUriPermission err = " + JSON.stringify(err));
number1 = err.code
});
uriPermissionManager.verifyUriPermission(uri2, 2, accessTokenId, (err, data) => {
console.info(TAG + "verifyUriPermission err = " + JSON.stringify(err));
console.info(TAG + "verifyUriPermission data = " + JSON.stringify(data));
number2 = err.code
})
setTimeout(()=>{
expect(number1).assertEqual(-1);
expect(number2).assertEqual(-1);
done()
}, 3000)
} catch (err) {
console.info(TAG + "catch err = " + JSON.stringify(err));
expect().assertFail();
done();
}
})
/*
* @tc.number SUB_AA_OpenHarmony_RequestPermissionsFromUser_0100
* @tc.name FA model is not configured with permission for authorization verification.
......
/*
* 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index"
import wantAgent from '@ohos.wantAgent';
var TAG
export default function wantAgentCoverTest(abilityContext) {
describe('WantAgentTest', function () {
/*
* @tc.number SUB_AA_OpenHarmony_WantAgentCover_0100
* @tc.name Verify stageMode properties and getOperationType interface.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_WantAgentCover_0100', 0, async function(done) {
TAG = 'SUB_AA_OpenHarmony_WantAgentCover_0100 ==>';
try {
let status:any = abilityContext.stageMode
let code1 = undefined
var wantAgentInfo = {
wants: [
{
deviceId: "",
bundleName: "com.example.apicoverhaptest",
abilityName: "com.example.apicoverhaptest.MainAbility",
action: "action1",
entities: ["entity1"],
type: "MIMETYPE",
uri: "key={true.true,false}",
parameters: {
myKey0: 2222
}
}
],
operationType: wantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}
wantAgent.getWantAgent(wantAgentInfo).then((data) =>{
console.info(TAG + "getWantAgent data = " + JSON.stringify(data));
wantAgent.getOperationType(data, (err, data) => {
code1 = data
console.info(TAG + "getOperationType data = " + JSON.stringify(data));
console.info(TAG + "getOperationType err = " + JSON.stringify(err));
});
setTimeout(() => {
expect(status).assertTrue();
expect(code1).assertEqual(2);
done()
},1500)
}).catch((err) => {
console.info(TAG + "getWantAgent err = " + JSON.stringify(err));
expect().assertFail();
done();
})
} catch (err) {
console.info(TAG + "catch err = " + JSON.stringify(err));
expect().assertFail();
done();
}
})
})
}
\ No newline at end of file
......@@ -13,15 +13,19 @@
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("FormSupplyAppA") {
ohos_hap("FormSupplyAppA") {
hap_profile = "entry/src/main/config.json"
hap_name = "FormSupplyAppA"
js_build_mode = "debug"
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
deps = [
":FormOfFaEts_form_js_assets",
":FormOfFaEts_js_assets",
":FormOfFaEts_resources",
]
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "FormSupplyAppA"
part_name = "prebuilt_hap"
subsystem_name = "applications"
}
......
......@@ -13,15 +13,19 @@
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("FormSupplyAppB") {
ohos_hap("FormSupplyAppB") {
hap_profile = "entry/src/main/config.json"
hap_name = "FormSupplyAppB"
js_build_mode = "debug"
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
deps = [
":FormOfFaEts_form_js_assets",
":FormOfFaEts_js_assets",
":FormOfFaEts_resources",
]
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "FormSupplyAppB"
part_name = "prebuilt_hap"
subsystem_name = "applications"
}
......
......@@ -13,15 +13,19 @@
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("FormSupplyAppC") {
ohos_hap("FormSupplyAppC") {
hap_profile = "entry/src/main/config.json"
hap_name = "FormSupplyAppC"
js_build_mode = "debug"
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
deps = [
":FormOfFaEts_form_js_assets",
":FormOfFaEts_js_assets",
":FormOfFaEts_resources",
]
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "FormSupplyAppC"
part_name = "prebuilt_hap"
subsystem_name = "applications"
}
......
......@@ -13,7 +13,7 @@
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("FormSupplyAppD") {
ohos_hap("FormSupplyAppD") {
hap_profile = "entry/src/main/config.json"
deps = [
":FormOfFaEts_form_js_assets",
......@@ -24,6 +24,10 @@ ohos_js_hap_suite("FormSupplyAppD") {
hap_name = "FormSupplyAppD"
part_name = "prebuilt_hap"
subsystem_name = "applications"
js_build_mode = "debug"
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
}
ohos_js_assets("FormOfFaEts_js_assets") {
......
......@@ -13,7 +13,7 @@
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("FormSupplyAppE") {
ohos_hap("FormSupplyAppE") {
hap_profile = "entry/src/main/config.json"
deps = [
":FormOfFaEts_form_js_assets",
......@@ -24,6 +24,10 @@ ohos_js_hap_suite("FormSupplyAppE") {
hap_name = "FormSupplyAppE"
part_name = "prebuilt_hap"
subsystem_name = "applications"
js_build_mode = "debug"
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
}
ohos_js_assets("FormOfFaEts_js_assets") {
......
......@@ -13,7 +13,7 @@
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("FormSupplyAppF") {
ohos_hap("FormSupplyAppF") {
hap_profile = "entry/src/main/config.json"
deps = [
":FormOfFaEts_form_js_assets",
......@@ -24,6 +24,10 @@ ohos_js_hap_suite("FormSupplyAppF") {
hap_name = "FormSupplyAppF"
part_name = "prebuilt_hap"
subsystem_name = "applications"
js_build_mode = "debug"
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
}
ohos_js_assets("FormOfFaEts_js_assets") {
......
......@@ -13,7 +13,7 @@
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("FormSupplyAppG") {
ohos_hap("FormSupplyAppG") {
hap_profile = "entry/src/main/config.json"
deps = [
":FormOfFaEts_form_js_assets",
......@@ -24,6 +24,10 @@ ohos_js_hap_suite("FormSupplyAppG") {
hap_name = "FormSupplyAppG"
part_name = "prebuilt_hap"
subsystem_name = "applications"
js_build_mode = "debug"
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
}
ohos_js_assets("FormOfFaEts_js_assets") {
......
......@@ -13,7 +13,7 @@
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("FormSupplyAppH") {
ohos_hap("FormSupplyAppH") {
hap_profile = "entry/src/main/config.json"
deps = [
":FormOfFaEts_form_js_assets",
......@@ -24,6 +24,10 @@ ohos_js_hap_suite("FormSupplyAppH") {
hap_name = "FormSupplyAppH"
part_name = "prebuilt_hap"
subsystem_name = "applications"
js_build_mode = "debug"
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
}
ohos_js_assets("FormOfFaEts_js_assets") {
......
......@@ -13,7 +13,7 @@
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("FormSupplyAppNS") {
ohos_hap("FormSupplyAppNS") {
hap_profile = "entry/src/main/config.json"
deps = [
":FormOfFaEts_form_js_assets",
......@@ -24,6 +24,10 @@ ohos_js_hap_suite("FormSupplyAppNS") {
hap_name = "FormSupplyAppNS"
part_name = "prebuilt_hap"
subsystem_name = "applications"
js_build_mode = "debug"
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
}
ohos_js_assets("FormOfFaEts_js_assets") {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册