From c405ddd636c45505ae91dd036818f4015fd39537 Mon Sep 17 00:00:00 2001 From: Hoyub Lee Date: Wed, 3 Jan 2018 22:31:55 +0900 Subject: [PATCH] tc: Add test cases for tpl_display Add below tests for tpl_display. TEST CASE | TEST ------------------------------------------------------------------ DEFAULT_tpl_display_get_backend_type | success DEFAULT_tpl_display_get_backend_type | failure DEFAULT_tpl_display_get_native_window_info | success_2 DEFAULT_tpl_display_get_native_pixmap_info | failure DEFAULT_tpl_display_get_buffer_from_native_pixmap | success DEFAULT_tpl_display_get_buffer_from_native_pixmap | failure DEFAULT_tpl_display_query_supported_present_modes | success _from_native_window Change-Id: I2dd81ea35e820441a26df50fee008d55c7ab2943 Signed-off-by: Hoyub Lee --- tc/test/tpl-test_display_test.cpp | 96 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 95 insertions(+), 1 deletion(-) diff --git a/tc/test/tpl-test_display_test.cpp b/tc/test/tpl-test_display_test.cpp index 923538b..af7df80 100644 --- a/tc/test/tpl-test_display_test.cpp +++ b/tc/test/tpl-test_display_test.cpp @@ -127,9 +127,27 @@ TEST_F(DEFAULT_tpl_display_filter_config, failure_invalid_display) } +typedef TPLTestBase DEFAULT_tpl_display_get_backend_type; + +TEST_F(DEFAULT_tpl_display_get_backend_type, success) { + tpl_backend_type_t result; + + result = tpl_display_get_backend_type(backend->display_handle); + ASSERT_NE(TPL_BACKEND_UNKNOWN, result); +} + +TEST_F(DEFAULT_tpl_display_get_backend_type, failure) { + tpl_backend_type_t result; + + result = tpl_display_get_backend_type(NULL); + ASSERT_EQ(TPL_BACKEND_UNKNOWN, result); +} + + typedef TPLTestBase DEFAULT_tpl_display_get_native_window_info; -TEST_F(DEFAULT_tpl_display_get_native_window_info, success) +// Test with alpha size = 8 +TEST_F(DEFAULT_tpl_display_get_native_window_info, success_1) { tpl_result_t result; int width, height; @@ -147,8 +165,44 @@ TEST_F(DEFAULT_tpl_display_get_native_window_info, success) ASSERT_EQ(TPL_ERROR_NONE, result); } +// Test with alpha size = 0 +TEST_F(DEFAULT_tpl_display_get_native_window_info, success_2) +{ + tpl_result_t result; + int width, height; + tbm_format format; + + result = tpl_display_get_native_window_info(backend->tpl_display, + backend->surface_handle, + &width, &height, &format, + config.depth, 0); + + EXPECT_EQ(config.width, width); + EXPECT_EQ(config.height, height); + EXPECT_EQ(TBM_FORMAT_XRGB8888, format); + + ASSERT_EQ(TPL_ERROR_NONE, result); +} + /* TODO: Make test - DEFAULT_tpl_display_get_native_window_info, failure */ + +typedef TPLTestBase DEFAULT_tpl_display_get_native_pixmap_info; + +/* TODO: Make test - DEFAULT_tpl_display_get_native_pixmap_info, success */ + +TEST_F(DEFAULT_tpl_display_get_native_pixmap_info, failure) { + tpl_result_t result; + int width, height; + tbm_format format; + + result = tpl_display_get_native_pixmap_info(backend->tpl_display, NULL, + &width, &height, &format); + + ASSERT_EQ(TPL_ERROR_INVALID_OPERATION, result); +} + + typedef TPLTestBase EXTRA_tpl_display_query_supported_buffer_count_from_native_window; @@ -167,6 +221,46 @@ TEST_F(EXTRA_tpl_display_query_supported_buffer_count_from_native_window, return; } + // TODO: Add check on min and max + ASSERT_EQ(TPL_ERROR_NONE, result); } + +typedef TPLTestBase DEFAULT_tpl_display_get_buffer_from_native_pixmap; + +/* TODO: Make test - DEFAULT_tpl_display_get_native_pixmap_info, success */ + +TEST_F(DEFAULT_tpl_display_get_buffer_from_native_pixmap, success) { + tbm_surface_h tbm_surface; + + tbm_surface = tpl_display_get_buffer_from_native_pixmap(backend->tpl_display, + backend->surface_handle); + + EXPECT_NE((void *)NULL, tbm_surface); +} + +TEST_F(DEFAULT_tpl_display_get_buffer_from_native_pixmap, failure) { + tbm_surface_h tbm_surface; + + EXPECT_DEATH((tbm_surface = tpl_display_get_buffer_from_native_pixmap(backend->tpl_display, NULL)), + ".*Assertion `pixmap' failed\..*"); +} + + +typedef TPLTestBase DEFAULT_tpl_display_query_supported_present_modes_from_native_window; + +TEST_F(DEFAULT_tpl_display_query_supported_present_modes_from_native_window, success) { + tpl_result_t result; + + result = tpl_display_query_supported_present_modes_from_native_window( + backend->tpl_display, backend->surface_handle, NULL); + + // SUCCEED() if backend does not support operation + if (result == TPL_ERROR_INVALID_OPERATION) { + SUCCEED() << "Backend does not support this operation"; + return; + } + + EXPECT_EQ(TPL_ERROR_NONE, result); +} -- 2.7.4