#include "tbm_stubs.h"
#include "stub_pthread.h"
-#include "tdm_list_stubs.h"
#include "stub_stdlib.h"
#include "stub_backend.h"
#include "stub_tdm_pp.h"
#include "stub_tdm_event_loop.h"
#include "stub_tdm_buffer.h"
#include "stub_unistd.h"
+#include "stub_tdm_thread.h"
+#include "stub_tdm.h"
+#include "stub_tdm_buffer.h"
+#include "stub_tdm_helper.h"
+#include "tdm_list.h"
#include "tdm_display.c"
static void _init_test()
{
+ stub_tdm_helper_init();
+ stub_tdm_buffer_init();
+ stub_tdm_init();
+ stub_unistd_init();
+ stub_tdm_thread_init();
stub_pthread_init();
stub_tdm_event_loop_init();
stub_tdm_thread_init();
stub_backend_init();
stub_tbm_init();
stub_stdlib_init();
+ tdm_debug_module = TDM_DEBUG_THREAD | TDM_DEBUG_BUFFER;
+ tdm_debug_dump = TDM_DUMP_FLAG_LAYER;
+ tdm_dump_enable = 1;
}
static void ut_tdm_output_vblank_handler(tdm_output *output,
tdm_private_layer layer;
tdm_private_output private_output;
tdm_private_display private_display;
+ struct _tbm_surface waiting_buffer;
+ struct _tbm_surface showing_buffer;
_init_test();
layer.private_output = &private_output;
private_output.private_display = &private_display;
- layer.waiting_buffer = NULL;
- layer.showing_buffer = NULL;
+ layer.waiting_buffer = &waiting_buffer;
+ layer.showing_buffer = &showing_buffer;
private_display.func_layer.layer_unset_buffer = layer_unset_buffer;
error = tdm_layer_unset_buffer_queue(&layer);
ASSERT_EQ(error, expected_error);
+ ASSERT_EQ(stub_tdm_buffer_unref_backend_count, 2);
+ ASSERT_EQ(tbm_surface_queue_release_count, 2);
+ ASSERT_TRUE(layer.waiting_buffer == NULL);
+ ASSERT_TRUE(layer.showing_buffer == NULL);
}
TEST(tdm_layer_unset_buffer_queue, work_flow_success_2)
tdm_private_layer layer;
tdm_private_output private_output;
tdm_private_display private_display;
+ struct _tbm_surface waiting_buffer;
_init_test();
private_output.private_display = &private_display;
private_display.func_layer.layer_set_buffer = layer_set_buffer;
layer.buffer_queue = NULL;
- layer.waiting_buffer = NULL;
+ layer.waiting_buffer = &waiting_buffer;
error = tdm_layer_set_buffer_queue(&layer, &buffer_queue);
ASSERT_EQ(error, expected_error);
+ ASSERT_EQ(stub_tdm_buffer_unref_backend_count, 1);
+ ASSERT_EQ(tbm_surface_queue_release_count, 1);
+ ASSERT_TRUE(layer.waiting_buffer == NULL);
}
TEST(tdm_layer_set_buffer_queue, work_flow_success_2)
tdm_private_layer layer;
tdm_private_output private_output;
tdm_private_display private_display;
+ struct _tbm_surface waiting_buffer;
+ struct _tbm_surface showing_buffer;
_init_test();
layer.private_output = &private_output;
private_output.private_display = &private_display;
- layer.waiting_buffer = NULL;
- layer.showing_buffer = NULL;
+ layer.waiting_buffer = &waiting_buffer;
+ layer.showing_buffer = &showing_buffer;
private_display.func_layer.layer_unset_buffer = layer_unset_buffer;
error = tdm_layer_unset_buffer(&layer);
ASSERT_EQ(error, expected_error);
+ ASSERT_EQ(stub_tdm_buffer_unref_backend_count, 2);
}
TEST(tdm_layer_unset_buffer, work_flow_success_2)
tdm_private_layer layer;
tdm_private_output private_output;
tdm_private_display private_display;
+ struct _tbm_surface waiting_buffer;
_init_test();
+ layer.caps.capabilities = TDM_LAYER_CAPABILITY_GRAPHIC;
layer.private_output = &private_output;
private_output.private_display = &private_display;
- layer.waiting_buffer = NULL;
+ layer.waiting_buffer = &waiting_buffer;
private_display.func_layer.layer_set_buffer = layer_set_buffer;
error = tdm_layer_set_buffer(&layer, &buffer);
_init_test();
+ layer.usable = 1;
+ info.src_config.format = 0;
layer.private_output = &private_output;
private_output.private_display = &private_display;
private_display.func_layer.layer_set_info = layer_set_info;
_init_test();
+ info.src_config.format = 1;
layer.private_output = &private_output;
private_output.private_display = &private_display;
private_display.func_layer.layer_set_info = layer_set_info;
/* tdm_output_set_dpms() */
-TEST(tdm_output_set_dpms, work_flow_success_3)
+TEST(tdm_output_set_dpms, error_output_is_null)
{
- tdm_error error = TDM_ERROR_INVALID_PARAMETER;
- tdm_error expected_error = TDM_ERROR_NONE;
+ tdm_error error = TDM_ERROR_NONE;
+ tdm_error expected_error = TDM_ERROR_INVALID_PARAMETER;
tdm_output_dpms dpms_value = TDM_OUTPUT_DPMS_OFF;
+
+ _init_test();
+
+ error = tdm_output_set_dpms(NULL, dpms_value);
+
+ ASSERT_EQ(error, expected_error);
+}
+
+TEST(tdm_output_set_dpms, success_dpms_is_already_set)
+{
+ tdm_error error;
+ tdm_output_dpms dpms_value = (tdm_output_dpms)10;
tdm_private_output output;
tdm_private_display private_display;
_init_test();
+ output.current_dpms_value = TDM_OUTPUT_DPMS_OFF;
+
output.private_display = &private_display;
- private_display.func_output.output_set_dpms = output_set_dpms;
- output.dpms_changed_timer = 1;
error = tdm_output_set_dpms(&output, dpms_value);
- ASSERT_EQ(error, expected_error);
+ ASSERT_EQ(error, TDM_ERROR_NONE);
}
-TEST(tdm_output_set_dpms, work_flow_success_2)
+TEST(tdm_output_set_dpms, error_event_loop_add_timer_handler_error)
{
- tdm_error error = TDM_ERROR_NONE;
- tdm_error not_expected_error = TDM_ERROR_NONE;
- tdm_output_dpms dpms_value = TDM_OUTPUT_DPMS_ON;
+ tdm_error error;
+ tdm_output_dpms dpms_value = TDM_OUTPUT_DPMS_OFF;
+ tdm_private_output output;
+ tdm_private_display private_display;
+
+ _init_test();
+
+ LIST_INITHEAD(&output.change_handler_list_sub);
+
+ stub_tdm_event_loop_add_timer_handler_error = 1;
+ output.dpms_changed_timer = NULL;
+ output.current_dpms_value = TDM_OUTPUT_DPMS_ON;
+ output.private_display = &private_display;
+
+ error = tdm_output_set_dpms(&output, dpms_value);
+
+ ASSERT_EQ(error, TDM_ERROR_OUT_OF_MEMORY);
+}
+
+TEST(tdm_output_set_dpms, success_output_set_dpms_is_null)
+{
+ tdm_error error;
+ tdm_output_dpms dpms_value = TDM_OUTPUT_DPMS_OFF;
+ tdm_private_output output;
+ tdm_private_display private_display;
+ tdm_func_output func_output;
+
+ _init_test();
+
+ LIST_INITHEAD(&output.change_handler_list_sub);
+
+ output.dpms_changed_timer = NULL;
+ output.current_dpms_value = TDM_OUTPUT_DPMS_ON;
+ output.private_display = &private_display;
+
+ func_output.output_set_dpms = NULL;
+
+ private_display.func_output = func_output;
+
+ error = tdm_output_set_dpms(&output, dpms_value);
+
+ ASSERT_EQ(error, TDM_ERROR_NONE);
+}
+
+TEST(tdm_output_set_dpms, error_output_set_dpms)
+{
+ tdm_error error;
+ tdm_output_dpms dpms_value = TDM_OUTPUT_DPMS_OFF;
tdm_private_output output;
tdm_private_display private_display;
+ tdm_func_output func_output;
_init_test();
+ LIST_INITHEAD(&output.change_handler_list_sub);
+
+ output.dpms_changed_timer = NULL;
+ output.current_dpms_value = TDM_OUTPUT_DPMS_ON;
output.private_display = &private_display;
- private_display.func_output.output_set_dpms = output_set_dpms;
+
+ func_output.output_set_dpms = output_set_dpms;
+ func_output.output_set_dpms_handler = NULL;
+
+ private_display.func_output = func_output;
+
OUTPUT_SET_DPMS_ERROR = 1;
error = tdm_output_set_dpms(&output, dpms_value);
- ASSERT_NE(error, not_expected_error);
+ ASSERT_EQ(error, TDM_ERROR_OPERATION_FAILED);
}
-TEST(tdm_output_set_dpms, work_flow_success_1)
+TEST(tdm_output_set_dpms, error_output_set_dpms_handler_is_null)
{
- tdm_error error = TDM_ERROR_NONE;
- tdm_error expected_error = TDM_ERROR_NONE;
+ tdm_error error;
tdm_output_dpms dpms_value = TDM_OUTPUT_DPMS_OFF;
tdm_private_output output;
tdm_private_display private_display;
+ tdm_func_output func_output;
+ tdm_private_change_handler change_handler;
_init_test();
+ stub_tdm_event_loop_source_timer_update_error = 1;
+
+ LIST_INITHEAD(&output.change_handler_list_sub);
+ LIST_INITHEAD(&output.change_handler_list_main);
+ LIST_ADD(&change_handler.link, &output.change_handler_list_sub);
+
+ output.dpms_changed_timer = NULL;
+ output.current_dpms_value = TDM_OUTPUT_DPMS_ON;
output.private_display = &private_display;
- private_display.func_output.output_set_dpms = NULL;
+
+ func_output.output_set_dpms = output_set_dpms;
+ func_output.output_set_dpms_handler = NULL;
+
+ private_display.func_output = func_output;
error = tdm_output_set_dpms(&output, dpms_value);
- ASSERT_EQ(error, expected_error);
+ ASSERT_EQ(error, TDM_ERROR_OPERATION_FAILED);
}
-TEST(tdm_output_set_dpms, null_ptr_fail_1)
+TEST(tdm_output_set_dpms, success_output_set_dpms_handler_is_null)
{
- tdm_error error = TDM_ERROR_NONE;
- tdm_error expected_error = TDM_ERROR_INVALID_PARAMETER;
+ tdm_error error;
tdm_output_dpms dpms_value = TDM_OUTPUT_DPMS_OFF;
+ tdm_private_output output;
+ tdm_private_display private_display;
+ tdm_func_output func_output;
+ tdm_private_change_handler change_handler;
_init_test();
- error = tdm_output_set_dpms(NULL, dpms_value);
+ LIST_INITHEAD(&output.change_handler_list_sub);
+ LIST_INITHEAD(&output.change_handler_list_main);
+ LIST_ADD(&change_handler.link, &output.change_handler_list_sub);
- ASSERT_EQ(error, expected_error);
+ output.dpms_changed_timer = NULL;
+ output.current_dpms_value = TDM_OUTPUT_DPMS_ON;
+ output.private_display = &private_display;
+
+ func_output.output_set_dpms = output_set_dpms;
+ func_output.output_set_dpms_handler = NULL;
+
+ private_display.func_output = func_output;
+
+ error = tdm_output_set_dpms(&output, dpms_value);
+
+ ASSERT_EQ(error, TDM_ERROR_NONE);
+}
+
+TEST(tdm_output_set_dpms, success_output_set_dpms_handler_is_not_null)
+{
+ tdm_error error;
+ tdm_output_dpms dpms_value = TDM_OUTPUT_DPMS_OFF;
+ tdm_private_output output;
+ tdm_private_display private_display;
+ tdm_func_output func_output;
+
+ _init_test();
+
+ stub_tdm_event_loop_source_timer_update_error = 1;
+
+ LIST_INITHEAD(&output.change_handler_list_sub);
+ LIST_INITHEAD(&output.change_handler_list_main);
+
+ output.dpms_changed_timer = NULL;
+ output.current_dpms_value = TDM_OUTPUT_DPMS_ON;
+ output.private_display = &private_display;
+ output.regist_dpms_cb = 0;
+
+ func_output.output_set_dpms = output_set_dpms;
+ func_output.output_set_dpms_handler = output_set_dpms_handler;
+
+ private_display.func_output = func_output;
+
+ error = tdm_output_set_dpms(&output, dpms_value);
+
+ ASSERT_EQ(error, TDM_ERROR_NONE);
}
/* tdm_output_get_mode() */
_init_test();
+ LIST_INITHEAD(&output.commit_handler_list);
+
output.private_display = &private_display;
private_display.func_output.output_commit = NULL;
output.current_dpms_value = TDM_OUTPUT_DPMS_OFF;
_init_test();
+ LIST_INITHEAD(&output.commit_handler_list);
+
output.private_display = &private_display;
private_display.func_output.output_commit = output_commit;
private_display.func_output.output_set_commit_handler =
_init_test();
+ LIST_INITHEAD(&output.commit_handler_list);
+
output.private_display = &private_display;
private_display.func_output.output_commit = output_commit;
private_display.func_output.output_set_commit_handler =
_init_test();
+ LIST_INITHEAD(&output.commit_handler_list);
+
output.private_display = &private_display;
private_display.func_output.output_commit = output_commit;
private_display.func_output.output_set_commit_handler =
_init_test();
+ LIST_INITHEAD(&output.commit_handler_list);
+
output.private_display = &private_display;
private_display.func_output.output_commit = output_commit;
OUTPUT_COMMIT_ERROR = 1;
_init_test();
+ LIST_INITHEAD(&output.commit_handler_list);
+
output.private_display = &private_display;
private_display.func_output.output_commit = output_commit;
CALLOC_ERROR = 1;
_init_test();
+ LIST_INITHEAD(&output.commit_handler_list);
+
output.private_display = &private_display;
private_display.func_output.output_commit = NULL;
output.current_dpms_value = TDM_OUTPUT_DPMS_ON;
_init_test();
+ LIST_INITHEAD(&output.vblank_handler_list);
+
output.private_display = &private_display;
private_display.func_output.output_wait_vblank = NULL;
output.current_dpms_value = TDM_OUTPUT_DPMS_STANDBY;
_init_test();
+ LIST_INITHEAD(&output.vblank_handler_list);
+
output.private_display = &private_display;
private_display.func_output.output_wait_vblank = output_wait_vblank;
private_display.func_output.output_set_vblank_handler =
_init_test();
+ LIST_INITHEAD(&output.vblank_handler_list);
+
output.private_display = &private_display;
private_display.func_output.output_wait_vblank = output_wait_vblank;
private_display.func_output.output_set_vblank_handler =
_init_test();
+ LIST_INITHEAD(&output.vblank_handler_list);
+
output.private_display = &private_display;
private_display.func_output.output_wait_vblank = output_wait_vblank;
private_display.func_output.output_set_vblank_handler =
_init_test();
+ LIST_INITHEAD(&output.vblank_handler_list);
+
output.private_display = &private_display;
private_display.func_output.output_wait_vblank = output_wait_vblank;
OUTPUT_WAIT_VBLANK_ERROR = 1;
_init_test();
+ LIST_INITHEAD(&output.vblank_handler_list);
+
output.private_display = &private_display;
private_display.func_output.output_wait_vblank = output_wait_vblank;
CALLOC_ERROR = 1;
_init_test();
+ LIST_INITHEAD(&output.vblank_handler_list);
+
output.private_display = &private_display;
private_display.func_output.output_wait_vblank = NULL;
output.current_dpms_value = TDM_OUTPUT_DPMS_ON;
/* tdm_output_get_layer() */
-TEST(tdm_output_get_layer, work_flow_success_1)
+TEST(tdm_output_get_layer, success_get_layer)
+{
+ tdm_error error = TDM_ERROR_INVALID_PARAMETER;
+ tdm_error expected_error = TDM_ERROR_NONE;
+ tdm_private_output output;
+ tdm_private_layer private_layer;
+ tdm_layer *layer;
+
+ _init_test();
+
+ private_layer.index = 15;
+
+ LIST_INITHEAD(&output.layer_list);
+ LIST_ADD(&private_layer.link, &output.layer_list);
+
+ layer = tdm_output_get_layer(&output, 15, &error);
+
+ ASSERT_EQ(error, expected_error);
+ ASSERT_TRUE(layer == &private_layer);
+}
+
+TEST(tdm_output_get_layer, success_list_is_empty)
{
tdm_error error = TDM_ERROR_INVALID_PARAMETER;
tdm_error expected_error = TDM_ERROR_NONE;
tdm_private_output output;
+ tdm_layer *layer;
_init_test();
- tdm_output_get_layer(&output, 1, &error);
+ LIST_INITHEAD(&output.layer_list);
+
+ layer = tdm_output_get_layer(&output, 1, &error);
ASSERT_EQ(error, expected_error);
+ ASSERT_TRUE(layer == NULL);
}
TEST(tdm_output_get_layer, null_ptr_fail_1)
/* tdm_output_get_layer_count() */
+TEST(tdm_output_get_layer_count, work_flow_success_2)
+{
+ tdm_error error = TDM_ERROR_INVALID_PARAMETER;
+ tdm_error expected_error = TDM_ERROR_NONE;
+ int count;
+ tdm_private_output output;
+ tdm_private_layer private_layer_1;
+ tdm_private_layer private_layer_2;
+
+ _init_test();
+
+ LIST_INITHEAD(&output.layer_list);
+ LIST_ADD(&private_layer_1.link, &output.layer_list);
+ LIST_ADD(&private_layer_2.link, &output.layer_list);
+
+ error = tdm_output_get_layer_count(&output, &count);
+
+ ASSERT_EQ(error, expected_error);
+ ASSERT_EQ(count, 2);
+}
+
TEST(tdm_output_get_layer_count, work_flow_success_1)
{
tdm_error error = TDM_ERROR_INVALID_PARAMETER;
_init_test();
+ LIST_INITHEAD(&output.layer_list);
+
error = tdm_output_get_layer_count(&output, &count);
ASSERT_EQ(error, expected_error);
+ ASSERT_EQ(count, 0);
}
TEST(tdm_output_get_layer_count, null_ptr_fail_2)
/* tdm_display_handle_events() */
-TEST(tdm_display_handle_events, work_flow_success_4)
+TEST(tdm_display_handle_events, success_thread_handle_cb)
{
tdm_error error = TDM_ERROR_OPERATION_FAILED;
- tdm_error expected_error = TDM_ERROR_NONE;
struct _tdm_private_display dpy;
- tdm_private_loop private_loop;
_init_test();
- dpy.private_loop = &private_loop;
- private_loop.private_thread = NULL;
+ stub_tdm_thread_is_run = 1;
error = tdm_display_handle_events(&dpy);
- ASSERT_EQ(error, expected_error);
+ ASSERT_EQ(error, TDM_ERROR_NONE);
}
-TEST(tdm_display_handle_events, work_flow_success_3)
+TEST(tdm_display_handle_events, error_thread_handle_cb)
{
- tdm_error error = TDM_ERROR_NONE;
- tdm_error not_expected_error = TDM_ERROR_NONE;
+ tdm_error error = TDM_ERROR_OPERATION_FAILED;
struct _tdm_private_display dpy;
- tdm_private_loop private_loop;
_init_test();
- dpy.private_loop = &private_loop;
- private_loop.private_thread = NULL;
- TDM_EVENT_LOOP_DISPATCH_ERROR = 1;
+ stub_tdm_thread_is_run = 1;
+ TDM_THREAD_HANDLE_ERROR = 1;
error = tdm_display_handle_events(&dpy);
- ASSERT_NE(error, not_expected_error);
+ ASSERT_EQ(error, TDM_ERROR_OPERATION_FAILED);
}
-TEST(tdm_display_handle_events, work_flow_success_2)
+TEST(tdm_display_handle_events, error_poll)
+{
+ tdm_error error = TDM_ERROR_OPERATION_FAILED;
+ struct _tdm_private_display dpy;
+
+ _init_test();
+
+ stub_poll_error = 1;
+
+ error = tdm_display_handle_events(&dpy);
+
+ ASSERT_EQ(error, TDM_ERROR_OPERATION_FAILED);
+}
+
+TEST(tdm_display_handle_events, success_poll_eagain)
+{
+ tdm_error error = TDM_ERROR_OPERATION_FAILED;
+ struct _tdm_private_display dpy;
+
+ _init_test();
+
+ stub_poll_eagain = 1;
+
+ error = tdm_display_handle_events(&dpy);
+
+ ASSERT_EQ(error, TDM_ERROR_NONE);
+}
+
+TEST(tdm_display_handle_events, work_flow_success_4)
{
tdm_error error = TDM_ERROR_OPERATION_FAILED;
tdm_error expected_error = TDM_ERROR_NONE;
_init_test();
- dpy.private_loop = &private_loop;
- private_loop.private_thread = (tdm_private_thread *) 1;
-
error = tdm_display_handle_events(&dpy);
ASSERT_EQ(error, expected_error);
}
+TEST(tdm_display_handle_events, work_flow_success_3)
+{
+ tdm_error error = TDM_ERROR_NONE;
+ tdm_error not_expected_error = TDM_ERROR_NONE;
+ struct _tdm_private_display dpy;
+
+ _init_test();
+
+ TDM_EVENT_LOOP_DISPATCH_ERROR = 1;
+
+ error = tdm_display_handle_events(&dpy);
+
+ ASSERT_NE(error, not_expected_error);
+}
+
TEST(tdm_display_handle_events, null_ptr_fail_1)
{
tdm_error error = TDM_ERROR_NONE;
/* tdm_display_get_fd() */
+TEST(tdm_display_get_fd, success_thread_is_running)
+{
+ tdm_error error;
+ int fd;
+ struct _tdm_private_display dpy;
+
+ _init_test();
+
+ stub_tdm_thread_is_run = 1;
+ stub_tdm_thread_ret_fd = 5;
+
+ error = tdm_display_get_fd(&dpy, &fd);
+
+ ASSERT_EQ(error, TDM_ERROR_NONE);
+ ASSERT_EQ(fd, stub_tdm_thread_ret_fd);
+}
+
TEST(tdm_display_get_fd, work_flow_success_1)
{
tdm_error error = TDM_ERROR_OPERATION_FAILED;
tdm_error expected_error = TDM_ERROR_NONE;
int fd;
struct _tdm_private_display dpy;
- tdm_private_loop private_loop;
_init_test();
- dpy.private_loop = &private_loop;
- private_loop.private_thread = NULL;
-
error = tdm_display_get_fd(&dpy, &fd);
ASSERT_EQ(error, expected_error);
/* tdm_display_get_output() */
+TEST(tdm_display_get_output, success_get_output)
+{
+ tdm_error error = TDM_ERROR_OPERATION_FAILED;
+ tdm_error expected_error;
+ struct _tdm_private_display dpy;
+ tdm_output *ret_output;
+ tdm_private_output output;
+
+ _init_test();
+
+ output.index = 20;
+
+ LIST_INITHEAD(&dpy.output_list);
+ LIST_ADD(&output.link, &dpy.output_list);
+
+ ret_output = tdm_display_get_output(&dpy, output.index, &error);
+
+ expected_error = TDM_ERROR_NONE;
+
+ ASSERT_EQ(error, expected_error);
+ ASSERT_EQ(ret_output, &output);
+}
+
TEST(tdm_display_get_output, work_flow_success_1)
{
tdm_error error = TDM_ERROR_OPERATION_FAILED;
_init_test();
+ LIST_INITHEAD(&dpy.output_list);
+
tdm_display_get_output(&dpy, 1, &error);
expected_error = TDM_ERROR_NONE;
/* tdm_display_get_output_count() */
+TEST(tdm_display_get_output_count, work_flow_success_2)
+{
+ tdm_error error = TDM_ERROR_OPERATION_FAILED;
+ tdm_error expected_error;
+ struct _tdm_private_display dpy;
+ int count;
+ tdm_private_output output_1;
+ tdm_private_output output_2;
+
+ _init_test();
+
+ LIST_INITHEAD(&dpy.output_list);
+ LIST_ADD(&output_1.link, &dpy.output_list);
+ LIST_ADD(&output_2.link, &dpy.output_list);
+
+ error = tdm_display_get_output_count(&dpy, &count);
+
+ expected_error = TDM_ERROR_NONE;
+
+ ASSERT_EQ(error, expected_error);
+ ASSERT_EQ(count, 2);
+}
+
TEST(tdm_display_get_output_count, work_flow_success_1)
{
tdm_error error = TDM_ERROR_OPERATION_FAILED;
_init_test();
+ LIST_INITHEAD(&dpy.output_list);
+
error = tdm_display_get_output_count(&dpy, &count);
expected_error = TDM_ERROR_NONE;
ASSERT_EQ(error, expected_error);
+ ASSERT_EQ(count, 0);
}
TEST(tdm_display_get_output_count, null_ptr_fail_2)
ASSERT_EQ(error, expected_error);
}
+
+/* tdm_display_get_capture_available_size() */
+
+TEST(tdm_display_get_capture_available_size, error_dpy_is_null)
+{
+ tdm_error error = TDM_ERROR_NONE;
+
+ _init_test();
+
+ error = tdm_display_get_capture_available_size(NULL, NULL, NULL, NULL, NULL, NULL);
+
+ ASSERT_EQ(error, TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST(tdm_display_get_capture_available_size, error_no_capability)
+{
+ tdm_error error = TDM_ERROR_NONE;
+ tdm_private_display display;
+
+ _init_test();
+
+ display.capabilities = TDM_DISPLAY_CAPABILITY_PP;
+
+ error = tdm_display_get_capture_available_size(&display, NULL, NULL, NULL, NULL, NULL);
+
+ ASSERT_EQ(error, TDM_ERROR_NO_CAPABILITY);
+}
+
+TEST(tdm_display_get_capture_available_size, success_get_capture_available_size)
+{
+ tdm_error error = TDM_ERROR_NONE;
+ tdm_private_display display;
+ int min_w, min_h, max_w, max_h, preferred_align;
+
+ _init_test();
+
+ display.capabilities = TDM_DISPLAY_CAPABILITY_CAPTURE;
+
+ display.caps_capture.min_w = 200;
+ display.caps_capture.min_h = 300;
+ display.caps_capture.max_w = 1080;
+ display.caps_capture.max_h = 1920;
+ display.caps_capture.preferred_align = 100;
+
+ error = tdm_display_get_capture_available_size(&display, &min_w,
+ &min_h, &max_w, &max_h,
+ &preferred_align);
+
+ ASSERT_EQ(error, TDM_ERROR_NONE);
+ ASSERT_EQ(display.caps_capture.min_w, min_w);
+ ASSERT_EQ(display.caps_capture.min_h, min_h);
+ ASSERT_EQ(display.caps_capture.max_w, max_w);
+ ASSERT_EQ(display.caps_capture.max_h, max_h);
+ ASSERT_EQ(display.caps_capture.preferred_align, preferred_align);
+}
+
+/* tdm_display_get_capture_available_size() */
+
+TEST(tdm_display_get_max_layer_count, error_dpy_is_null)
+{
+ tdm_error error = TDM_ERROR_NONE;
+ int max_count;
+
+ _init_test();
+
+ error = tdm_display_get_max_layer_count(NULL, &max_count);
+
+ ASSERT_EQ(error, TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST(tdm_display_get_max_layer_count, error_max_count_is_null)
+{
+ tdm_error error = TDM_ERROR_NONE;
+ tdm_private_display display;
+
+ _init_test();
+
+ error = tdm_display_get_max_layer_count(&display, NULL);
+
+ ASSERT_EQ(error, TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST(tdm_display_get_max_layer_count, success_get_max_layer_count)
+{
+ tdm_error error = TDM_ERROR_NONE;
+ tdm_private_display display;
+ int max_count;
+
+ _init_test();
+
+ display.caps_display.max_layer_count = 100;
+
+ error = tdm_display_get_max_layer_count(&display, &max_count);
+
+ ASSERT_EQ(error, TDM_ERROR_NONE);
+ ASSERT_EQ(display.caps_display.max_layer_count, max_count);
+}
+
+/* tdm_display_get_backend_info() */
+
+TEST(tdm_display_get_backend_info, error_dpy_is_null)
+{
+ tdm_error error;
+
+ _init_test();
+
+ error = tdm_display_get_backend_info(NULL, NULL, NULL, NULL, NULL);
+
+ ASSERT_EQ(error, TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST(tdm_display_get_backend_info, success_get_backend_info)
+{
+ tdm_error error;
+ tdm_private_display display;
+ tdm_backend_module module_data;
+ const char *name;
+ const char *vendor;
+ int major;
+ int minor;
+
+ _init_test();
+
+ display.module_data = &module_data;
+
+ module_data.name = "name";
+ module_data.vendor = "vendor";
+ module_data.abi_version = 0xFFFFFFFF;
+
+ error = tdm_display_get_backend_info(&display, &name, &vendor, &major, &minor);
+
+ ASSERT_EQ(error, TDM_ERROR_NONE);
+ ASSERT_TRUE(name == module_data.name);
+ ASSERT_TRUE(vendor == module_data.vendor);
+ ASSERT_EQ(major, TDM_BACKEND_GET_ABI_MAJOR(module_data.abi_version));
+ ASSERT_EQ(minor, TDM_BACKEND_GET_ABI_MINOR(module_data.abi_version));
+}
+
+/* tdm_output_get_capabilities() */
+
+TEST(tdm_output_get_capabilities, error_output_is_null)
+{
+ tdm_error error;
+ tdm_output_capability capabilities;
+
+ _init_test();
+
+ error = tdm_output_get_capabilities(NULL, &capabilities);
+
+ ASSERT_EQ(error, TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST(tdm_output_get_capabilities, error_capabilities_is_null)
+{
+ tdm_error error;
+ tdm_private_output output;
+
+ _init_test();
+
+ error = tdm_output_get_capabilities(&output, NULL);
+
+ ASSERT_EQ(error, TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST(tdm_output_get_capabilities, success_get_capabilities)
+{
+ tdm_error error;
+ tdm_private_output output;
+ tdm_output_capability capabilities;
+
+ _init_test();
+
+ output.caps.capabilities = TDM_OUTPUT_CAPABILITY_ASYNC_DPMS;
+
+ error = tdm_output_get_capabilities(&output, &capabilities);
+
+ ASSERT_EQ(error, TDM_ERROR_NONE);
+ ASSERT_EQ(capabilities, output.caps.capabilities);
+}
+
+/* tdm_output_cb_status() */
+
+TEST(tdm_output_cb_status, success_no_in_display_thread)
+{
+ tdm_private_output private_output;
+ tdm_private_display private_display;
+ tdm_thread_cb_output_status *output_status;
+ tdm_output_conn_status status = TDM_OUTPUT_CONN_STATUS_CONNECTED;
+
+ _init_test();
+
+ private_output.private_display = &private_display;
+ private_output.stamp = 15.25;
+
+ LIST_INITHEAD(&private_output.change_handler_list_sub);
+
+ tdm_output_cb_status(&private_output, status, &private_output);
+
+ output_status = (tdm_thread_cb_output_status *)stub_tdm_thread_send_cb_buff;
+
+ ASSERT_EQ(output_status->base.type, TDM_THREAD_CB_OUTPUT_STATUS);
+ ASSERT_EQ(output_status->base.length, sizeof * output_status);
+ ASSERT_EQ(output_status->output_stamp, private_output.stamp);
+ ASSERT_EQ(output_status->status, status);
+ ASSERT_TRUE(output_status->user_data == &private_output);
+}
+
+TEST(tdm_output_cb_status, success_in_display_thread)
+{
+ tdm_private_output private_output;
+ tdm_private_display private_display;
+ tdm_output_conn_status status = TDM_OUTPUT_CONN_STATUS_CONNECTED;
+ tdm_private_change_handler change_handler;
+
+ _init_test();
+
+ stub_tdm_thread_display_thread = 1;
+ private_output.private_display = &private_display;
+ private_output.stamp = 15.25;
+
+ change_handler.func = stub_tdm_output_change_handler_cb;
+
+ LIST_INITHEAD(&private_output.change_handler_list_main);
+ LIST_ADD(&change_handler.link, &private_output.change_handler_list_main);
+
+ tdm_output_cb_status(&private_output, status, &private_output);
+
+ ASSERT_TRUE(stub_tdm_output_change_handler_count);
+}
+
+/* tdm_output_add_change_handler() */
+
+TEST(tdm_output_add_change_handler, error_output_is_null)
+{
+ tdm_error error;
+
+ _init_test();
+
+ error = tdm_output_add_change_handler(NULL, stub_tdm_output_change_handler_cb,
+ NULL);
+
+ ASSERT_EQ(error, TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST(tdm_output_add_change_handler, error_func_is_null)
+{
+ tdm_error error;
+ tdm_private_output output;
+
+ _init_test();
+
+ error = tdm_output_add_change_handler(&output, NULL, NULL);
+
+ ASSERT_EQ(error, TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST(tdm_output_add_change_handler, error_calloc)
+{
+ tdm_error error;
+ tdm_private_output output;
+
+ _init_test();
+
+ CALLOC_ERROR = 1;
+
+ error = tdm_output_add_change_handler(&output, stub_tdm_output_change_handler_cb,
+ NULL);
+
+ ASSERT_EQ(error, TDM_ERROR_OUT_OF_MEMORY);
+}
+
+TEST(tdm_output_add_change_handler, success_no_in_display_thread)
+{
+ tdm_error error;
+ tdm_private_output output;
+ int user_data = 10;
+ tdm_private_change_handler *h = NULL, *handler = NULL;
+
+ _init_test();
+
+ LIST_INITHEAD(&output.change_handler_list_main);
+ LIST_INITHEAD(&output.change_handler_list_sub);
+
+ stub_syscall_return_value = 21615;
+
+ error = tdm_output_add_change_handler(&output, stub_tdm_output_change_handler_cb,
+ &user_data);
+
+ ASSERT_EQ(error, TDM_ERROR_NONE);
+ ASSERT_TRUE(LIST_IS_EMPTY(&output.change_handler_list_main));
+ ASSERT_TRUE(!LIST_IS_EMPTY(&output.change_handler_list_sub));
+ LIST_FOR_EACH_ENTRY(h, &output.change_handler_list_sub, link) {
+ if (h->func == stub_tdm_output_change_handler_cb || h->user_data == &user_data) {
+ handler = h;
+ break;
+ }
+ }
+ ASSERT_TRUE(handler);
+ ASSERT_TRUE(handler->private_output == &output);
+ ASSERT_EQ(handler->owner_tid, stub_syscall_return_value);
+ free(handler);
+}
+
+TEST(tdm_output_add_change_handler, success_in_display_thread)
+{
+ tdm_error error;
+ tdm_private_output output;
+ int user_data = 10;
+ tdm_private_change_handler *h = NULL, *handler = NULL;
+
+ _init_test();
+
+ LIST_INITHEAD(&output.change_handler_list_main);
+ LIST_INITHEAD(&output.change_handler_list_sub);
+
+ stub_tdm_thread_display_thread = 1;
+ stub_syscall_return_value = 21615;
+
+ error = tdm_output_add_change_handler(&output, stub_tdm_output_change_handler_cb,
+ &user_data);
+
+ ASSERT_EQ(error, TDM_ERROR_NONE);
+ ASSERT_TRUE(!LIST_IS_EMPTY(&output.change_handler_list_main));
+ ASSERT_TRUE(LIST_IS_EMPTY(&output.change_handler_list_sub));
+ LIST_FOR_EACH_ENTRY(h, &output.change_handler_list_main, link) {
+ if (h->func == stub_tdm_output_change_handler_cb || h->user_data == &user_data) {
+ handler = h;
+ break;
+ }
+ }
+ ASSERT_TRUE(handler);
+ ASSERT_TRUE(handler->private_output == &output);
+ ASSERT_EQ(handler->owner_tid, stub_syscall_return_value);
+ free(handler);
+}
+
+/* tdm_output_remove_change_handler */
+
+TEST(tdm_output_remove_change_handler, success_list_main)
+{
+ tdm_private_output output;
+ int user_data = 10;
+ tdm_private_change_handler *change_handler;
+
+ _init_test();
+
+ LIST_INITHEAD(&output.change_handler_list_main);
+ LIST_INITHEAD(&output.change_handler_list_sub);
+
+ change_handler = (tdm_private_change_handler *)calloc(1, sizeof(tdm_private_change_handler));
+
+ change_handler->func = stub_tdm_output_change_handler_cb;
+ change_handler->user_data = &user_data;
+
+ LIST_ADD(&change_handler->link, &output.change_handler_list_main);
+
+ tdm_output_remove_change_handler(&output, stub_tdm_output_change_handler_cb,
+ &user_data);
+
+ ASSERT_EQ(FREE_CALLED, 1);
+ ASSERT_TRUE(LIST_IS_EMPTY(&output.change_handler_list_main));
+}
+
+TEST(tdm_output_remove_change_handler, success_list_sub)
+{
+ tdm_private_output output;
+ int user_data = 10;
+ tdm_private_change_handler *change_handler;
+
+ _init_test();
+
+ LIST_INITHEAD(&output.change_handler_list_main);
+ LIST_INITHEAD(&output.change_handler_list_sub);
+
+ change_handler = (tdm_private_change_handler *)calloc(1, sizeof(tdm_private_change_handler));
+
+ change_handler->func = stub_tdm_output_change_handler_cb;
+ change_handler->user_data = &user_data;
+
+ LIST_ADD(&change_handler->link, &output.change_handler_list_sub);
+
+ tdm_output_remove_change_handler(&output, stub_tdm_output_change_handler_cb,
+ &user_data);
+
+ ASSERT_EQ(FREE_CALLED, 1);
+ ASSERT_TRUE(LIST_IS_EMPTY(&output.change_handler_list_sub));
+}
+
+TEST(tdm_output_remove_change_handler, success_list_main_2)
+{
+ tdm_private_output output;
+ int user_data = 10;
+ tdm_private_change_handler *change_handler;
+ tdm_private_change_handler *change_handler_2;
+ tdm_private_change_handler *h = NULL, *handler = NULL;
+
+ _init_test();
+
+ LIST_INITHEAD(&output.change_handler_list_main);
+ LIST_INITHEAD(&output.change_handler_list_sub);
+
+ change_handler = (tdm_private_change_handler *)calloc(1, sizeof(tdm_private_change_handler));
+
+ change_handler->func = NULL;
+ change_handler->user_data = NULL;
+
+ change_handler_2 = (tdm_private_change_handler *)calloc(1, sizeof(tdm_private_change_handler));
+
+ change_handler_2->func = stub_tdm_output_change_handler_cb;
+ change_handler_2->user_data = &user_data;
+
+ LIST_ADD(&change_handler_2->link, &output.change_handler_list_main);
+ LIST_ADD(&change_handler->link, &output.change_handler_list_main);
+
+ tdm_output_remove_change_handler(&output, stub_tdm_output_change_handler_cb,
+ &user_data);
+
+ ASSERT_EQ(FREE_CALLED, 1);
+ ASSERT_TRUE(!LIST_IS_EMPTY(&output.change_handler_list_main));
+ LIST_FOR_EACH_ENTRY(h, &output.change_handler_list_main, link) {
+ if (h->func == NULL || h->user_data == NULL) {
+ handler = h;
+ break;
+ }
+ }
+ ASSERT_TRUE(handler);
+ LIST_DEL(&handler->link);
+ free(handler);
+ ASSERT_TRUE(LIST_IS_EMPTY(&output.change_handler_list_main));
+}
+
+TEST(tdm_output_remove_change_handler, success_list_sub_2)
+{
+ tdm_private_output output;
+ int user_data = 10;
+ tdm_private_change_handler *change_handler;
+ tdm_private_change_handler *change_handler_2;
+ tdm_private_change_handler *h = NULL, *handler = NULL;
+
+ _init_test();
+
+ LIST_INITHEAD(&output.change_handler_list_main);
+ LIST_INITHEAD(&output.change_handler_list_sub);
+
+ change_handler = (tdm_private_change_handler *)calloc(1, sizeof(tdm_private_change_handler));
+
+ change_handler->func = NULL;
+ change_handler->user_data = NULL;
+
+ change_handler_2 = (tdm_private_change_handler *)calloc(1, sizeof(tdm_private_change_handler));
+
+ change_handler_2->func = stub_tdm_output_change_handler_cb;
+ change_handler_2->user_data = &user_data;
+
+ LIST_ADD(&change_handler_2->link, &output.change_handler_list_sub);
+ LIST_ADD(&change_handler->link, &output.change_handler_list_sub);
+
+ tdm_output_remove_change_handler(&output, stub_tdm_output_change_handler_cb,
+ &user_data);
+
+ ASSERT_EQ(FREE_CALLED, 1);
+ ASSERT_TRUE(!LIST_IS_EMPTY(&output.change_handler_list_sub));
+ LIST_FOR_EACH_ENTRY(h, &output.change_handler_list_sub, link) {
+ if (h->func == NULL || h->user_data == NULL) {
+ handler = h;
+ break;
+ }
+ }
+ ASSERT_TRUE(handler);
+ LIST_DEL(&handler->link);
+ free(handler);
+ ASSERT_TRUE(LIST_IS_EMPTY(&output.change_handler_list_sub));
+}
+
+TEST(tdm_output_remove_change_handler, success_handler_is_not_exist)
+{
+ tdm_private_output output;
+ int user_data = 10;
+ tdm_private_change_handler *change_handler;
+ tdm_private_change_handler *change_handler_2;
+ tdm_private_change_handler *h = NULL, *handler = NULL;
+
+ _init_test();
+
+ LIST_INITHEAD(&output.change_handler_list_main);
+ LIST_INITHEAD(&output.change_handler_list_sub);
+
+ change_handler = (tdm_private_change_handler *)calloc(1, sizeof(tdm_private_change_handler));
+
+ change_handler->func = NULL;
+ change_handler->user_data = NULL;
+
+ change_handler_2 = (tdm_private_change_handler *)calloc(1, sizeof(tdm_private_change_handler));
+
+ change_handler_2->func = NULL;
+ change_handler_2->user_data = NULL;
+
+ LIST_ADD(&change_handler->link, &output.change_handler_list_sub);
+ LIST_ADD(&change_handler_2->link, &output.change_handler_list_sub);
+
+ tdm_output_remove_change_handler(&output, stub_tdm_output_change_handler_cb,
+ &user_data);
+
+ ASSERT_EQ(FREE_CALLED, 0);
+ ASSERT_TRUE(!LIST_IS_EMPTY(&output.change_handler_list_sub));
+ LIST_FOR_EACH_ENTRY(h, &output.change_handler_list_sub, link) {
+ if (h->func == NULL || h->user_data == NULL) {
+ handler = h;
+ break;
+ }
+ }
+ ASSERT_TRUE(handler);
+ LIST_DEL(&handler->link);
+ free(handler);
+ handler = NULL;
+ ASSERT_TRUE(!LIST_IS_EMPTY(&output.change_handler_list_sub));
+ LIST_FOR_EACH_ENTRY(h, &output.change_handler_list_sub, link) {
+ if (h->func == NULL || h->user_data == NULL) {
+ handler = h;
+ break;
+ }
+ }
+ ASSERT_TRUE(handler);
+ LIST_DEL(&handler->link);
+ free(handler);
+ ASSERT_TRUE(LIST_IS_EMPTY(&output.change_handler_list_sub));
+}
+
+/* tdm_output_get_cursor_available_size() */
+
+TEST(tdm_output_get_cursor_available_size, error_output_is_null)
+{
+ tdm_error error;
+
+ _init_test();
+
+ error = tdm_output_get_cursor_available_size(NULL, NULL, NULL, NULL, NULL, NULL);
+
+ ASSERT_EQ(error, TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST(tdm_output_get_cursor_available_size, error_abi_version_is_1_4)
+{
+ tdm_error error;
+ tdm_private_output output;
+ tdm_private_display display;
+ tdm_backend_module module;
+ int min_w, min_h, max_w, max_h, preferred_align;
+
+ _init_test();
+
+ output.private_display = &display;
+
+ display.module_data = &module;
+ module.abi_version = 0x00010004;
+
+ output.caps.cursor_min_w = 200;
+ output.caps.cursor_min_h = 300;
+ output.caps.cursor_max_w = 1080;
+ output.caps.cursor_max_h = 1920;
+ output.caps.cursor_preferred_align = 256;
+
+ error = tdm_output_get_cursor_available_size(&output, &min_w, &min_h, &max_w,
+ &max_h, &preferred_align);
+
+ ASSERT_EQ(error, TDM_ERROR_BAD_MODULE);
+ ASSERT_EQ(min_w, -1);
+ ASSERT_EQ(min_h, -1);
+ ASSERT_EQ(max_w, -1);
+ ASSERT_EQ(max_h, -1);
+ ASSERT_EQ(preferred_align, -1);
+}
+
+TEST(tdm_output_get_cursor_available_size, success_abi_version_is_1_5)
+{
+ tdm_error error;
+ tdm_private_output output;
+ tdm_private_display display;
+ tdm_backend_module module;
+ int min_w, min_h, max_w, max_h, preferred_align;
+
+ _init_test();
+
+ output.private_display = &display;
+
+ display.module_data = &module;
+ module.abi_version = 0x00010005;
+
+ output.caps.cursor_min_w = 200;
+ output.caps.cursor_min_h = 300;
+ output.caps.cursor_max_w = 1080;
+ output.caps.cursor_max_h = 1920;
+ output.caps.cursor_preferred_align = 256;
+
+ error = tdm_output_get_cursor_available_size(&output, &min_w, &min_h, &max_w,
+ &max_h, &preferred_align);
+
+ ASSERT_EQ(error, TDM_ERROR_NONE);
+ ASSERT_EQ(min_w, output.caps.cursor_min_w);
+ ASSERT_EQ(min_h, output.caps.cursor_min_h);
+ ASSERT_EQ(max_w, output.caps.cursor_max_w);
+ ASSERT_EQ(max_h, output.caps.cursor_max_h);
+ ASSERT_EQ(preferred_align, output.caps.cursor_preferred_align);
+}
+
+/* tdm_output_get_primary_index() */
+
+TEST(tdm_output_get_primary_index, error_output_is_null)
+{
+ tdm_error error;
+ int index;
+
+ _init_test();
+
+ error = tdm_output_get_primary_index(NULL, &index);
+
+ ASSERT_EQ(error, TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST(tdm_output_get_primary_index, error_index_is_null)
+{
+ tdm_error error;
+ tdm_private_output output;
+
+ _init_test();
+
+ error = tdm_output_get_primary_index(&output, NULL);
+
+ ASSERT_EQ(error, TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST(tdm_output_get_primary_index, success_layer_list_is_empty)
+{
+ tdm_error error;
+ tdm_private_output output;
+ int index = 0;
+
+ _init_test();
+
+ LIST_INITHEAD(&output.layer_list);
+
+ error = tdm_output_get_primary_index(&output, &index);
+
+ ASSERT_EQ(error, TDM_ERROR_NONE);
+ ASSERT_EQ(index, 0);
+}
+
+TEST(tdm_output_get_primary_index, success_get_primary_index)
+{
+ tdm_error error;
+ tdm_private_output output;
+ tdm_private_layer private_layer_1;
+ tdm_private_layer private_layer_2;
+ int index;
+
+ _init_test();
+
+ LIST_INITHEAD(&output.layer_list);
+ LIST_ADD(&private_layer_1.link, &output.layer_list);
+ LIST_ADD(&private_layer_2.link, &output.layer_list);
+
+ private_layer_1.index = 25;
+ private_layer_2.index = 35;
+
+ private_layer_1.caps.capabilities = (tdm_layer_capability)(TDM_LAYER_CAPABILITY_GRAPHIC |
+ TDM_LAYER_CAPABILITY_PRIMARY);
+
+ private_layer_2.caps.capabilities = (tdm_layer_capability)(TDM_LAYER_CAPABILITY_GRAPHIC |
+ TDM_LAYER_CAPABILITY_OVERLAY);
+
+ error = tdm_output_get_primary_index(&output, &index);
+
+ ASSERT_EQ(error, TDM_ERROR_NONE);
+ ASSERT_EQ(index, private_layer_1.index);
+}
+
+/* tdm_output_cb_vblank() */
+
+TEST(tdm_output_cb_vblank, success_no_in_display_thread)
+{
+ tdm_private_vblank_handler vblank_handler;
+ tdm_private_output output;
+ tdm_private_display display;
+ unsigned int sequence = 17, tv_sec = 145, tv_usec = 874;
+ tdm_thread_cb_output_vblank *output_vblank;
+
+ _init_test();
+
+ vblank_handler.private_output = &output;
+ output.private_display = &display;
+ output.stamp = 10.11;
+ stub_syscall_return_value = 115;
+ vblank_handler.owner_tid = stub_syscall_return_value - 1;
+
+ tdm_output_cb_vblank(&output, sequence, tv_sec, tv_usec, &vblank_handler);
+
+ output_vblank = (tdm_thread_cb_output_vblank *)stub_tdm_thread_send_cb_buff;
+
+ ASSERT_EQ(output_vblank->base.type, TDM_THREAD_CB_OUTPUT_VBLANK);
+ ASSERT_EQ(output_vblank->base.length, sizeof * output_vblank);
+ ASSERT_DOUBLE_EQ(output_vblank->output_stamp, output.stamp);
+ ASSERT_EQ(output_vblank->sequence, sequence);
+ ASSERT_EQ(output_vblank->tv_sec, tv_sec);
+ ASSERT_EQ(output_vblank->tv_usec, tv_usec);
+ ASSERT_TRUE(output_vblank->user_data == &vblank_handler);
+}
+
+TEST(tdm_output_cb_vblank, success_in_display_thread)
+{
+ tdm_private_vblank_handler *vblank_handler;
+ tdm_private_output output;
+ tdm_private_display display;
+ unsigned int sequence = 17, tv_sec = 145, tv_usec = 874;
+ struct list_head list;
+
+ _init_test();
+
+ vblank_handler = (tdm_private_vblank_handler *)calloc(1, sizeof * vblank_handler);
+ vblank_handler->private_output = &output;
+ output.private_display = &display;
+
+ stub_syscall_return_value = 115;
+ stub_syscall_reset = 1;
+
+ vblank_handler->owner_tid = stub_syscall_return_value;
+ vblank_handler->func = stub_tdm_output_vblank_handler;
+
+ LIST_INITHEAD(&list);
+ LIST_ADD(&vblank_handler->link, &list);
+
+ tdm_output_cb_vblank(&output, sequence, tv_sec, tv_usec, vblank_handler);
+
+ ASSERT_EQ(stub_tdm_output_vblank_handler_count, 1);
+ ASSERT_EQ(FREE_CALLED, 1);
+ ASSERT_TRUE(LIST_IS_EMPTY(&list));
+}
+
+/* tdm_output_cb_commit() */
+
+TEST(tdm_output_cb_commit, success_no_in_display_thread)
+{
+ tdm_private_commit_handler commit_handler;
+ tdm_private_output output;
+ tdm_private_display display;
+ unsigned int sequence = 17, tv_sec = 145, tv_usec = 874;
+ tdm_thread_cb_output_commit *output_commit;
+
+ _init_test();
+
+ commit_handler.private_output = &output;
+ output.private_display = &display;
+ output.stamp = 10.11;
+ stub_syscall_return_value = 115;
+ commit_handler.owner_tid = stub_syscall_return_value - 1;
+
+ tdm_output_cb_commit(&output, sequence, tv_sec, tv_usec, &commit_handler);
+
+ output_commit = (tdm_thread_cb_output_commit *)stub_tdm_thread_send_cb_buff;
+
+ ASSERT_EQ(output_commit->base.type, TDM_THREAD_CB_OUTPUT_COMMIT);
+ ASSERT_EQ(output_commit->base.length, sizeof * output_commit);
+ ASSERT_DOUBLE_EQ(output_commit->output_stamp, output.stamp);
+ ASSERT_EQ(output_commit->sequence, sequence);
+ ASSERT_EQ(output_commit->tv_sec, tv_sec);
+ ASSERT_EQ(output_commit->tv_usec, tv_usec);
+ ASSERT_TRUE(output_commit->user_data == &commit_handler);
+}
+
+TEST(tdm_output_cb_commit, success_in_display_thread)
+{
+ tdm_private_commit_handler *commit_handler;
+ tdm_private_output output;
+ tdm_private_display display;
+ unsigned int sequence = 17, tv_sec = 145, tv_usec = 874;
+ tdm_private_layer private_layer_1;
+ tdm_private_layer private_layer_2;
+ tdm_private_layer private_layer_3;
+ struct _tbm_surface waiting_buffer;
+ struct _tbm_surface showing_buffer;
+ struct list_head list;
+ struct _tbm_surface_queue surface_queue;
+
+ _init_test();
+
+ commit_handler = (tdm_private_commit_handler *)calloc(1, sizeof * commit_handler);
+
+ private_layer_1.waiting_buffer = NULL;
+ private_layer_1.showing_buffer = NULL;
+
+ private_layer_2.waiting_buffer = &waiting_buffer;
+ private_layer_2.showing_buffer = &showing_buffer;
+ private_layer_2.buffer_queue = &surface_queue;
+
+ private_layer_3.waiting_buffer = &waiting_buffer;
+ private_layer_3.showing_buffer = NULL;
+
+ commit_handler->private_output = &output;
+ output.private_display = &display;
+ stub_syscall_return_value = 115;
+ commit_handler->owner_tid = stub_syscall_return_value;
+
+ LIST_INITHEAD(&output.layer_list);
+ LIST_ADD(&private_layer_1.link, &output.layer_list);
+ LIST_ADD(&private_layer_2.link, &output.layer_list);
+ LIST_ADD(&private_layer_3.link, &output.layer_list);
+
+ commit_handler->func = stub_tdm_output_commit_handler;
+
+ LIST_INITHEAD(&list);
+ LIST_ADD(&commit_handler->link, &list);
+
+ tdm_output_cb_commit(&output, sequence, tv_sec, tv_usec, commit_handler);
+
+ ASSERT_EQ(stub_tdm_buffer_unref_backend_count, 1);
+ ASSERT_EQ(tbm_surface_queue_release_count, 1);
+ ASSERT_TRUE(private_layer_1.showing_buffer == NULL);
+ ASSERT_TRUE(private_layer_2.showing_buffer == &waiting_buffer);
+ ASSERT_TRUE(private_layer_3.showing_buffer == &waiting_buffer);
+ ASSERT_TRUE(private_layer_1.waiting_buffer == NULL);
+ ASSERT_TRUE(private_layer_2.waiting_buffer == NULL);
+ ASSERT_TRUE(private_layer_3.waiting_buffer == NULL);
+ ASSERT_EQ(stub_tdm_output_commit_handler_count, 1);
+ ASSERT_EQ(FREE_CALLED, 1);
+ ASSERT_TRUE(LIST_IS_EMPTY(&list));
+}
+
+/* tdm_output_cb_dpms() */
+
+TEST(tdm_output_cb_dpms, success_no_in_display_thread)
+{
+ tdm_private_output output;
+ tdm_private_display display;
+ tdm_thread_cb_output_dpms *output_dpms;
+ tdm_output_dpms dpms = TDM_OUTPUT_DPMS_STANDBY;
+
+ _init_test();
+
+ output.private_display = &display;
+ output.stamp = 10.11;
+
+ LIST_INITHEAD(&output.change_handler_list_sub);
+ LIST_INITHEAD(&output.change_handler_list_main);
+
+ tdm_output_cb_dpms(&output, dpms, &output);
+
+ output_dpms = (tdm_thread_cb_output_dpms *)stub_tdm_thread_send_cb_buff;
+
+ ASSERT_EQ(output_dpms->base.type, TDM_THREAD_CB_OUTPUT_DPMS);
+ ASSERT_EQ(output_dpms->base.length, sizeof * output_dpms);
+ ASSERT_DOUBLE_EQ(output_dpms->output_stamp, output.stamp);
+ ASSERT_EQ(output_dpms->dpms, TDM_OUTPUT_DPMS_STANDBY);
+ ASSERT_TRUE(output_dpms->user_data == &output);
+}
+
+TEST(tdm_output_cb_dpms, success_in_display_thread)
+{
+ tdm_private_output output;
+ tdm_private_display display;
+ tdm_output_dpms dpms = TDM_OUTPUT_DPMS_STANDBY;
+ tdm_private_change_handler change_handler_1;
+ tdm_private_change_handler change_handler_2;
+
+ _init_test();
+
+ stub_tdm_thread_display_thread = 1;
+
+ output.private_display = &display;
+
+ LIST_INITHEAD(&output.change_handler_list_sub);
+ LIST_INITHEAD(&output.change_handler_list_main);
+ LIST_ADD(&change_handler_1.link, &output.change_handler_list_main);
+ LIST_ADD(&change_handler_2.link, &output.change_handler_list_main);
+
+ change_handler_1.func = stub_tdm_output_change_handler_cb;
+ change_handler_2.func = stub_tdm_output_change_handler_cb;
+
+ tdm_output_cb_dpms(&output, dpms, &output);
+
+ ASSERT_EQ(stub_tdm_output_change_handler_count, 2);
+ ASSERT_EQ(output.current_dpms_value, dpms);
+
+}
+
+/* tdm_layer_get_displaying_buffer() */
+
+TEST(tdm_layer_get_displaying_buffer, error_layer_is_null)
+{
+ tdm_error error;
+ tbm_surface_h buffer;
+
+ _init_test();
+
+ buffer = tdm_layer_get_displaying_buffer(NULL, &error);
+
+ ASSERT_EQ(error, TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(buffer, NULL);
+}
+
+TEST(tdm_layer_get_displaying_buffer, error_showing_buffer_is_null)
+{
+ tdm_error error;
+ tbm_surface_h buffer;
+ tdm_private_layer layer;
+ tdm_private_output output;
+
+ _init_test();
+
+ layer.private_output = &output;
+
+ layer.showing_buffer = NULL;
+
+ buffer = tdm_layer_get_displaying_buffer(&layer, &error);
+
+ ASSERT_EQ(error, TDM_ERROR_OPERATION_FAILED);
+ ASSERT_EQ(buffer, NULL);
+}
+
+TEST(tdm_layer_get_displaying_buffer, success_get_displaying_buffer)
+{
+ tdm_error error;
+ tbm_surface_h buffer;
+ tdm_private_layer layer;
+ tdm_private_output output;
+ struct _tbm_surface showing_buffer;
+
+ _init_test();
+
+ layer.private_output = &output;
+
+ layer.showing_buffer = &showing_buffer;
+
+ buffer = tdm_layer_get_displaying_buffer(&layer, &error);
+
+ ASSERT_EQ(error, TDM_ERROR_NONE);
+ ASSERT_EQ(buffer, &showing_buffer);
+}
+
+/* tdm_layer_get_buffer_flags() */
+
+TEST(tdm_layer_get_buffer_flags, error_layer_is_null)
+{
+ tdm_error error;
+ unsigned int flags;
+
+ _init_test();
+
+ error = tdm_layer_get_buffer_flags(NULL, &flags);
+
+ ASSERT_EQ(error, TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST(tdm_layer_get_buffer_flags, error_layer_get_buffer_flags_is_null)
+{
+ tdm_error error;
+ unsigned int flags;
+ tdm_private_layer layer;
+ tdm_private_output output;
+ tdm_private_display display;
+ tdm_func_layer func_layer;
+
+ _init_test();
+
+ layer.private_output = &output;
+ output.private_display = &display;
+
+ func_layer.layer_get_buffer_flags = NULL;
+
+ display.func_layer = func_layer;
+
+ error = tdm_layer_get_buffer_flags(&layer, &flags);
+
+ ASSERT_EQ(error, TDM_ERROR_NOT_IMPLEMENTED);
+}
+
+TEST(tdm_layer_get_buffer_flags, success_get_buffer_flags)
+{
+ tdm_error error;
+ unsigned int flags;
+ tdm_private_layer layer;
+ tdm_private_output output;
+ tdm_private_display display;
+ tdm_func_layer func_layer;
+
+ _init_test();
+
+ layer.private_output = &output;
+ output.private_display = &display;
+
+ func_layer.layer_get_buffer_flags = layer_get_buffer_flags;
+
+ display.func_layer = func_layer;
+
+ error = tdm_layer_get_buffer_flags(&layer, &flags);
+
+ ASSERT_EQ(error, TDM_ERROR_NONE);
+ ASSERT_EQ(flags, layer_get_buffer_flags_ret);
+}