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

!3302 新增ExtensionAbility查询用例和application查询用例

Merge pull request !3302 from ry/master
......@@ -57,6 +57,7 @@ group("bundlemanager") {
"sceneProject/bmsscenetwo:bmsJstest2",
"sceneProject/bmssecondright:second_right",
"sceneProject/bmsstagedemoone:bmsStageDemo1",
"sceneProject/bmsstagedemotwo:bmsStageDemo2",
]
}
}
......@@ -24,6 +24,8 @@ const SELF_BUNDLENAME = "com.example.actsbmsetsunpermissiontest";
const SELF_ABILITYNAME = "com.example.actsbmsetsunpermissiontest.MainAbility";
const BUNDLE_SETTINGS = "com.ohos.settings";
const ABILITIY_SETTINGS = "com.ohos.settings.MainAbility";
const BUNDLE_NAME1 = "ohos.acts.bundle.stage";
const ABILITY_NAME1 = "ExtensionAbility1";
export default function actsBmsJsUnPermissionTest() {
describe('actsBmsJsUnPermissionTest', function () {
......@@ -183,6 +185,38 @@ export default function actsBmsJsUnPermissionTest() {
});
});
/*
* @tc.number: SUB_BMS_APPINFO_EXTENSION_0019
* @tc.name: test queryExtensionAbilityInfos api
* @tc.desc: test queryExtensionAbilityInfos no permission
*/
it('SUB_BMS_APPINFO_EXTENSION_0019', 0, async function (done) {
await bundle.queryExtensionAbilityInfos(
{
"bundleName": BUNDLE_NAME1,
"abilityName": ABILITY_NAME1
}, bundle.ExtensionAbilityType.FORM, bundle.ExtensionFlag.GET_EXTENSION_INFO_DEFAULT,
100).then(data => {
expect(data).assertFail();
}).catch(err => {
expect(err).assertEqual(1);
});
bundle.queryExtensionAbilityInfos(
{
"bundleName": BUNDLE_NAME1,
"abilityName": ABILITY_NAME1
}, bundle.ExtensionAbilityType.FORM, bundle.ExtensionFlag.GET_EXTENSION_INFO_DEFAULT,
100, (err, data) => {
if (err) {
expect(err).assertEqual(1);
done();
return;
}
expect(data).assertFail();
done();
})
})
async function checkAbilityInfo(data) {
console.info("checkAbilityInfo start !!!");
expect(data.bundleName).assertEqual("com.example.actsbmsetsunpermissiontest");
......
......@@ -28,7 +28,8 @@
"bmsThirdBundleTest1.hap -> /data/bmsThirdBundleTest1.hap ",
"first_right.hap -> /data/test/first_right.hap",
"second_right.hap -> /data/second_right.hap",
"bmsStageDemo1.hap -> /data/test/bmsStageDemo1.hap"
"bmsStageDemo1.hap -> /data/test/bmsStageDemo1.hap",
"bmsStageDemo2.hap -> /data/test/bmsStageDemo2.hap"
]
},
{
......@@ -37,11 +38,13 @@
"bm install -p /data/bmsThirdBundleTest1.hap",
"bm install -p /data/test/first_right.hap",
"bm install -p /data/second_right.hap",
"bm install -p /data/test/bmsStageDemo1.hap"
"bm install -p /data/test/bmsStageDemo1.hap",
"bm install -p /data/test/bmsStageDemo2.hap"
],
"teardown-command":[
"bm uninstall -n com.example.third1",
"bm uninstall -n com.example.l3jsdemo"
"bm uninstall -n com.example.l3jsdemo",
"bm uninstall -n ohos.acts.bundle.stage"
]
}
]
......
......@@ -227,10 +227,6 @@ export default function GetabilityInfo() {
expect(typeof (data.description)).assertEqual("string");
expect(data.icon).assertEqual("$media:icon");
expect(typeof (data.icon)).assertEqual("string");
expect(data.srcPath).assertEqual("MainAbility");
expect(typeof (data.srcPath)).assertEqual("string");
expect(data.srcLanguage).assertEqual("ets");
expect(typeof (data.srcLanguage)).assertEqual("string");
expect(data.isVisible).assertEqual(true);
expect(Array.isArray(data.permissions)).assertEqual(true);
expect(Array.isArray(data.deviceCapabilities)).assertEqual(true);
......@@ -284,8 +280,6 @@ export default function GetabilityInfo() {
expect(data.label).assertEqual("$string:app_name");
expect(data.description).assertEqual("$string:mainability_description");
expect(data.icon).assertEqual("$media:icon");
expect(data.srcPath).assertEqual("");
expect(data.srcLanguage).assertEqual("js");
expect(data.isVisible).assertEqual(true);
expect(data.deviceTypes[0]).assertEqual("phone");
expect(data.process).assertEqual("");
......@@ -304,7 +298,6 @@ export default function GetabilityInfo() {
expect(data.readPermission).assertEqual("");
expect(data.writePermission).assertEqual("");
expect(data.targetAbility).assertEqual("");
expect(data.theme).assertEqual("");
expect(data.metaData.length).assertEqual(0);
expect(data.metadata.length).assertEqual(0);
checkApplicationInfo_other(data.applicationInfo);
......
......@@ -26,9 +26,12 @@ const TAG_TEST_0300_001 = ' bundle_getAllApplicationInfo_test_0300_007 ';
const TAG_TEST_0400_001 = ' bundle_getAllApplicationInfo_test_0400_008 ';
const TAG_TEST_0500_001 = ' bundle_getAllApplicationInfo_test_0500_009 ';
const TAG_TEST_0500_002 = ' bundle_getAllApplicationInfo_test_0500_0010 ';
const DEFAULT_FLAG = Bundle.BundleFlag.GET_BUNDLE_DEFAULT;
const BUNDLE_OTHER = 'com.example.third1';
const PATH = "/data/app/el1/bundle/public";
const USER_ID_100 = 100;
export default function applicationBundleJsunit() {
export default function getAllApplicationBundleTest() {
describe('appInfoTest', function () {
......@@ -215,48 +218,96 @@ export default function applicationBundleJsunit() {
});
/**
* @tc.number: bundle_getApplicationInfo_test_0500_009
* @tc.number: bundle_getApplicationInfo_test_0500_0010
* @tc.name: getApplicationInfo : Obtains based on a given bundle name.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it(TAG_TEST_0500_001, 0, async function (done) {
it(TAG_TEST_0500_002, 0, async function (done) {
let errors;
let startTime = await Utils.getNowTime();
await Bundle.getAllApplicationInfo('Bundle.BundleFlag.GET_BUNDLE_DEFAULT').then((data) => {
console.info(TAG_TEST_0500_001 + 'noUserId promise data is: ' + data);
await Bundle.getAllApplicationInfo('Bundle.BundleFlag.GET_BUNDLE_DEFAULT', USER_ID_100).then((data) => {
console.info(TAG_TEST_0500_002 + 'noUserId promise data is: ' + data);
expect(data).assertFail();
}).catch((error) => {
console.info(TAG_TEST_0500_001 + 'noUserId promise error is: ' + error);
console.info(TAG_TEST_0500_002 + 'UserId promise error is: ' + error);
errors = error;
expect(errors).assertEqual(1);
});
let endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0500_001, startTime, endTime);
Utils.getDurationTime(TAG_TEST_0500_002, startTime, endTime);
done();
});
/**
* @tc.number: bundle_getApplicationInfo_test_0500_0010
* @tc.number: getApplicationInfos_1000
* @tc.name: getApplicationInfo : Obtains based on a given bundle name.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
* @tc.desc: Check the return value of the interface
*/
it(TAG_TEST_0500_002, 0, async function (done) {
let errors;
let startTime = await Utils.getNowTime();
await Bundle.getAllApplicationInfo('Bundle.BundleFlag.GET_BUNDLE_DEFAULT', USER_ID_100).then((data) => {
console.info(TAG_TEST_0500_002 + 'noUserId promise data is: ' + data);
it('getApplicationInfos_1000', 0, async function (done) {
await Bundle.getAllApplicationInfo(DEFAULT_FLAG).then((data) => {
expect(data.length).assertLarger(10);
let flag = 0;
for(let i in data){
if (data[i].name == BUNDLE_OTHER){
flag = 1;
getApplicationInfoSuccessOther(data[i]);
}
}
expect(flag).assertEqual(1);
}).catch((error) => {
expect(error).assertFail();
});
Bundle.getAllApplicationInfo(DEFAULT_FLAG, (err, data) => {
expect(err).assertEqual(0);
expect(data.length).assertLarger(10);
let flag = 0;
for(let i in data){
if (data[i].name == BUNDLE_OTHER){
flag = 1;
getApplicationInfoSuccessOther(data[i]);
}
}
expect(flag).assertEqual(1);
done();
});
});
/**
* @tc.number: getApplicationInfos_1200
* @tc.name: getApplicationInfo : Obtains based on a given bundle name.
* @tc.desc: Check the return value of the interface
*/
it('getApplicationInfos_1200', 0, async function (done) {
await Bundle.getAllApplicationInfo('Bundle.BundleFlag.GET_BUNDLE_DEFAULT').then((data) => {
expect(data).assertFail();
}).catch((error) => {
console.info(TAG_TEST_0500_002 + 'UserId promise error is: ' + error);
errors = error;
expect(errors).assertEqual(1);
expect(error).assertEqual(1);
});
let endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0500_002, startTime, endTime);
await Bundle.getAllApplicationInfo(null).then((data) => {
expect(data).assertFail();
}).catch((error) => {
expect(error).assertEqual(1);
});
await Bundle.getAllApplicationInfo(undefined).then((data) => {
expect(data).assertFail();
}).catch((error) => {
expect(error).assertEqual(1);
});
Bundle.getAllApplicationInfo(undefined, (err, data) => {
expect(err).assertEqual(1);
expect(data).assertEqual("type mismatch");
Bundle.getAllApplicationInfo('Bundle.BundleFlag.GET_BUNDLE_DEFAULT', (err, data) => {
expect(err).assertEqual(1);
expect(data).assertEqual("type mismatch");
Bundle.getAllApplicationInfo(null, (err, data) => {
expect(err).assertEqual(1);
expect(data).assertEqual("type mismatch");
done();
});
});
});
});
function expectData(msg, data) {
console.info(msg + 'commonTest data length [' + data.length + ']');
......@@ -326,6 +377,38 @@ export default function applicationBundleJsunit() {
}
}
function getApplicationInfoSuccessOther(data) {
expect(data.name).assertEqual(BUNDLE_OTHER);
expect(data.codePath).assertEqual(PATH + '/' + BUNDLE_OTHER);
expect(data.accessTokenId).assertLarger(0);
expect(data.description).assertEqual('$string:mainability_description');
expect(data.descriptionId).assertLarger(0);
expect(data.icon).assertEqual('$media:icon');
expect(data.iconId).assertLarger(0);
expect(data.label).assertEqual('$string:app_name');
expect(data.labelId).assertLarger(0);
expect(data.systemApp).assertFalse();
expect(data.supportedModes).assertEqual(0);
expect(data.process).assertEqual("");
expect(data.entryDir).assertEqual(PATH + '/' + BUNDLE_OTHER + '/' + BUNDLE_OTHER + '.entry');
expect(data.permissions.length).assertEqual(0);
expect(data.moduleSourceDirs.length).assertEqual(1);
expect(data.moduleSourceDirs[0]).assertEqual(PATH + '/' + BUNDLE_OTHER + '/' + BUNDLE_OTHER + '.entry');
expect(data.moduleInfos.length).assertEqual(1);
expect(data.moduleInfos[0].moduleName).assertEqual('entry');
expect(data.moduleInfos[0].moduleSourceDir).assertEqual(PATH + '/' +
BUNDLE_OTHER + '/' + BUNDLE_OTHER + '.entry');
expect(JSON.stringify(data.metaData)).assertEqual("{}");
expect(JSON.stringify(data.metadata)).assertEqual("{}");
expect(data.enabled).assertTrue();
expect(data.flags).assertEqual(0);
expect(data.uid).assertLarger(0);
expect(data.entityType).assertEqual('unspecified');
expect(data.removable).assertTrue();
expect(data.fingerprint).assertEqual("");
console.info('check end');
}
});
}
\ No newline at end of file
......@@ -30,10 +30,13 @@ const TAG_TEST_0600_001 = ' bundle_getApplicationInfo_test_0600_0011 ';
const TAG_TEST_0600_002 = ' bundle_getApplicationInfo_test_0600_0012 ';
const TAG_TEST_0600_003 = ' bundle_getApplicationInfo_test_0600_0013 ';
const BUNDLE_NAME = 'com.open.harmony.packagemag';
const BUNDLE_NAME_OTHER = 'com.ohos.acepackage';
const BUNDLE_OTHER = 'com.example.third1';
const BUNDLE_NOTEXIST = 'com.ohos.package';
const FLAG_DEFAULT = Bundle.BundleFlag.GET_BUNDLE_DEFAULT;
const PATH = "/data/app/el1/bundle/public";
const USER_ID_100 = 100;
export default function getApplicationInfoJsunit() {
export default function applicationBundleJsunit() {
describe('appInfoTest', function () {
......@@ -222,26 +225,6 @@ export default function getApplicationInfoJsunit() {
done();
});
/**
* @tc.number: bundle_getApplicationInfo_test_0500_001
* @tc.name: getApplicationInfo : Obtains based on a given bundle name.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it(TAG_TEST_0500_001, 0, async function (done) {
let startTime = await Utils.getNowTime();
await Bundle.getApplicationInfo('', Bundle.BundleFlag.GET_BUNDLE_DEFAULT).then((data) => {
console.info(TAG_TEST_0500_001 + 'noUserId promise data is: ' + data);
expect(data).assertFail();
}).catch((error) => {
console.info(TAG_TEST_0500_001 + 'noUserId promise error is: ' + error);
expect(error).assertEqual(1);
});
let endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0500_001, startTime, endTime);
done();
});
/**
* @tc.number: bundle_getApplicationInfo_test_0500_002
* @tc.name: getApplicationInfo : Obtains based on a given bundle name.
......@@ -262,29 +245,6 @@ export default function getApplicationInfoJsunit() {
done();
});
/**
* @tc.number: bundle_getApplicationInfo_test_0600_001
* @tc.name: getApplicationInfo : Obtains based on a given bundle name.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it(TAG_TEST_0600_001, 0, async function (done) {
let errors
let startTime = await Utils.getNowTime();
await Bundle.getApplicationInfo(BUNDLE_NAME_OTHER,
Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION).then((data) => {
console.info(TAG_TEST_0600_001 + 'other bundleName noUserId promise data is: ' + data);
expect(data).assertFail();
}).catch((error) => {
console.info(TAG_TEST_0600_001 + 'other bundleName noUserId promise error is: ' + error);
errors = error
expect(errors).assertEqual(1);
});
let endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0600_001, startTime, endTime);
done();
});
/**
* @tc.number: bundle_getApplicationInfo_test_0600_002
* @tc.name: getApplicationInfo : Obtains based on a given bundle name.
......@@ -294,7 +254,7 @@ export default function getApplicationInfoJsunit() {
it(TAG_TEST_0600_002, 0, async function (done) {
let startTime = await Utils.getNowTime();
let errors
await Bundle.getApplicationInfo(BUNDLE_NAME_OTHER,
await Bundle.getApplicationInfo(BUNDLE_NOTEXIST,
Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USER_ID_100).then((data) => {
console.info(TAG_TEST_0600_002 + 'other bundleName UserId promise data is: ' + data);
expect(data).assertFail();
......@@ -309,26 +269,112 @@ export default function getApplicationInfoJsunit() {
});
/**
* @tc.number: bundle_getApplicationInfo_test_0600_003
* @tc.number: getApplicationInfo_1300
* @tc.name: getApplicationInfo : Obtains based on a given bundle name.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
* @tc.desc: Check the return value of the interface
*/
it(TAG_TEST_0600_003, 0, async function (done) {
it('getApplicationInfo_1300', 0, async function (done) {
let startTime = await Utils.getNowTime();
await Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_BUNDLE_DEFAULT).then((data) => {
await Bundle.getApplicationInfo(BUNDLE_NAME, FLAG_DEFAULT).then((data) => {
let endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0600_003, startTime, endTime);
console.info(TAG_TEST_0600_003 + 'noUserId promise data is: ' + data);
expect(typeof (data)).assertEqual("object");
expectData(TAG_TEST_0600_003, data);
getApplicationInfoSuccess_plus(TAG_TEST_0600_003, data);
}).catch((error) => {
console.info(TAG_TEST_0600_003 + 'noUserId promise error is: ' + error);
expect(error).assertFail();
});
startTime = await Utils.getNowTime();
Bundle.getApplicationInfo(BUNDLE_NAME, FLAG_DEFAULT, (err, data) => {
let endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0600_003, startTime, endTime);
console.info(TAG_TEST_0600_003 + 'noUserId promise data is: ' + data);
expectData(TAG_TEST_0600_003, data);
getApplicationInfoSuccess_plus(TAG_TEST_0600_003, data);
expect(err).assertEqual(0);
done();
});
});
/**
* @tc.number: getApplicationInfo_1400
* @tc.name: getApplicationInfo : Obtains based on a given bundle name.
* @tc.desc: Check the return value of the interface
*/
it('getApplicationInfo_1400', 0, async function (done) {
await Bundle.getApplicationInfo(BUNDLE_OTHER, FLAG_DEFAULT).then((data) => {
console.info('noUserId promise data is: ' + data);
getApplicationInfoSuccessOther(data);
}).catch((error) => {
expect(error).assertFail();
});
Bundle.getApplicationInfo(BUNDLE_OTHER, FLAG_DEFAULT, (err, data) => {
console.info('noUserId promise data is: ' + data);
expect(err).assertEqual(0);
getApplicationInfoSuccessOther(data);
done();
});
});
/**
* @tc.number: getApplicationInfo_1500
* @tc.name: getApplicationInfo : Obtains based on a given bundle name.
* @tc.desc: Check the return value of the interface
*/
it('getApplicationInfo_1500', 0, async function (done) {
let startTime = await Utils.getNowTime();
await Bundle.getApplicationInfo(BUNDLE_NOTEXIST, FLAG_DEFAULT).then((data) => {
expect(data).assertFail();
}).catch((error) => {
expect(error).assertEqual(1);
let endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0600_001, startTime, endTime);
});
startTime = await Utils.getNowTime();
await Bundle.getApplicationInfo(BUNDLE_NOTEXIST, FLAG_DEFAULT, (err, data) => {
let endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0600_001, startTime, endTime);
expect(err).assertEqual(1);
expect(JSON.stringify(data)).assertEqual(undefined);
done();
});
});
/**
* @tc.number: getApplicationInfo_1700
* @tc.name: getApplicationInfo : Obtains based on a given bundle name.
* @tc.desc: Check the return value of the interface
*/
it('getApplicationInfo_1700', 0, async function (done) {
await Bundle.getApplicationInfo('', FLAG_DEFAULT).then((data) => {
expect(data).assertFail();
}).catch((error) => {
expect(error).assertEqual(1);
});
await Bundle.getApplicationInfo(null, FLAG_DEFAULT).then((data) => {
expect(data).assertFail();
}).catch((error) => {
expect(error).assertEqual(1);
});
await Bundle.getApplicationInfo(BUNDLE_NAME, null).then((data) => {
expect(data).assertFail();
}).catch((error) => {
expect(error).assertEqual(1);
});
Bundle.getApplicationInfo('', FLAG_DEFAULT, (err, data) => {
expect(err).assertEqual(1);
expect(JSON.stringify(data)).assertEqual(undefined);
Bundle.getApplicationInfo(null, FLAG_DEFAULT, (err, data) => {
expect(err).assertEqual(1);
expect(data).assertEqual("type mismatch");
Bundle.getApplicationInfo(BUNDLE_NAME, null, (err, data) => {
expect(err).assertEqual(1);
expect(data).assertEqual("type mismatch");
done();
});
});
});
});
function expectData(msg, data) {
expect(typeof (data)).assertEqual('object');
......@@ -358,8 +404,8 @@ export default function getApplicationInfoJsunit() {
}
function getApplicationInfoSuccess(msg, data) {
expect(data.name).assertEqual('com.open.harmony.packagemag');
expect(data.codePath).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag');
expect(data.name).assertEqual(BUNDLE_NAME);
expect(data.codePath).assertEqual(PATH + '/' + BUNDLE_NAME);
expect(data.accessTokenId > 0).assertEqual(true);
expect(data.description).assertEqual('$string:mainability_description');
expect(data.descriptionId > 0).assertEqual(true);
......@@ -372,16 +418,13 @@ export default function getApplicationInfoJsunit() {
expect(data.supportedModes).assertEqual(0);
expect(data.flags).assertEqual(0);
expect(data.process).assertEqual("");
expect(data.entryDir).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag' +
'/com.open.harmony.packagemag');
expect(data.entryDir).assertEqual(PATH + '/' + BUNDLE_NAME + '/' + BUNDLE_NAME);
expect(data.enabled).assertEqual(true);
expect(data.entityType).assertEqual('unspecified');
expect(data.removable).assertEqual(true);
expect(data.moduleInfos[0].moduleName).assertEqual('entry');
expect(data.moduleInfos[0].moduleSourceDir).assertEqual('/data/app/el1/bundle/public/' +
'com.open.harmony.packagemag/com.open.harmony.packagemag');
expect(data.moduleSourceDirs[0]).assertEqual('/data/app/el1/bundle/public/' +
'com.open.harmony.packagemag/com.open.harmony.packagemag');
expect(data.moduleInfos[0].moduleSourceDir).assertEqual(PATH + '/' + BUNDLE_NAME + '/' + BUNDLE_NAME);
expect(data.moduleSourceDirs[0]).assertEqual(PATH + '/' + BUNDLE_NAME + '/' + BUNDLE_NAME);
expect(data.permissions[0]).assertEqual("ohos.permission.CHANGE_ABILITY_ENABLED_STATE");
expect(data.permissions[1]).assertEqual("ohos.permission.GET_BUNDLE_INFO");
expect(data.permissions[2]).assertEqual("ohos.permission.GET_BUNDLE_INFO_PRIVILEGED");
......@@ -389,31 +432,67 @@ export default function getApplicationInfoJsunit() {
}
function getApplicationInfoSuccess_plus(msg, data) {
expect(data.name).assertEqual('com.open.harmony.packagemag');
expect(data.codePath).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag');
expect(data.accessTokenId > 0).assertEqual(true);
expect(data.name).assertEqual(BUNDLE_NAME);
expect(data.codePath).assertEqual(PATH + '/' + BUNDLE_NAME);
expect(data.accessTokenId).assertLarger(0);
expect(data.description).assertEqual('$string:mainability_description');
expect(data.descriptionId > 0).assertEqual(true);
expect(data.descriptionId).assertLarger(0);
expect(data.icon).assertEqual('$media:icon');
expect(data.iconId > 0).assertEqual(true);
expect(data.uid > 0).assertEqual(true);
expect(data.iconId).assertLarger(0);
expect(data.label).assertEqual('$string:entry_MainAbility');
expect(data.labelId > 0).assertEqual(true);
expect(data.systemApp).assertEqual(true);
expect(data.labelId).assertLarger(0);
expect(data.systemApp).assertTrue();
expect(data.supportedModes).assertEqual(0);
expect(data.flags).assertEqual(0);
expect(data.process).assertEqual("");
expect(data.entryDir).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag' +
'/com.open.harmony.packagemag');
expect(data.enabled).assertEqual(true);
expect(data.entryDir).assertEqual(PATH + '/' + BUNDLE_NAME + '/' + BUNDLE_NAME);
expect(data.permissions.length).assertEqual(0);
expect(data.moduleSourceDirs.length).assertEqual(1);
expect(data.moduleSourceDirs[0]).assertEqual(PATH + '/' + BUNDLE_NAME + '/' + BUNDLE_NAME);
expect(data.moduleInfos.length).assertEqual(1);
expect(data.moduleInfos[0].moduleName).assertEqual('entry');
expect(data.moduleInfos[0].moduleSourceDir).assertEqual(PATH + '/' +
BUNDLE_NAME + '/' + BUNDLE_NAME);
expect(JSON.stringify(data.metaData)).assertEqual("{}");
expect(JSON.stringify(data.metadata)).assertEqual("{}");
expect(data.enabled).assertTrue();
expect(data.flags).assertEqual(0);
expect(data.uid).assertLarger(0);
expect(data.entityType).assertEqual('unspecified');
expect(data.removable).assertEqual(true);
expect(data.removable).assertTrue();
expect(data.fingerprint).assertEqual("");
console.info(msg + ' end ');
}
function getApplicationInfoSuccessOther(data) {
expect(data.name).assertEqual(BUNDLE_OTHER);
expect(data.codePath).assertEqual(PATH + '/' + BUNDLE_OTHER);
expect(data.accessTokenId).assertLarger(0);
expect(data.description).assertEqual('$string:mainability_description');
expect(data.descriptionId).assertLarger(0);
expect(data.icon).assertEqual('$media:icon');
expect(data.iconId).assertLarger(0);
expect(data.label).assertEqual('$string:app_name');
expect(data.labelId).assertLarger(0);
expect(data.systemApp).assertFalse();
expect(data.supportedModes).assertEqual(0);
expect(data.process).assertEqual("");
expect(data.entryDir).assertEqual(PATH + '/' + BUNDLE_OTHER + '/' + BUNDLE_OTHER + '.entry');
expect(data.permissions.length).assertEqual(0);
expect(data.moduleSourceDirs.length).assertEqual(1);
expect(data.moduleSourceDirs[0]).assertEqual(PATH + '/' + BUNDLE_OTHER + '/' + BUNDLE_OTHER + '.entry');
expect(data.moduleInfos.length).assertEqual(1);
expect(data.moduleInfos[0].moduleName).assertEqual('entry');
expect(data.moduleInfos[0].moduleSourceDir).assertEqual('/data/app/el1/bundle/public/' +
'com.open.harmony.packagemag/com.open.harmony.packagemag');
expect(data.moduleSourceDirs[0]).assertEqual('/data/app/el1/bundle/public/' +
'com.open.harmony.packagemag/com.open.harmony.packagemag');
console.log(msg + ' end ' + JSON.stringify(data));
expect(data.moduleInfos[0].moduleSourceDir).assertEqual(PATH + '/' +
BUNDLE_OTHER + '/' + BUNDLE_OTHER + '.entry');
expect(JSON.stringify(data.metaData)).assertEqual("{}");
expect(JSON.stringify(data.metadata)).assertEqual("{}");
expect(data.enabled).assertTrue();
expect(data.flags).assertEqual(0);
expect(data.uid).assertLarger(0);
expect(data.entityType).assertEqual('unspecified');
expect(data.removable).assertTrue();
expect(data.fingerprint).assertEqual("");
console.info('check end');
}
});
......
......@@ -13,16 +13,18 @@
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("bmsStageDemo1") {
ohos_hap("bmsStageDemo1") {
hap_profile = "entry/src/main/module.json"
hap_name = "bmsStageDemo1"
subsystem_name = XTS_SUITENAME
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
deps = [
":bmsstagedemoone_js_assets",
":bmsstagedemoone_resources",
":hjs_demo_js_assets",
":hjs_demo_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "bmsStageDemo1"
testonly = true
}
ohos_app_scope("bmsstagedemoone_app_profile") {
......@@ -30,11 +32,11 @@ ohos_app_scope("bmsstagedemoone_app_profile") {
sources = [ "AppScope/resources" ]
}
ohos_js_assets("bmsstagedemoone_js_assets") {
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("bmsstagedemoone_resources") {
ohos_resources("hjs_demo_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":bmsstagedemoone_app_profile" ]
hap_profile = "entry/src/main/module.json"
......
import FormExtension from '@ohos.application.FormExtension';
import formBindingData from '@ohos.application.formBindingData';
import formInfo from '@ohos.application.formInfo';
export default class FormAbility extends FormExtension {
onCreate(want) {
// Called to return a FormBindingData object.
let formData = {};
return formBindingData.createFormBindingData(formData);
}
onCastToNormal(formId) {
// Called when the form provider is notified that a temporary form is successfully
// converted to a normal form.
}
onUpdate(formId) {
// Called to notify the form provider to update a specified form.
}
onVisibilityChange(newStatus) {
// Called when the form provider receives form events from the system.
}
onEvent(formId, message) {
// Called when a specified message event defined by the form provider is triggered.
}
onDestroy(formId) {
// Called to notify the form provider that a specified form has been destroyed.
}
onAcquireFormState(want) {
// Called to return a {@link FormState} object.
return formInfo.FormState.READY;
}
};
\ No newline at end of file
......@@ -40,13 +40,41 @@
"label": "$string:form_FormAbility_label",
"description": "$string:form_FormAbility_desc",
"type": "form",
"skills": [
{
"actions": ["actionZ"]
},
{
"actions": ["actionZ12"],
"uris": [
{
"scheme": "https",
"host": "www.test.com",
"pathStartWith": "query/teacher"
}
]
},
{
"actions": ["action_1"],
"uris": [
{
"scheme": "https",
"host": "www.test.com",
"path": "query/student/name"
}
]
},
{
"actions": ["actionZ14"],
"entities": ["entitiesZ14","entitiesCommon","entitiesZZ"]
}
],
"metadata": [
{
"name": "ohos.extension.form",
"resource": "$profile:form_config"
}
],
"permissions": ["ohos.permission.GET_BUNDLE_INFO"]
]
},
{
"name": "ExtensionAbility1",
......@@ -54,13 +82,56 @@
"label": "$string:form_FormAbility_label",
"description": "$string:form_FormAbility_desc",
"type": "form",
"skills": [
{
"actions": ["actionY"]
},
{
"actions": ["actionY12"],
"uris": [
{
"scheme": "https",
"host": "www.test.com",
"path": "query/student/name"
}
]
},
{
"actions": ["action_2"],
"uris": [
{
"scheme": "https",
"host": "www.test.com",
"pathStartWith": "query/teacher"
}
]
},
{
"actions": ["actionY14"],
"entities": ["entitiesY14"]
}
],
"metadata": [
{
"name": "ohos.extension.form",
"value": "testExtensionAbilities",
"resource": "$profile:form_config"
}
],
"permissions": ["ohos.permission.GET_BUNDLE_INFO"]
},
{
"name": "ServiceAbility",
"srcEntrance": "./ets/ServiceAbility/FormAbility.ts",
"label": "$string:form_FormAbility_label",
"description": "$string:form_FormAbility_desc",
"type": "service",
"metadata": [
{
"name": "ohos.extension.form",
"resource": "$profile:form_config"
}
]
}
]
......
{
"app":{
"bundleName":"ohos.acts.bundle.stage",
"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":8,
"targetAPIVersion":8,
"car":{
"apiCompatibleVersion":8,
"singleUser":false
}
}
}
{
"string":[
{
"name":"app_name",
"value":"ohosProject"
}
]
}
\ 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_hap("bmsStageDemo2") {
hap_profile = "entry/src/main/module.json"
hap_name = "bmsStageDemo2"
subsystem_name = XTS_SUITENAME
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "signature/openharmony_sx.p7b"
}
ohos_app_scope("bmsstagedemoone_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("hjs_demo_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":bmsstagedemoone_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
}
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context;
}
}
import FormExtension from '@ohos.application.FormExtension';
import formBindingData from '@ohos.application.formBindingData';
import formInfo from '@ohos.application.formInfo';
export default class FormAbility extends FormExtension {
onCreate(want) {
// Called to return a FormBindingData object.
let formData = {};
return formBindingData.createFormBindingData(formData);
}
onCastToNormal(formId) {
// Called when the form provider is notified that a temporary form is successfully
// converted to a normal form.
}
onUpdate(formId) {
// Called to notify the form provider to update a specified form.
}
onVisibilityChange(newStatus) {
// Called when the form provider receives form events from the system.
}
onEvent(formId, message) {
// Called when a specified message event defined by the form provider is triggered.
}
onDestroy(formId) {
// Called to notify the form provider that a specified form has been destroyed.
}
onAcquireFormState(want) {
// Called to return a {@link FormState} object.
return formInfo.FormState.READY;
}
};
\ No newline at end of file
import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
onCreate(want,launchParam){
// Ability is creating, initialize resources for this ability
console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("[Demo] MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate")
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "pages/index/index", null)
}
onWindowStageDestroy() {
//Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility onBackground")
}
};
\ No newline at end of file
import FormExtension from '@ohos.application.FormExtension';
import formBindingData from '@ohos.application.formBindingData';
import formInfo from '@ohos.application.formInfo';
export default class FormAbility extends FormExtension {
onCreate(want) {
// Called to return a FormBindingData object.
let formData = {};
return formBindingData.createFormBindingData(formData);
}
onCastToNormal(formId) {
// Called when the form provider is notified that a temporary form is successfully
// converted to a normal form.
}
onUpdate(formId) {
// Called to notify the form provider to update a specified form.
}
onVisibilityChange(newStatus) {
// Called when the form provider receives form events from the system.
}
onEvent(formId, message) {
// Called when a specified message event defined by the form provider is triggered.
}
onDestroy(formId) {
// Called to notify the form provider that a specified form has been destroyed.
}
onAcquireFormState(want) {
// Called to return a {@link FormState} object.
return formInfo.FormState.READY;
}
};
\ 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 file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets"
import testsuite from "../../test/List.test.ets"
@Entry
@Component
struct Index {
aboutToAppear(){
console.info("start run testcase!!!!")
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
const reportExtend = new ReportExtend(file)
core.addService('report', reportExtend)
core.init()
core.subscribeEvent('task', reportExtend)
const configService = core.getDefaultService('config')
console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters))
globalThis.abilityWant.parameters.timeout = 70000;
configService.setConfig(globalThis.abilityWant.parameters)
testsuite(globalThis.abilityContext)
core.execute()
}
build() {
Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(25)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
})
}
.width('100%')
.height('100%')
}
}
\ 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 router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "Second Page"
build() {
Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ 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 function testsuite(context) {
}
\ No newline at end of file
{
"module": {
"name": "myfeature",
"type": "feature",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility1",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "ohos.acts.bundle.stage.MainAbility1",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"orientation": "portrait",
"visible": true,
"skills": [
{
"actions": [
"action.system.home"
],
"entities":[
"entity.system.home"
]
}
]
}
],
"extensionAbilities": [
{
"name": "ExtensionAbilityQ",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"label": "$string:form_FormAbility_label",
"description": "$string:form_FormAbility_desc",
"type": "form",
"skills": [
{
"actions": ["actionQ"],
"entities": ["entitiesQ"]
}
],
"metadata": [
{
"name": "ohos.extension.form",
"resource": "$profile:form_config"
}
]
},
{
"name": "ExtensionAbilityW",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"label": "$string:form_FormAbility_label",
"description": "$string:form_FormAbility_desc",
"type": "service",
"skills": [
{
"actions": ["actionW"],
"entities": ["entitiesW","entitiesCommon"]
}
],
"metadata": [
{
"name": "ohos.extension.form",
"resource": "$profile:form_config"
}
],
"permissions": ["ohos.permission.GET_BUNDLE_INFO"]
},
{
"name": "ExtensionAbilityA",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"label": "$string:form_FormAbility_label",
"description": "$string:form_FormAbility_desc",
"type": "wallpaper",
"skills": [
{
"actions": ["action_3"],
"uris": [
{
"scheme": "https",
"host": "www.test.com",
"pathRegex": "ab*c"
}
]
}
],
"metadata": [
{
"name": "ohos.extension.form",
"resource": "$profile:form_config"
}
]
},
{
"name": "ExtensionAbilityB",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"label": "$string:form_FormAbility_label",
"description": "$string:form_FormAbility_desc",
"type": "workScheduler",
"skills": [
{
"actions": ["action_4"],
"uris": [
{
"scheme": "https",
"host": "www.test.com",
"path": "query/student/name",
"pathRegex": "ab*c",
"pathStartWith": "query/teacher"
}
]
}
],
"metadata": [
{
"name": "ohos.extension.form",
"resource": "$profile:form_config"
}
],
"permissions": ["ohos.permission.GET_BUNDLE_INFO"]
}
]
}
}
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsContextTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
},
{
"name": "form_FormAbility_desc",
"value": "form_description"
},
{
"name": "form_FormAbility_label",
"value": "form_label"
}
]
}
{
"forms": [
{
"isDefault": true,
"src": "./js/widget/pages/index/index",
"scheduledUpdateTime": "10:30",
"defaultDimension": "2*2",
"name": "widget",
"description": "This is a service widget.",
"colorMode": "auto",
"window": {
"designWidth": 720,
"autoDesignWidth": true
},
"formConfigAbility": "ability://xxxxx",
"supportDimensions": [
"2*2"
],
"updateEnabled": true,
"updateDuration": 1
},
{
"isDefault": true,
"src": "./js/widget1/pages/index/index",
"scheduledUpdateTime": "10:30",
"defaultDimension": "2*2",
"name": "widget1",
"description": "This is a service widget.",
"colorMode": "auto",
"window": {
"designWidth": 720,
"autoDesignWidth": true
},
"formConfigAbility": "ability://xxxxx",
"supportDimensions": [
"1*2",
"2*2"
],
"updateEnabled": true,
"updateDuration": 1
},
{
"isDefault": true,
"src": "./js/widget2/pages/index/index",
"scheduledUpdateTime": "10:30",
"defaultDimension": "2*2",
"name": "widget2",
"description": "This is a service widget.",
"colorMode": "auto",
"window": {
"designWidth": 720,
"autoDesignWidth": true
},
"formConfigAbility": "ability://xxxxx",
"supportDimensions": [
"2*2"
],
"updateEnabled": true,
"updateDuration": 1
},
{
"isDefault": true,
"src": "./js/widget3/pages/index/index",
"scheduledUpdateTime": "10:30",
"defaultDimension": "2*2",
"name": "widget3",
"description": "This is a service widget.",
"colorMode": "auto",
"window": {
"designWidth": 720,
"autoDesignWidth": true
},
"formConfigAbility": "ability://xxxxx",
"supportDimensions": [
"2*2"
],
"updateEnabled": true,
"updateDuration": 1
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册