forked from rdkcentral/networkmanager
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
136 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include "WiFiSignalStrengthMonitor.h" | ||
#include "NetworkManagerImplementation.h" | ||
#include "NetworkManagerLogger.h" | ||
#include "INetworkManager.h" | ||
#include <gtest/gtest.h> | ||
#include <gmock/gmock.h> | ||
#include <iostream> | ||
#include <thread> | ||
#include <chrono> | ||
#include <list> | ||
#include <string> | ||
|
||
using namespace std; | ||
using namespace WPEFramework; | ||
using namespace WPEFramework::Plugin; | ||
namespace WPEFramework | ||
{ | ||
namespace Plugin | ||
{ | ||
NetworkManagerImplementation* _instance; | ||
void NetworkManagerImplementation::ReportWiFiSignalStrengthChange(const string ssid, const string strength, const WiFiSignalQuality quality) | ||
{ | ||
return; | ||
} | ||
void NetworkManagerImplementation::ReportInternetStatusChange(const InternetStatus prevState, const InternetStatus currState) | ||
{ | ||
return; | ||
} | ||
} | ||
} | ||
|
||
class WiFiSignalStrengthMonitorTest : public ::testing::Test { | ||
protected: | ||
WPEFramework::Plugin::WiFiSignalStrengthMonitor monitor; | ||
void SetUp() override { | ||
} | ||
void TearDown() override { | ||
} | ||
}; | ||
#define BUFFER_SIZE 1024 | ||
|
||
TEST_F(WiFiSignalStrengthMonitorTest, GetSignalData_Connected) { | ||
std::string ssid = "TestSSID"; | ||
Exchange::INetworkManager::WiFiSignalQuality quality; | ||
std::string strengthOut= "-55"; | ||
monitor.getSignalData(ssid, quality, strengthOut); | ||
} | ||
|
||
TEST_F(WiFiSignalStrengthMonitorTest, StartWiFiSignalStrengthMonitor) { | ||
monitor.startWiFiSignalStrengthMonitor(1); | ||
|
||
} | ||
|
||
int main(int argc, char **argv) { | ||
::testing::InitGoogleMock(&argc, argv); | ||
return RUN_ALL_TESTS(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
cmake_minimum_required(VERSION 3.10) | ||
set(UNIT_TEST "tests") | ||
|
||
find_package(PkgConfig REQUIRED) | ||
pkg_check_modules(GLIB REQUIRED glib-2.0) | ||
pkg_check_modules(GIO REQUIRED gio-2.0) | ||
pkg_check_modules(LIBNM REQUIRED libnm) | ||
|
||
include(FetchContent) | ||
FetchContent_Declare( | ||
googletest | ||
URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip | ||
) | ||
|
||
FetchContent_MakeAvailable(googletest) | ||
add_executable(${UNIT_TEST} | ||
Tests/unit_test/test_WiFiSignalStrengthMonitor.cpp | ||
WiFiSignalStrengthMonitor.cpp | ||
NetworkManagerLogger.cpp | ||
NetworkManagerConnectivity.cpp | ||
) | ||
set_target_properties(${UNIT_TEST} PROPERTIES | ||
CXX_STANDARD 11 | ||
CXX_STANDARD_REQUIRED YES | ||
) | ||
target_compile_options(${UNIT_TEST} PRIVATE -Wall -include ${CMAKE_SOURCE_DIR}/INetworkManager.h) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") | ||
|
||
target_include_directories(${UNIT_TEST} PRIVATE | ||
${GLIB_INCLUDE_DIRS} | ||
${LIBNM_INCLUDE_DIRS} | ||
${GIO_INCLUDE_DIRS} | ||
${PROJECT_SOURCE_DIR} | ||
${CMAKE_CURRENT_SOURCE_DIR} | ||
Tests | ||
${gtest_SOURCE_DIR}/include | ||
${gtest_SOURCE_DIR}/../googlemock/include | ||
) | ||
|
||
target_link_libraries(${UNIT_TEST} PRIVATE gmock_main ${NAMESPACE}Core::${NAMESPACE}Core ${GLIB_LIBRARIES} ${GIO_LIBRARIES} ${LIBNM_LIBRARIES} ${CURL_LIBRARIES}) | ||
target_include_directories(${UNIT_TEST} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) | ||
install(TARGETS ${UNIT_TEST} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters