mirror of
https://gitee.com/openharmony/ability_dmsfwk
synced 2024-11-27 00:20:44 +00:00
add bms install info
Signed-off-by: yaoyao <maluyao3@huawei.com>
This commit is contained in:
parent
f7178f9cfb
commit
26f72e963f
@ -12,6 +12,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
declare_args() {
|
||||
dms_path = "//foundation/ability/dmsfwk"
|
||||
dmsfwk_standard_form_share = true
|
||||
dmsfwk_mission_manager = false
|
||||
efficiency_manager_service_enable = false
|
||||
|
@ -16,6 +16,7 @@ import("//build/ohos.gni")
|
||||
import("//build/ohos_var.gni")
|
||||
import("//build/test.gni")
|
||||
import("//foundation/ability/dmsfwk/dmsfwk.gni")
|
||||
import("../../../dmsfwk.gni")
|
||||
|
||||
module_output_path = "dmsfwk/distributedschedsvrtest"
|
||||
|
||||
@ -135,6 +136,11 @@ if (dmsfwk_standard_form_share) {
|
||||
ohos_unittest("distributedschedsvrtest") {
|
||||
module_out_path = module_output_path
|
||||
|
||||
deps = [
|
||||
"${dms_path}/test/sceneProject/unittest/bundle_dependencies/bmsThirdBundle:bmsThirdBundle",
|
||||
"${dms_path}/test/sceneProject/unittest/ohos_test:copy_ohos_test",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"unittest/distributed_sched_adapter_test.cpp",
|
||||
"unittest/distributed_sched_dumper_test.cpp",
|
||||
@ -205,7 +211,6 @@ ohos_unittest("dmsfreeinstallcbtest") {
|
||||
|
||||
ohos_unittest("dschedcontinuetest") {
|
||||
module_out_path = module_output_path
|
||||
|
||||
sources = [
|
||||
"unittest/distributed_sched_continuation_test.cpp",
|
||||
"unittest/dms_version_manager_test.cpp",
|
||||
@ -223,6 +228,11 @@ ohos_unittest("dschedcontinuetest") {
|
||||
public_deps = dsched_public_deps
|
||||
}
|
||||
|
||||
deps = [
|
||||
"${dms_path}/test/sceneProject/unittest/bundle_dependencies/bmsThirdBundle:bmsThirdBundle",
|
||||
"${dms_path}/test/sceneProject/unittest/ohos_test:copy_ohos_test",
|
||||
]
|
||||
|
||||
if (dmsfwk_mission_manager) {
|
||||
defines = [ "SUPPORT_DISTRIBUTED_MISSION_MANAGER" ]
|
||||
}
|
||||
@ -311,7 +321,11 @@ ohos_unittest("bundlemanagerinternaltest") {
|
||||
"//foundation/ability/dmsfwk/services/dtbschedmgr/test/resource:coverage_flags",
|
||||
]
|
||||
configs += dsched_configs
|
||||
deps = [ "${distributed_service}/dtbschedmgr:distributedschedsvr" ]
|
||||
deps = [
|
||||
"${distributed_service}/dtbschedmgr:distributedschedsvr",
|
||||
"${dms_path}/test/sceneProject/unittest/bundle_dependencies/bmsThirdBundle:bmsThirdBundle",
|
||||
"${dms_path}/test/sceneProject/unittest/ohos_test:copy_ohos_test",
|
||||
]
|
||||
if (is_standard_system) {
|
||||
external_deps = dsched_external_deps
|
||||
public_deps = dsched_public_deps
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-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
|
||||
@ -13,6 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <thread>
|
||||
|
||||
#include "bundle_manager_internal_test.h"
|
||||
#include "bundle/bundle_manager_internal.h"
|
||||
|
||||
@ -20,6 +22,7 @@
|
||||
#include "bundle/bundle_manager_callback_stub.h"
|
||||
#undef private
|
||||
|
||||
#include "distributed_sched_util.h"
|
||||
#include "dtbschedmgr_log.h"
|
||||
#include "test_log.h"
|
||||
|
||||
@ -30,11 +33,14 @@ namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
namespace {
|
||||
const string GROUP_ID = "TEST_GROUP_ID";
|
||||
constexpr int32_t SLEEP_TIME = 1000;
|
||||
}
|
||||
|
||||
void BundleManagerInternalTest::SetUpTestCase()
|
||||
{
|
||||
DTEST_LOG << "BundleManagerInternalTest::SetUpTestCase" << std::endl;
|
||||
DistributedSchedUtil::InstallThirdPartyHap();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIME));
|
||||
}
|
||||
|
||||
void BundleManagerInternalTest::TearDownTestCase()
|
||||
@ -136,7 +142,7 @@ HWTEST_F(BundleManagerInternalTest, BundleManagerInternalTest_005, TestSize.Leve
|
||||
{
|
||||
DTEST_LOG << "BundleManagerInternalTest BundleManagerInternalTest_005 begin" << std::endl;
|
||||
string deviceId = "123456";
|
||||
string bundleName = "ohos.samples.distributedcalc";
|
||||
string bundleName = "com.third.hiworld.example";
|
||||
AppExecFwk::DistributedBundleInfo remoteBundleInfo;
|
||||
int ret = BundleManagerInternal::CheckRemoteBundleInfoForContinuation(deviceId, bundleName, remoteBundleInfo);
|
||||
EXPECT_TRUE(CONTINUE_REMOTE_UNINSTALLED_UNSUPPORT_FREEINSTALL == ret);
|
||||
@ -153,9 +159,9 @@ HWTEST_F(BundleManagerInternalTest, BundleManagerInternalTest_006, TestSize.Leve
|
||||
{
|
||||
DTEST_LOG << "BundleManagerInternalTest BundleManagerInternalTest_006 begin" << std::endl;
|
||||
string deviceId = "123456";
|
||||
string bundleName = "ohos.samples.distributedcalc";
|
||||
string bundleName = "com.third.hiworld.example";
|
||||
string moduleName = "entry";
|
||||
string abilityName = "MainAbility";
|
||||
string abilityName = "bmsThirdBundle";
|
||||
AAFwk::Want want;
|
||||
want.SetElementName(deviceId, bundleName, abilityName, moduleName);
|
||||
int32_t missionId = 0;
|
||||
|
@ -12,6 +12,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <thread>
|
||||
|
||||
#include "distributed_sched_continuation_test.h"
|
||||
#include "distributed_sched_util.h"
|
||||
@ -25,7 +26,6 @@ using namespace testing::ext;
|
||||
using namespace OHOS::AAFwk;
|
||||
using namespace OHOS::AppExecFwk;
|
||||
using namespace OHOS::DistributedHardware;
|
||||
using string = std::string;
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
@ -33,7 +33,8 @@ namespace {
|
||||
const std::u16string MOCK_DEVICE_ID = u"MOCK_DEVICE_ID";
|
||||
constexpr int32_t MOCK_SESSION_ID = 123;
|
||||
constexpr int32_t MOCK_TASK_ID = 456;
|
||||
const string LOCAL_DEVICE_ID = "192.168.43.100";
|
||||
const std::string LOCAL_DEVICE_ID = "192.168.43.100";
|
||||
constexpr int32_t SLEEP_TIME = 1000;
|
||||
}
|
||||
|
||||
void DSchedContinuationTest::SetUpTestCase()
|
||||
@ -44,6 +45,8 @@ void DSchedContinuationTest::SetUpTestCase()
|
||||
const std::string pkgName = "DBinderBus_" + std::to_string(getpid());
|
||||
std::shared_ptr<DmInitCallback> initCallback_ = std::make_shared<DeviceInitCallBack>();
|
||||
DeviceManager::GetInstance().InitDeviceManager(pkgName, initCallback_);
|
||||
DistributedSchedUtil::InstallThirdPartyHap();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIME));
|
||||
}
|
||||
|
||||
void DSchedContinuationTest::TearDownTestCase()
|
||||
@ -82,7 +85,8 @@ int32_t DSchedContinuationTest::PushAbilityToken()
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
std::shared_ptr<Want> DSchedContinuationTest::MockWant(const string& bundleName, const string& ability, int32_t flags)
|
||||
std::shared_ptr<Want> DSchedContinuationTest::MockWant(const std::string& bundleName,
|
||||
const std::string& ability, int32_t flags)
|
||||
{
|
||||
ElementName element("", bundleName, ability);
|
||||
std::shared_ptr<Want> spWant = std::make_shared<Want>();
|
||||
@ -115,9 +119,9 @@ sptr<IDistributedSched> DSchedContinuationTest::GetDms()
|
||||
|
||||
int32_t DSchedContinuationTest::StartContinuation(int32_t missionId, int32_t flags)
|
||||
{
|
||||
string bundleName = "bundleName";
|
||||
string abilityName = "abilityName";
|
||||
string devId = "devId";
|
||||
std::string bundleName = "bundleName";
|
||||
std::string abilityName = "abilityName";
|
||||
std::string devId = "devId";
|
||||
std::shared_ptr<Want> spWant = MockWant(bundleName, abilityName, flags);
|
||||
int callerUid = 0;
|
||||
return DistributedSchedService::GetInstance().StartContinuation(*spWant, missionId, callerUid, 0, 0);
|
||||
@ -125,9 +129,9 @@ int32_t DSchedContinuationTest::StartContinuation(int32_t missionId, int32_t fla
|
||||
|
||||
int32_t DSchedContinuationTest::StartRemoteFreeInstall(int32_t flags, const sptr<IRemoteObject>& callback)
|
||||
{
|
||||
string bundleName = "bundleName";
|
||||
string abilityName = "abilityName";
|
||||
string devId = "devId";
|
||||
std::string bundleName = "bundleName";
|
||||
std::string abilityName = "abilityName";
|
||||
std::string devId = "devId";
|
||||
std::shared_ptr<Want> spWant = MockWant(bundleName, abilityName, flags);
|
||||
int callerUid = 0;
|
||||
return DistributedSchedService::GetInstance().StartRemoteFreeInstall(*spWant, callerUid, 0, 0, callback);
|
||||
@ -303,8 +307,8 @@ HWTEST_F(DSchedContinuationTest, SetWantForContinuation_001, TestSize.Level1)
|
||||
* @tc.steps: step1. input invalid bundleName.
|
||||
* @tc.expected: step1. return err.
|
||||
*/
|
||||
string bundleName = "bundleName";
|
||||
string abilityName = "abilityName";
|
||||
std::string bundleName = "bundleName";
|
||||
std::string abilityName = "abilityName";
|
||||
std::shared_ptr<Want> spWant = MockWant(bundleName, abilityName, 0);
|
||||
int32_t missionId = 0;
|
||||
int32_t ret = DistributedSchedService::GetInstance().SetWantForContinuation(*spWant, missionId);
|
||||
@ -324,8 +328,8 @@ HWTEST_F(DSchedContinuationTest, SetWantForContinuation_002, TestSize.Level1)
|
||||
* @tc.steps: step1. input valid bundleName.
|
||||
* @tc.expected: step1. return OK.
|
||||
*/
|
||||
string bundleName = "ohos.samples.distributedcalc";
|
||||
string abilityName = "MainAbility";
|
||||
std::string bundleName = "com.third.hiworld.example";
|
||||
std::string abilityName = "bmsThirdBundle";
|
||||
std::shared_ptr<Want> spWant = MockWant(bundleName, abilityName, 0);
|
||||
int32_t missionId = 0;
|
||||
int32_t ret = DistributedSchedService::GetInstance().SetWantForContinuation(*spWant, missionId);
|
||||
@ -345,7 +349,7 @@ HWTEST_F(DSchedContinuationTest, ContinueLocalMission_001, TestSize.Level1)
|
||||
* @tc.steps: step1. input invalid missionId.
|
||||
* @tc.expected: step1. return err.
|
||||
*/
|
||||
string deviceId = "123456";
|
||||
std::string deviceId = "123456";
|
||||
int32_t missionId = 0;
|
||||
auto callback = GetDSchedService();
|
||||
WantParams wantParams;
|
||||
@ -367,7 +371,7 @@ HWTEST_F(DSchedContinuationTest, ContinueLocalMission_002, TestSize.Level1)
|
||||
* @tc.steps: step1. input invalid mission.
|
||||
* @tc.expected: step1. return err.
|
||||
*/
|
||||
string deviceId = "123456";
|
||||
std::string deviceId = "123456";
|
||||
int32_t missionId = 0;
|
||||
auto callback = GetDSchedService();
|
||||
WantParams wantParams;
|
||||
@ -391,7 +395,7 @@ HWTEST_F(DSchedContinuationTest, ContinueLocalMission_002, TestSize.Level1)
|
||||
HWTEST_F(DSchedContinuationTest, ContinueLocalMission_003, TestSize.Level1)
|
||||
{
|
||||
DTEST_LOG << "DSchedContinuationTest ContinueLocalMission_003 start" << std::endl;
|
||||
string deviceId = "123456";
|
||||
std::string deviceId = "123456";
|
||||
int32_t missionId = -1;
|
||||
auto callback = GetDSchedService();
|
||||
WantParams wantParams;
|
||||
@ -411,7 +415,7 @@ HWTEST_F(DSchedContinuationTest, ContinueLocalMission_003, TestSize.Level1)
|
||||
HWTEST_F(DSchedContinuationTest, ContinueLocalMission_004, TestSize.Level1)
|
||||
{
|
||||
DTEST_LOG << "DSchedContinuationTest ContinueLocalMission_004 start" << std::endl;
|
||||
string deviceId;
|
||||
std::string deviceId;
|
||||
int32_t missionId = -1;
|
||||
auto callback = GetDSchedService();
|
||||
WantParams wantParams;
|
||||
@ -434,8 +438,8 @@ HWTEST_F(DSchedContinuationTest, ContinueRemoteMission_001, TestSize.Level1)
|
||||
* @tc.steps: step1. input invalid deviceId.
|
||||
* @tc.expected: step1. return err.
|
||||
*/
|
||||
string srcDeviceId = "123456";
|
||||
string dstDeviceid = "123456";
|
||||
std::string srcDeviceId = "123456";
|
||||
std::string dstDeviceid = "123456";
|
||||
int32_t missionId = 0;
|
||||
auto callback = GetDSchedService();
|
||||
WantParams wantParams;
|
||||
@ -457,9 +461,9 @@ HWTEST_F(DSchedContinuationTest, ContinueRemoteMission_002, TestSize.Level1)
|
||||
* @tc.steps: step1. input invalid param.
|
||||
* @tc.expected: step1. return err.
|
||||
*/
|
||||
string srcDeviceId;
|
||||
std::string srcDeviceId;
|
||||
DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(srcDeviceId);
|
||||
string dstDeviceid = "123456";
|
||||
std::string dstDeviceid = "123456";
|
||||
int32_t missionId = 0;
|
||||
auto callback = GetDSchedService();
|
||||
WantParams wantParams;
|
||||
@ -1394,8 +1398,8 @@ HWTEST_F(DSchedContinuationTest, ProxyCallStartRemoteAbilityByCall001, TestSize.
|
||||
if (proxy == nullptr) {
|
||||
return;
|
||||
}
|
||||
string bundleName = "bundleName";
|
||||
string abilityName = "abilityName";
|
||||
std::string bundleName = "bundleName";
|
||||
std::string abilityName = "abilityName";
|
||||
std::shared_ptr<Want> spWant = MockWant(bundleName, abilityName, 0);
|
||||
int32_t ret = proxy->StartRemoteAbilityByCall(*spWant, nullptr, 0, 0, 1);
|
||||
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
|
||||
@ -1415,8 +1419,8 @@ HWTEST_F(DSchedContinuationTest, ProxyCallStartRemoteAbilityByCall002, TestSize.
|
||||
if (proxy == nullptr) {
|
||||
return;
|
||||
}
|
||||
string bundleName = "bundleName";
|
||||
string abilityName = "abilityName";
|
||||
std::string bundleName = "bundleName";
|
||||
std::string abilityName = "abilityName";
|
||||
std::shared_ptr<Want> spWant = MockWant(bundleName, abilityName, 0);
|
||||
int32_t ret = proxy->StartRemoteAbilityByCall(*spWant, GetDSchedService(), 0, 0, 1);
|
||||
EXPECT_NE(ret, ERR_NULL_OBJECT);
|
||||
@ -1477,8 +1481,8 @@ HWTEST_F(DSchedContinuationTest, ProxyCallStartAbilityByCallFromRemote001, TestS
|
||||
return;
|
||||
}
|
||||
// mock want
|
||||
string bundleName = "bundleName";
|
||||
string abilityName = "abilityName";
|
||||
std::string bundleName = "bundleName";
|
||||
std::string abilityName = "abilityName";
|
||||
std::shared_ptr<Want> spWant = MockWant(bundleName, abilityName, 0);
|
||||
// mock callerinfo
|
||||
CallerInfo callerInfo;
|
||||
@ -1509,8 +1513,8 @@ HWTEST_F(DSchedContinuationTest, ProxyCallStartAbilityByCallFromRemote002, TestS
|
||||
return;
|
||||
}
|
||||
// mock want
|
||||
string bundleName = "bundleName";
|
||||
string abilityName = "abilityName";
|
||||
std::string bundleName = "bundleName";
|
||||
std::string abilityName = "abilityName";
|
||||
std::shared_ptr<Want> spWant = MockWant(bundleName, abilityName, 0);
|
||||
// mock callerinfo
|
||||
CallerInfo callerInfo;
|
||||
@ -1593,8 +1597,8 @@ HWTEST_F(DSchedContinuationTest, ProxyCallStartRemoteFreeInstall001, TestSize.Le
|
||||
return;
|
||||
}
|
||||
// mock want
|
||||
string bundleName = "bundleName";
|
||||
string abilityName = "abilityName";
|
||||
std::string bundleName = "bundleName";
|
||||
std::string abilityName = "abilityName";
|
||||
std::shared_ptr<Want> spWant = MockWant(bundleName, abilityName, 0);
|
||||
|
||||
int32_t ret = proxy->StartRemoteFreeInstall(*spWant, 0, 1, 1, GetDSchedService());
|
||||
@ -1616,8 +1620,8 @@ HWTEST_F(DSchedContinuationTest, ProxyCallStartRemoteFreeInstall002, TestSize.Le
|
||||
return;
|
||||
}
|
||||
// mock want
|
||||
string bundleName = "bundleName";
|
||||
string abilityName = "abilityName";
|
||||
std::string bundleName = "bundleName";
|
||||
std::string abilityName = "abilityName";
|
||||
std::shared_ptr<Want> spWant = MockWant(bundleName, abilityName, 0);
|
||||
|
||||
int32_t ret = proxy->StartRemoteFreeInstall(*spWant, 0, 1, 1, nullptr);
|
||||
|
@ -12,6 +12,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <thread>
|
||||
|
||||
#define private public
|
||||
#define protected public
|
||||
@ -59,6 +60,7 @@ namespace {
|
||||
const string ABILITY_NAME = "com.ohos.launcher.MainAbility";
|
||||
const string BUNDLE_NAME = "com.ohos.launcher";
|
||||
const string DMS_IS_CALLER_BACKGROUND = "dmsIsCallerBackGround";
|
||||
constexpr int32_t SLEEP_TIME = 1000;
|
||||
}
|
||||
|
||||
class DistributedSchedServiceTest : public testing::Test {
|
||||
@ -68,6 +70,7 @@ public:
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
sptr<IDistributedSched> GetDms();
|
||||
int32_t InstallBundle(const std::string &bundlePath) const;
|
||||
sptr<IDistributedSched> proxy_;
|
||||
|
||||
protected:
|
||||
@ -93,6 +96,8 @@ void DistributedSchedServiceTest::SetUpTestCase()
|
||||
const std::string pkgName = "DBinderBus_" + std::to_string(getpid());
|
||||
std::shared_ptr<DmInitCallback> initCallback_ = std::make_shared<DeviceInitCallBack>();
|
||||
DeviceManager::GetInstance().InitDeviceManager(pkgName, initCallback_);
|
||||
DistributedSchedUtil::InstallThirdPartyHap();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIME));
|
||||
}
|
||||
|
||||
void DistributedSchedServiceTest::TearDownTestCase()
|
||||
@ -1179,8 +1184,8 @@ HWTEST_F(DistributedSchedServiceTest, SendResultFromRemote_007, TestSize.Level3)
|
||||
std::string localDeviceId;
|
||||
DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDeviceId);
|
||||
want.SetParam(DMS_SRC_NETWORK_ID, localDeviceId);
|
||||
AppExecFwk::ElementName element(localDeviceId, "ohos.samples.distributedcalc",
|
||||
"ohos.samples.distributedcalc.MainAbility");
|
||||
AppExecFwk::ElementName element(localDeviceId, "com.third.hiworld.example",
|
||||
"bmsThirdBundle");
|
||||
want.SetElement(element);
|
||||
CallerInfo callerInfo;
|
||||
callerInfo.uid = 0;
|
||||
@ -1204,15 +1209,15 @@ HWTEST_F(DistributedSchedServiceTest, StartAbilityByCallFromRemote_001, TestSize
|
||||
AAFwk::Want want;
|
||||
std::string localDeviceId;
|
||||
DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDeviceId);
|
||||
AppExecFwk::ElementName element(localDeviceId, "ohos.samples.distributedcalc",
|
||||
"ohos.samples.distributedcalc.MainAbility");
|
||||
AppExecFwk::ElementName element(localDeviceId, "com.third.hiworld.example",
|
||||
"bmsThirdBundle");
|
||||
want.SetElement(element);
|
||||
want.SetParam(DMS_IS_CALLER_BACKGROUND, false);
|
||||
sptr<IRemoteObject> connect = new MockDistributedSched();
|
||||
CallerInfo callerInfo;
|
||||
callerInfo.uid = 0;
|
||||
callerInfo.sourceDeviceId = LOCAL_DEVICEID;
|
||||
bool result = BundleManagerInternal::GetCallerAppIdFromBms("ohos.samples.distributedcalc",
|
||||
bool result = BundleManagerInternal::GetCallerAppIdFromBms("com.third.hiworld.example",
|
||||
callerInfo.callerAppId);
|
||||
EXPECT_EQ(result, true);
|
||||
IDistributedSched::AccountInfo accountInfo;
|
||||
@ -1235,8 +1240,8 @@ HWTEST_F(DistributedSchedServiceTest, StartAbilityByCallFromRemote_002, TestSize
|
||||
AAFwk::Want want;
|
||||
std::string localDeviceId;
|
||||
DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDeviceId);
|
||||
AppExecFwk::ElementName element(localDeviceId, "ohos.samples.distributedcalc",
|
||||
"ohos.samples.distributedcalc.MainAbility");
|
||||
AppExecFwk::ElementName element(localDeviceId, "com.third.hiworld.example",
|
||||
"bmsThirdBundle");
|
||||
want.SetElement(element);
|
||||
want.SetParam(DMS_IS_CALLER_BACKGROUND, false);
|
||||
sptr<IRemoteObject> connect = new MockDistributedSched();
|
||||
@ -1332,7 +1337,7 @@ HWTEST_F(DistributedSchedServiceTest, StartLocalAbility_005, TestSize.Level3)
|
||||
AAFwk::Want want;
|
||||
std::string localDeviceId;
|
||||
DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDeviceId);
|
||||
AppExecFwk::ElementName element(localDeviceId, "com.ohos.note", "MainAbility");
|
||||
AppExecFwk::ElementName element(localDeviceId, "com.third.hiworld.example", "bmsThirdBundle");
|
||||
want.SetElement(element);
|
||||
want.SetParam(DMS_IS_CALLER_BACKGROUND, false);
|
||||
AppExecFwk::AbilityInfo abilityInfo;
|
||||
@ -1340,7 +1345,7 @@ HWTEST_F(DistributedSchedServiceTest, StartLocalAbility_005, TestSize.Level3)
|
||||
CallerInfo callerInfo;
|
||||
callerInfo.uid = 0;
|
||||
callerInfo.sourceDeviceId = LOCAL_DEVICEID;
|
||||
bool result = BundleManagerInternal::GetCallerAppIdFromBms("com.ohos.note", callerInfo.callerAppId);
|
||||
bool result = BundleManagerInternal::GetCallerAppIdFromBms("com.third.hiworld.example", callerInfo.callerAppId);
|
||||
EXPECT_TRUE(result);
|
||||
IDistributedSched::AccountInfo accountInfo;
|
||||
accountInfo.accountType = IDistributedSched::SAME_ACCOUNT_TYPE;
|
||||
|
@ -15,20 +15,66 @@
|
||||
|
||||
#include "distributed_sched_util.h"
|
||||
|
||||
#include <future>
|
||||
|
||||
#include "accesstoken_kit.h"
|
||||
#include "bundle_installer_interface.h"
|
||||
#include "dtbschedmgr_log.h"
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "nativetoken_kit.h"
|
||||
#include "nocopyable.h"
|
||||
#include "status_receiver_host.h"
|
||||
#include "status_receiver_interface.h"
|
||||
#include "system_ability_definition.h"
|
||||
#include "token_setproc.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
using namespace AppExecFwk;
|
||||
namespace {
|
||||
const std::string TAG = "DistributedSchedUtil";
|
||||
const std::string TAG = "DistributedSchedUtil";
|
||||
const std::string HAP_FILE_PATH = "/data/test/resource/dmsfwk/resource/bmsThirdBundle.hap";
|
||||
const char* DISTSCHED_PROCESS_NAME = "distributedsched";
|
||||
constexpr int32_t DMS_LOAD_SA_TIMEOUT_MS = 10000;
|
||||
constexpr int32_t USER_ID = 100;
|
||||
constexpr int32_t FAILED_RETURN = -1;
|
||||
}
|
||||
|
||||
class StatusReceiverImpl : public StatusReceiverHost {
|
||||
public:
|
||||
StatusReceiverImpl();
|
||||
~StatusReceiverImpl() override;
|
||||
void OnStatusNotify(const int progress) override;
|
||||
void OnFinished(const int32_t resultCode, const std::string &resultMsg) override;
|
||||
|
||||
private:
|
||||
mutable std::promise<std::string> resultMsgSignal_;
|
||||
int iProgress_ = 0;
|
||||
|
||||
DISALLOW_COPY_AND_MOVE(StatusReceiverImpl);
|
||||
};
|
||||
|
||||
StatusReceiverImpl::StatusReceiverImpl()
|
||||
{
|
||||
HILOGI("create status receiver instance");
|
||||
}
|
||||
|
||||
StatusReceiverImpl::~StatusReceiverImpl()
|
||||
{
|
||||
HILOGI("destroy status receiver instance");
|
||||
}
|
||||
|
||||
void StatusReceiverImpl::OnStatusNotify(const int progress)
|
||||
{
|
||||
iProgress_ = progress;
|
||||
HILOGI("OnStatusNotify progress:%{public}d", progress);
|
||||
}
|
||||
|
||||
void StatusReceiverImpl::OnFinished(const int32_t resultCode, const std::string &resultMsg)
|
||||
{
|
||||
HILOGI("on finished result is %{public}d, %{public}s", resultCode, resultMsg.c_str());
|
||||
resultMsgSignal_.set_value(resultMsg);
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> DistributedSchedUtil::remote_ = nullptr;
|
||||
@ -48,6 +94,46 @@ void DistributedSchedUtil::MockProcess(const char* processName)
|
||||
MockProcessAndPermission(processName);
|
||||
}
|
||||
|
||||
sptr<AppExecFwk::IBundleMgr> DistributedSchedUtil::GetBundleManager()
|
||||
{
|
||||
sptr<ISystemAbilityManager> samgrProxy = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (samgrProxy == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
sptr<IRemoteObject> bmsProxy = samgrProxy->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID);
|
||||
if (bmsProxy == nullptr) {
|
||||
HILOGE("failed to get bms from samgr");
|
||||
return nullptr;
|
||||
}
|
||||
return iface_cast<AppExecFwk::IBundleMgr>(bmsProxy);
|
||||
}
|
||||
|
||||
int32_t DistributedSchedUtil::InstallThirdPartyHap()
|
||||
{
|
||||
auto bms = GetBundleManager();
|
||||
if (bms == nullptr) {
|
||||
HILOGE("bms is null");
|
||||
return FAILED_RETURN;
|
||||
}
|
||||
auto installer = bms->GetBundleInstaller();
|
||||
if (!installer) {
|
||||
HILOGE("installer is null");
|
||||
return FAILED_RETURN;
|
||||
}
|
||||
InstallParam installParam;
|
||||
installParam.installFlag = InstallFlag::NORMAL;
|
||||
installParam.userId = USER_ID;
|
||||
sptr<StatusReceiverImpl> statusReceiver(new (std::nothrow) StatusReceiverImpl());
|
||||
if (!statusReceiver) {
|
||||
return FAILED_RETURN;
|
||||
}
|
||||
bool result = installer->Install(HAP_FILE_PATH, installParam, statusReceiver);
|
||||
if (!result) {
|
||||
return FAILED_RETURN;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DistributedSchedUtil::MockProcessAndPermission(const char* processName, const char *perms[], int32_t permsNum)
|
||||
{
|
||||
uint64_t tokenId;
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <cstdint>
|
||||
#include <mutex>
|
||||
|
||||
#include "bundle_mgr_interface.h"
|
||||
#include "iremote_object.h"
|
||||
#include "system_ability_load_callback_stub.h"
|
||||
|
||||
@ -33,6 +34,8 @@ public:
|
||||
static bool LoadDistributedSchedService();
|
||||
static void LoadSystemAbilitySuccessNotify(const sptr<IRemoteObject>& remoteObject);
|
||||
static void LoadSystemAbilityFailNotify();
|
||||
static sptr<AppExecFwk::IBundleMgr> GetBundleManager();
|
||||
static int32_t InstallThirdPartyHap();
|
||||
|
||||
static std::mutex remoteMutex_;
|
||||
static sptr<IRemoteObject> remote_;
|
||||
|
BIN
test/sceneProject/signature/com.third.hiworld.example.p7b
Normal file
BIN
test/sceneProject/signature/com.third.hiworld.example.p7b
Normal file
Binary file not shown.
22
test/sceneProject/unittest/bundle_dependencies/BUILD.gn
Normal file
22
test/sceneProject/unittest/bundle_dependencies/BUILD.gn
Normal file
@ -0,0 +1,22 @@
|
||||
# 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.
|
||||
|
||||
group("bundle_dependencies") {
|
||||
testonly = true
|
||||
deps = []
|
||||
|
||||
deps += [
|
||||
# deps file
|
||||
"dependencies_entry:dependencies_entry",
|
||||
]
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
# 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("//build/ohos.gni")
|
||||
import("../../../../../dmsfwk.gni")
|
||||
|
||||
ohos_hap("bmsThirdBundle") {
|
||||
hap_profile = "./src/main/config.json"
|
||||
hap_name = "bmsThirdBundle"
|
||||
subsystem_name = "bundlemanager"
|
||||
final_hap_path = "$root_out_dir/tests/unittest/dmsfwk/distributedschedsvrtest/resource/${hap_name}.hap"
|
||||
testonly = true
|
||||
deps = [
|
||||
":hjs_demo_js_assets",
|
||||
":hjs_demo_resources",
|
||||
]
|
||||
certificate_profile =
|
||||
"${dms_path}/test/sceneProject/signature/com.third.hiworld.example.p7b"
|
||||
}
|
||||
ohos_js_assets("hjs_demo_js_assets") {
|
||||
source_dir = "./src/main/js/default"
|
||||
}
|
||||
ohos_resources("hjs_demo_resources") {
|
||||
sources = [ "./src/main/js/resources" ]
|
||||
hap_profile = "./src/main/config.json"
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
{
|
||||
"app": {
|
||||
"bundleName": "com.third.hiworld.example",
|
||||
"vendor": "example",
|
||||
"version": {
|
||||
"code": 1,
|
||||
"name": "1.0"
|
||||
},
|
||||
"apiVersion": {
|
||||
"compatible": 3,
|
||||
"target": 3
|
||||
}
|
||||
},
|
||||
"deviceConfig": {
|
||||
"default": {}
|
||||
},
|
||||
"module": {
|
||||
"package": "com.third.hiworld.example.hap",
|
||||
"name": "bmsThirdBundle",
|
||||
"deviceType": [
|
||||
"tablet",
|
||||
"default",
|
||||
"tv",
|
||||
"car"
|
||||
],
|
||||
"distro": {
|
||||
"deliveryWithInstall": true,
|
||||
"moduleName": "testability",
|
||||
"moduleType": "entry"
|
||||
},
|
||||
"abilities": [
|
||||
{
|
||||
"name": "bmsThirdBundle",
|
||||
"icon": "$media:snowball",
|
||||
"label": "bmsThirdBundle Ability",
|
||||
"launchType": "singleton",
|
||||
"orientation": "unspecified",
|
||||
"type": "page",
|
||||
"visible": true
|
||||
}
|
||||
],
|
||||
"js": [
|
||||
{
|
||||
"pages": [
|
||||
"pages/index/index"
|
||||
],
|
||||
"name": "default",
|
||||
"window": {
|
||||
"designWidth": 720,
|
||||
"autoDesignWidth": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
export default {
|
||||
onCreate() {
|
||||
console.info('AceApplication onCreate');
|
||||
},
|
||||
onDestroy() {
|
||||
console.info('AceApplication onDestroy');
|
||||
}
|
||||
};
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"strings": {
|
||||
"hello": "Hello",
|
||||
"world": "World"
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"strings": {
|
||||
"hello": "您好",
|
||||
"world": "世界"
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
.container {
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 100px;
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<div class="container">
|
||||
<text class="title">
|
||||
{{ $t('strings.hello') }} {{ title }}
|
||||
</text>
|
||||
</div>
|
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
const injectRef = Object.getPrototypeOf(global) || global
|
||||
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
|
||||
|
||||
export default {
|
||||
data: {
|
||||
title: ""
|
||||
},
|
||||
onInit() {
|
||||
this.title = this.$t('strings.world');
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "entry_MainAbility",
|
||||
"value": "bmsfirstright"
|
||||
},
|
||||
{
|
||||
"name": "mainability_description",
|
||||
"value": "JS_Phone_Empty Feature Ability"
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 6.2 KiB |
23
test/sceneProject/unittest/ohos_test/BUILD.gn
Normal file
23
test/sceneProject/unittest/ohos_test/BUILD.gn
Normal file
@ -0,0 +1,23 @@
|
||||
# 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("//build/ohos.gni")
|
||||
|
||||
ohos_copy("copy_ohos_test") {
|
||||
sources = [ "./ohos_test.xml" ]
|
||||
outputs = [
|
||||
"$root_out_dir/tests/unittest/dmsfwk/distributedschedsvrtest/ohos_test.xml",
|
||||
]
|
||||
part_name = "dmsfwk"
|
||||
subsystem_name = "ability"
|
||||
}
|
31
test/sceneProject/unittest/ohos_test/ohos_test.xml
Normal file
31
test/sceneProject/unittest/ohos_test/ohos_test.xml
Normal file
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--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.
|
||||
-->
|
||||
<configuration ver="2.0">
|
||||
<target name="distributedschedsvrtest">
|
||||
<preparer>
|
||||
<option name="push" value="resource/bmsThirdBundle1.hap -> /data/test/resource/dmsfwk/resource/" src="res"/>
|
||||
</preparer>
|
||||
</target>
|
||||
<target name="bundlemanagerinternaltest">
|
||||
<preparer>
|
||||
<option name="push" value="resource/bmsThirdBundle1.hap -> /data/test/resource/dmsfwk/resource/" src="res"/>
|
||||
</preparer>
|
||||
</target>
|
||||
<target name="dschedcontinuetest">
|
||||
<preparer>
|
||||
<option name="push" value="resource/bmsThirdBundle1.hap -> /data/test/resource/dmsfwk/resource/" src="res"/>
|
||||
</preparer>
|
||||
</target>
|
||||
</configuration>
|
Loading…
Reference in New Issue
Block a user