提交 f0009239 编写于 作者: I inter515

新增api覆盖

Signed-off-by: Ninter515 <ry.renyi@huawei.com>
上级 9d2c51f4
......@@ -20,7 +20,7 @@
"mainAbility": "com.open.harmony.packagemag.MainAbility",
"deviceType": [
"default",
"default"
"tablet"
],
"reqPermissions": [
{
......@@ -52,6 +52,7 @@
}
],
"visible": true,
"orientation": "unspecified",
"srcPath": "MainAbility",
"name": ".MainAbility",
"srcLanguage": "ets",
......@@ -81,6 +82,28 @@
"srcLanguage": "ets",
"description": "$string:description_serviceability",
"type": "service"
},
{
"name": ".DataAbility",
"srcLanguage": "ets",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:DataAbility_desc",
"type": "data",
"uri": "dataability://com.open.harmony.packagemag.DataAbility"
},
{
"orientation": "followRecent",
"formsEnabled": false,
"name": ".FollowRecentAbility",
"srcLanguage": "ets",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:PageAbility1_desc",
"label": "$string:PageAbility1_label",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"js": [
......
/**
* 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 impligetProfileByAbilityEmptyAbilityCalled.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import bundle from '@ohos.bundle.bundleManager';
import util from "./Utils";
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "hypium/index"
export default function getBundleInfoForSelf() {
describe('getBundleInfoForSelf', function () {
/*
* @tc.number: SUB_BMS_APPINFO_QUERY_0124
* @tc.name: getBundleInfoForSelfAbilityPro
* @tc.desc: Test getBundleInfoForSelf with ability flag(by promise).
*/
it('getBundleInfoForSelfAbilityPro', 0, async function (done) {
await bundle.getBundleInfoForSelf(
bundle.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundle.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY
).then(data => {
console.info("AbilityPro" + JSON.stringify(data.hapModulesInfo[0].abilitiesInfo[0]));
expect(data.hapModulesInfo[0].abilitiesInfo.length).assertEqual(5);
expect(data.hapModulesInfo[0].abilitiesInfo[0].type).assertEqual(bundle.AbilityType.DATA);
expect(data.hapModulesInfo[0].abilitiesInfo[0].orientation).assertEqual(bundle.DisplayOrientation.UNSPECIFIED);
expect(data.hapModulesInfo[0].abilitiesInfo[1].type).assertEqual(bundle.AbilityType.PAGE);
expect(data.hapModulesInfo[0].abilitiesInfo[1].orientation).assertEqual(bundle.DisplayOrientation.FOLLOW_RECENT);
expect(data.hapModulesInfo[0].abilitiesInfo[2].type).assertEqual(bundle.AbilityType.PAGE);
expect(data.hapModulesInfo[0].abilitiesInfo[2].orientation).assertEqual(bundle.DisplayOrientation.UNSPECIFIED);
expect(data.hapModulesInfo[0].abilitiesInfo[3].type).assertEqual(bundle.AbilityType.SERVICE);
expect(data.hapModulesInfo[0].abilitiesInfo[3].orientation).assertEqual(bundle.DisplayOrientation.UNSPECIFIED);
expect(data.hapModulesInfo[0].abilitiesInfo[4].type).assertEqual(bundle.AbilityType.PAGE);
expect(data.hapModulesInfo[0].abilitiesInfo[4].orientation).assertEqual(bundle.DisplayOrientation.UNSPECIFIED);
console.info("AbilityPro11" + JSON.stringify(data.hapModulesInfo[0].abilitiesInfo[0]));
done();
}).catch(err => {
console.info("getBundleInfoForSelf fail" + JSON.stringify(err));
expect(err).assertFail();
done();
})
})
})
}
\ No newline at end of file
......@@ -29,8 +29,10 @@ import getWindowPorperties from './getWindowProperties.test.ets';
import GetSecondModuleTest from './GetSecondModule.test.ets';
import GetInfoSync from './GetInfoSync.test.ets';
import GetResourceTest from './GetResourceTest.test.ets';
import getBundleInfoForSelf from './GetBundleInfoForSelf.test.ets';
export default function testsuite() {
getBundleInfoForSelf();
getBundleArchiveInfo();
queryExtensionAbilityInfos();
getAbilityIcon();
......
......@@ -27,6 +27,18 @@
{
"name": "entry_description",
"value": "entry_description"
},
{
"name": "PageAbility1_desc",
"value": "description"
},
{
"name": "PageAbility1_label",
"value": "label"
},
{
"name": "DataAbility_desc",
"value": "hap sample empty provider"
}
]
}
\ 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 bundle from '@ohos.bundle.bundleManager';
import { describe, beforeAll, it, expect } from '@ohos/hypium'
export default function GetSecondModuleTest() {
describe('getSecondModuleTest', function () {
/**
* @tc.number SUB_BMS_APPINFO_QUERY_0138
* @tc.name GetSecondModuleTest
* @tc.desc Test the bundleManager secondary module
*/
it('GetSecondModuleTest', 0, async function (done) {
let bundleInfo = await bundle.getBundleInfoForSelf(
bundle.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION |
bundle.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO |
bundle.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE |
bundle.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA |
bundle.BundleFlag.GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY |
bundle.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY |
bundle.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION)
let applicationInfoTest: bundle.ApplicationInfo = bundleInfo.appInfo;
expect(typeof (applicationInfoTest.name)).assertEqual('string');
let metadataTest: bundle.Metadata = bundleInfo.hapModulesInfo[0].metadata[0];
expect(typeof (metadataTest.name)).assertEqual('string');
let bundleInfoTest: bundle.BundleInfo = bundleInfo;
expect(typeof (bundleInfoTest.name)).assertEqual('string');
let usedSceneTest: bundle.UsedScene = bundleInfo.reqPermissionDetails[0].usedScene
expect(typeof (usedSceneTest.abilities[0])).assertEqual('string');
let reqPermissionDetailsTest: bundle.ReqPermissionDetail = bundleInfo.reqPermissionDetails[0]
expect(typeof (reqPermissionDetailsTest.name)).assertEqual('string');
let signatureInfoTest: bundle.SignatureInfo = bundleInfo.signatureInfo;
expect(typeof (signatureInfoTest.appId)).assertEqual('string');
let hapModuleInfoTest: bundle.HapModuleInfo = bundleInfo.hapModulesInfo[0];
expect(typeof (hapModuleInfoTest.name)).assertEqual('string');
let abilityInfoTest: bundle.AbilityInfo = bundleInfo.hapModulesInfo[0].abilitiesInfo[0];
expect(typeof (abilityInfoTest.bundleName)).assertEqual('string');
let windowSizeTest: bundle.WindowSize = bundleInfo.hapModulesInfo[0].abilitiesInfo[0].windowSize;
expect(windowSizeTest.maxWindowRatio).assertEqual(0);
let extensionAbilityInfoTest: bundle.ExtensionAbilityInfo = bundleInfo.hapModulesInfo[0].extensionAbilitiesInfo[0];
expect(typeof (extensionAbilityInfoTest.bundleName)).assertEqual('string');
let elementNameExample = {
deviceId: "123456789",
bundleName: "bundleName",
moduleName:"moduleName",
abilityName: "abilityName",
uri:"uri",
shortName:"shortName"
}
let elementNameTest: bundle.ElementName = elementNameExample;
expect(elementNameTest.deviceId).assertEqual("123456789");
expect(elementNameTest.bundleName).assertEqual("bundleName");
expect(elementNameTest.moduleName).assertEqual("moduleName");
expect(elementNameTest.abilityName).assertEqual("abilityName");
expect(elementNameTest.uri).assertEqual("uri");
expect(elementNameTest.shortName).assertEqual("shortName");
done();
})
})
}
......@@ -15,8 +15,12 @@
import getProfileByAbility from './GetProfileByAbility.test.ets';
import getProfileByExtensionAbility from './GetProfileByExtensionAbility.test.ets';
import getBundleInfoForSelf from './GetBundleInfoForSelf.test.ets';
import getSecondModuleTest from './GetSecondModule.test.ets';
export default function testsuite() {
getProfileByAbility();
getProfileByExtensionAbility();
getBundleInfoForSelf();
getSecondModuleTest();
}
\ 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 class Utils {
static sleep(time) {
return new Promise((resolve, reject) => {
setTimeout((data) => {
resolve(data)
}, time)
}).then(() => {
console.info(`sleep ${time} over...`)
})
}
}
......@@ -4,9 +4,10 @@
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:testModule_entry_dsc",
"mainElement": "MainAbility",
"mainElement": "ohos.acts.bundle.stage.test.MainAbility",
"deviceTypes": [
"default"
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
......@@ -20,6 +21,7 @@
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"launchType": "singleton",
"orientation": "portrait",
"skills": [
{
......@@ -66,7 +68,107 @@
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "standard",
"orientation": "landscape",
"skills": []
},
{
"name": "ohos.acts.bundle.stage.test.MainAbility2",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:testModule_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"launchType": "specified",
"orientation": "landscape_inverted",
"skills": []
},
{
"name": "ohos.acts.bundle.stage.test.MainAbility3",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:testModule_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"launchType": "specified",
"orientation": "portrait_inverted",
"skills": []
},
{
"name": "ohos.acts.bundle.stage.test.MainAbility4",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:testModule_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"launchType": "specified",
"orientation": "auto_rotation",
"skills": []
},
{
"name": "ohos.acts.bundle.stage.test.MainAbility5",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:testModule_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"launchType": "specified",
"orientation": "auto_rotation_landscape",
"skills": []
},
{
"name": "ohos.acts.bundle.stage.test.MainAbility6",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:testModule_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"launchType": "specified",
"orientation": "auto_rotation_portrait",
"skills": []
},
{
"name": "ohos.acts.bundle.stage.test.MainAbility7",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:testModule_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"launchType": "specified",
"orientation": "auto_rotation_restricted",
"skills": []
},
{
"name": "ohos.acts.bundle.stage.test.MainAbility8",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:testModule_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"launchType": "specified",
"orientation": "auto_rotation_landscape_restricted",
"skills": []
},
{
"name": "ohos.acts.bundle.stage.test.MainAbility9",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:testModule_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"launchType": "specified",
"orientation": "auto_rotation_portrait_restricted",
"skills": []
},
{
"name": "ohos.acts.bundle.stage.test.MainAbility10",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:testModule_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"launchType": "specified",
"orientation": "locked",
"skills": []
}
],
......@@ -76,6 +178,7 @@
"descriptionId": 16777219,
"icon": "$media:icon",
"iconId": 16777225,
"label": "$string:entry_label",
"metadata": [
{
"name": "ohos.extension.form",
......@@ -113,11 +216,158 @@
"descriptionId": 16777219,
"icon": "$media:icon",
"iconId": 16777225,
"label": "$string:entry_label",
"name": "Form1",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"type": "form",
"visible": true
},
{
"description": "$string:form_description",
"descriptionId": 16777219,
"icon": "$media:icon",
"iconId": 16777225,
"label": "$string:entry_label",
"name": "workScheduler",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"type": "workScheduler",
"visible": true
},
{
"description": "$string:form_description",
"descriptionId": 16777219,
"icon": "$media:icon",
"iconId": 16777225,
"label": "$string:entry_label",
"name": "inputMethod",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"type": "inputMethod",
"visible": true
},
{
"description": "$string:form_description",
"descriptionId": 16777219,
"icon": "$media:icon",
"iconId": 16777225,
"label": "$string:entry_label",
"name": "accessibility",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"type": "accessibility",
"visible": true
},
{
"description": "$string:form_description",
"descriptionId": 16777219,
"icon": "$media:icon",
"iconId": 16777225,
"label": "$string:entry_label",
"name": "fileShare",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"type": "fileShare",
"visible": true
},
{
"description": "$string:form_description",
"descriptionId": 16777219,
"icon": "$media:icon",
"iconId": 16777225,
"label": "$string:entry_label",
"name": "staticSubscriber",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"type": "staticSubscriber",
"visible": true
},
{
"description": "$string:form_description",
"descriptionId": 16777219,
"icon": "$media:icon",
"iconId": 16777225,
"label": "$string:entry_label",
"name": "wallpaper",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"type": "wallpaper",
"visible": true
},
{
"description": "$string:form_description",
"descriptionId": 16777219,
"icon": "$media:icon",
"iconId": 16777225,
"label": "$string:entry_label",
"name": "backup",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"type": "backup",
"visible": true
},
{
"description": "$string:form_description",
"descriptionId": 16777219,
"icon": "$media:icon",
"iconId": 16777225,
"label": "$string:entry_label",
"name": "window",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"type": "window",
"visible": true
},
{
"description": "$string:form_description",
"descriptionId": 16777219,
"icon": "$media:icon",
"iconId": 16777225,
"label": "$string:entry_label",
"name": "enterpriseAdmin",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"type": "enterpriseAdmin",
"visible": true
},
{
"description": "$string:form_description",
"descriptionId": 16777219,
"icon": "$media:icon",
"iconId": 16777225,
"label": "$string:entry_label",
"name": "thumbnail",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"type": "thumbnail",
"visible": true
},
{
"description": "$string:form_description",
"descriptionId": 16777219,
"icon": "$media:icon",
"iconId": 16777225,
"label": "$string:entry_label",
"name": "preview",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"type": "preview",
"visible": true
}
],
"requestPermissions": [
{
"name": "ohos.permission.GET_BUNDLE_INFO",
"reason": "$string:permission_reason",
"usedScene": {
"abilities": ["MainAbility"],
"when": "always"
}
},
{
"name": "ohos.permission.READ_CALENDAR",
"reason": "$string:permission_reason",
"usedScene": {
"abilities": ["MainAbility"],
"when": "inuse"
}
}
],
"metadata": [
{
"name": "MetaData1",
"value": "MetaDataValue",
"resource": "$profile:shortcuts_config"
}
]
}
}
......@@ -35,6 +35,10 @@
{
"name": "form_FormAbility_label",
"value": "form_label"
},
{
"name": "permission_reason",
"value": "Need permission"
}
]
}
......@@ -18,6 +18,7 @@
#include <cstdlib>
#include <fstream>
#include <gtest/gtest.h>
#include <mutex>
#include <securec.h>
#include <sstream>
#include <string>
......@@ -38,9 +39,12 @@ static int SIX = 6;
static int EIGHT = 8;
static int GARBAGE_LEN = strlen(GARBAGE);
static unsigned BUFFER_SIZE = 8192;
std::mutex gzMutex_;
std::mutex puMutex_;
static unsigned pull(void *desc, unsigned char **buf)
{
std::lock_guard<std::mutex> lock(puMutex_);
static unsigned int next = 0;
static unsigned char dat[] = {0x63, 0, 2, 0};
......@@ -53,12 +57,14 @@ static unsigned pull(void *desc, unsigned char **buf)
static int push(void *desc, unsigned char *buf, unsigned len)
{
std::lock_guard<std::mutex> lock(puMutex_);
buf += len;
return desc != nullptr; /* force error if desc not null */
}
static int TestGzPrintf(gzFile file, const char *format, ...)
{
std::lock_guard<std::mutex> lock(gzMutex_);
va_list va;
int ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册