ADD_SUBDIRECTORY(lib)
ADD_SUBDIRECTORY(bt-share)
+
+IF (BUILD_GTESTS)
+ADD_SUBDIRECTORY(unittest)
+ENDIF (BUILD_GTESTS)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(bluetooth-share C)
+PROJECT(bluetooth-share C CXX)
SET(SRCS src/bt-share-main.c
src/bt-share-notification.c
#endif(CONTACTS_SERVICE2_FOUND)
ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
+
#TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} ${CALENDAR_SERVICE2_LDFLAGS} ${CONTACTS_SERVICE2_LDFLAGS} -L${CMAKE_CURRENT_SOURCE_DIR}/../lib -lbluetooth-share-api)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} -L${CMAKE_CURRENT_SOURCE_DIR}/../lib -lbluetooth-share-api)
+IF (BUILD_GTESTS)
+# Do not include "-fvisibility=hidden" option to call internal functions
+SET(CMAKE_C_FLAGS "-fpie ${EXTRA_CFLAGS} -fPIC -Werror -Wno-deprecated-declarations")
+
+ADD_LIBRARY(bt-share SHARED ${SRCS})
+SET_TARGET_PROPERTIES(bt-share
+ PROPERTIES
+ SOVERSION 0.1.0
+ CLEAN_DIRECT_OUTPUT 1)
+
+TARGET_LINK_LIBRARIES(bt-share ${pkgs_LDFLAGS} -L${CMAKE_CURRENT_SOURCE_DIR}/../lib -lbluetooth-share-api)
+INSTALL(TARGETS bt-share DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
+ENDIF (BUILD_GTESTS)
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
#INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/org.bluetooth.share.service DESTINATION share/dbus-1/system-services)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(bluetooth-share-api C)
+PROJECT(bluetooth-share-api C CXX)
SET(SRCS bt-share-db.c
)
Name: bluetooth-share
Summary: Bluetooth file share Agent
-Version: 0.0.48
+Version: 0.0.49
Release: 0
Group: Network & Connectivity/Bluetooth
License: Apache-2.0
BuildRequires: pkgconfig(eventsystem)
BuildRequires: pkgconfig(storage)
BuildRequires: pkgconfig(libsystemd)
+%if 0%{?gtests:1}
+BuildRequires: pkgconfig(gmock)
+%endif
%description
Bluetooth File Share Agent
export LDFLAGS+=" -Wl,--rpath=/usr/lib -Wl,--as-needed -Wl,--unresolved-symbols=ignore-in-shared-libs -pie"
%cmake . \
- -DCMAKE_INSTALL_PREFIX=%{_prefix}
+ -DCMAKE_INSTALL_PREFIX=%{_prefix} \
+ -DBUILD_GTESTS=%{?gtests:1}%{!?gtests:0} \
+ -DBUILD_GCOV=%{?gcov:1}%{!?gcov:0}
make
%install
%{_libdir}/systemd/system/bluetooth-share.service
%{upgrade_script_path}/500.bluetooth-share_upgrade.sh
%{upgrade_data_path}/init_db.sh
+%if 0%{?gtests:1}
+%{_bindir}/gtest-bluetooth-share
+%exclude %{_libdir}/libbt-share.so*
+%exclude %{_libdir}/debug/*
+%exclude %{_libdir}/debug/.build-id/*
+%endif
%files -n libbluetooth-share
%manifest libbluetooth-share.manifest
--- /dev/null
+# 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-share")
+
+INCLUDE_DIRECTORIES(/usr/include)
+INCLUDE_DIRECTORIES(/usr/include/db-util)
+INCLUDE_DIRECTORIES(/usr/include/glib-2.0)
+INCLUDE_DIRECTORIES(/usr/lib/glib-2.0/include/)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/bt-share/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-share_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}/lib
+ -lbluetooth-share-api
+ -L${CMAKE_SOURCE_DIR}/bt-share
+ -lbt-share
+)
+
+INSTALL(TARGETS ${TARGET_GTEST_TESTS} DESTINATION /usr/bin)
--- /dev/null
+/*
+ * 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-share_test.cpp
+ * @author abc
+ * @version 1.0
+ * @brief Unit-tests setup
+ */
+
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+#include <unistd.h>
+#include <glib.h>
+#include "bluetooth-share-api.h"
+#include "bt-share-common.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(BluetoothShare_test, _bt_share_block_sleep_p) {
+ int ret = BT_SHARE_ERROR_NONE;
+
+ ret = _bt_share_block_sleep(TRUE);
+ ASSERT_FALSE(ret == BT_SHARE_ERROR_NONE);
+
+ ret = _bt_share_block_sleep(FALSE);
+ ASSERT_FALSE(ret == BT_SHARE_ERROR_NONE);
+}
+
+int main(int argc, char **argv) {
+ InitGoogleTest(&argc, argv);
+
+ return RUN_ALL_TESTS();
+}