mirror of
https://gitee.com/openharmony/ability_dmsfwk
synced 2024-11-23 06:20:07 +00:00
commit
6616d15b66
@ -16,9 +16,8 @@
|
||||
|
||||
#define private public
|
||||
#define protected public
|
||||
#include <thread>
|
||||
|
||||
#include "ability_connect_callback_stub.h"
|
||||
#include "device_manager.h"
|
||||
#include "distributed_sched_service.h"
|
||||
#include "distributed_sched_util.h"
|
||||
#include "dtbschedmgr_device_info_storage.h"
|
||||
@ -34,10 +33,10 @@ namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
using namespace OHOS::DistributedHardware;
|
||||
|
||||
namespace {
|
||||
constexpr int32_t STDOUT_FD = 1;
|
||||
constexpr int32_t SLEEP_TIME = 1000;
|
||||
}
|
||||
|
||||
class AbilityConnectCallbackTest : public AAFwk::AbilityConnectionStub {
|
||||
@ -82,6 +81,10 @@ public:
|
||||
|
||||
void AddConnectCount(int32_t uid) const;
|
||||
void DecreaseConnectCount(int32_t uid) const;
|
||||
|
||||
class DeviceInitCallBack : public DmInitCallback {
|
||||
void OnRemoteDied() override;
|
||||
};
|
||||
};
|
||||
|
||||
void AbilityConnectCallbackTest::OnAbilityConnectDone(const AppExecFwk::ElementName& element,
|
||||
@ -106,9 +109,9 @@ void AbilityConnectionWrapperStubTest::OnAbilityDisconnectDone(const AppExecFwk:
|
||||
|
||||
void DistributedSchedConnectTest::SetUpTestCase()
|
||||
{
|
||||
DnetworkAdapter::GetInstance()->Init();
|
||||
DtbschedmgrDeviceInfoStorage::GetInstance().Init();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIME));
|
||||
const std::string pkgName = "DBinderBus_" + std::to_string(getpid());
|
||||
std::shared_ptr<DmInitCallback> initCallback_ = std::make_shared<DeviceInitCallBack>();
|
||||
DeviceManager::GetInstance().InitDeviceManager(pkgName, initCallback_);
|
||||
}
|
||||
|
||||
void DistributedSchedConnectTest::TearDownTestCase()
|
||||
@ -124,6 +127,10 @@ void DistributedSchedConnectTest::TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
void DistributedSchedConnectTest::DeviceInitCallBack::OnRemoteDied()
|
||||
{
|
||||
}
|
||||
|
||||
void DistributedSchedConnectTest::AddSession(const sptr<IRemoteObject>& connect,
|
||||
const std::string& localDeviceId, const std::string& remoteDeviceId, const AAFwk::Want& want) const
|
||||
{
|
||||
|
@ -14,9 +14,6 @@
|
||||
*/
|
||||
|
||||
#include "distributed_sched_continuation_test.h"
|
||||
|
||||
#include <thread>
|
||||
|
||||
#include "distributed_sched_util.h"
|
||||
#include "dtbschedmgr_device_info_storage.h"
|
||||
#include "mock_distributed_sched.h"
|
||||
@ -25,6 +22,7 @@ using namespace testing;
|
||||
using namespace testing::ext;
|
||||
using namespace OHOS::AAFwk;
|
||||
using namespace OHOS::AppExecFwk;
|
||||
using namespace OHOS::DistributedHardware;
|
||||
using string = std::string;
|
||||
|
||||
namespace OHOS {
|
||||
@ -33,15 +31,14 @@ 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;
|
||||
constexpr int32_t SLEEP_TIME = 1000;
|
||||
const string LOCAL_DEVICE_ID = "192.168.43.100";
|
||||
}
|
||||
|
||||
void DSchedContinuationTest::SetUpTestCase()
|
||||
{
|
||||
DnetworkAdapter::GetInstance()->Init();
|
||||
DtbschedmgrDeviceInfoStorage::GetInstance().Init();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIME));
|
||||
const std::string pkgName = "DBinderBus_" + std::to_string(getpid());
|
||||
std::shared_ptr<DmInitCallback> initCallback_ = std::make_shared<DeviceInitCallBack>();
|
||||
DeviceManager::GetInstance().InitDeviceManager(pkgName, initCallback_);
|
||||
}
|
||||
|
||||
void DSchedContinuationTest::TearDownTestCase()
|
||||
@ -59,6 +56,10 @@ void DSchedContinuationTest::TearDown()
|
||||
dschedContinuation_ = nullptr;
|
||||
}
|
||||
|
||||
void DSchedContinuationTest::DeviceInitCallBack::OnRemoteDied()
|
||||
{
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> DSchedContinuationTest::GetDSchedService() const
|
||||
{
|
||||
sptr<IRemoteObject> dsched = new MockDistributedSched();
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "distributed_sched_service.h"
|
||||
#undef private
|
||||
#include "gtest/gtest.h"
|
||||
#include "device_manager.h"
|
||||
#include "dtbschedmgr_log.h"
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "iservice_registry.h"
|
||||
@ -57,6 +58,10 @@ protected:
|
||||
std::shared_ptr<DmsCallbackTask> dmsCallbackTask_;
|
||||
bool timeoutFlag_ = false;
|
||||
bool freeInstallTimeoutFlag_ = false;
|
||||
|
||||
class DeviceInitCallBack : public OHOS::DistributedHardware::DmInitCallback {
|
||||
void OnRemoteDied() override;
|
||||
};
|
||||
};
|
||||
} // namespace DistributedSchedule
|
||||
} // namespace OHOS
|
||||
|
@ -17,6 +17,7 @@
|
||||
#define protected public
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "device_manager.h"
|
||||
#include "distributed_sched_proxy.h"
|
||||
#include "distributed_sched_service.h"
|
||||
#include "distributed_sched_util.h"
|
||||
@ -43,12 +44,12 @@ namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
using namespace AAFwk;
|
||||
using namespace AppExecFwk;
|
||||
using namespace DistributedHardware;
|
||||
namespace {
|
||||
const string LOCAL_DEVICEID = "192.168.43.100";
|
||||
const string REMOTE_DEVICEID = "255.255.255.255";
|
||||
const std::u16string DEVICE_ID = u"192.168.43.100";
|
||||
constexpr int32_t SESSION_ID = 123;
|
||||
constexpr int32_t SLEEP_TIME = 1000;
|
||||
const std::string DMS_MISSION_ID = "dmsMissionId";
|
||||
constexpr int32_t MISSION_ID = 1;
|
||||
const std::string DMS_SRC_NETWORK_ID = "dmsSrcNetworkId";
|
||||
@ -73,13 +74,17 @@ protected:
|
||||
void GetAbilityInfo(const std::string& package, const std::string& name,
|
||||
const std::string& bundleName, const std::string& deviceId,
|
||||
OHOS::AppExecFwk::AbilityInfo& abilityInfo);
|
||||
|
||||
class DeviceInitCallBack : public DmInitCallback {
|
||||
void OnRemoteDied() override;
|
||||
};
|
||||
};
|
||||
|
||||
void DistributedSchedServiceTest::SetUpTestCase()
|
||||
{
|
||||
DnetworkAdapter::GetInstance()->Init();
|
||||
DtbschedmgrDeviceInfoStorage::GetInstance().Init();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIME));
|
||||
const std::string pkgName = "DBinderBus_" + std::to_string(getpid());
|
||||
std::shared_ptr<DmInitCallback> initCallback_ = std::make_shared<DeviceInitCallBack>();
|
||||
DeviceManager::GetInstance().InitDeviceManager(pkgName, initCallback_);
|
||||
}
|
||||
|
||||
void DistributedSchedServiceTest::TearDownTestCase()
|
||||
@ -93,6 +98,9 @@ void DistributedSchedServiceTest::SetUp()
|
||||
void DistributedSchedServiceTest::TearDown()
|
||||
{}
|
||||
|
||||
void DistributedSchedServiceTest::DeviceInitCallBack::OnRemoteDied()
|
||||
{}
|
||||
|
||||
sptr<IDistributedSched> DistributedSchedServiceTest::GetDms()
|
||||
{
|
||||
if (proxy_ != nullptr) {
|
||||
|
Loading…
Reference in New Issue
Block a user