ADD_SUBDIRECTORY(legacy)
ADD_SUBDIRECTORY(muse)
+IF(ENABLE_GTESTS)
+ADD_SUBDIRECTORY(unittest)
+ENDIF(ENABLE_GTESTS)
IF(UNIX)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-
SET(service "legacy")
SET(submodule "camera")
-# for package file
SET(dependents "dlog mm-camcorder capi-base-common")
+SET(LEGACY "${service}-${submodule}")
-SET(fw_name "${service}-${submodule}")
-
-PROJECT(${fw_name})
+PROJECT(${LEGACY})
SET(CMAKE_INSTALL_PREFIX /usr)
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
INCLUDE_DIRECTORIES(${INC_DIR})
INCLUDE(FindPkgConfig)
-pkg_check_modules(${fw_name} REQUIRED ${dependents})
-FOREACH(flag ${${fw_name}_CFLAGS})
+pkg_check_modules(${LEGACY} REQUIRED ${dependents})
+FOREACH(flag ${${LEGACY}_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}")
aux_source_directory(src LEGACY_SOURCES)
-ADD_LIBRARY(${fw_name} SHARED ${LEGACY_SOURCES})
+ADD_LIBRARY(${LEGACY} SHARED ${LEGACY_SOURCES})
-SET_TARGET_PROPERTIES(${fw_name}
+SET_TARGET_PROPERTIES(${LEGACY}
PROPERTIES
CLEAN_DIRECT_OUTPUT 1
)
+TARGET_LINK_LIBRARIES(${LEGACY} ${${LEGACY}_LDFLAGS})
-TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS})
-
-INSTALL(TARGETS ${fw_name} DESTINATION ${LIB_INSTALL_DIR})
+INSTALL(TARGETS ${LEGACY} DESTINATION ${LIB_INSTALL_DIR})
INSTALL(
DIRECTORY ${INC_DIR}/ DESTINATION include/media
FILES_MATCHING
SET(submodule "camera")
SET(dependents "dlog glib-2.0 muse-server mm-common libtbm gstreamer-1.0")
-SET(fw_name "${service}-${submodule}")
+SET(MUSE_MODULE "${service}-${submodule}")
-PROJECT(${fw_name})
+PROJECT(${MUSE_MODULE})
SET(CMAKE_INSTALL_PREFIX /usr)
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
INCLUDE_DIRECTORIES(${INC_DIR})
INCLUDE(FindPkgConfig)
-pkg_check_modules(${fw_name} REQUIRED ${dependents})
-FOREACH(flag ${${fw_name}_CFLAGS})
+pkg_check_modules(${MUSE_MODULE} REQUIRED ${dependents})
+FOREACH(flag ${${MUSE_MODULE}_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}")
aux_source_directory(src MUSED_SOURCES)
-ADD_LIBRARY(${fw_name} SHARED ${MUSED_SOURCES})
+ADD_LIBRARY(${MUSE_MODULE} SHARED ${MUSED_SOURCES})
-TARGET_LINK_LIBRARIES(${fw_name} legacy-camera ${${fw_name}_LDFLAGS})
+TARGET_LINK_LIBRARIES(${MUSE_MODULE} legacy-camera ${${MUSE_MODULE}_LDFLAGS})
-SET_TARGET_PROPERTIES(${fw_name}
+SET_TARGET_PROPERTIES(${MUSE_MODULE}
PROPERTIES
CLEAN_DIRECT_OUTPUT 1
)
-INSTALL(TARGETS ${fw_name} DESTINATION ${LIB_INSTALL_DIR})
+INSTALL(TARGETS ${MUSE_MODULE} DESTINATION ${LIB_INSTALL_DIR})
INSTALL(
DIRECTORY ${INC_DIR}/ DESTINATION include/media
FILES_MATCHING
#ifndef __MUSE_CAMERA_H__
#define __MUSE_CAMERA_H__
-#ifdef _cplusplus
+#ifdef __cplusplus
extern "C" {
#endif
#ifndef __MUSE_CAMERA_INTERNAL_H__
#define __MUSE_CAMERA_INTERNAL_H__
-#ifdef _cplusplus
+#ifdef __cplusplus
extern "C" {
#endif
Name: mmsvc-camera
Summary: A Camera module for muse server
-Version: 0.3.19
+Version: 0.3.21
Release: 0
Group: Multimedia/Libraries
License: Apache-2.0
BuildRequires: pkgconfig(mm-camcorder)
BuildRequires: pkgconfig(capi-base-common)
BuildRequires: pkgconfig(libtbm)
+%if "%{gtests}" == "1"
+BuildRequires: pkgconfig(gmock)
+%endif
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
export CFLAGS+=" -DTIZEN_DEBUG_ENABLE"
%endif
MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
-%cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DFULLVER=%{version} -DMAJORVER=${MAJORVER} -DLIBDIR=%{_libdir}
+%cmake . \
+%if "%{gtests}" == "1"
+ -DENABLE_GTESTS=On\
+%else
+ -DENABLE_GTESTS=Off\
+%endif
+ -DCMAKE_INSTALL_PREFIX=%{_prefix}\
+ -DFULLVER=%{version}\
+ -DMAJORVER=${MAJORVER}\
+ -DLIBDIR=%{_libdir}
+
make %{?jobs:-j%jobs}
%license LICENSE.APLv2
%{_libdir}/liblegacy-camera.so
%{_libdir}/libmuse-camera.so
+%if "%{gtests}" == "1"
+%{_bindir}/gtests-*
+%endif
%files devel
%{_includedir}/media/*.h
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+ADD_SUBDIRECTORY(legacy)
+ADD_SUBDIRECTORY(muse)
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(LEGACY "legacy-camera")
+SET(fw_test "gtests-${LEGACY}")
+
+PROJECT(${fw_test} C CXX)
+
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(REQUIRED_PKGS REQUIRED glib-2.0 gmock mm-camcorder capi-base-common)
+FOREACH(flag ${${fw_test}_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ MESSAGE(${flag})
+ENDFOREACH()
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -fPIE -Wall")
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/legacy/include)
+INCLUDE_DIRECTORIES(${REQUIRED_PKGS_INCLUDE_DIRS})
+LINK_DIRECTORIES(${REQUIRED_PKGS_LIBRARY_DIRS})
+
+ADD_EXECUTABLE(${fw_test} gtests_legacy_camera.cpp)
+TARGET_LINK_LIBRARIES(${fw_test} ${LEGACY} ${LEGACY_LDFLAGS} ${REQUIRED_PKGS_LDFLAGS})
+INSTALL(TARGETS ${fw_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 "gtests_legacy_camera.h"
+
+using namespace std;
+using ::testing::InitGoogleTest;
+using ::testing::Test;
+using ::testing::TestCase;
+
+
+class LegacyCameraTestF : public ::testing::Test {
+ protected:
+ camera_h handle;
+
+ void SetUp() {
+ int ret = CAMERA_ERROR_NONE;
+
+ cout << "[SetUp]" << endl;
+
+ ret = legacy_camera_create(CAMERA_DEVICE_CAMERA0, &handle);
+ ASSERT_EQ(ret, CAMERA_ERROR_NONE);
+
+ return;
+ }
+
+ void TearDown() {
+ cout << "[TearDown]" << endl << endl;
+
+ if (handle) {
+ legacy_camera_destroy(handle);
+ handle = NULL;
+ }
+
+ return;
+ }
+};
+
+TEST(LegacyCameraTest, CreateP)
+{
+ int ret = CAMERA_ERROR_NONE;
+ camera_h new_handle = NULL;
+
+ ret = legacy_camera_create(CAMERA_DEVICE_CAMERA0, &new_handle);
+ ASSERT_EQ(ret, CAMERA_ERROR_NONE);
+
+ legacy_camera_destroy(new_handle);
+}
+
+TEST(LegacyCameraTest, DestroyP)
+{
+ int ret = CAMERA_ERROR_NONE;
+ camera_h new_handle = NULL;
+
+ ret = legacy_camera_create(CAMERA_DEVICE_CAMERA0, &new_handle);
+ ASSERT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = legacy_camera_destroy(new_handle);
+ ASSERT_EQ(ret, CAMERA_ERROR_NONE);
+}
+
+TEST_F(LegacyCameraTestF, SetDisplayP)
+{
+ int ret = CAMERA_ERROR_NONE;
+
+ ret = legacy_camera_set_display(handle, CAMERA_DISPLAY_TYPE_NONE, NULL);
+ ASSERT_EQ(ret, CAMERA_ERROR_NONE);
+}
+
+
+int main(int argc, char **argv)
+{
+ InitGoogleTest(&argc, argv);
+
+ return RUN_ALL_TESTS();
+}
--- /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 __LEGACY_CAMERA_UNITTEST_H__
+#define __LEGACY_CAMERA_UNITTEST_H__
+
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+#include <legacy_camera.h>
+
+#undef LOG_TAG
+#define LOG_TAG "GTEST_LEGACY_CAMERA"
+
+#endif /*__LEGACY_CAMERA_UNITTEST_H__*/
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(MUSE_MODULE "muse-camera")
+SET(fw_test "gtests-${MUSE_MODULE}")
+
+PROJECT(${fw_test} C CXX)
+
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(REQUIRED_PKGS REQUIRED glib-2.0 gmock)
+FOREACH(flag ${${fw_test}_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ MESSAGE(${flag})
+ENDFOREACH()
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -fPIE -Wall")
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/muse/include)
+INCLUDE_DIRECTORIES(${REQUIRED_PKGS_INCLUDE_DIRS})
+LINK_DIRECTORIES(${REQUIRED_PKGS_LIBRARY_DIRS})
+
+ADD_EXECUTABLE(${fw_test} gtests_muse_camera.cpp)
+TARGET_LINK_LIBRARIES(${fw_test} ${MUSE_MODULE} ${MUSE_MODULE_LDFLAGS} ${REQUIRED_PKGS_LDFLAGS})
+INSTALL(TARGETS ${fw_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 "gtests_muse_camera.h"
+
+using namespace std;
+using ::testing::InitGoogleTest;
+using ::testing::Test;
+using ::testing::TestCase;
+
+
+class MuseCameraTestF : public ::testing::Test {
+ protected:
+ void SetUp() {
+ cout << "[SetUp]" << endl;
+ return;
+ }
+
+ void TearDown() {
+ cout << "[TearDown]" << endl << endl;
+ return;
+ }
+};
+
+TEST_F(MuseCameraTestF, CreateP)
+{
+ int ret = 0;
+
+ ASSERT_EQ(ret, 0);
+}
+
+
+int main(int argc, char **argv)
+{
+ InitGoogleTest(&argc, argv);
+
+ return RUN_ALL_TESTS();
+}
--- /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 __MUSE_CAMERA_UNITTEST_H__
+#define __MUSE_CAMERA_UNITTEST_H__
+
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+#include <muse_camera.h>
+
+#undef LOG_TAG
+#define LOG_TAG "GTEST_MUSE_CAMERA"
+
+#endif /*__MUSE_CAMERA_UNITTEST_H__*/