Skip to content

Commit

Permalink
Test code make it as unit test code
Browse files Browse the repository at this point in the history
  • Loading branch information
cmuhammedrafi committed Oct 4, 2024
1 parent 37c5d5b commit b19a37a
Show file tree
Hide file tree
Showing 19 changed files with 995 additions and 1,456 deletions.
62 changes: 62 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"files.associations": {
"cstdio": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"cctype": "cpp",
"chrono": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"compare": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"list": "cpp",
"map": "cpp",
"set": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"random": "cpp",
"ratio": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"numbers": "cpp",
"ostream": "cpp",
"semaphore": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"typeinfo": "cpp"
}
}
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/${STORAGE

if(ENABLE_GNOME_NETWORKMANAGER)
target_sources(${MODULE_NAME} PRIVATE NetworkManagerGnomeProxy.cpp
NetworkManagerGnomeWIFI.cpp
NetworkManagerGnomeEvents.cpp
NetworkManagerGnomeUtils.cpp )
GnomeProxy/NetworkManagerGnomeUtils.cpp
GnomeProxy/NetworkManagerGnomeClient.cpp
)
target_include_directories(${MODULE_NAME} PRIVATE ${GLIB_INCLUDE_DIRS} ${LIBNM_INCLUDE_DIRS})
target_link_libraries(${MODULE_NAME} PRIVATE ${LIBNM_LIBRARIES})
target_link_libraries(${MODULE_NAME} PRIVATE ${GLIB_LIBRARIES} ${GIO_LIBRARIES})
else()
target_sources(${MODULE_NAME} PRIVATE NetworkManagerRDKProxy.cpp)
target_include_directories(${MODULE_NAME} PRIVATE ${IARMBUS_INCLUDE_DIRS})
Expand Down
68 changes: 68 additions & 0 deletions GnomeProxy/NetworkManagerDbusMgr.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
* If not stated otherwise in this file or this component's LICENSE
* file the following copyright and licenses apply:
*
* Copyright 2022 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

#include <glib.h>
#include <gio/gio.h>
#include <string>

#include "NetworkManagerDbusMgr.h"
#include "NetworkManagerLogger.h"

namespace WPEFramework
{
namespace Plugin
{

DbusConnectionManager::DbusConnectionManager() : connection(nullptr) {
NMLOG_INFO("DbusConnectionManager created");
}

DbusConnectionManager::~DbusConnectionManager() {
DeinitializeDbusConnection();
}

bool DbusConnectionManager::InitializeBusConnection(const std::string& busName) {
GError* error = nullptr;
connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, nullptr, &error);

if (!connection) {
NMLOG_ERROR("Failed to initialize D-Bus connection: %s ", error->message);
g_error_free(error);
return false;
}

NMLOG_INFO("D-Bus connection initialized successfully for bus: %s", busName.c_str());
return true;
}

void DbusConnectionManager::DeinitializeDbusConnection() {
if (connection) {
g_object_unref(connection);
connection = nullptr;
NMLOG_INFO("D-Bus connection deinitialized successfully");
}
}

GDBusConnection* DbusConnectionManager::getConnection() const {
return connection;
}

} // Plugin
} // WPEFramework

47 changes: 47 additions & 0 deletions GnomeProxy/NetworkManagerDbusMgr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2020 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once
#include <gio/gio.h>
#include <iostream>
#include <string>
#include <list>

/* include NetworkManager.h for the defines, but we don't link against libnm. */
#include <nm-dbus-interface.h>

namespace WPEFramework
{
namespace Plugin
{
class DbusConnectionManager {
public:
DbusConnectionManager();
~DbusConnectionManager();

bool InitializeBusConnection(const std::string& busName);
void DeinitializeDbusConnection();
GDBusConnection* getConnection() const;

private:
GDBusConnection* connection;
};

}
}
Loading

0 comments on commit b19a37a

Please sign in to comment.