From 7f368ba8a926b1585d075a5b7dbf58f37ac89cb9 Mon Sep 17 00:00:00 2001 From: Parvathi Date: Thu, 5 Dec 2024 10:55:35 +0530 Subject: [PATCH] tried for class invocation --- .../test_LegacyPlugin_WiFiManagerAPIs.cpp | 50 ++++++++----------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/Tests/unittest/test_LegacyPlugin_WiFiManagerAPIs.cpp b/Tests/unittest/test_LegacyPlugin_WiFiManagerAPIs.cpp index df957a1d..1c232b5c 100644 --- a/Tests/unittest/test_LegacyPlugin_WiFiManagerAPIs.cpp +++ b/Tests/unittest/test_LegacyPlugin_WiFiManagerAPIs.cpp @@ -14,7 +14,7 @@ using namespace std; using namespace WPEFramework; using ::testing::NiceMock; -//using namespace WPEFramework::PluginHost; +using namespace WPEFramework::Plugin; //class WiFiManager : public PluginHost::IPlugin, public PluginHost::JSONRPC @@ -22,36 +22,30 @@ class WiFiManagerTest : public ::testing::Test { protected: Core::ProxyType plugin; Core::JSONRPC::Handler& handler; - //Core::JSONRPC::Connection connection; + Core::JSONRPC::Connection connection; string response; Core::JSONRPC::Message message; - //WrapsImplMock *p_wrapsImplMock = nullptr ; - //NiceMock iarmBusImplMock; - //IarmBusImplMock *p_iarmBusImplMock = nullptr ; - //ServiceMock services; -}; - -class WifiInitializedEventTest : public WiFiManagerTest { -protected: - FactoriesImplementation factoriesImplementation; - PluginHost::IDispatcher* dispatcher; - - - WifiInitializedEventTest() - : WiFiManagerTest() - { - PluginHost::IFactories::Assign(&factoriesImplementation); - - dispatcher = static_cast( - plugin->QueryInterface(PluginHost::IDispatcher::ID)); - dispatcher->Activate(&services); + + NiceMock mockShell; + NiceMock mockDispatcher; + + + WiFiManagerTest() + : plugin(Core::ProxyType::Create()) + , handler(*(plugin)) + , connection(1, 0) { } - virtual ~WifiInitializedEventTest() override - { - dispatcher->Deactivate(); - dispatcher->Release(); - PluginHost::IFactories::Assign(nullptr); - + virtual ~WiFiManagerTest() override { + // Cleanup if needed + } + + // Helper function to simulate sending a JSON-RPC request + void sendJsonRpcRequest(const string& methodName, const JsonObject& parameters) { + message.Method(methodName); + message.Parameters(parameters); + handler.Process(connection, message); } }; + +