mirror of
https://gitee.com/openharmony/ability_dmsfwk
synced 2024-11-23 06:20:07 +00:00
补充ut
Signed-off-by: 师皓杰 <shihaojie10@huawei.com>
This commit is contained in:
parent
c01f4d089d
commit
b0acba7f39
@ -254,9 +254,7 @@ HWTEST_F(DistributedSchedUtilsTest, IsInt32_001, TestSize.Level1)
|
||||
EXPECT_FALSE(ret);
|
||||
|
||||
cJSON *paramValue = cJSON_CreateObject();
|
||||
if (paramValue == nullptr) {
|
||||
return;
|
||||
}
|
||||
ASSERT_NE(paramValue, nullptr);
|
||||
int32_t data = MAX_TEST_PATH_LEN;
|
||||
cJSON_AddNumberToObject(paramValue, "data", data);
|
||||
ret = IsInt32(paramValue);
|
||||
@ -281,12 +279,8 @@ HWTEST_F(DistributedSchedUtilsTest, IsString_001, TestSize.Level1)
|
||||
bool ret = IsString(nullptr);
|
||||
EXPECT_FALSE(ret);
|
||||
|
||||
cJSON *paramValue = nullptr;
|
||||
std::string str("string");
|
||||
paramValue = cJSON_Parse(str.c_str());
|
||||
if (paramValue == nullptr) {
|
||||
return;
|
||||
}
|
||||
cJSON *paramValue = cJSON_CreateString("test string");
|
||||
ASSERT_NE(paramValue, nullptr);
|
||||
ret = IsString(paramValue);
|
||||
EXPECT_TRUE(ret);
|
||||
if (paramValue != nullptr) {
|
||||
@ -304,9 +298,7 @@ HWTEST_F(DistributedSchedUtilsTest, IsString_001, TestSize.Level1)
|
||||
HWTEST_F(DistributedSchedUtilsTest, IsString_002, TestSize.Level1)
|
||||
{
|
||||
cJSON *paramValue = cJSON_CreateObject();
|
||||
if (paramValue == nullptr) {
|
||||
return;
|
||||
}
|
||||
ASSERT_NE(paramValue, nullptr);
|
||||
int32_t data = MAX_TEST_PATH_LEN;
|
||||
cJSON_AddNumberToObject(paramValue, "data", data);
|
||||
bool ret = IsString(paramValue);
|
||||
@ -327,6 +319,59 @@ HWTEST_F(DistributedSchedUtilsTest, CJsonParamCheck_001, TestSize.Level1)
|
||||
{
|
||||
bool ret = CJsonParamCheck(nullptr, {PARAM_KEY_OS_TYPE, PARAM_KEY_OS_VERSION});
|
||||
EXPECT_FALSE(ret);
|
||||
|
||||
cJSON *jsonObj = cJSON_CreateArray();
|
||||
const std::initializer_list<std::string> keys = {"key1", "key2"};
|
||||
ret = CJsonParamCheck(jsonObj, keys);
|
||||
EXPECT_FALSE(ret);
|
||||
cJSON_Delete(jsonObj);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: CJsonParamCheck_002
|
||||
* @tc.desc: CJsonParamCheck
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I5WKCK
|
||||
*/
|
||||
HWTEST_F(DistributedSchedUtilsTest, CJsonParamCheck_002, TestSize.Level1)
|
||||
{
|
||||
cJSON *jsonObj = cJSON_CreateObject();
|
||||
const std::initializer_list<std::string> keys = {"key1", "key2"};
|
||||
bool ret = CJsonParamCheck(jsonObj, keys);
|
||||
EXPECT_FALSE(ret);
|
||||
cJSON_Delete(jsonObj);
|
||||
|
||||
cJSON *jsonObj1 = cJSON_CreateObject();
|
||||
cJSON_AddItemToObject(jsonObj1, "key1", cJSON_CreateString("value1"));
|
||||
const std::initializer_list<std::string> keys1 = {"key1", "key2"};
|
||||
ret = CJsonParamCheck(jsonObj1, keys1);
|
||||
EXPECT_FALSE(ret);
|
||||
cJSON_Delete(jsonObj1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: CJsonParamCheck_003
|
||||
* @tc.desc: CJsonParamCheck
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I5WKCK
|
||||
*/
|
||||
HWTEST_F(DistributedSchedUtilsTest, CJsonParamCheck_003, TestSize.Level1)
|
||||
{
|
||||
cJSON *jsonObj = cJSON_CreateObject();
|
||||
cJSON_AddItemToObject(jsonObj, PARAM_KEY_OS_TYPE, cJSON_CreateString("value1"));
|
||||
cJSON_AddItemToObject(jsonObj, PARAM_KEY_OS_VERSION, cJSON_CreateString("value2"));
|
||||
const std::initializer_list<std::string> keys = {PARAM_KEY_OS_TYPE, PARAM_KEY_OS_VERSION};
|
||||
bool ret = CJsonParamCheck(jsonObj, keys);
|
||||
EXPECT_FALSE(ret);
|
||||
cJSON_Delete(jsonObj);
|
||||
|
||||
cJSON *jsonObj1 = cJSON_CreateObject();
|
||||
cJSON_AddItemToObject(jsonObj1, PARAM_KEY_OS_TYPE, cJSON_CreateNumber(1));
|
||||
cJSON_AddItemToObject(jsonObj1, PARAM_KEY_OS_VERSION, cJSON_CreateString("value2"));
|
||||
const std::initializer_list<std::string> keys1 = {PARAM_KEY_OS_TYPE, PARAM_KEY_OS_VERSION};
|
||||
ret = CJsonParamCheck(jsonObj1, keys1);
|
||||
EXPECT_TRUE(ret);
|
||||
cJSON_Delete(jsonObj1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -343,5 +388,20 @@ HWTEST_F(DistributedSchedUtilsTest, GetOsInfoFromDM_001, TestSize.Level1)
|
||||
bool ret = GetOsInfoFromDM(dmInfoEx, osType, osVersion);
|
||||
EXPECT_FALSE(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetOsInfoFromDM_002
|
||||
* @tc.desc: GetOsInfoFromDM
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I5WKCK
|
||||
*/
|
||||
HWTEST_F(DistributedSchedUtilsTest, GetOsInfoFromDM_002, TestSize.Level1)
|
||||
{
|
||||
std::string dmInfoEx = "{\"osType\":\"1\",\"osVersion\":\"1.0\"}";
|
||||
int32_t osType;
|
||||
std::string osVersion;
|
||||
bool ret = GetOsInfoFromDM(dmInfoEx, osType, osVersion);
|
||||
EXPECT_FALSE(ret);
|
||||
}
|
||||
} // namespace DistributedSchedule
|
||||
} // namespace OHOS
|
||||
|
@ -473,7 +473,6 @@ ohos_unittest("dmsmissionmanagertest") {
|
||||
sources = [
|
||||
"unittest/mission/distributed_data_storage_test.cpp",
|
||||
"unittest/mission/dms_mission_manager_test.cpp",
|
||||
"unittest/mission/mock_distributed_sched_adapter.cpp",
|
||||
"unittest/mission/mock_image_packer.cpp",
|
||||
]
|
||||
sources += dtbschedmgr_sources
|
||||
|
@ -27,6 +27,10 @@ using namespace testing;
|
||||
using namespace testing::ext;
|
||||
using namespace OHOS::DistributedKv;
|
||||
using namespace OHOS::DistributedHardware;
|
||||
|
||||
static std::string g_mockGetLocalUdid = "";
|
||||
static std::string g_mockGetUdidByNetworkId = "";
|
||||
static std::string g_mockGetUuidByNetworkId = "";
|
||||
namespace {
|
||||
const std::string BASEDIR = "/data/service/el1/public/database/DistributedSchedule";
|
||||
constexpr int32_t TASK_ID_1 = 11;
|
||||
@ -36,6 +40,23 @@ constexpr uint8_t ONE_BYTE = '6';
|
||||
constexpr uint16_t ONE = 1;
|
||||
}
|
||||
|
||||
bool DtbschedmgrDeviceInfoStorage::GetLocalUdid(std::string& udid)
|
||||
{
|
||||
udid = g_mockGetLocalUdid;
|
||||
DTEST_LOG << "shihaojie GetLocalUdid" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string DtbschedmgrDeviceInfoStorage::GetUdidByNetworkId(const std::string& networkId)
|
||||
{
|
||||
return g_mockGetUdidByNetworkId;
|
||||
}
|
||||
|
||||
std::string DtbschedmgrDeviceInfoStorage::GetUuidByNetworkId(const std::string& networkId)
|
||||
{
|
||||
return g_mockGetUuidByNetworkId;
|
||||
}
|
||||
|
||||
void DistributedBmStorageTest::SetUpTestCase()
|
||||
{
|
||||
mkdir(BASEDIR.c_str(), (S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH));
|
||||
@ -51,6 +72,9 @@ void DistributedBmStorageTest::TearDownTestCase()
|
||||
void DistributedBmStorageTest::SetUp()
|
||||
{
|
||||
DistributedSchedUtil::MockPermission();
|
||||
g_mockGetLocalUdid = "";
|
||||
g_mockGetUdidByNetworkId = "";
|
||||
g_mockGetUuidByNetworkId = "";
|
||||
dmsBmStorage_ = std::make_shared<DmsBmStorage>();
|
||||
DTEST_LOG << "DistributedBmStorageTest::SetUp" << std::endl;
|
||||
}
|
||||
@ -107,6 +131,26 @@ HWTEST_F(DistributedBmStorageTest, DeleteStorageDistributeInfoTest_001, TestSize
|
||||
DTEST_LOG << "DistributedBmStorageTest DeleteStorageDistributeInfoTest_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: DeleteStorageDistributeInfoTest_002
|
||||
* @tc.desc: test insert DistributedBmStorage
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DistributedBmStorageTest, DeleteStorageDistributeInfoTest_002, TestSize.Level1)
|
||||
{
|
||||
DTEST_LOG << "DistributedBmStorageTest DeleteStorageDistributeInfoTest_002 start" << std::endl;
|
||||
ASSERT_NE(dmsBmStorage_, nullptr);
|
||||
auto distributedDataStorage = GetDmsBmStorage();
|
||||
EXPECT_NE(distributedDataStorage, nullptr);
|
||||
if (distributedDataStorage != nullptr) {
|
||||
const std::string bundleName = "NonexistentName";
|
||||
g_mockGetLocalUdid = "localudid";
|
||||
bool ret = dmsBmStorage_->GetInstance()->DeleteStorageDistributeInfo(bundleName);
|
||||
EXPECT_EQ(ret, true);
|
||||
}
|
||||
DTEST_LOG << "DistributedBmStorageTest DeleteStorageDistributeInfoTest_002 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetStorageDistributeInfo_001
|
||||
* @tc.desc: test insert DistributedBmStorage
|
||||
@ -127,6 +171,27 @@ HWTEST_F(DistributedBmStorageTest, GetStorageDistributeInfo_001, TestSize.Level1
|
||||
DTEST_LOG << "DistributedBmStorageTest GetStorageDistributeInfo_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetStorageDistributeInfo_002
|
||||
* @tc.desc: test insert DistributedBmStorage
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DistributedBmStorageTest, GetStorageDistributeInfo_002, TestSize.Level1)
|
||||
{
|
||||
DTEST_LOG << "DistributedBmStorageTest GetStorageDistributeInfo_002 start" << std::endl;
|
||||
ASSERT_NE(dmsBmStorage_, nullptr);
|
||||
auto distributedDataStorage = GetDmsBmStorage();
|
||||
EXPECT_NE(distributedDataStorage, nullptr);
|
||||
if (distributedDataStorage != nullptr) {
|
||||
const std::string bundleName = "NonexistentName";
|
||||
DmsBundleInfo info;
|
||||
g_mockGetUdidByNetworkId = "udid";
|
||||
bool ret = dmsBmStorage_->GetInstance()->GetStorageDistributeInfo("", bundleName, info);
|
||||
EXPECT_EQ(ret, false);
|
||||
}
|
||||
DTEST_LOG << "DistributedBmStorageTest GetStorageDistributeInfo_002 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetDistributedBundleNameTest_001
|
||||
* @tc.desc: test insert DistributedBmStorage
|
||||
@ -344,6 +409,28 @@ HWTEST_F(DistributedBmStorageTest, GetAbilityNameTest_001, TestSize.Level1)
|
||||
DTEST_LOG << "DistributedBmStorageTest GetAbilityNameTest_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetAbilityNameTest_002
|
||||
* @tc.desc: test delete DistributedBmStorage
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DistributedBmStorageTest, GetAbilityNameTest_002, TestSize.Level1)
|
||||
{
|
||||
DTEST_LOG << "DistributedBmStorageTest GetAbilityNameTest_002 start" << std::endl;
|
||||
ASSERT_NE(dmsBmStorage_, nullptr);
|
||||
auto distributedDataStorage = GetDmsBmStorage();
|
||||
EXPECT_NE(distributedDataStorage, nullptr);
|
||||
if (distributedDataStorage != nullptr) {
|
||||
std::string networkId;
|
||||
std::string bundleName;
|
||||
std::string continueType;
|
||||
g_mockGetUdidByNetworkId = "udid";
|
||||
std::string ret = dmsBmStorage_->GetInstance()->GetAbilityName(networkId, bundleName, continueType);
|
||||
EXPECT_EQ(ret, "");
|
||||
}
|
||||
DTEST_LOG << "DistributedBmStorageTest GetAbilityNameTest_002 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetContinueTypeIdTest_001
|
||||
* @tc.desc: test delete DistributedBmStorage
|
||||
@ -365,6 +452,28 @@ HWTEST_F(DistributedBmStorageTest, GetContinueTypeIdTest_001, TestSize.Level1)
|
||||
DTEST_LOG << "DistributedBmStorageTest GetContinueTypeIdTest_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetContinueTypeIdTest_002
|
||||
* @tc.desc: test delete DistributedBmStorage
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DistributedBmStorageTest, GetContinueTypeIdTest_002, TestSize.Level1)
|
||||
{
|
||||
DTEST_LOG << "DistributedBmStorageTest GetContinueTypeIdTest_002 start" << std::endl;
|
||||
ASSERT_NE(dmsBmStorage_, nullptr);
|
||||
auto distributedDataStorage = GetDmsBmStorage();
|
||||
EXPECT_NE(distributedDataStorage, nullptr);
|
||||
if (distributedDataStorage != nullptr) {
|
||||
std::string bundleName;
|
||||
std::string abilityName;
|
||||
uint8_t continueTypeId = 0;
|
||||
g_mockGetLocalUdid = "localudid";
|
||||
bool ret = dmsBmStorage_->GetInstance()->GetContinueTypeId(bundleName, abilityName, continueTypeId);
|
||||
EXPECT_EQ(ret, false);
|
||||
}
|
||||
DTEST_LOG << "DistributedBmStorageTest GetContinueTypeIdTest_002 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetContinueEventInfoTest_001
|
||||
* @tc.desc: test delete DistributedBmStorage
|
||||
@ -388,6 +497,30 @@ HWTEST_F(DistributedBmStorageTest, GetContinueEventInfoTest_001, TestSize.Level1
|
||||
DTEST_LOG << "DistributedBmStorageTest GetContinueEventInfoTest_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetContinueEventInfoTest_002
|
||||
* @tc.desc: test delete DistributedBmStorage
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DistributedBmStorageTest, GetContinueEventInfoTest_002, TestSize.Level1)
|
||||
{
|
||||
DTEST_LOG << "DistributedBmStorageTest GetContinueEventInfoTest_002 start" << std::endl;
|
||||
ASSERT_NE(dmsBmStorage_, nullptr);
|
||||
auto distributedDataStorage = GetDmsBmStorage();
|
||||
EXPECT_NE(distributedDataStorage, nullptr);
|
||||
if (distributedDataStorage != nullptr) {
|
||||
std::string networkId;
|
||||
std::string bundleName;
|
||||
std::string continueType;
|
||||
ContinueEventInfo continueEventInfo;
|
||||
g_mockGetUdidByNetworkId = "udid";
|
||||
bool ret = dmsBmStorage_->GetInstance()->GetContinueEventInfo(networkId, bundleName,
|
||||
continueType, continueEventInfo);
|
||||
EXPECT_EQ(ret, false);
|
||||
}
|
||||
DTEST_LOG << "DistributedBmStorageTest GetContinueEventInfoTest_002 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: DmsPutBatchTest_001
|
||||
* @tc.desc: test delete DistributedBmStorage
|
||||
@ -406,6 +539,25 @@ HWTEST_F(DistributedBmStorageTest, DmsPutBatchTest_001, TestSize.Level1)
|
||||
DTEST_LOG << "DistributedBmStorageTest DmsPutBatchTest_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: DmsPutBatchTest_002
|
||||
* @tc.desc: DmsPutBatch
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DistributedBmStorageTest, DmsPutBatchTest_002, TestSize.Level1)
|
||||
{
|
||||
DTEST_LOG << "DistributedBmStorageTest DmsPutBatchTest_002 start" << std::endl;
|
||||
ASSERT_NE(dmsBmStorage_, nullptr);
|
||||
auto distributedDataStorage = GetDmsBmStorage();
|
||||
EXPECT_NE(distributedDataStorage, nullptr);
|
||||
if (distributedDataStorage != nullptr) {
|
||||
std::vector<DmsBundleInfo> dmsBundleInfos;
|
||||
g_mockGetLocalUdid = "localudid";
|
||||
dmsBmStorage_->GetInstance()->DmsPutBatch(dmsBundleInfos);
|
||||
}
|
||||
DTEST_LOG << "DistributedBmStorageTest DmsPutBatchTest_002 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UpdatePublicRecordsTest_001
|
||||
* @tc.desc: test delete DistributedBmStorage
|
||||
@ -486,6 +638,36 @@ HWTEST_F(DistributedBmStorageTest, DealGetBundleNameTest_001, TestSize.Level1)
|
||||
DTEST_LOG << "DistributedBmStorageTest DealGetBundleNameTest_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: DealGetBundleNameTest_002
|
||||
* @tc.desc: test DealGetBundleName
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DistributedBmStorageTest, DealGetBundleNameTest_002, TestSize.Level1)
|
||||
{
|
||||
DTEST_LOG << "DistributedBmStorageTest DealGetBundleNameTest_002 start" << std::endl;
|
||||
auto distributedDataStorage = GetDmsBmStorage();
|
||||
EXPECT_NE(distributedDataStorage, nullptr);
|
||||
if (distributedDataStorage != nullptr) {
|
||||
std::string bundleName;
|
||||
g_mockGetUdidByNetworkId = "udid";
|
||||
g_mockGetUuidByNetworkId = "uuid";
|
||||
bool ret = dmsBmStorage_->DealGetBundleName("", ONE, bundleName);
|
||||
EXPECT_EQ(ret, false);
|
||||
|
||||
g_mockGetUdidByNetworkId = "";
|
||||
g_mockGetUuidByNetworkId = "uuid";
|
||||
ret = dmsBmStorage_->DealGetBundleName("", ONE, bundleName);
|
||||
EXPECT_EQ(ret, false);
|
||||
|
||||
g_mockGetUdidByNetworkId = "udid";
|
||||
g_mockGetUuidByNetworkId = "";
|
||||
ret = dmsBmStorage_->DealGetBundleName("", ONE, bundleName);
|
||||
EXPECT_EQ(ret, false);
|
||||
}
|
||||
DTEST_LOG << "DistributedBmStorageTest DealGetBundleNameTest_002 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: DelReduDataTest_001
|
||||
* @tc.desc: test DelReduData
|
||||
@ -504,6 +686,37 @@ HWTEST_F(DistributedBmStorageTest, DelReduDataTest_001, TestSize.Level1)
|
||||
DTEST_LOG << "DistributedBmStorageTest DelReduDataTest_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: DelReduDataTest_002
|
||||
* @tc.desc: test DelReduData
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DistributedBmStorageTest, DelReduDataTest_002, TestSize.Level1)
|
||||
{
|
||||
DTEST_LOG << "DistributedBmStorageTest DelReduDataTest_002 start" << std::endl;
|
||||
auto distributedDataStorage = GetDmsBmStorage();
|
||||
EXPECT_NE(distributedDataStorage, nullptr);
|
||||
if (distributedDataStorage != nullptr) {
|
||||
std::vector<DistributedKv::Entry> reduRiskEntries;
|
||||
g_mockGetUdidByNetworkId = "udid";
|
||||
g_mockGetUuidByNetworkId = "";
|
||||
bool ret = dmsBmStorage_->DelReduData("", reduRiskEntries);
|
||||
EXPECT_EQ(ret, false);
|
||||
|
||||
g_mockGetUdidByNetworkId = "";
|
||||
g_mockGetUuidByNetworkId = "uuid";
|
||||
ret = dmsBmStorage_->DelReduData("", reduRiskEntries);
|
||||
EXPECT_EQ(ret, false);
|
||||
|
||||
|
||||
g_mockGetUdidByNetworkId = "udid";
|
||||
g_mockGetUuidByNetworkId = "uuid";
|
||||
ret = dmsBmStorage_->DelReduData("", reduRiskEntries);
|
||||
EXPECT_EQ(ret, false);
|
||||
}
|
||||
DTEST_LOG << "DistributedBmStorageTest DelReduDataTest_002 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RebuildLocalDataTest_001
|
||||
* @tc.desc: test RebuildLocalData
|
||||
@ -521,6 +734,24 @@ HWTEST_F(DistributedBmStorageTest, RebuildLocalDataTest_001, TestSize.Level1)
|
||||
DTEST_LOG << "DistributedBmStorageTest RebuildLocalDataTest_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RebuildLocalDataTest_002
|
||||
* @tc.desc: test RebuildLocalData
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DistributedBmStorageTest, RebuildLocalDataTest_002, TestSize.Level1)
|
||||
{
|
||||
DTEST_LOG << "DistributedBmStorageTest RebuildLocalDataTest_002 start" << std::endl;
|
||||
auto distributedDataStorage = GetDmsBmStorage();
|
||||
EXPECT_NE(distributedDataStorage, nullptr);
|
||||
if (distributedDataStorage != nullptr) {
|
||||
g_mockGetLocalUdid = "localudid";
|
||||
bool ret = dmsBmStorage_->RebuildLocalData();
|
||||
EXPECT_EQ(ret, true);
|
||||
}
|
||||
DTEST_LOG << "DistributedBmStorageTest RebuildLocalDataTest_002 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ConvertToDistributedBundleInfoTest_001
|
||||
* @tc.desc: test ConvertToDistributedBundleInfo
|
||||
@ -584,5 +815,56 @@ HWTEST_F(DistributedBmStorageTest, GetDistributedBundleInfoTest_001, TestSize.Le
|
||||
}
|
||||
DTEST_LOG << "DistributedBmStorageTest GetDistributedBundleInfoTest_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetDistributedBundleInfoTest_002
|
||||
* @tc.desc: test GetDistributedBundleInfo
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DistributedBmStorageTest, GetDistributedBundleInfoTest_002, TestSize.Level1)
|
||||
{
|
||||
DTEST_LOG << "DistributedBmStorageTest GetDistributedBundleInfoTest_002 start" << std::endl;
|
||||
auto distributedDataStorage = GetDmsBmStorage();
|
||||
EXPECT_NE(distributedDataStorage, nullptr);
|
||||
if (distributedDataStorage != nullptr) {
|
||||
std::string networkId;
|
||||
uint16_t bundleNameId = 0;
|
||||
DmsBundleInfo distributeBundleInfo;
|
||||
g_mockGetUdidByNetworkId = "udid";
|
||||
g_mockGetUuidByNetworkId = "uuid";
|
||||
bool ret = dmsBmStorage_->GetDistributedBundleInfo(networkId, bundleNameId, distributeBundleInfo);
|
||||
EXPECT_EQ(ret, false);
|
||||
|
||||
g_mockGetUdidByNetworkId = "";
|
||||
g_mockGetUuidByNetworkId = "uuid";
|
||||
ret = dmsBmStorage_->GetDistributedBundleInfo(networkId, bundleNameId, distributeBundleInfo);
|
||||
EXPECT_EQ(ret, false);
|
||||
|
||||
g_mockGetUdidByNetworkId = "udid";
|
||||
g_mockGetUuidByNetworkId = "";
|
||||
ret = dmsBmStorage_->GetDistributedBundleInfo(networkId, bundleNameId, distributeBundleInfo);
|
||||
EXPECT_EQ(ret, false);
|
||||
}
|
||||
DTEST_LOG << "DistributedBmStorageTest GetDistributedBundleInfoTest_002 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetLastBundleNameIdTest_001
|
||||
* @tc.desc: test GetLastBundleNameId
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DistributedBmStorageTest, GetLastBundleNameIdTest_001, TestSize.Level1)
|
||||
{
|
||||
DTEST_LOG << "DistributedBmStorageTest GetLastBundleNameIdTest_001 start" << std::endl;
|
||||
auto distributedDataStorage = GetDmsBmStorage();
|
||||
EXPECT_NE(distributedDataStorage, nullptr);
|
||||
if (distributedDataStorage != nullptr) {
|
||||
uint16_t bundleNameId = 0;
|
||||
g_mockGetLocalUdid = "localudid";
|
||||
bool ret = dmsBmStorage_->GetLastBundleNameId(bundleNameId);
|
||||
EXPECT_EQ(ret, true);
|
||||
}
|
||||
DTEST_LOG << "DistributedBmStorageTest GetLastBundleNameIdTest_001 end" << std::endl;
|
||||
}
|
||||
} // namespace DistributedSchedule
|
||||
} // namespace OHOS
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#define private public
|
||||
#define protected public
|
||||
#include "distributed_sched_adapter.h"
|
||||
#include "distributed_sched_proxy.h"
|
||||
#include "distributed_sched_service.h"
|
||||
#include "distributed_sched_test_util.h"
|
||||
@ -64,6 +65,12 @@ bool DMSMissionManagerTest::isCaseDone_ = false;
|
||||
std::mutex DMSMissionManagerTest::caseDoneLock_;
|
||||
std::condition_variable DMSMissionManagerTest::caseDoneCondition_;
|
||||
|
||||
int32_t DistributedSchedAdapter::GetLocalMissionSnapshotInfo(const std::string& networkId, int32_t missionId,
|
||||
AAFwk::MissionSnapshot& missionSnapshot)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
void DMSMissionManagerTest::SetUpTestCase()
|
||||
{
|
||||
if (!DistributedSchedUtil::LoadDistributedSchedService()) {
|
||||
@ -71,15 +78,11 @@ void DMSMissionManagerTest::SetUpTestCase()
|
||||
}
|
||||
const std::string pkgName = "DBinderBus_" + std::to_string(getprocpid());
|
||||
std::shared_ptr<DmInitCallback> initCallback_ = std::make_shared<DeviceInitCallBack>();
|
||||
mockDmsAdapter = std::make_shared<MockAdapter>();
|
||||
AdapterMock::dmsAdapter = mockDmsAdapter;
|
||||
DeviceManager::GetInstance().InitDeviceManager(pkgName, initCallback_);
|
||||
}
|
||||
|
||||
void DMSMissionManagerTest::TearDownTestCase()
|
||||
{
|
||||
AdapterMock::dmsAdapter = nullptr;
|
||||
mockDmsAdapter = nullptr;
|
||||
}
|
||||
|
||||
void DMSMissionManagerTest::SetUp()
|
||||
@ -1287,7 +1290,6 @@ HWTEST_F(DMSMissionManagerTest, testNotifyMissionSnapshotChanged001, TestSize.Le
|
||||
{
|
||||
DTEST_LOG << "testNotifyMissionSnapshotChanged001 begin" << std::endl;
|
||||
DistributedSchedMissionManager::GetInstance().Init();
|
||||
EXPECT_CALL(*mockDmsAdapter, GetLocalMissionSnapshotInfo(_, _, _)).WillOnce(Return(true));
|
||||
DistributedSchedMissionManager::GetInstance().NotifyMissionSnapshotChanged(1);
|
||||
EXPECT_NE(DistributedSchedMissionManager::GetInstance().missionChangeHandler_, nullptr);
|
||||
DTEST_LOG << "testNotifyMissionSnapshotChanged001 end" << std::endl;
|
||||
@ -1384,7 +1386,6 @@ HWTEST_F(DMSMissionManagerTest, testMissionSnapshotChanged001, TestSize.Level3)
|
||||
DistributedSchedMissionManager::GetInstance().NotifyDmsProxyProcessDied();
|
||||
std::vector<DstbMissionInfo> missionInfos;
|
||||
DistributedSchedMissionManager::GetInstance().InitAllSnapshots(missionInfos);
|
||||
EXPECT_CALL(*mockDmsAdapter, GetLocalMissionSnapshotInfo(_, _, _)).WillOnce(Return(1)).WillOnce(Return(1));
|
||||
auto ret = DistributedSchedMissionManager::GetInstance().MissionSnapshotChanged(NUM_MISSIONS);
|
||||
EXPECT_NE(ret, ERR_NONE);
|
||||
DTEST_LOG << "testMissionSnapshotChanged001 end" << std::endl;
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "remote_mission_listener_stub.h"
|
||||
|
||||
#include "distributed_sched_interface.h"
|
||||
#include "mock_distributed_sched_adapter.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
@ -41,7 +40,6 @@ protected:
|
||||
static bool isCaseDone_;
|
||||
static std::mutex caseDoneLock_;
|
||||
static std::condition_variable caseDoneCondition_;
|
||||
static inline std::shared_ptr<MockAdapter> mockDmsAdapter = nullptr;
|
||||
|
||||
class DeviceInitCallBack : public OHOS::DistributedHardware::DmInitCallback {
|
||||
void OnRemoteDied() override;
|
||||
|
@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
#include "mock_distributed_sched_adapter.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
int32_t DistributedSchedAdapter::GetLocalMissionSnapshotInfo(const std::string& networkId, int32_t missionId,
|
||||
AAFwk::MissionSnapshot& missionSnapshot)
|
||||
{
|
||||
return OHOS::DistributedSchedule::AdapterMock::dmsAdapter->GetLocalMissionSnapshotInfo(networkId, missionId,
|
||||
missionSnapshot);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
#ifndef MOCK_DISTRIBUTED_SCHED_ADAPTER_H
|
||||
#define MOCK_DISTRIBUTED_SCHED_ADAPTER_H
|
||||
|
||||
#include <gmock/gmock.h>
|
||||
#include <string>
|
||||
|
||||
#include "distributed_sched_adapter.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
class AdapterMock {
|
||||
public:
|
||||
virtual ~AdapterMock() = default;
|
||||
public:
|
||||
virtual int32_t GetLocalMissionSnapshotInfo(const std::string& networkId, int32_t missionId,
|
||||
AAFwk::MissionSnapshot& missionSnapshot) = 0;
|
||||
public:
|
||||
static inline std::shared_ptr<AdapterMock> dmsAdapter = nullptr;
|
||||
};
|
||||
|
||||
class MockAdapter : public AdapterMock {
|
||||
public:
|
||||
MOCK_METHOD(int32_t, GetLocalMissionSnapshotInfo, (const std::string& networkId, int32_t missionId,
|
||||
AAFwk::MissionSnapshot& missionSnapshot));
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif //MOCK_DISTRIBUTED_SCHED_ADAPTER_H
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include "mock_softbus_adapter.h"
|
||||
#include "softbus_error_code.h"
|
||||
#include "dtbschedmgr_log.h"
|
||||
#include "test_log.h"
|
||||
|
||||
using namespace testing;
|
||||
@ -26,6 +27,7 @@ namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
namespace {
|
||||
const std::string NETWORKID_01 = "networkId01";
|
||||
constexpr int32_t RETRY_SENT_EVENT_MAX_TIME = 3;
|
||||
}
|
||||
|
||||
void SoftbusAdapterTest::SetUpTestCase()
|
||||
@ -56,15 +58,78 @@ void SoftbusAdapterTest::SetUp()
|
||||
HWTEST_F(SoftbusAdapterTest, SendSoftbusEvent_001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "SoftbusAdapterTest SendSoftbusEvent_001 begin" << std::endl;
|
||||
uint32_t sendDataLen = 1;
|
||||
size_t sendDataLen = 1;
|
||||
std::shared_ptr<DSchedDataBuffer> buffer = std::make_shared<DSchedDataBuffer>(sendDataLen);
|
||||
SoftbusMock sortbusMock;
|
||||
EXPECT_CALL(sortbusMock, SendEvent(_, _, _)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
uint32_t result = SoftbusAdapter::GetInstance().SendSoftbusEvent(buffer);
|
||||
SoftbusAdapter::GetInstance().eventHandler_ = nullptr;
|
||||
int32_t result = SoftbusAdapter::GetInstance().SendSoftbusEvent(buffer);
|
||||
EXPECT_EQ(result, SOFTBUS_OK);
|
||||
|
||||
SoftbusMock sortbusMock;
|
||||
SoftbusAdapter::GetInstance().Init();
|
||||
result = SoftbusAdapter::GetInstance().SendSoftbusEvent(buffer);
|
||||
EXPECT_EQ(result, SOFTBUS_OK);
|
||||
SoftbusAdapter::GetInstance().UnInit();
|
||||
DTEST_LOG << "SoftbusAdapterTest SendSoftbusEvent_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: DealSendSoftbusEvent_001
|
||||
* @tc.desc: call DealSendSoftbusEvent
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(SoftbusAdapterTest, DealSendSoftbusEvent_001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "SoftbusAdapterTest DealSendSoftbusEvent_001 begin" << std::endl;
|
||||
size_t sendDataLen = 1;
|
||||
int32_t retry = 0;
|
||||
std::shared_ptr<DSchedDataBuffer> buffer = std::make_shared<DSchedDataBuffer>(sendDataLen);
|
||||
SoftbusAdapter::GetInstance().eventHandler_ = nullptr;
|
||||
int32_t result = SoftbusAdapter::GetInstance().DealSendSoftbusEvent(nullptr, retry);
|
||||
EXPECT_EQ(result, INVALID_PARAMETERS_ERR);
|
||||
|
||||
SoftbusAdapter::GetInstance().Init();
|
||||
result = SoftbusAdapter::GetInstance().DealSendSoftbusEvent(nullptr, retry);
|
||||
EXPECT_EQ(result, INVALID_PARAMETERS_ERR);
|
||||
|
||||
SoftbusMock sortbusMock;
|
||||
EXPECT_CALL(sortbusMock, SendEvent(_, _, _)).WillOnce(Return(SOFTBUS_OK));
|
||||
result = SoftbusAdapter::GetInstance().DealSendSoftbusEvent(buffer, retry);
|
||||
EXPECT_EQ(result, SOFTBUS_OK);
|
||||
|
||||
EXPECT_CALL(sortbusMock, SendEvent(_, _, _)).WillOnce(Return(INVALID_PARAMETERS_ERR));
|
||||
result = SoftbusAdapter::GetInstance().DealSendSoftbusEvent(buffer, retry);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
SoftbusAdapter::GetInstance().UnInit();
|
||||
DTEST_LOG << "SoftbusAdapterTest DealSendSoftbusEvent_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RetrySendSoftbusEvent_001
|
||||
* @tc.desc: call RetrySendSoftbusEvent
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(SoftbusAdapterTest, RetrySendSoftbusEvent_001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "SoftbusAdapterTest RetrySendSoftbusEvent_001 begin" << std::endl;
|
||||
size_t sendDataLen = 1;
|
||||
int32_t retry = RETRY_SENT_EVENT_MAX_TIME;
|
||||
std::shared_ptr<DSchedDataBuffer> buffer = std::make_shared<DSchedDataBuffer>(sendDataLen);
|
||||
SoftbusAdapter::GetInstance().eventHandler_ = nullptr;
|
||||
int32_t result = SoftbusAdapter::GetInstance().RetrySendSoftbusEvent(nullptr, retry);
|
||||
EXPECT_EQ(result, INVALID_PARAMETERS_ERR);
|
||||
|
||||
retry = 0;
|
||||
SoftbusAdapter::GetInstance().eventHandler_ = nullptr;
|
||||
result = SoftbusAdapter::GetInstance().RetrySendSoftbusEvent(buffer, retry);
|
||||
EXPECT_EQ(result, INVALID_PARAMETERS_ERR);
|
||||
|
||||
SoftbusAdapter::GetInstance().Init();
|
||||
result = SoftbusAdapter::GetInstance().RetrySendSoftbusEvent(buffer, retry);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
SoftbusAdapter::GetInstance().UnInit();
|
||||
DTEST_LOG << "SoftbusAdapterTest RetrySendSoftbusEvent_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: StopSoftbusEvent_001
|
||||
* @tc.desc: call StopSoftbusEvent from distributedsched
|
||||
@ -74,9 +139,13 @@ HWTEST_F(SoftbusAdapterTest, StopSoftbusEvent_001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "SoftbusAdapterTest StopSoftbusEvent_001 begin" << std::endl;
|
||||
SoftbusMock sortbusMock;
|
||||
EXPECT_CALL(sortbusMock, StopEvent(_, _, _)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
uint32_t result = SoftbusAdapter::GetInstance().StopSoftbusEvent();
|
||||
EXPECT_CALL(sortbusMock, StopEvent(_, _, _)).WillOnce(Return(SOFTBUS_OK));
|
||||
int32_t result = SoftbusAdapter::GetInstance().StopSoftbusEvent();
|
||||
EXPECT_EQ(result, SOFTBUS_OK);
|
||||
|
||||
EXPECT_CALL(sortbusMock, StopEvent(_, _, _)).WillOnce(Return(INVALID_PARAMETERS_ERR));
|
||||
result = SoftbusAdapter::GetInstance().StopSoftbusEvent();
|
||||
EXPECT_EQ(result, INVALID_PARAMETERS_ERR);
|
||||
DTEST_LOG << "SoftbusAdapterTest StopSoftbusEvent_001 end" << std::endl;
|
||||
}
|
||||
|
||||
@ -97,8 +166,8 @@ HWTEST_F(SoftbusAdapterTest, RegisterSoftbusEventListener_001, TestSize.Level3)
|
||||
DTEST_LOG << "SoftbusAdapterTest RegisterSoftbusEventListener_001 begin" << std::endl;
|
||||
std::shared_ptr<SubSoftbusAdapterListener> listener = std::make_shared<SubSoftbusAdapterListener>();
|
||||
SoftbusMock sortbusMock;
|
||||
EXPECT_CALL(sortbusMock, RegisterEventListener(_, _)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
uint32_t result = SoftbusAdapter::GetInstance().RegisterSoftbusEventListener(listener);
|
||||
EXPECT_CALL(sortbusMock, RegisterEventListener(_, _)).WillOnce(Return(SOFTBUS_OK));
|
||||
int32_t result = SoftbusAdapter::GetInstance().RegisterSoftbusEventListener(listener);
|
||||
EXPECT_EQ(result, SOFTBUS_OK);
|
||||
DTEST_LOG << "SoftbusAdapterTest RegisterSoftbusEventListener_001 end" << std::endl;
|
||||
}
|
||||
@ -113,8 +182,8 @@ HWTEST_F(SoftbusAdapterTest, UnregisterSoftbusEventListener_001, TestSize.Level3
|
||||
DTEST_LOG << "SoftbusAdapterTest UnregisterSoftbusEventListener_001 begin" << std::endl;
|
||||
std::shared_ptr<SubSoftbusAdapterListener> listener = std::make_shared<SubSoftbusAdapterListener>();
|
||||
SoftbusMock sortbusMock;
|
||||
EXPECT_CALL(sortbusMock, UnregisterEventListener(_, _)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
uint32_t result = SoftbusAdapter::GetInstance().UnregisterSoftbusEventListener(listener);
|
||||
EXPECT_CALL(sortbusMock, UnregisterEventListener(_, _)).WillOnce(Return(SOFTBUS_OK));
|
||||
int32_t result = SoftbusAdapter::GetInstance().UnregisterSoftbusEventListener(listener);
|
||||
EXPECT_EQ(result, SOFTBUS_OK);
|
||||
DTEST_LOG << "SoftbusAdapterTest UnregisterSoftbusEventListener_001 end" << std::endl;
|
||||
}
|
||||
@ -128,27 +197,11 @@ HWTEST_F(SoftbusAdapterTest, RegisterSoftbusEventListener_002, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "SoftbusAdapterTest RegisterSoftbusEventListener_002 begin" << std::endl;
|
||||
std::shared_ptr<SubSoftbusAdapterListener> listener = nullptr;
|
||||
uint32_t result = SoftbusAdapter::GetInstance().RegisterSoftbusEventListener(listener);
|
||||
int32_t result = SoftbusAdapter::GetInstance().RegisterSoftbusEventListener(listener);
|
||||
EXPECT_EQ(result, SOFTBUS_INVALID_PARAM);
|
||||
DTEST_LOG << "SoftbusAdapterTest RegisterSoftbusEventListener_002 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: StopSoftbusEvent_002
|
||||
* @tc.desc: call StopSoftbusEvent from distributedsched
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(SoftbusAdapterTest, StopSoftbusEvent_002, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "SoftbusAdapterTest StopSoftbusEvent_002 begin" << std::endl;
|
||||
SoftbusAdapter::GetInstance().pkgName_ = "oh";
|
||||
SoftbusMock sortbusMock;
|
||||
EXPECT_CALL(sortbusMock, SendEvent(_, _, _)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
uint32_t result = SoftbusAdapter::GetInstance().StopSoftbusEvent();
|
||||
EXPECT_EQ(result, SOFTBUS_OK);
|
||||
DTEST_LOG << "SoftbusAdapterTest StopSoftbusEvent_002 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RegisterSoftbusEventListener_003
|
||||
* @tc.desc: call RegisterSoftbusEventListener from distributedsched
|
||||
@ -158,7 +211,7 @@ HWTEST_F(SoftbusAdapterTest, RegisterSoftbusEventListener_003, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "SoftbusAdapterTest RegisterSoftbusEventListener_003 begin" << std::endl;
|
||||
std::shared_ptr<SubSoftbusAdapterListener> listener;
|
||||
uint32_t result = SoftbusAdapter::GetInstance().RegisterSoftbusEventListener(listener);
|
||||
int32_t result = SoftbusAdapter::GetInstance().RegisterSoftbusEventListener(listener);
|
||||
EXPECT_EQ(result, SOFTBUS_INVALID_PARAM);
|
||||
DTEST_LOG << "SoftbusAdapterTest RegisterSoftbusEventListener_003 end" << std::endl;
|
||||
}
|
||||
@ -173,7 +226,7 @@ HWTEST_F(SoftbusAdapterTest, RegisterSoftbusEventListener_004, TestSize.Level3)
|
||||
DTEST_LOG << "SoftbusAdapterTest RegisterSoftbusEventListener_004 begin" << std::endl;
|
||||
std::shared_ptr<SubSoftbusAdapterListener> listener;
|
||||
SoftbusAdapter::GetInstance().pkgName_ = "oh";
|
||||
uint32_t result = SoftbusAdapter::GetInstance().RegisterSoftbusEventListener(listener);
|
||||
int32_t result = SoftbusAdapter::GetInstance().RegisterSoftbusEventListener(listener);
|
||||
EXPECT_EQ(result, SOFTBUS_INVALID_PARAM);
|
||||
DTEST_LOG << "SoftbusAdapterTest RegisterSoftbusEventListener_004 end" << std::endl;
|
||||
}
|
||||
@ -187,7 +240,7 @@ HWTEST_F(SoftbusAdapterTest, UnregisterSoftbusEventListener_002, TestSize.Level3
|
||||
{
|
||||
DTEST_LOG << "SoftbusAdapterTest UnregisterSoftbusEventListener_002 begin" << std::endl;
|
||||
std::shared_ptr<SubSoftbusAdapterListener> listener;
|
||||
uint32_t result = SoftbusAdapter::GetInstance().UnregisterSoftbusEventListener(listener);
|
||||
int32_t result = SoftbusAdapter::GetInstance().UnregisterSoftbusEventListener(listener);
|
||||
EXPECT_EQ(result, SOFTBUS_INVALID_PARAM);
|
||||
DTEST_LOG << "SoftbusAdapterTest UnregisterSoftbusEventListener_002 end" << std::endl;
|
||||
}
|
||||
@ -203,10 +256,10 @@ HWTEST_F(SoftbusAdapterTest, UnregisterSoftbusEventListener_003, TestSize.Level3
|
||||
std::shared_ptr<SubSoftbusAdapterListener> listener = std::make_shared<SubSoftbusAdapterListener>();
|
||||
SoftbusAdapter::GetInstance().pkgName_ = "oh";
|
||||
SoftbusMock sortbusMock;
|
||||
EXPECT_CALL(sortbusMock, UnregisterEventListener(_, _)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
uint32_t result = SoftbusAdapter::GetInstance().UnregisterSoftbusEventListener(listener);
|
||||
EXPECT_EQ(result, SOFTBUS_OK);
|
||||
EXPECT_CALL(sortbusMock, UnregisterEventListener(_, _)).WillOnce(Return(INVALID_PARAMETERS_ERR));
|
||||
int32_t result = SoftbusAdapter::GetInstance().UnregisterSoftbusEventListener(listener);
|
||||
EXPECT_EQ(result, INVALID_PARAMETERS_ERR);
|
||||
DTEST_LOG << "SoftbusAdapterTest UnregisterSoftbusEventListener_003 end" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -676,5 +676,27 @@ HWTEST_F(DSchedTransportSoftbusAdapterTest, AddNewPeerSession_001, TestSize.Leve
|
||||
EXPECT_EQ(ret, REMOTE_DEVICE_BIND_ABILITY_ERR);
|
||||
DTEST_LOG << "DSchedTransportSoftbusAdapterTest AddNewPeerSession_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ConnectDevice_001
|
||||
* @tc.desc: call ConnectDevice
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DSchedTransportSoftbusAdapterTest, ConnectDevice_001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DSchedTransportSoftbusAdapterTest ConnectDevice_001 begin" << std::endl;
|
||||
std::string peerDeviceId = "peerDeviceId";
|
||||
int32_t sessionId = 0;
|
||||
SessionInfo info = {0, "deviceid", "peerDeviceId", "sessionName", false};
|
||||
std::shared_ptr<DSchedSoftbusSession> ptr = std::make_shared<DSchedSoftbusSession>(info);
|
||||
DSchedTransportSoftbusAdapter::GetInstance().sessions_.clear();
|
||||
DSchedTransportSoftbusAdapter::GetInstance().sessions_[1] = nullptr;
|
||||
DSchedTransportSoftbusAdapter::GetInstance().sessions_[0] = ptr;
|
||||
int32_t ret = DSchedTransportSoftbusAdapter::GetInstance().ConnectDevice("peer", sessionId);
|
||||
|
||||
ret = DSchedTransportSoftbusAdapter::GetInstance().ConnectDevice(peerDeviceId, sessionId);
|
||||
EXPECT_EQ(ret, ERR_OK);
|
||||
DTEST_LOG << "DSchedTransportSoftbusAdapterTest ConnectDevice_001 end" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user