mirror of
https://gitee.com/openharmony/distributedhardware_distributed_hardware_fwk
synced 2024-11-23 07:40:26 +00:00
add ut
Signed-off-by: li-tiangang4 <litiangang4@huawei.com>
This commit is contained in:
parent
01135d5f4a
commit
76cd39cfa5
@ -27,7 +27,20 @@ namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
using namespace std;
|
||||
namespace {
|
||||
|
||||
const std::string SUBTYPE_MIC = "mic";
|
||||
const std::string SUBTYPE_CAMERA = "camera";
|
||||
const std::string NETWORK_ID = "123456789";
|
||||
constexpr uint16_t DEVICE_TYPE_WIFI_CAMERA = 0x08;
|
||||
constexpr uint16_t DEVICE_TYPE_AUDIO = 0x0A;
|
||||
constexpr uint16_t DEVICE_TYPE_PC = 0x0C;
|
||||
constexpr uint16_t DEVICE_TYPE_PHONE = 0x0E;
|
||||
constexpr uint16_t DEVICE_TYPE_PAD = 0x11;
|
||||
constexpr uint16_t DEVICE_TYPE_WATCH = 0x6D;
|
||||
constexpr uint16_t DEVICE_TYPE_CAR = 0x83;
|
||||
constexpr uint16_t DEVICE_TYPE_TV = 0x9C;
|
||||
constexpr uint16_t DEVICE_TYPE_SMART_DISPLAY = 0xA02;
|
||||
constexpr uint16_t DEVICE_TYPE_2IN1 = 0xA2F;
|
||||
constexpr uint16_t DEVICE_TYPE_UNKNOWN = 0x00;
|
||||
}
|
||||
class ComponentPrivacyTest : public testing::Test {
|
||||
public:
|
||||
@ -58,107 +71,265 @@ void ComponentPrivacyTest::TearDown()
|
||||
|
||||
HWTEST_F(ComponentPrivacyTest, OnPrivaceResourceMessage_001, TestSize.Level0)
|
||||
{
|
||||
if (compPrivacy_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
ASSERT_TRUE(compPrivacy_ != nullptr);
|
||||
ResourceEventType type = ResourceEventType::EVENT_TYPE_QUERY_RESOURCE;
|
||||
std::string subtype = "mic";
|
||||
std::string networkId = "networkId_test";
|
||||
bool isSensitive = true;
|
||||
bool isSameAccout = true;
|
||||
int32_t ret = compPrivacy_->OnPrivaceResourceMessage(type, subtype, networkId, isSensitive, isSameAccout);
|
||||
int32_t ret = compPrivacy_->OnPrivaceResourceMessage(type, SUBTYPE_MIC, NETWORK_ID, isSensitive, isSameAccout);
|
||||
EXPECT_EQ(ERR_DH_FWK_RESOURCE_KEY_IS_EMPTY, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(ComponentPrivacyTest, OnPrivaceResourceMessage_002, TestSize.Level0)
|
||||
{
|
||||
if (compPrivacy_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
ResourceEventType type = ResourceEventType::EVENT_TYPE_PULL_UP_PAGE;
|
||||
std::string subtype = "mic";
|
||||
std::string networkId = "networkId_test";
|
||||
ASSERT_TRUE(compPrivacy_ != nullptr);
|
||||
ResourceEventType type = ResourceEventType::EVENT_TYPE_QUERY_RESOURCE;
|
||||
bool isSensitive = true;
|
||||
bool isSameAccout = true;
|
||||
int32_t ret = compPrivacy_->OnPrivaceResourceMessage(type, subtype, networkId, isSensitive, isSameAccout);
|
||||
EXPECT_EQ(DH_FWK_SUCCESS, ret);
|
||||
int32_t ret = compPrivacy_->OnPrivaceResourceMessage(type, SUBTYPE_MIC, "", isSensitive, isSameAccout);
|
||||
EXPECT_EQ(ERR_DH_FWK_PARA_INVALID, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(ComponentPrivacyTest, OnPrivaceResourceMessage_003, TestSize.Level0)
|
||||
{
|
||||
if (compPrivacy_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
ResourceEventType type = ResourceEventType::EVENT_TYPE_CLOSE_PAGE;
|
||||
std::string subtype = "mic";
|
||||
std::string networkId = "networkId_test";
|
||||
ASSERT_TRUE(compPrivacy_ != nullptr);
|
||||
ResourceEventType type = ResourceEventType::EVENT_TYPE_PULL_UP_PAGE;
|
||||
bool isSensitive = true;
|
||||
bool isSameAccout = true;
|
||||
int32_t ret = compPrivacy_->OnPrivaceResourceMessage(type, subtype, networkId, isSensitive, isSameAccout);
|
||||
int32_t ret = compPrivacy_->OnPrivaceResourceMessage(type, SUBTYPE_MIC, "", isSensitive, isSameAccout);
|
||||
EXPECT_EQ(DH_FWK_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(ComponentPrivacyTest, OnResourceInfoCallback_001, TestSize.Level0)
|
||||
HWTEST_F(ComponentPrivacyTest, OnPrivaceResourceMessage_004, TestSize.Level0)
|
||||
{
|
||||
if (compPrivacy_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
std::string subtype = "mic";
|
||||
std::string networkId = "networkId_test";
|
||||
ASSERT_TRUE(compPrivacy_ != nullptr);
|
||||
ResourceEventType type = ResourceEventType::EVENT_TYPE_PULL_UP_PAGE;
|
||||
bool isSensitive = true;
|
||||
bool isSameAccout = true;
|
||||
ComponentLoader::GetInstance().resDescMap_[subtype] = true;
|
||||
int32_t ret = compPrivacy_->OnResourceInfoCallback(subtype, networkId, isSensitive, isSameAccout);
|
||||
EXPECT_EQ(ERR_DH_FWK_RESOURCE_KEY_IS_EMPTY, ret);
|
||||
compPrivacy_->eventHandler_ = nullptr;
|
||||
int32_t ret = compPrivacy_->OnPrivaceResourceMessage(type, SUBTYPE_MIC, NETWORK_ID, isSensitive, isSameAccout);
|
||||
EXPECT_EQ(DH_FWK_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(ComponentPrivacyTest, OnPrivaceResourceMessage_005, TestSize.Level0)
|
||||
{
|
||||
ASSERT_TRUE(compPrivacy_ != nullptr);
|
||||
ResourceEventType type = ResourceEventType::EVENT_TYPE_CLOSE_PAGE;
|
||||
bool isSensitive = true;
|
||||
bool isSameAccout = true;
|
||||
int32_t ret = compPrivacy_->OnPrivaceResourceMessage(type, SUBTYPE_MIC, NETWORK_ID, isSensitive, isSameAccout);
|
||||
EXPECT_EQ(DH_FWK_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(ComponentPrivacyTest, OnPrivaceResourceMessage_006, TestSize.Level0)
|
||||
{
|
||||
ASSERT_TRUE(compPrivacy_ != nullptr);
|
||||
ResourceEventType type = ResourceEventType::EVENT_TYPE_CLOSE_PAGE;
|
||||
bool isSensitive = true;
|
||||
bool isSameAccout = true;
|
||||
compPrivacy_->eventHandler_ = nullptr;
|
||||
int32_t ret = compPrivacy_->OnPrivaceResourceMessage(type, SUBTYPE_MIC, NETWORK_ID, isSensitive, isSameAccout);
|
||||
EXPECT_EQ(DH_FWK_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(ComponentPrivacyTest, HandlePullUpPage_002, TestSize.Level0)
|
||||
{
|
||||
ASSERT_TRUE(compPrivacy_ != nullptr);
|
||||
compPrivacy_->eventHandler_ = nullptr;
|
||||
EXPECT_NO_FATAL_FAILURE(compPrivacy_->HandlePullUpPage(SUBTYPE_MIC, NETWORK_ID));
|
||||
}
|
||||
|
||||
HWTEST_F(ComponentPrivacyTest, HandleClosePage_001, TestSize.Level0)
|
||||
{
|
||||
ASSERT_TRUE(compPrivacy_ != nullptr);
|
||||
compPrivacy_->eventHandler_ = nullptr;
|
||||
EXPECT_NO_FATAL_FAILURE(compPrivacy_->HandleClosePage(SUBTYPE_MIC));
|
||||
}
|
||||
|
||||
HWTEST_F(ComponentPrivacyTest, StartPrivacePage_001, TestSize.Level0)
|
||||
{
|
||||
ASSERT_TRUE(compPrivacy_ != nullptr);
|
||||
auto ret = compPrivacy_->StartPrivacePage(SUBTYPE_MIC, "");
|
||||
EXPECT_EQ(ERR_DH_FWK_PARA_INVALID, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(ComponentPrivacyTest, ProcessEvent_001, TestSize.Level0)
|
||||
{
|
||||
ASSERT_TRUE(compPrivacy_ != nullptr);
|
||||
cJSON *jsonArrayMsg = cJSON_CreateArray();
|
||||
if (jsonArrayMsg == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
cJSON *tmpJson = cJSON_CreateObject();
|
||||
if (tmpJson == NULL) {
|
||||
cJSON_Delete(jsonArrayMsg);
|
||||
return;
|
||||
}
|
||||
cJSON_AddNumberToObject(tmpJson, PRIVACY_SUBTYPE.c_str(), 1);
|
||||
cJSON_AddStringToObject(tmpJson, PRIVACY_NETWORKID.c_str(), NETWORK_ID.c_str());
|
||||
cJSON_AddItemToArray(jsonArrayMsg, tmpJson);
|
||||
AppExecFwk::InnerEvent::Pointer msgEvent = AppExecFwk::InnerEvent::Get(COMP_START_PAGE,
|
||||
std::shared_ptr<cJSON>(jsonArrayMsg, cJSON_Delete), 0);
|
||||
EXPECT_NO_FATAL_FAILURE(compPrivacy_->eventHandler_->ProcessEvent(msgEvent));
|
||||
}
|
||||
|
||||
HWTEST_F(ComponentPrivacyTest, ProcessEvent_002, TestSize.Level0)
|
||||
{
|
||||
ASSERT_TRUE(compPrivacy_ != nullptr);
|
||||
cJSON *jsonArrayMsg = cJSON_CreateArray();
|
||||
if (jsonArrayMsg == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
cJSON *tmpJson = cJSON_CreateObject();
|
||||
if (tmpJson == NULL) {
|
||||
cJSON_Delete(jsonArrayMsg);
|
||||
return;
|
||||
}
|
||||
cJSON_AddStringToObject(tmpJson, PRIVACY_SUBTYPE.c_str(), SUBTYPE_MIC.c_str());
|
||||
cJSON_AddNumberToObject(tmpJson, PRIVACY_NETWORKID.c_str(), 1);
|
||||
cJSON_AddItemToArray(jsonArrayMsg, tmpJson);
|
||||
AppExecFwk::InnerEvent::Pointer msgEvent = AppExecFwk::InnerEvent::Get(COMP_START_PAGE,
|
||||
std::shared_ptr<cJSON>(jsonArrayMsg, cJSON_Delete), 0);
|
||||
EXPECT_NO_FATAL_FAILURE(compPrivacy_->eventHandler_->ProcessEvent(msgEvent));
|
||||
}
|
||||
|
||||
HWTEST_F(ComponentPrivacyTest, ProcessEvent_003, TestSize.Level0)
|
||||
{
|
||||
ASSERT_TRUE(compPrivacy_ != nullptr);
|
||||
cJSON *jsonArrayMsg = cJSON_CreateArray();
|
||||
if (jsonArrayMsg == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
cJSON *tmpJson = cJSON_CreateObject();
|
||||
if (tmpJson == NULL) {
|
||||
cJSON_Delete(jsonArrayMsg);
|
||||
return;
|
||||
}
|
||||
cJSON_AddStringToObject(tmpJson, PRIVACY_SUBTYPE.c_str(), SUBTYPE_MIC.c_str());
|
||||
cJSON_AddStringToObject(tmpJson, PRIVACY_NETWORKID.c_str(), NETWORK_ID.c_str());
|
||||
cJSON_AddItemToArray(jsonArrayMsg, tmpJson);
|
||||
AppExecFwk::InnerEvent::Pointer msgEvent = AppExecFwk::InnerEvent::Get(COMP_START_PAGE,
|
||||
std::shared_ptr<cJSON>(jsonArrayMsg, cJSON_Delete), 0);
|
||||
EXPECT_NO_FATAL_FAILURE(compPrivacy_->eventHandler_->ProcessEvent(msgEvent));
|
||||
}
|
||||
|
||||
HWTEST_F(ComponentPrivacyTest, ProcessEvent_004, TestSize.Level0)
|
||||
{
|
||||
ASSERT_TRUE(compPrivacy_ != nullptr);
|
||||
cJSON *jsonArrayMsg = cJSON_CreateArray();
|
||||
if (jsonArrayMsg == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
cJSON *tmpJson = cJSON_CreateObject();
|
||||
if (tmpJson == NULL) {
|
||||
cJSON_Delete(jsonArrayMsg);
|
||||
return;
|
||||
}
|
||||
cJSON_AddStringToObject(tmpJson, PRIVACY_SUBTYPE.c_str(), SUBTYPE_CAMERA.c_str());
|
||||
cJSON_AddStringToObject(tmpJson, PRIVACY_NETWORKID.c_str(), NETWORK_ID.c_str());
|
||||
cJSON_AddItemToArray(jsonArrayMsg, tmpJson);
|
||||
AppExecFwk::InnerEvent::Pointer msgEvent = AppExecFwk::InnerEvent::Get(COMP_START_PAGE,
|
||||
std::shared_ptr<cJSON>(jsonArrayMsg, cJSON_Delete), 0);
|
||||
EXPECT_NO_FATAL_FAILURE(compPrivacy_->eventHandler_->ProcessEvent(msgEvent));
|
||||
}
|
||||
|
||||
HWTEST_F(ComponentPrivacyTest, ProcessEvent_005, TestSize.Level0)
|
||||
{
|
||||
ASSERT_TRUE(compPrivacy_ != nullptr);
|
||||
cJSON *jsonArrayMsg = cJSON_CreateArray();
|
||||
if (jsonArrayMsg == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
cJSON *tmpJson = cJSON_CreateObject();
|
||||
if (tmpJson == NULL) {
|
||||
cJSON_Delete(jsonArrayMsg);
|
||||
return;
|
||||
}
|
||||
cJSON_AddNumberToObject(tmpJson, PRIVACY_SUBTYPE.c_str(), 1);
|
||||
cJSON_AddItemToArray(jsonArrayMsg, tmpJson);
|
||||
AppExecFwk::InnerEvent::Pointer msgEvent = AppExecFwk::InnerEvent::Get(COMP_STOP_PAGE,
|
||||
std::shared_ptr<cJSON>(jsonArrayMsg, cJSON_Delete), 0);
|
||||
EXPECT_NO_FATAL_FAILURE(compPrivacy_->eventHandler_->ProcessEvent(msgEvent));
|
||||
}
|
||||
|
||||
HWTEST_F(ComponentPrivacyTest, ProcessEvent_006, TestSize.Level0)
|
||||
{
|
||||
ASSERT_TRUE(compPrivacy_ != nullptr);
|
||||
cJSON *jsonArrayMsg = cJSON_CreateArray();
|
||||
if (jsonArrayMsg == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
cJSON *tmpJson = cJSON_CreateObject();
|
||||
if (tmpJson == NULL) {
|
||||
cJSON_Delete(jsonArrayMsg);
|
||||
return;
|
||||
}
|
||||
cJSON_AddStringToObject(tmpJson, PRIVACY_SUBTYPE.c_str(), SUBTYPE_CAMERA.c_str());
|
||||
cJSON_AddItemToArray(jsonArrayMsg, tmpJson);
|
||||
AppExecFwk::InnerEvent::Pointer msgEvent = AppExecFwk::InnerEvent::Get(COMP_STOP_PAGE,
|
||||
std::shared_ptr<cJSON>(jsonArrayMsg, cJSON_Delete), 0);
|
||||
EXPECT_NO_FATAL_FAILURE(compPrivacy_->eventHandler_->ProcessEvent(msgEvent));
|
||||
}
|
||||
|
||||
HWTEST_F(ComponentPrivacyTest, ProcessEvent_007, TestSize.Level0)
|
||||
{
|
||||
ASSERT_TRUE(compPrivacy_ != nullptr);
|
||||
cJSON *jsonArrayMsg = cJSON_CreateArray();
|
||||
if (jsonArrayMsg == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
cJSON *tmpJson = cJSON_CreateObject();
|
||||
if (tmpJson == NULL) {
|
||||
cJSON_Delete(jsonArrayMsg);
|
||||
return;
|
||||
}
|
||||
cJSON_AddStringToObject(tmpJson, PRIVACY_SUBTYPE.c_str(), SUBTYPE_MIC.c_str());
|
||||
cJSON_AddItemToArray(jsonArrayMsg, tmpJson);
|
||||
AppExecFwk::InnerEvent::Pointer msgEvent = AppExecFwk::InnerEvent::Get(COMP_STOP_PAGE,
|
||||
std::shared_ptr<cJSON>(jsonArrayMsg, cJSON_Delete), 0);
|
||||
EXPECT_NO_FATAL_FAILURE(compPrivacy_->eventHandler_->ProcessEvent(msgEvent));
|
||||
}
|
||||
|
||||
HWTEST_F(ComponentPrivacyTest, DeviceTypeToString_001, TestSize.Level0)
|
||||
{
|
||||
if (compPrivacy_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
uint16_t deviceTypeId = 0x08;
|
||||
std::string ret = compPrivacy_->DeviceTypeToString(deviceTypeId);
|
||||
ASSERT_TRUE(compPrivacy_ != nullptr);
|
||||
std::string ret = compPrivacy_->DeviceTypeToString(DEVICE_TYPE_WIFI_CAMERA);
|
||||
EXPECT_EQ("camera", ret);
|
||||
|
||||
deviceTypeId = 0x0A;
|
||||
ret = compPrivacy_->DeviceTypeToString(deviceTypeId);
|
||||
ret = compPrivacy_->DeviceTypeToString(DEVICE_TYPE_AUDIO);
|
||||
EXPECT_EQ("audio", ret);
|
||||
|
||||
deviceTypeId = 0x0C;
|
||||
ret = compPrivacy_->DeviceTypeToString(deviceTypeId);
|
||||
ret = compPrivacy_->DeviceTypeToString(DEVICE_TYPE_PC);
|
||||
EXPECT_EQ("pc", ret);
|
||||
|
||||
deviceTypeId = 0x0E;
|
||||
ret = compPrivacy_->DeviceTypeToString(deviceTypeId);
|
||||
ret = compPrivacy_->DeviceTypeToString(DEVICE_TYPE_PHONE);
|
||||
EXPECT_EQ("phone", ret);
|
||||
|
||||
deviceTypeId = 0x11;
|
||||
ret = compPrivacy_->DeviceTypeToString(deviceTypeId);
|
||||
ret = compPrivacy_->DeviceTypeToString(DEVICE_TYPE_PAD);
|
||||
EXPECT_EQ("pad", ret);
|
||||
|
||||
deviceTypeId = 0x6D;
|
||||
ret = compPrivacy_->DeviceTypeToString(deviceTypeId);
|
||||
ret = compPrivacy_->DeviceTypeToString(DEVICE_TYPE_WATCH);
|
||||
EXPECT_EQ("watch", ret);
|
||||
|
||||
deviceTypeId = 0x83;
|
||||
ret = compPrivacy_->DeviceTypeToString(deviceTypeId);
|
||||
ret = compPrivacy_->DeviceTypeToString(DEVICE_TYPE_CAR);
|
||||
EXPECT_EQ("car", ret);
|
||||
|
||||
deviceTypeId = 0x9C;
|
||||
ret = compPrivacy_->DeviceTypeToString(deviceTypeId);
|
||||
ret = compPrivacy_->DeviceTypeToString(DEVICE_TYPE_TV);
|
||||
EXPECT_EQ("tv", ret);
|
||||
|
||||
deviceTypeId = 0xA02;
|
||||
ret = compPrivacy_->DeviceTypeToString(deviceTypeId);
|
||||
ret = compPrivacy_->DeviceTypeToString(DEVICE_TYPE_SMART_DISPLAY);
|
||||
EXPECT_EQ("display", ret);
|
||||
|
||||
deviceTypeId = 0xA2F;
|
||||
ret = compPrivacy_->DeviceTypeToString(deviceTypeId);
|
||||
ret = compPrivacy_->DeviceTypeToString(DEVICE_TYPE_2IN1);
|
||||
EXPECT_EQ("2in1", ret);
|
||||
|
||||
deviceTypeId = 0x00;
|
||||
ret = compPrivacy_->DeviceTypeToString(deviceTypeId);
|
||||
ret = compPrivacy_->DeviceTypeToString(DEVICE_TYPE_UNKNOWN);
|
||||
EXPECT_EQ("unknown", ret);
|
||||
}
|
||||
}
|
||||
|
@ -410,7 +410,7 @@ HWTEST_F(DbAdapterTest, RemoveDeviceData_001, TestSize.Level0)
|
||||
return;
|
||||
}
|
||||
g_dbAdapterPtr->GetKvStorePtr(true, DistributedKv::DataType::TYPE_DYNAMICAL);
|
||||
EXPECT_EQ(ERR_DH_FWK_RESOURCE_KV_STORAGE_OPERATION_FAIL, g_dbAdapterPtr->RemoveDeviceData(TEST_DEV_ID_0));
|
||||
EXPECT_EQ(DH_FWK_SUCCESS, g_dbAdapterPtr->RemoveDeviceData(TEST_DEV_ID_0));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -30,9 +30,18 @@ namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
namespace {
|
||||
constexpr uint16_t DEV_TYPE_TEST = 14;
|
||||
constexpr uint32_t DH_TYPE_TEST = 0x01;
|
||||
const std::string DHID_TEST = "123456789";
|
||||
const std::string DEVID_TEST = "111222333";
|
||||
const std::string DEVNAME_TEST = "camera";
|
||||
const std::string DHATTRS_TEST = "attrs";
|
||||
const std::string DHSUBTYPE_TEST = "subtype";
|
||||
const std::string UDIDHASH_TEST = "987654321";
|
||||
const std::string SINKVER_TEST = "1.0";
|
||||
|
||||
}
|
||||
|
||||
class MetaInfoMgrTest : public testing::Test {
|
||||
class MetaCapInfoTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase(void);
|
||||
static void TearDownTestCase(void);
|
||||
@ -40,290 +49,302 @@ public:
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void MetaInfoMgrTest::SetUp() {}
|
||||
void MetaCapInfoTest::SetUp() {}
|
||||
|
||||
void MetaInfoMgrTest::TearDown() {}
|
||||
void MetaCapInfoTest::TearDown() {}
|
||||
|
||||
void MetaInfoMgrTest::SetUpTestCase() {}
|
||||
void MetaCapInfoTest::SetUpTestCase() {}
|
||||
|
||||
void MetaInfoMgrTest::TearDownTestCase() {}
|
||||
void MetaCapInfoTest::TearDownTestCase() {}
|
||||
|
||||
HWTEST_F(MetaInfoMgrTest, Init_001, TestSize.Level0)
|
||||
HWTEST_F(MetaCapInfoTest, FromJsonString_001, TestSize.Level0)
|
||||
{
|
||||
auto ret = MetaInfoManager::GetInstance()->Init();
|
||||
EXPECT_EQ(DH_FWK_SUCCESS, ret);
|
||||
ret = MetaInfoManager::GetInstance()->UnInit();
|
||||
EXPECT_EQ(DH_FWK_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(MetaInfoMgrTest, UnInit_001, TestSize.Level0)
|
||||
{
|
||||
MetaInfoManager::GetInstance()->dbAdapterPtr_ = nullptr;
|
||||
auto ret = MetaInfoManager::GetInstance()->UnInit();
|
||||
EXPECT_EQ(ERR_DH_FWK_RESOURCE_UNINIT_DB_FAILED, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(MetaInfoMgrTest, AddMetaCapInfos_001, TestSize.Level0)
|
||||
{
|
||||
std::vector<std::shared_ptr<MetaCapabilityInfo>> metaCapInfos;
|
||||
auto ret = MetaInfoManager::GetInstance()->AddMetaCapInfos(metaCapInfos);
|
||||
EXPECT_EQ(ERR_DH_FWK_RESOURCE_RES_DB_DATA_INVALID, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(MetaInfoMgrTest, AddMetaCapInfos_002, TestSize.Level0)
|
||||
{
|
||||
std::string deviceId = "deviceId_test";
|
||||
std::string udidHash = "udidHash_test";
|
||||
std::string dhId = "dhId_test";
|
||||
std::shared_ptr<MetaCapabilityInfo> metaCapInfo = std::make_shared<MetaCapabilityInfo>(
|
||||
dhId, deviceId, "devName_test", DEV_TYPE_TEST, DHType::CAMERA, "attrs_test", "subtype", udidHash, "1.0");
|
||||
std::vector<std::shared_ptr<MetaCapabilityInfo>> metaCapInfos;
|
||||
metaCapInfos.push_back(metaCapInfo);
|
||||
auto ret = MetaInfoManager::GetInstance()->AddMetaCapInfos(metaCapInfos);
|
||||
EXPECT_EQ(ERR_DH_FWK_RESOURCE_DB_ADAPTER_POINTER_NULL, ret);
|
||||
|
||||
MetaInfoManager::GetInstance()->Init();
|
||||
ret = MetaInfoManager::GetInstance()->AddMetaCapInfos(metaCapInfos);
|
||||
EXPECT_EQ(DH_FWK_SUCCESS, ret);
|
||||
MetaInfoManager::GetInstance()->UnInit();
|
||||
}
|
||||
|
||||
HWTEST_F(MetaInfoMgrTest, SyncMetaInfoFromDB_001, TestSize.Level0)
|
||||
{
|
||||
std::string udidHash = "";
|
||||
auto ret = MetaInfoManager::GetInstance()->SyncMetaInfoFromDB(udidHash);
|
||||
uint16_t devType = 1;
|
||||
std::shared_ptr<MetaCapabilityInfo> metaCapInfo =
|
||||
std::make_shared<MetaCapabilityInfo>("", "", "", devType, DHType::CAMERA, "", "", "", "");
|
||||
std::string jsonStr = "";
|
||||
auto ret = metaCapInfo->FromJsonString(jsonStr);
|
||||
EXPECT_EQ(ERR_DH_FWK_PARA_INVALID, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(MetaInfoMgrTest, SyncMetaInfoFromDB_002, TestSize.Level0)
|
||||
HWTEST_F(MetaCapInfoTest, FromJsonString_002, TestSize.Level0)
|
||||
{
|
||||
std::string udidHash = "132456798";
|
||||
auto ret = MetaInfoManager::GetInstance()->SyncMetaInfoFromDB(udidHash);
|
||||
EXPECT_EQ(ERR_DH_FWK_RESOURCE_DB_ADAPTER_POINTER_NULL, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(MetaInfoMgrTest, SyncMetaInfoFromDB_003, TestSize.Level0)
|
||||
{
|
||||
std::string udidHash = "132456798";
|
||||
MetaInfoManager::GetInstance()->Init();
|
||||
auto ret = MetaInfoManager::GetInstance()->SyncMetaInfoFromDB(udidHash);
|
||||
EXPECT_EQ(ERR_DH_FWK_RESOURCE_DB_ADAPTER_OPERATION_FAIL, ret);
|
||||
MetaInfoManager::GetInstance()->UnInit();
|
||||
}
|
||||
|
||||
HWTEST_F(MetaInfoMgrTest, SyncRemoteMetaInfos_001, TestSize.Level0)
|
||||
{
|
||||
auto ret = MetaInfoManager::GetInstance()->SyncRemoteMetaInfos();
|
||||
EXPECT_EQ(ERR_DH_FWK_RESOURCE_DB_ADAPTER_POINTER_NULL, ret);
|
||||
|
||||
MetaInfoManager::GetInstance()->Init();
|
||||
ret = MetaInfoManager::GetInstance()->SyncRemoteMetaInfos();
|
||||
EXPECT_EQ(DH_FWK_SUCCESS, ret);
|
||||
MetaInfoManager::GetInstance()->UnInit();
|
||||
}
|
||||
|
||||
HWTEST_F(MetaInfoMgrTest, GetDataByKeyPrefix_001, TestSize.Level0)
|
||||
{
|
||||
std::string keyPrefix = "";
|
||||
MetaCapInfoMap metaCapMap;
|
||||
auto ret = MetaInfoManager::GetInstance()->GetDataByKeyPrefix(keyPrefix, metaCapMap);
|
||||
EXPECT_EQ(ERR_DH_FWK_PARA_INVALID, ret);
|
||||
|
||||
keyPrefix = "keyPrefix_test";
|
||||
ret = MetaInfoManager::GetInstance()->GetDataByKeyPrefix(keyPrefix, metaCapMap);
|
||||
EXPECT_EQ(ERR_DH_FWK_RESOURCE_DB_ADAPTER_POINTER_NULL, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(MetaInfoMgrTest, GetDataByKeyPrefix_002, TestSize.Level0)
|
||||
{
|
||||
std::string keyPrefix = "keyPrefix_test";
|
||||
MetaCapInfoMap metaCapMap;
|
||||
MetaInfoManager::GetInstance()->Init();
|
||||
auto ret = MetaInfoManager::GetInstance()->GetDataByKeyPrefix(keyPrefix, metaCapMap);
|
||||
EXPECT_EQ(ERR_DH_FWK_RESOURCE_DB_ADAPTER_OPERATION_FAIL, ret);
|
||||
MetaInfoManager::GetInstance()->UnInit();
|
||||
}
|
||||
|
||||
HWTEST_F(MetaInfoMgrTest, RemoveMetaInfoByKey_001, TestSize.Level0)
|
||||
{
|
||||
std::string key = "";
|
||||
auto ret = MetaInfoManager::GetInstance()->RemoveMetaInfoByKey(key);
|
||||
EXPECT_EQ(ERR_DH_FWK_PARA_INVALID, ret);
|
||||
|
||||
key = "key_test";
|
||||
ret = MetaInfoManager::GetInstance()->RemoveMetaInfoByKey(key);
|
||||
EXPECT_EQ(ERR_DH_FWK_RESOURCE_DB_ADAPTER_POINTER_NULL, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(MetaInfoMgrTest, RemoveMetaInfoByKey_002, TestSize.Level0)
|
||||
{
|
||||
std::string key = "key_test";
|
||||
MetaInfoManager::GetInstance()->Init();
|
||||
auto ret = MetaInfoManager::GetInstance()->RemoveMetaInfoByKey(key);
|
||||
EXPECT_EQ(DH_FWK_SUCCESS, ret);
|
||||
MetaInfoManager::GetInstance()->UnInit();
|
||||
}
|
||||
|
||||
HWTEST_F(MetaInfoMgrTest, GetMetaCapInfo_001, TestSize.Level0)
|
||||
{
|
||||
std::string udidHash = "";
|
||||
std::string dhId = "";
|
||||
std::shared_ptr<MetaCapabilityInfo> metaCapPtr;
|
||||
auto ret = MetaInfoManager::GetInstance()->GetMetaCapInfo(udidHash, dhId, metaCapPtr);
|
||||
EXPECT_EQ(ERR_DH_FWK_PARA_INVALID, ret);
|
||||
|
||||
udidHash = "123456789";
|
||||
ret = MetaInfoManager::GetInstance()->GetMetaCapInfo(udidHash, dhId, metaCapPtr);
|
||||
EXPECT_EQ(ERR_DH_FWK_PARA_INVALID, ret);
|
||||
|
||||
udidHash = "";
|
||||
dhId = "123456789";
|
||||
ret = MetaInfoManager::GetInstance()->GetMetaCapInfo(udidHash, dhId, metaCapPtr);
|
||||
EXPECT_EQ(ERR_DH_FWK_PARA_INVALID, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(MetaInfoMgrTest, GetMetaCapInfo_002, TestSize.Level0)
|
||||
{
|
||||
std::string deviceId = "deviceId_test";
|
||||
std::string udidHash = "udidHash_test";
|
||||
std::string dhId = "dhId_test";
|
||||
std::shared_ptr<MetaCapabilityInfo> metaCapPtr;
|
||||
std::shared_ptr<MetaCapabilityInfo> dhMetaCapInfo = std::make_shared<MetaCapabilityInfo>(
|
||||
dhId, deviceId, "devName_test", DEV_TYPE_TEST, DHType::CAMERA, "attrs_test", "subtype", udidHash, "1.0");
|
||||
std::string key = udidHash + "###" + dhId;
|
||||
MetaInfoManager::GetInstance()->globalMetaInfoMap_[key] = dhMetaCapInfo;
|
||||
auto ret = MetaInfoManager::GetInstance()->GetMetaCapInfo(deviceId, dhId, metaCapPtr);
|
||||
EXPECT_EQ(ERR_DH_FWK_RESOURCE_CAPABILITY_MAP_NOT_FOUND, ret);
|
||||
|
||||
ret = MetaInfoManager::GetInstance()->GetMetaCapInfo(udidHash, dhId, metaCapPtr);
|
||||
EXPECT_EQ(DH_FWK_SUCCESS, ret);
|
||||
MetaInfoManager::GetInstance()->globalMetaInfoMap_.clear();
|
||||
}
|
||||
|
||||
HWTEST_F(MetaInfoMgrTest, GetMetaCapInfosByUdidHash_001, TestSize.Level0)
|
||||
{
|
||||
std::string udidHash = "";
|
||||
std::vector<std::shared_ptr<MetaCapabilityInfo>> metaCapInfos;
|
||||
MetaInfoManager::GetInstance()->GetMetaCapInfosByUdidHash(udidHash, metaCapInfos);
|
||||
|
||||
udidHash = "udidHash_test";
|
||||
std::string deviceId = "deviceId_test";
|
||||
std::string dhId = "dhId_test";
|
||||
std::shared_ptr<MetaCapabilityInfo> metaCapInfo = std::make_shared<MetaCapabilityInfo>(
|
||||
dhId, deviceId, "devName_test", DEV_TYPE_TEST, DHType::CAMERA, "attrs_test", "subtype", udidHash, "1.0");
|
||||
std::string key = udidHash + "###" + dhId;
|
||||
MetaInfoManager::GetInstance()->globalMetaInfoMap_[key] = metaCapInfo;
|
||||
MetaInfoManager::GetInstance()->GetMetaCapInfosByUdidHash(deviceId, metaCapInfos);
|
||||
EXPECT_TRUE(metaCapInfos.empty());
|
||||
|
||||
MetaInfoManager::GetInstance()->GetMetaCapInfosByUdidHash(udidHash, metaCapInfos);
|
||||
EXPECT_FALSE(metaCapInfos.empty());
|
||||
MetaInfoManager::GetInstance()->globalMetaInfoMap_.clear();
|
||||
}
|
||||
|
||||
HWTEST_F(MetaInfoMgrTest, GetMetaCapByValue_001, TestSize.Level0)
|
||||
{
|
||||
std::string value = "";
|
||||
std::shared_ptr<MetaCapabilityInfo> metaCapPtr = nullptr;
|
||||
auto ret = MetaInfoManager::GetInstance()->GetMetaCapByValue(value, metaCapPtr);
|
||||
EXPECT_EQ(ERR_DH_FWK_PARA_INVALID, ret);
|
||||
|
||||
value = "invalid JSON string";
|
||||
ret = MetaInfoManager::GetInstance()->GetMetaCapByValue(value, metaCapPtr);
|
||||
EXPECT_EQ(ERR_DH_FWK_JSON_PARSE_FAILED, ret);
|
||||
|
||||
std::string deviceId = "deviceId_test";
|
||||
std::string udidHash = "udidHash_test";
|
||||
std::string dhId = "dhId_test";
|
||||
metaCapPtr = std::make_shared<MetaCapabilityInfo>(
|
||||
dhId, deviceId, "devName_test", DEV_TYPE_TEST, DHType::CAMERA, "attrs_test", "subtype", udidHash, "1.0");
|
||||
ret = MetaInfoManager::GetInstance()->GetMetaCapByValue(value, metaCapPtr);
|
||||
EXPECT_EQ(ERR_DH_FWK_JSON_PARSE_FAILED, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(MetaInfoMgrTest, GetMetaDataByDHType_001, TestSize.Level0)
|
||||
{
|
||||
std::string deviceId = "deviceId_test";
|
||||
std::string udidHash = "udidHash_test";
|
||||
std::string dhId = "dhId_test";
|
||||
MetaCapInfoMap metaInfoMap;
|
||||
std::shared_ptr<MetaCapabilityInfo> dhMetaCapInfo = std::make_shared<MetaCapabilityInfo>(
|
||||
dhId, deviceId, "devName_test", DEV_TYPE_TEST, DHType::CAMERA, "attrs_test", "subtype", udidHash, "1.0");
|
||||
std::string key = udidHash + "###" + dhId;
|
||||
MetaInfoManager::GetInstance()->globalMetaInfoMap_[key] = dhMetaCapInfo;
|
||||
auto ret = MetaInfoManager::GetInstance()->GetMetaDataByDHType(DHType::AUDIO, metaInfoMap);
|
||||
EXPECT_EQ(DH_FWK_SUCCESS, ret);
|
||||
|
||||
ret = MetaInfoManager::GetInstance()->GetMetaDataByDHType(DHType::CAMERA, metaInfoMap);
|
||||
EXPECT_EQ(DH_FWK_SUCCESS, ret);
|
||||
MetaInfoManager::GetInstance()->globalMetaInfoMap_.clear();
|
||||
}
|
||||
|
||||
HWTEST_F(MetaInfoMgrTest, SyncDataByNetworkId_001, TestSize.Level0)
|
||||
{
|
||||
std::string networkId = "";
|
||||
auto ret = MetaInfoManager::GetInstance()->SyncDataByNetworkId(networkId);
|
||||
EXPECT_EQ(ERR_DH_FWK_PARA_INVALID, ret);
|
||||
|
||||
networkId = "networkId_test";
|
||||
ret = MetaInfoManager::GetInstance()->SyncDataByNetworkId(networkId);
|
||||
EXPECT_EQ(ERR_DH_FWK_RESOURCE_DB_ADAPTER_POINTER_NULL, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(MetaInfoMgrTest, SyncDataByNetworkId_002, TestSize.Level0)
|
||||
{
|
||||
std::string networkId = "networkId_test";
|
||||
MetaInfoManager::GetInstance()->Init();
|
||||
auto ret = MetaInfoManager::GetInstance()->SyncDataByNetworkId(networkId);
|
||||
EXPECT_EQ(DH_FWK_SUCCESS, ret);
|
||||
MetaInfoManager::GetInstance()->UnInit();
|
||||
}
|
||||
|
||||
HWTEST_F(MetaInfoMgrTest, RemoveMetaInfoInMemByUdid_001, TestSize.Level0)
|
||||
{
|
||||
std::string peerudid = "123456789";
|
||||
std::string peerudIdHash = Sha256(peerudid);
|
||||
std::string deviceId = "deviceId_test";
|
||||
std::string udidHash = "udidHash_test";
|
||||
std::string dhId = "dhId_test";
|
||||
std::shared_ptr<MetaCapabilityInfo> metaCapPtr = std::make_shared<MetaCapabilityInfo>(
|
||||
dhId, deviceId, "devName_test", DEV_TYPE_TEST, DHType::CAMERA, "attrs_test", "subtype", udidHash, "1.0");
|
||||
std::string key = peerudIdHash + "###" + dhId;
|
||||
MetaInfoManager::GetInstance()->globalMetaInfoMap_[key] = metaCapPtr;
|
||||
auto ret = MetaInfoManager::GetInstance()->RemoveMetaInfoInMemByUdid(deviceId);
|
||||
EXPECT_EQ(DH_FWK_SUCCESS, ret);
|
||||
|
||||
ret = MetaInfoManager::GetInstance()->RemoveMetaInfoInMemByUdid(peerudid);
|
||||
uint16_t devType = 1;
|
||||
std::shared_ptr<MetaCapabilityInfo> metaCapInfo =
|
||||
std::make_shared<MetaCapabilityInfo>("", "", "", devType, DHType::CAMERA, "", "", "", "");
|
||||
cJSON *jsonObj = cJSON_CreateObject();
|
||||
ASSERT_TRUE(jsonObj != nullptr);
|
||||
cJSON_AddStringToObject(jsonObj, DH_ID.c_str(), DHID_TEST.c_str());
|
||||
char* cjson = cJSON_PrintUnformatted(jsonObj);
|
||||
if (cjson == nullptr) {
|
||||
cJSON_Delete(jsonObj);
|
||||
return;
|
||||
}
|
||||
std::string jsonStr(cjson);
|
||||
auto ret = metaCapInfo->FromJsonString(jsonStr);
|
||||
cJSON_free(cjson);
|
||||
cJSON_Delete(jsonObj);
|
||||
EXPECT_EQ(DH_FWK_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(MetaInfoMgrTest, ClearRemoteDeviceMetaInfoData_001, TestSize.Level0)
|
||||
HWTEST_F(MetaCapInfoTest, ToJson_001, TestSize.Level0)
|
||||
{
|
||||
MetaInfoManager::GetInstance()->Init();
|
||||
std::string peerudid = "peerudid_test";
|
||||
std::string peeruuid = "peeruuid_test";
|
||||
auto ret = MetaInfoManager::GetInstance()->ClearRemoteDeviceMetaInfoData(peerudid, peeruuid);
|
||||
EXPECT_EQ(ERR_DH_FWK_RESOURCE_DB_ADAPTER_OPERATION_FAIL, ret);
|
||||
|
||||
MetaInfoManager::GetInstance()->UnInit();
|
||||
ret = MetaInfoManager::GetInstance()->ClearRemoteDeviceMetaInfoData(peerudid, peeruuid);
|
||||
EXPECT_EQ(ERR_DH_FWK_RESOURCE_DB_ADAPTER_POINTER_NULL, ret);
|
||||
cJSON *jsonObject = nullptr;
|
||||
MetaCapabilityInfo metaCapInfo;
|
||||
EXPECT_NO_FATAL_FAILURE(ToJson(jsonObject, metaCapInfo));
|
||||
}
|
||||
|
||||
HWTEST_F(MetaInfoMgrTest, GetEntriesByKeys_001, TestSize.Level0)
|
||||
HWTEST_F(MetaCapInfoTest, FromJson_001, TestSize.Level0)
|
||||
{
|
||||
std::vector<std::string> keys;
|
||||
auto ret = MetaInfoManager::GetInstance()->GetEntriesByKeys(keys);
|
||||
EXPECT_EQ(0, ret.size());
|
||||
MetaCapabilityInfo metaCapInfo;
|
||||
cJSON *jsonObj = cJSON_CreateObject();
|
||||
ASSERT_TRUE(jsonObj != nullptr);
|
||||
cJSON_AddNumberToObject(jsonObj, DH_ID.c_str(), 1);
|
||||
EXPECT_NO_FATAL_FAILURE(FromJson(jsonObj, metaCapInfo));
|
||||
cJSON_Delete(jsonObj);
|
||||
}
|
||||
|
||||
keys.push_back("key_test");
|
||||
ret = MetaInfoManager::GetInstance()->GetEntriesByKeys(keys);
|
||||
EXPECT_EQ(0, ret.size());
|
||||
HWTEST_F(MetaCapInfoTest, FromJson_002, TestSize.Level0)
|
||||
{
|
||||
MetaCapabilityInfo metaCapInfo;
|
||||
cJSON *jsonObj = cJSON_CreateObject();
|
||||
ASSERT_TRUE(jsonObj != nullptr);
|
||||
cJSON_AddStringToObject(jsonObj, DH_ID.c_str(), DHID_TEST.c_str());
|
||||
cJSON_AddNumberToObject(jsonObj, DEV_ID.c_str(), 1);
|
||||
EXPECT_NO_FATAL_FAILURE(FromJson(jsonObj, metaCapInfo));
|
||||
cJSON_Delete(jsonObj);
|
||||
}
|
||||
|
||||
MetaInfoManager::GetInstance()->Init();
|
||||
ret = MetaInfoManager::GetInstance()->GetEntriesByKeys(keys);
|
||||
EXPECT_EQ(0, ret.size());
|
||||
MetaInfoManager::GetInstance()->UnInit();
|
||||
HWTEST_F(MetaCapInfoTest, FromJson_003, TestSize.Level0)
|
||||
{
|
||||
MetaCapabilityInfo metaCapInfo;
|
||||
cJSON *jsonObj = cJSON_CreateObject();
|
||||
ASSERT_TRUE(jsonObj != nullptr);
|
||||
cJSON_AddStringToObject(jsonObj, DH_ID.c_str(), DHID_TEST.c_str());
|
||||
cJSON_AddStringToObject(jsonObj, DEV_ID.c_str(), DEVID_TEST.c_str());
|
||||
cJSON_AddNumberToObject(jsonObj, DEV_NAME.c_str(), 1);
|
||||
EXPECT_NO_FATAL_FAILURE(FromJson(jsonObj, metaCapInfo));
|
||||
cJSON_Delete(jsonObj);
|
||||
}
|
||||
|
||||
HWTEST_F(MetaCapInfoTest, FromJson_004, TestSize.Level0)
|
||||
{
|
||||
MetaCapabilityInfo metaCapInfo;
|
||||
cJSON *jsonObj = cJSON_CreateObject();
|
||||
ASSERT_TRUE(jsonObj != nullptr);
|
||||
std::string devTypeTest = "devTypeTest";
|
||||
cJSON_AddStringToObject(jsonObj, DH_ID.c_str(), DHID_TEST.c_str());
|
||||
cJSON_AddStringToObject(jsonObj, DEV_ID.c_str(), DEVID_TEST.c_str());
|
||||
cJSON_AddStringToObject(jsonObj, DEV_NAME.c_str(), DEVNAME_TEST.c_str());
|
||||
cJSON_AddStringToObject(jsonObj, DEV_TYPE.c_str(), devTypeTest.c_str());
|
||||
EXPECT_NO_FATAL_FAILURE(FromJson(jsonObj, metaCapInfo));
|
||||
cJSON_Delete(jsonObj);
|
||||
}
|
||||
|
||||
HWTEST_F(MetaCapInfoTest, FromJson_005, TestSize.Level0)
|
||||
{
|
||||
MetaCapabilityInfo metaCapInfo;
|
||||
cJSON *jsonObj = cJSON_CreateObject();
|
||||
ASSERT_TRUE(jsonObj != nullptr);
|
||||
std::string dhTypeTest = "dhTypeTest";
|
||||
cJSON_AddStringToObject(jsonObj, DH_ID.c_str(), DHID_TEST.c_str());
|
||||
cJSON_AddStringToObject(jsonObj, DEV_ID.c_str(), DEVID_TEST.c_str());
|
||||
cJSON_AddStringToObject(jsonObj, DEV_NAME.c_str(), DEVNAME_TEST.c_str());
|
||||
cJSON_AddNumberToObject(jsonObj, DEV_TYPE.c_str(), DEV_TYPE_TEST);
|
||||
cJSON_AddStringToObject(jsonObj, DH_TYPE.c_str(), dhTypeTest.c_str());
|
||||
EXPECT_NO_FATAL_FAILURE(FromJson(jsonObj, metaCapInfo));
|
||||
cJSON_Delete(jsonObj);
|
||||
}
|
||||
|
||||
HWTEST_F(MetaCapInfoTest, FromJson_006, TestSize.Level0)
|
||||
{
|
||||
MetaCapabilityInfo metaCapInfo;
|
||||
cJSON *jsonObj = cJSON_CreateObject();
|
||||
ASSERT_TRUE(jsonObj != nullptr);
|
||||
std::string dhTypeTest = "dhTypeTest";
|
||||
cJSON_AddStringToObject(jsonObj, DH_ID.c_str(), DHID_TEST.c_str());
|
||||
cJSON_AddStringToObject(jsonObj, DEV_ID.c_str(), DEVID_TEST.c_str());
|
||||
cJSON_AddStringToObject(jsonObj, DEV_NAME.c_str(), DEVNAME_TEST.c_str());
|
||||
cJSON_AddNumberToObject(jsonObj, DEV_TYPE.c_str(), DEV_TYPE_TEST);
|
||||
cJSON_AddNumberToObject(jsonObj, DH_TYPE.c_str(), DH_TYPE_TEST);
|
||||
cJSON_AddNumberToObject(jsonObj, DH_ATTRS.c_str(), 1);
|
||||
EXPECT_NO_FATAL_FAILURE(FromJson(jsonObj, metaCapInfo));
|
||||
cJSON_Delete(jsonObj);
|
||||
}
|
||||
|
||||
HWTEST_F(MetaCapInfoTest, FromJson_007, TestSize.Level0)
|
||||
{
|
||||
MetaCapabilityInfo metaCapInfo;
|
||||
cJSON *jsonObj = cJSON_CreateObject();
|
||||
ASSERT_TRUE(jsonObj != nullptr);
|
||||
std::string dhTypeTest = "dhTypeTest";
|
||||
cJSON_AddStringToObject(jsonObj, DH_ID.c_str(), DHID_TEST.c_str());
|
||||
cJSON_AddStringToObject(jsonObj, DEV_ID.c_str(), DEVID_TEST.c_str());
|
||||
cJSON_AddStringToObject(jsonObj, DEV_NAME.c_str(), DEVNAME_TEST.c_str());
|
||||
cJSON_AddNumberToObject(jsonObj, DEV_TYPE.c_str(), DEV_TYPE_TEST);
|
||||
cJSON_AddNumberToObject(jsonObj, DH_TYPE.c_str(), DH_TYPE_TEST);
|
||||
cJSON_AddStringToObject(jsonObj, DH_ATTRS.c_str(), DHATTRS_TEST.c_str());
|
||||
cJSON_AddNumberToObject(jsonObj, DH_SUBTYPE.c_str(), 1);
|
||||
EXPECT_NO_FATAL_FAILURE(FromJson(jsonObj, metaCapInfo));
|
||||
cJSON_Delete(jsonObj);
|
||||
}
|
||||
|
||||
HWTEST_F(MetaCapInfoTest, FromJson_008, TestSize.Level0)
|
||||
{
|
||||
MetaCapabilityInfo metaCapInfo;
|
||||
cJSON *jsonObj = cJSON_CreateObject();
|
||||
ASSERT_TRUE(jsonObj != nullptr);
|
||||
std::string dhTypeTest = "dhTypeTest";
|
||||
cJSON_AddStringToObject(jsonObj, DH_ID.c_str(), DHID_TEST.c_str());
|
||||
cJSON_AddStringToObject(jsonObj, DEV_ID.c_str(), DEVID_TEST.c_str());
|
||||
cJSON_AddStringToObject(jsonObj, DEV_NAME.c_str(), DEVNAME_TEST.c_str());
|
||||
cJSON_AddNumberToObject(jsonObj, DEV_TYPE.c_str(), DEV_TYPE_TEST);
|
||||
cJSON_AddNumberToObject(jsonObj, DH_TYPE.c_str(), DH_TYPE_TEST);
|
||||
cJSON_AddStringToObject(jsonObj, DH_ATTRS.c_str(), DHATTRS_TEST.c_str());
|
||||
cJSON_AddStringToObject(jsonObj, DH_SUBTYPE.c_str(), DHSUBTYPE_TEST.c_str());
|
||||
cJSON_AddNumberToObject(jsonObj, DEV_UDID_HASH.c_str(), 1);
|
||||
EXPECT_NO_FATAL_FAILURE(FromJson(jsonObj, metaCapInfo));
|
||||
cJSON_Delete(jsonObj);
|
||||
}
|
||||
|
||||
HWTEST_F(MetaCapInfoTest, FromJson_009, TestSize.Level0)
|
||||
{
|
||||
MetaCapabilityInfo metaCapInfo;
|
||||
cJSON *jsonObj = cJSON_CreateObject();
|
||||
ASSERT_TRUE(jsonObj != nullptr);
|
||||
std::string dhTypeTest = "dhTypeTest";
|
||||
cJSON_AddStringToObject(jsonObj, DH_ID.c_str(), DHID_TEST.c_str());
|
||||
cJSON_AddStringToObject(jsonObj, DEV_ID.c_str(), DEVID_TEST.c_str());
|
||||
cJSON_AddStringToObject(jsonObj, DEV_NAME.c_str(), DEVNAME_TEST.c_str());
|
||||
cJSON_AddNumberToObject(jsonObj, DEV_TYPE.c_str(), DEV_TYPE_TEST);
|
||||
cJSON_AddNumberToObject(jsonObj, DH_TYPE.c_str(), DH_TYPE_TEST);
|
||||
cJSON_AddStringToObject(jsonObj, DH_ATTRS.c_str(), DHATTRS_TEST.c_str());
|
||||
cJSON_AddStringToObject(jsonObj, DH_SUBTYPE.c_str(), DHSUBTYPE_TEST.c_str());
|
||||
cJSON_AddStringToObject(jsonObj, DEV_UDID_HASH.c_str(), UDIDHASH_TEST.c_str());
|
||||
cJSON_AddNumberToObject(jsonObj, SINK_VER.c_str(), 1);
|
||||
EXPECT_NO_FATAL_FAILURE(FromJson(jsonObj, metaCapInfo));
|
||||
cJSON_Delete(jsonObj);
|
||||
}
|
||||
|
||||
HWTEST_F(MetaCapInfoTest, FromJson_010, TestSize.Level0)
|
||||
{
|
||||
MetaCapabilityInfo metaCapInfo;
|
||||
cJSON *jsonObj = cJSON_CreateObject();
|
||||
ASSERT_TRUE(jsonObj != nullptr);
|
||||
cJSON_AddStringToObject(jsonObj, DH_ID.c_str(), DHID_TEST.c_str());
|
||||
cJSON_AddStringToObject(jsonObj, DEV_ID.c_str(), DEVID_TEST.c_str());
|
||||
cJSON_AddStringToObject(jsonObj, DEV_NAME.c_str(), DEVNAME_TEST.c_str());
|
||||
cJSON_AddNumberToObject(jsonObj, DEV_TYPE.c_str(), DEV_TYPE_TEST);
|
||||
cJSON_AddNumberToObject(jsonObj, DH_TYPE.c_str(), DH_TYPE_TEST);
|
||||
cJSON_AddStringToObject(jsonObj, DH_ATTRS.c_str(), DHATTRS_TEST.c_str());
|
||||
cJSON_AddStringToObject(jsonObj, DH_SUBTYPE.c_str(), DHSUBTYPE_TEST.c_str());
|
||||
cJSON_AddStringToObject(jsonObj, DEV_UDID_HASH.c_str(), UDIDHASH_TEST.c_str());
|
||||
cJSON_AddStringToObject(jsonObj, SINK_VER.c_str(), SINKVER_TEST.c_str());
|
||||
EXPECT_NO_FATAL_FAILURE(FromJson(jsonObj, metaCapInfo));
|
||||
cJSON_Delete(jsonObj);
|
||||
}
|
||||
|
||||
HWTEST_F(MetaCapInfoTest, Compare_001, TestSize.Level0)
|
||||
{
|
||||
uint16_t devType = 1;
|
||||
MetaCapabilityInfo metaCapInfo("", "", "", devType, DHType::CAMERA, "", "", "", "");
|
||||
std::shared_ptr<MetaCapabilityInfo> metaCapInfoPtr =
|
||||
std::make_shared<MetaCapabilityInfo>("devid_123", "", "", devType, DHType::CAMERA, "", "", "", "");
|
||||
auto ret = metaCapInfoPtr->Compare(metaCapInfo);
|
||||
EXPECT_EQ(false, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(MetaCapInfoTest, Compare_002, TestSize.Level0)
|
||||
{
|
||||
uint16_t devType = 1;
|
||||
MetaCapabilityInfo metaCapInfo("devid_123", "", "", devType, DHType::CAMERA, "", "", "", "");
|
||||
std::shared_ptr<MetaCapabilityInfo> metaCapInfoPtr =
|
||||
std::make_shared<MetaCapabilityInfo>("devid_123", "dhid_123", "", devType, DHType::CAMERA, "", "", "", "");
|
||||
auto ret = metaCapInfoPtr->Compare(metaCapInfo);
|
||||
EXPECT_EQ(false, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(MetaCapInfoTest, Compare_003, TestSize.Level0)
|
||||
{
|
||||
uint16_t devType = 1;
|
||||
MetaCapabilityInfo metaCapInfo("devid_123", "dhid_123", "", devType, DHType::CAMERA, "", "", "", "");
|
||||
std::shared_ptr<MetaCapabilityInfo> metaCapInfoPtr = std::make_shared<MetaCapabilityInfo>(
|
||||
"devid_123", "dhid_123", "devname", devType, DHType::CAMERA, "", "", "", "");
|
||||
auto ret = metaCapInfoPtr->Compare(metaCapInfo);
|
||||
EXPECT_EQ(false, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(MetaCapInfoTest, Compare_004, TestSize.Level0)
|
||||
{
|
||||
uint16_t devType = 1;
|
||||
MetaCapabilityInfo metaCapInfo("devid_123", "dhid_123", "devname", devType, DHType::CAMERA, "", "", "", "");
|
||||
std::shared_ptr<MetaCapabilityInfo> metaCapInfoPtr =
|
||||
std::make_shared<MetaCapabilityInfo>("devid_123", "dhid_123", "devname", 2, DHType::CAMERA, "", "", "", "");
|
||||
auto ret = metaCapInfoPtr->Compare(metaCapInfo);
|
||||
EXPECT_EQ(false, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(MetaCapInfoTest, Compare_005, TestSize.Level0)
|
||||
{
|
||||
uint16_t devType = 1;
|
||||
MetaCapabilityInfo metaCapInfo("devid_123", "dhid_123", "devname", devType, DHType::CAMERA, "", "", "", "");
|
||||
std::shared_ptr<MetaCapabilityInfo> metaCapInfoPtr = std::make_shared<MetaCapabilityInfo>(
|
||||
"devid_123", "dhid_123", "devname", devType, DHType::AUDIO, "", "", "", "");
|
||||
auto ret = metaCapInfoPtr->Compare(metaCapInfo);
|
||||
EXPECT_EQ(false, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(MetaCapInfoTest, Compare_006, TestSize.Level0)
|
||||
{
|
||||
uint16_t devType = 1;
|
||||
MetaCapabilityInfo metaCapInfo("devid_123", "dhid_123", "devname", devType, DHType::CAMERA, "", "", "", "");
|
||||
std::shared_ptr<MetaCapabilityInfo> metaCapInfoPtr = std::make_shared<MetaCapabilityInfo>(
|
||||
"devid_123", "dhid_123", "devname", devType, DHType::CAMERA, "attrs", "", "", "");
|
||||
auto ret = metaCapInfoPtr->Compare(metaCapInfo);
|
||||
EXPECT_EQ(false, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(MetaCapInfoTest, Compare_007, TestSize.Level0)
|
||||
{
|
||||
uint16_t devType = 1;
|
||||
MetaCapabilityInfo metaCapInfo("devid_123", "dhid_123", "devname", devType, DHType::CAMERA, "attrs", "", "", "");
|
||||
std::shared_ptr<MetaCapabilityInfo> metaCapInfoPtr = std::make_shared<MetaCapabilityInfo>(
|
||||
"devid_123", "dhid_123", "devname", devType, DHType::CAMERA, "attrs", "subtype", "", "");
|
||||
auto ret = metaCapInfoPtr->Compare(metaCapInfo);
|
||||
EXPECT_EQ(false, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(MetaCapInfoTest, Compare_008, TestSize.Level0)
|
||||
{
|
||||
uint16_t devType = 1;
|
||||
MetaCapabilityInfo metaCapInfo("devid_123", "dhid_123", "devname",
|
||||
devType, DHType::CAMERA, "attrs", "subtype", "", "");
|
||||
std::shared_ptr<MetaCapabilityInfo> metaCapInfoPtr = std::make_shared<MetaCapabilityInfo>(
|
||||
"devid_123", "dhid_123", "devname", devType, DHType::CAMERA, "attrs", "subtype", "udidhash_123", "");
|
||||
auto ret = metaCapInfoPtr->Compare(metaCapInfo);
|
||||
EXPECT_EQ(false, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(MetaCapInfoTest, Compare_009, TestSize.Level0)
|
||||
{
|
||||
uint16_t devType = 1;
|
||||
MetaCapabilityInfo metaCapInfo("devid_123", "dhid_123", "devname",
|
||||
devType, DHType::CAMERA, "attrs", "subtype", "udidhash_123", "");
|
||||
std::shared_ptr<MetaCapabilityInfo> metaCapInfoPtr = std::make_shared<MetaCapabilityInfo>(
|
||||
"devid_123", "dhid_123", "devname", devType, DHType::CAMERA, "attrs", "subtype", "udidhash_123", "1.0");
|
||||
auto ret = metaCapInfoPtr->Compare(metaCapInfo);
|
||||
EXPECT_EQ(false, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(MetaCapInfoTest, Compare_010, TestSize.Level0)
|
||||
{
|
||||
uint16_t devType = 1;
|
||||
MetaCapabilityInfo metaCapInfo("devid_123", "dhid_123", "devname",
|
||||
devType, DHType::CAMERA, "attrs", "subtype", "udidhash_123", "1.0");
|
||||
std::shared_ptr<MetaCapabilityInfo> metaCapInfoPtr = std::make_shared<MetaCapabilityInfo>(
|
||||
"devid_123", "dhid_123", "devname", devType, DHType::CAMERA, "attrs", "subtype", "udidhash_123", "1.0");
|
||||
auto ret = metaCapInfoPtr->Compare(metaCapInfo);
|
||||
EXPECT_EQ(true, ret);
|
||||
}
|
||||
}
|
||||
}
|
@ -303,7 +303,7 @@ HWTEST_F(MetaInfoMgrTest, ClearRemoteDeviceMetaInfoData_001, TestSize.Level0)
|
||||
std::string peerudid = "peerudid_test";
|
||||
std::string peeruuid = "peeruuid_test";
|
||||
auto ret = MetaInfoManager::GetInstance()->ClearRemoteDeviceMetaInfoData(peerudid, peeruuid);
|
||||
EXPECT_EQ(ERR_DH_FWK_RESOURCE_DB_ADAPTER_OPERATION_FAIL, ret);
|
||||
EXPECT_EQ(DH_FWK_SUCCESS, ret);
|
||||
|
||||
MetaInfoManager::GetInstance()->UnInit();
|
||||
ret = MetaInfoManager::GetInstance()->ClearRemoteDeviceMetaInfoData(peerudid, peeruuid);
|
||||
|
Loading…
Reference in New Issue
Block a user