- 'using' member from mm_player_video_bo_info_t has replaced with 'used' as 'using' is reserved keyword on c++
- static constraints on __mmplayer_parse_profile() has removed for calling it from unittest
- initialy, it has only two testcases with __parse_profile
- Enabling gtest build with '--define "gtests 1"
Change-Id: I00414f1bf3a6d80cf312ff516cabc4df270b9509
ACLOCAL_AMFLAGS='-I m4'
SUBDIRS = src
+if IS_TESTS
+SUBDIRS += unittest
+endif
pcfiles = mm-player.pc
pkgconfigdir = $(libdir)/pkgconfig
# Checks for programs.
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
AC_PROG_CC
+AC_PROG_CXX
AC_PROG_LIBTOOL
AC_C_CONST
AC_TYPE_INT64_T
AC_HEADER_TIME
+AC_SUBST(GCC_CXXFLAGS)
# Checks for library functions.
AC_FUNC_MALLOC
AC_SUBST(TBM_CFLAGS)
AC_SUBST(TBM_LIBS)
+AC_ARG_ENABLE(tests, AC_HELP_STRING([--enable-tests], [unittest build]),
+ [
+ case "${enableval}" in
+ yes) IS_TESTS=yes ;;
+ no) IS_TESTS=no ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --enable-tests) ;;
+ esac
+ ],
+[IS_TESTS=no])
+AM_CONDITIONAL([IS_TESTS], [test "x$IS_TESTS" = "xyes"])
+
+AS_IF([test "x$enable_tests" = "xyes"], [
+ PKG_CHECK_MODULES(GTESTS, gmock)
+ AC_SUBST(GTESTS_CFLAGS)
+ AC_SUBST(GTESTS_LIBS)
+])
+
AC_ARG_ENABLE(sdk, AC_HELP_STRING([--enable-sdk], [sdk build]),
[
case "${enableval}" in
AC_CONFIG_FILES([Makefile
src/Makefile
+ unittest/Makefile
mm-player.pc
])
AC_OUTPUT
BuildRequires: pkgconfig(libtzplatform-config)
BuildRequires: pkgconfig(capi-media-sound-manager)
BuildRequires: pkgconfig(libtbm)
+%if 0%{?gtests:1}
+BuildRequires: pkgconfig(gmock)
+%endif
%description
Multimedia Framework Player Library files.
LDFLAGS+="-Wl,--rpath=%{_prefix}/lib -Wl,--hash-style=both -Wl,--as-needed"; export LDFLAGS
./autogen.sh
# always enable sdk build. This option should go away
-CFLAGS=$CFLAGS LDFLAGS=$LDFLAGS ./configure --enable-sdk --prefix=%{_prefix} --disable-static
+#CFLAGS=$CFLAGS LDFLAGS=$LDFLAGS ./configure --enable-sdk --prefix=%{_prefix} --disable-static
%configure \
+%if 0%{?gtests:1}
+--enable-tests \
+%endif
--disable-static \
--enable-wayland
%license LICENSE.Apache-2.0
%defattr(-,root,root,-)
%{_libdir}/*.so.*
-
+%if 0%{?gtests:1}
+%{_bindir}/gtest_libmm_player
+%endif
%files devel
%manifest %{name}.manifest
* @since_tizen 3.0
*/
typedef struct {
- gboolean using;
+ gboolean used;
void* bo;
} mm_player_video_bo_info_t;
int __mmplayer_gst_element_add_bucket_to_bin(GstBin* bin, GList* element_bucket);
int __mmplayer_gst_element_link_bucket(GList* element_bucket);
void __mmplayer_typefind_have_type(GstElement *tf, guint probability, GstCaps *caps, gpointer data);
+int __mmplayer_parse_profile(const char *uri, void *param, MMPlayerParseProfile* data);
+
#ifdef __cplusplus
}
for (l = g_list_first(player->video_bo_list); l; l = g_list_next(l)) {
mm_player_video_bo_info_t* tmp = (mm_player_video_bo_info_t *)l->data;
if (tmp && tmp->bo == bo) {
- tmp->using = FALSE;
+ tmp->used = FALSE;
LOGD("release bo %p", bo);
tbm_bo_unref(tmp->bo);
MMPLAYER_VIDEO_BO_UNLOCK(player);
g_free(bo_info);
break;
}
- bo_info->using = FALSE;
+ bo_info->used = FALSE;
player->video_bo_list = g_list_append(player->video_bo_list, bo_info);
}
/* get bo from list*/
for (l = g_list_first(player->video_bo_list); l; l = g_list_next(l)) {
mm_player_video_bo_info_t* tmp = (mm_player_video_bo_info_t *)l->data;
- if (tmp && (tmp->using == FALSE)) {
+ if (tmp && (tmp->used == FALSE)) {
LOGD("found bo %p to use", tmp->bo);
- tmp->using = TRUE;
+ tmp->used = TRUE;
MMPLAYER_VIDEO_BO_UNLOCK(player);
return tbm_bo_ref(tmp->bo);
}
return MM_ERROR_NONE;
}
-static int __mmplayer_parse_profile(const char *uri, void *param, MMPlayerParseProfile* data)
+int __mmplayer_parse_profile(const char *uri, void *param, MMPlayerParseProfile* data)
{
int ret = MM_ERROR_PLAYER_INVALID_URI;
char *path = NULL;
--- /dev/null
+# Unit tests
+bin_PROGRAMS = gtest_libmm_player
+
+gtest_libmm_player_SOURCES = libmm-player_internal.cpp
+
+gtest_libmm_player_CXXFLAGS = -I$(top_srcdir)/src/include \
+ $(MMCOMMON_CFLAGS) \
+ $(MMUTIL_CFLAGS) \
+ $(GST_CFLAGS) \
+ $(GST_VIDEO_CFLAGS) \
+ $(GST_APP_CFLAGS) \
+ $(MMSOUND_CFLAGS) \
+ $(MM_RESOURCE_MANAGER_CFLAGS) \
+ $(ICU_CFLAGS) \
+ $(UTILX_CFLAGS) \
+ $(MEDIAPACKET_CFLAGS) \
+ $(DLOG_CFLAGS) \
+ $(SYSTEMINFO_CFLAGS) \
+ $(STORAGE_CFLAGS) \
+ $(TZPLATFORM_CONFIG_CFLAGS) \
+ $(MEDIASOUNDMGR_CFLAGS) \
+ $(TBM_CFLAGS) \
+ $(GST_ALLOCATORS_CFLAGS) \
+ $(GTESTS_CFLAGS) \
+ -Werror -Wno-deprecated -Wno-deprecated-declarations -Wno-cpp
+
+gtest_libmm_player_DEPENDENCIES = $(top_srcdir)/src/.libs/libmmfplayer.la
+
+gtest_libmm_player_LDADD = \
+ $(GST_LIBS) \
+ $(MMCOMMON_LIBS) \
+ $(MMUTIL_LIBS) \
+ $(GST_INTERFACE_LIBS) \
+ $(GST_VIDEO_LIBS) \
+ $(GST_APP_LIBS) \
+ $(INIPARSER_LIBS) \
+ $(MMSOUND_LIBS) \
+ $(MM_RESOURCE_MANAGER_LIBS) \
+ $(ICU_LIBS) \
+ $(MEDIAPACKET_LIBS) \
+ $(DLOG_LIBS) \
+ $(UTILX_LIBS) \
+ $(SYSTEMINFO_LIBS) \
+ $(STORAGE_LIBS) \
+ $(TZPLATFORM_CONFIG_LIBS) \
+ $(TBM_LIBS) \
+ $(GST_ALLOCATORS_LIBS) \
+ $(GTESTS_LIBS) \
+ $(MEDIASOUNDMGR_LIBS) \
+ $(top_srcdir)/src/.libs/libmmfplayer.la
--- /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 "libmm-player_internal.h"
+#include "mm_error.h"
+#include "mm_player_priv.h"
+
+using ::testing::InitGoogleTest;
+using ::testing::Test;
+using ::testing::TestCase;
+
+class libmm_player_Test : public ::testing::Test {
+ protected:
+ void SetUp() {
+ std::cout << "SetUp()" << std::endl;
+ }
+
+ void TearDown() {
+ std::cout << "TearDown()" << std::endl;
+ }
+};
+
+TEST(libmm_playerTest, __mmplayer_parse_profile_p)
+{
+ int ret = MM_ERROR_NONE;
+ MMPlayerParseProfile profile;
+ gchar* uri = NULL;
+ memset((void*)&profile, 0, sizeof(MMPlayerParseProfile));
+
+ uri = g_strdup("http://test-url");
+ ret = __mmplayer_parse_profile(uri, NULL, &profile);
+ EXPECT_EQ(ret, MM_ERROR_NONE);
+ EXPECT_EQ(profile.uri_type, MM_PLAYER_URI_TYPE_URL_HTTP);
+ g_free(uri);
+ memset((void*)&profile, 0, sizeof(MMPlayerParseProfile));
+}
+
+TEST(libmm_playerTest, __mmplayer_parse_profile_n)
+{
+ int ret = MM_ERROR_NONE;
+ MMPlayerParseProfile profile;
+ gchar* uri = NULL;
+ memset((void*)&profile, 0, sizeof(MMPlayerParseProfile));
+
+ uri = g_strdup("file://non-existing-file.mp4");
+ ret = __mmplayer_parse_profile(uri, NULL, &profile);
+ EXPECT_EQ(ret, MM_ERROR_PLAYER_FILE_NOT_FOUND);
+ g_free(uri);
+ memset((void*)&profile, 0, sizeof(MMPlayerParseProfile));
+}
+
+gint main(gint argc, gchar **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 __LIB_MM_PLAYER_UNITTEST_H__
+#define __LIB_MM_PLAYER_UNITTEST_H__
+
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+#undef LOG_TAG
+#define LOG_TAG "GTEST_LIBMM_PLAYER"
+
+#endif /*__LIB_MM_PLAYER_UNITTEST_H__*/