From 1adde2365074986c56c342c9515ccf18585229b2 Mon Sep 17 00:00:00 2001 From: yuvaramachandran_gurusamy Date: Fri, 30 Aug 2024 09:26:36 +0000 Subject: [PATCH] RDKTV-32602: Update MiracastService unit test based on getRFCParameter API Signed-off-by: yuvaramachandran_gurusamy --- .../MiracastService/MiracastController.cpp | 4 +--- Tests/L1Tests/tests/test_MiracastService.cpp | 22 ++++++++++++++++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Miracast/MiracastService/MiracastController.cpp b/Miracast/MiracastService/MiracastController.cpp index ce13b6d0a3..67e182cd91 100644 --- a/Miracast/MiracastService/MiracastController.cpp +++ b/Miracast/MiracastService/MiracastController.cpp @@ -1352,13 +1352,11 @@ void MiracastController::set_enable(bool is_enabled) isMiracastRFCEnabled = true; } } - - MIRACASTLOG_INFO(" Is Miracast RFC enabled ? %d , call value %d ", isMiracastRFCEnabled, wdmpStatus); + MIRACASTLOG_INFO(" Is Miracast RFC enabled ? %d , call value %d , type value %d", isMiracastRFCEnabled, wdmpStatus, param.type); #else isMiracastRFCEnabled = true; #endif //RFC_ENABLED - if(!isMiracastRFCEnabled) { MIRACASTLOG_INFO("----------MIRACAST RFC Disabled---------- "); diff --git a/Tests/L1Tests/tests/test_MiracastService.cpp b/Tests/L1Tests/tests/test_MiracastService.cpp index a960fb9342..b1a87c29c2 100644 --- a/Tests/L1Tests/tests/test_MiracastService.cpp +++ b/Tests/L1Tests/tests/test_MiracastService.cpp @@ -5,6 +5,7 @@ #include "WrapsMock.h" #include "WpaCtrlMock.h" #include "IarmBusMock.h" +#include "RfcApiMock.h" using ::testing::NiceMock; using namespace WPEFramework; @@ -77,6 +78,7 @@ class MiracastServiceTest : public ::testing::Test { WrapsImplMock *p_wrapsImplMock = nullptr; WpaCtrlApiImplMock *p_wpaCtrlImplMock = nullptr; IarmBusImplMock *p_iarmBusImplMock = nullptr; + RfcApiImplMock *p_rfcApiImplMock = nullptr; IARM_EventHandler_t pwrMgrEventHandler; MiracastServiceTest() @@ -93,6 +95,9 @@ class MiracastServiceTest : public ::testing::Test { p_iarmBusImplMock = new testing::NiceMock ; IarmBus::setImpl(p_iarmBusImplMock); + p_rfcApiImplMock = new testing::NiceMock ; + RfcApi::setImpl(p_rfcApiImplMock); + EXPECT_CALL(service, QueryInterfaceByCallsign(::testing::_, ::testing::_)) .Times(::testing::AnyNumber()) .WillRepeatedly(::testing::Invoke([&](const uint32_t, const string& name) -> void* { return nullptr; })); @@ -121,6 +126,14 @@ class MiracastServiceTest : public ::testing::Test { } return IARM_RESULT_SUCCESS; }); + ON_CALL(*p_rfcApiImplMock, getRFCParameter) + .WillByDefault([](char* pcCallerID, const char* pcParameterName, RFC_ParamData_t* pstParamData){ + EXPECT_EQ(string(pcCallerID), string("MiracastPlugin")); + EXPECT_EQ(string(pcParameterName), string("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Miracast.Enable")); + strncpy(pstParamData->value, "true", sizeof(pstParamData->value)); + pstParamData->type = WDMP_BOOLEAN; + return WDMP_SUCCESS; + }); } virtual ~MiracastServiceTest() override { @@ -144,6 +157,13 @@ class MiracastServiceTest : public ::testing::Test { delete p_iarmBusImplMock; p_iarmBusImplMock = nullptr; } + + RfcApi::setImpl(nullptr); + if (p_rfcApiImplMock != nullptr) + { + delete p_rfcApiImplMock; + p_rfcApiImplMock = nullptr; + } } }; @@ -2046,4 +2066,4 @@ TEST_F(MiracastServiceEventTest, wifiStateChange) removeEntryFromFile("/etc/device.properties","WIFI_P2P_CTRL_INTERFACE=p2p0"); removeFile("/var/run/wpa_supplicant/p2p0"); -} \ No newline at end of file +}