From: DoHyun Pyun Date: Mon, 4 Jun 2018 04:47:38 +0000 (+0900) Subject: Add the base code for gtest verification X-Git-Tag: accepted/tizen/unified/20180813.061325~14 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fconnectivity%2Fbluetooth-agent.git;a=commitdiff_plain;h=f6533393551aaf2cc7349bfc18cf6eb6db4db5d0 Add the base code for gtest verification Change-Id: I5d25520e06ea8c91b8608cd51aa031759972059d Signed-off-by: DoHyun Pyun --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 243207b..b7c18fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,4 +8,7 @@ ADD_SUBDIRECTORY(map-agent) ADD_SUBDIRECTORY(pb-agent) ADD_SUBDIRECTORY(ag-agent) ADD_SUBDIRECTORY(ipsp-agent) -ADD_SUBDIRECTORY(hid-agent) \ No newline at end of file +ADD_SUBDIRECTORY(hid-agent) +IF (BUILD_GTESTS) +ADD_SUBDIRECTORY(unittest) +ENDIF (BUILD_GTESTS) diff --git a/ag-agent/CMakeLists.txt b/ag-agent/CMakeLists.txt index 71e3a80..c5b357b 100644 --- a/ag-agent/CMakeLists.txt +++ b/ag-agent/CMakeLists.txt @@ -1,5 +1,5 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(bluetooth-ag-agent C) +PROJECT(bluetooth-ag-agent C CXX) SET(SRCS bluetooth-ag-agent.c bluetooth-ag-handler.c @@ -39,6 +39,21 @@ ADD_DEFINITIONS("-DAPP_SYSCONFDIR=\"${APP_SYSCONFDIR}\"") ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_ag_agent_LDFLAGS}) +IF (BUILD_GTESTS) +# -fvisibility option should be "default" to call internal functions +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fvisibility=default -fPIC -Werror -Wno-deprecated-declarations -fprofile-arcs -ftest-coverage") + +ADD_LIBRARY(ag-agent SHARED ${SRCS}) +SET_TARGET_PROPERTIES(ag-agent + PROPERTIES + SOVERSION 0.1.0 + CLEAN_DIRECT_OUTPUT 1) + +TARGET_LINK_LIBRARIES(ag-agent ${pkgs_ag_agent_LDFLAGS} -lgcov) + +INSTALL(TARGETS ag-agent DESTINATION lib COMPONENT RuntimeLibraries) +ENDIF (BUILD_GTESTS) + INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/org.bluez.ag_agent.service DESTINATION share/dbus-1/system-services) diff --git a/ag-agent/bluetooth-ag-agent.h b/ag-agent/bluetooth-ag-agent.h index 3198660..c6b26b0 100755 --- a/ag-agent/bluetooth-ag-agent.h +++ b/ag-agent/bluetooth-ag-agent.h @@ -25,6 +25,10 @@ #ifndef __DEF_BT_AG_AGENT_H_ #define __DEF_BT_AG_AGENT_H_ +#ifdef __cplusplus +extern "C" { +#endif + #undef LOG_TAG #define LOG_TAG "BLUETOOTH_AG_AGENT" @@ -628,4 +632,7 @@ bt_hfp_agent_error_t _bt_ag_agent_vendor_cmd(const gchar *cmd, void _bt_ag_agent_check_transport_state(void); #endif +#ifdef __cplusplus +} +#endif #endif /* __DEF_BT_AG_AGENT_H_ */ diff --git a/ag-agent/bluetooth-ag-handler.h b/ag-agent/bluetooth-ag-handler.h index 96bd7f3..35587e8 100755 --- a/ag-agent/bluetooth-ag-handler.h +++ b/ag-agent/bluetooth-ag-handler.h @@ -22,6 +22,13 @@ * */ +#ifndef __DEF_BT_AG_HANDLER_H_ +#define __DEF_BT_AG_HANDLER_H_ + +#ifdef __cplusplus +extern "C" { +#endif + #include #include #include @@ -177,3 +184,8 @@ int _bt_hfp_vendor_cmd(bt_ag_info_t *hs, const char *buf); int _bt_hfp_send_vendor_cmd(bt_ag_info_t *hs, const char *cmd); int _bt_vendor_cmd_response(void *t_device, bt_hfp_agent_error_t err); + +#ifdef __cplusplus +} +#endif +#endif /* __DEF_BT_AG_HANDLER_H_ */ diff --git a/hf-agent/CMakeLists.txt b/hf-agent/CMakeLists.txt index 1ee2094..48a8211 100644 --- a/hf-agent/CMakeLists.txt +++ b/hf-agent/CMakeLists.txt @@ -1,5 +1,5 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(bluetooth-hf-agent C) +PROJECT(bluetooth-hf-agent C CXX) SET(SRCS bluetooth-hf-agent.c ../include/bluetooth-agent-profile.c) @@ -22,6 +22,21 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror") ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_hf_agent_LDFLAGS}) +IF (BUILD_GTESTS) +# -fvisibility option should be "default" to call internal functions +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fvisibility=default -fPIC -Werror -Wno-deprecated-declarations -fprofile-arcs -ftest-coverage") + +ADD_LIBRARY(hf-agent SHARED ${SRCS}) +SET_TARGET_PROPERTIES(hf-agent + PROPERTIES + SOVERSION 0.1.0 + CLEAN_DIRECT_OUTPUT 1) + +TARGET_LINK_LIBRARIES(hf-agent ${pkgs_hf_agent_LDFLAGS} -lgcov) + +INSTALL(TARGETS hf-agent DESTINATION lib COMPONENT RuntimeLibraries) +ENDIF (BUILD_GTESTS) + INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/org.bluez.hf_agent.service DESTINATION share/dbus-1/system-services) diff --git a/hf-agent/bluetooth-hf-agent.h b/hf-agent/bluetooth-hf-agent.h index da34405..a86a7f1 100644 --- a/hf-agent/bluetooth-hf-agent.h +++ b/hf-agent/bluetooth-hf-agent.h @@ -24,6 +24,10 @@ #ifndef __DEF_BT_HF_AGENT_H_ #define __DEF_BT_HF_AGENT_H_ +#ifdef __cplusplus +extern "C" { +#endif + #undef LOG_TAG #define LOG_TAG "BLUETOOTH_HF_AGENT" @@ -339,4 +343,7 @@ struct sockaddr_sco { bdaddr_t sco_bdaddr; }; +#ifdef __cplusplus +} +#endif #endif /* __DEF_BT_HF_AGENT_H_ */ diff --git a/hid-agent/CMakeLists.txt b/hid-agent/CMakeLists.txt index 094bba1..0c5da53 100644 --- a/hid-agent/CMakeLists.txt +++ b/hid-agent/CMakeLists.txt @@ -1,5 +1,5 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(bluetooth-hid-agent C) +PROJECT(bluetooth-hid-agent C CXX) SET(SRCS bluetooth-hid-agent.c bluetooth-hid-manager.c) @@ -20,6 +20,21 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall") ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_hid_agent_LDFLAGS}) +IF (BUILD_GTESTS) +# -fvisibility option should be "default" to call internal functions +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fvisibility=default -fPIC -Werror -Wno-deprecated-declarations -fprofile-arcs -ftest-coverage") + +ADD_LIBRARY(hid-agent SHARED ${SRCS}) +SET_TARGET_PROPERTIES(hid-agent + PROPERTIES + SOVERSION 0.1.0 + CLEAN_DIRECT_OUTPUT 1) + +TARGET_LINK_LIBRARIES(hid-agent ${pkgs_hid_agent_LDFLAGS} -lgcov) + +INSTALL(TARGETS hid-agent DESTINATION lib COMPONENT RuntimeLibraries) +ENDIF (BUILD_GTESTS) + INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/org.bluez.hid_agent.service DESTINATION share/dbus-1/system-services) diff --git a/hid-agent/bluetooth-hid-agent.h b/hid-agent/bluetooth-hid-agent.h index 8552031..3a277a8 100644 --- a/hid-agent/bluetooth-hid-agent.h +++ b/hid-agent/bluetooth-hid-agent.h @@ -21,6 +21,10 @@ #define __DEF_BT_HID_AGENT_H_ #define FUNCTION_TRACE +#ifdef __cplusplus +extern "C" { +#endif + #include #include #include @@ -160,4 +164,7 @@ struct sockaddr_remote { bt_hid_agent_error_t _bt_hid_disconnect_profile(void); +#ifdef __cplusplus +} +#endif #endif /* __DEF_BT_HID_AGENT_H_ */ diff --git a/hid-agent/bluetooth-hid-manager.h b/hid-agent/bluetooth-hid-manager.h index 9f76b5d..e4b09d7 100644 --- a/hid-agent/bluetooth-hid-manager.h +++ b/hid-agent/bluetooth-hid-manager.h @@ -20,9 +20,16 @@ #ifndef __DEF_BT_HID_MANAGER_H_ #define __DEF_BT_HID_MANAGER_H_ +#ifdef __cplusplus +extern "C" { +#endif + void _bt_hid_set_profile_state(bt_hid_state_t new_state); bt_hid_agent_error_t _bt_hid_register_application(gboolean register_flag, const char *sender_name); const GSList* _bt_hid_get_sender_list(void); +#ifdef __cplusplus +} +#endif #endif /* __DEF_BT_HID_MANAGER_H_ */ diff --git a/ipsp-agent/CMakeLists.txt b/ipsp-agent/CMakeLists.txt index 7c54aa9..476752d 100644 --- a/ipsp-agent/CMakeLists.txt +++ b/ipsp-agent/CMakeLists.txt @@ -1,5 +1,5 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(bluetooth-ipsp-agent C) +PROJECT(bluetooth-ipsp-agent C CXX) SET(SRCS bluetooth_ipsp_agent.c ../include/bluetooth-agent-profile.c) @@ -39,6 +39,21 @@ SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_ipsp_agent_LDFLAGS} -L${CMAKE_CURRENT_SOURCE_DIR}/../bt-api -lbluetooth-api) +IF (BUILD_GTESTS) +# -fvisibility option should be "default" to call internal functions +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fvisibility=default -fPIC -Werror -Wno-deprecated-declarations -fprofile-arcs -ftest-coverage") + +ADD_LIBRARY(ipsp-agent SHARED ${SRCS}) +SET_TARGET_PROPERTIES(ipsp-agent + PROPERTIES + SOVERSION 0.1.0 + CLEAN_DIRECT_OUTPUT 1) + +TARGET_LINK_LIBRARIES(ipsp-agent ${pkgs_ipsp_agent_LDFLAGS} -lgcov) + +INSTALL(TARGETS ipsp-agent DESTINATION lib COMPONENT RuntimeLibraries) +ENDIF (BUILD_GTESTS) + INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/org.bluez.ipsp_agent.service DESTINATION share/dbus-1/system-services) diff --git a/map-agent/CMakeLists.txt b/map-agent/CMakeLists.txt index d887e65..653b4b6 100644 --- a/map-agent/CMakeLists.txt +++ b/map-agent/CMakeLists.txt @@ -1,5 +1,5 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(bluetooth-map-agent C) +PROJECT(bluetooth-map-agent C CXX) SET(SRCS bluetooth_map_agent.c bluetooth_map_sms.c bluetooth_map_email.c map_bmessage.c ../include/bluetooth-agent-profile.c) @@ -21,5 +21,20 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror") ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_map_agent_LDFLAGS}) +IF (BUILD_GTESTS) +# -fvisibility option should be "default" to call internal functions +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fvisibility=default -fPIC -Werror -Wno-deprecated-declarations -fprofile-arcs -ftest-coverage") + +ADD_LIBRARY(map-agent SHARED ${SRCS}) +SET_TARGET_PROPERTIES(map-agent + PROPERTIES + SOVERSION 0.1.0 + CLEAN_DIRECT_OUTPUT 1) + +TARGET_LINK_LIBRARIES(map-agent ${pkgs_map_agent_LDFLAGS} -lgcov) + +INSTALL(TARGETS map-agent DESTINATION lib COMPONENT RuntimeLibraries) +ENDIF (BUILD_GTESTS) + INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/org.bluez.map_agent.service DESTINATION share/dbus-1/system-services) diff --git a/map-agent/bluetooth_map_agent.h b/map-agent/bluetooth_map_agent.h index fcaad44..014f12c 100644 --- a/map-agent/bluetooth_map_agent.h +++ b/map-agent/bluetooth_map_agent.h @@ -24,6 +24,10 @@ #ifndef __DEF_BT_PB_AGENT_H_ #define __DEF_BT_PB_AGENT_H_ +#ifdef __cplusplus +extern "C" { +#endif + #include #include #include @@ -82,4 +86,8 @@ gboolean _bt_verify_sender(message_info_t *msg_info, char *sender); gboolean _bt_verify_receiver(message_info_t *msg_info, char *receiver); gboolean _bt_verify_time(message_info_t *msg_info, map_msg_filter_t *filter); gboolean _bt_filter_priority(message_info_t *msg_info, guint8 priority); + +#ifdef __cplusplus +} +#endif #endif /* __DEF_BT_AGENT_H_ */ diff --git a/map-agent/bluetooth_map_email.h b/map-agent/bluetooth_map_email.h index 538781e..a3c9f49 100644 --- a/map-agent/bluetooth_map_email.h +++ b/map-agent/bluetooth_map_email.h @@ -24,6 +24,10 @@ #ifndef __DEF_MAP_EMAIL_H_ #define __DEF_MAP_EMAIL_H_ +#ifdef __cplusplus +extern "C" { +#endif + #include #include "bluetooth_map_types.h" #include "map_bmessage.h" @@ -50,4 +54,7 @@ gboolean _bt_map_get_email_message(int mail_id, gboolean attach, gboolean _bt_map_push_email_data(struct bmsg_data *bmsg_info, msg_send_option_t *option, char *folder); +#ifdef __cplusplus +} +#endif #endif /* __DEF_MAP_EMAIL_H_ */ diff --git a/map-agent/bluetooth_map_sms.h b/map-agent/bluetooth_map_sms.h index ba5328a..27741b3 100644 --- a/map-agent/bluetooth_map_sms.h +++ b/map-agent/bluetooth_map_sms.h @@ -24,6 +24,10 @@ #ifndef BLUETOOTH_MAP_SMS_H_ #define BLUETOOTH_MAP_SMS_H_ +#ifdef __cplusplus +extern "C" { +#endif + #include #include "bluetooth_map_types.h" #include "map_bmessage.h" @@ -48,4 +52,7 @@ gboolean _bt_map_sms_set_read_status(int msg_id, gboolean read_status); gboolean _bt_map_push_sms_data(struct bmsg_data *bmsg_info, msg_send_option_t *option, char *folder); +#ifdef __cplusplus +} +#endif #endif /* BLUETOOTH_MAP_SMS_H_ */ diff --git a/map-agent/bluetooth_map_types.h b/map-agent/bluetooth_map_types.h index 4cfd297..4226bc1 100644 --- a/map-agent/bluetooth_map_types.h +++ b/map-agent/bluetooth_map_types.h @@ -24,6 +24,10 @@ #ifndef BLUETOOTH_MAP_TYPES_H_ #define BLUETOOTH_MAP_TYPES_H_ +#ifdef __cplusplus +extern "C" { +#endif + #define FOLDER_COUNT 5 /* INBOX, OUTBOX, SENT, DRAFT, DELETED*/ #define MSG_TYPES 2 /* GSM_SMS, EMAIL*/ #define BT_MAP_SUBJECT_MAX_LEN 50 @@ -97,4 +101,8 @@ typedef struct { char *originator; guint8 priority; } map_msg_filter_t; + +#ifdef __cplusplus +} +#endif #endif /* BLUETOOTH_MAP_TYPES_H_ */ diff --git a/packaging/bluetooth-agent.spec b/packaging/bluetooth-agent.spec index 9c80b8e..df66624 100644 --- a/packaging/bluetooth-agent.spec +++ b/packaging/bluetooth-agent.spec @@ -45,6 +45,10 @@ BuildRequires: pkgconfig(libexif) BuildRequires: pkgconfig(gio-2.0) BuildRequires: cmake Requires: security-config +%if 0%{?gcov:1} +BuildRequires: pkgconfig(gmock) +%endif + #Requires: %{name}-compat = %{version}-%{release} #Recommends: %{name}-profile_common = %{version}-%{release} @@ -93,6 +97,16 @@ Group: Network & Connectivity/Bluetooth %description ipsp Bluetooth agent binary compiled for IPSP(Internet Protocol Support Profile) +%if 0%{?gcov:1} +%package test +Summary: Test package for bluetooth-agent +Group: TO_BE/FILLED +Requires: %{name} = %{version}-%{release} + +%description test +This package is C-API test application. +%endif + %prep %setup -q cp %{SOURCE1001} . @@ -127,7 +141,11 @@ export LDFLAGS+=" -Wl,--rpath=/usr/lib -Wl,--as-needed -Wl,--unresolved-symbols= export CFLAGS_DEFAULT="$CFLAGS" # Build All (wearalbe/ivi/common/tv/mobile) -cmake . -DCMAKE_INSTALL_PREFIX=/usr -DTIZEN_FEATURE_BT_HFP_AG=1 +cmake . -DCMAKE_INSTALL_PREFIX=/usr \ + -DTIZEN_FEATURE_BT_HFP_AG=1 \ + -DBUILD_GTESTS=%{?gcov:1}%{!?gcov:0} \ + -DBUILD_GCOV=%{?gcov:1}%{!?gcov:0} + make VERBOSE=1 %install @@ -204,3 +222,11 @@ ln -sf %{_libdir}/systemd/system/bluetooth-pbap-agent.service %{_sysconfdir}/sys %{_datadir}/dbus-1/system-services/org.bluez.ipsp_agent.service %{_sysconfdir}/dbus-1/system.d/bluetooth-ipsp-agent.conf +%if 0%{?gcov:1} +%files test +%manifest %{name}.manifest +%{_bindir}/gtest-bluetooth-agent +%{_libdir}/lib* +%exclude %{_libdir}/debug/* +%exclude %{_libdir}/debug/.build-id/* +%endif diff --git a/pb-agent/CMakeLists.txt b/pb-agent/CMakeLists.txt index fb2b4ed..01ceade 100644 --- a/pb-agent/CMakeLists.txt +++ b/pb-agent/CMakeLists.txt @@ -1,5 +1,5 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(bluetooth-pb-agent C) +PROJECT(bluetooth-pb-agent C CXX) SET(SRCS bluetooth_pb_agent.c bluetooth_pb_vcard.c ../include/bluetooth-agent-profile.c) @@ -20,6 +20,21 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror") ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_pb_agent_LDFLAGS}) +IF (BUILD_GTESTS) +# -fvisibility option should be "default" to call internal functions +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fvisibility=default -fPIC -Werror -Wno-deprecated-declarations -fprofile-arcs -ftest-coverage") + +ADD_LIBRARY(pb-agent SHARED ${SRCS}) +SET_TARGET_PROPERTIES(pb-agent + PROPERTIES + SOVERSION 0.1.0 + CLEAN_DIRECT_OUTPUT 1) + +TARGET_LINK_LIBRARIES(pb-agent ${pkgs_pb_agent_LDFLAGS} -lgcov) + +INSTALL(TARGETS pb-agent DESTINATION lib COMPONENT RuntimeLibraries) +ENDIF (BUILD_GTESTS) + INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/org.bluez.pb_agent.service DESTINATION share/dbus-1/system-services) diff --git a/pb-agent/bluetooth_pb_agent.h b/pb-agent/bluetooth_pb_agent.h index e7127a2..706a954 100644 --- a/pb-agent/bluetooth_pb_agent.h +++ b/pb-agent/bluetooth_pb_agent.h @@ -24,6 +24,10 @@ #ifndef __DEF_BT_PB_AGENT_H_ #define __DEF_BT_PB_AGENT_H_ +#ifdef __cplusplus +extern "C" { +#endif + #include #include @@ -62,4 +66,8 @@ typedef enum { TELECOM_NONE } PhoneBookType; +#ifdef __cplusplus +} +#endif + #endif /* __DEF_BT_AGENT_H_ */ diff --git a/pb-agent/bluetooth_pb_vcard.h b/pb-agent/bluetooth_pb_vcard.h index 97fb014..c7c3a31 100644 --- a/pb-agent/bluetooth_pb_vcard.h +++ b/pb-agent/bluetooth_pb_vcard.h @@ -24,6 +24,10 @@ #ifndef __DEF_BT_PB_VCARD_H_ #define __DEF_BT_PB_VCARD_H_ +#ifdef __cplusplus +extern "C" { +#endif + #include #define SIM_ADDRESSBOOK_PREFIX "http://tizen.org/addressbook/sim" @@ -65,4 +69,8 @@ gchar *_bluetooth_pb_owner_name(void); bool _bt_is_sim_addressbook(const char *addressbook); +#ifdef __cplusplus +} +#endif + #endif diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt new file mode 100644 index 0000000..4d686db --- /dev/null +++ b/unittest/CMakeLists.txt @@ -0,0 +1,59 @@ +# Copyright (c) 2014-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 +# @author +# @brief Cmake for tests +# +SET(TARGET_GTEST_TESTS "gtest-bluetooth-agent") + +INCLUDE_DIRECTORIES(/usr/include) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) +INCLUDE_DIRECTORIES(/usr/include/glib-2.0) +INCLUDE_DIRECTORIES(/usr/lib/glib-2.0/include/) + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(EXEC_PREFIX "\${prefix}") +SET(INCLUDEDIR "/usr/include") + +INCLUDE(FindPkgConfig) +pkg_check_modules(testpkgs REQUIRED glib-2.0 gmock) + +SET(GTEST_TESTS_SOURCES +bluetooth-agent_test.cpp +) + +ADD_EXECUTABLE(${TARGET_GTEST_TESTS} + ${GTEST_TESTS_SOURCES} +) + +TARGET_LINK_LIBRARIES(${TARGET_GTEST_TESTS} + ${pkgs_LDFLAGS} + ${pkgs_LIBRARIES} + gmock + -L${CMAKE_SOURCE_DIR}/ag-agent + -L${CMAKE_SOURCE_DIR}/hf-agent + -L${CMAKE_SOURCE_DIR}/hid-agent + -L${CMAKE_SOURCE_DIR}/ipsp-agent + -L${CMAKE_SOURCE_DIR}/map-agent + -L${CMAKE_SOURCE_DIR}/pb-agent + -lag-agent + -lhf-agent + -lhid-agent + -lipsp-agent + -lmap-agent + -lpb-agent +) + +INSTALL(TARGETS ${TARGET_GTEST_TESTS} DESTINATION /usr/bin) diff --git a/unittest/bluetooth-agent_test.cpp b/unittest/bluetooth-agent_test.cpp new file mode 100644 index 0000000..8bc7b63 --- /dev/null +++ b/unittest/bluetooth-agent_test.cpp @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2014 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 bluetooth-agent_test.cpp + * @author abc + * @version 1.0 + * @brief Unit-tests setup + */ + +#include +#include +#include +#include + +using ::testing::EmptyTestEventListener; +using ::testing::InitGoogleTest; +using ::testing::Test; +using ::testing::TestCase; +using ::testing::TestEventListeners; +using ::testing::TestInfo; +using ::testing::TestPartResult; +using ::testing::UnitTest; + +int main(int argc, char **argv) { + InitGoogleTest(&argc, argv); + + return RUN_ALL_TESTS(); +}