From 8655628cc6dfb24f134438681d250cf2c9227db9 Mon Sep 17 00:00:00 2001 From: Andrii Sokolenko Date: Fri, 10 Nov 2017 17:29:44 +0200 Subject: [PATCH] [utest] Add 34 test cases Change-Id: I688da85318260b6a3ba342eb7b28ce0d1a99b04d Signed-off-by: Andrii Sokolenko --- utests/src/ut_tdm_layer.cpp | 100 ++++++++--- utests/src/ut_tdm_output.cpp | 395 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 469 insertions(+), 26 deletions(-) diff --git a/utests/src/ut_tdm_layer.cpp b/utests/src/ut_tdm_layer.cpp index 98c148e..265281c 100644 --- a/utests/src/ut_tdm_layer.cpp +++ b/utests/src/ut_tdm_layer.cpp @@ -41,7 +41,7 @@ class TDMLayer : public ::testing::Test { protected: tdm_display *dpy = NULL; tbm_bufmgr tbm_bufmgr = NULL; - int master_fd = -42, tbm_fd = -42, layer_count = 0; + int master_fd = -42, tbm_fd = -42, layer_count = 0, output_count = 0; tdm_layer ** tdm_layer_array = NULL; bool has_layers = false; void SetUp(void) @@ -58,32 +58,30 @@ protected: ASSERT_FALSE(dpy == NULL); master_fd = tbm_drm_helper_get_master_fd(); tbm_fd = tbm_drm_helper_get_fd(); - int output_count = 0; - if (tdm_display_get_output_count(dpy, &output_count) == TDM_ERROR_NONE) { - for (int i = 0; i < output_count; i++) { - tdm_output * output = tdm_display_get_output(dpy, i, &error); - if (TDM_ERROR_NONE != error || NULL == output) - continue; - tdm_output_conn_status status = TDM_OUTPUT_CONN_STATUS_DISCONNECTED; - if (TDM_ERROR_NONE != tdm_output_get_conn_status(output, &status)) - continue; - if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED) - continue; - int temp_layer_count = 0; - if (TDM_ERROR_NONE != tdm_output_get_layer_count(output, &temp_layer_count)) - continue; - if (0 == temp_layer_count) - continue; - tdm_layer_array = (tdm_layer **) realloc(tdm_layer_array, - (layer_count + temp_layer_count)*sizeof(tdm_layer *)); - ASSERT_FALSE(NULL == tdm_layer_array); - for (int k = layer_count; k < (layer_count + temp_layer_count); k++) { - tdm_layer_array[k] = tdm_output_get_layer(output, k, &error); - ASSERT_TRUE(TDM_ERROR_NONE == error); - ASSERT_FALSE(NULL == tdm_layer_array[k]); - } - layer_count+=temp_layer_count; + ASSERT_TRUE(tdm_display_get_output_count(dpy, &output_count) == TDM_ERROR_NONE); + for (int i = 0; i < output_count; i++) { + tdm_output * output = tdm_display_get_output(dpy, i, &error); + if (TDM_ERROR_NONE != error || NULL == output) + continue; + tdm_output_conn_status status = TDM_OUTPUT_CONN_STATUS_DISCONNECTED; + if (TDM_ERROR_NONE != tdm_output_get_conn_status(output, &status)) + continue; + if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED) + continue; + int temp_layer_count = 0; + if (TDM_ERROR_NONE != tdm_output_get_layer_count(output, &temp_layer_count)) + continue; + if (0 == temp_layer_count) + continue; + tdm_layer_array = (tdm_layer **) realloc(tdm_layer_array, + (layer_count + temp_layer_count)*sizeof(tdm_layer *)); + ASSERT_FALSE(NULL == tdm_layer_array); + for (int k = layer_count; k < (layer_count + temp_layer_count); k++) { + tdm_layer_array[k] = tdm_output_get_layer(output, k, &error); + ASSERT_TRUE(TDM_ERROR_NONE == error); + ASSERT_FALSE(NULL == tdm_layer_array[k]); } + layer_count+=temp_layer_count; } #ifdef FAIL_ON_UNSUPPORTED @@ -130,3 +128,53 @@ TEST_F(TDMLayer, LayerGetCapabilitiesSuccessful) ASSERT_NE(capabilities, -42); } } + +TEST_F(TDMLayer, LayerGetCapabilitiesFailNullAll) +{ + SKIP_FLAG(has_layers); + ASSERT_EXIT({if (tdm_layer_get_capabilities(NULL, NULL) == TDM_ERROR_NONE) exit(1); + exit(0);}, ::testing::ExitedWithCode(0), ""); +} + +TEST_F(TDMLayer, LayerGetCapabilitiesFailOnlyLayer) +{ + SKIP_FLAG(has_layers); + ASSERT_EXIT({for (int i = 0; i < layer_count; i++) { + if (tdm_layer_get_capabilities(tdm_layer_array[i], NULL) == TDM_ERROR_NONE) exit(1); + } + exit(0);}, ::testing::ExitedWithCode(0), ""); +} + +TEST_F(TDMLayer, OutputGetPrimaryIndexSuccessful) +{ + SKIP_FLAG(has_layers); + for (int i = 0; i < output_count; i++) { + tdm_error error = TDM_ERROR_NONE; + int index = -42; + tdm_output * output = tdm_display_get_output(dpy, i, &error); + ASSERT_FALSE(NULL == output); + ASSERT_TRUE(TDM_ERROR_NONE == error); + ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_primary_index(output, &index)); + ASSERT_NE(index, -42); + } +} + +TEST_F(TDMLayer, OutputGetPrimaryIndexFailNullAll) +{ + SKIP_FLAG(has_layers); + ASSERT_EXIT({if (tdm_output_get_primary_index(NULL, NULL) == TDM_ERROR_NONE) exit(1); + exit(0);}, ::testing::ExitedWithCode(0), ""); +} + +TEST_F(TDMLayer, OutputGetPrimaryIndexFailOnlyOutput) +{ + SKIP_FLAG(has_layers); + ASSERT_EXIT({for (int i = 0; i < output_count; i++) { + tdm_error error = TDM_ERROR_NONE; + tdm_output * output = tdm_display_get_output(dpy, i, &error); + if (NULL == output) exit(1); + if (TDM_ERROR_NONE != error) exit(1); + if (tdm_output_get_primary_index(output, NULL) == TDM_ERROR_NONE) exit(1); + } + exit(0);}, ::testing::ExitedWithCode(0), ""); +} diff --git a/utests/src/ut_tdm_output.cpp b/utests/src/ut_tdm_output.cpp index f510e20..e3178c1 100644 --- a/utests/src/ut_tdm_output.cpp +++ b/utests/src/ut_tdm_output.cpp @@ -245,6 +245,7 @@ TEST_F(TDMOutput, OutputGetConnStatusFailOnlyOutput) TEST_F(TDMOutput, OutputSetDPMSSuccessful) { SKIP_FLAG(has_output); + bool checked = false; for (int i = 0; i < output_count; i++) { tdm_error error = TDM_ERROR_NONE; tdm_output_conn_status status; @@ -254,16 +255,21 @@ TEST_F(TDMOutput, OutputSetDPMSSuccessful) ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_conn_status(output, &status)); if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED) continue; + checked = true; ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON)); ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_STANDBY)); ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_SUSPEND)); ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF)); } + if (false == checked) { + FAIL() << "All outputs are disconnected. Testcase skipped" << std::endl; + } } TEST_F(TDMOutput, OutputAddChangeHandlerSuccessful) { SKIP_FLAG(has_output); + bool checked = false; for (int i = 0; i < output_count; i++) { tdm_error error = TDM_ERROR_NONE; tdm_output * output = tdm_display_get_output(dpy, i, &error); @@ -273,6 +279,7 @@ TEST_F(TDMOutput, OutputAddChangeHandlerSuccessful) ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_conn_status(output, &status)); if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED) continue; + checked = true; ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_add_change_handler(output, tdm_output_change_handler_test_func, (void *) -101)); @@ -280,11 +287,15 @@ TEST_F(TDMOutput, OutputAddChangeHandlerSuccessful) ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF)); ASSERT_GT(handle_call, 0); } + if (false == checked) { + FAIL() << "All outputs are disconnected. Testcase skipped" << std::endl; + } } TEST_F(TDMOutput, OutputAddChangeHandlerSuccessfulFewFuncs) { SKIP_FLAG(has_output); + bool checked = false; for (int i = 0; i < output_count; i++) { tdm_error error = TDM_ERROR_NONE; tdm_output * output = tdm_display_get_output(dpy, i, &error); @@ -294,6 +305,7 @@ TEST_F(TDMOutput, OutputAddChangeHandlerSuccessfulFewFuncs) ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_conn_status(output, &status)); if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED) continue; + checked = true; for (int k = 0; k < 20; k++) { ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_add_change_handler(output, tdm_output_change_handler_test_func, @@ -303,6 +315,9 @@ TEST_F(TDMOutput, OutputAddChangeHandlerSuccessfulFewFuncs) ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF)); ASSERT_GT(handle_call, 20); } + if (false == checked) { + FAIL() << "All outputs are disconnected. Testcase skipped" << std::endl; + } } @@ -337,6 +352,7 @@ TEST_F(TDMOutput, OutputAddChangeHandlerFailWrongOutput) TEST_F(TDMOutput, OutputRemoveChangeHandlerSuccessful) { SKIP_FLAG(has_output); + bool checked = false; for (int i = 0; i < output_count; i++) { tdm_error error = TDM_ERROR_NONE; tdm_output * output = tdm_display_get_output(dpy, i, &error); @@ -346,6 +362,7 @@ TEST_F(TDMOutput, OutputRemoveChangeHandlerSuccessful) ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_conn_status(output, &status)); if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED) continue; + checked = true; ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_add_change_handler(output, tdm_output_change_handler_test_func, (void *) -101)); @@ -358,11 +375,15 @@ TEST_F(TDMOutput, OutputRemoveChangeHandlerSuccessful) ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF)); ASSERT_EQ(handle_call, 0); } + if (false == checked) { + FAIL() << "All outputs are disconnected. Testcase skipped" << std::endl; + } } TEST_F(TDMOutput, OutputRemoveChangeHandlerSuccessfulFewFuncs) { SKIP_FLAG(has_output); + bool checked = false; for (int i = 0; i < output_count; i++) { tdm_error error = TDM_ERROR_NONE; tdm_output * output = tdm_display_get_output(dpy, i, &error); @@ -372,6 +393,7 @@ TEST_F(TDMOutput, OutputRemoveChangeHandlerSuccessfulFewFuncs) ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_conn_status(output, &status)); if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED) continue; + checked = true; for (int k = 0; k < 20; k++) { ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_add_change_handler(output, tdm_output_change_handler_test_func, @@ -388,6 +410,9 @@ TEST_F(TDMOutput, OutputRemoveChangeHandlerSuccessfulFewFuncs) ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF)); ASSERT_EQ(handle_call, 0); } + if (false == checked) { + FAIL() << "All outputs are disconnected. Testcase skipped" << std::endl; + } } TEST_F(TDMOutput, OutputRemoveChangeHandlerFailAllNull) @@ -466,3 +491,373 @@ TEST_F(TDMOutput, OutputGetLayerCountSuccessful) ASSERT_NE(count, -42); } } + +TEST_F(TDMOutput, OutputGetLayerCountFailNullAll) +{ + SKIP_FLAG(has_output); + ASSERT_EXIT({if (tdm_output_get_layer_count(NULL, NULL) == TDM_ERROR_NONE) exit(1); + exit(0);}, ::testing::ExitedWithCode(0), ""); +} + +TEST_F(TDMOutput, OutputGetLayerCountFailOnlyOutput) +{ + SKIP_FLAG(has_output); + ASSERT_EXIT({for (int i = 0; i < output_count; i++) { + tdm_error error = TDM_ERROR_NONE; + tdm_output * output = tdm_display_get_output(dpy, i, &error); + if (NULL == output) exit(1); + if (TDM_ERROR_NONE != error) exit(1); + if (TDM_ERROR_NONE == tdm_output_get_layer_count(output, NULL)) exit(1); + } + exit(0);}, ::testing::ExitedWithCode(0), ""); +} + +TEST_F(TDMOutput, OutputGetAvailablePropertiesSuccessful) +{ + SKIP_FLAG(has_output); + for (int i = 0; i < output_count; i++) { + tdm_error error = TDM_ERROR_NONE; + int count = -42; + const tdm_prop *tdm_prop_array = (const tdm_prop *) 0xBEAF; + tdm_output * output = tdm_display_get_output(dpy, i, &error); + ASSERT_FALSE(NULL == output); + ASSERT_TRUE(TDM_ERROR_NONE == error); + ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_available_properties(output, + &tdm_prop_array, + &count)); + ASSERT_NE(count, -42); + ASSERT_NE(tdm_prop_array, 0xBEAF); + } +} + +TEST_F(TDMOutput, OutputGetAvailablePropertiesFailNullAll) +{ + SKIP_FLAG(has_output); + ASSERT_EXIT({if (tdm_output_get_available_properties(NULL, NULL, NULL) == TDM_ERROR_NONE) exit(1); + exit(0);}, ::testing::ExitedWithCode(0), ""); +} + +TEST_F(TDMOutput, OutputGetAvailablePropertiesFailOnlyOutput) +{ + SKIP_FLAG(has_output); + ASSERT_EXIT({for (int i = 0; i < output_count; i++) { + tdm_error error = TDM_ERROR_NONE; + tdm_output * output = tdm_display_get_output(dpy, i, &error); + if (NULL == output) exit(1); + if (TDM_ERROR_NONE != error) exit(1); + if (TDM_ERROR_NONE == tdm_output_get_available_properties(output, NULL, NULL)) exit(1); + } + exit(0);}, ::testing::ExitedWithCode(0), ""); +} + +TEST_F(TDMOutput, OutputGetAvailablePropertiesFailNullCount) +{ + SKIP_FLAG(has_output); + ASSERT_EXIT({for (int i = 0; i < output_count; i++) { + tdm_error error = TDM_ERROR_NONE; + const tdm_prop *tdm_prop_array = NULL; + tdm_output * output = tdm_display_get_output(dpy, i, &error); + if (NULL == output) exit(1); + if (TDM_ERROR_NONE != error) exit(1); + if (TDM_ERROR_NONE == tdm_output_get_available_properties(output, + &tdm_prop_array, + NULL)) exit(1); + } + exit(0);}, ::testing::ExitedWithCode(0), ""); +} + +TEST_F(TDMOutput, OutputGetAvailablePropertiesFailNullProperty) +{ + SKIP_FLAG(has_output); + ASSERT_EXIT({for (int i = 0; i < output_count; i++) { + tdm_error error = TDM_ERROR_NONE; + int count = -42; + tdm_output * output = tdm_display_get_output(dpy, i, &error); + if (NULL == output) exit(1); + if (TDM_ERROR_NONE != error) exit(1); + if (TDM_ERROR_NONE == tdm_output_get_available_properties(output, + NULL, + &count)) exit(1); + } + exit(0);}, ::testing::ExitedWithCode(0), ""); +} + +TEST_F(TDMOutput, OutputGetAvailableModesSuccessful) +{ + SKIP_FLAG(has_output); + for (int i = 0; i < output_count; i++) { + tdm_error error = TDM_ERROR_NONE; + int count = -42; + const tdm_output_mode *modes_array = (const tdm_output_mode *) 0xBEAF; + tdm_output * output = tdm_display_get_output(dpy, i, &error); + ASSERT_FALSE(NULL == output); + ASSERT_TRUE(TDM_ERROR_NONE == error); + ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_available_modes(output, + &modes_array, + &count)); + ASSERT_NE(count, -42); + ASSERT_NE(modes_array, 0xBEAF); + } +} + +TEST_F(TDMOutput, OutputGetAvailableModesFailNullAll) +{ + SKIP_FLAG(has_output); + ASSERT_EXIT({if (tdm_output_get_available_modes(NULL, NULL, NULL) == TDM_ERROR_NONE) exit(1); + exit(0);}, ::testing::ExitedWithCode(0), ""); +} + +TEST_F(TDMOutput, OutputGetAvailableModesFailOnlyOutput) +{ + SKIP_FLAG(has_output); + ASSERT_EXIT({for (int i = 0; i < output_count; i++) { + tdm_error error = TDM_ERROR_NONE; + tdm_output * output = tdm_display_get_output(dpy, i, &error); + if (NULL == output) exit(1); + if (TDM_ERROR_NONE != error) exit(1); + if (TDM_ERROR_NONE == tdm_output_get_available_modes(output, NULL, NULL)) exit(1); + } + exit(0);}, ::testing::ExitedWithCode(0), ""); +} + +TEST_F(TDMOutput, OutputGetAvailableModesFailNullCount) +{ + SKIP_FLAG(has_output); + ASSERT_EXIT({for (int i = 0; i < output_count; i++) { + tdm_error error = TDM_ERROR_NONE; + const tdm_output_mode *modes_array = NULL; + tdm_output * output = tdm_display_get_output(dpy, i, &error); + if (NULL == output) exit(1); + if (TDM_ERROR_NONE != error) exit(1); + if (TDM_ERROR_NONE == tdm_output_get_available_modes(output, + &modes_array, + NULL)) exit(1); + } + exit(0);}, ::testing::ExitedWithCode(0), ""); +} + +TEST_F(TDMOutput, OutputGetAvailableModesFailNullModes) +{ + SKIP_FLAG(has_output); + ASSERT_EXIT({for (int i = 0; i < output_count; i++) { + tdm_error error = TDM_ERROR_NONE; + int count = -42; + tdm_output * output = tdm_display_get_output(dpy, i, &error); + if (NULL == output) exit(1); + if (TDM_ERROR_NONE != error) exit(1); + if (TDM_ERROR_NONE == tdm_output_get_available_modes(output, + NULL, + &count)) exit(1); + } + exit(0);}, ::testing::ExitedWithCode(0), ""); +} + +TEST_F(TDMOutput, OutputGetAvailableSizeSuccessful) +{ + SKIP_FLAG(has_output); + for (int i = 0; i < output_count; i++) { + tdm_error error = TDM_ERROR_NONE; + int min_w = -42, min_h = -42, max_w = -42, max_h = -42, preferred_align = -42; + tdm_output * output = tdm_display_get_output(dpy, i, &error); + ASSERT_FALSE(NULL == output); + ASSERT_TRUE(TDM_ERROR_NONE == error); + ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_available_size(output, &min_w, &min_h, + &max_w, &max_h, &preferred_align)); + ASSERT_NE(min_w, -42); + ASSERT_NE(min_h, -42); + ASSERT_NE(max_w, -42); + ASSERT_NE(max_h, -42); + ASSERT_NE(preferred_align, -42); + } +} + +TEST_F(TDMOutput, OutputGetAvailableSizeFailNullAll) +{ + SKIP_FLAG(has_output); + ASSERT_EXIT({if (tdm_output_get_available_size(NULL, NULL, NULL, + NULL, NULL, NULL) == TDM_ERROR_NONE) exit(1); + exit(0);}, ::testing::ExitedWithCode(0), ""); +} + +TEST_F(TDMOutput, OutputGetAvailableSizeSuccessfulOnlyOutput) +{ + SKIP_FLAG(has_output); + ASSERT_EXIT({for (int i = 0; i < output_count; i++) { + tdm_error error = TDM_ERROR_NONE; + tdm_output * output = tdm_display_get_output(dpy, i, &error); + if (NULL == output) exit(1); + if (TDM_ERROR_NONE != error) exit(1); + if (tdm_output_get_available_size(output, NULL, NULL, + NULL, NULL, NULL) != TDM_ERROR_NONE) exit(1); + } + exit(0);}, ::testing::ExitedWithCode(0), ""); +} + +TEST_F(TDMOutput, OutputGetCursorAvailableSizeSuccessful) +{ + SKIP_FLAG(has_output); + for (int i = 0; i < output_count; i++) { + tdm_error error = TDM_ERROR_NONE; + int min_w = -42, min_h = -42, max_w = -42, max_h = -42, preferred_align = -42; + tdm_output * output = tdm_display_get_output(dpy, i, &error); + ASSERT_FALSE(NULL == output); + ASSERT_TRUE(TDM_ERROR_NONE == error); + ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_cursor_available_size(output, &min_w, &min_h, + &max_w, &max_h, &preferred_align)); + ASSERT_NE(min_w, -42); + ASSERT_NE(min_h, -42); + ASSERT_NE(max_w, -42); + ASSERT_NE(max_h, -42); + ASSERT_NE(preferred_align, -42); + } +} + +TEST_F(TDMOutput, OutputGetCursorAvailableSizeFailNullAll) +{ + SKIP_FLAG(has_output); + ASSERT_EXIT({if (tdm_output_get_cursor_available_size(NULL, NULL, NULL, + NULL, NULL, NULL) == TDM_ERROR_NONE) exit(1); + exit(0);}, ::testing::ExitedWithCode(0), ""); +} + +TEST_F(TDMOutput, OutputGetCursorAvailableSizeSuccessfulOnlyOutput) +{ + SKIP_FLAG(has_output); + ASSERT_EXIT({for (int i = 0; i < output_count; i++) { + tdm_error error = TDM_ERROR_NONE; + tdm_output * output = tdm_display_get_output(dpy, i, &error); + if (NULL == output) exit(1); + if (TDM_ERROR_NONE != error) exit(1); + if (tdm_output_get_cursor_available_size(output, NULL, NULL, + NULL, NULL, NULL) != TDM_ERROR_NONE) exit(1); + } + exit(0);}, ::testing::ExitedWithCode(0), ""); +} + +TEST_F(TDMOutput, OutputGetPhysicalSizeSuccessful) +{ + SKIP_FLAG(has_output); + for (int i = 0; i < output_count; i++) { + tdm_error error = TDM_ERROR_NONE; + unsigned int mmWidth = UINT_MAX, mmHeight = UINT_MAX; + tdm_output * output = tdm_display_get_output(dpy, i, &error); + ASSERT_FALSE(NULL == output); + ASSERT_TRUE(TDM_ERROR_NONE == error); + ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_physical_size(output, &mmWidth, &mmHeight)); + ASSERT_NE(mmWidth, UINT_MAX); + ASSERT_NE(mmHeight, UINT_MAX); + } +} + +TEST_F(TDMOutput, OutputGetPhysicalSizeFailNullAll) +{ + SKIP_FLAG(has_output); + ASSERT_EXIT({if (tdm_output_get_physical_size(NULL, NULL, NULL) == TDM_ERROR_NONE) exit(1); + exit(0);}, ::testing::ExitedWithCode(0), ""); +} + +TEST_F(TDMOutput, OutputGetPhysicalSuccessfulOnlyOutput) +{ + SKIP_FLAG(has_output); + ASSERT_EXIT({for (int i = 0; i < output_count; i++) { + tdm_error error = TDM_ERROR_NONE; + tdm_output * output = tdm_display_get_output(dpy, i, &error); + if (NULL == output) exit(1); + if (TDM_ERROR_NONE != error) exit(1); + if (tdm_output_get_physical_size(output, NULL, NULL) != TDM_ERROR_NONE) exit(1); + } + exit(0);}, ::testing::ExitedWithCode(0), ""); +} + +TEST_F(TDMOutput, OutputGetSubpixelSuccessful) +{ + SKIP_FLAG(has_output); + for (int i = 0; i < output_count; i++) { + tdm_error error = TDM_ERROR_NONE; + unsigned int subpixel = UINT_MAX; + tdm_output * output = tdm_display_get_output(dpy, i, &error); + ASSERT_FALSE(NULL == output); + ASSERT_TRUE(TDM_ERROR_NONE == error); + ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_subpixel(output, &subpixel)); + ASSERT_NE(subpixel, UINT_MAX); + } +} + +TEST_F(TDMOutput, OutputGetSubpixelFailNullAll) +{ + SKIP_FLAG(has_output); + ASSERT_EXIT({if (tdm_output_get_subpixel(NULL, NULL) == TDM_ERROR_NONE) exit(1); + exit(0);}, ::testing::ExitedWithCode(0), ""); +} + +TEST_F(TDMOutput, OutputGetSubpixelFailOnlyOutput) +{ + SKIP_FLAG(has_output); + ASSERT_EXIT({for (int i = 0; i < output_count; i++) { + tdm_error error = TDM_ERROR_NONE; + tdm_output * output = tdm_display_get_output(dpy, i, &error); + if (NULL == output) exit(1); + if (TDM_ERROR_NONE != error) exit(1); + if (tdm_output_get_subpixel(output, NULL) == TDM_ERROR_NONE) exit(1); + } + exit(0);}, ::testing::ExitedWithCode(0), ""); +} + +TEST_F(TDMOutput, OutputGetPipeSuccessful) +{ + SKIP_FLAG(has_output); + for (int i = 0; i < output_count; i++) { + tdm_error error = TDM_ERROR_NONE; + unsigned int pipe = UINT_MAX; + tdm_output * output = tdm_display_get_output(dpy, i, &error); + ASSERT_FALSE(NULL == output); + ASSERT_TRUE(TDM_ERROR_NONE == error); + ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_pipe(output, &pipe)); + ASSERT_NE(pipe, UINT_MAX); + } +} + +TEST_F(TDMOutput, OutputGetPipeFailNullAll) +{ + SKIP_FLAG(has_output); + ASSERT_EXIT({if (tdm_output_get_pipe(NULL, NULL) == TDM_ERROR_NONE) exit(1); + exit(0);}, ::testing::ExitedWithCode(0), ""); +} + +TEST_F(TDMOutput, OutputGetPipeFailOnlyOutput) +{ + SKIP_FLAG(has_output); + ASSERT_EXIT({for (int i = 0; i < output_count; i++) { + tdm_error error = TDM_ERROR_NONE; + tdm_output * output = tdm_display_get_output(dpy, i, &error); + if (NULL == output) exit(1); + if (TDM_ERROR_NONE != error) exit(1); + if (tdm_output_get_pipe(output, NULL) == TDM_ERROR_NONE) exit(1); + } + exit(0);}, ::testing::ExitedWithCode(0), ""); +} + +TEST_F(TDMOutput, OutputSetPropertySuccessful) +{ + SKIP_FLAG(has_output); + for (int i = 0; i < output_count; i++) { + tdm_error error = TDM_ERROR_NONE; + tdm_value value = {.u32 = 0}; + tdm_output * output = tdm_display_get_output(dpy, i, &error); + ASSERT_FALSE(NULL == output); + ASSERT_TRUE(TDM_ERROR_NONE == error); + error = tdm_output_set_property(output, UINT_MAX, value); + ASSERT_TRUE(error == TDM_ERROR_NOT_IMPLEMENTED || error == TDM_ERROR_OPERATION_FAILED); + } +} + +TEST_F(TDMOutput, OutputSetPropertyFailNullAll) +{ + SKIP_FLAG(has_output); + ASSERT_EXIT({tdm_error error = TDM_ERROR_NONE; + tdm_value value = {.u32 = 0}; + error = tdm_output_set_property(NULL, 0, value); + if (error == TDM_ERROR_NONE || error == TDM_ERROR_NOT_IMPLEMENTED || + error == TDM_ERROR_OPERATION_FAILED) exit(1); + exit(0);}, ::testing::ExitedWithCode(0), ""); +} -- 2.7.4