From: Hyunil Date: Thu, 29 Nov 2018 03:37:37 +0000 (+0900) Subject: Add unittest X-Git-Tag: submit/tizen/20181129.232925^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F92%2F194092%2F3;p=platform%2Fcore%2Fmultimedia%2Flibmm-evas-renderer.git Add unittest Change-Id: I22379443e9df36bd4c4413a6eb7000d0db736ae8 Signed-off-by: Hyunil --- diff --git a/packaging/libmm-evas-renderer.spec b/packaging/libmm-evas-renderer.spec index 49255a8..8ac41b0 100644 --- a/packaging/libmm-evas-renderer.spec +++ b/packaging/libmm-evas-renderer.spec @@ -60,7 +60,7 @@ make %{?jobs:-j%jobs} %defattr(-,root,root,-) %{_libdir}/*.so.* %if 0%{?gtests:1} -%{_bindir}/gtest-libmm-evas-renderer +%{_bindir}/gtests-libmm-evas-renderer %endif %files devel diff --git a/unittest/Makefile.am b/unittest/Makefile.am index ce8cbb6..c57596e 100644 --- a/unittest/Makefile.am +++ b/unittest/Makefile.am @@ -1,9 +1,9 @@ # Unit tests -bin_PROGRAMS = gtest-libmm-evas-renderer +bin_PROGRAMS = gtests-libmm-evas-renderer -gtest_libmm_evas_renderer_SOURCES = libmm_evas_renderer_unittest.cpp +gtests_libmm_evas_renderer_SOURCES = libmm_evas_renderer_unittest.cpp -gtest_libmm_evas_renderer_CXXFLAGS = -I$(top_srcdir)/src/include \ +gtests_libmm_evas_renderer_CXXFLAGS = -I$(top_srcdir)/src/include \ $(MMCOMMON_CFLAGS) \ $(MEDIAPACKET_CFLAGS) \ $(DLOG_CFLAGS) \ @@ -11,13 +11,14 @@ gtest_libmm_evas_renderer_CXXFLAGS = -I$(top_srcdir)/src/include \ $(ECORE_CFLAGS) \ $(ELEMENTARY_CFLAGS) \ $(GLIB_CFLAGS) \ - $(TBM_CFLAGS) \ $(GTESTS_CFLAGS) \ + $(GMOCK_CFLAGS) \ + $(TBM_CFLAGS) \ -Werror -Wno-deprecated -Wno-deprecated-declarations -Wno-cpp -gtest_libmm_evas_renderer_DEPENDENCIES = $(top_srcdir)/src/.libs/libmmfevasrenderer.la +gtests_libmm_evas_renderer_DEPENDENCIES = $(top_srcdir)/src/.libs/libmmfevasrenderer.la -gtest_libmm_evas_renderer_LDADD = \ +gtests_libmm_evas_renderer_LDADD = \ $(GST_LIBS) \ $(MMCOMMON_LIBS) \ $(MEDIAPACKET_LIBS) \ @@ -26,6 +27,7 @@ gtest_libmm_evas_renderer_LDADD = \ $(ECORE_LIBS) \ $(ELEMENTARY_LIBS) \ $(GLIB_LIBS) \ - $(TBM_LIBS) \ $(GTESTS_LIBS) \ + $(GMOCK_LIBS) \ + $(TBM_LIBS) \ $(top_srcdir)/src/.libs/libmmfevasrenderer.la diff --git a/unittest/libmm_evas_renderer_unittest.cpp b/unittest/libmm_evas_renderer_unittest.cpp index 9602979..4b061b1 100644 --- a/unittest/libmm_evas_renderer_unittest.cpp +++ b/unittest/libmm_evas_renderer_unittest.cpp @@ -13,36 +13,263 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include "libmm_evas_renderer_unittest.h" +#include +#include +#include + +enum { + DISP_GEO_METHOD_LETTER_BOX = 0, + DISP_GEO_METHOD_ORIGIN_SIZE, + DISP_GEO_METHOD_FULL_SCREEN, + DISP_GEO_METHOD_CROPPED_FULL_SCREEN, + DISP_GEO_METHOD_ORIGIN_SIZE_OR_LETTER_BOX, + DISP_GEO_METHOD_CUSTOM_ROI, + DISP_GEO_METHOD_NUM, +}; + +enum { + DEGREE_0 = 0, + DEGREE_90, + DEGREE_180, + DEGREE_270, + DEGREE_NUM, +}; + +enum { + FLIP_NONE = 0, + FLIP_HORIZONTAL, + FLIP_VERTICAL, + FLIP_BOTH, + FLIP_NUM, +}; using ::testing::InitGoogleTest; using ::testing::Test; using ::testing::TestCase; +using namespace std; + +static Evas_Object *win; +static Evas_Object *image; + class libmm_evas_renderer_Test : public ::testing::Test { protected: + void *evas_handle = NULL; + void SetUp() { - std::cout << "SetUp()" << std::endl; + if (mm_evas_renderer_create(&evas_handle, image) != MM_ERROR_NONE) + cout << "[ERROR] mm_evas_renderer_create() failed" << endl; } void TearDown() { - std::cout << "TearDown()" << std::endl; + if (evas_handle) { + if (mm_evas_renderer_destroy(&evas_handle) != MM_ERROR_NONE) + cout << "[ERROR] mm_evas_renderer_destroy() failed" << endl; + } } }; -TEST_F(libmm_evas_renderer_Test, mm_evas_renderer_create_p) +static void create_win() +{ + Evas *e = NULL; + cout << "Create winow" << endl; + elm_init(1, NULL); + win = elm_win_add(NULL, "unit_test", ELM_WIN_BASIC); + if (!win) + return; + e = evas_object_evas_get(win); + if (!e) + return; + cout << "Create image" << endl; + image = evas_object_image_add(e); +} + +static void destroy_win() +{ + if (image) { + evas_object_del(image); + image = NULL; + } + + if (win) { + evas_object_del(win); + win = NULL; + } +} + +TEST_F(libmm_evas_renderer_Test, set_visible_p) +{ + int ret = mm_evas_renderer_set_visible(evas_handle, TRUE); + EXPECT_EQ(ret, MM_ERROR_NONE); +} + +TEST_F(libmm_evas_renderer_Test, set_visible_n) +{ + int ret = mm_evas_renderer_set_visible(NULL, TRUE); + EXPECT_EQ(ret, MM_ERROR_EVASRENDER_NOT_INITIALIZED); +} + +TEST_F(libmm_evas_renderer_Test, get_visible_p) +{ + bool visible = FALSE; + + int ret = mm_evas_renderer_set_visible(evas_handle, TRUE); + ASSERT_EQ(ret, MM_ERROR_NONE); + + ret = mm_evas_renderer_get_visible(evas_handle, &visible); + ASSERT_EQ(ret, MM_ERROR_NONE); + EXPECT_EQ(visible, TRUE); +} + +TEST_F(libmm_evas_renderer_Test, get_visible_n) +{ + bool visible = FALSE; + + int ret = mm_evas_renderer_get_visible(NULL, &visible); + EXPECT_EQ(ret, MM_ERROR_EVASRENDER_NOT_INITIALIZED); +} + +TEST_F(libmm_evas_renderer_Test, set_rotation_p) +{ + int ret = mm_evas_renderer_set_rotation(evas_handle, DEGREE_90); + EXPECT_EQ(ret, MM_ERROR_NONE); +} + +TEST_F(libmm_evas_renderer_Test, set_rotation_n) +{ + int ret = mm_evas_renderer_set_rotation(NULL, DEGREE_90); + EXPECT_EQ(ret, MM_ERROR_EVASRENDER_NOT_INITIALIZED); +} + +TEST_F(libmm_evas_renderer_Test, get_rotation_p) +{ + int rotate = -1; + + int ret = mm_evas_renderer_set_rotation(evas_handle, DEGREE_90); + ASSERT_EQ(ret, MM_ERROR_NONE); + + ret = mm_evas_renderer_get_rotation(evas_handle, &rotate); + ASSERT_EQ(ret, MM_ERROR_NONE); + EXPECT_EQ(rotate, DEGREE_90); +} + +TEST_F(libmm_evas_renderer_Test, get_rotation_n) { + int rotate = -1; + int ret = mm_evas_renderer_get_rotation(NULL, &rotate); + EXPECT_EQ(ret, MM_ERROR_EVASRENDER_NOT_INITIALIZED); } -TEST_F(libmm_evas_renderer_Test, mm_evas_renderer_create_n) +TEST_F(libmm_evas_renderer_Test, set_geometry_p) { + int ret = mm_evas_renderer_set_geometry(evas_handle, DISP_GEO_METHOD_LETTER_BOX); + EXPECT_EQ(ret, MM_ERROR_NONE); +} + +TEST_F(libmm_evas_renderer_Test, set_geometry_n) +{ + int ret = mm_evas_renderer_set_geometry(NULL, DISP_GEO_METHOD_LETTER_BOX); + EXPECT_EQ(ret, MM_ERROR_EVASRENDER_NOT_INITIALIZED); +} + +TEST_F(libmm_evas_renderer_Test, get_geometry_p) +{ + int get_mode = -1; + + int ret = mm_evas_renderer_set_geometry(evas_handle, DISP_GEO_METHOD_LETTER_BOX); + ASSERT_EQ(ret, MM_ERROR_NONE); + + ret = mm_evas_renderer_get_geometry(evas_handle, &get_mode); + ASSERT_EQ(ret, MM_ERROR_NONE); + EXPECT_EQ(DISP_GEO_METHOD_LETTER_BOX, get_mode); +} + +TEST_F(libmm_evas_renderer_Test, get_geometry_n) +{ + int mode = -1; + + int ret = mm_evas_renderer_get_geometry(NULL, &mode); + EXPECT_EQ(ret, MM_ERROR_EVASRENDER_NOT_INITIALIZED); +} + +TEST_F(libmm_evas_renderer_Test, set_roi_area_p) +{ + int ret = mm_evas_renderer_set_roi_area(evas_handle, 10, 10, 320, 240); + EXPECT_EQ(ret, MM_ERROR_NONE); +} + +TEST_F(libmm_evas_renderer_Test, set_roi_area_n) +{ + int ret = mm_evas_renderer_set_roi_area(NULL, 10, 10, 320, 240); + EXPECT_EQ(ret, MM_ERROR_EVASRENDER_NOT_INITIALIZED); +} + +TEST_F(libmm_evas_renderer_Test, get_roi_area_p) +{ + int get_x = 0, get_y = 0, get_w = 0, get_h = 0; + + int ret = mm_evas_renderer_set_roi_area(evas_handle, 10, 10, 320, 240); + ASSERT_EQ(ret, MM_ERROR_NONE); + ret = mm_evas_renderer_get_roi_area(evas_handle, &get_x, &get_y, &get_w, &get_h); + ASSERT_EQ(ret, MM_ERROR_NONE); + EXPECT_EQ(10, get_x); + EXPECT_EQ(10, get_y); + EXPECT_EQ(320, get_w); + EXPECT_EQ(240, get_h); +} + +TEST_F(libmm_evas_renderer_Test, get_roi_area_n) +{ + + int get_x = 0, get_y = 0, get_w = 0, get_h = 0; + + int ret = mm_evas_renderer_get_roi_area(NULL, &get_x, &get_y, &get_w, &get_h); + EXPECT_EQ(ret, MM_ERROR_EVASRENDER_NOT_INITIALIZED); +} + +TEST_F(libmm_evas_renderer_Test, set_flip_p) +{ + int ret = mm_evas_renderer_set_flip(evas_handle, FLIP_NONE); + EXPECT_EQ(ret, MM_ERROR_NONE); +} + +TEST_F(libmm_evas_renderer_Test, set_flip_n) +{ + int ret = mm_evas_renderer_set_flip(NULL, FLIP_NONE); + EXPECT_EQ(ret, MM_ERROR_EVASRENDER_NOT_INITIALIZED); +} + +TEST_F(libmm_evas_renderer_Test, get_flip_p) +{ + int get_flip = FLIP_NONE; + + int ret = mm_evas_renderer_set_flip(evas_handle, FLIP_HORIZONTAL); + ASSERT_EQ(ret, MM_ERROR_NONE); + + ret = mm_evas_renderer_get_flip(evas_handle, &get_flip); + ASSERT_EQ(ret, MM_ERROR_NONE); + EXPECT_EQ(FLIP_HORIZONTAL, get_flip); +} + +TEST_F(libmm_evas_renderer_Test, get_flip_n) +{ + int get_flip = FLIP_NONE; + + int ret = mm_evas_renderer_get_flip(NULL, &get_flip); + EXPECT_EQ(ret, MM_ERROR_EVASRENDER_NOT_INITIALIZED); } gint main(gint argc, gchar **argv) { + int ret; + create_win(); InitGoogleTest(&argc, argv); + ret = RUN_ALL_TESTS(); + destroy_win(); - return RUN_ALL_TESTS(); -} + return ret; +} \ No newline at end of file diff --git a/unittest/libmm_evas_renderer_unittest.h b/unittest/libmm_evas_renderer_unittest.h index bc8be51..b080aab 100644 --- a/unittest/libmm_evas_renderer_unittest.h +++ b/unittest/libmm_evas_renderer_unittest.h @@ -16,7 +16,6 @@ #ifndef __LIB_MM_EVAS_RENDERER_UNITTEST_H__ #define __LIB_MM_EVAS_RENDERER_UNITTEST_H__ - #include #include #include