mirror of
https://gitee.com/openharmony/distributedhardware_distributed_hardware_fwk
synced 2024-11-23 15:50:09 +00:00
代码检视整改
Signed-off-by: li-tiangang4 <litiangang4@huawei.com>
This commit is contained in:
parent
aee8dd2ff8
commit
41234b4ba1
@ -95,6 +95,7 @@ namespace DistributedHardware {
|
||||
constexpr int32_t ERR_DH_FWK_SERVICE_WRITE_INFO_FAIL = -10807;
|
||||
constexpr int32_t ERR_DH_FWK_PUBLISHER_LISTENER_IS_NULL = -10808;
|
||||
constexpr int32_t ERR_DH_FWK_SERVICE_MSG_INVALID = -10809;
|
||||
constexpr int32_t ERR_DH_FWK_AVTRANS_CALLBACK_IS_NULL = -10810;
|
||||
|
||||
/* AccessManager errno, range: [-10900, -10999] */
|
||||
constexpr int32_t ERR_DH_FWK_ACCESS_INIT_DM_FAILED = -10900;
|
||||
|
@ -359,7 +359,10 @@ int32_t DistributedHardwareProxy::RegisterCtlCenterCallback(int32_t engineId,
|
||||
DHLOGE("remote service is null");
|
||||
return ERR_DH_AVT_SERVICE_REMOTE_IS_NULL;
|
||||
}
|
||||
|
||||
if (callback == nullptr) {
|
||||
DHLOGE("callback is null");
|
||||
return ERR_DH_FWK_AVTRANS_CALLBACK_IS_NULL;
|
||||
}
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
@ -54,8 +54,10 @@ void DistributedHardwareFwkStubFuzzTest(const uint8_t *data, size_t size)
|
||||
pdata.WriteUint32(tag);
|
||||
pdata.WriteString(value);
|
||||
}
|
||||
sptr<PublisherListenerStub> publisherListenerStub(new (std::nothrow)
|
||||
MyPublisherListenerStub());
|
||||
sptr<PublisherListenerStub> publisherListenerStub(new (std::nothrow)MyPublisherListenerStub());
|
||||
if (publisherListenerStub == nullptr) {
|
||||
return;
|
||||
}
|
||||
publisherListenerStub->OnRemoteRequest(code, pdata, reply, option);
|
||||
}
|
||||
} // namespace DistributedHardware
|
||||
|
@ -81,6 +81,9 @@ uint32_t DistributedHardwareFwkKitTest::TestPublisherListener::GetTopicMsgCnt(co
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareFwkKitTest, RegisterPublisherListener_001, testing::ext::TestSize.Level0)
|
||||
{
|
||||
if (dhfwkPtr_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
sptr<TestPublisherListener> listener1(new TestPublisherListener());
|
||||
int32_t ret = dhfwkPtr_->RegisterPublisherListener(DHTopic::TOPIC_START_DSCREEN, listener1);
|
||||
EXPECT_EQ(DH_FWK_SUCCESS, ret);
|
||||
@ -118,6 +121,9 @@ HWTEST_F(DistributedHardwareFwkKitTest, RegisterPublisherListener_001, testing::
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareFwkKitTest, PublishMessage_001, testing::ext::TestSize.Level0)
|
||||
{
|
||||
if (dhfwkPtr_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
uint32_t invalid = 7;
|
||||
DHTopic topic = static_cast<DHTopic>(invalid);
|
||||
std::string message;
|
||||
@ -132,6 +138,9 @@ HWTEST_F(DistributedHardwareFwkKitTest, PublishMessage_001, testing::ext::TestSi
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareFwkKitTest, PublishMessage_002, testing::ext::TestSize.Level0)
|
||||
{
|
||||
if (dhfwkPtr_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
DHTopic topic = DHTopic::TOPIC_STOP_DSCREEN;
|
||||
std::string message;
|
||||
EXPECT_EQ(ERR_DH_FWK_PARA_INVALID, dhfwkPtr_->PublishMessage(topic, message));
|
||||
@ -145,6 +154,9 @@ HWTEST_F(DistributedHardwareFwkKitTest, PublishMessage_002, testing::ext::TestSi
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareFwkKitTest, PublishMessage_003, testing::ext::TestSize.Level0)
|
||||
{
|
||||
if (dhfwkPtr_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
DHTopic topic = DHTopic::TOPIC_STOP_DSCREEN;
|
||||
std::string message = "TOPIC_STOP_DSCREEN";
|
||||
EXPECT_EQ(ERR_DH_FWK_PUBLISH_MSG_FAILED, dhfwkPtr_->PublishMessage(topic, message));
|
||||
@ -158,6 +170,9 @@ HWTEST_F(DistributedHardwareFwkKitTest, PublishMessage_003, testing::ext::TestSi
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareFwkKitTest, PublishMessage_004, testing::ext::TestSize.Level0)
|
||||
{
|
||||
if (dhfwkPtr_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
DHTopic topic = DHTopic::TOPIC_STOP_DSCREEN;
|
||||
std::string message;
|
||||
uint32_t MAX_MESSAGE_LEN = 40 * 1024 * 1024 + 10;
|
||||
@ -173,6 +188,9 @@ HWTEST_F(DistributedHardwareFwkKitTest, PublishMessage_004, testing::ext::TestSi
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareFwkKitTest, OnDHFWKOnLine_001, testing::ext::TestSize.Level0)
|
||||
{
|
||||
if (dhfwkPtr_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
bool isOnLine = true;
|
||||
dhfwkPtr_->OnDHFWKOnLine(isOnLine);
|
||||
EXPECT_EQ(nullptr, DHFWKSAManager::GetInstance().GetDHFWKProxy());
|
||||
@ -186,6 +204,9 @@ HWTEST_F(DistributedHardwareFwkKitTest, OnDHFWKOnLine_001, testing::ext::TestSiz
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareFwkKitTest, RegisterPublisherListener_002, testing::ext::TestSize.Level0)
|
||||
{
|
||||
if (dhfwkPtr_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
DHTopic topic = DHTopic::TOPIC_MIN;
|
||||
sptr<IPublisherListener> listener = nullptr;
|
||||
int32_t ret = dhfwkPtr_->RegisterPublisherListener(topic, listener);
|
||||
@ -200,6 +221,9 @@ HWTEST_F(DistributedHardwareFwkKitTest, RegisterPublisherListener_002, testing::
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareFwkKitTest, RegisterPublisherListener_003, testing::ext::TestSize.Level0)
|
||||
{
|
||||
if (dhfwkPtr_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
DHTopic topic = DHTopic::TOPIC_START_DSCREEN;
|
||||
sptr<IPublisherListener> listener = nullptr;
|
||||
int32_t ret = dhfwkPtr_->RegisterPublisherListener(topic, listener);
|
||||
@ -214,6 +238,9 @@ HWTEST_F(DistributedHardwareFwkKitTest, RegisterPublisherListener_003, testing::
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareFwkKitTest, UnregisterPublisherListener_001, testing::ext::TestSize.Level0)
|
||||
{
|
||||
if (dhfwkPtr_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
DHTopic topic = DHTopic::TOPIC_MIN;
|
||||
sptr<IPublisherListener> listener = nullptr;
|
||||
int32_t ret = dhfwkPtr_->UnregisterPublisherListener(topic, listener);
|
||||
@ -228,6 +255,9 @@ HWTEST_F(DistributedHardwareFwkKitTest, UnregisterPublisherListener_001, testing
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareFwkKitTest, UnregisterPublisherListener_002, testing::ext::TestSize.Level0)
|
||||
{
|
||||
if (dhfwkPtr_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
DHTopic topic = DHTopic::TOPIC_START_DSCREEN;
|
||||
sptr<IPublisherListener> listener = nullptr;
|
||||
int32_t ret = dhfwkPtr_->UnregisterPublisherListener(topic, listener);
|
||||
@ -242,6 +272,9 @@ HWTEST_F(DistributedHardwareFwkKitTest, UnregisterPublisherListener_002, testing
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareFwkKitTest, QueryLocalSysSpec_001, testing::ext::TestSize.Level0)
|
||||
{
|
||||
if (dhfwkPtr_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
QueryLocalSysSpecType spec = QueryLocalSysSpecType::MIN;
|
||||
std::string ret = dhfwkPtr_->QueryLocalSysSpec(spec);
|
||||
EXPECT_EQ(true, ret.empty());
|
||||
@ -255,6 +288,9 @@ HWTEST_F(DistributedHardwareFwkKitTest, QueryLocalSysSpec_001, testing::ext::Tes
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareFwkKitTest, QueryLocalSysSpec_002, testing::ext::TestSize.Level0)
|
||||
{
|
||||
if (dhfwkPtr_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
QueryLocalSysSpecType spec = QueryLocalSysSpecType::HISTREAMER_AUDIO_ENCODER;
|
||||
std::string ret = dhfwkPtr_->QueryLocalSysSpec(spec);
|
||||
EXPECT_EQ(true, ret.empty());
|
||||
@ -268,6 +304,9 @@ HWTEST_F(DistributedHardwareFwkKitTest, QueryLocalSysSpec_002, testing::ext::Tes
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareFwkKitTest, InitializeAVCenter_001, testing::ext::TestSize.Level0)
|
||||
{
|
||||
if (dhfwkPtr_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
TransRole transRole = TransRole::UNKNOWN;
|
||||
int32_t engineId = 0;
|
||||
int32_t ret = dhfwkPtr_->InitializeAVCenter(transRole, engineId);
|
||||
@ -282,6 +321,9 @@ HWTEST_F(DistributedHardwareFwkKitTest, InitializeAVCenter_001, testing::ext::Te
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareFwkKitTest, ReleaseAVCenter_001, testing::ext::TestSize.Level0)
|
||||
{
|
||||
if (dhfwkPtr_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
int32_t engineId = 0;
|
||||
int32_t ret = dhfwkPtr_->ReleaseAVCenter(engineId);
|
||||
EXPECT_EQ(ERR_DH_FWK_POINTER_IS_NULL, ret);
|
||||
@ -295,6 +337,9 @@ HWTEST_F(DistributedHardwareFwkKitTest, ReleaseAVCenter_001, testing::ext::TestS
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareFwkKitTest, CreateControlChannel_001, testing::ext::TestSize.Level0)
|
||||
{
|
||||
if (dhfwkPtr_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
int32_t engineId = 0;
|
||||
std::string peerDevId = "peerDevId_test";
|
||||
int32_t ret = dhfwkPtr_->CreateControlChannel(engineId, peerDevId);
|
||||
@ -309,6 +354,9 @@ HWTEST_F(DistributedHardwareFwkKitTest, CreateControlChannel_001, testing::ext::
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareFwkKitTest, NotifyAVCenter_001, testing::ext::TestSize.Level0)
|
||||
{
|
||||
if (dhfwkPtr_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
int32_t engineId = 0;
|
||||
AVTransEvent event;
|
||||
int32_t ret = dhfwkPtr_->NotifyAVCenter(engineId, event);
|
||||
@ -323,6 +371,9 @@ HWTEST_F(DistributedHardwareFwkKitTest, NotifyAVCenter_001, testing::ext::TestSi
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareFwkKitTest, PauseDistributedHardware_001, testing::ext::TestSize.Level0)
|
||||
{
|
||||
if (dhfwkPtr_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
DHType dhType = DHType::CAMERA;
|
||||
std::string networkId = "networkId_test";
|
||||
int32_t ret = dhfwkPtr_->PauseDistributedHardware(dhType, networkId);
|
||||
@ -337,6 +388,9 @@ HWTEST_F(DistributedHardwareFwkKitTest, PauseDistributedHardware_001, testing::e
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareFwkKitTest, ResumeDistributedHardware_001, testing::ext::TestSize.Level0)
|
||||
{
|
||||
if (dhfwkPtr_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
DHType dhType = DHType::CAMERA;
|
||||
std::string networkId = "networkId_test";
|
||||
int32_t ret = dhfwkPtr_->ResumeDistributedHardware(dhType, networkId);
|
||||
@ -351,6 +405,9 @@ HWTEST_F(DistributedHardwareFwkKitTest, ResumeDistributedHardware_001, testing::
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareFwkKitTest, StopDistributedHardware_001, testing::ext::TestSize.Level0)
|
||||
{
|
||||
if (dhfwkPtr_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
DHType dhType = DHType::CAMERA;
|
||||
std::string networkId = "networkId_test";
|
||||
int32_t ret = dhfwkPtr_->StopDistributedHardware(dhType, networkId);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-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
|
||||
@ -92,7 +92,7 @@ HWTEST_F(DHFWKSAManagerTest, GetDHFWKProxy_001, TestSize.Level0)
|
||||
HWTEST_F(DHFWKSAManagerTest, GetDHFWKProxy_002, TestSize.Level0)
|
||||
{
|
||||
DHFWKSAManager::GetInstance().isSubscribeDHFWKSAChangeListener.store(true);
|
||||
DHFWKSAManager::GetInstance().dhfwkProxy_ = new OHOS::DistributedHardware::MockIDistributedHardware();
|
||||
DHFWKSAManager::GetInstance().dhfwkProxy_ = sptr<MockIDistributedHardware>(new MockIDistributedHardware());
|
||||
DHFWKSAManager::GetInstance().GetDHFWKProxy();
|
||||
EXPECT_NE(nullptr, DHFWKSAManager::GetInstance().dhfwkProxy_);
|
||||
}
|
||||
@ -119,7 +119,11 @@ HWTEST_F(DHFWKSAManagerTest, RegisterSAStateCallback_001, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DHFWKSAManagerTest, OnAddSystemAbility_001, TestSize.Level0)
|
||||
{
|
||||
DHFWKSAManager::GetInstance().saListener_ = new DHFWKSAManager::SystemAbilityListener();
|
||||
DHFWKSAManager::GetInstance().saListener_ =
|
||||
sptr<DHFWKSAManager::SystemAbilityListener>(new DHFWKSAManager::SystemAbilityListener());
|
||||
if (DHFWKSAManager::GetInstance().saListener_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
int32_t systemAbilityId = 1;
|
||||
std::string deviceId = "deviceId";
|
||||
DHFWKSAManager::GetInstance().saListener_->OnAddSystemAbility(systemAbilityId, deviceId);
|
||||
@ -134,7 +138,11 @@ HWTEST_F(DHFWKSAManagerTest, OnAddSystemAbility_001, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DHFWKSAManagerTest, OnAddSystemAbility_002, TestSize.Level0)
|
||||
{
|
||||
DHFWKSAManager::GetInstance().saListener_ = new DHFWKSAManager::SystemAbilityListener();
|
||||
DHFWKSAManager::GetInstance().saListener_ =
|
||||
sptr<DHFWKSAManager::SystemAbilityListener>(new DHFWKSAManager::SystemAbilityListener());
|
||||
if (DHFWKSAManager::GetInstance().saListener_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
int32_t systemAbilityId = DISTRIBUTED_HARDWARE_SA_ID;
|
||||
std::string deviceId = "deviceId";
|
||||
DHFWKSAManager::GetInstance().saListener_->OnAddSystemAbility(systemAbilityId, deviceId);
|
||||
@ -149,10 +157,13 @@ HWTEST_F(DHFWKSAManagerTest, OnAddSystemAbility_002, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DHFWKSAManagerTest, OnAddSystemAbility_003, TestSize.Level0)
|
||||
{
|
||||
DHFWKSAManager::GetInstance().saListener_ = new DHFWKSAManager::SystemAbilityListener();
|
||||
DHFWKSAManager::GetInstance().saListener_ =
|
||||
sptr<DHFWKSAManager::SystemAbilityListener>(new DHFWKSAManager::SystemAbilityListener());
|
||||
if (DHFWKSAManager::GetInstance().saListener_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
int32_t systemAbilityId = DISTRIBUTED_HARDWARE_SA_ID;
|
||||
std::string deviceId = "deviceId";
|
||||
DHFWKSAManager::GetInstance().dhfwkProxy_ = new MockIDistributedHardware();
|
||||
DHFWKSAManager::GetInstance().saStateCallback = DHFWKSaStateCallback;
|
||||
DHFWKSAManager::GetInstance().saListener_->OnAddSystemAbility(systemAbilityId, deviceId);
|
||||
EXPECT_NE(nullptr, DHFWKSAManager::GetInstance().saListener_);
|
||||
@ -166,7 +177,11 @@ HWTEST_F(DHFWKSAManagerTest, OnAddSystemAbility_003, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DHFWKSAManagerTest, OnRemoveSystemAbility_001, TestSize.Level0)
|
||||
{
|
||||
DHFWKSAManager::GetInstance().saListener_ = new DHFWKSAManager::SystemAbilityListener();
|
||||
DHFWKSAManager::GetInstance().saListener_ =
|
||||
sptr<DHFWKSAManager::SystemAbilityListener>(new DHFWKSAManager::SystemAbilityListener());
|
||||
if (DHFWKSAManager::GetInstance().saListener_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
int32_t systemAbilityId = 1;
|
||||
std::string deviceId = "deviceId";
|
||||
DHFWKSAManager::GetInstance().saListener_->OnRemoveSystemAbility(systemAbilityId, deviceId);
|
||||
@ -181,7 +196,11 @@ HWTEST_F(DHFWKSAManagerTest, OnRemoveSystemAbility_001, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DHFWKSAManagerTest, OnRemoveSystemAbility_002, TestSize.Level0)
|
||||
{
|
||||
DHFWKSAManager::GetInstance().saListener_ = new DHFWKSAManager::SystemAbilityListener();
|
||||
DHFWKSAManager::GetInstance().saListener_ =
|
||||
sptr<DHFWKSAManager::SystemAbilityListener>(new DHFWKSAManager::SystemAbilityListener());
|
||||
if (DHFWKSAManager::GetInstance().saListener_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
int32_t systemAbilityId = DISTRIBUTED_HARDWARE_SA_ID;
|
||||
std::string deviceId = "deviceId";
|
||||
DHFWKSAManager::GetInstance().saListener_->OnRemoveSystemAbility(systemAbilityId, deviceId);
|
||||
@ -196,10 +215,13 @@ HWTEST_F(DHFWKSAManagerTest, OnRemoveSystemAbility_002, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DHFWKSAManagerTest, OnRemoveSystemAbility_003, TestSize.Level0)
|
||||
{
|
||||
DHFWKSAManager::GetInstance().saListener_ = new DHFWKSAManager::SystemAbilityListener();
|
||||
DHFWKSAManager::GetInstance().saListener_ =
|
||||
sptr<DHFWKSAManager::SystemAbilityListener>(new DHFWKSAManager::SystemAbilityListener());
|
||||
if (DHFWKSAManager::GetInstance().saListener_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
int32_t systemAbilityId = DISTRIBUTED_HARDWARE_SA_ID;
|
||||
std::string deviceId = "deviceId";
|
||||
DHFWKSAManager::GetInstance().dhfwkProxy_ = new OHOS::DistributedHardware::MockIDistributedHardware();
|
||||
DHFWKSAManager::GetInstance().saStateCallback = DHFWKSaStateCallback;
|
||||
DHFWKSAManager::GetInstance().saListener_->OnAddSystemAbility(systemAbilityId, deviceId);
|
||||
EXPECT_NE(nullptr, DHFWKSAManager::GetInstance().saListener_);
|
||||
|
@ -46,6 +46,9 @@ void DistributedHardwareProxyTest::TearDown()
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareProxyTest, RegisterPublisherListener_001, TestSize.Level0)
|
||||
{
|
||||
if (hardwareProxy_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
DHTopic topic = DHTopic::TOPIC_STOP_DSCREEN;
|
||||
sptr<IPublisherListener> listener = nullptr;
|
||||
int32_t ret = hardwareProxy_->RegisterPublisherListener(topic, listener);
|
||||
@ -60,6 +63,9 @@ HWTEST_F(DistributedHardwareProxyTest, RegisterPublisherListener_001, TestSize.L
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareProxyTest, RegisterAbilityListener_002, TestSize.Level0)
|
||||
{
|
||||
if (hardwareProxy_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
int32_t invalid = 7;
|
||||
DHTopic topic = static_cast<DHTopic>(invalid);
|
||||
sptr<IPublisherListener> listener(new MockIPublisherListener());
|
||||
@ -75,6 +81,9 @@ HWTEST_F(DistributedHardwareProxyTest, RegisterAbilityListener_002, TestSize.Lev
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareProxyTest, RegisterAbilityListener_003, TestSize.Level0)
|
||||
{
|
||||
if (hardwareProxy_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
DHTopic topic = DHTopic::TOPIC_STOP_DSCREEN;
|
||||
sptr<IPublisherListener> listener(new MockIPublisherListener());
|
||||
int32_t ret = hardwareProxy_->RegisterPublisherListener(topic, listener);
|
||||
@ -89,6 +98,9 @@ HWTEST_F(DistributedHardwareProxyTest, RegisterAbilityListener_003, TestSize.Lev
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareProxyTest, UnregisterPublisherListener_001, TestSize.Level0)
|
||||
{
|
||||
if (hardwareProxy_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
DHTopic topic = DHTopic::TOPIC_STOP_DSCREEN;
|
||||
sptr<IPublisherListener> listener = nullptr;
|
||||
int32_t ret = hardwareProxy_->UnregisterPublisherListener(topic, listener);
|
||||
@ -103,6 +115,9 @@ HWTEST_F(DistributedHardwareProxyTest, UnregisterPublisherListener_001, TestSize
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareProxyTest, UnregisterPublisherListener_002, TestSize.Level0)
|
||||
{
|
||||
if (hardwareProxy_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
int32_t invalid = 7;
|
||||
DHTopic topic = static_cast<DHTopic>(invalid);
|
||||
sptr<IPublisherListener> listener(new MockIPublisherListener());
|
||||
@ -118,6 +133,9 @@ HWTEST_F(DistributedHardwareProxyTest, UnregisterPublisherListener_002, TestSize
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareProxyTest, UnregisterPublisherListener_003, TestSize.Level0)
|
||||
{
|
||||
if (hardwareProxy_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
DHTopic topic = DHTopic::TOPIC_STOP_DSCREEN;
|
||||
sptr<IPublisherListener> listener(new MockIPublisherListener());
|
||||
int32_t ret = hardwareProxy_->UnregisterPublisherListener(topic, listener);
|
||||
@ -132,6 +150,9 @@ HWTEST_F(DistributedHardwareProxyTest, UnregisterPublisherListener_003, TestSize
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareProxyTest, PublishMessage_001, TestSize.Level0)
|
||||
{
|
||||
if (hardwareProxy_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
int32_t invalid = 7;
|
||||
std::string msg;
|
||||
DHTopic topic = static_cast<DHTopic>(invalid);
|
||||
@ -147,6 +168,9 @@ HWTEST_F(DistributedHardwareProxyTest, PublishMessage_001, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareProxyTest, PublishMessage_002, TestSize.Level0)
|
||||
{
|
||||
if (hardwareProxy_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
DHTopic topic = DHTopic::TOPIC_STOP_DSCREEN;
|
||||
std::string msg;
|
||||
int32_t ret = hardwareProxy_->PublishMessage(topic, msg);
|
||||
@ -161,6 +185,9 @@ HWTEST_F(DistributedHardwareProxyTest, PublishMessage_002, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareProxyTest, PublishMessage_003, TestSize.Level0)
|
||||
{
|
||||
if (hardwareProxy_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
DHTopic topic = DHTopic::TOPIC_STOP_DSCREEN;
|
||||
std::string msg = "msg";
|
||||
int32_t ret = hardwareProxy_->PublishMessage(topic, msg);
|
||||
@ -175,6 +202,9 @@ HWTEST_F(DistributedHardwareProxyTest, PublishMessage_003, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareProxyTest, QueryLocalSysSpec_001, TestSize.Level0)
|
||||
{
|
||||
if (hardwareProxy_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
QueryLocalSysSpecType spec = QueryLocalSysSpecType::MIN;
|
||||
std::string ret = hardwareProxy_->QueryLocalSysSpec(spec);
|
||||
EXPECT_EQ(true, ret.empty());
|
||||
@ -188,6 +218,9 @@ HWTEST_F(DistributedHardwareProxyTest, QueryLocalSysSpec_001, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareProxyTest, InitializeAVCenter_001, TestSize.Level0)
|
||||
{
|
||||
if (hardwareProxy_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
TransRole transRole = TransRole::UNKNOWN;;
|
||||
int32_t engineId = 0;
|
||||
int32_t ret = hardwareProxy_->InitializeAVCenter(transRole, engineId);
|
||||
@ -202,6 +235,9 @@ HWTEST_F(DistributedHardwareProxyTest, InitializeAVCenter_001, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareProxyTest, ReleaseAVCenter_001, TestSize.Level0)
|
||||
{
|
||||
if (hardwareProxy_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
int32_t engineId = 0;
|
||||
int32_t ret = hardwareProxy_->ReleaseAVCenter(engineId);
|
||||
EXPECT_EQ(ERR_DH_AVT_SERVICE_REMOTE_IS_NULL, ret);
|
||||
@ -215,6 +251,9 @@ HWTEST_F(DistributedHardwareProxyTest, ReleaseAVCenter_001, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareProxyTest, CreateControlChannel_001, TestSize.Level0)
|
||||
{
|
||||
if (hardwareProxy_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
int32_t engineId = 0;
|
||||
std::string peerDevId = "peerDevId_test";
|
||||
int32_t ret = hardwareProxy_->CreateControlChannel(engineId, peerDevId);
|
||||
@ -229,6 +268,9 @@ HWTEST_F(DistributedHardwareProxyTest, CreateControlChannel_001, TestSize.Level0
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareProxyTest, NotifyAVCenter_001, TestSize.Level0)
|
||||
{
|
||||
if (hardwareProxy_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
int32_t engineId = 0;
|
||||
AVTransEvent event;
|
||||
int32_t ret = hardwareProxy_->NotifyAVCenter(engineId, event);
|
||||
@ -243,6 +285,9 @@ HWTEST_F(DistributedHardwareProxyTest, NotifyAVCenter_001, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareProxyTest, NotifySourceRemoteSinkStarted_001, TestSize.Level0)
|
||||
{
|
||||
if (hardwareProxy_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
std::string deviceId = "devid_test";
|
||||
int32_t ret = hardwareProxy_->NotifySourceRemoteSinkStarted(deviceId);
|
||||
EXPECT_EQ(ERR_DH_AVT_SERVICE_REMOTE_IS_NULL, ret);
|
||||
@ -256,6 +301,9 @@ HWTEST_F(DistributedHardwareProxyTest, NotifySourceRemoteSinkStarted_001, TestSi
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareProxyTest, PauseDistributedHardware_001, TestSize.Level0)
|
||||
{
|
||||
if (hardwareProxy_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
DHType dhType = DHType::CAMERA;
|
||||
std::string networkId = "networkId_test";
|
||||
int32_t ret = hardwareProxy_->PauseDistributedHardware(dhType, networkId);
|
||||
@ -270,6 +318,9 @@ HWTEST_F(DistributedHardwareProxyTest, PauseDistributedHardware_001, TestSize.Le
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareProxyTest, ResumeDistributedHardware_001, TestSize.Level0)
|
||||
{
|
||||
if (hardwareProxy_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
DHType dhType = DHType::CAMERA;
|
||||
std::string networkId = "networkId_test";
|
||||
int32_t ret = hardwareProxy_->ResumeDistributedHardware(dhType, networkId);
|
||||
@ -284,6 +335,9 @@ HWTEST_F(DistributedHardwareProxyTest, ResumeDistributedHardware_001, TestSize.L
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareProxyTest, StopDistributedHardware_001, TestSize.Level0)
|
||||
{
|
||||
if (hardwareProxy_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
DHType dhType = DHType::CAMERA;
|
||||
std::string networkId = "networkId_test";
|
||||
int32_t ret = hardwareProxy_->StopDistributedHardware(dhType, networkId);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-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
|
||||
@ -45,6 +45,9 @@ void PublisherListenerStubTest::TearDown()
|
||||
*/
|
||||
HWTEST_F(PublisherListenerStubTest, OnRemoteRequest_001, TestSize.Level0)
|
||||
{
|
||||
if (listenerStub_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
uint32_t code = 0;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
|
@ -307,6 +307,10 @@ ActionResult ComponentManager::StartSource()
|
||||
std::unordered_map<DHType, std::shared_future<int32_t>> futures;
|
||||
std::string uuid = DHContext::GetInstance().GetDeviceInfo().uuid;
|
||||
for (const auto &item : compSource_) {
|
||||
if (item.second == nullptr) {
|
||||
DHLOGE("comp source ptr is null");
|
||||
continue;
|
||||
}
|
||||
CompVersion compversion;
|
||||
VersionManager::GetInstance().GetCompVersion(uuid, item.first, compversion);
|
||||
auto params = compversion.sourceVersion;
|
||||
@ -328,7 +332,10 @@ ActionResult ComponentManager::StartSource(DHType dhType)
|
||||
DHLOGE("Component for DHType: %{public}" PRIu32 " not init source handler", (uint32_t)dhType);
|
||||
return futures;
|
||||
}
|
||||
|
||||
if (compSource_[dhType] == nullptr) {
|
||||
DHLOGE("comp source ptr is null");
|
||||
return futures;
|
||||
}
|
||||
std::string uuid = DHContext::GetInstance().GetDeviceInfo().uuid;
|
||||
CompVersion compVersion;
|
||||
VersionManager::GetInstance().GetCompVersion(uuid, dhType, compVersion);
|
||||
@ -349,6 +356,10 @@ ActionResult ComponentManager::StartSink()
|
||||
std::unordered_map<DHType, std::shared_future<int32_t>> futures;
|
||||
std::string uuid = DHContext::GetInstance().GetDeviceInfo().uuid;
|
||||
for (const auto &item : compSink_) {
|
||||
if (item.second == nullptr) {
|
||||
DHLOGE("comp sink ptr is null");
|
||||
continue;
|
||||
}
|
||||
CompVersion compversion;
|
||||
VersionManager::GetInstance().GetCompVersion(uuid, item.first, compversion);
|
||||
auto params = compversion.sinkVersion;
|
||||
@ -378,7 +389,10 @@ ActionResult ComponentManager::StartSink(DHType dhType)
|
||||
DHLOGE("Component for DHType: %{public}" PRIu32 " not init sink handler", (uint32_t)dhType);
|
||||
return futures;
|
||||
}
|
||||
|
||||
if (compSink_[dhType] == nullptr) {
|
||||
DHLOGE("comp sink ptr is null");
|
||||
return futures;
|
||||
}
|
||||
std::string uuid = DHContext::GetInstance().GetDeviceInfo().uuid;
|
||||
CompVersion compVersion;
|
||||
VersionManager::GetInstance().GetCompVersion(uuid, dhType, compVersion);
|
||||
@ -406,6 +420,10 @@ ActionResult ComponentManager::StopSource()
|
||||
DHLOGI("start.");
|
||||
std::unordered_map<DHType, std::shared_future<int32_t>> futures;
|
||||
for (const auto &item : compSource_) {
|
||||
if (item.second == nullptr) {
|
||||
DHLOGE("comp source ptr is null");
|
||||
continue;
|
||||
}
|
||||
std::promise<int32_t> p;
|
||||
std::future<int32_t> f = p.get_future();
|
||||
std::thread([p = std::move(p), item] () mutable {
|
||||
@ -421,6 +439,10 @@ ActionResult ComponentManager::StopSink()
|
||||
DHLOGI("start.");
|
||||
std::unordered_map<DHType, std::shared_future<int32_t>> futures;
|
||||
for (const auto &item : compSink_) {
|
||||
if (item.second == nullptr) {
|
||||
DHLOGE("comp sink ptr is null");
|
||||
continue;
|
||||
}
|
||||
std::promise<int32_t> p;
|
||||
std::future<int32_t> f = p.get_future();
|
||||
std::thread([p = std::move(p), item] () mutable {
|
||||
@ -971,6 +993,10 @@ void ComponentManager::TriggerFullCapsSync(const std::string &networkId)
|
||||
DHLOGE("Remote networkid is null");
|
||||
return;
|
||||
}
|
||||
if (dhCommToolPtr_ == nullptr) {
|
||||
DHLOGE("DH communication tool ptr is null");
|
||||
return;
|
||||
}
|
||||
dhCommToolPtr_->TriggerReqFullDHCaps(networkId);
|
||||
}
|
||||
|
||||
@ -1001,6 +1027,10 @@ ComponentManager::ComponentManagerEventHandler::ComponentManagerEventHandler(
|
||||
void ComponentManager::ComponentManagerEventHandler::ProcessEvent(
|
||||
const AppExecFwk::InnerEvent::Pointer &event)
|
||||
{
|
||||
if (event == nullptr) {
|
||||
DHLOGE("event is nullptr");
|
||||
return;
|
||||
}
|
||||
uint32_t eventId = event->GetInnerEventId();
|
||||
switch (eventId) {
|
||||
case EVENT_DATA_SYNC_MANUAL: {
|
||||
|
@ -254,6 +254,10 @@ bool ComponentPrivacy::GetPageFlag()
|
||||
|
||||
void ComponentPrivacy::ComponentEventHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
{
|
||||
if (event == nullptr) {
|
||||
DHLOGE("event is nullptr");
|
||||
return;
|
||||
}
|
||||
switch (event->GetInnerEventId()) {
|
||||
case COMP_START_PAGE:
|
||||
ProcessStartPage(event);
|
||||
@ -282,6 +286,10 @@ ComponentPrivacy::ComponentEventHandler::~ComponentEventHandler()
|
||||
void ComponentPrivacy::ComponentEventHandler::ProcessStartPage(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
{
|
||||
DHLOGI("ProcessStartPage enter.");
|
||||
if (event == nullptr) {
|
||||
DHLOGE("event is nullptr");
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<cJSON> dataMsg = event->GetSharedObject<cJSON>();
|
||||
cJSON *innerMsg = cJSON_GetArrayItem(dataMsg.get(), 0);
|
||||
if (!IsString(innerMsg, PRIVACY_SUBTYPE)) {
|
||||
@ -293,6 +301,10 @@ void ComponentPrivacy::ComponentEventHandler::ProcessStartPage(const AppExecFwk:
|
||||
DHLOGE("PRIVACY_NETWORKID is invalid");
|
||||
return;
|
||||
}
|
||||
if (comPrivacyObj_ == nullptr) {
|
||||
DHLOGE("comPrivacyObj_ is nullptr");
|
||||
return;
|
||||
}
|
||||
std::string networkId = cJSON_GetObjectItem(innerMsg, PRIVACY_NETWORKID.c_str())->valuestring;
|
||||
comPrivacyObj_->StartPrivacePage(subtype, networkId);
|
||||
}
|
||||
@ -300,12 +312,20 @@ void ComponentPrivacy::ComponentEventHandler::ProcessStartPage(const AppExecFwk:
|
||||
void ComponentPrivacy::ComponentEventHandler::ProcessStopPage(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
{
|
||||
DHLOGI("ProcessStopPage enter.");
|
||||
if (event == nullptr) {
|
||||
DHLOGE("event is nullptr");
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<cJSON> dataMsg = event->GetSharedObject<cJSON>();
|
||||
cJSON *innerMsg = cJSON_GetArrayItem(dataMsg.get(), 0);
|
||||
if (!IsString(innerMsg, PRIVACY_SUBTYPE)) {
|
||||
DHLOGE("PRIVACY_SUBTYPE is invalid");
|
||||
return;
|
||||
}
|
||||
if (comPrivacyObj_ == nullptr) {
|
||||
DHLOGE("comPrivacyObj_ is nullptr");
|
||||
return;
|
||||
}
|
||||
std::string subtype = cJSON_GetObjectItem(innerMsg, PRIVACY_SUBTYPE.c_str())->valuestring;
|
||||
comPrivacyObj_->StopPrivacePage(subtype);
|
||||
}
|
||||
|
@ -106,6 +106,10 @@ void LocalHardwareManager::QueryLocalHardware(const DHType dhType, IHardwareHand
|
||||
int32_t retryTimes = QUERY_RETRY_MAX_TIMES;
|
||||
while (retryTimes > 0) {
|
||||
DHLOGI("Query hardwareHandler retry times left: %{public}d, dhType: %{public}#X", retryTimes, dhType);
|
||||
if (hardwareHandler == nullptr) {
|
||||
DHLOGE("hardwareHandler is null.");
|
||||
return;
|
||||
}
|
||||
dhItems = hardwareHandler->Query();
|
||||
if (dhItems.empty()) {
|
||||
DHLOGE("Query hardwareHandler and obtain empty, dhType: %{public}#X", dhType);
|
||||
|
@ -41,8 +41,10 @@ void ComponentMonitorTest::SetUp()
|
||||
|
||||
void ComponentMonitorTest::TearDown()
|
||||
{
|
||||
compMonitorPtr_->saListeners_.clear();
|
||||
compMonitorPtr_ = nullptr;
|
||||
if (compMonitorPtr_ != nullptr) {
|
||||
compMonitorPtr_->saListeners_.clear();
|
||||
compMonitorPtr_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,6 +55,9 @@ void ComponentMonitorTest::TearDown()
|
||||
*/
|
||||
HWTEST_F(ComponentMonitorTest, AddSAMonitor_001, TestSize.Level0)
|
||||
{
|
||||
if (compMonitorPtr_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
int32_t saId = static_cast<int32_t>(DHType::AUDIO);
|
||||
compMonitorPtr_->AddSAMonitor(saId);
|
||||
EXPECT_EQ(false, compMonitorPtr_->saListeners_.empty());
|
||||
@ -66,6 +71,9 @@ HWTEST_F(ComponentMonitorTest, AddSAMonitor_001, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(ComponentMonitorTest, AddSAMonitor_002, TestSize.Level0)
|
||||
{
|
||||
if (compMonitorPtr_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
int32_t saId = static_cast<int32_t>(DHType::CAMERA);
|
||||
sptr<ComponentMonitor::CompSystemAbilityListener> listener(new ComponentMonitor::CompSystemAbilityListener());
|
||||
compMonitorPtr_->saListeners_.insert(std::make_pair(saId, listener));
|
||||
@ -81,6 +89,9 @@ HWTEST_F(ComponentMonitorTest, AddSAMonitor_002, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(ComponentMonitorTest, RemoveSAMonitor_001, TestSize.Level0)
|
||||
{
|
||||
if (compMonitorPtr_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
int32_t saId = static_cast<int32_t>(DHType::GPS);
|
||||
compMonitorPtr_->RemoveSAMonitor(saId);
|
||||
EXPECT_EQ(true, compMonitorPtr_->saListeners_.empty());
|
||||
@ -94,6 +105,9 @@ HWTEST_F(ComponentMonitorTest, RemoveSAMonitor_001, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(ComponentMonitorTest, RemoveSAMonitor_002, TestSize.Level0)
|
||||
{
|
||||
if (compMonitorPtr_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
int32_t saId = static_cast<int32_t>(DHType::CAMERA);
|
||||
sptr<ComponentMonitor::CompSystemAbilityListener> listener(new ComponentMonitor::CompSystemAbilityListener());
|
||||
compMonitorPtr_->saListeners_.insert(std::make_pair(saId, listener));
|
||||
@ -109,6 +123,9 @@ HWTEST_F(ComponentMonitorTest, RemoveSAMonitor_002, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(ComponentMonitorTest, OnRemoveSystemAbility_001, TestSize.Level0)
|
||||
{
|
||||
if (compMonitorPtr_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
sptr<ComponentMonitor::CompSystemAbilityListener> listener(new ComponentMonitor::CompSystemAbilityListener());
|
||||
int32_t saId = static_cast<int32_t>(DHType::UNKNOWN);
|
||||
std::string deviceId;
|
||||
@ -125,6 +142,9 @@ HWTEST_F(ComponentMonitorTest, OnRemoveSystemAbility_001, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(ComponentMonitorTest, OnRemoveSystemAbility_002, TestSize.Level0)
|
||||
{
|
||||
if (compMonitorPtr_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
sptr<ComponentMonitor::CompSystemAbilityListener> listener(new ComponentMonitor::CompSystemAbilityListener());
|
||||
int32_t saId = static_cast<int32_t>(DHType::CAMERA);
|
||||
std::string deviceId;
|
||||
|
@ -58,6 +58,9 @@ void ComponentPrivacyTest::TearDown()
|
||||
|
||||
HWTEST_F(ComponentPrivacyTest, OnPrivaceResourceMessage_001, TestSize.Level0)
|
||||
{
|
||||
if (compPrivacy_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
ResourceEventType type = ResourceEventType::EVENT_TYPE_QUERY_RESOURCE;
|
||||
std::string subtype = "mic";
|
||||
std::string networkId = "networkId_test";
|
||||
@ -69,6 +72,9 @@ HWTEST_F(ComponentPrivacyTest, OnPrivaceResourceMessage_001, TestSize.Level0)
|
||||
|
||||
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";
|
||||
@ -80,6 +86,9 @@ HWTEST_F(ComponentPrivacyTest, OnPrivaceResourceMessage_002, TestSize.Level0)
|
||||
|
||||
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";
|
||||
@ -91,6 +100,9 @@ HWTEST_F(ComponentPrivacyTest, OnPrivaceResourceMessage_003, TestSize.Level0)
|
||||
|
||||
HWTEST_F(ComponentPrivacyTest, OnResourceInfoCallback_001, TestSize.Level0)
|
||||
{
|
||||
if (compPrivacy_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
std::string subtype = "mic";
|
||||
std::string networkId = "networkId_test";
|
||||
bool isSensitive = true;
|
||||
@ -102,6 +114,9 @@ HWTEST_F(ComponentPrivacyTest, OnResourceInfoCallback_001, TestSize.Level0)
|
||||
|
||||
HWTEST_F(ComponentPrivacyTest, DeviceTypeToString_001, TestSize.Level0)
|
||||
{
|
||||
if (compPrivacy_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
uint16_t deviceTypeId = 0x08;
|
||||
std::string ret = compPrivacy_->DeviceTypeToString(deviceTypeId);
|
||||
EXPECT_EQ("camera", ret);
|
||||
|
@ -137,6 +137,9 @@ void DbAdapterTest::TearDown()
|
||||
*/
|
||||
HWTEST_F(DbAdapterTest, db_adapter_test_000, TestSize.Level0)
|
||||
{
|
||||
if (g_dbAdapterPtr == nullptr) {
|
||||
return;
|
||||
}
|
||||
EXPECT_EQ(DH_FWK_SUCCESS, g_dbAdapterPtr->Init(true, DistributedKv::DataType::TYPE_DYNAMICAL));
|
||||
}
|
||||
|
||||
@ -148,6 +151,9 @@ HWTEST_F(DbAdapterTest, db_adapter_test_000, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DbAdapterTest, db_adapter_test_001, TestSize.Level0)
|
||||
{
|
||||
if (g_dbAdapterPtr == nullptr) {
|
||||
return;
|
||||
}
|
||||
vector<shared_ptr<CapabilityInfo>> resInfos { CAP_INFO_0, CAP_INFO_1, CAP_INFO_2, CAP_INFO_3, CAP_INFO_4,
|
||||
CAP_INFO_5, CAP_INFO_6, CAP_INFO_7, CAP_INFO_8, CAP_INFO_9 };
|
||||
|
||||
@ -173,6 +179,9 @@ HWTEST_F(DbAdapterTest, db_adapter_test_001, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DbAdapterTest, db_adapter_test_002, TestSize.Level0)
|
||||
{
|
||||
if (g_dbAdapterPtr == nullptr) {
|
||||
return;
|
||||
}
|
||||
std::vector<std::string> keys { std::string(TEST_DEV_ID_2 + TEST_DH_ID_0) };
|
||||
std::vector<std::string> values { TEST_DH_ATTR_0 };
|
||||
|
||||
@ -188,6 +197,9 @@ HWTEST_F(DbAdapterTest, db_adapter_test_002, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DbAdapterTest, db_adapter_test_003, TestSize.Level0)
|
||||
{
|
||||
if (g_dbAdapterPtr == nullptr) {
|
||||
return;
|
||||
}
|
||||
std::vector<std::string> keys { std::string(TEST_DEV_ID_2 + TEST_DH_ID_0) };
|
||||
std::vector<std::string> valuesEmpty;
|
||||
|
||||
@ -202,6 +214,9 @@ HWTEST_F(DbAdapterTest, db_adapter_test_003, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DbAdapterTest, db_adapter_test_004, TestSize.Level0)
|
||||
{
|
||||
if (g_dbAdapterPtr == nullptr) {
|
||||
return;
|
||||
}
|
||||
std::vector<std::string> keysEmpty;
|
||||
std::vector<std::string> values { TEST_DH_ATTR_0 };
|
||||
|
||||
@ -216,6 +231,9 @@ HWTEST_F(DbAdapterTest, db_adapter_test_004, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DbAdapterTest, db_adapter_test_005, TestSize.Level0)
|
||||
{
|
||||
if (g_dbAdapterPtr == nullptr) {
|
||||
return;
|
||||
}
|
||||
std::vector<std::string> keysEmpty;
|
||||
std::vector<std::string> valuesEmpty;
|
||||
|
||||
@ -230,6 +248,9 @@ HWTEST_F(DbAdapterTest, db_adapter_test_005, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DbAdapterTest, db_adapter_test_006, TestSize.Level0)
|
||||
{
|
||||
if (g_dbAdapterPtr == nullptr) {
|
||||
return;
|
||||
}
|
||||
std::vector<std::string> keys { std::string(TEST_DEV_ID_2 + TEST_DH_ID_0) };
|
||||
std::vector<std::string> values { TEST_DH_ATTR_0, TEST_DH_ATTR_1 };
|
||||
|
||||
@ -244,6 +265,9 @@ HWTEST_F(DbAdapterTest, db_adapter_test_006, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DbAdapterTest, db_adapter_test_007, TestSize.Level0)
|
||||
{
|
||||
if (g_dbAdapterPtr == nullptr) {
|
||||
return;
|
||||
}
|
||||
g_dbAdapterPtr->kvStoragePtr_ = nullptr;
|
||||
std::vector<std::string> keys { std::string(TEST_DEV_ID_2 + TEST_DH_ID_0) };
|
||||
std::vector<std::string> values { TEST_DH_ATTR_0 };
|
||||
@ -259,6 +283,9 @@ HWTEST_F(DbAdapterTest, db_adapter_test_007, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DbAdapterTest, db_adapter_test_008, TestSize.Level0)
|
||||
{
|
||||
if (g_dbAdapterPtr == nullptr) {
|
||||
return;
|
||||
}
|
||||
g_dbAdapterPtr->kvStoragePtr_ = nullptr;
|
||||
EXPECT_EQ(ERR_DH_FWK_RESOURCE_KV_STORAGE_POINTER_NULL, g_dbAdapterPtr->ReInit(true));
|
||||
}
|
||||
@ -271,6 +298,9 @@ HWTEST_F(DbAdapterTest, db_adapter_test_008, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DbAdapterTest, db_adapter_test_009, TestSize.Level0)
|
||||
{
|
||||
if (g_dbAdapterPtr == nullptr) {
|
||||
return;
|
||||
}
|
||||
g_dbAdapterPtr->kvStoragePtr_ = nullptr;
|
||||
EXPECT_EQ(ERR_DH_FWK_RESOURCE_KV_STORAGE_POINTER_NULL, g_dbAdapterPtr->RemoveDeviceData(TEST_DEV_ID_0));
|
||||
}
|
||||
@ -283,6 +313,9 @@ HWTEST_F(DbAdapterTest, db_adapter_test_009, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DbAdapterTest, db_adapter_test_010, TestSize.Level0)
|
||||
{
|
||||
if (g_dbAdapterPtr == nullptr) {
|
||||
return;
|
||||
}
|
||||
g_dbAdapterPtr->kvStoragePtr_ = nullptr;
|
||||
EXPECT_EQ(ERR_DH_FWK_RESOURCE_KV_STORAGE_POINTER_NULL, g_dbAdapterPtr->RemoveDataByKey("key"));
|
||||
}
|
||||
@ -295,6 +328,9 @@ HWTEST_F(DbAdapterTest, db_adapter_test_010, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DbAdapterTest, db_adapter_test_012, TestSize.Level0)
|
||||
{
|
||||
if (g_dbAdapterPtr == nullptr) {
|
||||
return;
|
||||
}
|
||||
g_dbAdapterPtr->kvStoragePtr_ = nullptr;
|
||||
EXPECT_EQ(ERR_DH_FWK_RESOURCE_KV_STORAGE_POINTER_NULL, g_dbAdapterPtr->UnRegisterChangeListener());
|
||||
}
|
||||
@ -307,6 +343,9 @@ HWTEST_F(DbAdapterTest, db_adapter_test_012, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DbAdapterTest, db_adapter_test_013, TestSize.Level0)
|
||||
{
|
||||
if (g_dbAdapterPtr == nullptr) {
|
||||
return;
|
||||
}
|
||||
std::string key = std::string(TEST_DEV_ID_1 + TEST_DH_ID_1);
|
||||
std::string value = TEST_DH_ATTR_0;
|
||||
g_dbAdapterPtr->kvStoragePtr_ = nullptr;
|
||||
@ -321,6 +360,9 @@ HWTEST_F(DbAdapterTest, db_adapter_test_013, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DbAdapterTest, db_adapter_test_014, TestSize.Level0)
|
||||
{
|
||||
if (g_dbAdapterPtr == nullptr) {
|
||||
return;
|
||||
}
|
||||
std::string networkId = DEV_NETWORK_ID_1;
|
||||
g_dbAdapterPtr->kvStoragePtr_ = nullptr;
|
||||
EXPECT_EQ(ERR_DH_FWK_RESOURCE_KV_STORAGE_POINTER_NULL, g_dbAdapterPtr->RegisterChangeListener());
|
||||
@ -334,6 +376,9 @@ HWTEST_F(DbAdapterTest, db_adapter_test_014, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DbAdapterTest, db_adapter_test_015, TestSize.Level0)
|
||||
{
|
||||
if (g_dbAdapterPtr == nullptr) {
|
||||
return;
|
||||
}
|
||||
g_dbAdapterPtr->kvStoragePtr_ = nullptr;
|
||||
EXPECT_EQ(ERR_DH_FWK_RESOURCE_KV_STORAGE_POINTER_NULL, g_dbAdapterPtr->UnRegisterChangeListener());
|
||||
}
|
||||
@ -346,6 +391,9 @@ HWTEST_F(DbAdapterTest, db_adapter_test_015, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DbAdapterTest, ReInit_001, TestSize.Level0)
|
||||
{
|
||||
if (g_dbAdapterPtr == nullptr) {
|
||||
return;
|
||||
}
|
||||
g_dbAdapterPtr->GetKvStorePtr(true, DistributedKv::DataType::TYPE_DYNAMICAL);
|
||||
EXPECT_EQ(DH_FWK_SUCCESS, g_dbAdapterPtr->ReInit(true));
|
||||
}
|
||||
@ -358,6 +406,9 @@ HWTEST_F(DbAdapterTest, ReInit_001, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DbAdapterTest, RemoveDeviceData_001, TestSize.Level0)
|
||||
{
|
||||
if (g_dbAdapterPtr == nullptr) {
|
||||
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));
|
||||
}
|
||||
@ -370,6 +421,9 @@ HWTEST_F(DbAdapterTest, RemoveDeviceData_001, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DbAdapterTest, PutData_01, TestSize.Level0)
|
||||
{
|
||||
if (g_dbAdapterPtr == nullptr) {
|
||||
return;
|
||||
}
|
||||
std::string key;
|
||||
std::string value;
|
||||
EXPECT_EQ(ERR_DH_FWK_PARA_INVALID, g_dbAdapterPtr->PutData(key, value));
|
||||
@ -383,6 +437,9 @@ HWTEST_F(DbAdapterTest, PutData_01, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DbAdapterTest, PutData_02, TestSize.Level0)
|
||||
{
|
||||
if (g_dbAdapterPtr == nullptr) {
|
||||
return;
|
||||
}
|
||||
uint32_t MAX_MESSAGE_LEN = 40 * 1024 * 1024 +1 ;
|
||||
std::string key = "key";
|
||||
key.resize(MAX_MESSAGE_LEN);
|
||||
@ -398,6 +455,9 @@ HWTEST_F(DbAdapterTest, PutData_02, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DbAdapterTest, PutData_03, TestSize.Level0)
|
||||
{
|
||||
if (g_dbAdapterPtr == nullptr) {
|
||||
return;
|
||||
}
|
||||
std::string key = "key";
|
||||
std::string value;
|
||||
EXPECT_EQ(ERR_DH_FWK_PARA_INVALID, g_dbAdapterPtr->PutData(key, value));
|
||||
@ -411,6 +471,9 @@ HWTEST_F(DbAdapterTest, PutData_03, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DbAdapterTest, PutData_04, TestSize.Level0)
|
||||
{
|
||||
if (g_dbAdapterPtr == nullptr) {
|
||||
return;
|
||||
}
|
||||
uint32_t MAX_MESSAGE_LEN = 40 * 1024 * 1024 + 1;
|
||||
std::string key = "key";
|
||||
std::string value;
|
||||
@ -426,6 +489,9 @@ HWTEST_F(DbAdapterTest, PutData_04, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DbAdapterTest, PutData_05, TestSize.Level0)
|
||||
{
|
||||
if (g_dbAdapterPtr == nullptr) {
|
||||
return;
|
||||
}
|
||||
std::string key = "key";
|
||||
std::string value = "value";
|
||||
g_dbAdapterPtr->kvStoragePtr_ = nullptr;
|
||||
|
@ -36,7 +36,7 @@ namespace DistributedHardware {
|
||||
namespace {
|
||||
const int32_t ASID = 4801;
|
||||
const DHTopic TOPIC = DHTopic::TOPIC_START_DSCREEN;
|
||||
sptr<IPublisherListener> g_listener = sptr<IPublisherListener>(new MockPublisherListener());
|
||||
sptr<IPublisherListener> g_listener(new MockPublisherListener());
|
||||
|
||||
const std::u16string ARGS_H = u"-h";
|
||||
const std::u16string ARGS_L = u"-l";
|
||||
|
@ -45,6 +45,9 @@ void DistributedHardwareStubTest::TearDown()
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_001, TestSize.Level0)
|
||||
{
|
||||
if (stubTest_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
uint32_t code = 0;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
@ -60,6 +63,9 @@ HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_001, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_002, TestSize.Level0)
|
||||
{
|
||||
if (stubTest_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
uint32_t code = 0;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
@ -69,6 +75,9 @@ HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_002, TestSize.Level0)
|
||||
|
||||
HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_003, TestSize.Level0)
|
||||
{
|
||||
if (stubTest_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
uint32_t code = static_cast<uint32_t>(DHMsgInterfaceCode::REG_PUBLISHER_LISTNER);
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
@ -82,6 +91,9 @@ HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_003, TestSize.Level0)
|
||||
|
||||
HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_004, TestSize.Level0)
|
||||
{
|
||||
if (stubTest_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
uint32_t code = static_cast<uint32_t>(DHMsgInterfaceCode::PUBLISH_MESSAGE);
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
@ -95,6 +107,9 @@ HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_004, TestSize.Level0)
|
||||
|
||||
HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_005, TestSize.Level0)
|
||||
{
|
||||
if (stubTest_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
uint32_t code = static_cast<uint32_t>(DHMsgInterfaceCode::INIT_CTL_CEN);
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
@ -108,6 +123,9 @@ HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_005, TestSize.Level0)
|
||||
|
||||
HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_006, TestSize.Level0)
|
||||
{
|
||||
if (stubTest_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
uint32_t code = static_cast<uint32_t>(DHMsgInterfaceCode::RELEASE_CTL_CEN);
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
@ -121,6 +139,9 @@ HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_006, TestSize.Level0)
|
||||
|
||||
HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_007, TestSize.Level0)
|
||||
{
|
||||
if (stubTest_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
uint32_t code = static_cast<uint32_t>(DHMsgInterfaceCode::CREATE_CTL_CEN_CHANNEL);
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
@ -136,6 +157,9 @@ HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_007, TestSize.Level0)
|
||||
|
||||
HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_008, TestSize.Level0)
|
||||
{
|
||||
if (stubTest_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
uint32_t code = static_cast<uint32_t>(DHMsgInterfaceCode::NOTIFY_AV_EVENT);
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
@ -155,6 +179,9 @@ HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_008, TestSize.Level0)
|
||||
|
||||
HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_009, TestSize.Level0)
|
||||
{
|
||||
if (stubTest_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
uint32_t code = static_cast<uint32_t>(DHMsgInterfaceCode::QUERY_LOCAL_SYS_SPEC);
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
@ -168,6 +195,9 @@ HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_009, TestSize.Level0)
|
||||
|
||||
HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_010, TestSize.Level0)
|
||||
{
|
||||
if (stubTest_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
uint32_t code = static_cast<uint32_t>(DHMsgInterfaceCode::NOTIFY_SOURCE_DEVICE_REMOTE_DMSDP_STARTED);
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
@ -181,6 +211,9 @@ HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_010, TestSize.Level0)
|
||||
|
||||
HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_011, TestSize.Level0)
|
||||
{
|
||||
if (stubTest_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
uint32_t code = static_cast<uint32_t>(DHMsgInterfaceCode::PAUSE_DISTRIBUTED_HARDWARE);
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
@ -192,6 +225,9 @@ HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_011, TestSize.Level0)
|
||||
|
||||
HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_012, TestSize.Level0)
|
||||
{
|
||||
if (stubTest_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
uint32_t code = static_cast<uint32_t>(DHMsgInterfaceCode::RESUME_DISTRIBUTED_HARDWARE);
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
@ -203,6 +239,9 @@ HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_012, TestSize.Level0)
|
||||
|
||||
HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_013, TestSize.Level0)
|
||||
{
|
||||
if (stubTest_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
uint32_t code = static_cast<uint32_t>(DHMsgInterfaceCode::STOP_DISTRIBUTED_HARDWARE);
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
@ -214,6 +253,9 @@ HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_013, TestSize.Level0)
|
||||
|
||||
HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_014, TestSize.Level0)
|
||||
{
|
||||
if (stubTest_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
uint32_t code = static_cast<uint32_t>(DHMsgInterfaceCode::UNREG_PUBLISHER_LISTENER);
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
@ -233,6 +275,9 @@ HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_014, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareStubTest, RegisterPublisherListenerInner_001, TestSize.Level0)
|
||||
{
|
||||
if (stubTest_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
EXPECT_NE(DH_FWK_SUCCESS, stubTest_->RegisterPublisherListenerInner(data, reply));
|
||||
@ -246,6 +291,9 @@ HWTEST_F(DistributedHardwareStubTest, RegisterPublisherListenerInner_001, TestSi
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareStubTest, UnregisterPublisherListenerInner_001, TestSize.Level0)
|
||||
{
|
||||
if (stubTest_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
EXPECT_NE(DH_FWK_SUCCESS, stubTest_->UnregisterPublisherListenerInner(data, reply));
|
||||
@ -259,6 +307,9 @@ HWTEST_F(DistributedHardwareStubTest, UnregisterPublisherListenerInner_001, Test
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareStubTest, PublishMessageInner_001, TestSize.Level0)
|
||||
{
|
||||
if (stubTest_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
EXPECT_NE(DH_FWK_SUCCESS, stubTest_->PublishMessageInner(data, reply));
|
||||
@ -272,6 +323,9 @@ HWTEST_F(DistributedHardwareStubTest, PublishMessageInner_001, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareStubTest, ValidTopic_001, TestSize.Level0)
|
||||
{
|
||||
if (stubTest_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
uint32_t topic = static_cast<uint32_t>(DHTopic::TOPIC_MIN);
|
||||
EXPECT_EQ(false, stubTest_->ValidTopic(topic));
|
||||
|
||||
@ -290,6 +344,9 @@ HWTEST_F(DistributedHardwareStubTest, ValidTopic_001, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareStubTest, ValidQueryLocalSpec_001, TestSize.Level0)
|
||||
{
|
||||
if (stubTest_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
uint32_t spec = 1;
|
||||
EXPECT_EQ(true, stubTest_->ValidQueryLocalSpec(spec));
|
||||
}
|
||||
@ -302,6 +359,9 @@ HWTEST_F(DistributedHardwareStubTest, ValidQueryLocalSpec_001, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(DistributedHardwareStubTest, ValidQueryLocalSpec_002, TestSize.Level0)
|
||||
{
|
||||
if (stubTest_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
uint32_t spec = 0;
|
||||
EXPECT_EQ(false, stubTest_->ValidQueryLocalSpec(spec));
|
||||
spec = 5;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-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
|
||||
@ -46,6 +46,9 @@ void PublisherListenerProxyTest::TearDown()
|
||||
*/
|
||||
HWTEST_F(PublisherListenerProxyTest, OnMessage_001, TestSize.Level0)
|
||||
{
|
||||
if (proxy_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
uint32_t invalid = 8;
|
||||
DHTopic topic = static_cast<DHTopic>(invalid);
|
||||
std::string message;
|
||||
@ -61,6 +64,9 @@ HWTEST_F(PublisherListenerProxyTest, OnMessage_001, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(PublisherListenerProxyTest, OnMessage_002, TestSize.Level0)
|
||||
{
|
||||
if (proxy_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
DHTopic topic = DHTopic::TOPIC_START_DSCREEN;
|
||||
std::string message;
|
||||
proxy_->OnMessage(topic, message);
|
||||
@ -75,6 +81,9 @@ HWTEST_F(PublisherListenerProxyTest, OnMessage_002, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(PublisherListenerProxyTest, OnMessage_003, TestSize.Level0)
|
||||
{
|
||||
if (proxy_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
DHTopic topic = DHTopic::TOPIC_START_DSCREEN;
|
||||
std::string message = "message";
|
||||
proxy_->OnMessage(topic, message);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-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
|
||||
@ -51,6 +51,9 @@ void PluginListenerImplTest::TearDown() {}
|
||||
*/
|
||||
HWTEST_F(PluginListenerImplTest, plugin_listener_impl_test_001, TestSize.Level0)
|
||||
{
|
||||
if (g_mockHardwareHandler == nullptr) {
|
||||
return;
|
||||
}
|
||||
g_mockHardwareHandler->RegisterPluginListener(g_listener);
|
||||
EXPECT_EQ(g_mockHardwareHandler->PluginHardware(dhId, attrs, subtype), DH_FWK_SUCCESS);
|
||||
}
|
||||
@ -63,6 +66,9 @@ HWTEST_F(PluginListenerImplTest, plugin_listener_impl_test_001, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(PluginListenerImplTest, plugin_listener_impl_test_002, TestSize.Level0)
|
||||
{
|
||||
if (g_mockHardwareHandler == nullptr) {
|
||||
return;
|
||||
}
|
||||
EXPECT_EQ(g_mockHardwareHandler->UnPluginHardware(dhId), DH_FWK_SUCCESS);
|
||||
g_mockHardwareHandler->UnRegisterPluginListener();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-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
|
||||
@ -30,7 +30,7 @@ void LowLatencyListenerTest::TearDownTestCase()
|
||||
|
||||
void LowLatencyListenerTest::SetUp()
|
||||
{
|
||||
listener_ = new(std::nothrow) LowLatencyListener;
|
||||
listener_ = sptr<LowLatencyListener>(new(std::nothrow) LowLatencyListener());
|
||||
}
|
||||
|
||||
void LowLatencyListenerTest::TearDown()
|
||||
@ -46,6 +46,9 @@ void LowLatencyListenerTest::TearDown()
|
||||
*/
|
||||
HWTEST_F(LowLatencyListenerTest, OnMessage_001, TestSize.Level0)
|
||||
{
|
||||
if (listener_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
DHTopic topic = DHTopic::TOPIC_MIN;
|
||||
std::string message;
|
||||
listener_->OnMessage(topic, message);
|
||||
@ -60,6 +63,9 @@ HWTEST_F(LowLatencyListenerTest, OnMessage_001, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(LowLatencyListenerTest, OnMessage_002, TestSize.Level0)
|
||||
{
|
||||
if (listener_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
DHTopic topic = DHTopic::TOPIC_START_DSCREEN;
|
||||
std::string message;
|
||||
listener_->OnMessage(topic, message);
|
||||
@ -74,6 +80,9 @@ HWTEST_F(LowLatencyListenerTest, OnMessage_002, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(LowLatencyListenerTest, OnMessage_003, TestSize.Level0)
|
||||
{
|
||||
if (listener_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
DHTopic topic = DHTopic::TOPIC_START_DSCREEN;
|
||||
std::string message = "message";
|
||||
listener_->OnMessage(topic, message);
|
||||
@ -88,8 +97,10 @@ HWTEST_F(LowLatencyListenerTest, OnMessage_003, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(LowLatencyListenerTest, OnMessage_004, TestSize.Level0)
|
||||
{
|
||||
if (listener_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
DHTopic topic = DHTopic::TOPIC_START_DSCREEN;
|
||||
|
||||
cJSON* json = cJSON_CreateObject();
|
||||
const char* DH_TYPE = "dh_type";
|
||||
const char* LOW_LATENCY_ENABLE = "low_latency_enable";
|
||||
@ -112,6 +123,9 @@ HWTEST_F(LowLatencyListenerTest, OnMessage_004, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(LowLatencyListenerTest, OnMessage_005, TestSize.Level0)
|
||||
{
|
||||
if (listener_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
DHTopic topic = DHTopic::TOPIC_START_DSCREEN;
|
||||
std::string message;
|
||||
uint32_t MAX_MESSAGE_LEN = 40 * 1024 * 1024;
|
||||
@ -128,6 +142,9 @@ HWTEST_F(LowLatencyListenerTest, OnMessage_005, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(LowLatencyListenerTest, OnMessage_006, TestSize.Level0)
|
||||
{
|
||||
if (listener_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
DHTopic topic = DHTopic::TOPIC_START_DSCREEN;
|
||||
cJSON* json = cJSON_CreateObject();
|
||||
const char* DH_TYPE = "dh_type";
|
||||
@ -150,6 +167,9 @@ HWTEST_F(LowLatencyListenerTest, OnMessage_006, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(LowLatencyListenerTest, OnMessage_007, TestSize.Level0)
|
||||
{
|
||||
if (listener_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
DHTopic topic = DHTopic::TOPIC_START_DSCREEN;
|
||||
cJSON* json = cJSON_CreateObject();
|
||||
const char* DH_TYPE = "dh_type";
|
||||
@ -172,6 +192,9 @@ HWTEST_F(LowLatencyListenerTest, OnMessage_007, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(LowLatencyListenerTest, ExecuteInner_008, TestSize.Level0)
|
||||
{
|
||||
if (listener_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
std::string timerId;
|
||||
int32_t delayTimeMs = 1;
|
||||
LowLatencyTimer timer(timerId, delayTimeMs);
|
||||
@ -187,6 +210,9 @@ HWTEST_F(LowLatencyListenerTest, ExecuteInner_008, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(LowLatencyListenerTest, HandleStopTimer_008, TestSize.Level0)
|
||||
{
|
||||
if (listener_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
std::string timerId;
|
||||
int32_t delayTimeMs = 1;
|
||||
LowLatencyTimer timer(timerId, delayTimeMs);
|
||||
|
@ -59,6 +59,9 @@ void DhCommToolTest::TearDown()
|
||||
|
||||
HWTEST_F(DhCommToolTest, TriggerReqFullDHCaps_001, TestSize.Level0)
|
||||
{
|
||||
if (dhCommToolTest_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
std::string remoteNetworkId = "";
|
||||
dhCommToolTest_->TriggerReqFullDHCaps(remoteNetworkId);
|
||||
|
||||
@ -76,6 +79,9 @@ HWTEST_F(DhCommToolTest, TriggerReqFullDHCaps_001, TestSize.Level0)
|
||||
|
||||
HWTEST_F(DhCommToolTest, GetAndSendLocalFullCaps_001, TestSize.Level0)
|
||||
{
|
||||
if (dhCommToolTest_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
std::string reqNetworkId = "";
|
||||
dhCommToolTest_->dhTransportPtr_ = nullptr;
|
||||
dhCommToolTest_->GetAndSendLocalFullCaps(reqNetworkId);
|
||||
@ -87,6 +93,9 @@ HWTEST_F(DhCommToolTest, GetAndSendLocalFullCaps_001, TestSize.Level0)
|
||||
|
||||
HWTEST_F(DhCommToolTest, ParseAndSaveRemoteDHCaps_001, TestSize.Level0)
|
||||
{
|
||||
if (dhCommToolTest_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
std::string remoteCaps = "";
|
||||
FullCapsRsp ret = dhCommToolTest_->ParseAndSaveRemoteDHCaps(remoteCaps);
|
||||
EXPECT_EQ("", ret.networkId);
|
||||
|
@ -60,6 +60,9 @@ void DhTransportTest::TearDown()
|
||||
|
||||
HWTEST_F(DhTransportTest, OnSocketClosed_001, TestSize.Level0)
|
||||
{
|
||||
if (dhTransportTest_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
ShutdownReason reason = ShutdownReason::SHUTDOWN_REASON_UNKNOWN;
|
||||
dhTransportTest_->remoteDevSocketIds_[g_networkid] = g_socketid;
|
||||
dhTransportTest_->OnSocketClosed(2, reason);
|
||||
@ -70,6 +73,9 @@ HWTEST_F(DhTransportTest, OnSocketClosed_001, TestSize.Level0)
|
||||
|
||||
HWTEST_F(DhTransportTest, OnBytesReceived_001, TestSize.Level0)
|
||||
{
|
||||
if (dhTransportTest_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
int32_t sessionId = -1;
|
||||
char *data = nullptr;
|
||||
uint32_t dataLen = 0;
|
||||
@ -101,6 +107,9 @@ HWTEST_F(DhTransportTest, OnBytesReceived_001, TestSize.Level0)
|
||||
|
||||
HWTEST_F(DhTransportTest, Init_001, TestSize.Level0)
|
||||
{
|
||||
if (dhTransportTest_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
dhTransportTest_->isSocketSvrCreateFlag_ = true;
|
||||
auto ret = dhTransportTest_->Init();
|
||||
EXPECT_EQ(DH_FWK_SUCCESS, ret);
|
||||
@ -112,6 +121,9 @@ HWTEST_F(DhTransportTest, Init_001, TestSize.Level0)
|
||||
|
||||
HWTEST_F(DhTransportTest, UnInit_001, TestSize.Level0)
|
||||
{
|
||||
if (dhTransportTest_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
auto ret = dhTransportTest_->UnInit();
|
||||
EXPECT_EQ(DH_FWK_SUCCESS, ret);
|
||||
|
||||
@ -122,6 +134,9 @@ HWTEST_F(DhTransportTest, UnInit_001, TestSize.Level0)
|
||||
|
||||
HWTEST_F(DhTransportTest, IsDeviceSessionOpened_001, TestSize.Level0)
|
||||
{
|
||||
if (dhTransportTest_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
dhTransportTest_->remoteDevSocketIds_.clear();
|
||||
auto ret = dhTransportTest_->IsDeviceSessionOpened(g_networkid, g_socketid);
|
||||
EXPECT_EQ(false, ret);
|
||||
@ -133,6 +148,9 @@ HWTEST_F(DhTransportTest, IsDeviceSessionOpened_001, TestSize.Level0)
|
||||
|
||||
HWTEST_F(DhTransportTest, StartSocket_001, TestSize.Level0)
|
||||
{
|
||||
if (dhTransportTest_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
dhTransportTest_->remoteDevSocketIds_[g_networkid] = g_socketid;
|
||||
auto ret = dhTransportTest_->StartSocket(g_networkid);
|
||||
EXPECT_EQ(DH_FWK_SUCCESS, ret);
|
||||
@ -144,6 +162,9 @@ HWTEST_F(DhTransportTest, StartSocket_001, TestSize.Level0)
|
||||
|
||||
HWTEST_F(DhTransportTest, StopSocket_001, TestSize.Level0)
|
||||
{
|
||||
if (dhTransportTest_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
dhTransportTest_->remoteDevSocketIds_.clear();
|
||||
auto ret = dhTransportTest_->StopSocket(g_networkid);
|
||||
EXPECT_EQ(ERR_DH_FWK_COMPONENT_TRANSPORT_OPT_FAILED, ret);
|
||||
@ -155,6 +176,9 @@ HWTEST_F(DhTransportTest, StopSocket_001, TestSize.Level0)
|
||||
|
||||
HWTEST_F(DhTransportTest, Send_001, TestSize.Level0)
|
||||
{
|
||||
if (dhTransportTest_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
std::string payload = "payload_test";
|
||||
dhTransportTest_->remoteDevSocketIds_.clear();
|
||||
auto ret = dhTransportTest_->Send(g_networkid, payload);
|
||||
|
Loading…
Reference in New Issue
Block a user