ADD_SUBDIRECTORY(src)
IF(BUILD_GTESTS)
- ADD_SUBDIRECTORY(unittest)
+ ADD_SUBDIRECTORY(gtest)
ENDIF(BUILD_GTESTS)
IF(BUILD_TEST_APP)
ADD_SUBDIRECTORY(test)
--- /dev/null
+# Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+#
+# 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.
+#
+# @file CMakeLists.txt
+#
+
+LINK_DIRECTORIES(${CMAKE_BINARY_DIR})
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+
+SET(GTEST_TEST "gtest-inm-manager")
+
+IF(BUILD_GTESTS)
+ ADD_DEFINITIONS(-DBUILD_GTESTS)
+ENDIF(BUILD_GTESTS)
+
+FILE(GLOB GTEST_TEST_SRCS *.cpp ${CMAKE_SOURCE_DIR}/src/*.c)
+LIST(REMOVE_ITEM GTEST_TEST_SRCS ${CMAKE_SOURCE_DIR}/src/inm-manager-main.c)
+
+FILE(GLOB GTEST_TEST_SRCS *.cpp)
+
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(gtest_pkgs REQUIRED
+ glib-2.0
+ gio-2.0
+ gmock
+ vconf
+ libnl-2.0
+ dlog
+ )
+
+SET(REQUIRED_LIBS "-ldl")
+
+IF(BUILD_GCOV)
+ ADD_DEFINITIONS("-DTIZEN_TEST_GCOV")
+ SET(REQUIRED_LIBS "${REQUIRED_LIBS} -lgcov")
+ENDIF(BUILD_GCOV)
+
+FOREACH(flag ${gtest_pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+INCLUDE_DIRECTORIES(${gtest_pkgs_INCLUDE_DIRS})
+LINK_DIRECTORIES(${gtest_pkgs_LIBRARY_DIRS})
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fpie")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpie")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+
+ADD_DEFINITIONS("-DUSE_DLOG")
+
+ADD_EXECUTABLE(${GTEST_TEST} ${GTEST_TEST_SRCS})
+TARGET_LINK_LIBRARIES(${GTEST_TEST} ${gtest_pkgs_LDFLAGS} ${LIBRARY} ${REQUIRED_LIBS})
+
+INSTALL(TARGETS ${GTEST_TEST} DESTINATION bin)
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 "gtest-inm-mgr-connection.h"
+
+#define INM_MGR_CONNECTION_DBUS_INTERFACE INM_MGR_DBUS_SERVICE ".conn"
+#define INM_MGR_CONNECTION_DBUS_PATH INM_MGR_DBUS_PATH "/conn"
+#define INM_MGR_MTD_GET_ALL "GetAll"
+
+//LCOV_EXCL_START
+Connection::Connection(void) : GDbus(INM_MGR_DBUS_SERVICE,
+ INM_MGR_CONNECTION_DBUS_PATH,
+ INM_MGR_CONNECTION_DBUS_INTERFACE)
+{
+}
+
+Connection::~Connection(void)
+{
+}
+
+error_e Connection::getAll_p(const char *object_path)
+{
+ error_e ret;
+ GVariant *reply;
+
+ reply = GDbus::InvokeMethod(object_path, INM_MGR_MTD_GET_ALL,
+ NULL, &ret);
+ if (ret != ERROR_NONE)
+ return ret;
+
+ if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("(a{sv})"))) {
+ g_variant_unref(reply);
+ return ERROR_OPERATION_FAILED;
+ }
+
+ g_variant_unref(reply);
+ return ERROR_NONE;
+}
+//LCOV_EXCL_STOP
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+#ifndef __GTEST_INM_MGR_CONNECTION_H__
+#define __GTEST_INM_MGR_CONNECTION_H__
+
+#include "gtest-inm-mgr-gdbus.h"
+#include "gtest-inm-mgr-error.h"
+
+class Connection : public GDbus {
+private:
+public:
+ Connection(void);
+ ~Connection(void);
+ error_e getAll_p(const char *object_path);
+};
+
+#endif /* __GTEST_INM_MGR_CONNECTION_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+#ifndef __GTEST_INM_MGR_ERROR_H__
+#define __GTEST_INM_MGR_ERROR_H__
+
+#include <glib.h>
+
+#define APP_ID_LEN 128
+#define IFNAME_LEN 16
+#define SUBSCRIBER_ID_LEN 128
+
+#ifdef USE_DLOG
+#include <dlog.h>
+#undef LOG_TAG
+#define LOG_TAG "INM_GTEST"
+#define GLOGD(format, args...) LOGD(format, ##args)
+#else
+#define GLOGD(format, args...)
+#endif
+
+typedef enum {
+ ERROR_NONE = 0,
+ ERROR_NOT_INITIALIZED,
+ ERROR_INVALID_PARAM,
+ ERROR_NOT_PERMITTED,
+ ERROR_OUT_OF_MEMORY,
+ ERROR_OPERATION_FAILED,
+ ERROR_IN_PROGRESS
+} error_e;
+
+#endif /* __GTEST_INM_MGR_ERROR_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <iostream>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+#include "gtest-inm-mgr-gdbus.h"
+
+//LCOV_EXCL_START
+GDbus::GDbus(void) : m_pConnection(NULL), m_pCancellable(NULL),
+ m_gdbusDestination(NULL), m_gdbusObjectPath(NULL),
+ m_gdbusInterface(NULL)
+{
+}
+
+GDbus::GDbus(const char *gdbusDestination,
+ const char *gdbusObjectPath,
+ const char *gdbusInterface):m_pConnection(NULL), m_pCancellable(NULL)
+{
+ m_gdbusDestination = gdbusDestination;
+ m_gdbusObjectPath = gdbusObjectPath;
+ m_gdbusInterface = gdbusInterface;
+
+ Create();
+}
+
+GDbus::~GDbus(void)
+{
+ Destroy();
+}
+
+error_e GDbus::Create(void)
+{
+ GError *err = NULL;
+
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+ g_type_init();
+#endif
+
+ this->m_pConnection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
+ if (this->m_pConnection == NULL) {
+ if (err != NULL) {
+ GLOGD("Failed to connect to the D-BUS daemon [%s]",
+ err->message);
+ g_error_free(err);
+ }
+
+ return ERROR_OPERATION_FAILED;
+ }
+
+ this->m_pCancellable = g_cancellable_new();
+
+ return ERROR_NONE;
+}
+
+error_e GDbus::Destroy(void)
+{
+ g_cancellable_cancel(this->m_pCancellable);
+ g_object_unref(this->m_pCancellable);
+ this->m_pCancellable = NULL;
+
+ g_object_unref(this->m_pConnection);
+ this->m_pConnection = NULL;
+
+ return ERROR_NONE;
+}
+
+GDBusConnection *GDbus::GetConnection(void)
+{
+ return this->m_pConnection;
+}
+
+GCancellable *GDbus::GetCancellable(void)
+{
+ return this->m_pCancellable;
+}
+
+error_e GDbus::ConvertErrorStringToEnum(const char *error)
+{
+ if (NULL != strstr(error, "InvalidParameter"))
+ return ERROR_INVALID_PARAM;
+ else if (NULL != strstr(error, "NotPermitted"))
+ return ERROR_NOT_PERMITTED;
+ else if (NULL != strstr(error, "OutOfMemory"))
+ return ERROR_OUT_OF_MEMORY;
+ else if (NULL != strstr(error, "OperationFailed"))
+ return ERROR_OPERATION_FAILED;
+ else if (NULL != strstr(error, "InProgress"))
+ return ERROR_IN_PROGRESS;
+
+ return ERROR_OPERATION_FAILED;
+}
+
+GVariant *GDbus::InvokeMethod(const char *object_path,
+ const char *method,
+ GVariant *params,
+ error_e *dbus_error)
+{
+ GError *error = NULL;
+ GVariant *reply = NULL;
+ GDBusConnection *connection = NULL;
+ *dbus_error = ERROR_NONE;
+
+ connection = GetConnection();
+ if (connection == NULL) {
+ GLOGD("GDBusconnection is NULL");
+ *dbus_error = ERROR_NOT_INITIALIZED;
+ return reply;
+ }
+
+ reply = g_dbus_connection_call_sync(connection,
+ m_gdbusDestination,
+ object_path,
+ m_gdbusInterface,
+ method,
+ params,
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ DBUS_REPLY_TIMEOUT,
+ GetCancellable(),
+ &error);
+
+ if (reply == NULL) {
+ if (error != NULL) {
+ GLOGD("g_dbus_connection_call_sync() failed "
+ "error [%d: %s]", error->code, error->message);
+ *dbus_error = ConvertErrorStringToEnum(error->message);
+ g_error_free(error);
+ } else {
+ GLOGD("g_dbus_connection_call_sync() failed");
+ *dbus_error = ERROR_OPERATION_FAILED;
+ }
+
+ return NULL;
+ }
+
+ return reply;
+}
+
+GVariant *GDbus::InvokeMethod(const char *method,
+ GVariant *params,
+ error_e *dbus_error)
+{
+ return InvokeMethod(m_gdbusObjectPath, method, params, dbus_error);
+}
+
+error_e GDbus::InvokeMethodNonblock(const char *method,
+ GVariant *params,
+ int timeout,
+ GAsyncReadyCallback notify_func,
+ void *user_data)
+{
+ GDBusConnection *connection = NULL;
+
+ connection = GetConnection();
+ if (connection == NULL) {
+ GLOGD("GDBusconnection is NULL");
+ return ERROR_NOT_INITIALIZED;
+ }
+
+ g_dbus_connection_call(connection,
+ m_gdbusDestination,
+ m_gdbusObjectPath,
+ m_gdbusInterface,
+ method,
+ params,
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ timeout,
+ GetCancellable(),
+ (GAsyncReadyCallback) notify_func,
+ (gpointer)user_data);
+
+ return ERROR_NONE;
+}
+//LCOV_EXCL_START
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+#ifndef __GTEST_INM_MGR_GDBUS_H__
+#define __GTEST_INM_MGR_GDBUS_H__
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include "gtest-inm-mgr-error.h"
+
+#define DBUS_REPLY_TIMEOUT (2 * 1000)
+
+#define INM_MGR_DBUS_SERVICE "net.inm_manager"
+#define INM_MGR_DBUS_PATH "/net/inm_manager"
+#define INM_MGR_DBUS_INTERFACE "net.inm_manager"
+
+#define INM_MGR_PEER_DBUS_INTERFACE "org.freedesktop.DBus.Peer"
+#define INM_MGR_MTD_PING "Ping"
+
+class GDbus {
+private:
+ GDBusConnection *m_pConnection;
+ GCancellable *m_pCancellable;
+
+ const char *m_gdbusDestination;
+ const char *m_gdbusObjectPath;
+ const char *m_gdbusInterface;
+
+ GDbus(void);
+ error_e Create(void);
+ error_e Destroy(void);
+ GDBusConnection *GetConnection(void);
+ GCancellable *GetCancellable(void);
+ error_e ConvertErrorStringToEnum(const char *error);
+public:
+ GDbus(const char *gdbusDestination,
+ const char *gdbusObjectPath,
+ const char *gdbusInterface);
+ ~GDbus(void);
+ GVariant *InvokeMethod(const char *method,
+ GVariant *params,
+ error_e *dbus_error);
+ GVariant *InvokeMethod(const char *object_path,
+ const char *method,
+ GVariant *params,
+ error_e *dbus_error);
+ error_e InvokeMethodNonblock(const char *method,
+ GVariant *params,
+ int timeout,
+ GAsyncReadyCallback notify_func,
+ void *user_data);
+};
+
+#endif /* __GTEST_INM_MGR_GDBUS_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 "gtest-inm-mgr-mainloop.h"
+
+GMainLoop *MainLoop::m_mainLoop = NULL;
+guint MainLoop::m_timerId = 0;
+
+//LCOV_EXCL_START
+MainLoop::MainLoop(void)
+{
+}
+
+MainLoop::~MainLoop(void)
+{
+ if (m_mainLoop)
+ g_main_loop_quit(m_mainLoop);
+ if (m_timerId)
+ g_source_remove(m_timerId);
+
+ m_mainLoop = NULL;
+ m_timerId = 0;
+}
+
+gboolean MainLoop::timeoutCb(gpointer data)
+{
+ if (m_mainLoop)
+ g_main_loop_quit(m_mainLoop);
+ if (m_timerId)
+ g_source_remove(m_timerId);
+
+ m_mainLoop = NULL;
+ m_timerId = 0;
+
+ return false;
+}
+
+void MainLoop::run(unsigned int timeout)
+{
+ if (m_timerId > 0)
+ return;
+
+ m_mainLoop = g_main_loop_new(NULL, false);
+ m_timerId = g_timeout_add_seconds(timeout,
+ (GSourceFunc) MainLoop::timeoutCb,
+ NULL);
+ g_main_loop_run(m_mainLoop);
+}
+
+void MainLoop::quit(void)
+{
+ timeoutCb(NULL);
+}
+
+//LCOV_EXCL_STOP
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+#ifndef __GTEST_INM_MGR_LOOP_H__
+#define __GTEST_INM_MGR_LOOP_H__
+
+#include <glib.h>
+
+class MainLoop {
+private:
+ static GMainLoop *m_mainLoop;
+ static guint m_timerId;
+
+ static gboolean timeoutCb(gpointer data);
+public:
+ MainLoop(void);
+ ~MainLoop(void);
+ void run(unsigned int timeout);
+ void quit(void);
+};
+
+#endif /* __GTEST_INM_MGR_LOOP_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 "gtest-inm-mgr-manager.h"
+
+#define INM_MGR_MTD_GET_STATISTICS "GetStatistics"
+#define INM_MGR_MTD_RESET_STATISTICS "ResetStatistics"
+#define INM_MGR_MTD_GET_CURRENT_CONNECTION "GetCurrentConnection"
+#define INM_MGR_MTD_GET_CONNECTIONS "GetConnections"
+#define INM_MGR_MTD_GET_ETHERNET_CABLE_STATE "GetEthernetCableState"
+#define INM_MGR_MTD_GET_WIFI_MODULE_STATE "GetWifiModuleState"
+#define INM_MGR_MTD_GET_IP_CONFLICT_STATE "GetIpConflictState"
+#define INM_MGR_MTD_GET_IP_CONFLICT_DETECT "GetIpConflictDetect"
+#define INM_MGR_MTD_SET_IP_CONFLICT_DETECT "SetIpConflictDetect"
+#define INM_MGR_MTD_GET_TCPDUMP_STATE "GetTcpdumpState"
+#define INM_MGR_MTD_SET_TCPDUMP_STATE "SetTcpdumpState"
+#define INM_MGR_MTD_GET_CELLULAR_STATE "GetCellularState"
+#define INM_MGR_MTD_GET_WIFI_STATE "GetWifiState"
+#define INM_MGR_MTD_GET_ETHERNET_STATE "GetEthernetState"
+#define INM_MGR_MTD_GET_CONGESTION_LEVEL "GetCongestionLevel"
+#define INM_MGR_MTD_GET_RETRY_TX_RATE "GetRetryTxRate"
+#define INM_MGR_MTD_GET_CHANNEL_INTERFERENCE "GetChannelInterference"
+#define INM_MGR_MTD_START_ARPING "StartArping"
+#define INM_MGR_MTD_STOP_ARPING "StopArping"
+#define INM_MGR_MTD_START_CHECK_GATEWAY "StartCheckGateway"
+#define INM_MGR_MTD_STOP_CHECK_GATEWAY "StopCheckGateway"
+#define INM_MGR_MTD_ADD_REACHER_URL "AddReacherUrl"
+#define INM_MGR_MTD_REMOVE_REACHER_URL "RemoveReacherUrl"
+#define INM_MGR_MTD_START_REACHER "StartReacher"
+#define INM_MGR_MTD_STOP_REACHER "StopReacher"
+#define INM_MGR_MTD_REACHER_IS_RUNNING "ReacherIsRunning"
+
+//LCOV_EXCL_START
+Manager::Manager(void) : GDbus(INM_MGR_DBUS_SERVICE,
+ INM_MGR_DBUS_PATH,
+ INM_MGR_DBUS_INTERFACE)
+{
+}
+
+Manager::~Manager(void)
+{
+}
+
+error_e Manager::getStatistics_p(void)
+{
+ error_e ret;
+ GVariant *reply;
+ GVariant *params;
+
+ int connection_type = 1;
+ int statistics_type = 1;
+
+ params = g_variant_new("(ii)", connection_type, statistics_type);
+
+ reply = GDbus::InvokeMethod(INM_MGR_MTD_GET_STATISTICS,
+ params, &ret);
+ if (ret != ERROR_NONE)
+ return ret;
+
+ if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("(t)"))) {
+ g_variant_unref(reply);
+ return ERROR_OPERATION_FAILED;
+ }
+
+ g_variant_unref(reply);
+ return ERROR_NONE;
+}
+
+error_e Manager::resetStatistics_p(void)
+{
+ error_e ret;
+ GVariant *reply;
+ GVariant *params;
+
+ int connection_type = 1;
+ int statistics_type = 1;
+
+ params = g_variant_new("(ii)", connection_type, statistics_type);
+
+ reply = GDbus::InvokeMethod(INM_MGR_MTD_RESET_STATISTICS,
+ params, &ret);
+ if (ret != ERROR_NONE)
+ return ret;
+
+ if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("()"))) {
+ g_variant_unref(reply);
+ return ERROR_OPERATION_FAILED;
+ }
+
+ g_variant_unref(reply);
+ return ERROR_NONE;
+}
+
+error_e Manager::getCurrentConnection_p(void)
+{
+ error_e ret;
+ GVariant *reply;
+
+ reply = GDbus::InvokeMethod(INM_MGR_MTD_GET_CURRENT_CONNECTION,
+ NULL, &ret);
+ if (ret != ERROR_NONE)
+ return ret;
+
+ if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("(oa{sv})"))) {
+ g_variant_unref(reply);
+ return ERROR_OPERATION_FAILED;
+ }
+
+ g_variant_unref(reply);
+ return ERROR_NONE;
+}
+
+error_e Manager::getCurrentConnectionObjectPath(char **objectPath)
+{
+ error_e ret;
+ GVariant *reply;
+ GVariantIter *dict;
+
+ if (objectPath == NULL)
+ return ERROR_OPERATION_FAILED;
+
+ reply = GDbus::InvokeMethod(INM_MGR_MTD_GET_CURRENT_CONNECTION,
+ NULL, &ret);
+ if (ret != ERROR_NONE)
+ return ret;
+
+ if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("(oa{sv})"))) {
+ g_variant_unref(reply);
+ return ERROR_OPERATION_FAILED;
+ }
+
+ g_variant_get(reply, "(oa{sv})", objectPath, &dict);
+ g_variant_iter_free(dict);
+ g_variant_unref(reply);
+ return ERROR_NONE;
+}
+
+error_e Manager::getConnections_p(void)
+{
+ error_e ret;
+ GVariant *reply;
+
+ reply = GDbus::InvokeMethod(INM_MGR_MTD_GET_CONNECTIONS,
+ NULL, &ret);
+ if (ret != ERROR_NONE)
+ return ret;
+
+ if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("(a(oa{sv}))"))) {
+ g_variant_unref(reply);
+ return ERROR_OPERATION_FAILED;
+ }
+
+ g_variant_unref(reply);
+ return ERROR_NONE;
+}
+
+error_e Manager::getEthernetCableState_p(void)
+{
+ error_e ret;
+ GVariant *reply;
+
+ reply = GDbus::InvokeMethod(INM_MGR_MTD_GET_ETHERNET_CABLE_STATE,
+ NULL, &ret);
+ if (ret != ERROR_NONE)
+ return ret;
+
+ if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("(b)"))) {
+ g_variant_unref(reply);
+ return ERROR_OPERATION_FAILED;
+ }
+
+ g_variant_unref(reply);
+ return ERROR_NONE;
+}
+
+error_e Manager::getWifiModuleState_p(void)
+{
+ error_e ret;
+ GVariant *reply;
+
+ reply = GDbus::InvokeMethod(INM_MGR_MTD_GET_WIFI_MODULE_STATE,
+ NULL, &ret);
+ if (ret != ERROR_NONE)
+ return ret;
+
+ if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("(b)"))) {
+ g_variant_unref(reply);
+ return ERROR_OPERATION_FAILED;
+ }
+
+ g_variant_unref(reply);
+ return ERROR_NONE;
+}
+
+error_e Manager::getIpConflictState_p(void)
+{
+ error_e ret;
+ GVariant *reply;
+
+ reply = GDbus::InvokeMethod(INM_MGR_MTD_GET_IP_CONFLICT_STATE,
+ NULL, &ret);
+ if (ret != ERROR_NONE)
+ return ret;
+
+ if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("(b)"))) {
+ g_variant_unref(reply);
+ return ERROR_OPERATION_FAILED;
+ }
+
+ g_variant_unref(reply);
+ return ERROR_NONE;
+}
+
+error_e Manager::getIpConflictDetect_p(void)
+{
+ error_e ret;
+ GVariant *reply;
+
+ reply = GDbus::InvokeMethod(INM_MGR_MTD_GET_IP_CONFLICT_DETECT,
+ NULL, &ret);
+ if (ret != ERROR_NONE)
+ return ret;
+
+ if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("(b)"))) {
+ g_variant_unref(reply);
+ return ERROR_OPERATION_FAILED;
+ }
+
+ g_variant_unref(reply);
+ return ERROR_NONE;
+}
+
+error_e Manager::setIpConflictDetect_p(void)
+{
+ error_e ret;
+ GVariant *reply;
+ GVariant *params;
+ gboolean ip_conflict_detect = TRUE;
+
+ params = g_variant_new("(b)", ip_conflict_detect);
+
+ reply = GDbus::InvokeMethod(INM_MGR_MTD_SET_IP_CONFLICT_DETECT,
+ params, &ret);
+ if (ret != ERROR_NONE)
+ return ret;
+
+ if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("()"))) {
+ g_variant_unref(reply);
+ return ERROR_OPERATION_FAILED;
+ }
+
+ g_variant_unref(reply);
+ return ERROR_NONE;
+}
+
+error_e Manager::getTcpdumpState_p(void)
+{
+ error_e ret;
+ GVariant *reply;
+
+ reply = GDbus::InvokeMethod(INM_MGR_MTD_GET_TCPDUMP_STATE,
+ NULL, &ret);
+ if (ret != ERROR_NONE)
+ return ret;
+
+ if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("(b)"))) {
+ g_variant_unref(reply);
+ return ERROR_OPERATION_FAILED;
+ }
+
+ g_variant_unref(reply);
+ return ERROR_NONE;
+}
+
+error_e Manager::setTcpdumpState_p(void)
+{
+ error_e ret;
+ GVariant *reply;
+ GVariant *params;
+ gboolean tcp_dump_state = FALSE;
+
+ params = g_variant_new("(b)", tcp_dump_state);
+
+ reply = GDbus::InvokeMethod(INM_MGR_MTD_SET_TCPDUMP_STATE,
+ params, &ret);
+ if (ret != ERROR_NONE)
+ return ret;
+
+ if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("()"))) {
+ g_variant_unref(reply);
+ return ERROR_OPERATION_FAILED;
+ }
+
+ g_variant_unref(reply);
+ return ERROR_NONE;
+}
+
+error_e Manager::getCellularState_p(void)
+{
+ error_e ret;
+ GVariant *reply;
+
+ reply = GDbus::InvokeMethod(INM_MGR_MTD_GET_CELLULAR_STATE,
+ NULL, &ret);
+ if (ret != ERROR_NONE)
+ return ret;
+
+ if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("(i)"))) {
+ g_variant_unref(reply);
+ return ERROR_OPERATION_FAILED;
+ }
+
+ g_variant_unref(reply);
+ return ERROR_NONE;
+}
+
+error_e Manager::getWifiState_p(void)
+{
+ error_e ret;
+ GVariant *reply;
+
+ reply = GDbus::InvokeMethod(INM_MGR_MTD_GET_WIFI_STATE,
+ NULL, &ret);
+ if (ret != ERROR_NONE)
+ return ret;
+
+ if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("(i)"))) {
+ g_variant_unref(reply);
+ return ERROR_OPERATION_FAILED;
+ }
+
+ g_variant_unref(reply);
+ return ERROR_NONE;
+}
+
+error_e Manager::getEthernetState_p(void)
+{
+ error_e ret;
+ GVariant *reply;
+
+ reply = GDbus::InvokeMethod(INM_MGR_MTD_GET_ETHERNET_STATE,
+ NULL, &ret);
+ if (ret != ERROR_NONE)
+ return ret;
+
+ if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("(i)"))) {
+ g_variant_unref(reply);
+ return ERROR_OPERATION_FAILED;
+ }
+
+ g_variant_unref(reply);
+ return ERROR_NONE;
+}
+
+error_e Manager::getCongestionLevel_p(void)
+{
+ error_e ret;
+ GVariant *reply;
+
+ reply = GDbus::InvokeMethod(INM_MGR_MTD_GET_CONGESTION_LEVEL,
+ NULL, &ret);
+ if (ret != ERROR_NONE)
+ return ret;
+
+ if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("(i)"))) {
+ g_variant_unref(reply);
+ return ERROR_OPERATION_FAILED;
+ }
+
+ g_variant_unref(reply);
+ return ERROR_NONE;
+}
+
+error_e Manager::getRetryTxRate_p(void)
+{
+ error_e ret;
+ GVariant *reply;
+
+ reply = GDbus::InvokeMethod(INM_MGR_MTD_GET_RETRY_TX_RATE,
+ NULL, &ret);
+ if (ret != ERROR_NONE)
+ return ret;
+
+ if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("(i)"))) {
+ g_variant_unref(reply);
+ return ERROR_OPERATION_FAILED;
+ }
+
+ g_variant_unref(reply);
+ return ERROR_NONE;
+}
+
+error_e Manager::getChannelInterference_p(void)
+{
+ error_e ret;
+ GVariant *reply;
+
+ reply = GDbus::InvokeMethod(INM_MGR_MTD_GET_CHANNEL_INTERFERENCE,
+ NULL, &ret);
+ if (ret != ERROR_NONE)
+ return ret;
+
+ if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("(d)"))) {
+ g_variant_unref(reply);
+ return ERROR_OPERATION_FAILED;
+ }
+
+ g_variant_unref(reply);
+ return ERROR_NONE;
+}
+
+error_e Manager::startArping_p(void)
+{
+ error_e ret;
+ GVariant *reply;
+ GVariant *params;
+ const char *target_ip = "127.0.0.1";
+ int timeout = 2;
+
+ params = g_variant_new("(si)", target_ip, timeout);
+
+ reply = GDbus::InvokeMethod(INM_MGR_MTD_START_ARPING,
+ params, &ret);
+ if (ret != ERROR_NONE && ret != ERROR_IN_PROGRESS)
+ return ret;
+
+ if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("()"))) {
+ g_variant_unref(reply);
+ return ERROR_OPERATION_FAILED;
+ }
+
+ g_variant_unref(reply);
+ return ERROR_NONE;
+}
+
+error_e Manager::stopArping_p(void)
+{
+ error_e ret;
+ GVariant *reply;
+ GVariant *params;
+ const char *target_ip = "127.0.0.1";
+
+ params = g_variant_new("(s)", target_ip);
+
+ reply = GDbus::InvokeMethod(INM_MGR_MTD_STOP_ARPING,
+ params, &ret);
+ if (ret != ERROR_NONE)
+ return ret;
+
+ if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("()"))) {
+ g_variant_unref(reply);
+ return ERROR_OPERATION_FAILED;
+ }
+
+ g_variant_unref(reply);
+ return ERROR_NONE;
+}
+
+error_e Manager::startCheckGateway_p(void)
+{
+ error_e ret;
+ GVariant *reply;
+
+ reply = GDbus::InvokeMethod(INM_MGR_MTD_START_CHECK_GATEWAY,
+ NULL, &ret);
+ if (ret != ERROR_NONE && ret != ERROR_IN_PROGRESS)
+ return ret;
+
+ if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("()"))) {
+ g_variant_unref(reply);
+ return ERROR_OPERATION_FAILED;
+ }
+
+ g_variant_unref(reply);
+ return ERROR_NONE;
+}
+
+error_e Manager::stopCheckGateway_p(void)
+{
+ error_e ret;
+ GVariant *reply;
+
+ reply = GDbus::InvokeMethod(INM_MGR_MTD_STOP_CHECK_GATEWAY,
+ NULL, &ret);
+ if (ret != ERROR_NONE)
+ return ret;
+
+ if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("()"))) {
+ g_variant_unref(reply);
+ return ERROR_OPERATION_FAILED;
+ }
+
+ g_variant_unref(reply);
+ return ERROR_NONE;
+}
+
+error_e Manager::addReacherUrl_p(void)
+{
+ error_e ret;
+ GVariant *reply;
+ GVariant *params;
+ const char *url = "http://www.tizen.org";
+
+ params = g_variant_new("(s)", url);
+
+ reply = GDbus::InvokeMethod(INM_MGR_MTD_ADD_REACHER_URL,
+ params, &ret);
+ if (ret != ERROR_NONE)
+ return ret;
+
+ if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("()"))) {
+ g_variant_unref(reply);
+ return ERROR_OPERATION_FAILED;
+ }
+
+ g_variant_unref(reply);
+ return ERROR_NONE;
+}
+
+error_e Manager::removeReacherUrl_p(void)
+{
+ error_e ret;
+ GVariant *reply;
+ GVariant *params;
+ const char *url = "http://www.tizen.org";
+
+ params = g_variant_new("(s)", url);
+
+ reply = GDbus::InvokeMethod(INM_MGR_MTD_REMOVE_REACHER_URL,
+ params, &ret);
+ if (ret != ERROR_NONE)
+ return ret;
+
+ if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("()"))) {
+ g_variant_unref(reply);
+ return ERROR_OPERATION_FAILED;
+ }
+
+ g_variant_unref(reply);
+ return ERROR_NONE;
+}
+
+error_e Manager::startReacher_p(void)
+{
+ error_e ret;
+ GVariant *reply;
+ GVariant *params;
+ int type = 0;
+
+ params = g_variant_new("(i)", type);
+
+ reply = GDbus::InvokeMethod(INM_MGR_MTD_START_REACHER,
+ params, &ret);
+ if (ret != ERROR_NONE)
+ return ret;
+
+ if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("()"))) {
+ g_variant_unref(reply);
+ return ERROR_OPERATION_FAILED;
+ }
+
+ g_variant_unref(reply);
+ return ERROR_NONE;
+}
+
+error_e Manager::stopReacher_p(void)
+{
+ error_e ret;
+ GVariant *reply;
+ GVariant *params;
+ int type = 0;
+
+ params = g_variant_new("(i)", type);
+
+ reply = GDbus::InvokeMethod(INM_MGR_MTD_STOP_REACHER,
+ params, &ret);
+ if (ret != ERROR_NONE)
+ return ret;
+
+ if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("()"))) {
+ g_variant_unref(reply);
+ return ERROR_OPERATION_FAILED;
+ }
+
+ g_variant_unref(reply);
+ return ERROR_NONE;
+}
+
+error_e Manager::reacherIsRunning_p(void)
+{
+ error_e ret;
+ GVariant *reply;
+
+ reply = GDbus::InvokeMethod(INM_MGR_MTD_REACHER_IS_RUNNING,
+ NULL, &ret);
+ if (ret != ERROR_NONE)
+ return ret;
+
+ if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("(b)"))) {
+ g_variant_unref(reply);
+ return ERROR_OPERATION_FAILED;
+ }
+
+ g_variant_unref(reply);
+ return ERROR_NONE;
+}
+//LCOV_EXCL_STOP
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+#ifndef __GTEST_INM_MGR_MANAGER_H__
+#define __GTEST_INM_MGR_MANAGER_H__
+
+#include "gtest-inm-mgr-gdbus.h"
+#include "gtest-inm-mgr-error.h"
+
+class Manager : public GDbus {
+private:
+public:
+ Manager(void);
+ ~Manager(void);
+ error_e getStatistics_p(void);
+ error_e resetStatistics_p(void);
+ error_e getCurrentConnection_p(void);
+ error_e getCurrentConnectionObjectPath(char **objectPath);
+ error_e getConnections_p(void);
+ error_e getEthernetCableState_p(void);
+ error_e getWifiModuleState_p(void);
+ error_e getIpConflictState_p(void);
+ error_e getIpConflictDetect_p(void);
+ error_e setIpConflictDetect_p(void);
+ error_e getTcpdumpState_p(void);
+ error_e setTcpdumpState_p(void);
+ error_e getCellularState_p(void);
+ error_e getWifiState_p(void);
+ error_e getEthernetState_p(void);
+ error_e getCongestionLevel_p(void);
+ error_e getRetryTxRate_p(void);
+ error_e getChannelInterference_p(void);
+ error_e startArping_p(void);
+ error_e stopArping_p(void);
+ error_e startCheckGateway_p(void);
+ error_e stopCheckGateway_p(void);
+ error_e addReacherUrl_p(void);
+ error_e removeReacherUrl_p(void);
+ error_e startReacher_p(void);
+ error_e stopReacher_p(void);
+ error_e reacherIsRunning_p(void);
+};
+
+#endif /* __GTEST_INM_MGR_MANAGER_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+#include <unistd.h>
+
+#include "gtest-inm-mgr-error.h"
+#include "gtest-inm-mgr-wifi.h"
+#include "gtest-inm-mgr-connection.h"
+#include "gtest-inm-mgr-manager.h"
+#include "gtest-inm-mgr-unittest.h"
+#include "gtest-inm-mgr-mainloop.h"
+
+using ::testing::EmptyTestEventListener;
+using ::testing::InitGoogleTest;
+using ::testing::Test;
+using ::testing::TestCase;
+using ::testing::TestEventListeners;
+using ::testing::TestInfo;
+using ::testing::TestPartResult;
+using ::testing::UnitTest;
+
+#ifdef TIZEN_TEST_GCOV
+extern "C" void __gcov_flush(void);
+#endif
+
+//LCOV_EXCL_START
+TEST(InmMgrWifi, getConnectedAp_p)
+{
+ error_e ret = ERROR_NONE;
+ Wifi wifi;
+
+ ret = wifi.getConnectedAp_p();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(InmMgrWifi, getFoundAps_p)
+{
+ error_e ret = ERROR_NONE;
+ Wifi wifi;
+
+ ret = wifi.getFoundAps_p();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(InmMgrWifi, getScanState_p)
+{
+ error_e ret = ERROR_NONE;
+ Wifi wifi;
+
+ ret = wifi.getScanState_p();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(InmMgrConnection, getAll_p)
+{
+ error_e ret = ERROR_NONE;
+ Connection connection;
+ Manager manager;
+ MainLoop loop;
+ char *object_path = NULL;
+
+ ret = manager.getCurrentConnectionObjectPath(&object_path);
+ EXPECT_EQ(ERROR_NONE, ret);
+
+ loop.run(1);
+
+ ret = connection.getAll_p(object_path);
+ EXPECT_EQ(ERROR_NONE, ret);
+
+ loop.run(1);
+
+ g_free(object_path);
+}
+
+TEST(InmMgrManager, getStatistics_p)
+{
+ error_e ret = ERROR_NONE;
+ Manager manager;
+
+ ret = manager.getStatistics_p();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(InmMgrManager, resetStatistics_p)
+{
+ error_e ret = ERROR_NONE;
+ Manager manager;
+
+ ret = manager.resetStatistics_p();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(InmMgrManager, getCurrentConnection_p)
+{
+ error_e ret = ERROR_NONE;
+ Manager manager;
+
+ ret = manager.getCurrentConnection_p();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(InmMgrManager, getConnections_p)
+{
+ error_e ret = ERROR_NONE;
+ Manager manager;
+
+ ret = manager.getConnections_p();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(InmMgrManager, getEthernetCableState_p)
+{
+ error_e ret = ERROR_NONE;
+ Manager manager;
+
+ ret = manager.getEthernetCableState_p();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(InmMgrManager, getWifiModuleState_p)
+{
+ error_e ret = ERROR_NONE;
+ Manager manager;
+
+ ret = manager.getWifiModuleState_p();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(InmMgrManager, getIpConflictState_p)
+{
+ error_e ret = ERROR_NONE;
+ Manager manager;
+
+ ret = manager.getIpConflictState_p();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(InmMgrManager, getIpConflictDetect_p)
+{
+ error_e ret = ERROR_NONE;
+ Manager manager;
+
+ ret = manager.getIpConflictDetect_p();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(InmMgrManager, setIpConflictDetect_p)
+{
+ error_e ret = ERROR_NONE;
+ Manager manager;
+
+ ret = manager.setIpConflictDetect_p();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(InmMgrManager, getTcpdumpState_p)
+{
+ error_e ret = ERROR_NONE;
+ Manager manager;
+
+ ret = manager.getTcpdumpState_p();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(InmMgrManager, setTcpdumpState_p)
+{
+ error_e ret = ERROR_NONE;
+ Manager manager;
+
+ ret = manager.setTcpdumpState_p();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(InmMgrManager, getCellularState_p)
+{
+ error_e ret = ERROR_NONE;
+ Manager manager;
+
+ ret = manager.getCellularState_p();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(InmMgrManager, getWifiState_p)
+{
+ error_e ret = ERROR_NONE;
+ Manager manager;
+
+ ret = manager.getWifiState_p();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(InmMgrManager, getEthernetState_p)
+{
+ error_e ret = ERROR_NONE;
+ Manager manager;
+
+ ret = manager.getEthernetState_p();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(InmMgrManager, getCongestionLevel_p)
+{
+ error_e ret = ERROR_NONE;
+ Manager manager;
+
+ ret = manager.getCongestionLevel_p();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(InmMgrManager, getRetryTxRate_p)
+{
+ error_e ret = ERROR_NONE;
+ Manager manager;
+
+ ret = manager.getRetryTxRate_p();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(InmMgrManager, getChannelInterference_p)
+{
+ error_e ret = ERROR_NONE;
+ Manager manager;
+
+ ret = manager.getChannelInterference_p();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(InmMgrManager, startArping_p)
+{
+ error_e ret = ERROR_NONE;
+ Manager manager;
+ MainLoop loop;
+
+ ret = manager.startArping_p();
+ EXPECT_EQ(ERROR_NONE, ret);
+ loop.run(1);
+}
+
+TEST(InmMgrManager, stopArping_p)
+{
+ error_e ret = ERROR_NONE;
+ Manager manager;
+ MainLoop loop;
+
+ ret = manager.stopArping_p();
+ EXPECT_EQ(ERROR_NONE, ret);
+ loop.run(1);
+}
+
+TEST(InmMgrManager, startCheckGateway_p)
+{
+ error_e ret = ERROR_NONE;
+ Manager manager;
+ MainLoop loop;
+
+ ret = manager.startCheckGateway_p();
+ EXPECT_EQ(ERROR_NONE, ret);
+ loop.run(1);
+}
+
+TEST(InmMgrManager, stopCheckGateway_p)
+{
+ error_e ret = ERROR_NONE;
+ Manager manager;
+ MainLoop loop;
+
+ ret = manager.stopCheckGateway_p();
+ EXPECT_EQ(ERROR_NONE, ret);
+ loop.run(1);
+}
+
+TEST(InmMgrManager, addReacherUrl_p)
+{
+ error_e ret = ERROR_NONE;
+ Manager manager;
+ MainLoop loop;
+
+ ret = manager.addReacherUrl_p();
+ EXPECT_EQ(ERROR_NONE, ret);
+ loop.run(1);
+}
+
+TEST(InmMgrManager, removeReacherUrl_p)
+{
+ error_e ret = ERROR_NONE;
+ Manager manager;
+ MainLoop loop;
+
+ ret = manager.removeReacherUrl_p();
+ EXPECT_EQ(ERROR_NONE, ret);
+ loop.run(1);
+}
+
+TEST(InmMgrManager, startReacher_p)
+{
+ error_e ret = ERROR_NONE;
+ Manager manager;
+ MainLoop loop;
+
+ ret = manager.startReacher_p();
+ EXPECT_EQ(ERROR_NONE, ret);
+ loop.run(1);
+}
+
+TEST(InmMgrManager, stopReacher_p)
+{
+ error_e ret = ERROR_NONE;
+ Manager manager;
+ MainLoop loop;
+
+ ret = manager.stopReacher_p();
+ EXPECT_EQ(ERROR_NONE, ret);
+ loop.run(1);
+}
+
+TEST(InmMgrManager, reacherIsRunning_p)
+{
+ error_e ret = ERROR_NONE;
+ Manager manager;
+
+ ret = manager.reacherIsRunning_p();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+int main(int argc, char **argv)
+{
+ int ret = 0;
+
+#ifdef TIZEN_TEST_GCOV
+ setenv("GCOV_PREFIX", "/tmp", 1);
+#endif
+
+ InitGoogleTest(&argc, argv);
+ ret = RUN_ALL_TESTS();
+
+#ifdef TIZEN_TEST_GCOV
+ __gcov_flush();
+#endif
+
+ return ret;
+}
+//LCOV_EXCL_STOP
--- /dev/null
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+#ifndef __GTEST_INM_MGR_UNITTEST_H__
+#define __GTEST_INM_MGR_UNITTEST_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <glib.h>
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__GTEST_INM_MGR_UNITTEST_H__
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 "gtest-inm-mgr-wifi.h"
+
+#define INM_MGR_WIFI_DBUS_INTERFACE INM_MGR_DBUS_SERVICE ".wifi"
+#define INM_MGR_WIFI_DBUS_PATH INM_MGR_DBUS_PATH "/wifi"
+#define INM_MGR_MTD_GET_CONNECTED_AP "GetConnectedAp"
+#define INM_MGR_MTD_GET_FOUND_APS "GetFoundAps"
+#define INM_MGR_MTD_GET_SCAN_STATE "GetScanState"
+
+//LCOV_EXCL_START
+Wifi::Wifi(void) : GDbus(INM_MGR_DBUS_SERVICE,
+ INM_MGR_WIFI_DBUS_PATH,
+ INM_MGR_WIFI_DBUS_INTERFACE)
+{
+}
+
+Wifi::~Wifi(void)
+{
+}
+
+error_e Wifi::getConnectedAp_p(void)
+{
+ error_e ret;
+ GVariant *reply;
+
+ reply = GDbus::InvokeMethod(INM_MGR_MTD_GET_CONNECTED_AP,
+ NULL, &ret);
+ if (ret != ERROR_NONE)
+ return ret;
+
+ if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("(a{sv})"))) {
+ g_variant_unref(reply);
+ return ERROR_OPERATION_FAILED;
+ }
+
+ g_variant_unref(reply);
+ return ERROR_NONE;
+}
+
+error_e Wifi::getFoundAps_p(void)
+{
+ error_e ret;
+ GVariant *reply;
+
+ reply = GDbus::InvokeMethod(INM_MGR_MTD_GET_FOUND_APS,
+ NULL, &ret);
+ if (ret != ERROR_NONE)
+ return ret;
+
+ if (!g_variant_is_of_type(reply,
+ G_VARIANT_TYPE("(a(oa{sv}))"))) {
+ g_variant_unref(reply);
+ return ERROR_OPERATION_FAILED;
+ }
+
+ g_variant_unref(reply);
+ return ERROR_NONE;
+}
+
+error_e Wifi::getScanState_p(void)
+{
+ error_e ret;
+ GVariant *reply;
+
+ reply = GDbus::InvokeMethod(INM_MGR_MTD_GET_SCAN_STATE,
+ NULL, &ret);
+ if (ret != ERROR_NONE)
+ return ret;
+
+ if (!g_variant_is_of_type(reply,
+ G_VARIANT_TYPE("(b)"))) {
+ g_variant_unref(reply);
+ return ERROR_OPERATION_FAILED;
+ }
+
+ g_variant_unref(reply);
+ return ERROR_NONE;
+}
+//LCOV_EXCL_STOP
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+#ifndef __GTEST_INM_MGR_WIFI_H__
+#define __GTEST_INM_MGR_WIFI_H__
+
+#include "gtest-inm-mgr-gdbus.h"
+#include "gtest-inm-mgr-error.h"
+
+class Wifi : public GDbus {
+private:
+public:
+ Wifi(void);
+ ~Wifi(void);
+ error_e getConnectedAp_p(void);
+ error_e getFoundAps_p(void);
+ error_e getScanState_p(void);
+};
+
+#endif /* __GTEST_INM_MGR_WIFI_H__ */
extern "C" {
#endif
+#ifdef TIZEN_TEST_GCOV
+ void __gcov_flush(void);
+#define GCOV_FLUSH() \
+ do { \
+ __gcov_flush();\
+ } while (0)
+#else
+#define GCOV_FLUSH()
+#endif
+
#ifdef USE_DLOG
#include <dlog.h>
#define INM_LOGF(format, args...) LOGF(format, ##args)
#define __INM_FUNC_ENTER__ LOGD("Enter")
-#define __INM_FUNC_EXIT__ LOGD("Quit")
+#define __INM_FUNC_EXIT__ LOGD("Quit");GCOV_FLUSH();
#define INM_SECLOGI(format, args...) SECURE_LOG(LOG_INFO, LOG_TAG, format, ##args)
#define INM_SECLOGD(format, args...) SECURE_LOG(LOG_DEBUG, LOG_TAG, format, ##args)
Name: inm-manager
Summary: INM(Intelligent Network Monitoring) daemon
-Version: 0.0.7
+Version: 0.0.8
Release: 1
Group: Network & Connectivity/Other
License: Apache-2.0
BuildRequires: python
BuildRequires: python-xml
Requires: security-config
+
%if 0%{?gtests:1}
BuildRequires: pkgconfig(gmock)
%endif
+%if 0%{?gcov:1}
+BuildRequires: lcov
+%endif
+
%description
An application service platform manager to manage services and sessions
export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
+
%if 0%{?gcov:1}
-export CFLAGS+=" -fprofile-arcs -ftest-coverage"
-export CXXFLAGS+=" -fprofile-arcs -ftest-coverage"
-export FFLAGS+=" -fprofile-arcs -ftest-coverage"
-export LDFLAGS+=" -lgcov"
+export CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
+export CXXFLAGS="$CXXFLAGS -fprofile-arcs -ftest-coverage"
+export LDFLAGS="$LDFLAGS -lgcov"
%endif
%cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \
libcurl
)
+SET(REQUIRED_LIBS "-ldl")
+
+IF(BUILD_GCOV)
+ ADD_DEFINITIONS("-DTIZEN_TEST_GCOV")
+ SET(REQUIRED_LIBS "${REQUIRED_LIBS} -lgcov")
+ENDIF(BUILD_GCOV)
+
FOREACH(flag ${inm_pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fpic -Wall -Werror-implicit-function-declaration -fvisibility=hidden")
SET(ARM_CFLAGS "${ARM_CFLAGS} -mapcs -mabi=aapcs-linux -msoft-float -Uarm -fpic")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${inm_pkgs_LDFLAGS} -ldl)
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${inm_pkgs_LDFLAGS} ${REQUIRED_LIBS})
INSTALL(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${BIN_DIR})
GDBusMethodInvocation *invocation)
{
/* TODO */
+ __INM_FUNC_ENTER__;
+ g_dbus_method_invocation_return_value(invocation, NULL);
+ __INM_FUNC_EXIT__;
return;
}
GDBusMethodInvocation *invocation)
{
/* TODO get & return real Wi-Fi connected AP */
+ GVariant *arg = NULL;
+ GVariantBuilder *builder = NULL;
+
+ __INM_FUNC_ENTER__;
+ builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+ arg = g_variant_new("(a{sv})", builder);
+ g_variant_builder_unref(builder);
+
+ DEBUG_G_VARIANT("Sending = ", arg);
+ g_dbus_method_invocation_return_value(invocation, arg);
+ __INM_FUNC_EXIT__;
}
static inline void __handle_get_found_aps(GVariant *parameters,
GDBusMethodInvocation *invocation)
{
/* TODO get real Wi-Fi Found AP */
+ GVariant *arg = NULL;
+ GVariantBuilder *builder = NULL;
+
+ __INM_FUNC_ENTER__;
+ builder = g_variant_builder_new(G_VARIANT_TYPE("a(oa{sv})"));
+ arg = g_variant_new("(a(oa{sv}))", builder);
+ g_variant_builder_unref(builder);
+
+ DEBUG_G_VARIANT("Sending = ", arg);
+ g_dbus_method_invocation_return_value(invocation, arg);
+ __INM_FUNC_EXIT__;
}
static inline void __handle_get_scan_state(GVariant *parameters,
#include "inm-manager.h"
#include "inm-manager-log.h"
+#ifdef TIZEN_TEST_GCOV
+void __gcov_flush(void);
+#endif
+
static GMainLoop *g_loop = NULL;
static void __signal_handler(int sig)
int ret = 0;
__INM_FUNC_ENTER__;
+
+#ifdef TIZEN_TEST_GCOV
+ setenv("GCOV_PREFIX", "/tmp", 1);
+#endif
+
/*
ret = daemon(0, 0);
if (ret != 0) {
g_main_loop_unref(g_loop);
+#ifdef TIZEN_TEST_GCOV
+ __gcov_flush();
+#endif
+
__INM_FUNC_EXIT__;
return 0;
}
+++ /dev/null
-# Copyright (c) 2014-2015 Samsung Electronics Co., Ltd All Rights Reserved
-#
-# 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.
-#
-# @file CMakeLists.txt
-#
-
-LINK_DIRECTORIES(${CMAKE_BINARY_DIR})
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
-
-SET(GTEST_TEST "gtest-inm-manager")
-
-IF(BUILD_GTESTS)
- ADD_DEFINITIONS(-DBUILD_GTESTS)
-ENDIF(BUILD_GTESTS)
-
-FILE(GLOB GTEST_TEST_SRCS *.cpp ${CMAKE_SOURCE_DIR}/src/*.c)
-LIST(REMOVE_ITEM GTEST_TEST_SRCS ${CMAKE_SOURCE_DIR}/src/inm-manager-main.c)
-
-SET(GTEST_TEST_SRCS ${GTEST_TEST_SRCS} unittest.cpp)
-
-INCLUDE(FindPkgConfig)
-PKG_CHECK_MODULES(gtest_pkgs REQUIRED glib-2.0 gio-2.0 gmock vconf libnl-2.0)
-
-FOREACH(flag ${gtest_pkgs_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-INCLUDE_DIRECTORIES(${gtest_pkgs_INCLUDE_DIRS})
-LINK_DIRECTORIES(${gtest_pkgs_LIBRARY_DIRS})
-
-IF(BUILD_GCOV)
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fpie -fprofile-arcs -ftest-coverage")
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpie -fprofile-arcs -ftest-coverage")
- SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
-ELSE(BUILD_GCOV)
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fpie")
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpie")
- SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
-ENDIF(BUILD_GCOV)
-
-
-ADD_EXECUTABLE(${GTEST_TEST} ${GTEST_TEST_SRCS})
-TARGET_LINK_LIBRARIES(${GTEST_TEST} ${gtest_pkgs_LDFLAGS} ${LIBRARY} -ldl)
-
-INSTALL(TARGETS ${GTEST_TEST} DESTINATION bin)
+++ /dev/null
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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 <stdio.h>
-#include <stdlib.h>
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-#include <unistd.h>
-
-#include "unittest.h"
-
-using ::testing::EmptyTestEventListener;
-using ::testing::InitGoogleTest;
-using ::testing::Test;
-using ::testing::TestCase;
-using ::testing::TestEventListeners;
-using ::testing::TestInfo;
-using ::testing::TestPartResult;
-using ::testing::UnitTest;
-
-TEST(inm_manager_main, main_Positive)
-{
-
-}
-
-int main(int argc, char **argv)
-{
- InitGoogleTest(&argc, argv);
-
- return RUN_ALL_TESTS();
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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.
- */
-#ifndef __INM_MANAGER_UNITTEST_H__
-#define __INM_MANAGER_UNITTEST_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <glib.h>
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__INM_MANAGER_UNITTEST_H__