SET(CMAKE_C_FLAGS "-I./include -I./include/headers ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -w")
SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+IF(MEDIA_TOOL_GTESTS_BUILD)
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
+ENDIF(MEDIA_TOOL_GTESTS_BUILD)
+
IF("${ARCH}" STREQUAL "arm")
ADD_DEFINITIONS("-DTARGET")
ENDIF("${ARCH}" STREQUAL "arm")
IF(TIZEN_FEATURE_TESTSUITE)
ADD_SUBDIRECTORY(test)
ENDIF(TIZEN_FEATURE_TESTSUITE)
+IF(MEDIA_TOOL_GTESTS_BUILD)
+ADD_SUBDIRECTORY(unittest)
+ENDIF(MEDIA_TOOL_GTESTS_BUILD)
IF(UNIX)
)
ENDIF(UNIX)
-
Name: capi-media-tool
Summary: A Core API media tool library in Tizen Native API
-Version: 0.1.52
-Release: 1
+Version: 0.1.53
+Release: 0
Group: Multimedia/API
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(capi-base-common)
BuildRequires: pkgconfig(libtbm)
+%if "%{gtests}" == "1"
+BuildRequires: pkgconfig(mm-common)
+BuildRequires: pkgconfig(gmock)
+%endif
%description
A Core API media tool library in Tizen Native API
export CFLAGS+=" -DPATH_LIBDIR=\\\"%{_libdir}\\\""
MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
-%cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \
+%cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \
+%if "%{gtests}" == "1"
+ -DMEDIA_TOOL_GTESTS_BUILD=On \
+%endif
%if "%{tizen_profile_name}" != "tv"
-DTIZEN_FEATURE_TESTSUITE=On
%else
%files gcov
%{_datadir}/gcov/obj/*
%endif
-
--- /dev/null
+
+LINK_DIRECTORIES(${CMAKE_BINARY_DIR})
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+
+SET(GTEST_MEDIA_TOOL "gtest-media-tool")
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fpie")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpie")
+
+FILE(GLOB GTEST_MEDIA_TOOL_SRCS *.cpp)
+
+PKG_CHECK_MODULES(GTEST_PKGS REQUIRED glib-2.0 dlog mm-common gmock)
+INCLUDE_DIRECTORIES(${GTEST_PKGS_INCLUDE_DIRS})
+LINK_DIRECTORIES(${GTEST_PKGS_LIBRARY_DIRS})
+
+ADD_EXECUTABLE(${GTEST_MEDIA_TOOL} ${GTEST_MEDIA_TOOL_SRCS})
+TARGET_LINK_LIBRARIES(${GTEST_MEDIA_TOOL} ${fw_name} ${GTEST_PKGS_LDFLAGS} -lgcov)
+
+INSTALL(TARGETS ${GTEST_MEDIA_TOOL} DESTINATION ${BINDIR})
--- /dev/null
+/*
+ * Copyright (c) 2022 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 "media_tool_gtest.h"
--- /dev/null
+/*
+ * Copyright (c) 2022 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 __MEDIATOOL_GTEST_H__
+#define __MEDIATOOL_GTEST_H__
+
+#include "unittest.h"
+
+#endif /*__MEDIATOOL_GTEST_H__*/
--- /dev/null
+/*
+ * Copyright (c) 2022 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 "media_tool_gtest.h"
+#include "media_format.h"
+
+using ::testing::InitGoogleTest;
+using ::testing::Test;
+using ::testing::TestCase;
+
+class MediaToolTest : public ::testing::Test {
+ protected:
+ void SetUp() {
+ std::cout << "SetUp()" << std::endl;
+ }
+
+ void TearDown() {
+ std::cout << "TearDown()" << std::endl;
+ }
+};
+
+TEST(MediaToolTest, media_tool_gtest_create)
+{
+ media_format_h fmt;
+ int ret = media_format_create(&fmt);
+ ASSERT_EQ(ret, MEDIA_FORMAT_ERROR_NONE);
+
+ media_format_unref(fmt);
+}
+
+int main(int argc, char **argv)
+{
+ InitGoogleTest(&argc, argv);
+
+ return RUN_ALL_TESTS();
+}
--- /dev/null
+/*
+ * Copyright (c) 2022 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 __UNITTEST_H__
+#define __UNITTEST_H__
+
+#include <glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <iostream>
+#include <dlog.h>
+#include <mm_error.h>
+
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+#endif /*__UNITTEST_H__*/