change all symbol and file name.
Change-Id: Id48ccad285938dfcbb8f136c71592806c120d47e
-if HAVE_UTEST
-SUBDIRS = . include protocol common src backends client tools utests
+if HAVE_HALTESTS
+SUBDIRS = . include protocol common src backends client tools haltests
else
SUBDIRS = . include protocol common src backends client tools
endif
# Enable quiet compiles on automake 1.11.
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
-AC_ARG_WITH(utests, AS_HELP_STRING([--with-utests=yes/no], [whether build/run unit tests or not]),
- [ utests="$withval" ],
- [ utests="no" ])
+AC_ARG_WITH(haltests, AS_HELP_STRING([--with-haltests=yes/no], [whether build/run unit tests or not]),
+ [ haltests="$withval" ],
+ [ haltests="no" ])
-AM_CONDITIONAL(HAVE_UTEST, test "x$utests" = "xyes")
+AM_CONDITIONAL(HAVE_HALTESTS, test "x$haltests" = "xyes")
AC_PATH_PROG([wayland_scanner], [wayland-scanner])
if test x$wayland_scanner = x; then
client/libtdm-client.pc
client/Makefile
tools/Makefile
- utests/Makefile])
+ haltests/Makefile])
echo ""
echo "$PACKAGE_STRING will be compiled with:"
--- /dev/null
+bin_PROGRAMS = tdm-haltests
+
+tdm_haltests_SOURCES = \
+ src/tc_tdm_main.cpp \
+ src/tc_tdm_log.cpp \
+ src/tc_tdm_env.cpp \
+ src/tc_tdm_event_loop.cpp \
+ src/tc_tdm_buffer.cpp \
+ src/tc_tdm_helper.cpp \
+ src/tc_tdm_vblank.cpp \
+ src/tc_tdm_display.cpp \
+ src/tc_tdm_output.cpp \
+ src/tc_tdm_layer.cpp \
+ src/tc_tdm_client.cpp \
+ src/tc_tdm_backend_env.cpp \
+ src/tc_tdm_backend_display.cpp \
+ src/tc_tdm_backend_pp.cpp \
+ src/tc_tdm_backend_capture.cpp
+
+tdm_haltests_SOURCES += \
+ ../tools/buffers.c
+
+tdm_haltests_CXXFLAGS = \
+ $(CXXFLAGS) \
+ $(TDM_CFLAGS) \
+ -I../src \
+ -I../include \
+ -I../client \
+ -I../tools \
+ -I$(includedir)/gtest \
+ -fpermissive
+# The flag -w is used, because there are many warnings in libtdm's sources.
+# Warnings occur because we build project with g++.
+# In C++ we need to use explicit types conversion.
+
+tdm_haltests_LDFLAGS = \
+ ${LDFLAGS} \
+ $(TDM_LIBS) \
+ $(top_builddir)/src/libtdm.la \
+ $(top_builddir)/client/libtdm-client.la \
+ $(top_builddir)/common/libtdm-common.la \
+ -lgtest
+
+check:
+ ./tdm-haltests
--- /dev/null
+#ifndef _UT_TDM_H_
+#define _UT_TDM_H_
+
+#include <sys/epoll.h>
+#include <sys/timerfd.h>
+#include <limits.h>
+#include <vector>
+#include <list>
+#include <climits>
+#include <pthread.h>
+#include <gtest/gtest.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <poll.h>
+
+extern "C" {
+#include <tbm_bufmgr.h>
+#include <tbm_drm_helper.h>
+}
+
+/* LCOV_EXCL_START */
+
+#include "tdm.h"
+#include "tdm_helper.h"
+#include "tdm_config.h"
+#include "tdm_log.h"
+#include "tdm_macro.h"
+#include "buffers.h"
+
+//#define TDM_UT_TEST_WITH_PARAMS
+
+extern bool enable_porting_debug;
+
+#undef TDM_DBG
+#undef TDM_INFO
+#undef TDM_WRN
+#undef TDM_ERR
+#define TDM_DBG(fmt, args...) tdm_log_print(TDM_LOG_LEVEL_DBG, fmt, ##args)
+#define TDM_INFO(fmt, args...) tdm_log_print(TDM_LOG_LEVEL_INFO, fmt, ##args)
+#define TDM_WRN(fmt, args...) tdm_log_print(TDM_LOG_LEVEL_WRN, fmt, ##args)
+#define TDM_ERR(fmt, args...) tdm_log_print(TDM_LOG_LEVEL_ERR, fmt, ##args)
+
+#define TDM_UT_INFO(fmt, args...) tdm_log_printf(TDM_LOG_LEVEL_INFO, fmt, ##args)
+#define TDM_UT_WRN(fmt, args...) tdm_log_printf(TDM_LOG_LEVEL_WRN, fmt, ##args)
+#define TDM_UT_ERR(fmt, args...) tdm_log_printf(TDM_LOG_LEVEL_ERR, fmt, ##args)
+
+#define TDM_UT_ENTRY() \
+ TDM_ERR("--------------------------------------------- %s", typeid(*this).name())
+
+#define TDM_UT_CHECK_FLAG(FLAG) \
+ do {\
+ if(!(FLAG)) \
+ TDM_UT_WRN("[ ] not supported");\
+ } while(0)
+
+#define TDM_UT_SKIP_FLAG(FLAG) \
+ do {\
+ if(!(FLAG)) {\
+ TDM_UT_WRN("[ SKIPPED ] not supported");\
+ return;\
+ }\
+ } while(0)
+
+#define TDM_UT_RETURN_IF_FAIL(cond) \
+ do { \
+ if (!(cond)) { \
+ TDM_UT_ERR("[%s,%d] '%s' failed", __FUNCTION__, __LINE__, #cond); \
+ return; \
+ } \
+ } while(0)
+#define TDM_UT_RETURN_FALSE_IF_FAIL(cond) \
+ do { \
+ if (!(cond)) { \
+ TDM_UT_ERR("[%s,%d] '%s' failed", __FUNCTION__, __LINE__, #cond); \
+ return false; \
+ } \
+ } while(0)
+#define TDM_UT_RETURN_VAL_IF_FAIL(cond, val) \
+ do { \
+ if (!(cond)) { \
+ TDM_UT_ERR("[%s,%d] '%s' failed", __FUNCTION__, __LINE__, #cond); \
+ return val; \
+ } \
+ } while(0)
+#define TDM_UT_GOTO_IF_FAIL(cond, dst) \
+ do { \
+ if (!(cond)) { \
+ TDM_UT_ERR("[%s,%d] '%s' failed", __FUNCTION__, __LINE__, #cond); \
+ goto dst; \
+ } \
+ } while(0)
+
+#define TDM_UT_ASSERT_TRUE(cond, fmt, args...) \
+ do { \
+ if (!(cond)) { \
+ if (enable_porting_debug) \
+ TDM_UT_ERR(fmt, ##args); \
+ GTEST_TEST_BOOLEAN_((cond), #cond, false, true, GTEST_FATAL_FAILURE_); \
+ } \
+ } while(0)
+#define TDM_UT_EXPECT_TRUE(cond, fmt, args...) \
+ do { \
+ if (!(cond)) { \
+ if (enable_porting_debug) \
+ TDM_UT_ERR(fmt, ##args); \
+ GTEST_TEST_BOOLEAN_((cond), #cond, false, true, GTEST_NONFATAL_FAILURE_); \
+ } \
+ } while(0)
+
+#define TDM_UT_SIZE_ALIGN(value, base) (((value) + ((base) - 1)) & ~((base) - 1))
+
+#define TDM_UT_DUMP_DIR "/tmp/tdm_dump"
+#define TDM_UT_INVALID_VALUE -42
+#define TDM_UT_BUFFER_SIZE 256
+#define TDM_UT_VBLANK_NAME "tc_tdm_vblank"
+
+using ::testing::TestWithParam;
+using ::testing::Bool;
+using ::testing::Values;
+using ::testing::Combine;
+
+#ifdef TDM_UT_TEST_WITH_PARAMS
+class TDMEnv : public TestWithParam< ::testing::tuple<bool, bool, const char*> >
+{
+public:
+ void SetUp(void);
+ void TearDown(void);
+};
+#else
+class TDMEnv : public TestWithParam< ::testing::tuple<const char*> >
+{
+public:
+ void SetUp(void);
+ void TearDown(void);
+};
+#endif
+
+class TDMDisplay : public TDMEnv
+{
+public:
+ tdm_display *dpy;
+ tbm_bufmgr bufmgr;
+
+ bool has_pp_cap;
+ bool has_capture_cap;
+
+ TDMDisplay();
+ void SetUp(void);
+ void TearDown(void);
+};
+
+class TDMOutput : public TDMDisplay
+{
+public:
+ bool has_outputs;
+ tdm_output **outputs;
+ int output_count;
+
+ bool done1, done2, done3;
+
+ TDMOutput();
+ void SetUp(void);
+ void TearDown(void);
+};
+
+#ifdef TIZEN_TEST_GCOV
+extern "C" void __gcov_flush(void);
+#endif
+
+tdm_error tc_tdm_display_handle_events(tdm_display *dpy);
+bool tc_tdm_display_has_pp_capability(tdm_display *dpy);
+bool tc_tdm_display_has_capture_capability(tdm_display *dpy);
+
+bool tc_tdm_buffer_create(int width, int height, tbm_format format, int flags, bool fill,
+ int count, tbm_surface_h *buffers);
+
+bool tc_tdm_output_is_async_dpms_enable(tdm_output *output);
+bool tc_tdm_output_is_hwc_enable(tdm_output *output);
+bool tc_tdm_output_is_aod_enable(tdm_output *output);
+bool tc_tdm_output_is_connected(tdm_output *output);
+bool tc_tdm_output_mode_setting(tdm_output *output);
+bool tc_tdm_output_prepare(tdm_display *dpy, tdm_output *output, bool fill);
+bool tc_tdm_output_prepare_all_output(tdm_display *dpy, tdm_output **outputs, int output_count, bool fill);
+bool tc_tdm_output_unset(tdm_display *dpy, tdm_output *output);
+double tc_tdm_output_get_vblank_interval_time(tdm_output *output);
+tdm_layer *tc_tdm_output_get_primary_layer(tdm_output *output);
+
+bool tc_tdm_layer_is_cursor_layer(tdm_layer *layer);
+bool tc_tdm_layer_is_primary_layer(tdm_layer *layer);
+bool tc_tdm_layer_is_video_layer(tdm_layer *layer);
+bool tc_tdm_layer_support_scale(tdm_layer *layer);
+bool tc_tdm_layer_support_no_crop(tdm_layer *layer);
+bool tc_tdm_layer_prepare_buffer(tdm_layer *layer, tbm_surface_h *buffers, int buffer_count, bool fill);
+bool tc_tdm_layer_prepare_buffer_queue(tdm_layer *layer, tbm_surface_queue_h *buffer_queue);
+bool tc_tdm_layer_fill_info(tdm_layer *layer, tbm_surface_h buffer, tbm_surface_queue_h buffer_queue, tdm_info_layer *info);
+bool tc_tdm_layer_set_buffer(tdm_layer *layer, tbm_surface_h buffer);
+bool tc_tdm_layer_set_buffer_with_pos(tdm_layer *layer, tbm_surface_h buffer, tdm_pos *pos);
+unsigned int tc_tdm_layer_get_output_pipe(tdm_layer *layer);
+tbm_format tc_tdm_layer_find_best_format(tdm_layer *layer);
+bool tc_tdm_layer_is_avaiable(tdm_layer *layer);
+
+bool tc_tdm_pp_fill_info(tbm_surface_h srcbuf, tbm_surface_h dstbuf, tdm_transform transform, tdm_info_pp *info);
+bool tc_tdm_capture_fill_info(tdm_output *output, tbm_surface_h buffer, tdm_transform transform,
+ tdm_capture_type type, int frequency, bool stretch, tdm_info_capture *info);
+
+/******************************************************************************/
+/** testing for checking backend's basic implementation **/
+/******************************************************************************/
+class TDMBackendEnv : public TDMEnv
+{
+public:
+ void SetUp(void);
+ void TearDown(void);
+};
+
+class TDMBackendBasic : public TDMBackendEnv
+{
+public:
+ tdm_display *dpy;
+
+ tdm_output **outputs;
+ int output_count;
+
+ tdm_layer **layers;
+ int layer_count;
+
+ tbm_surface_h buffers[3];
+
+ TDMBackendBasic();
+ void SetUp(void);
+ void TearDown(void);
+ void UnsetOutput(void);
+ void DestroyBuffers(void);
+};
+
+class TDMBackendDisplay : public TDMBackendBasic
+{
+public:
+ void SetUp(void) { TDMBackendBasic::SetUp(); }
+ void TearDown(void) { TDMBackendBasic::TearDown(); }
+};
+
+char tc_tdm_backend_getchar(void);
+
+#define TDM_UT_ASK_YNR(fmt, ...) \
+ do { \
+ if (enable_porting_debug) { \
+ char ch; \
+ do { \
+ printf(fmt" [Y]es, [n]o, [r]etry): ", ##__VA_ARGS__); \
+ ch = tc_tdm_backend_getchar(); \
+ } while(ch != 'y' && ch != 'n' && ch != 'r'); \
+ if (ch == 'n') \
+ GTEST_FATAL_FAILURE_("tc failed"); \
+ if (ch == 'r') \
+ goto retry; \
+ } \
+ } while (0)
+
+/* LCOV_EXCL_STOP */
+
+#endif // _UT_TDM_H_
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
+ * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
+ * Contact: Roman Marchenko <r.marchenko@samsung.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+**************************************************************************/
+
+#include "tc_tdm.h"
+
+/* LCOV_EXCL_START */
+class TDMBackendCapture : public TDMBackendDisplay
+{
+public:
+ bool has_capture_cap;
+
+ tdm_capture *capture;
+ tdm_capture_capability capabilities;
+ const tbm_format *formats;
+ int format_count;
+ int min_w;
+ int min_h;
+ int max_w;
+ int max_h;
+ int preferred_align;
+
+ tbm_surface_h buffers[3];
+
+ tdm_info_capture info;
+
+ tdm_output *output;
+ unsigned int pipe;
+ const tdm_output_mode *mode;
+
+ tdm_layer *dst_layer;
+ int dst_zpos;
+ int dst_layer_index;
+ tdm_pos dst_pos;
+
+ bool stream_exit;
+ int stream_count;
+
+ TDMBackendCapture();
+ void SetUp(void);
+ void TearDown(void);
+
+ bool FindLayer(int output_idx, tbm_format fmt, tdm_pos *punch);
+ bool TestPrepareDefault(void);
+ bool TestPrepare(int output_idx, int w, int h, tbm_format fmt, tdm_transform t, tdm_capture_type c, int frequency, bool stretch);
+ void TestDone(void);
+ void ShowBuffer(int b, tdm_pos *pos);
+ void HideLayer(void);
+ void DumpBuffer(int b, char *test);
+ void DestroyBuffers(void);
+};
+
+TDMBackendCapture::TDMBackendCapture()
+{
+ has_capture_cap = false;
+ capture = NULL;
+ capabilities = (tdm_capture_capability)0;
+ formats = NULL;
+ format_count = 0;
+ min_w = min_h = max_w = max_h = preferred_align = -1;
+
+ for (int b = 0; b < 3; b++)
+ buffers[b] = NULL;
+ memset(&info, 0, sizeof info);
+
+ output = NULL;
+ pipe = 0;
+ mode = NULL;
+
+ dst_layer = NULL;
+ dst_zpos = 0;
+ dst_layer_index = 0;
+ memset(&dst_pos, 0, sizeof dst_pos);
+
+ stream_exit = false;
+ stream_count = 0;
+}
+
+void TDMBackendCapture::SetUp(void)
+{
+ tdm_display_capability dpy_capabilities;
+
+ TDMBackendDisplay::SetUp();
+
+ ASSERT_EQ(tdm_display_get_capabilities(dpy, &dpy_capabilities), TDM_ERROR_NONE);
+ has_capture_cap = dpy_capabilities & TDM_DISPLAY_CAPABILITY_CAPTURE;
+
+ if (!has_capture_cap)
+ return;
+
+ ASSERT_EQ(tdm_display_get_capture_capabilities(dpy, &capabilities), TDM_ERROR_NONE);
+ ASSERT_GT(capabilities, 0);
+ ASSERT_EQ(tdm_display_get_capture_available_formats(dpy, &formats, &format_count), TDM_ERROR_NONE);
+ ASSERT_NE(formats, NULL);
+ ASSERT_GT(format_count, 0);
+ ASSERT_EQ(tdm_display_get_capture_available_size(dpy, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_NONE);
+ ASSERT_TRUE(min_w == -1 || min_w > 0);
+ ASSERT_TRUE(min_h == -1 || min_h > 0);
+ ASSERT_TRUE(max_w == -1 || max_w > 0);
+ ASSERT_TRUE(max_h == -1 || max_h > 0);
+ ASSERT_TRUE(preferred_align == -1 || preferred_align > 0);
+
+ for (int o = 0; o < output_count; o++) {
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_prepare(dpy, outputs[o], true), true);
+ }
+}
+
+void TDMBackendCapture::TearDown(void)
+{
+ if (capture)
+ tdm_capture_destroy(capture);
+
+ for (int o = 0; o < output_count; o++) {
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_unset(dpy, outputs[o]), true);
+ }
+
+ DestroyBuffers();
+
+ TDMBackendDisplay::TearDown();
+}
+
+bool TDMBackendCapture::FindLayer(int output_idx, tbm_format fmt, tdm_pos *punch)
+{
+ tdm_error ret;
+ int count;
+ int primary_zpos, zpos;
+ tdm_layer *primary = tc_tdm_output_get_primary_layer(outputs[output_idx]);
+ TDM_UT_RETURN_FALSE_IF_FAIL(primary != NULL);
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_layer_count(outputs[output_idx], &count) == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_zpos(primary, &primary_zpos) == TDM_ERROR_NONE);
+
+ dst_layer = NULL;
+
+ for (int l = 0; l < count; l++) {
+ unsigned int usable;
+ const tbm_format *dst_formats;
+ int dst_format_count;
+
+ tdm_layer *temp = tdm_output_get_layer(outputs[output_idx], l, &ret);
+ TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(temp != NULL);
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_is_usable(temp, &usable) == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_zpos(temp, &zpos) == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_available_formats(temp, &dst_formats, &dst_format_count) == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(dst_formats != NULL);
+ TDM_UT_RETURN_FALSE_IF_FAIL(dst_format_count > 0);
+
+ if (usable) {
+ bool found = false;
+ for (int f = 0; f < dst_format_count; f++) {
+ if (dst_formats[f] == fmt) {
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ continue;
+ dst_layer = temp;
+ dst_zpos = zpos;
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_index(dst_layer, &dst_layer_index) == TDM_ERROR_NONE);
+ break;
+ }
+ }
+
+ if (dst_layer && (dst_zpos < primary_zpos)) {
+ tbm_surface_h displaying_buffer = tdm_layer_get_displaying_buffer(primary, &ret);
+ TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(displaying_buffer != NULL);
+ tdm_helper_clear_buffer_pos(displaying_buffer, punch);
+ }
+
+ return true;
+}
+
+bool TDMBackendCapture::TestPrepareDefault(void)
+{
+ tdm_error ret;
+
+ for (int o = 0; o < output_count; o++) {
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ capture = tdm_output_create_capture(outputs[o], &ret);
+ TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(capture != NULL);
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(tc_tdm_buffer_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[0], 0, false, 3, buffers) == true);
+ TDM_UT_RETURN_FALSE_IF_FAIL(tc_tdm_capture_fill_info(outputs[o], buffers[0], TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1, false, &info) == true);
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_capture_set_info(capture, &info) == TDM_ERROR_NONE);
+
+ output = outputs[o];
+
+ if (capture)
+ break;
+ }
+
+ return (capture) ? true : false;
+}
+
+bool TDMBackendCapture::TestPrepare(int output_idx, int w, int h, tbm_format fmt, tdm_transform t, tdm_capture_type c, int frequency, bool stretch)
+{
+ tdm_error ret;
+ int flags = 0;
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(outputs != NULL);
+ TDM_UT_RETURN_FALSE_IF_FAIL(output_count > 0);
+ TDM_UT_RETURN_FALSE_IF_FAIL(output_count >= output_idx);
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_display_get_capture_capabilities(dpy, &capabilities) == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(capabilities > 0);
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_display_get_capture_available_size(dpy, &min_w, &min_h, &max_w, &max_h, &preferred_align) == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(min_w == -1 || min_w > 0);
+ TDM_UT_RETURN_FALSE_IF_FAIL(min_h == -1 || min_h > 0);
+ TDM_UT_RETURN_FALSE_IF_FAIL(max_w == -1 || max_w > 0);
+ TDM_UT_RETURN_FALSE_IF_FAIL(max_h == -1 || max_h > 0);
+ TDM_UT_RETURN_FALSE_IF_FAIL(preferred_align == -1 || preferred_align > 0);
+
+ capture = tdm_output_create_capture(outputs[output_idx], &ret);
+ TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(capture != NULL);
+
+ if (dst_layer) {
+ tdm_layer_capability capabilities;
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_capabilities(dst_layer, &capabilities) == TDM_ERROR_NONE);
+ if (capabilities & TDM_LAYER_CAPABILITY_SCANOUT)
+ flags |= TBM_BO_SCANOUT;
+ }
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(tc_tdm_buffer_create(w, h, fmt, flags, false, 3, buffers) == true);
+ TDM_UT_RETURN_FALSE_IF_FAIL(tc_tdm_capture_fill_info(outputs[output_idx], buffers[0], t, c, frequency, stretch, &info) == true);
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_capture_set_info(capture, &info) == TDM_ERROR_NONE);
+
+ output = outputs[output_idx];
+
+ return true;
+}
+
+void TDMBackendCapture::TestDone(void)
+{
+ if (capture) {
+ tdm_capture_destroy(capture);
+ capture = NULL;
+ }
+
+ DestroyBuffers();
+}
+
+void TDMBackendCapture::DumpBuffer(int b, char *test)
+{
+ char filename[256];
+ if (test)
+ snprintf(filename, sizeof filename, "%s_%s_%d", typeid(*this).name(), test, b);
+ else
+ snprintf(filename, sizeof filename, "%s_%d", typeid(*this).name(), b);
+ tdm_helper_dump_buffer_str(buffers[b], NULL, filename);
+}
+
+void TDMBackendCapture::ShowBuffer(int b, tdm_pos *pos)
+{
+ ASSERT_NE(output, NULL);
+ ASSERT_NE(dst_layer, NULL);
+
+ ASSERT_EQ(tc_tdm_layer_set_buffer_with_pos(dst_layer, buffers[b], pos), true);
+ ASSERT_EQ(tdm_output_commit(output, 0, NULL, NULL), TDM_ERROR_NONE);
+}
+
+void TDMBackendCapture::HideLayer(void)
+{
+ ASSERT_NE(output, NULL);
+ ASSERT_NE(dst_layer, NULL);
+
+ tdm_layer_unset_buffer(dst_layer);
+ tdm_output_commit(output, 0, NULL, NULL);
+
+ dst_layer = NULL;
+}
+
+void TDMBackendCapture::DestroyBuffers(void)
+{
+ for (int b = 0; b < 3; b++) {
+ tbm_surface_destroy(buffers[b]);
+ buffers[b] = NULL;
+ }
+}
+
+static void
+_tc_tdm_capture_fit_rect(int src_w, int src_h, int dst_w, int dst_h, tdm_pos *fit)
+{
+ float rw, rh;
+
+ if (src_w <= 0 || src_h <= 0 || dst_w <= 0 || dst_h <= 0 || !fit)
+ return;
+
+ rw = (float)src_w / dst_w;
+ rh = (float)src_h / dst_h;
+
+ if (rw > rh) {
+ fit->w = dst_w;
+ fit->h = src_h / rw;
+ fit->x = 0;
+ fit->y = (dst_h - fit->h) / 2;
+ } else if (rw < rh) {
+ fit->w = src_w / rh;
+ fit->h = dst_h;
+ fit->x = (dst_w - fit->w) / 2;
+ fit->y = 0;
+ } else {
+ fit->w = dst_w;
+ fit->h = dst_h;
+ fit->x = 0;
+ fit->y = 0;
+ }
+
+ if (fit->x % 2)
+ fit->x = fit->x - 1;
+}
+
+bool
+tc_tdm_capture_fill_info(tdm_output *output, tbm_surface_h buffer, tdm_transform transform,
+ tdm_capture_type type, int frequency, bool stretch, tdm_info_capture *info)
+{
+ int bw, bh;
+ const tdm_output_mode *mode = NULL;
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_mode(output, &mode) == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(mode != NULL);
+
+ memset(info, 0, sizeof *info);
+
+ bw = bh = TDM_UT_INVALID_VALUE;
+ tdm_helper_get_buffer_full_size(buffer, &bw, &bh);
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(bw != TDM_UT_INVALID_VALUE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(bw >= tbm_surface_get_width(buffer));
+ TDM_UT_RETURN_FALSE_IF_FAIL(bh != TDM_UT_INVALID_VALUE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(bh >= tbm_surface_get_height(buffer));
+ info->dst_config.size.h = bw;
+ info->dst_config.size.v = bh;
+
+ if (stretch) {
+ info->dst_config.pos.x = 0;
+ info->dst_config.pos.y = 0;
+ info->dst_config.pos.w = tbm_surface_get_width(buffer);
+ info->dst_config.pos.h = tbm_surface_get_height(buffer);
+ } else {
+ _tc_tdm_capture_fit_rect(mode->hdisplay, mode->vdisplay,
+ tbm_surface_get_width(buffer), tbm_surface_get_height(buffer),
+ &info->dst_config.pos);
+ }
+
+ info->dst_config.format = tbm_surface_get_format(buffer);
+
+ info->transform = transform;
+ info->type = type;
+ info->flags = 0;
+
+ if (frequency <= 0)
+ frequency = mode->vrefresh;
+
+ info->frequency = frequency;
+
+ TDM_UT_INFO("filling capture info done: dst_config(%dx%d: %d,%d %dx%d: %c%c%c%c) transform(%s) type(%s) freq(%d)",
+ info->dst_config.size.h, info->dst_config.size.v,
+ info->dst_config.pos.x, info->dst_config.pos.y, info->dst_config.pos.w, info->dst_config.pos.h,
+ FOURCC_STR(info->dst_config.format),
+ tdm_transform_str(info->transform), tdm_capture_type_str(info->type), info->frequency);
+
+ return true;
+}
+
+TEST_P(TDMBackendCapture, CaptureDispalyGetAvaiableFormats)
+{
+ const tbm_format *formats = (const tbm_format *)TDM_UT_INVALID_VALUE;
+ int count = TDM_UT_INVALID_VALUE;
+ if (has_capture_cap) {
+ ASSERT_EQ(tdm_display_get_capture_available_formats(dpy, &formats, &count), TDM_ERROR_NONE);
+ ASSERT_TRUE(formats != NULL && formats != (const tbm_format *)TDM_UT_INVALID_VALUE);
+ ASSERT_TRUE(count > 0 && count != TDM_UT_INVALID_VALUE);
+ } else {
+ ASSERT_EQ(tdm_display_get_capture_available_formats(dpy, &formats, &count), TDM_ERROR_NO_CAPABILITY);
+ ASSERT_EQ(formats, (const tbm_format *)TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(count, TDM_UT_INVALID_VALUE);
+ }
+}
+
+TEST_P(TDMBackendCapture, CaptureDispalyGetAvaiableFormatsNullObject)
+{
+ const tbm_format *formats = (const tbm_format *)TDM_UT_INVALID_VALUE;
+ int count = TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_display_get_capture_available_formats(NULL, &formats, &count), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(formats, (const tbm_format *)TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(count, TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMBackendCapture, CaptureDispalyGetAvaiableFormatsNullOther)
+{
+ ASSERT_EQ(tdm_display_get_capture_available_formats(dpy, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMBackendCapture, CaptureDispalyGetAvaiableSize)
+{
+ int min_w = TDM_UT_INVALID_VALUE;
+ int min_h = TDM_UT_INVALID_VALUE;
+ int max_w = TDM_UT_INVALID_VALUE;
+ int max_h = TDM_UT_INVALID_VALUE;
+ int preferred_align = TDM_UT_INVALID_VALUE;
+ if (has_capture_cap) {
+ ASSERT_EQ(tdm_display_get_capture_available_size(dpy, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_NONE);
+ ASSERT_NE(min_w, TDM_UT_INVALID_VALUE);
+ ASSERT_NE(min_h, TDM_UT_INVALID_VALUE);
+ ASSERT_NE(max_w, TDM_UT_INVALID_VALUE);
+ ASSERT_NE(max_h, TDM_UT_INVALID_VALUE);
+ ASSERT_NE(preferred_align, TDM_UT_INVALID_VALUE);
+ } else {
+ ASSERT_EQ(tdm_display_get_capture_available_size(dpy, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_NO_CAPABILITY);
+ ASSERT_EQ(min_w, TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(min_h, TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(max_w, TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(max_h, TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(preferred_align, TDM_UT_INVALID_VALUE);
+ }
+}
+
+TEST_P(TDMBackendCapture, CaptureDispalyGetAvaiableSizeNullObject)
+{
+ int min_w = TDM_UT_INVALID_VALUE;
+ int min_h = TDM_UT_INVALID_VALUE;
+ int max_w = TDM_UT_INVALID_VALUE;
+ int max_h = TDM_UT_INVALID_VALUE;
+ int preferred_align = TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_display_get_capture_available_size(NULL, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(min_w, TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(min_h, TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(max_w, TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(max_h, TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(preferred_align, TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMBackendCapture, CaptureDispalyGetAvaiableSizeNullOther)
+{
+ if (has_capture_cap)
+ ASSERT_EQ(tdm_display_get_capture_available_size(dpy, NULL, NULL, NULL, NULL, NULL), TDM_ERROR_NONE);
+ else
+ ASSERT_EQ(tdm_display_get_capture_available_size(dpy, NULL, NULL, NULL, NULL, NULL), TDM_ERROR_NO_CAPABILITY);
+}
+
+TEST_P(TDMBackendCapture, CaptureDestroy)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+ TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
+
+ ASSERT_EQ(TestPrepareDefault(), true);
+
+ TestDone();
+}
+
+TEST_P(TDMBackendCapture, CaptureDestroyNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+ TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
+
+ tdm_capture_destroy(NULL);
+}
+
+TEST_P(TDMBackendCapture, CaptureSetInfo)
+{
+ /* tested in CaptureNoScaleNoTransformNoCSC */
+}
+
+TEST_P(TDMBackendCapture, CaptureSetInfoNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+ TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
+
+ tdm_info_capture info;
+ memset(&info, 0, sizeof info);
+ ASSERT_EQ(tdm_capture_set_info(NULL, &info), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMBackendCapture, CaptureSetInfoNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+ TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
+
+ ASSERT_EQ(TestPrepareDefault(), true);
+
+ ASSERT_EQ(tdm_capture_set_info(capture, NULL), TDM_ERROR_INVALID_PARAMETER);
+
+ TestDone();
+}
+
+static void
+_tc_tdm_capture_done_cb(tdm_capture *capture, tbm_surface_h buffer, void *user_data)
+{
+ bool *done = (bool*)user_data;
+ if (done)
+ *done = true;
+}
+
+TEST_P(TDMBackendCapture, CaptureSetDoneHandler)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+ TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
+
+ ASSERT_EQ(TestPrepareDefault(), true);
+
+ ASSERT_EQ(tdm_capture_set_done_handler(capture, _tc_tdm_capture_done_cb, NULL), TDM_ERROR_NONE);
+
+ TestDone();
+}
+
+TEST_P(TDMBackendCapture, CaptureSetDoneHandlerNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+ TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
+
+ ASSERT_EQ(tdm_capture_set_done_handler(NULL, _tc_tdm_capture_done_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMBackendCapture, CaptureSetDoneHandlerNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+ TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
+
+ ASSERT_EQ(TestPrepareDefault(), true);
+
+ ASSERT_EQ(tdm_capture_set_done_handler(capture, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
+
+ TestDone();
+}
+
+TEST_P(TDMBackendCapture, CaptureAttach)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+ TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
+
+ for (int o = 0; o < output_count; o++) {
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ for (int f = 0; f < format_count; f++) {
+ FindLayer(o, formats[f], &dst_pos);
+
+ ASSERT_EQ(TestPrepare(o, TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
+ TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1, false), true);
+
+ for (int b = 0; b < 3; b++)
+ ASSERT_EQ(tdm_capture_attach(capture, buffers[b]), TDM_ERROR_NONE);
+
+ TestDone();
+ }
+ }
+}
+
+TEST_P(TDMBackendCapture, CaptureAttachNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+ TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
+
+ tbm_surface_h buffer = (tbm_surface_h)TDM_UT_BUFFER_SIZE;
+
+ ASSERT_EQ(tdm_capture_attach(NULL, buffer), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMBackendCapture, CaptureAttachNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+ TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
+
+ ASSERT_EQ(TestPrepareDefault(), true);
+
+ ASSERT_EQ(tdm_capture_attach(capture, NULL), TDM_ERROR_INVALID_PARAMETER);
+
+ TestDone();
+}
+
+TEST_P(TDMBackendCapture, CaptureCommit)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+ TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
+
+ ASSERT_EQ(TestPrepareDefault(), true);
+
+ ASSERT_EQ(tdm_capture_commit(capture), TDM_ERROR_NONE);
+
+ TestDone();
+}
+
+TEST_P(TDMBackendCapture, CaptureCommitNullOBject)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+ TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
+
+ ASSERT_EQ(tdm_capture_commit(NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMBackendCapture, CaptureCommitDpmsOff)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+ TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
+
+ ASSERT_EQ(TestPrepareDefault(), true);
+
+ ASSERT_EQ(tc_tdm_output_unset(dpy, output), true);
+
+ ASSERT_EQ(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
+
+ ASSERT_EQ(tdm_capture_commit(capture), TDM_ERROR_BAD_REQUEST);
+
+ TestDone();
+}
+
+static void
+_tc_tdm_capture_done_cb2(tdm_capture *capture, tbm_surface_h buffer, void *user_data)
+{
+ int *done = (int*)user_data;
+ if (done)
+ (*done)++;
+}
+
+TEST_P(TDMBackendCapture, CaptureDestroyWithoutCommit)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+ TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
+
+ for (int o = 0; o < output_count; o++) {
+ const tdm_output_mode *mode = NULL;
+ int f = 0;
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE);
+
+ FindLayer(o, formats[f], &dst_pos);
+
+ ASSERT_EQ(TestPrepare(o, TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
+ TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1, false), true);
+
+ ASSERT_EQ(tdm_capture_set_done_handler(capture, _tc_tdm_capture_done_cb2, NULL), TDM_ERROR_NONE);
+
+ for (int b = 0; b < 3; b++)
+ ASSERT_EQ(tdm_capture_attach(capture, buffers[b]), TDM_ERROR_NONE);
+
+ tdm_capture_destroy(capture);
+ capture = NULL;
+
+ TestDone();
+ }
+}
+
+TEST_P(TDMBackendCapture, CaptureDestroyBeforeDone)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+ TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
+
+ for (int o = 0; o < output_count; o++) {
+ const tdm_output_mode *mode = NULL;
+ int f = 0;
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE);
+
+ FindLayer(o, formats[f], &dst_pos);
+
+ ASSERT_EQ(TestPrepare(o, TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
+ TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1, false), true);
+
+ ASSERT_EQ(tdm_capture_set_done_handler(capture, _tc_tdm_capture_done_cb2, NULL), TDM_ERROR_NONE);
+
+ for (int b = 0; b < 3; b++)
+ ASSERT_EQ(tdm_capture_attach(capture, buffers[b]), TDM_ERROR_NONE);
+
+ ASSERT_EQ(tdm_capture_commit(capture), TDM_ERROR_NONE);
+
+ tdm_capture_destroy(capture);
+ capture = NULL;
+
+ TestDone();
+ }
+}
+
+TEST_P(TDMBackendCapture, CaptureOneshotLetterboxSize)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+ TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
+ TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_ONESHOT);
+
+ bool done;
+
+ for (int o = 0; o < output_count; o++) {
+ const tdm_output_mode *mode = NULL;
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE);
+
+ for (int f = 0; f < format_count; f++) {
+ int half_size = ((mode->hdisplay <= mode->vdisplay) ? mode->hdisplay : mode->vdisplay) / 2;
+
+ dst_pos.x = (mode->hdisplay - half_size) / 2;
+ dst_pos.y = (mode->vdisplay - half_size) / 2;
+ dst_pos.w = half_size;
+ dst_pos.h = half_size;
+
+ TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(formats[f]));
+
+ FindLayer(o, formats[f], &dst_pos);
+
+ if (!dst_layer) {
+ TDM_UT_INFO("no proper layer for %c%c%c%c", FOURCC_STR(formats[f]));
+ continue;
+ }
+
+ ASSERT_EQ(TestPrepare(o, half_size, half_size, formats[f],
+ TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1, false), true);
+
+ ASSERT_EQ(tdm_capture_set_done_handler(capture, _tc_tdm_capture_done_cb, &done), TDM_ERROR_NONE);
+
+retry:
+ for (int b = 0; b < 3; b++) {
+ done = false;
+ ASSERT_EQ(tdm_capture_attach(capture, buffers[b]), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_capture_commit(capture), TDM_ERROR_NONE);
+
+ while (!done)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+
+#if 0
+ char temp[256];
+ snprintf(temp, sizeof temp, "f%d_b%d", f, b);
+ DumpBuffer(b, temp);
+#endif
+ ShowBuffer(b, &dst_pos);
+ }
+
+ TDM_UT_ASK_YNR("* Successed to capture a output to a '%c%c%c%c' buffer as letterbox size and show? (output: %d, layer: %d)",
+ FOURCC_STR(formats[f]), pipe, dst_layer_index);
+
+
+ HideLayer();
+
+ TestDone();
+ }
+ }
+}
+
+TEST_P(TDMBackendCapture, CaptureOneshotFullSize)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+ TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
+ TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_ONESHOT);
+
+ bool done;
+
+ for (int o = 0; o < output_count; o++) {
+ const tdm_output_mode *mode = NULL;
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE);
+
+ for (int f = 0; f < format_count; f++) {
+ int half_size = ((mode->hdisplay <= mode->vdisplay) ? mode->hdisplay : mode->vdisplay) / 2;
+
+ dst_pos.x = (mode->hdisplay - half_size) / 2;
+ dst_pos.y = (mode->vdisplay - half_size) / 2;
+ dst_pos.w = half_size;
+ dst_pos.h = half_size;
+
+ TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(formats[f]));
+
+ FindLayer(o, formats[f], &dst_pos);
+
+ if (!dst_layer) {
+ TDM_UT_INFO("no proper layer for %c%c%c%c", FOURCC_STR(formats[f]));
+ continue;
+ }
+
+ ASSERT_EQ(TestPrepare(o, half_size, half_size, formats[f],
+ TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1, true), true);
+
+ ASSERT_EQ(tdm_capture_set_done_handler(capture, _tc_tdm_capture_done_cb, &done), TDM_ERROR_NONE);
+
+retry:
+ for (int b = 0; b < 3; b++) {
+ done = false;
+ ASSERT_EQ(tdm_capture_attach(capture, buffers[b]), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_capture_commit(capture), TDM_ERROR_NONE);
+
+ while (!done)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+
+#if 0
+ char temp[256];
+ snprintf(temp, sizeof temp, "f%d_b%d", f, b);
+ DumpBuffer(b, temp);
+#endif
+ ShowBuffer(b, &dst_pos);
+ }
+
+ TDM_UT_ASK_YNR("* Successed to capture a output to a '%c%c%c%c' buffer as full size and show? (output: %d, layer: %d)",
+ FOURCC_STR(formats[f]), pipe, dst_layer_index);
+
+
+ HideLayer();
+
+ TestDone();
+ }
+ }
+}
+
+TEST_P(TDMBackendCapture, CaptureOneshotAttachFewTimesInOneCommit)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+ TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
+ TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_ONESHOT);
+
+ int done;
+
+ for (int o = 0; o < output_count; o++) {
+ const tdm_output_mode *mode = NULL;
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE);
+
+ for (int f = 0; f < format_count; f++) {
+ int half_size = ((mode->hdisplay <= mode->vdisplay) ? mode->hdisplay : mode->vdisplay) / 2;
+
+ dst_pos.x = (mode->hdisplay - half_size) / 2;
+ dst_pos.y = (mode->vdisplay - half_size) / 2;
+ dst_pos.w = half_size;
+ dst_pos.h = half_size;
+
+ TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(formats[f]));
+
+ FindLayer(o, formats[f], &dst_pos);
+
+ if (!dst_layer) {
+ TDM_UT_INFO("no proper layer for %c%c%c%c", FOURCC_STR(formats[f]));
+ continue;
+ }
+
+ ASSERT_EQ(TestPrepare(o, half_size, half_size, formats[f],
+ TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1, false), true);
+
+ done = 0;
+ ASSERT_EQ(tdm_capture_set_done_handler(capture, _tc_tdm_capture_done_cb2, &done), TDM_ERROR_NONE);
+
+retry:
+ for (int b = 0; b < 3; b++)
+ ASSERT_EQ(tdm_capture_attach(capture, buffers[b]), TDM_ERROR_NONE);
+
+ ASSERT_EQ(tdm_capture_commit(capture), TDM_ERROR_NONE);
+
+ while (done != 3)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+
+ for (int b = 0; b < 3; b++) {
+#if 0
+ char temp[256];
+ snprintf(temp, sizeof temp, "f%d_b%d", f, b);
+ DumpBuffer(b, temp);
+#endif
+ ShowBuffer(b, &dst_pos);
+ }
+
+ TDM_UT_ASK_YNR("* Successed to capture a output to a '%c%c%c%c' buffer as letterbox size and show? (output: %d, layer: %d)",
+ FOURCC_STR(formats[f]), pipe, dst_layer_index);
+
+
+ HideLayer();
+
+ TestDone();
+ }
+ }
+}
+
+static void
+_tc_tdm_backend_capture_buffer_release_cb(tbm_surface_h buffer, void *user_data)
+{
+ TDMBackendCapture *backend_capture = (TDMBackendCapture*)user_data;
+
+ tdm_buffer_remove_release_handler(buffer, _tc_tdm_backend_capture_buffer_release_cb, backend_capture);
+
+ ASSERT_EQ(tdm_capture_attach(backend_capture->capture, buffer), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_capture_commit(backend_capture->capture), TDM_ERROR_NONE);
+}
+
+static void
+_tc_tdm_capture_stream_done_cb(tdm_capture *capture, tbm_surface_h buffer, void *user_data)
+{
+ TDMBackendCapture *backend_capture = (TDMBackendCapture*)user_data;
+
+ for (int b = 0; b < 3; b++) {
+ if (backend_capture->buffers[b] == buffer) {
+#if 0
+ char temp[256];
+ snprintf(temp, sizeof temp, "f%d_b%d", f, b);
+ DumpBuffer(b, temp);
+#endif
+ tdm_buffer_add_release_handler(buffer, _tc_tdm_backend_capture_buffer_release_cb, (void*)backend_capture);
+ backend_capture->ShowBuffer(b, &backend_capture->dst_pos);
+ break;
+ }
+ }
+
+ if (--backend_capture->stream_count == 0) {
+ backend_capture->stream_exit = 1;
+ }
+}
+
+TEST_P(TDMBackendCapture, CaptureStreamLetterboxSize)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+ TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
+ TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_STREAM);
+
+ for (int o = 0; o < output_count; o++) {
+ const tdm_output_mode *mode = NULL;
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE);
+
+ for (int f = 0; f < format_count; f++) {
+ int half_size = ((mode->hdisplay <= mode->vdisplay) ? mode->hdisplay : mode->vdisplay) / 2;
+
+ dst_pos.x = (mode->hdisplay - half_size) / 2;
+ dst_pos.y = (mode->vdisplay - half_size) / 2;
+ dst_pos.w = half_size;
+ dst_pos.h = half_size;
+
+ TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(formats[f]));
+
+ FindLayer(o, formats[f], &dst_pos);
+
+ if (!dst_layer) {
+ TDM_UT_INFO("no proper layer for %c%c%c%c", FOURCC_STR(formats[f]));
+ continue;
+ }
+
+ ASSERT_EQ(TestPrepare(o, half_size, half_size, formats[f],
+ TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_STREAM, -1, false), true);
+
+ ASSERT_EQ(tdm_capture_set_done_handler(capture, _tc_tdm_capture_stream_done_cb, (void*)this), TDM_ERROR_NONE);
+
+ for (int b = 0; b < 3; b++)
+ ASSERT_EQ(tdm_capture_attach(capture, buffers[b]), TDM_ERROR_NONE);
+
+retry:
+
+ stream_exit = false;
+ stream_count = 30;
+
+ ASSERT_EQ(tdm_capture_commit(capture), TDM_ERROR_NONE);
+
+ while (!stream_exit)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+
+ TDM_UT_ASK_YNR("* Successed to capture a output to a '%c%c%c%c' buffer as letterbox size and show? (output: %d, layer: %d)",
+ FOURCC_STR(formats[f]), pipe, dst_layer_index);
+
+
+ HideLayer();
+
+ TestDone();
+ }
+ }
+}
+
+TEST_P(TDMBackendCapture, CaptureStreamFullSize)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+ TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
+ TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_STREAM);
+
+ for (int o = 0; o < output_count; o++) {
+ const tdm_output_mode *mode = NULL;
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE);
+
+ for (int f = 0; f < format_count; f++) {
+ int half_size = ((mode->hdisplay <= mode->vdisplay) ? mode->hdisplay : mode->vdisplay) / 2;
+
+ dst_pos.x = (mode->hdisplay - half_size) / 2;
+ dst_pos.y = (mode->vdisplay - half_size) / 2;
+ dst_pos.w = half_size;
+ dst_pos.h = half_size;
+
+ TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(formats[f]));
+
+ FindLayer(o, formats[f], &dst_pos);
+
+ if (!dst_layer) {
+ TDM_UT_INFO("no proper layer for %c%c%c%c", FOURCC_STR(formats[f]));
+ continue;
+ }
+
+ ASSERT_EQ(TestPrepare(o, half_size, half_size, formats[f],
+ TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_STREAM, -1, true), true);
+
+ ASSERT_EQ(tdm_capture_set_done_handler(capture, _tc_tdm_capture_stream_done_cb, (void*)this), TDM_ERROR_NONE);
+
+ for (int b = 0; b < 3; b++)
+ ASSERT_EQ(tdm_capture_attach(capture, buffers[b]), TDM_ERROR_NONE);
+
+retry:
+
+ stream_exit = false;
+ stream_count = 30;
+
+ ASSERT_EQ(tdm_capture_commit(capture), TDM_ERROR_NONE);
+
+ while (!stream_exit)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+
+ TDM_UT_ASK_YNR("* Successed to capture a output to a '%c%c%c%c' buffer as full size and show? (output: %d, layer: %d)",
+ FOURCC_STR(formats[f]), pipe, dst_layer_index);
+
+
+ HideLayer();
+
+ TestDone();
+ }
+ }
+}
+
+#ifdef TDM_UT_TEST_WITH_PARAMS
+INSTANTIATE_TEST_CASE_P(TDMBackendCaptureParams,
+ TDMBackendCapture,
+ Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
+#else
+INSTANTIATE_TEST_CASE_P(TDMBackendCaptureParams,
+ TDMBackendCapture,
+ Values(TDM_DEFAULT_MODULE));
+#endif
+
+/* LCOV_EXCL_END */
\ No newline at end of file
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
+ * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
+ * Contact: Roman Marchenko <r.marchenko@samsung.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+**************************************************************************/
+
+#include "tc_tdm.h"
+
+/* LCOV_EXCL_START */
+
+#define TDM_UT_BACKEND_TEST_CNT 20
+
+TDMBackendBasic::TDMBackendBasic()
+{
+ dpy = NULL;
+ outputs = NULL;
+ output_count = 0;
+ layers = NULL;
+ layer_count = 0;
+
+ for (int b = 0; b < 3; b++)
+ buffers[b] = NULL;
+}
+
+void TDMBackendBasic::SetUp(void)
+{
+ tdm_error ret;
+
+ TDMBackendEnv::SetUp();
+
+ dpy = tdm_display_init(&ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(dpy, NULL);
+
+ ASSERT_EQ(tdm_display_get_output_count(dpy, &output_count), TDM_ERROR_NONE);
+ ASSERT_GE(output_count, 0);
+
+ if (output_count > 0) {
+ outputs = (tdm_output**)calloc(output_count, sizeof(tdm_output*));
+ ASSERT_NE(outputs, NULL);
+
+ for (int o = 0; o < output_count; o++) {
+ tdm_error ret;
+ tdm_output *output = tdm_display_get_output(dpy, o, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(output, NULL);
+ outputs[o] = output;
+ }
+ }
+
+ for (int o = 0; o < output_count; o++) {
+ int old_layer_count = layer_count, count = TDM_UT_INVALID_VALUE;
+ tdm_error ret;
+
+ if (tc_tdm_output_is_hwc_enable(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tdm_output_get_layer_count(outputs[o], &count), TDM_ERROR_NONE);
+ ASSERT_GT(count, 0);
+
+ layer_count += count;
+ layers = (tdm_layer**)realloc(layers, layer_count * sizeof(tdm_layer*));
+ ASSERT_NE(layers, NULL);
+
+ for (int l = 0; l < count; l++) {
+ tdm_layer *layer = tdm_output_get_layer(outputs[o], l, &ret);
+ ASSERT_NE(layer, NULL);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ layers[old_layer_count + l] = layer;
+ }
+ }
+}
+
+void TDMBackendBasic::TearDown(void)
+{
+ tdm_display_deinit(dpy);
+ dpy = NULL;
+
+ free(outputs);
+ outputs = NULL;
+ output_count = 0;
+
+ free(layers);
+ layers = NULL;
+ layer_count = 0;
+
+ DestroyBuffers();
+
+ ASSERT_EQ(tbm_bufmgr_debug_get_ref_count(), 0);
+
+ TDMBackendEnv::TearDown();
+}
+
+void TDMBackendBasic::DestroyBuffers(void)
+{
+ for (int b = 0; b < 3; b++) {
+ if (buffers[b])
+ tbm_surface_destroy(buffers[b]);
+ buffers[b] = NULL;
+ }
+}
+
+char
+tc_tdm_backend_getchar(void)
+{
+ int c = getchar();
+ int ch = c;
+
+ if (ch == '\n' || ch == '\r')
+ ch = 'y';
+ else if (ch < 'a')
+ ch += ('a' - 'A');
+
+ while (c != '\n' && c != EOF)
+ c = getchar();
+
+ return ch;
+}
+
+TEST_P(TDMBackendBasic, VerifyOutputObject)
+{
+ tdm_error ret;
+ int output_count = 0;
+
+ ASSERT_EQ(tdm_display_get_output_count(dpy, &output_count), TDM_ERROR_NONE);
+ TDM_UT_ASSERT_TRUE(output_count > 0, "output count(%d) should be greater than 0. Check display_get_outputs().");
+
+ for (int o = 0; o < output_count; o++) {
+ tdm_output *output = tdm_display_get_output(dpy, o, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ TDM_UT_ASSERT_TRUE(output != NULL, "no output. (output: %d). Check display_get_outputs().", o);
+ }
+}
+
+TEST_P(TDMBackendBasic, VerifyLayerObject)
+{
+ tdm_error ret;
+ int output_count = 0;
+
+ ASSERT_EQ(tdm_display_get_output_count(dpy, &output_count), TDM_ERROR_NONE);
+
+ for (int o = 0; o < output_count; o++) {
+ tdm_output *output = tdm_display_get_output(dpy, o, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+
+ int layer_count = 0;
+ ASSERT_EQ(tdm_output_get_layer_count(output, &layer_count), TDM_ERROR_NONE);
+ TDM_UT_ASSERT_TRUE(layer_count > 0,
+ "layer count(%d) should be greater than 0. (output: %d). Check output_get_layers().",
+ layer_count, o);
+
+ for (int l = 0; l < layer_count; l++) {
+ tdm_layer *layer = tdm_output_get_layer(output, l, &ret);
+ TDM_UT_ASSERT_TRUE(layer != NULL, "no layer. (output: %d, layer: %d). Check output_get_layers().", o, l);
+ }
+ }
+}
+
+TEST_P(TDMBackendBasic, VerifyOutputGetProperty)
+{
+ tdm_error ret;
+ int output_count = 0;
+
+ ASSERT_EQ(tdm_display_get_output_count(dpy, &output_count), TDM_ERROR_NONE);
+
+ for (int o = 0; o < output_count; o++) {
+ tdm_output *output = tdm_display_get_output(dpy, o, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+
+ const tdm_prop *props = NULL;
+ int prop_count = 0;
+ ASSERT_EQ(tdm_output_get_available_properties(output, &props, &prop_count), TDM_ERROR_NONE);
+
+ if (prop_count > 0)
+ TDM_UT_ASSERT_TRUE(props != NULL, "no props. (output: %d). Check output_get_capability(), tdm_caps_output.", o);
+
+ for (int p = 0; p < prop_count; p++) {
+ tdm_value value;
+ value.s32 = TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_output_get_property(output, props[p].id, &value), TDM_ERROR_NONE);
+ TDM_UT_ASSERT_TRUE(value.s32 != TDM_UT_INVALID_VALUE,
+ "Getting a prop failed. (output: %d, prop_id: %d). Check output_get_property().",
+ o, props[p].id);
+ }
+ }
+}
+
+TEST_P(TDMBackendBasic, VerifyLayerGetProperty)
+{
+ tdm_error ret;
+ int output_count = 0;
+
+ ASSERT_EQ(tdm_display_get_output_count(dpy, &output_count), TDM_ERROR_NONE);
+
+ for (int o = 0; o < output_count; o++) {
+ tdm_output *output = tdm_display_get_output(dpy, o, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+
+ int layer_count = 0;
+ ASSERT_EQ(tdm_output_get_layer_count(output, &layer_count), TDM_ERROR_NONE);
+
+ for (int l = 0; l < layer_count; l++) {
+ tdm_layer *layer = tdm_output_get_layer(output, l, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+
+ const tdm_prop *props = NULL;
+ int prop_count = 0;
+ ASSERT_EQ(tdm_layer_get_available_properties(layer, &props, &prop_count), TDM_ERROR_NONE);
+
+ if (prop_count > 0)
+ TDM_UT_ASSERT_TRUE(props != NULL, "no props. (output: %d, layer: %d). Check output_get_capability(), tdm_caps_output.", o, l);
+
+ for (int p = 0; p < prop_count; p++) {
+ tdm_value value;
+ value.s32 = TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_layer_get_property(layer, props[p].id, &value), TDM_ERROR_NONE);
+ TDM_UT_ASSERT_TRUE(value.s32 != TDM_UT_INVALID_VALUE,
+ "Getting a prop failed. (output: %d, layer: %d, prop_id: %d). Check output_get_property().",
+ o, l, props[p].id);
+ }
+ }
+ }
+}
+
+TEST_P(TDMBackendBasic, VerifyOutputSetMode)
+{
+ for (int o = 0; o < output_count; o++) {
+ const tdm_output_mode *got_mode = NULL;
+ const tdm_output_mode *modes = (const tdm_output_mode *)TDM_UT_INVALID_VALUE;
+ const tdm_output_mode *set_mode = NULL;
+ const tdm_output_mode *best = NULL;
+ int count = TDM_UT_INVALID_VALUE;
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tdm_output_get_available_modes(outputs[o], &modes, &count), TDM_ERROR_NONE);
+ TDM_UT_ASSERT_TRUE(count > 0, "mode's count should be greater than 0. Check output_get_capability(), tdm_caps_output.");
+ TDM_UT_ASSERT_TRUE(modes != NULL, "mode's count should be greater than 0. Check output_get_capability(), tdm_caps_output.");
+
+ for (int i = 0; i < count; i++) {
+ if (!best)
+ best = &modes[i];
+ if (modes[i].type & TDM_OUTPUT_MODE_TYPE_PREFERRED)
+ set_mode = &modes[i];
+ }
+ if (!set_mode && best)
+ set_mode = best;
+ ASSERT_NE(set_mode, NULL);
+
+ ASSERT_EQ(tdm_output_set_mode(outputs[o], set_mode), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_get_mode(outputs[o], &got_mode), TDM_ERROR_NONE);
+ TDM_UT_ASSERT_TRUE(set_mode == got_mode, "The mode which is set and got are different. Check output_set_mode(), output_get_mode()");
+ }
+}
+
+TEST_P(TDMBackendBasic, VerifyOutputSetDpms)
+{
+ for (int o = 0; o < output_count; o++) {
+ const tdm_output_mode *got_mode = NULL;
+ const tdm_output_mode *modes = (const tdm_output_mode *)TDM_UT_INVALID_VALUE;
+ const tdm_output_mode *set_mode = NULL;
+ const tdm_output_mode *best = NULL;
+ int count = TDM_UT_INVALID_VALUE;
+ tdm_output_dpms got_dpms = TDM_OUTPUT_DPMS_OFF;
+ tdm_output_dpms set_dpms = TDM_OUTPUT_DPMS_ON;
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tdm_output_get_available_modes(outputs[o], &modes, &count), TDM_ERROR_NONE);
+ ASSERT_GT(count, 0);
+ ASSERT_NE(modes, NULL);
+
+ for (int i = 0; i < count; i++) {
+ if (!best)
+ best = &modes[i];
+ if (modes[i].type & TDM_OUTPUT_MODE_TYPE_PREFERRED)
+ set_mode = &modes[i];
+ }
+ if (!set_mode && best)
+ set_mode = best;
+
+ ASSERT_NE(set_mode, NULL);
+ ASSERT_EQ(tdm_output_set_mode(outputs[o], set_mode), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_get_mode(outputs[o], &got_mode), TDM_ERROR_NONE);
+ ASSERT_EQ(set_mode, got_mode);
+
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], set_dpms), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_get_dpms(outputs[o], &got_dpms), TDM_ERROR_NONE);
+ TDM_UT_ASSERT_TRUE(set_dpms == got_dpms, "The dpms value which is set and got are different. Check output_set_dpms(), output_get_dpms()");
+ }
+}
+
+TEST_P(TDMBackendBasic, VerifyPrimaryLayerShowOneFrame)
+{
+ for (int o = 0; o < output_count; o++) {
+ tdm_layer *layer;
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_mode_setting(outputs[o]), true);
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
+
+ layer = tc_tdm_output_get_primary_layer(outputs[o]);
+ ASSERT_NE(layer, NULL);
+
+retry:
+ ASSERT_EQ(tc_tdm_layer_prepare_buffer(layer, buffers, 1, true), true);
+ ASSERT_EQ(tc_tdm_layer_set_buffer(layer, buffers[0]), true);
+ DestroyBuffers();
+
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
+
+ TDM_UT_ASK_YNR("* Successed to display a frame to a primary layer? (output: %d)", o);
+
+ ASSERT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
+
+ }
+}
+
+TEST_P(TDMBackendBasic, VerifyPrimaryLayerShowManyFrames)
+{
+ for (int o = 0; o < output_count; o++) {
+ tdm_layer *layer;
+ int next_buffer = 0;
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_mode_setting(outputs[o]), true);
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
+
+ layer = tc_tdm_output_get_primary_layer(outputs[o]);
+ ASSERT_NE(layer, NULL);
+
+retry:
+ ASSERT_EQ(tc_tdm_layer_prepare_buffer(layer, buffers, 3, true), true);
+
+ /* set buffer & commit for TDM_UT_BACKEND_TEST_CNT times */
+ for (int t = 0; t < TDM_UT_BACKEND_TEST_CNT; t++) {
+ ASSERT_EQ(tc_tdm_layer_set_buffer(layer, buffers[next_buffer]), true);
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
+ usleep(40000); /* 40 ms */
+ next_buffer++;
+ if (next_buffer == 3)
+ next_buffer = 0;
+ }
+
+ DestroyBuffers();
+
+ TDM_UT_ASK_YNR("* Successed to display many frames to a primary layer? (output: %d)", o);
+
+ ASSERT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
+ }
+}
+
+static void
+_tc_tdm_backend_output_commit_cb(tdm_output *output, unsigned int sequence,
+ unsigned int tv_sec, unsigned int tv_usec,
+ void *user_data)
+{
+ bool *done = (bool*)user_data;
+ if (done)
+ *done = true;
+}
+
+TEST_P(TDMBackendBasic, VerifyPrimaryLayerShowOneFrameWithCommitHandler)
+{
+ for (int o = 0; o < output_count; o++) {
+ tdm_layer *layer;
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_mode_setting(outputs[o]), true);
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
+
+ layer = tc_tdm_output_get_primary_layer(outputs[o]);
+ ASSERT_NE(layer, NULL);
+
+retry:
+ ASSERT_EQ(tc_tdm_layer_prepare_buffer(layer, buffers, 1, true), true);
+ ASSERT_EQ(tc_tdm_layer_set_buffer(layer, buffers[0]), true);
+ DestroyBuffers();
+
+ bool done = false;
+ TDM_UT_ASSERT_TRUE(tdm_output_commit(outputs[o], 0, _tc_tdm_backend_output_commit_cb, &done) == TDM_ERROR_NONE,
+ "Check output_commit(), output_set_commit_handler()");
+ while (!done)
+ TDM_UT_ASSERT_TRUE(tc_tdm_display_handle_events(dpy) == TDM_ERROR_NONE,
+ "Check display_get_fd(), display_handle_events()");
+
+ TDM_UT_ASK_YNR("* Successed to display a frame to a primary layer? (output: %d)", o);
+
+ ASSERT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
+ }
+}
+
+TEST_P(TDMBackendBasic, VerifyOverlayLayersShowOneFrame)
+{
+ for (int o = 0; o < output_count; o++) {
+ tdm_layer *layer;
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_mode_setting(outputs[o]), true);
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
+
+ layer = tc_tdm_output_get_primary_layer(outputs[o]);
+ ASSERT_NE(layer, NULL);
+
+ ASSERT_EQ(tc_tdm_layer_prepare_buffer(layer, buffers, 1, false), true);
+ ASSERT_EQ(tc_tdm_layer_set_buffer(layer, buffers[0]), true);
+ DestroyBuffers();
+
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
+ usleep(40000); /* 40 ms */
+
+retry:
+ for (int l = 0; l < layer_count; l++) {
+ tdm_error ret;
+
+ if (tdm_layer_get_output(layers[l], &ret) != outputs[o])
+ continue;
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ if (tc_tdm_layer_is_primary_layer(layers[l]))
+ continue;
+ if (tc_tdm_layer_is_cursor_layer(layers[l]))
+ continue;
+ ASSERT_EQ(tc_tdm_layer_prepare_buffer(layers[l], buffers, 1, true), true);
+ ASSERT_EQ(tc_tdm_layer_set_buffer(layers[l], buffers[0]), true);
+ DestroyBuffers();
+ }
+
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
+
+ TDM_UT_ASK_YNR("* Successed to display frames to all overlay layers? (output: %d)", o);
+
+ for (int l = 0; l < layer_count; l++)
+ ASSERT_EQ(tdm_layer_unset_buffer(layers[l]), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
+ }
+}
+
+TEST_P(TDMBackendBasic, VerifyOverlayLayersShowManyFrames)
+{
+ for (int o = 0; o < output_count; o++) {
+ tdm_layer *layer;
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_mode_setting(outputs[o]), true);
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
+
+ layer = tc_tdm_output_get_primary_layer(outputs[o]);
+ ASSERT_NE(layer, NULL);
+
+ ASSERT_EQ(tc_tdm_layer_prepare_buffer(layer, buffers, 1, false), true);
+ ASSERT_EQ(tc_tdm_layer_set_buffer(layer, buffers[0]), true);
+ DestroyBuffers();
+
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
+ usleep(40000); /* 40 ms */
+
+ for (int l = 0; l < layer_count; l++) {
+ tdm_error ret;
+ int next_buffer = 0;
+
+ if (tdm_layer_get_output(layers[l], &ret) != outputs[o])
+ continue;
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ if (tc_tdm_layer_is_primary_layer(layers[l]))
+ continue;
+ if (tc_tdm_layer_is_cursor_layer(layers[l]))
+ continue;
+
+retry:
+ ASSERT_EQ(tc_tdm_layer_prepare_buffer(layers[l], buffers, 3, true), true);
+
+ /* set buffer & commit for TDM_UT_BACKEND_TEST_CNT times */
+ for (int t = 0; t < TDM_UT_BACKEND_TEST_CNT; t++) {
+ ASSERT_EQ(tc_tdm_layer_set_buffer(layers[l], buffers[next_buffer]), true);
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
+ usleep(40000); /* 40 ms */
+ next_buffer++;
+ if (next_buffer == 3)
+ next_buffer = 0;
+ }
+
+ DestroyBuffers();
+
+ TDM_UT_ASK_YNR("* Successed to display many frames to a layer? (output: %d, layer: %d)", o, l);
+
+ ASSERT_EQ(tdm_layer_unset_buffer(layers[l]), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
+ usleep(40000); /* 40 ms */
+ }
+ }
+}
+
+TEST_P(TDMBackendBasic, DISABLED_VerifyCursorLayer)
+{
+}
+
+static void
+_tc_tdm_backend_output_done_cb(tdm_output *output, unsigned int sequence,
+ unsigned int tv_sec, unsigned int tv_usec,
+ void *user_data)
+{
+ bool *done = (bool*)user_data;
+ if (done)
+ *done = true;
+}
+
+TEST_P(TDMBackendBasic, VerifyOutputWaitVblank)
+{
+ for (int o = 0; o < output_count; o++) {
+ tdm_layer *layer;
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_mode_setting(outputs[o]), true);
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
+
+ layer = tc_tdm_output_get_primary_layer(outputs[o]);
+ ASSERT_NE(layer, NULL);
+
+ ASSERT_EQ(tc_tdm_layer_prepare_buffer(layer, buffers, 1, true), true);
+ ASSERT_EQ(tc_tdm_layer_set_buffer(layer, buffers[0]), true);
+ DestroyBuffers();
+
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
+
+ /* start from 1 */
+ for (int t = 1; t < 10; t++) {
+ double start, end, interval;
+ bool done;
+
+ interval = tc_tdm_output_get_vblank_interval_time(outputs[o]);
+
+ done = false;
+ start = tdm_helper_get_time();
+ TDM_UT_ASSERT_TRUE(tdm_output_wait_vblank(outputs[o], t, 0, _tc_tdm_backend_output_done_cb, &done) == TDM_ERROR_NONE,
+ "Check output_wait_vblank(), output_set_vblank_handler()");
+ while (!done)
+ TDM_UT_ASSERT_TRUE(tc_tdm_display_handle_events(dpy) == TDM_ERROR_NONE,
+ "Check display_get_fd(), display_handle_events()");
+ end = tdm_helper_get_time();
+
+ /* "+ interval" consider the delay of socket communication between kernel and platform */
+ TDM_UT_ASSERT_TRUE((end - start) > (interval * (t - 1)),
+ "The vblank event should happen after %d vsync intervals(%d ms).\n"
+ "\t But it happened at %d ms. Check output_wait_vblank(), output_set_vblank_handler()",
+ t, (int)(t * interval * 1000), (int)((end - start) * 1000));
+ TDM_UT_ASSERT_TRUE((end - start) < (interval * t + interval),
+ "The vblank event should happen after %d vsync intervals(%d ms).\n"
+ "\t But it happened at %d ms. Check output_wait_vblank(), output_set_vblank_handler()",
+ t, (int)(t * interval * 1000), (int)((end - start) * 1000));
+
+ }
+ }
+}
+
+TEST_P(TDMBackendBasic, VerifyOutputWaitVblankInterval)
+{
+ for (int o = 0; o < output_count; o++) {
+ tdm_layer *layer;
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_mode_setting(outputs[o]), true);
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
+
+ layer = tc_tdm_output_get_primary_layer(outputs[o]);
+ ASSERT_NE(layer, NULL);
+
+ ASSERT_EQ(tc_tdm_layer_prepare_buffer(layer, buffers, 1, true), true);
+ ASSERT_EQ(tc_tdm_layer_set_buffer(layer, buffers[0]), true);
+ DestroyBuffers();
+
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
+
+ /* start from 1 */
+ for (int t = 1; t < 10; t++) {
+ double start, end, interval;
+ bool done;
+
+ interval = tc_tdm_output_get_vblank_interval_time(outputs[o]);
+
+ done = false;
+ start = tdm_helper_get_time();
+ ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _tc_tdm_backend_output_done_cb, &done), TDM_ERROR_NONE);
+ while (!done)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ end = tdm_helper_get_time();
+
+ /* "+ interval" consider the delay of socket communication between kernel and platform */
+ TDM_UT_ASSERT_TRUE((end - start) > (interval * (t - 1)),
+ "The vblank event should happen after %d vsync intervals(%d ms).\n"
+ "\t But it happened at %d ms. Check output_wait_vblank(), output_set_vblank_handler()",
+ t, (int)(t * interval * 1000), (int)((end - start) * 1000));
+ TDM_UT_ASSERT_TRUE((end - start) < (interval * t + interval),
+ "The vblank event should happen after %d vsync intervals(%d ms).\n"
+ "\t But it happened at %d ms. Check output_wait_vblank(), output_set_vblank_handler()",
+ t, (int)(t * interval * 1000), (int)((end - start) * 1000));
+ }
+ }
+}
+
+TEST_P(TDMBackendBasic, VerifyOutputWaitVblankFewTimesInOneVblank)
+{
+ for (int o = 0; o < output_count; o++) {
+ tdm_layer *layer;
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_mode_setting(outputs[o]), true);
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
+
+ layer = tc_tdm_output_get_primary_layer(outputs[o]);
+ ASSERT_NE(layer, NULL);
+
+ ASSERT_EQ(tc_tdm_layer_prepare_buffer(layer, buffers, 1, true), true);
+ ASSERT_EQ(tc_tdm_layer_set_buffer(layer, buffers[0]), true);
+ DestroyBuffers();
+
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
+
+ /* start from 1 */
+ for (int t = 1; t < 10; t++) {
+ double start, end, interval;
+ bool done1, done2, done3;
+
+ interval = tc_tdm_output_get_vblank_interval_time(outputs[o]);
+
+ done1 = done2 = done3 = false;
+ ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _tc_tdm_backend_output_done_cb, &done1), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _tc_tdm_backend_output_done_cb, &done2), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _tc_tdm_backend_output_done_cb, &done3), TDM_ERROR_NONE);
+ start = tdm_helper_get_time();
+ while (!done1 || !done2 || !done3)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ end = tdm_helper_get_time();
+
+ /* "+ interval" consider the delay of socket communication between kernel and platform */
+ TDM_UT_ASSERT_TRUE((end - start) > (interval * (t - 1)),
+ "The vblank event should happen after %d vsync intervals(%d ms).\n"
+ "\t But it happened at %d ms. Check output_wait_vblank(), output_set_vblank_handler()",
+ t, (int)(t * interval * 1000), (int)((end - start) * 1000));
+ TDM_UT_ASSERT_TRUE((end - start) < (interval * t + interval),
+ "The vblank event should happen after %d vsync intervals(%d ms).\n"
+ "\t But it happened at %d ms. Check output_wait_vblank(), output_set_vblank_handler()",
+ t, (int)(t * interval * 1000), (int)((end - start) * 1000));
+ }
+ }
+}
+
+TEST_P(TDMBackendBasic, VerifyPPObject)
+{
+ tdm_error ret;
+ tdm_pp *pp;
+
+ if (!tc_tdm_display_has_pp_capability(dpy)) {
+ TDM_UT_INFO("PP not supported");
+ return;
+ }
+
+ pp = tdm_display_create_pp(dpy, &ret);
+ TDM_UT_ASSERT_TRUE(ret == TDM_ERROR_NONE, "can't create a PP object. Check display_create_pp()");
+ TDM_UT_ASSERT_TRUE(pp != NULL, "can't create a PP object. Check display_create_pp()");
+
+ tdm_pp_destroy(pp);
+}
+
+TEST_P(TDMBackendBasic, VerifyPPCapabilities)
+{
+ tdm_pp_capability capabilities = (tdm_pp_capability)0;
+
+ if (!tc_tdm_display_has_pp_capability(dpy)) {
+ TDM_UT_INFO("PP not supported");
+ return;
+ }
+
+ TDM_UT_ASSERT_TRUE(tdm_display_get_pp_capabilities(dpy, &capabilities) == TDM_ERROR_NONE,
+ "Check display_get_pp_capability(), tdm_caps_pp, tdm_pp_capability.");
+ TDM_UT_ASSERT_TRUE(capabilities != (tdm_pp_capability)0,
+ "PP has no capability. Check display_get_pp_capability(), tdm_caps_pp, tdm_pp_capability.");
+}
+
+TEST_P(TDMBackendBasic, VerifyPPAvaiableSize)
+{
+ if (!tc_tdm_display_has_pp_capability(dpy)) {
+ TDM_UT_INFO("PP not supported");
+ return;
+ }
+
+ int min_w = 0;
+ int min_h = 0;
+ int max_w = 0;
+ int max_h = 0;
+ int preferred_align = 0;
+ ASSERT_EQ(tdm_display_get_pp_available_size(dpy, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_NONE);
+ ASSERT_NE(min_w, 0);
+ ASSERT_NE(min_h, 0);
+ ASSERT_NE(max_w, 0);
+ ASSERT_NE(max_h, 0);
+ ASSERT_NE(preferred_align, 0);
+}
+
+TEST_P(TDMBackendBasic, VerifyPPAvaiableFormats)
+{
+ if (!tc_tdm_display_has_pp_capability(dpy)) {
+ TDM_UT_INFO("PP not supported");
+ return;
+ }
+
+ const tbm_format *formats = NULL;
+ int format_count = 0;
+ TDM_UT_ASSERT_TRUE(tdm_display_get_pp_available_formats(dpy, &formats, &format_count) == TDM_ERROR_NONE,
+ "Check display_get_pp_capability(), tdm_caps_pp");
+ TDM_UT_ASSERT_TRUE(formats != NULL, "Should have a format table. Check display_get_pp_capability(), tdm_caps_pp.");
+ TDM_UT_ASSERT_TRUE(format_count > 0, "Format count should be greater than 0. Check display_get_pp_capability(), tdm_caps_pp.");
+}
+
+TEST_P(TDMBackendBasic, VerifyCaptureObject)
+{
+ if (!tc_tdm_display_has_capture_capability(dpy)) {
+ TDM_UT_INFO("Capture not supported.");
+ return;
+ }
+
+ for (int o = 0; o < output_count; o++) {
+ tdm_capture *capture;
+ tdm_error ret;
+
+ unsigned int has_capability = 0;
+ ASSERT_EQ(tdm_output_has_capture_capability(outputs[o], &has_capability), TDM_ERROR_NONE);
+ if (!has_capability) {
+ TDM_UT_INFO("Capture not supported. (output: %d)", o);
+ continue;
+ }
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ capture = tdm_output_create_capture(outputs[o], &ret);
+ TDM_UT_ASSERT_TRUE(ret == TDM_ERROR_NONE, "Can't create a capture object. Check output_create_capture().");
+ TDM_UT_ASSERT_TRUE(capture != NULL, "Can't create a capture object. Check output_create_capture().");
+
+ tdm_capture_destroy(capture);
+ }
+}
+
+TEST_P(TDMBackendBasic, VerifyCaptureAvaiableSize)
+{
+ if (!tc_tdm_display_has_capture_capability(dpy)) {
+ TDM_UT_INFO("Capture not supported.");
+ return;
+ }
+
+ int min_w = 0;
+ int min_h = 0;
+ int max_w = 0;
+ int max_h = 0;
+ int preferred_align = 0;
+ ASSERT_EQ(tdm_display_get_capture_available_size(dpy, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_NONE);
+ ASSERT_NE(min_w, 0);
+ ASSERT_NE(min_h, 0);
+ ASSERT_NE(max_w, 0);
+ ASSERT_NE(max_h, 0);
+ ASSERT_NE(preferred_align, 0);
+}
+
+TEST_P(TDMBackendBasic, VerifyCaptureAvaiableFormats)
+{
+ if (!tc_tdm_display_has_capture_capability(dpy)) {
+ TDM_UT_INFO("Capture not supported.");
+ return;
+ }
+
+ const tbm_format *formats = NULL;
+ int format_count = 0;
+ TDM_UT_ASSERT_TRUE(tdm_display_get_capture_available_formats(dpy, &formats, &format_count) == TDM_ERROR_NONE,
+ "Check display_get_capture_capability(), tdm_caps_capture.");
+ TDM_UT_ASSERT_TRUE(formats != NULL, "Should have a format table. Check display_get_capture_capability(), tdm_caps_capture.");
+ TDM_UT_ASSERT_TRUE(format_count > 0, "The format count should be greater than 0. Check display_get_capture_capability(), tdm_caps_capture.");
+}
+
+#ifdef TDM_UT_TEST_WITH_PARAMS
+INSTANTIATE_TEST_CASE_P(TDMBackendBasicParams,
+ TDMBackendBasic,
+ Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
+#else
+INSTANTIATE_TEST_CASE_P(TDMBackendBasicParams,
+ TDMBackendBasic,
+ Values(TDM_DEFAULT_MODULE));
+#endif
+
+TEST_P(TDMBackendDisplay, VerifyPirmaryLayerFormat)
+{
+ for (int o = 0; o < output_count; o++) {
+ tdm_layer *layer;
+ int next_buffer = 0;
+ bool done = false;
+ tdm_error ret;
+ const tbm_format *formats;
+ int format_count = 0;
+ const tdm_output_mode *mode = NULL;
+ unsigned int flags = 0;
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ layer = tc_tdm_output_get_primary_layer(outputs[o]);
+ ASSERT_NE(layer, NULL);
+
+ ASSERT_EQ(tdm_layer_get_buffer_flags(layer, &flags), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_layer_get_available_formats(layer, &formats, &format_count), TDM_ERROR_NONE);
+
+ for (int f = 0; f < format_count; f++) {
+ ASSERT_EQ(tc_tdm_output_mode_setting(outputs[o]), true);
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE);
+ ASSERT_NE(mode, NULL);
+
+retry:
+ TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(formats[f]));
+ ASSERT_EQ(tc_tdm_buffer_create(mode->hdisplay, mode->vdisplay, formats[f], flags | TBM_BO_SCANOUT, true, 3, buffers), true);
+
+ /* set buffer & commit for 60 times */
+ for (int t = 0; t < 60; t++) {
+ tbm_surface_h displaying_buffer;
+ ASSERT_EQ(tc_tdm_layer_set_buffer(layer, buffers[next_buffer]), true);
+ done = false;
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, _tc_tdm_backend_output_commit_cb, &done), TDM_ERROR_NONE);
+ while (!done)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_EQ(displaying_buffer, buffers[next_buffer]);
+ next_buffer++;
+ if (next_buffer == 3)
+ next_buffer = 0;
+ }
+
+ DestroyBuffers();
+
+ TDM_UT_ASK_YNR("* Successed to display '%c%c%c%c' frames to a primary layer? (output: %d)", FOURCC_STR(formats[f]), o);
+ }
+ }
+}
+
+TEST_P(TDMBackendDisplay, VerifyOverlayLayerFormat)
+{
+ ASSERT_EQ(tc_tdm_output_prepare_all_output(dpy, outputs, output_count, false), true);
+
+ for (int l = 0; l < layer_count; l++) {
+ tdm_error ret;
+ tdm_output *output;
+ tdm_layer *layer;
+ int next_buffer = 0;
+ bool done = false;
+ const tbm_format *formats;
+ int format_count = 0;
+ const tdm_output_mode *mode = NULL;
+ unsigned int flags = 0;
+ unsigned int pipe = 0;
+
+ layer = layers[l];
+
+ output = tdm_layer_get_output(layer, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+
+ if (!tc_tdm_output_is_connected(output))
+ continue;
+ if (tc_tdm_layer_is_primary_layer(layer))
+ continue;
+ if (tc_tdm_layer_is_cursor_layer(layer))
+ continue;
+
+ ASSERT_EQ(tdm_output_get_pipe(output, &pipe), TDM_ERROR_NONE);
+
+ TDM_UT_INFO("* testing for (output: %d, layer: %d)", pipe, l);
+
+ ASSERT_EQ(tdm_layer_get_buffer_flags(layer, &flags), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_get_mode(output, &mode), TDM_ERROR_NONE);
+ ASSERT_NE(mode, NULL);
+
+ ASSERT_EQ(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
+
+ ASSERT_EQ(tdm_layer_get_available_formats(layer, &formats, &format_count), TDM_ERROR_NONE);
+
+ for (int f = 0; f < format_count; f++) {
+retry:
+ TDM_UT_INFO("** testing for %c%c%c%c", FOURCC_STR(formats[f]));
+ ASSERT_EQ(tc_tdm_buffer_create(mode->hdisplay, mode->vdisplay, formats[f], flags | TBM_BO_SCANOUT, true, 3, buffers), true);
+
+ /* set buffer & commit for TDM_UT_BACKEND_TEST_CNT times */
+ for (int t = 0; t < TDM_UT_BACKEND_TEST_CNT; t++) {
+ tbm_surface_h displaying_buffer;
+ ASSERT_EQ(tc_tdm_layer_set_buffer(layer, buffers[next_buffer]), true);
+ done = false;
+ ASSERT_EQ(tdm_output_commit(output, 0, _tc_tdm_backend_output_commit_cb, &done), TDM_ERROR_NONE);
+ while (!done)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_EQ(displaying_buffer, buffers[next_buffer]);
+ next_buffer++;
+ if (next_buffer == 3)
+ next_buffer = 0;
+ }
+
+ TDM_UT_ASK_YNR("* Successed to display '%c%c%c%c' frames to a layer? (output: %d, layer: %d)", FOURCC_STR(formats[f]), pipe, l);
+
+ DestroyBuffers();
+ }
+
+ ASSERT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE);
+ }
+}
+
+TEST_P(TDMBackendDisplay, VerifyOverlayLayerSize)
+{
+ ASSERT_EQ(tc_tdm_output_prepare_all_output(dpy, outputs, output_count, false), true);
+
+ for (int l = 0; l < layer_count; l++) {
+ tdm_error ret;
+ tdm_output *output;
+ tdm_layer *layer;
+ int next_buffer = 0;
+ bool done = false;
+ const tbm_format *formats;
+ int format_count = 0;
+ const tdm_output_mode *mode = NULL;
+ unsigned int flags = 0;
+ unsigned int pipe = 0;
+
+ layer = layers[l];
+
+ output = tdm_layer_get_output(layer, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+
+ if (!tc_tdm_output_is_connected(output))
+ continue;
+ if (tc_tdm_layer_is_primary_layer(layer))
+ continue;
+ if (tc_tdm_layer_is_cursor_layer(layer))
+ continue;
+
+ ASSERT_EQ(tdm_output_get_pipe(output, &pipe), TDM_ERROR_NONE);
+
+ TDM_UT_INFO("* testing for (output: %d, layer: %d)", pipe, l);
+
+ ASSERT_EQ(tdm_layer_get_buffer_flags(layer, &flags), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_get_mode(output, &mode), TDM_ERROR_NONE);
+ ASSERT_NE(mode, NULL);
+
+ ASSERT_EQ(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
+
+ ASSERT_EQ(tdm_layer_get_available_formats(layer, &formats, &format_count), TDM_ERROR_NONE);
+
+ for (int f = 0; f < format_count; f++) {
+ int diffw = mode->hdisplay / (format_count + 2);
+ int diffh = mode->vdisplay / (format_count + 2);
+ int w = mode->hdisplay - diffw * (f + 1);
+ int h = mode->vdisplay - diffh * (f + 1);
+retry:
+ TDM_UT_INFO("** testing for %c%c%c%c", FOURCC_STR(formats[f]));
+ ASSERT_EQ(tc_tdm_buffer_create(w, h, formats[f], flags | TBM_BO_SCANOUT, true, 3, buffers), true);
+
+ /* set buffer & commit for TDM_UT_BACKEND_TEST_CNT times */
+ for (int t = 0; t < TDM_UT_BACKEND_TEST_CNT; t++) {
+ tbm_surface_h displaying_buffer;
+ ASSERT_EQ(tc_tdm_layer_set_buffer(layer, buffers[next_buffer]), true);
+ done = false;
+ ASSERT_EQ(tdm_output_commit(output, 0, _tc_tdm_backend_output_commit_cb, &done), TDM_ERROR_NONE);
+ while (!done)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_EQ(displaying_buffer, buffers[next_buffer]);
+ next_buffer++;
+ if (next_buffer == 3)
+ next_buffer = 0;
+ }
+
+ DestroyBuffers();
+
+ TDM_UT_ASK_YNR("* Successed to display '%c%c%c%c' small size(%dx%d) frames to a layer? (output: %d, layer: %d)",
+ FOURCC_STR(formats[f]), w, h, pipe, l);
+ }
+
+ ASSERT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE);
+ }
+}
+
+TEST_P(TDMBackendDisplay, VerifyOverlayLayerScale)
+{
+ ASSERT_EQ(tc_tdm_output_prepare_all_output(dpy, outputs, output_count, false), true);
+
+ for (int l = 0; l < layer_count; l++) {
+ tdm_error ret;
+ tdm_output *output;
+ tdm_layer *layer;
+ int next_buffer = 0;
+ bool done = false;
+ const tbm_format *formats;
+ int format_count = 0;
+ const tdm_output_mode *mode = NULL;
+ unsigned int flags = 0;
+ unsigned int pipe = 0;
+
+ layer = layers[l];
+
+ output = tdm_layer_get_output(layer, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+
+ ASSERT_EQ(tdm_output_get_pipe(output, &pipe), TDM_ERROR_NONE);
+
+ if (!tc_tdm_output_is_connected(output))
+ continue;
+ if (tc_tdm_layer_is_primary_layer(layer))
+ continue;
+ if (tc_tdm_layer_is_cursor_layer(layer))
+ continue;
+ if (!tc_tdm_layer_support_scale(layer)) {
+ TDM_UT_INFO("no scale capability. (output: %d, layer: %d)", pipe, l);
+ continue;
+ }
+
+ ASSERT_EQ(tdm_layer_get_buffer_flags(layer, &flags), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_get_mode(output, &mode), TDM_ERROR_NONE);
+ ASSERT_NE(mode, NULL);
+
+ ASSERT_EQ(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
+
+ ASSERT_EQ(tdm_layer_get_available_formats(layer, &formats, &format_count), TDM_ERROR_NONE);
+
+ for (int f = 0; f < format_count; f++) {
+retry:
+ TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(formats[f]));
+ ASSERT_EQ(tc_tdm_buffer_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f], flags | TBM_BO_SCANOUT, true, 3, buffers), true);
+
+ tdm_info_layer info;
+ memset(&info, 0, sizeof info);
+ info.src_config.size.h = TDM_UT_BUFFER_SIZE;
+ info.src_config.size.v = TDM_UT_BUFFER_SIZE;
+ info.src_config.pos.x = 0;
+ info.src_config.pos.y = 0;
+ info.src_config.pos.w = TDM_UT_BUFFER_SIZE;
+ info.src_config.pos.h = TDM_UT_BUFFER_SIZE;
+ info.src_config.format = formats[f];
+ info.dst_pos.x = 0;
+ info.dst_pos.y = 0;
+ info.dst_pos.w = mode->hdisplay;
+ info.dst_pos.h = mode->vdisplay;
+ info.transform = TDM_TRANSFORM_NORMAL;
+ ASSERT_EQ(tdm_layer_set_info(layer, &info), TDM_ERROR_NONE);
+
+ /* set buffer & commit for TDM_UT_BACKEND_TEST_CNT times */
+ for (int t = 0; t < TDM_UT_BACKEND_TEST_CNT; t++) {
+ tbm_surface_h displaying_buffer;
+ ASSERT_EQ(tdm_layer_set_buffer(layer, buffers[next_buffer]), TDM_ERROR_NONE);
+ done = false;
+ ASSERT_EQ(tdm_output_commit(output, 0, _tc_tdm_backend_output_commit_cb, &done), TDM_ERROR_NONE);
+ while (!done)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_EQ(displaying_buffer, buffers[next_buffer]);
+ next_buffer++;
+ if (next_buffer == 3)
+ next_buffer = 0;
+ }
+
+ DestroyBuffers();
+
+ TDM_UT_ASK_YNR("* Successed to scale '%c%c%c%c' small size(%dx%d) frames to fullsreen? (output: %d, layer: %d)",
+ FOURCC_STR(formats[f]), TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, pipe, l);
+ }
+
+ ASSERT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE);
+ }
+}
+
+TEST_P(TDMBackendDisplay, VerifyOverlayLayerMovePosition)
+{
+ ASSERT_EQ(tc_tdm_output_prepare_all_output(dpy, outputs, output_count, false), true);
+
+ for (int l = 0; l < layer_count; l++) {
+ tdm_error ret;
+ tdm_output *output;
+ tdm_layer *layer;
+ int next_buffer = 0;
+ bool done = false;
+ const tbm_format *formats;
+ int format_count = 0;
+ const tdm_output_mode *mode = NULL;
+ unsigned int flags = 0;
+ unsigned int pipe = 0;
+
+ layer = layers[l];
+
+ output = tdm_layer_get_output(layer, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+
+ if (!tc_tdm_output_is_connected(output))
+ continue;
+ if (tc_tdm_layer_is_primary_layer(layer))
+ continue;
+ if (tc_tdm_layer_is_cursor_layer(layer))
+ continue;
+
+ ASSERT_EQ(tdm_output_get_pipe(output, &pipe), TDM_ERROR_NONE);
+
+ TDM_UT_INFO("* testing for (output: %d, layer: %d)", pipe, l);
+
+ ASSERT_EQ(tdm_layer_get_buffer_flags(layer, &flags), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_get_mode(output, &mode), TDM_ERROR_NONE);
+ ASSERT_NE(mode, NULL);
+
+ ASSERT_EQ(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
+
+ ASSERT_EQ(tdm_layer_get_available_formats(layer, &formats, &format_count), TDM_ERROR_NONE);
+
+ for (int f = 0; f < format_count; f++) {
+retry:
+ TDM_UT_INFO("** testing for %c%c%c%c", FOURCC_STR(formats[f]));
+ ASSERT_EQ(tc_tdm_buffer_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f], flags | TBM_BO_SCANOUT, true, 3, buffers), true);
+
+ /* set buffer & commit for TDM_UT_BACKEND_TEST_CNT times */
+ for (int t = 0; t < TDM_UT_BACKEND_TEST_CNT; t++) {
+ tbm_surface_h displaying_buffer;
+
+ tdm_info_layer info;
+ memset(&info, 0, sizeof info);
+ info.src_config.size.h = TDM_UT_BUFFER_SIZE;
+ info.src_config.size.v = TDM_UT_BUFFER_SIZE;
+ info.src_config.pos.x = 0;
+ info.src_config.pos.y = 0;
+ info.src_config.pos.w = TDM_UT_BUFFER_SIZE;
+ info.src_config.pos.h = TDM_UT_BUFFER_SIZE;
+ info.src_config.format = formats[f];
+ info.dst_pos.x = ((mode->hdisplay - TDM_UT_BUFFER_SIZE) / TDM_UT_BACKEND_TEST_CNT) * t;
+ info.dst_pos.y = ((mode->vdisplay - TDM_UT_BUFFER_SIZE) / TDM_UT_BACKEND_TEST_CNT) * t;
+ info.dst_pos.w = TDM_UT_BUFFER_SIZE;
+ info.dst_pos.h = TDM_UT_BUFFER_SIZE;
+ info.transform = TDM_TRANSFORM_NORMAL;
+ ASSERT_EQ(tdm_layer_set_info(layer, &info), TDM_ERROR_NONE);
+
+ ASSERT_EQ(tdm_layer_set_buffer(layer, buffers[next_buffer]), TDM_ERROR_NONE);
+ done = false;
+ ASSERT_EQ(tdm_output_commit(output, 0, _tc_tdm_backend_output_commit_cb, &done), TDM_ERROR_NONE);
+ while (!done)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_EQ(displaying_buffer, buffers[next_buffer]);
+ next_buffer++;
+ if (next_buffer == 3)
+ next_buffer = 0;
+ }
+
+ DestroyBuffers();
+
+ TDM_UT_ASK_YNR("* Successed to move '%c%c%c%c' small size(%dx%d) frames on screen? (output: %d, layer: %d)",
+ FOURCC_STR(formats[f]), TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, pipe, l);
+ }
+
+ ASSERT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE);
+ }
+}
+
+TEST_P(TDMBackendDisplay, VerifyOverlayLayerCrop)
+{
+ ASSERT_EQ(tc_tdm_output_prepare_all_output(dpy, outputs, output_count, false), true);
+
+ for (int l = 0; l < layer_count; l++) {
+ tdm_error ret;
+ tdm_output *output;
+ tdm_layer *layer;
+ int next_buffer = 0;
+ bool done = false;
+ const tbm_format *formats;
+ int format_count = 0;
+ const tdm_output_mode *mode = NULL;
+ unsigned int flags = 0;
+ unsigned int pipe = 0;
+
+ layer = layers[l];
+
+ output = tdm_layer_get_output(layer, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+
+ ASSERT_EQ(tdm_output_get_pipe(output, &pipe), TDM_ERROR_NONE);
+
+ if (!tc_tdm_output_is_connected(output))
+ continue;
+ if (tc_tdm_layer_is_primary_layer(layer))
+ continue;
+ if (tc_tdm_layer_is_cursor_layer(layer))
+ continue;
+ if (tc_tdm_layer_support_no_crop(layer)) {
+ TDM_UT_INFO("no crop capability. (output: %d, layer: %d)", pipe, l);
+ continue;
+ }
+
+ TDM_UT_INFO("* testing for (output: %d, layer: %d)", pipe, l);
+
+ ASSERT_EQ(tdm_layer_get_buffer_flags(layer, &flags), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_get_mode(output, &mode), TDM_ERROR_NONE);
+ ASSERT_NE(mode, NULL);
+
+ ASSERT_EQ(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
+
+ ASSERT_EQ(tdm_layer_get_available_formats(layer, &formats, &format_count), TDM_ERROR_NONE);
+
+ for (int f = 0; f < format_count; f++) {
+retry:
+ TDM_UT_INFO("** testing for %c%c%c%c", FOURCC_STR(formats[f]));
+ ASSERT_EQ(tc_tdm_buffer_create(mode->hdisplay, mode->vdisplay, formats[f], flags | TBM_BO_SCANOUT, true, 3, buffers), true);
+
+ tdm_info_layer info;
+ memset(&info, 0, sizeof info);
+ info.src_config.size.h = mode->hdisplay;
+ info.src_config.size.v = mode->vdisplay;
+ info.src_config.pos.x = mode->hdisplay / 2;
+ info.src_config.pos.y = mode->vdisplay / 2;
+ info.src_config.pos.w = info.src_config.size.h / 2;
+ info.src_config.pos.h = info.src_config.size.v / 2;
+ info.src_config.format = formats[f];
+ info.dst_pos.x = info.src_config.pos.x;
+ info.dst_pos.y = info.src_config.pos.y;
+ info.dst_pos.w = info.src_config.pos.w;
+ info.dst_pos.h = info.src_config.pos.h;
+ info.transform = TDM_TRANSFORM_NORMAL;
+ ASSERT_EQ(tdm_layer_set_info(layer, &info), TDM_ERROR_NONE);
+
+ /* set buffer & commit for TDM_UT_BACKEND_TEST_CNT times */
+ for (int t = 0; t < TDM_UT_BACKEND_TEST_CNT; t++) {
+ tbm_surface_h displaying_buffer;
+ ASSERT_EQ(tdm_layer_set_buffer(layer, buffers[next_buffer]), TDM_ERROR_NONE);
+ done = false;
+ ASSERT_EQ(tdm_output_commit(output, 0, _tc_tdm_backend_output_commit_cb, &done), TDM_ERROR_NONE);
+ while (!done)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_EQ(displaying_buffer, buffers[next_buffer]);
+ next_buffer++;
+ if (next_buffer == 3)
+ next_buffer = 0;
+ }
+
+ DestroyBuffers();
+
+ TDM_UT_ASK_YNR("* Successed to crop '%c%c%c%c' frames and display it? (output: %d, layer: %d)",
+ FOURCC_STR(formats[f]), pipe, l);
+ }
+
+ ASSERT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE);
+ }
+}
+
+/* should be debugged int emulator kernel */
+TEST_P(TDMBackendDisplay, DISABLED_VerifyOutputSetDpmsFromOnToOff)
+{
+ ASSERT_EQ(tc_tdm_output_prepare_all_output(dpy, outputs, output_count, true), true);
+
+ for (int o = 0; o < output_count; o++) {
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
+ }
+}
+
+/* should be debugged int emulator kernel */
+TEST_P(TDMBackendDisplay, DISABLED_VerifyOutputSetDpmsFromOffToOn)
+{
+ ASSERT_EQ(tc_tdm_output_prepare_all_output(dpy, outputs, output_count, true), true);
+
+ for (int o = 0; o < output_count; o++) {
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
+ }
+}
+
+/* should be debugged int emulator kernel */
+TEST_P(TDMBackendDisplay, DISABLED_VerifyOutputSetDpmsToOnBeforeSet)
+{
+ for (int o = 0; o < output_count; o++) {
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_mode_setting(outputs[o]), true);
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
+ }
+}
+
+/* should be debugged int emulator kernel */
+TEST_P(TDMBackendDisplay, DISABLED_VerifyOutputSetDpmsToOffBeforeSet)
+{
+ for (int o = 0; o < output_count; o++) {
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_mode_setting(outputs[o]), true);
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
+ }
+}
+
+/* should be debugged int emulator kernel */
+TEST_P(TDMBackendDisplay, DISABLED_VerifyOutputSetDpmsToOffAfterUnsetWithoutCommit)
+{
+ for (int o = 0; o < output_count; o++) {
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_prepare(dpy, outputs[o], true), true);
+
+ tdm_layer *layer = tc_tdm_output_get_primary_layer(outputs[o]);
+ ASSERT_NE(layer, NULL);
+
+ ASSERT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE);
+
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
+ }
+}
+
+/* should be debugged int emulator kernel */
+TEST_P(TDMBackendDisplay, DISABLED_VerifyOutputSetDpmsToOffAfterUnsetWithCommit)
+{
+ for (int o = 0; o < output_count; o++) {
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_prepare(dpy, outputs[o], true), true);
+
+ tdm_layer *layer = tc_tdm_output_get_primary_layer(outputs[o]);
+ ASSERT_NE(layer, NULL);
+
+ ASSERT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
+
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
+ }
+}
+
+TEST_P(TDMBackendDisplay, DISABLED_VerifyOutputSetDpmsAsync)
+{
+}
+
+TEST_P(TDMBackendDisplay, VerifyLayerGetInfo)
+{
+ ASSERT_EQ(tc_tdm_output_prepare_all_output(dpy, outputs, output_count, true), true);
+
+ for (int o = 0; o < output_count; o++) {
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ tbm_surface_h displaying_buffer;
+ tdm_error ret;
+ tdm_info_layer info, temp;
+ tdm_layer *layer = tc_tdm_output_get_primary_layer(outputs[o]);
+ ASSERT_NE(layer, NULL);
+
+ displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret);
+ ASSERT_NE(displaying_buffer, NULL);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_EQ(tc_tdm_layer_fill_info(layer, displaying_buffer, NULL, &info), true);
+ ASSERT_EQ(tdm_layer_get_info(layer, &temp), TDM_ERROR_NONE);
+ ASSERT_EQ(memcmp(&info, &temp, sizeof info), 0);
+ }
+}
+
+TEST_P(TDMBackendDisplay, DISABLED_VerifyOutputWaitVblankBeforeDpmsOff) /* TODO */
+{
+}
+
+TEST_P(TDMBackendDisplay, DISABLED_VerifyLayerSetVideoPos)
+{
+}
+
+#ifdef TDM_UT_TEST_WITH_PARAMS
+INSTANTIATE_TEST_CASE_P(TDMBackendDisplayParams,
+ TDMBackendDisplay,
+ Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
+#else
+INSTANTIATE_TEST_CASE_P(TDMBackendDisplayParams,
+ TDMBackendDisplay,
+ Values(TDM_DEFAULT_MODULE));
+#endif
+
+/* LCOV_EXCL_END */
\ No newline at end of file
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
+ * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
+ * Contact: Roman Marchenko <r.marchenko@samsung.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+**************************************************************************/
+
+#include "tc_tdm.h"
+
+/* LCOV_EXCL_START */
+
+bool enable_porting_debug = false;
+
+void TDMBackendEnv::SetUp(void)
+{
+ const char *debug;
+
+ TDMEnv::SetUp();
+
+ /* thread, commit_per_vblank should be turned off for testing TDMBackend
+ * all TDMBackend's tcs should call tdm_output_commit once in a vblank.
+ * don't call tdm_layer_commit.
+ */
+ tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_THREAD, 0);
+ tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_COMMIT_PER_VBLANK, 0);
+
+ debug = getenv("TDM_UT_DEBUG_BACKEND");
+ if (debug && (debug[0] == '1'))
+ enable_porting_debug = true;
+}
+
+void TDMBackendEnv::TearDown(void)
+{
+ TDMEnv::TearDown();
+}
+
+TEST_P(TDMBackendEnv, VerifyDisplay)
+{
+ tdm_display *dpy;
+ tdm_error ret;
+
+ dpy = tdm_display_init(&ret);
+ TDM_UT_ASSERT_TRUE(dpy != NULL, "display init failed: %s", tdm_error_str(ret));
+
+ TDM_UT_INFO("display init success");
+
+ tdm_display_deinit(dpy);
+}
+
+#ifdef TDM_UT_TEST_WITH_PARAMS
+INSTANTIATE_TEST_CASE_P(TDMBackendEnvParams,
+ TDMBackendEnv,
+ Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
+#else
+INSTANTIATE_TEST_CASE_P(TDMBackendEnvParams,
+ TDMBackendEnv,
+ Values(TDM_DEFAULT_MODULE));
+#endif
+
+/* LCOV_EXCL_END */
\ No newline at end of file
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
+ * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
+ * Contact: Roman Marchenko <r.marchenko@samsung.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+**************************************************************************/
+
+#include "tc_tdm.h"
+
+/* LCOV_EXCL_START */
+
+class TDMBackendPP : public TDMBackendDisplay
+{
+public:
+ tdm_pp *pp;
+ tdm_pp_capability capabilities;
+ const tbm_format *formats;
+ int format_count;
+ int min_w;
+ int min_h;
+ int max_w;
+ int max_h;
+ int preferred_align;
+
+ tbm_surface_h srcbuf[3];
+ tbm_surface_h dstbuf[3];
+
+ tdm_info_pp info;
+
+ tdm_output *output;
+ unsigned int pipe;
+ const tdm_output_mode *mode;
+
+ tdm_layer *dst_layer;
+ const tbm_format *dst_formats;
+ int dst_format_count;
+ int dst_zpos;
+ int dst_layer_index;
+
+ TDMBackendPP();
+ void SetUp(void);
+ void TearDown(void);
+
+ bool FindLayerUnderPrimary(void);
+ bool FindLayerOverPrimary(void);
+ bool PreparePP(void);
+ bool PrepareBuffers(int sw, int sh, tbm_format sf, int dw, int dh, tbm_format df, tdm_transform t);
+ void ShowBuffer(int b);
+ void HideLayer(void);
+ void DumpBuffer(int b, char *test);
+ void DestroyBuffers(void);
+ void DestroyPP(void);
+};
+
+TDMBackendPP::TDMBackendPP()
+{
+ pp = NULL;
+ capabilities = (tdm_pp_capability)0;
+ formats = NULL;
+ format_count = 0;
+ min_w = min_h = max_w = max_h = preferred_align = -1;
+
+ for (int b = 0; b < 3; b++)
+ srcbuf[b] = dstbuf[b] = NULL;
+ memset(&info, 0, sizeof info);
+
+ output = NULL;
+ pipe = 0;
+ mode = NULL;
+
+ dst_layer = NULL;
+ dst_formats = NULL;
+ dst_format_count = 0;
+ dst_zpos = 0;
+ dst_layer_index = 0;
+}
+
+void TDMBackendPP::SetUp(void)
+{
+ TDMBackendDisplay::SetUp();
+
+ if (!tc_tdm_display_has_pp_capability(dpy))
+ return;
+
+ ASSERT_EQ(tdm_display_get_pp_capabilities(dpy, &capabilities), TDM_ERROR_NONE);
+ ASSERT_GT(capabilities, 0);
+ ASSERT_EQ(tdm_display_get_pp_available_formats(dpy, &formats, &format_count), TDM_ERROR_NONE);
+ ASSERT_NE(formats, NULL);
+ ASSERT_GT(format_count, 0);
+ ASSERT_EQ(tdm_display_get_pp_available_size(dpy, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_NONE);
+ ASSERT_TRUE(min_w == -1 || min_w > 0);
+ ASSERT_TRUE(min_h == -1 || min_h > 0);
+ ASSERT_TRUE(max_w == -1 || max_w > 0);
+ ASSERT_TRUE(max_h == -1 || max_h > 0);
+ ASSERT_TRUE(preferred_align == -1 || preferred_align > 0);
+
+ for (int o = 0; o < output_count; o++) {
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ output = outputs[o];
+ ASSERT_EQ(tdm_output_get_pipe(output, &pipe), TDM_ERROR_NONE);
+ ASSERT_EQ(tc_tdm_output_prepare(dpy, output, false), true);
+ ASSERT_EQ(tdm_output_get_mode(output, &mode), TDM_ERROR_NONE);
+ ASSERT_NE(mode, NULL);
+ break;
+ }
+}
+
+void TDMBackendPP::TearDown(void)
+{
+ if (pp)
+ tdm_pp_destroy(pp);
+
+ DestroyBuffers();
+
+ TDMBackendDisplay::TearDown();
+}
+
+bool TDMBackendPP::PreparePP(void)
+{
+ tdm_error ret;
+ pp = tdm_display_create_pp(dpy, &ret);
+ TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(pp != NULL);
+ return true;
+}
+
+void TDMBackendPP::DestroyPP(void)
+{
+ if (pp) {
+ tdm_pp_destroy(pp);
+ pp = NULL;
+ }
+}
+
+bool TDMBackendPP::PrepareBuffers(int sw, int sh, tbm_format sf, int dw, int dh, tbm_format df, tdm_transform t)
+{
+ int src_flags = 0, dst_flags = 0;
+
+ sw = TDM_UT_SIZE_ALIGN(sw, preferred_align);
+ dw = TDM_UT_SIZE_ALIGN(dw, preferred_align);
+
+ if (capabilities & TDM_PP_CAPABILITY_SCANOUT)
+ src_flags = dst_flags |= TBM_BO_SCANOUT;
+
+ if (dst_layer) {
+ tdm_layer_capability capabilities;
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_capabilities(dst_layer, &capabilities) == TDM_ERROR_NONE);
+ if (capabilities & TDM_LAYER_CAPABILITY_SCANOUT)
+ dst_flags |= TBM_BO_SCANOUT;
+ }
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(tc_tdm_buffer_create(sw, sh, sf, src_flags, true, 3, srcbuf) == true);
+ TDM_UT_RETURN_FALSE_IF_FAIL(tc_tdm_buffer_create(dw, dh, df, dst_flags, false, 3, dstbuf) == true);
+ TDM_UT_RETURN_FALSE_IF_FAIL(tc_tdm_pp_fill_info(srcbuf[0], dstbuf[0], t, &info) == true);
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_pp_set_info(pp, &info) == TDM_ERROR_NONE);
+
+ return true;
+}
+
+bool TDMBackendPP::FindLayerUnderPrimary(void)
+{
+ tdm_error ret;
+ int count;
+ int primary_zpos, zpos;
+ tdm_layer *primary = tc_tdm_output_get_primary_layer(output);
+ TDM_UT_RETURN_FALSE_IF_FAIL(primary != NULL);
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_layer_count(output, &count) == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_zpos(primary, &primary_zpos) == TDM_ERROR_NONE);
+
+ for (int l = 0; l < count; l++) {
+ unsigned int usable;
+ tdm_layer *temp = tdm_output_get_layer(output, l, &ret);
+ TDM_UT_RETURN_FALSE_IF_FAIL(temp != NULL);
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_is_usable(temp, &usable) == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_zpos(temp, &zpos) == TDM_ERROR_NONE);
+ if (zpos < primary_zpos && usable) {
+ dst_layer = temp;
+ dst_zpos = zpos;
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_available_formats(dst_layer, &dst_formats, &dst_format_count) == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(dst_formats != NULL);
+ TDM_UT_RETURN_FALSE_IF_FAIL(dst_format_count > 0);
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_index(dst_layer, &dst_layer_index) == TDM_ERROR_NONE);
+ break;
+ }
+ }
+
+ return true;
+}
+
+bool TDMBackendPP::FindLayerOverPrimary(void)
+{
+ tdm_error ret;
+ int count;
+ int primary_zpos, zpos;
+ tdm_layer *primary = tc_tdm_output_get_primary_layer(output);
+ TDM_UT_RETURN_FALSE_IF_FAIL(primary != NULL);
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_layer_count(output, &count) == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_zpos(primary, &primary_zpos) == TDM_ERROR_NONE);
+
+ for (int l = 0; l < count; l++) {
+ tdm_layer *temp = tdm_output_get_layer(output, l, &ret);
+ TDM_UT_RETURN_FALSE_IF_FAIL(temp != NULL);
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_zpos(temp, &zpos) == TDM_ERROR_NONE);
+ if (zpos > primary_zpos) {
+ dst_layer = temp;
+ dst_zpos = zpos;
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_available_formats(dst_layer, &dst_formats, &dst_format_count) == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(dst_formats != NULL);
+ TDM_UT_RETURN_FALSE_IF_FAIL(dst_format_count > 0);
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_index(dst_layer, &dst_layer_index) == TDM_ERROR_NONE);
+ break;
+ }
+ }
+
+ return true;
+
+}
+
+static void
+_tc_tdm_backend_pp_output_commit_cb(tdm_output *output, unsigned int sequence,
+ unsigned int tv_sec, unsigned int tv_usec,
+ void *user_data)
+{
+ bool *done = (bool *)user_data;
+ if (done)
+ *done = true;
+}
+
+void TDMBackendPP::ShowBuffer(int b)
+{
+ ASSERT_NE(output, NULL);
+ ASSERT_NE(dst_layer, NULL);
+
+ bool done = false;
+
+ ASSERT_EQ(tc_tdm_layer_set_buffer(dst_layer, dstbuf[b]), true);
+ ASSERT_EQ(tdm_output_commit(output, 0, _tc_tdm_backend_pp_output_commit_cb, &done), TDM_ERROR_NONE);
+ while (!done) {
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ }
+}
+
+void TDMBackendPP::HideLayer(void)
+{
+ ASSERT_NE(output, NULL);
+ ASSERT_NE(dst_layer, NULL);
+
+ tdm_layer_unset_buffer(dst_layer);
+ tdm_output_commit(output, 0, NULL, NULL);
+}
+
+void TDMBackendPP::DumpBuffer(int b, char *test)
+{
+ char filename[256];
+ if (test)
+ snprintf(filename, sizeof filename, "%s_%s_src_%d", typeid(*this).name(), test, b);
+ else
+ snprintf(filename, sizeof filename, "%s_src_%d", typeid(*this).name(), b);
+ tdm_helper_dump_buffer_str(srcbuf[b], NULL, filename);
+ if (test)
+ snprintf(filename, sizeof filename, "%s_%s_dst_%d", typeid(*this).name(), test, b);
+ else
+ snprintf(filename, sizeof filename, "%s_dst_%d", typeid(*this).name(), b);
+ tdm_helper_dump_buffer_str(dstbuf[b], NULL, filename);
+}
+
+void TDMBackendPP::DestroyBuffers(void)
+{
+ for (int b = 0; b < 3; b++) {
+ if (srcbuf[b])
+ tbm_surface_destroy(srcbuf[b]);
+ if (dstbuf[b])
+ tbm_surface_destroy(dstbuf[b]);
+ srcbuf[b] = dstbuf[b] = NULL;
+ }
+}
+
+bool
+tc_tdm_pp_fill_info(tbm_surface_h srcbuf, tbm_surface_h dstbuf, tdm_transform transform, tdm_info_pp *info)
+{
+ int bw, bh;
+
+ memset(info, 0, sizeof *info);
+
+ bw = bh = TDM_UT_INVALID_VALUE;
+ tdm_helper_get_buffer_full_size(srcbuf, &bw, &bh);
+ TDM_UT_RETURN_FALSE_IF_FAIL(bw != TDM_UT_INVALID_VALUE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(bw >= tbm_surface_get_width(srcbuf));
+ TDM_UT_RETURN_FALSE_IF_FAIL(bh != TDM_UT_INVALID_VALUE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(bh >= tbm_surface_get_height(srcbuf));
+ info->src_config.size.h = bw;
+ info->src_config.size.v = bh;
+ info->src_config.pos.x = 0;
+ info->src_config.pos.y = 0;
+ info->src_config.pos.w = tbm_surface_get_width(srcbuf);
+ info->src_config.pos.h = tbm_surface_get_height(srcbuf);
+ info->src_config.format = tbm_surface_get_format(srcbuf);
+
+ bw = bh = TDM_UT_INVALID_VALUE;
+ tdm_helper_get_buffer_full_size(dstbuf, &bw, &bh);
+ TDM_UT_RETURN_FALSE_IF_FAIL(bw != TDM_UT_INVALID_VALUE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(bw >= tbm_surface_get_width(dstbuf));
+ TDM_UT_RETURN_FALSE_IF_FAIL(bh != TDM_UT_INVALID_VALUE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(bh >= tbm_surface_get_height(dstbuf));
+ info->dst_config.size.h = bw;
+ info->dst_config.size.v = bh;
+ info->dst_config.pos.x = 0;
+ info->dst_config.pos.y = 0;
+ info->dst_config.pos.w = tbm_surface_get_width(dstbuf);
+ info->dst_config.pos.h = tbm_surface_get_height(dstbuf);
+ info->dst_config.format = tbm_surface_get_format(dstbuf);
+
+ info->transform = transform;
+ info->sync = 0;
+ info->flags = 0;
+
+ TDM_UT_INFO("src_config(%dx%d: %d,%d %dx%d: %c%c%c%c) dst_config(%dx%d: %d,%d %dx%d: %c%c%c%c) transform(%s) sync(%d) info->flags(%x)",
+ info->src_config.size.h, info->src_config.size.v,
+ info->src_config.pos.x, info->src_config.pos.y, info->src_config.pos.w, info->src_config.pos.h,
+ FOURCC_STR(info->src_config.format),
+ info->dst_config.size.h, info->dst_config.size.v,
+ info->dst_config.pos.x, info->dst_config.pos.y, info->dst_config.pos.w, info->dst_config.pos.h,
+ FOURCC_STR(info->dst_config.format),
+ tdm_transform_str(transform), info->sync, info->flags);
+
+ return true;
+}
+
+TEST_P(TDMBackendPP, PPDispalyGetAvaiableFormatsNullObject)
+{
+ const tbm_format *formats = (const tbm_format *)TDM_UT_INVALID_VALUE;
+ int count = TDM_UT_INVALID_VALUE;
+ if (tc_tdm_display_has_pp_capability(dpy))
+ ASSERT_EQ(tdm_display_get_pp_available_formats(NULL, &formats, &count), TDM_ERROR_INVALID_PARAMETER);
+ else
+ ASSERT_EQ(tdm_display_get_pp_available_formats(NULL, &formats, &count), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(formats, (const tbm_format *)TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(count, TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMBackendPP, PPDispalyGetAvaiableFormatsNullOther)
+{
+ if (tc_tdm_display_has_pp_capability(dpy)) {
+ ASSERT_EQ(PreparePP(), true);
+ ASSERT_EQ(tdm_display_get_pp_available_formats(pp, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
+ }
+}
+
+TEST_P(TDMBackendPP, PPDispalyGetAvaiableSizeNullObject)
+{
+ int min_w = TDM_UT_INVALID_VALUE;
+ int min_h = TDM_UT_INVALID_VALUE;
+ int max_w = TDM_UT_INVALID_VALUE;
+ int max_h = TDM_UT_INVALID_VALUE;
+ int preferred_align = TDM_UT_INVALID_VALUE;
+ if (tc_tdm_display_has_pp_capability(dpy))
+ ASSERT_EQ(tdm_display_get_pp_available_size(NULL, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_INVALID_PARAMETER);
+ else
+ ASSERT_EQ(tdm_display_get_pp_available_size(NULL, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(min_w, TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(min_h, TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(max_w, TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(max_h, TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(preferred_align, TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMBackendPP, PPDispalyGetAvaiableSizeNullOther)
+{
+ if (tc_tdm_display_has_pp_capability(dpy)) {
+ ASSERT_EQ(PreparePP(), true);
+ ASSERT_EQ(tdm_display_get_pp_available_size(dpy, NULL, NULL, NULL, NULL, NULL), TDM_ERROR_NONE);
+ }
+}
+
+TEST_P(TDMBackendPP, PPDestroy)
+{
+ TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
+
+ ASSERT_EQ(PreparePP(), true);
+ tdm_pp_destroy(pp);
+ pp = NULL;
+}
+
+TEST_P(TDMBackendPP, PPDestroyNullObject)
+{
+ TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
+
+ tdm_pp_destroy(NULL);
+}
+
+TEST_P(TDMBackendPP, PPSetInfo)
+{
+ /* tested in PPNoScaleNoTransformNoCSC */
+}
+
+TEST_P(TDMBackendPP, PPSetInfoNullObject)
+{
+ TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
+
+ tdm_info_pp info;
+ memset(&info, 0, sizeof info);
+ ASSERT_EQ(tdm_pp_set_info(NULL, &info), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMBackendPP, PPSetInfoNullOther)
+{
+ TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
+
+ ASSERT_EQ(PreparePP(), true);
+ ASSERT_EQ(tdm_pp_set_info(pp, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+static void
+_tc_tdm_pp_done_cb(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst, void *user_data)
+{
+ bool *done = (bool*)user_data;
+ if (done)
+ *done = true;
+}
+
+TEST_P(TDMBackendPP, PPSetDoneHandler)
+{
+ TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
+
+ ASSERT_EQ(PreparePP(), true);
+ ASSERT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb, NULL), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMBackendPP, PPSetDoneHandlerNullObject)
+{
+ TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
+
+ ASSERT_EQ(tdm_pp_set_done_handler(NULL, _tc_tdm_pp_done_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMBackendPP, PPSetDoneHandlerNullOther)
+{
+ TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
+
+ ASSERT_EQ(PreparePP(), true);
+ ASSERT_EQ(tdm_pp_set_done_handler(pp, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMBackendPP, PPAttach)
+{
+ TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
+
+ ASSERT_EQ(PreparePP(), true);
+
+ for (int f = 0; f < format_count; f++) {
+ ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
+ TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
+ TDM_TRANSFORM_NORMAL), true);
+
+ for (int b = 0; b < 3; b++)
+ ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
+
+ DestroyBuffers();
+ }
+}
+
+TEST_P(TDMBackendPP, PPAttachNullObject)
+{
+ TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
+
+ tbm_surface_h srcbuf = (tbm_surface_h)TDM_UT_BUFFER_SIZE;
+ tbm_surface_h dstbuf = (tbm_surface_h)TDM_UT_BUFFER_SIZE;
+
+ ASSERT_EQ(tdm_pp_attach(NULL, srcbuf, dstbuf), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMBackendPP, PPAttachNullOther)
+{
+ TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
+
+ ASSERT_EQ(PreparePP(), true);
+
+ ASSERT_EQ(tdm_pp_attach(pp, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMBackendPP, PPCommit)
+{
+ TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
+
+ ASSERT_EQ(PreparePP(), true);
+
+ ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMBackendPP, PPCommitNullOBject)
+{
+ TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
+
+ ASSERT_EQ(tdm_pp_commit(NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMBackendPP, PPConvertUnderlay)
+{
+ TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
+
+ FindLayerUnderPrimary();
+
+ ASSERT_NE(dst_layer, NULL);
+
+ for (int f = 0; f < dst_format_count; f++) {
+ bool done;
+
+ TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(dst_formats[f]));
+
+ ASSERT_EQ(PreparePP(), true);
+
+ ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
+ TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
+ TDM_TRANSFORM_NORMAL), true);
+
+ ASSERT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb, &done), TDM_ERROR_NONE);
+
+retry:
+ for (int b = 0; b < 3; b++) {
+ done = false;
+
+ ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
+
+ while (!done)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+
+#if 0
+ char temp[256];
+ snprintf(temp, sizeof temp, "f%d_b%d", f, b);
+ DumpBuffer(b, temp);
+#endif
+ ShowBuffer(b);
+ }
+
+ TDM_UT_ASK_YNR("* Successed to convert to '%c%c%c%c' buffers and show them to a underlay layer? (output: %d, layer: %d)",
+ FOURCC_STR(dst_formats[f]), pipe, dst_layer_index);
+
+ DestroyPP();
+ DestroyBuffers();
+ }
+}
+
+TEST_P(TDMBackendPP, PPConvertOverlay)
+{
+ TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
+
+ FindLayerOverPrimary();
+
+ TDM_UT_SKIP_FLAG(dst_layer != NULL);
+
+ for (int f = 0; f < dst_format_count; f++) {
+ bool done;
+
+ TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(dst_formats[f]));
+
+ ASSERT_EQ(PreparePP(), true);
+
+ ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
+ TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
+ TDM_TRANSFORM_NORMAL), true);
+
+ ASSERT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb, &done), TDM_ERROR_NONE);
+
+retry:
+ for (int b = 0; b < 3; b++) {
+ done = false;
+
+ ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
+
+ while (!done)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+
+#if 0
+ char temp[256];
+ snprintf(temp, sizeof temp, "f%d_b%d", f, b);
+ DumpBuffer(b, temp);
+#endif
+ ShowBuffer(b);
+ }
+
+ TDM_UT_ASK_YNR("* Successed to convert '%c%c%c%c' buffers and show them to a overlay layer? (output: %d, layer: %d)",
+ FOURCC_STR(dst_formats[f]), pipe, dst_layer_index);
+
+ DestroyPP();
+ DestroyBuffers();
+ }
+}
+
+TEST_P(TDMBackendPP, PPConvertScale)
+{
+ TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
+
+ FindLayerUnderPrimary();
+
+ ASSERT_NE(dst_layer, NULL);
+
+ for (int f = 0; f < dst_format_count; f++) {
+ bool done;
+
+ TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(dst_formats[f]));
+
+ ASSERT_EQ(PreparePP(), true);
+
+ ASSERT_EQ(PrepareBuffers(640, 480, dst_formats[f],
+ mode->hdisplay, mode->vdisplay, dst_formats[f],
+ TDM_TRANSFORM_NORMAL), true);
+
+ ASSERT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb, &done), TDM_ERROR_NONE);
+
+retry:
+ for (int b = 0; b < 3; b++) {
+ done = false;
+
+ ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
+
+ while (!done)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+
+#if 0
+ char temp[256];
+ snprintf(temp, sizeof temp, "f%d_b%d", f, b);
+ DumpBuffer(b, temp);
+#endif
+ ShowBuffer(b);
+ }
+
+ TDM_UT_ASK_YNR("* Successed to scale '%c%c%c%c' buffers? (output: %d, layer: %d)",
+ FOURCC_STR(dst_formats[f]), pipe, dst_layer_index);
+
+ DestroyPP();
+ DestroyBuffers();
+ }
+}
+
+TEST_P(TDMBackendPP, PPConvertTransform)
+{
+ TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
+
+ FindLayerUnderPrimary();
+
+ ASSERT_NE(dst_layer, NULL);
+
+ for (int f = 0; f < dst_format_count; f++) {
+ for (int t = (int)TDM_TRANSFORM_90; t <= (int)TDM_TRANSFORM_FLIPPED_270; t++) {
+ bool done;
+
+ TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(dst_formats[f]));
+
+ ASSERT_EQ(PreparePP(), true);
+
+ ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
+ TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
+ (tdm_transform)t), true);
+
+ ASSERT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb, &done), TDM_ERROR_NONE);
+
+retry:
+ for (int b = 0; b < 3; b++) {
+ done = false;
+
+ ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
+
+ while (!done)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+
+#if 0
+ char temp[256];
+ snprintf(temp, sizeof temp, "f%d_b%d_t%d", f, b, t);
+ DumpBuffer(b, temp);
+#endif
+ ShowBuffer(b);
+ }
+
+ TDM_UT_ASK_YNR("* Successed to rotate '%c%c%c%c' buffers? (transform: %s, output: %d, layer: %d)",
+ FOURCC_STR(dst_formats[f]), tdm_transform_str(t), pipe, dst_layer_index);
+
+ DestroyPP();
+ DestroyBuffers();
+ }
+ }
+}
+
+TEST_P(TDMBackendPP, PPConvertCSC)
+{
+ TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
+ TDM_UT_SKIP_FLAG(!(capabilities & TDM_PP_CAPABILITY_NO_CSC));
+
+ FindLayerUnderPrimary();
+
+ ASSERT_NE(dst_layer, NULL);
+
+ for (int df = 0; df < dst_format_count; df++) {
+ for (int sf = 0; sf < format_count; sf++) {
+ bool done;
+
+ TDM_UT_INFO("* testing for format(%c%c%c%c) -> format(%c%c%c%c)",
+ FOURCC_STR(formats[sf]), FOURCC_STR(dst_formats[df]));
+
+ ASSERT_EQ(PreparePP(), true);
+
+ ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, formats[sf],
+ TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[df],
+ TDM_TRANSFORM_NORMAL), true);
+
+ ASSERT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb, &done), TDM_ERROR_NONE);
+
+retry:
+ for (int b = 0; b < 3; b++) {
+ done = false;
+
+ ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
+
+ while (!done)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+
+#if 0
+ char temp[256];
+ snprintf(temp, sizeof temp, "sf%d_df%d_b%d", sf, df, b);
+ DumpBuffer(b, temp);
+#endif
+ ShowBuffer(b);
+ }
+
+ TDM_UT_ASK_YNR("* Successed to convert from '%c%c%c%c' to '%c%c%c%c'? (output: %d, layer: %d)",
+ FOURCC_STR(formats[sf]), FOURCC_STR(dst_formats[df]), pipe, dst_layer_index);
+
+ DestroyPP();
+ DestroyBuffers();
+ }
+ }
+}
+
+
+
+static void
+_tc_tdm_pp_done_cb2(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst, void *user_data)
+{
+ int *done = (int*)user_data;
+ if (done)
+ (*done)++;
+}
+
+/* some backend doens't implement correctly for attaching */
+TEST_P(TDMBackendPP, DISABLED_PPAttachFewTimesInOneCommit)
+{
+ TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
+
+ ASSERT_EQ(PreparePP(), true);
+
+ int done = 0;
+ int f = 0;
+ char temp[256];
+ snprintf(temp, sizeof temp, "%c%c%c%c", FOURCC_STR(formats[f]));
+
+ ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
+ TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
+ TDM_TRANSFORM_NORMAL), true);
+
+ ASSERT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb2, &done), TDM_ERROR_NONE);
+ for (int b = 0; b < 3; b++)
+ ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
+
+ ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
+
+ while (done != 3)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+
+ for (int b = 0; b < 3; b++)
+ ShowBuffer(b);
+
+ DestroyBuffers();
+}
+
+TEST_P(TDMBackendPP, PPDestroyWithoutCommit)
+{
+ TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
+
+ ASSERT_EQ(PreparePP(), true);
+
+ int f = 0;
+
+ ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
+ TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
+ TDM_TRANSFORM_NORMAL), true);
+
+ ASSERT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb2, NULL), TDM_ERROR_NONE);
+ for (int b = 0; b < 3; b++)
+ ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
+
+ tdm_pp_destroy(pp);
+ pp = NULL;
+
+ DestroyBuffers();
+}
+
+TEST_P(TDMBackendPP, PPDestroyBeforeDone)
+{
+ TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
+
+ ASSERT_EQ(PreparePP(), true);
+
+ int f = 0;
+
+ ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
+ TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
+ TDM_TRANSFORM_NORMAL), true);
+
+ ASSERT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb2, NULL), TDM_ERROR_NONE);
+ for (int b = 0; b < 3; b++)
+ ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
+
+ ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
+
+ tdm_pp_destroy(pp);
+ pp = NULL;
+
+ DestroyBuffers();
+}
+
+#ifdef TDM_UT_TEST_WITH_PARAMS
+INSTANTIATE_TEST_CASE_P(TDMBackendPPParams,
+ TDMBackendPP,
+ Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
+#else
+INSTANTIATE_TEST_CASE_P(TDMBackendPPParams,
+ TDMBackendPP,
+ Values(TDM_DEFAULT_MODULE));
+#endif
+
+/* LCOV_EXCL_END */
\ No newline at end of file
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
+ * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
+ * Contact: Roman Marchenko <r.marchenko@samsung.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+**************************************************************************/
+
+#include "tc_tdm.h"
+
+/* LCOV_EXCL_START */
+
+class TDMBuffer : public TDMDisplay
+{
+public:
+ tbm_surface_h buffer;
+ TDMBuffer();
+ void SetUp(void);
+ void TearDown(void);
+};
+
+TDMBuffer::TDMBuffer()
+{
+ buffer = NULL;
+}
+
+void TDMBuffer::SetUp(void)
+{
+ TDMDisplay::SetUp();
+
+ buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_ARGB8888);
+ ASSERT_NE(buffer, NULL);
+}
+
+void TDMBuffer::TearDown(void)
+{
+ if (buffer) {
+ tbm_surface_destroy(buffer);
+ buffer = NULL;
+ }
+ TDMDisplay::TearDown();
+}
+
+bool
+tc_tdm_buffer_create(int width, int height, tbm_format format, int flags, bool fill, int count, tbm_surface_h *buffers)
+{
+ TDM_UT_GOTO_IF_FAIL(width > 0, failed);
+ TDM_UT_GOTO_IF_FAIL(height > 0, failed);
+
+ for (int b = 0; b < count; b++) {
+ buffers[b] = tbm_surface_internal_create_with_flags(width, height, format, flags);
+ TDM_UT_GOTO_IF_FAIL(buffers[b] != NULL, failed);
+ if (fill)
+ tdm_test_buffer_fill(buffers[b], PATTERN_SMPTE);
+
+ TDM_INFO("creating buffer(%p) done: width(%d) height(%d), format(%c%c%c%c) flags(%x) fill(%d), count(%d)",
+ buffers[b], width, height, FOURCC_STR(format), flags, fill, count);
+ }
+
+ return true;
+failed:
+ for (int b = 0; b < count; b++) {
+ if (buffers[b]) {
+ tbm_surface_destroy(buffers[b]);
+ buffers[b] = NULL;
+ }
+ }
+ return false;
+}
+
+TEST_P(TDMBuffer, BufferRefBackend)
+{
+ ASSERT_EQ(tdm_buffer_ref_backend(buffer), buffer);
+ tdm_buffer_unref_backend(buffer);
+}
+
+TEST_P(TDMBuffer, BufferRefBackendNullOBject)
+{
+ ASSERT_EQ(tdm_buffer_ref_backend(NULL), NULL);
+}
+
+TEST_P(TDMBuffer, BufferUnrefBackend)
+{
+ tdm_buffer_unref_backend(buffer);
+}
+
+TEST_P(TDMBuffer, BufferUnrefBackendNullOBject)
+{
+ tdm_buffer_unref_backend(NULL);
+}
+
+static void
+_tc_tdm_buffer_destroy_cb(tbm_surface_h buffer, void *user_data)
+{
+ bool *done = (bool*)user_data;
+ if (done)
+ *done = true;
+}
+
+TEST_P(TDMBuffer, BufferAddDestroyHandler)
+{
+ bool done = false;
+ ASSERT_EQ(tdm_buffer_add_destroy_handler(buffer, _tc_tdm_buffer_destroy_cb, &done), TDM_ERROR_NONE);
+ tbm_surface_destroy(buffer);
+ buffer = NULL;
+ ASSERT_EQ(done, true);
+}
+
+TEST_P(TDMBuffer, BufferAddDestroyHandlerTwice)
+{
+ ASSERT_EQ(tdm_buffer_add_destroy_handler(buffer, _tc_tdm_buffer_destroy_cb, NULL), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_buffer_add_destroy_handler(buffer, _tc_tdm_buffer_destroy_cb, NULL), TDM_ERROR_BAD_REQUEST);
+}
+
+TEST_P(TDMBuffer, BufferAddDestroyHandlerNullObject)
+{
+ ASSERT_EQ(tdm_buffer_add_destroy_handler(NULL, _tc_tdm_buffer_destroy_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMBuffer, BufferAddDestroyHandlerNullOther)
+{
+ ASSERT_EQ(tdm_buffer_add_destroy_handler(buffer, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMBuffer, BufferRemoveDestroyHandler)
+{
+ bool done = false;
+ ASSERT_EQ(tdm_buffer_add_destroy_handler(buffer, _tc_tdm_buffer_destroy_cb, &done), TDM_ERROR_NONE);
+ tdm_buffer_remove_destroy_handler(buffer, _tc_tdm_buffer_destroy_cb, &done);
+ tbm_surface_destroy(buffer);
+ buffer = NULL;
+ ASSERT_EQ(done, false);
+}
+
+TEST_P(TDMBuffer, BufferRemoveDestroyHandlerDifferentData)
+{
+ bool done = false;
+ ASSERT_EQ(tdm_buffer_add_destroy_handler(buffer, _tc_tdm_buffer_destroy_cb, &done), TDM_ERROR_NONE);
+ tdm_buffer_remove_destroy_handler(buffer, _tc_tdm_buffer_destroy_cb, NULL);
+ tbm_surface_destroy(buffer);
+ buffer = NULL;
+ ASSERT_EQ(done, true);
+}
+
+TEST_P(TDMBuffer, BufferRemoveDestroyHandlerNullObject)
+{
+ tdm_buffer_remove_destroy_handler(NULL, _tc_tdm_buffer_destroy_cb, NULL);
+}
+
+TEST_P(TDMBuffer, BufferRemoveDestroyHandlerNullOther)
+{
+ tdm_buffer_remove_destroy_handler(buffer, NULL, NULL);
+}
+
+static void
+_tc_tdm_buffer_release_cb(tbm_surface_h buffer, void *user_data)
+{
+ bool *done = (bool*)user_data;
+ if (done)
+ *done = true;
+}
+
+TEST_P(TDMBuffer, BufferAddReleaseHandler)
+{
+ bool done = false;
+ ASSERT_EQ(tdm_buffer_add_release_handler(buffer, _tc_tdm_buffer_release_cb, &done), TDM_ERROR_NONE);
+ tdm_buffer_ref_backend(buffer);
+ ASSERT_EQ(done, false);
+ tdm_buffer_unref_backend(buffer);
+ ASSERT_EQ(done, true);
+}
+
+TEST_P(TDMBuffer, BufferAddReleaseHandlerTwice)
+{
+ ASSERT_EQ(tdm_buffer_add_release_handler(buffer, _tc_tdm_buffer_release_cb, NULL), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_buffer_add_release_handler(buffer, _tc_tdm_buffer_release_cb, NULL), TDM_ERROR_BAD_REQUEST);
+}
+
+TEST_P(TDMBuffer, BufferAddReleaseHandlerNullObject)
+{
+ bool done = false;
+ ASSERT_EQ(tdm_buffer_add_release_handler(NULL, _tc_tdm_buffer_release_cb, &done), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(done, false);
+}
+
+TEST_P(TDMBuffer, BufferAddReleaseHandlerNullOther)
+{
+ ASSERT_EQ(tdm_buffer_add_release_handler(buffer, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMBuffer, BufferRemoveReleaseHandler)
+{
+ bool done = false;
+ ASSERT_EQ(tdm_buffer_add_release_handler(buffer, _tc_tdm_buffer_release_cb, &done), TDM_ERROR_NONE);
+ tdm_buffer_ref_backend(buffer);
+ ASSERT_EQ(done, false);
+ tdm_buffer_remove_release_handler(buffer, _tc_tdm_buffer_release_cb, &done);
+ tdm_buffer_unref_backend(buffer);
+ ASSERT_EQ(done, false);
+}
+
+TEST_P(TDMBuffer, BufferRemoveReleaseHandlerDifferentData)
+{
+ bool done = false;
+ ASSERT_EQ(tdm_buffer_add_release_handler(buffer, _tc_tdm_buffer_release_cb, &done), TDM_ERROR_NONE);
+ tdm_buffer_ref_backend(buffer);
+ ASSERT_EQ(done, false);
+ tdm_buffer_remove_release_handler(buffer, _tc_tdm_buffer_release_cb, NULL);
+ tdm_buffer_unref_backend(buffer);
+ ASSERT_EQ(done, true);
+}
+
+static void
+_tc_tdm_buffer_release_cb2(tbm_surface_h buffer, void *user_data)
+{
+ bool *done = (bool*)user_data;
+ if (done)
+ *done = true;
+ tdm_buffer_remove_release_handler(buffer, _tc_tdm_buffer_release_cb2, user_data);
+}
+
+TEST_P(TDMBuffer, BufferRemoveReleaseHandlerInHandler)
+{
+ bool done = false;
+ ASSERT_EQ(tdm_buffer_add_release_handler(buffer, _tc_tdm_buffer_release_cb2, &done), TDM_ERROR_NONE);
+ tdm_buffer_ref_backend(buffer);
+ ASSERT_EQ(done, false);
+ tdm_buffer_unref_backend(buffer);
+ ASSERT_EQ(done, true);
+
+ done = false;
+ ASSERT_EQ(tdm_buffer_add_release_handler(buffer, _tc_tdm_buffer_release_cb2, &done), TDM_ERROR_NONE);
+ tdm_buffer_ref_backend(buffer);
+ ASSERT_EQ(done, false);
+ tdm_buffer_unref_backend(buffer);
+ ASSERT_EQ(done, true);
+
+ done = false;
+ ASSERT_EQ(tdm_buffer_add_release_handler(buffer, _tc_tdm_buffer_release_cb2, &done), TDM_ERROR_NONE);
+ tdm_buffer_ref_backend(buffer);
+ ASSERT_EQ(done, false);
+ tdm_buffer_unref_backend(buffer);
+ ASSERT_EQ(done, true);
+}
+
+TEST_P(TDMBuffer, BufferRemoveReleaseHandlerNullObject)
+{
+ bool done = false;
+ ASSERT_EQ(tdm_buffer_add_release_handler(buffer, _tc_tdm_buffer_release_cb, &done), TDM_ERROR_NONE);
+ tdm_buffer_ref_backend(buffer);
+ ASSERT_EQ(done, false);
+ tdm_buffer_remove_release_handler(NULL, _tc_tdm_buffer_release_cb, &done);
+ tdm_buffer_unref_backend(buffer);
+ ASSERT_EQ(done, true);
+}
+
+TEST_P(TDMBuffer, BufferRemoveReleaseHandlerNullOther)
+{
+ tdm_buffer_remove_release_handler(buffer, NULL, NULL);
+}
+
+TEST_P(TDMBuffer, BufferRemoveReleaseHandlerNoAdd)
+{
+ tdm_buffer_remove_release_handler(buffer, _tc_tdm_buffer_release_cb, NULL);
+}
+
+#ifdef TDM_UT_TEST_WITH_PARAMS
+INSTANTIATE_TEST_CASE_P(TDMBufferParams,
+ TDMBuffer,
+ Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
+#else
+INSTANTIATE_TEST_CASE_P(TDMBufferParams,
+ TDMBuffer,
+ Values(TDM_DEFAULT_MODULE));
+#endif
+
+/* LCOV_EXCL_END */
\ No newline at end of file
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2017 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
+ * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
+ * Contact: Roman Marchenko <r.marchenko@samsung.com>
+ * Contact: Sergey Sizonov <s.sizonov@samsung.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+**************************************************************************/
+
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/signalfd.h>
+#include <poll.h>
+#include <sys/prctl.h>
+
+#include "tc_tdm.h"
+#include "tdm_client.h"
+
+/* LCOV_EXCL_START */
+
+enum {
+ TDM_UT_PIPE_MSG_NONE,
+ TDM_UT_PIPE_MSG_REPLY,
+ TDM_UT_PIPE_MSG_SERVER_READY,
+ TDM_UT_PIPE_MSG_SERVER_FAILED,
+ TDM_UT_PIPE_MSG_DPMS_ON,
+ TDM_UT_PIPE_MSG_DPMS_OFF,
+ TDM_UT_PIPE_MSG_TERMINATE_SERVER,
+};
+
+static int _tc_tdm_pipe_read_msg(int fd);
+static bool _tc_tdm_pipe_write_msg(int fd, int reply_fd, int msg);
+static pid_t _tc_tdm_client_server_fork(int *pipe_to_parent, int *pipe_to_child);
+
+class TDMClient : public TDMEnv
+{
+public:
+ static pid_t server_pid;
+
+ /* 0: read, 1: write */
+ static int pipe_parent[2];
+ static int pipe_child[2];
+
+ tdm_client *client;
+ tdm_client_output *output;
+ tdm_client_vblank *vblank;
+
+ double vrefresh_interval, start, end;
+
+ TDMClient();
+
+ void SetUp(void);
+ void TearDown(void);
+ bool PrepareClient(void);
+ bool PrepareOutput(void);
+ bool PrepareVblank(void);
+
+ static void TearDownTestCase(void);
+ static void ServerFork(void);
+ static void ServerKill(void);
+};
+
+pid_t TDMClient::server_pid = -1;
+int TDMClient::pipe_parent[2] = {-1, -1};
+int TDMClient::pipe_child[2] = {-1, -1};
+
+void TDMClient::TearDownTestCase(void)
+{
+ ServerKill();
+}
+
+void TDMClient::ServerFork(void)
+{
+ if (server_pid > 0)
+ return;
+
+ server_pid = _tc_tdm_client_server_fork(pipe_parent, pipe_child);
+ ASSERT_GT(server_pid, 0);
+}
+
+void TDMClient::ServerKill(void)
+{
+ if (pipe_child[0] >= 0)
+ close(pipe_child[0]);
+ if (pipe_child[1] >= 0) {
+ if (server_pid > 0) {
+ bool ret = _tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_TERMINATE_SERVER);
+ if (ret) {
+ if (waitpid(server_pid, NULL, 0) == server_pid)
+ TDM_INFO("*** server terminated ***");
+ else
+ TDM_ERR("*** failed to terminate server ***");
+ } else {
+ if (kill(server_pid, 9) < 0)
+ TDM_ERR("*** failed to kill server ***");
+ }
+ }
+ close(pipe_child[1]);
+ }
+
+ if (pipe_parent[0] >= 0)
+ close(pipe_parent[0]);
+ if (pipe_parent[1] >= 0)
+ close(pipe_parent[1]);
+
+ server_pid = -1;
+ pipe_parent[0] = pipe_parent[1] = -1;
+ pipe_child[0] = pipe_child[1] = -1;
+}
+
+TDMClient::TDMClient()
+{
+ client = NULL;
+ output = NULL;
+ vblank = NULL;
+ vrefresh_interval = start = end = 0.0;
+}
+
+void TDMClient::SetUp(void)
+{
+ TDMEnv::SetUp();
+
+ if (server_pid == -1)
+ ServerFork();
+}
+
+void TDMClient::TearDown(void)
+{
+ if (vblank)
+ tdm_client_vblank_destroy(vblank);
+ if (client)
+ tdm_client_destroy(client);
+
+ TDMEnv::TearDown();
+}
+
+bool TDMClient::PrepareClient(void)
+{
+ tdm_error ret;
+ client = tdm_client_create(&ret);
+ TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(client != NULL);
+
+ return true;
+}
+
+bool TDMClient::PrepareOutput(void)
+{
+ tdm_error ret;
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(client != NULL);
+
+ output = tdm_client_get_output(client, NULL, &ret);
+ TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(output != NULL);
+
+ return true;
+}
+
+bool TDMClient::PrepareVblank(void)
+{
+ tdm_error ret;
+ unsigned int refresh;
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(output != NULL);
+
+ vblank = tdm_client_output_create_vblank(output, &ret);
+ TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(vblank != NULL);
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_client_output_get_refresh_rate(output, &refresh) == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(refresh > 0);
+
+ vrefresh_interval = 1.0 / (double)refresh;
+ TDM_UT_RETURN_FALSE_IF_FAIL(vrefresh_interval > 0);
+
+ return true;
+}
+
+static int
+_tc_tdm_pipe_read_msg(int fd)
+{
+ ssize_t len;
+ int msg;
+
+ do {
+ len = read(fd, &msg, sizeof msg);
+ } while (len < 0 && errno == EINTR);
+
+ if (len <= 0)
+ msg = TDM_UT_PIPE_MSG_NONE;
+
+ return msg;
+}
+
+static bool
+_tc_tdm_pipe_write_msg(int fd, int reply_fd, int msg)
+{
+ ssize_t len = write(fd, &msg, sizeof msg);
+ TDM_UT_RETURN_FALSE_IF_FAIL(len == sizeof msg);
+
+ if (reply_fd >= 0) {
+ int reply = _tc_tdm_pipe_read_msg(reply_fd);
+ TDM_UT_RETURN_FALSE_IF_FAIL(reply == TDM_UT_PIPE_MSG_REPLY);
+ }
+
+ return true;
+}
+
+static bool
+_tc_tdm_server_set_output_dpms(tdm_display *dpy, int msg)
+{
+ tdm_error ret;
+ tdm_output *output;
+ tdm_output_dpms dpms;
+
+ output = tdm_display_find_output(dpy, "primary", &ret);
+ TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(output != NULL);
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_dpms(output, &dpms) == TDM_ERROR_NONE);
+
+ switch (msg) {
+ case TDM_UT_PIPE_MSG_DPMS_ON:
+ if (dpms != TDM_OUTPUT_DPMS_ON)
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON) == TDM_ERROR_NONE);
+ break;
+ case TDM_UT_PIPE_MSG_DPMS_OFF:
+ if (dpms != TDM_OUTPUT_DPMS_OFF)
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF) == TDM_ERROR_NONE);
+ break;
+ default:
+ break;
+ }
+
+ return true;
+}
+
+static void
+_tc_tdm_server_run(int *pipe_parent, int *pipe_child)
+{
+ tdm_display *dpy = NULL;
+ tdm_error ret;
+ struct pollfd fds[2];
+ int tdm_fd, err;
+ int output_count = 0;
+
+ dpy = tdm_display_init(&ret);
+ TDM_UT_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, failed);
+ TDM_UT_GOTO_IF_FAIL(dpy != NULL, failed);
+
+ TDM_UT_GOTO_IF_FAIL(tdm_display_get_output_count(dpy, &output_count) == TDM_ERROR_NONE, failed);
+
+ for (int o = 0; o < output_count; o++) {
+ tdm_output *output = tdm_display_get_output(dpy, o, &ret);
+ TDM_UT_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, failed);
+ TDM_UT_GOTO_IF_FAIL(output != NULL, failed);
+
+ if (!tc_tdm_output_is_connected(output))
+ continue;
+
+ TDM_UT_GOTO_IF_FAIL(tc_tdm_output_prepare(dpy, output, true) == true, failed);
+ }
+
+ TDM_UT_GOTO_IF_FAIL(_tc_tdm_pipe_write_msg(pipe_parent[1], -1, TDM_UT_PIPE_MSG_SERVER_READY) == true, done);
+
+ TDM_INFO("*** server ready ***");
+
+ ret = tdm_display_get_fd(dpy, &tdm_fd);
+ TDM_UT_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, done);
+
+ fds[0].events = POLLIN;
+ fds[0].fd = tdm_fd;
+ fds[0].revents = 0;
+
+ fds[1].events = POLLIN;
+ fds[1].fd = pipe_child[0];
+ fds[1].revents = 0;
+
+ while (1) {
+ /* make sure all events are flushed to clients before falling in sleep */
+ tdm_display_flush(dpy);
+
+ err = poll(fds, 2, -1);
+ if (err < 0) {
+ if (errno == EINTR || errno == EAGAIN) {
+ continue;
+ } else {
+ TDM_ERR("server-process: poll failed: %m\n");
+ goto done;
+ }
+ }
+
+ if (fds[0].revents & POLLIN)
+ ret = tc_tdm_display_handle_events(dpy);
+
+ if (fds[1].revents & POLLIN) {
+ int msg = _tc_tdm_pipe_read_msg(pipe_child[0]);
+ _tc_tdm_pipe_write_msg(pipe_parent[1], -1, TDM_UT_PIPE_MSG_REPLY);
+
+ switch (msg) {
+ case TDM_UT_PIPE_MSG_DPMS_ON:
+ case TDM_UT_PIPE_MSG_DPMS_OFF:
+ _tc_tdm_server_set_output_dpms(dpy, msg);
+ break;
+ case TDM_UT_PIPE_MSG_TERMINATE_SERVER:
+ goto done;
+ default:
+ break;
+ }
+ }
+ }
+
+done:
+ if (dpy)
+ tdm_display_deinit(dpy);
+ return;
+
+failed:
+ TDM_UT_GOTO_IF_FAIL(_tc_tdm_pipe_write_msg(pipe_parent[1], -1, TDM_UT_PIPE_MSG_SERVER_FAILED) == true, done);
+ TDM_INFO("*** server failed ***");
+
+ if (dpy)
+ tdm_display_deinit(dpy);
+ return;
+
+}
+
+static void _tc_tdm_client_sig_handler(int sig)
+{
+ TDM_UT_ERR("got signal: %d", sig);
+ kill(TDMClient::server_pid, 9);
+ abort();
+}
+
+static pid_t
+_tc_tdm_client_server_fork(int *pipe_parent, int *pipe_child)
+{
+ pid_t pid;
+ int msg;
+
+ TDM_UT_GOTO_IF_FAIL(pipe(pipe_parent) == 0, failed);
+ TDM_UT_GOTO_IF_FAIL(pipe(pipe_child) == 0, failed);
+
+ signal(SIGCHLD, SIG_IGN);
+ signal(SIGSEGV, _tc_tdm_client_sig_handler);
+
+ prctl(PR_SET_PDEATHSIG, SIGHUP);
+
+ pid = fork();
+ TDM_UT_GOTO_IF_FAIL(pid >= 0, failed);
+
+ if (pid == 0) {
+ _tc_tdm_server_run(pipe_parent, pipe_child);
+ close(pipe_child[0]);
+ close(pipe_child[1]);
+ close(pipe_parent[0]);
+ close(pipe_parent[1]);
+
+#ifdef TIZEN_TEST_GCOV
+ __gcov_flush();
+#endif
+
+ exit(0);
+ }
+
+ msg = _tc_tdm_pipe_read_msg(pipe_parent[0]);
+ TDM_UT_GOTO_IF_FAIL(msg == TDM_UT_PIPE_MSG_SERVER_READY, failed);
+
+ TDM_INFO("*** server fork done ***");
+
+ return pid;
+
+failed:
+ return -1;
+}
+
+TEST_P(TDMClient, ClientCreate)
+{
+ tdm_error ret;
+
+ client = tdm_client_create(&ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(client, NULL);
+}
+
+TEST_P(TDMClient, ClientCreateNullOther)
+{
+ client = tdm_client_create(NULL);
+ ASSERT_NE(client, NULL);
+}
+
+TEST_P(TDMClient, ClientDestroy)
+{
+ tdm_error ret;
+
+ client = tdm_client_create(&ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(client, NULL);
+
+ tdm_client_destroy(client);
+ client = NULL;
+}
+
+TEST_P(TDMClient, ClientNullObject)
+{
+ tdm_client_destroy(NULL);
+}
+
+/* tdm_client_get_fd */
+TEST_P(TDMClient, ClientGetFd)
+{
+ int fd = TDM_UT_INVALID_VALUE;
+
+ ASSERT_EQ(PrepareClient(), true);
+
+ ASSERT_EQ(tdm_client_get_fd(client, &fd), TDM_ERROR_NONE);
+ ASSERT_GE(fd, 0);
+}
+
+TEST_P(TDMClient, ClientGetFdNullObject)
+{
+ int fd = TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_client_get_fd(NULL, &fd), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(fd, TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMClient, ClientGetFdNullOther)
+{
+ ASSERT_EQ(PrepareClient(), true);
+
+ ASSERT_EQ(tdm_client_get_fd(client, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+static void
+_tc_tdm_client_vblank_cb(unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec, void *user_data)
+{
+ bool *done = (bool *)user_data;
+ if (done)
+ *done = true;
+}
+
+/* tdm_client_handle_events_timeout */
+TEST_P(TDMClient, ClientHandleEvent)
+{
+ bool done = false;
+
+ ASSERT_EQ(PrepareClient(), true);
+
+ ASSERT_EQ(tdm_client_wait_vblank(client, NULL, 1, 1, 0, _tc_tdm_client_vblank_cb, &done), TDM_ERROR_NONE);
+ ASSERT_EQ(done, false);
+
+ while (!done)
+ ASSERT_EQ(tdm_client_handle_events(client), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMClient, ClientHandleEventNullObject)
+{
+ ASSERT_EQ(tdm_client_handle_events(NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+/* tdm_client_wait_vblank, deprecated */
+TEST_P(TDMClient, ClientWaitVblank)
+{
+ bool done = false;
+
+ ASSERT_EQ(PrepareClient(), true);
+
+ ASSERT_EQ(tdm_client_wait_vblank(client, NULL, 1, 1, 0, _tc_tdm_client_vblank_cb, &done), TDM_ERROR_NONE);
+ ASSERT_EQ(done, false);
+
+ while (!done)
+ ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
+}
+
+/* tdm_client_get_output */
+TEST_P(TDMClient, ClientGetOutput)
+{
+ tdm_error ret;
+
+ ASSERT_EQ(PrepareClient(), true);
+
+ output = tdm_client_get_output(client, NULL, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(output, NULL);
+}
+
+TEST_P(TDMClient, ClientGetOutputPrimary)
+{
+ tdm_error ret;
+
+ ASSERT_EQ(PrepareClient(), true);
+
+ output = tdm_client_get_output(client, (char*)"primary", &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(output, NULL);
+}
+
+TEST_P(TDMClient, ClientGetOutputDefault)
+{
+ tdm_error ret;
+
+ ASSERT_EQ(PrepareClient(), true);
+
+ output = tdm_client_get_output(client, (char*)"default", &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(output, NULL);
+}
+
+TEST_P(TDMClient, ClientGetOutputInvalidName)
+{
+ tdm_error ret;
+
+ ASSERT_EQ(PrepareClient(), true);
+
+ output = tdm_client_get_output(client, (char*)"invalid", &ret);
+ ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(output, NULL);
+}
+
+TEST_P(TDMClient, ClientGetOutputNullObject)
+{
+ tdm_error ret;
+
+ output = tdm_client_get_output(NULL, NULL, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(output, NULL);
+}
+
+TEST_P(TDMClient, ClientGetOutputNullOther)
+{
+ ASSERT_EQ(PrepareClient(), true);
+
+ output = tdm_client_get_output(client, NULL, NULL);
+ ASSERT_NE(output, NULL);
+}
+
+static void
+_tc_tdm_client_output_change_dpms_cb(tdm_client_output *output,
+ tdm_output_change_type type,
+ tdm_value value,
+ void *user_data)
+{
+ bool *done = (bool *)user_data;
+
+ switch (type) {
+ case TDM_OUTPUT_CHANGE_DPMS:
+ if (done)
+ *done = true;
+ break;
+ default:
+ break;
+ }
+}
+
+/* tdm_client_output_add_change_handler */
+TEST_P(TDMClient, ClientOutputAddChangeHandler)
+{
+ bool done = false;
+ tdm_output_dpms dpms;
+
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+
+ ASSERT_EQ(tdm_client_output_add_change_handler(output, _tc_tdm_client_output_change_dpms_cb, &done), TDM_ERROR_NONE);
+ ASSERT_EQ(_tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_OFF), true);
+
+ while (!done)
+ ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
+
+ ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
+ ASSERT_EQ(dpms, TDM_OUTPUT_DPMS_OFF);
+
+ ASSERT_EQ(_tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_ON), true);
+ while (dpms != TDM_OUTPUT_DPMS_ON) {
+ ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
+ }
+}
+
+TEST_P(TDMClient, ClientOutputAddChangeHandlerTwice)
+{
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+
+ ASSERT_EQ(tdm_client_output_add_change_handler(output, _tc_tdm_client_output_change_dpms_cb, NULL), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_client_output_add_change_handler(output, _tc_tdm_client_output_change_dpms_cb, NULL), TDM_ERROR_BAD_REQUEST);
+}
+
+TEST_P(TDMClient, ClientOutputAddChangeHandlerNullObject)
+{
+ ASSERT_EQ(tdm_client_output_add_change_handler(NULL, _tc_tdm_client_output_change_dpms_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMClient, ClientOutputAddChangeHandlerNullOther)
+{
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+
+ ASSERT_EQ(tdm_client_output_add_change_handler(output, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+/* tdm_client_output_remove_change_handler */
+TEST_P(TDMClient, ClientOutputRemoveChangeHandler)
+{
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+
+ ASSERT_EQ(tdm_client_output_add_change_handler(output, _tc_tdm_client_output_change_dpms_cb, NULL), TDM_ERROR_NONE);
+ tdm_client_output_remove_change_handler(output, _tc_tdm_client_output_change_dpms_cb, NULL);
+}
+
+TEST_P(TDMClient, ClientOutputRemoveChangeHandlerDifferentData)
+{
+ bool done = (bool)TDM_UT_INVALID_VALUE;
+
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+
+ ASSERT_EQ(tdm_client_output_add_change_handler(output, _tc_tdm_client_output_change_dpms_cb, &done), TDM_ERROR_NONE);
+ tdm_client_output_remove_change_handler(output, _tc_tdm_client_output_change_dpms_cb, NULL);
+}
+
+static void
+_tc_tdm_client_output_change_dpms_cb2(tdm_client_output *output,
+ tdm_output_change_type type,
+ tdm_value value,
+ void *user_data)
+{
+ switch (type) {
+ case TDM_OUTPUT_CHANGE_DPMS:
+ tdm_client_output_remove_change_handler(output, _tc_tdm_client_output_change_dpms_cb2, user_data);
+ break;
+ default:
+ break;
+ }
+}
+
+TEST_P(TDMClient, ClientOutputRemoveChangeHandlerInHandler)
+{
+ tdm_output_dpms dpms = TDM_OUTPUT_DPMS_ON;
+
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+
+ ASSERT_EQ(tdm_client_output_add_change_handler(output, _tc_tdm_client_output_change_dpms_cb2, NULL), TDM_ERROR_NONE);
+ ASSERT_EQ(_tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_OFF), true);
+ ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
+ while (dpms != TDM_OUTPUT_DPMS_OFF) {
+ ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
+ }
+
+ ASSERT_EQ(_tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_ON), true);
+ while (dpms != TDM_OUTPUT_DPMS_ON)
+ ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMClient, ClientOutputRemoveChangeHandlerNullObject)
+{
+ tdm_client_output_remove_change_handler(NULL, _tc_tdm_client_output_change_dpms_cb, NULL);
+}
+
+TEST_P(TDMClient, ClientOutputRemoveChangeHandlerNullOther)
+{
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+
+ tdm_client_output_remove_change_handler(output, NULL, NULL);
+}
+
+/* tdm_client_output_get_refresh_rate */
+TEST_P(TDMClient, ClientOutputGetRefreshRate)
+{
+ unsigned int refresh = 0;
+
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+
+ ASSERT_EQ(tdm_client_output_get_refresh_rate(output, &refresh), TDM_ERROR_NONE);
+ ASSERT_GT(refresh, 0);
+}
+
+TEST_P(TDMClient, ClientOutputGetRefreshRateNullObject)
+{
+ unsigned int refresh = (unsigned int)TDM_UT_INVALID_VALUE;
+
+ ASSERT_EQ(tdm_client_output_get_refresh_rate(NULL, &refresh), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(refresh, (unsigned int)TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMClient, ClientOutputGetRefreshRateNullOther)
+{
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+
+ ASSERT_EQ(tdm_client_output_get_refresh_rate(output, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+/* tdm_client_output_get_refresh_rate */
+TEST_P(TDMClient, ClientOutputGetConnStatus)
+{
+ tdm_output_conn_status status = (tdm_output_conn_status)TDM_UT_INVALID_VALUE;
+
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+
+ ASSERT_EQ(tdm_client_output_get_conn_status(output, &status), TDM_ERROR_NONE);
+ ASSERT_NE(status, (tdm_output_conn_status)TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMClient, ClientOutputGetConnStatusNullObject)
+{
+ tdm_output_conn_status status = (tdm_output_conn_status)TDM_UT_INVALID_VALUE;
+
+ ASSERT_EQ(tdm_client_output_get_conn_status(NULL, &status), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(status, (tdm_output_conn_status)TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMClient, ClientOutputGetConnStatusNullOther)
+{
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+
+ ASSERT_EQ(tdm_client_output_get_conn_status(output, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+/* tdm_client_output_get_dpms */
+TEST_P(TDMClient, ClientOutputGetDpms)
+{
+ tdm_output_dpms dpms = (tdm_output_dpms)TDM_UT_INVALID_VALUE;
+
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+
+ ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
+ ASSERT_NE(dpms, (tdm_output_dpms)TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMClient, ClientOutputGetDpmsNullObject)
+{
+ tdm_output_dpms dpms = (tdm_output_dpms)TDM_UT_INVALID_VALUE;
+
+ ASSERT_EQ(tdm_client_output_get_dpms(NULL, &dpms), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(dpms, (tdm_output_dpms)TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMClient, ClientOutputGetDpmsNullOther)
+{
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+
+ ASSERT_EQ(tdm_client_output_get_dpms(output, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+/* tdm_client_output_create_vblank */
+TEST_P(TDMClient, ClientOutputCreateVblank)
+{
+ tdm_error ret;
+
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+
+ vblank = tdm_client_output_create_vblank(output, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(vblank, NULL);
+}
+
+TEST_P(TDMClient, ClientOutputCreateVblankNullObject)
+{
+ tdm_error ret;
+
+ vblank = tdm_client_output_create_vblank(NULL, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(vblank, NULL);
+}
+
+TEST_P(TDMClient, ClientOutputCreateVblankNullOther)
+{
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+
+ vblank = tdm_client_output_create_vblank(output, NULL);
+ ASSERT_NE(vblank, NULL);
+}
+
+/* tdm_client_vblank_destroy */
+TEST_P(TDMClient, ClientVblankDestroy)
+{
+ tdm_error ret;
+
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+
+ vblank = tdm_client_output_create_vblank(output, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(vblank, NULL);
+
+ tdm_client_vblank_destroy(vblank);
+ vblank = NULL;
+}
+
+TEST_P(TDMClient, ClientVblankDestroyNullObject)
+{
+ tdm_client_vblank_destroy(NULL);
+}
+
+/* tdm_client_vblank_set_name */
+TEST_P(TDMClient, ClientVblankSetName)
+{
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+ ASSERT_EQ(PrepareVblank(), true);
+
+ ASSERT_EQ(tdm_client_vblank_set_name(vblank, TDM_UT_VBLANK_NAME), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMClient, ClientVblankSetNameTwice)
+{
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+ ASSERT_EQ(PrepareVblank(), true);
+
+ ASSERT_EQ(tdm_client_vblank_set_name(vblank, TDM_UT_VBLANK_NAME), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_client_vblank_set_name(vblank, TDM_UT_VBLANK_NAME), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMClient, ClientVblankSetNameNullObject)
+{
+ ASSERT_EQ(tdm_client_vblank_set_name(NULL, TDM_UT_VBLANK_NAME), TDM_ERROR_INVALID_PARAMETER);
+}
+
+/* tdm_client_vblank_set_sync */
+TEST_P(TDMClient, ClientVblankSetSync)
+{
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+ ASSERT_EQ(PrepareVblank(), true);
+
+ ASSERT_EQ(tdm_client_vblank_set_sync(vblank, 1), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMClient, ClientVblankSetSyncTwice)
+{
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+ ASSERT_EQ(PrepareVblank(), true);
+
+ ASSERT_EQ(tdm_client_vblank_set_sync(vblank, 1), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_client_vblank_set_sync(vblank, 1), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMClient, ClientVblankSetSyncNullObject)
+{
+ ASSERT_EQ(tdm_client_vblank_set_sync(NULL, 1), TDM_ERROR_INVALID_PARAMETER);
+}
+
+/* tdm_client_vblank_set_fps */
+TEST_P(TDMClient, ClientVblankSetFps)
+{
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+ ASSERT_EQ(PrepareVblank(), true);
+
+ ASSERT_EQ(tdm_client_vblank_set_fps(vblank, 30), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMClient, ClientVblankSetFpsTwice)
+{
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+ ASSERT_EQ(PrepareVblank(), true);
+
+ ASSERT_EQ(tdm_client_vblank_set_fps(vblank, 30), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_client_vblank_set_fps(vblank, 30), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMClient, ClientVblankSetFpsNullObject)
+{
+ ASSERT_EQ(tdm_client_vblank_set_fps(NULL, 30), TDM_ERROR_INVALID_PARAMETER);
+}
+
+/* tdm_client_vblank_set_offset */
+TEST_P(TDMClient, ClientVblankSetOffset)
+{
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+ ASSERT_EQ(PrepareVblank(), true);
+
+ ASSERT_EQ(tdm_client_vblank_set_offset(vblank, 10), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMClient, ClientVblankSetOffsetTwice)
+{
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+ ASSERT_EQ(PrepareVblank(), true);
+
+ ASSERT_EQ(tdm_client_vblank_set_offset(vblank, 10), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_client_vblank_set_offset(vblank, 10), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMClient, ClientVblankSetOffsetNullObject)
+{
+ ASSERT_EQ(tdm_client_vblank_set_offset(NULL, 10), TDM_ERROR_INVALID_PARAMETER);
+}
+
+/* tdm_client_vblank_set_enable_fake */
+TEST_P(TDMClient, ClientVblankSetEnableFake)
+{
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+ ASSERT_EQ(PrepareVblank(), true);
+
+ ASSERT_EQ(tdm_client_vblank_set_enable_fake(vblank, 1), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMClient, ClientVblankSetEnableFakeTwice)
+{
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+ ASSERT_EQ(PrepareVblank(), true);
+
+ ASSERT_EQ(tdm_client_vblank_set_enable_fake(vblank, 1), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_client_vblank_set_enable_fake(vblank, 1), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMClient, ClientVblankSetEnableFakeNullObject)
+{
+ ASSERT_EQ(tdm_client_vblank_set_enable_fake(NULL, 1), TDM_ERROR_INVALID_PARAMETER);
+}
+
+static void
+_tc_tdm_client_vblank_cb2(tdm_client_vblank *vblank,
+ tdm_error error,
+ unsigned int sequence,
+ unsigned int tv_sec,
+ unsigned int tv_usec,
+ void *user_data)
+{
+ bool *done = (bool *)user_data;
+ if (done)
+ *done = true;
+}
+
+/* tdm_client_vblank_wait */
+TEST_P(TDMClient, ClientVblankWait)
+{
+ bool done;
+
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+ ASSERT_EQ(PrepareVblank(), true);
+
+ done = false;
+ ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb2, &done), TDM_ERROR_NONE);
+
+ start = tdm_helper_get_time();
+ while (!done)
+ ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
+ end = tdm_helper_get_time();
+
+ /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
+ ASSERT_LT((end - start), (vrefresh_interval + vrefresh_interval));
+}
+
+TEST_P(TDMClient, ClientVblankWaitFewTime)
+{
+ bool done1, done2, done3;
+
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+ ASSERT_EQ(PrepareVblank(), true);
+
+ done1 = done2 = done3 = false;
+ ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb2, &done1), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb2, &done2), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb2, &done3), TDM_ERROR_NONE);
+
+ start = tdm_helper_get_time();
+ while (!done1 || !done2 || !done3)
+ ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
+ end = tdm_helper_get_time();
+
+ /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
+ ASSERT_LT((end - start), (vrefresh_interval + vrefresh_interval));
+
+}
+
+TEST_P(TDMClient, ClientVblankWaitInterval0)
+{
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+ ASSERT_EQ(PrepareVblank(), true);
+
+ ASSERT_EQ(tdm_client_vblank_wait(vblank, 0, _tc_tdm_client_vblank_cb2, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMClient, ClientVblankWaitInterval)
+{
+ bool done;
+
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+ ASSERT_EQ(PrepareVblank(), true);
+
+ /* start from 1 */
+ for (int t = 1; t < 10; t++) {
+ done = false;
+ ASSERT_EQ(tdm_client_vblank_wait(vblank, t, _tc_tdm_client_vblank_cb2, &done), TDM_ERROR_NONE);
+
+ start = tdm_helper_get_time();
+ while (!done)
+ ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
+ end = tdm_helper_get_time();
+
+ /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
+ ASSERT_GT((end - start), (vrefresh_interval * (t - 1)));
+ ASSERT_LT((end - start), (vrefresh_interval * t + vrefresh_interval));
+ }
+}
+
+static void
+_tc_tdm_client_vblank_cb3(tdm_client_vblank *vblank,
+ tdm_error error,
+ unsigned int sequence,
+ unsigned int tv_sec,
+ unsigned int tv_usec,
+ void *user_data)
+{
+ unsigned int *cur_seq = (unsigned int *)user_data;
+ if (cur_seq)
+ *cur_seq = sequence;
+}
+
+TEST_P(TDMClient, ClientVblankWaitSeq)
+{
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+ ASSERT_EQ(PrepareVblank(), true);
+
+ for (int t = 0; t < 10; t++) {
+ unsigned int cur_seq = 0, temp = 0;
+
+ ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb3, &cur_seq), TDM_ERROR_NONE);
+ while (cur_seq == 0)
+ ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
+
+ start = tdm_helper_get_time();
+ ASSERT_EQ(tdm_client_vblank_wait_seq(vblank, cur_seq + 1, _tc_tdm_client_vblank_cb3, &temp), TDM_ERROR_NONE);
+ while (temp == 0)
+ ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
+ end = tdm_helper_get_time();
+
+ /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
+ ASSERT_LT((end - start), (vrefresh_interval + vrefresh_interval));
+ }
+}
+
+TEST_P(TDMClient, ClientVblankWaitSeqInterval)
+{
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+ ASSERT_EQ(PrepareVblank(), true);
+
+ /* start from 1 */
+ for (int t = 1; t < 10; t++) {
+ unsigned int cur_seq = 0, temp = 0;
+
+ ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb3, &cur_seq), TDM_ERROR_NONE);
+ while (cur_seq == 0)
+ ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
+
+ start = tdm_helper_get_time();
+ ASSERT_EQ(tdm_client_vblank_wait_seq(vblank, cur_seq + t, _tc_tdm_client_vblank_cb3, &temp), TDM_ERROR_NONE);
+ while (temp == 0)
+ ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
+ end = tdm_helper_get_time();
+
+ /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
+ ASSERT_GT((end - start), (vrefresh_interval * (t - 1)));
+ ASSERT_LT((end - start), (vrefresh_interval * t + vrefresh_interval));
+ }
+}
+
+TEST_P(TDMClient, ClientVblankWaitSetOffset)
+{
+ bool done;
+
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+ ASSERT_EQ(PrepareVblank(), true);
+
+ ASSERT_EQ(tdm_client_vblank_set_offset(vblank, 100), TDM_ERROR_NONE);
+
+ done = false;
+ ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb2, &done), TDM_ERROR_NONE);
+
+ start = tdm_helper_get_time();
+ while (!done)
+ ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
+ end = tdm_helper_get_time();
+
+ /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
+ ASSERT_GT((end - start), (0.1));
+ ASSERT_LT((end - start), (vrefresh_interval + vrefresh_interval + 0.1));
+}
+
+TEST_P(TDMClient, ClientVblankWaitSetFps)
+{
+ bool done;
+ double interval;
+ unsigned int fps = 10;
+
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+ ASSERT_EQ(PrepareVblank(), true);
+
+ ASSERT_EQ(tdm_client_vblank_set_fps(vblank, fps), TDM_ERROR_NONE);
+ interval = 1.0 / (double)fps;
+
+ done = false;
+ ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb2, &done), TDM_ERROR_NONE);
+
+ start = tdm_helper_get_time();
+ while (!done)
+ ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
+ end = tdm_helper_get_time();
+
+ /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
+ ASSERT_GT((end - start), (interval - vrefresh_interval));
+ ASSERT_LT((end - start), (interval + vrefresh_interval));
+}
+
+#if 0
+
+TEST_P(TDMVblank, VblankWaitEnableDisableGlobalFps)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
+ double vrefresh_interval;
+ unsigned int cur_seq[3];
+ unsigned int global_fps = 5;
+ double start, end, interval;
+
+ ASSERT_EQ(TestPrepareOutput(), true);
+ ASSERT_EQ(TestCreateVblanks3(), true);
+ ASSERT_EQ(vblank_count, 3);
+
+ ASSERT_EQ(tdm_vblank_get_fps(vblanks[0], &fps), TDM_ERROR_NONE);
+ ASSERT_TRUE(fps >= 30 && fps != (unsigned int)TDM_UT_INVALID_VALUE);
+ vrefresh_interval = 1.0 / (double)fps;
+
+ for (int v = 0; v < 3; v++)
+ ASSERT_EQ(tdm_vblank_set_fixed_fps(vblanks[v], 10 * (v + 1)), TDM_ERROR_NONE);
+
+ /* enable test */
+ tdm_vblank_enable_global_fps(1, global_fps);
+ interval = 1.0 / (double)global_fps;
+
+ for (int v = 0; v < 3; v++) {
+ cur_seq[v] = 0;
+ ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _tc_tdm_vblank_cb, &cur_seq[v]), TDM_ERROR_NONE);
+ }
+
+ start = tdm_helper_get_time();
+ while (cur_seq[0] == 0)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ end = tdm_helper_get_time();
+
+ ASSERT_NE(cur_seq[1], 0);
+ ASSERT_NE(cur_seq[2], 0);
+
+ /* "+- vrefresh_interval" consider the delay of socket communication between kernel and platform */
+ ASSERT_GT((end - start), (interval - vrefresh_interval));
+ ASSERT_LT((end - start), (interval + vrefresh_interval));
+
+ /* disable test */
+ tdm_vblank_enable_global_fps(0, 0);
+
+ for (int v = 0; v < 3; v++) {
+ cur_seq[v] = 0;
+ ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _tc_tdm_vblank_cb, &cur_seq[v]), TDM_ERROR_NONE);
+ }
+
+ while (cur_seq[0] == 0)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ ASSERT_EQ(cur_seq[1], 0);
+ ASSERT_EQ(cur_seq[2], 0);
+
+ while (cur_seq[1] == 0)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ ASSERT_EQ(cur_seq[2], 0);
+}
+
+TEST_P(TDMVblank, VblankWaitIgnoreGlobalFps)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
+ unsigned int cur_seq[3];
+ unsigned int global_fps = 5;
+ double start, end, interval;
+
+ ASSERT_EQ(TestPrepareOutput(), true);
+ ASSERT_EQ(TestCreateVblanks3(), true);
+ ASSERT_EQ(vblank_count, 3);
+
+ ASSERT_EQ(tdm_vblank_get_fps(vblanks[0], &fps), TDM_ERROR_NONE);
+ ASSERT_TRUE(fps >= 30 && fps != (unsigned int)TDM_UT_INVALID_VALUE);
+ interval = 1.0 / (double)fps;
+
+ /* 2nd vblank will ignore the global fps. */
+ ASSERT_EQ(tdm_vblank_ignore_global_fps(vblanks[1], 1), TDM_ERROR_NONE);
+
+ tdm_vblank_enable_global_fps(1, global_fps);
+
+ for (int v = 0; v < 3; v++) {
+ cur_seq[v] = 0;
+ ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _tc_tdm_vblank_cb, &cur_seq[v]), TDM_ERROR_NONE);
+ }
+
+ start = tdm_helper_get_time();
+ while (cur_seq[1] == 0)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ end = tdm_helper_get_time();
+
+ ASSERT_EQ(cur_seq[0], 0);
+ ASSERT_EQ(cur_seq[2], 0);
+
+ /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
+ ASSERT_LT((end - start), (interval + interval));
+
+ while (cur_seq[0] == 0)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ ASSERT_NE(cur_seq[2], 0);
+}
+
+#endif
+
+TEST_P(TDMClient, ClientVblankWaitNullObject)
+{
+ unsigned int cur_seq = 0;
+
+ ASSERT_EQ(tdm_client_vblank_wait(NULL, 1, _tc_tdm_client_vblank_cb3, &cur_seq), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMClient, ClientVblankWaitNullOther)
+{
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+ ASSERT_EQ(PrepareVblank(), true);
+
+ ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMClient, ClientVblankWaitDpmsOff)
+{
+ tdm_output_dpms dpms = (tdm_output_dpms)TDM_UT_INVALID_VALUE;
+
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+ ASSERT_EQ(PrepareVblank(), true);
+
+ ASSERT_EQ(_tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_OFF), true);
+ while (dpms != TDM_OUTPUT_DPMS_OFF)
+ ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
+ ASSERT_EQ(dpms, TDM_OUTPUT_DPMS_OFF);
+
+ ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb2, NULL), TDM_ERROR_DPMS_OFF);
+
+ ASSERT_EQ(_tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_ON), true);
+ while (dpms != TDM_OUTPUT_DPMS_ON)
+ ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMClient, ClientVblankWaitSetEnableFakeDpmsOff)
+{
+ tdm_output_dpms dpms = (tdm_output_dpms)TDM_UT_INVALID_VALUE;
+ bool done;
+
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+ ASSERT_EQ(PrepareVblank(), true);
+
+ ASSERT_EQ(_tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_OFF), true);
+ while (dpms != TDM_OUTPUT_DPMS_OFF)
+ ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
+
+ ASSERT_EQ(tdm_client_vblank_set_enable_fake(vblank, 1), TDM_ERROR_NONE);
+
+ done = false;
+ ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb2, &done), TDM_ERROR_NONE);
+
+ while (!done)
+ ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
+
+ ASSERT_EQ(_tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_ON), true);
+ while (dpms != TDM_OUTPUT_DPMS_ON)
+ ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
+}
+
+/* tdm_client_vblank_wait */
+TEST_P(TDMClient, ClientVblankIsWaiting)
+{
+ bool done;
+ unsigned int waiting;
+
+ ASSERT_EQ(PrepareClient(), true);
+ ASSERT_EQ(PrepareOutput(), true);
+ ASSERT_EQ(PrepareVblank(), true);
+
+ done = false;
+ ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb2, &done), TDM_ERROR_NONE);
+
+ waiting = tdm_client_vblank_is_waiting(vblank);
+ ASSERT_EQ(waiting, 1);
+
+ start = tdm_helper_get_time();
+ while (!done)
+ ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
+ end = tdm_helper_get_time();
+
+ /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
+ ASSERT_LT((end - start), (vrefresh_interval + vrefresh_interval));
+
+ waiting = tdm_client_vblank_is_waiting(vblank);
+ ASSERT_EQ(waiting, 0);
+}
+
+/* tdm_client_vblank_wait */
+TEST_P(TDMClient, ClientVblankIsWaitingNullObject)
+{
+ unsigned int waiting = tdm_client_vblank_is_waiting(NULL);
+ ASSERT_EQ(waiting, 0);
+}
+
+#ifdef TDM_UT_TEST_WITH_PARAMS
+INSTANTIATE_TEST_CASE_P(TDMClientParams,
+ TDMClient,
+ Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
+#else
+INSTANTIATE_TEST_CASE_P(TDMClientParams,
+ TDMClient,
+ Values(TDM_DEFAULT_MODULE));
+#endif
+
+/* LCOV_EXCL_END */
\ No newline at end of file
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
+ * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
+ * Contact: Roman Marchenko <r.marchenko@samsung.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+**************************************************************************/
+
+#include "tc_tdm.h"
+
+/* LCOV_EXCL_START */
+
+TDMDisplay::TDMDisplay()
+{
+ dpy = NULL;
+ bufmgr = NULL;
+ has_pp_cap = false;
+ has_capture_cap = false;
+}
+
+void TDMDisplay::SetUp(void)
+{
+ tdm_error ret;
+ int count = TDM_UT_INVALID_VALUE;
+ tdm_display_capability capabilities = (tdm_display_capability)TDM_UT_INVALID_VALUE;
+
+ TDMEnv::SetUp();
+
+ dpy = tdm_display_init(&ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(dpy, NULL);
+
+ bufmgr = tbm_bufmgr_init(-1);
+ ASSERT_NE(bufmgr, NULL);
+
+ ASSERT_EQ(tdm_display_get_output_count(dpy, &count), TDM_ERROR_NONE);
+ ASSERT_GT(count, 0);
+
+ ASSERT_EQ(tdm_display_get_capabilities(dpy, &capabilities), TDM_ERROR_NONE);
+ has_pp_cap = capabilities & TDM_DISPLAY_CAPABILITY_PP;
+ has_capture_cap = capabilities & TDM_DISPLAY_CAPABILITY_CAPTURE;
+}
+
+void TDMDisplay::TearDown(void)
+{
+ tbm_bufmgr_deinit(bufmgr);
+ tdm_display_deinit(dpy);
+
+ ASSERT_EQ(tbm_bufmgr_debug_get_ref_count(), 0);
+
+ TDMEnv::TearDown();
+}
+
+tdm_error
+tc_tdm_display_handle_events(tdm_display *dpy)
+{
+ struct pollfd fds;
+ int fd = -1;
+ tdm_error ret;
+ int result;
+
+ ret = tdm_display_get_fd(dpy, &fd);
+ TDM_UT_RETURN_VAL_IF_FAIL(fd >= 0, ret);
+
+ fds.events = POLLIN;
+ fds.fd = fd;
+ fds.revents = 0;
+
+ do {
+ result = poll(&fds, 1, 3000);
+ } while (result == -1 && errno == EINTR);
+
+ if (result == 0) {
+ TDM_UT_ERR("polling tdm_fd timeout.");
+ return TDM_ERROR_TIMEOUT;
+ }
+
+ return tdm_display_handle_events(dpy);
+}
+
+bool
+tc_tdm_display_has_pp_capability(tdm_display *dpy)
+{
+ tdm_display_capability capabilities = (tdm_display_capability)0;
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_display_get_capabilities(dpy, &capabilities) == TDM_ERROR_NONE);
+ return capabilities & TDM_DISPLAY_CAPABILITY_PP;
+}
+
+bool
+tc_tdm_display_has_capture_capability(tdm_display *dpy)
+{
+ tdm_display_capability capabilities = (tdm_display_capability)0;
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_display_get_capabilities(dpy, &capabilities) == TDM_ERROR_NONE);
+ return capabilities & TDM_DISPLAY_CAPABILITY_CAPTURE;
+}
+
+TEST_P(TDMDisplay, DisplayUpdate)
+{
+ ASSERT_EQ(tdm_display_update(dpy), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMDisplay, DisplayUpdateNullObject)
+{
+ ASSERT_EQ(tdm_display_update(NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMDisplay, DisplayGetFDSuccesful)
+{
+ int fd = TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_display_get_fd(dpy, &fd), TDM_ERROR_NONE);
+ ASSERT_NE(fd, TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMDisplay, DisplayGetFDNullObject)
+{
+ int fd = TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_display_get_fd(NULL, &fd), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(fd, TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMDisplay, DisplayGetFDNullFD)
+{
+ ASSERT_EQ(tdm_display_get_fd(dpy, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+/* DISABLED */
+TEST_P(TDMDisplay, DISABLED_DisplayHandleEvents)
+{
+ /* TODO Generate events*/
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMDisplay, DisplayFlush)
+{
+ tdm_display_flush(dpy);
+}
+
+TEST_P(TDMDisplay, DisplayFlushNullObject)
+{
+ tdm_display_flush(NULL);
+}
+
+TEST_P(TDMDisplay, DisplayGetBackendInfo)
+{
+ const char *name = (const char*)TDM_UT_INVALID_VALUE;
+ const char *vendor = (const char*)TDM_UT_INVALID_VALUE;
+ int major = TDM_UT_INVALID_VALUE, minor = TDM_UT_INVALID_VALUE;
+
+ ASSERT_EQ(tdm_display_get_backend_info(dpy, &name, &vendor, &major, &minor), TDM_ERROR_NONE);
+ ASSERT_NE(name, (const char*)TDM_UT_INVALID_VALUE);
+ ASSERT_NE(vendor, (const char*)TDM_UT_INVALID_VALUE);
+ ASSERT_NE(major, TDM_UT_INVALID_VALUE);
+ ASSERT_NE(minor, TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMDisplay, DisplayGetBackendInfoNullObject)
+{
+ const char *name = (const char*)TDM_UT_INVALID_VALUE;
+ const char *vendor = (const char*)TDM_UT_INVALID_VALUE;
+ int major = TDM_UT_INVALID_VALUE, minor = TDM_UT_INVALID_VALUE;
+
+ ASSERT_EQ(tdm_display_get_backend_info(NULL, &name, &vendor, &major, &minor), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(name, (const char*)TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(vendor, (const char*)TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(major, TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(minor, TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMDisplay, DisplayGetBackendInfoNullOther)
+{
+ ASSERT_EQ(tdm_display_get_backend_info(dpy, NULL, NULL, NULL, NULL), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMDisplay, DisplayGetCapabilities)
+{
+ tdm_display_capability capabilities = (tdm_display_capability)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_display_get_capabilities(dpy, &capabilities), TDM_ERROR_NONE);
+ ASSERT_NE(capabilities, TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMDisplay, DisplayGetCapabilitiesNullObject)
+{
+ tdm_display_capability capabilities = (tdm_display_capability)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_display_get_capabilities(NULL, &capabilities), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(capabilities, (tdm_display_capability)TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMDisplay, DisplayGetCapabilitiesNullOther)
+{
+ ASSERT_EQ(tdm_display_get_capabilities(dpy, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMDisplay, DisplayGetPPCapabilities)
+{
+ tdm_pp_capability capabilities = (tdm_pp_capability) TDM_UT_INVALID_VALUE;
+ tdm_error ret;
+ if (!has_pp_cap)
+ return;
+ ret = tdm_display_get_pp_capabilities(dpy, &capabilities);
+ ASSERT_TRUE(ret == TDM_ERROR_NONE || ret == TDM_ERROR_NO_CAPABILITY);
+
+ if (ret == TDM_ERROR_NONE)
+ ASSERT_NE(capabilities, TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMDisplay, DisplayGetPPCapabilitiesNullObject)
+{
+ tdm_pp_capability capabilities = (tdm_pp_capability)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_display_get_pp_capabilities(NULL, &capabilities), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(capabilities, (tdm_pp_capability)TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMDisplay, DisplayGetPPCapabilitiesNullOther)
+{
+ ASSERT_EQ(tdm_display_get_pp_capabilities(dpy, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMDisplay, DisplayGetCaptureCapabilities)
+{
+ tdm_capture_capability capabilities = (tdm_capture_capability)TDM_UT_INVALID_VALUE;
+ tdm_error ret;
+
+ if (!has_capture_cap)
+ return;
+
+ ret = tdm_display_get_capture_capabilities(dpy, &capabilities);
+ ASSERT_TRUE(ret == TDM_ERROR_NONE || ret == TDM_ERROR_NO_CAPABILITY);
+
+ if (ret == TDM_ERROR_NONE)
+ ASSERT_NE(capabilities, (tdm_capture_capability)TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMDisplay, DisplayGetCaptureCapabilitiesNullObject)
+{
+ tdm_capture_capability capabilities = (tdm_capture_capability)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_display_get_capture_capabilities(NULL, &capabilities), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(capabilities, (tdm_capture_capability)TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMDisplay, DisplayGetCaptureCapabilitiesNullOther)
+{
+ ASSERT_EQ(tdm_display_get_capture_capabilities(dpy, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMDisplay, DisplayGetMaxLayerCount)
+{
+ int max_count = TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_display_get_max_layer_count(dpy, &max_count), TDM_ERROR_NONE);
+ ASSERT_NE(max_count, TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMDisplay, DisplayGetMaxLayerCountNullObject)
+{
+ int max_count = TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_display_get_max_layer_count(NULL, &max_count), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(max_count, TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMDisplay, DisplayGetMaxLayerCountNullOther)
+{
+ ASSERT_EQ(tdm_display_get_max_layer_count(dpy, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMDisplay, DisplayGetOutputCount)
+{
+ int count = TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_display_get_output_count(dpy, &count), TDM_ERROR_NONE);
+ ASSERT_NE(count, TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMDisplay, DisplayGetOutputCountNullObject)
+{
+ int count = TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_display_get_output_count(NULL, &count), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(count, TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMDisplay, DisplayGetOutputCountNullOther)
+{
+ ASSERT_EQ(tdm_display_get_output_count(dpy, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMDisplay, DisplayGetOutput)
+{
+ tdm_output *output;
+ int o, count = TDM_UT_INVALID_VALUE;
+ tdm_error ret;
+
+ ASSERT_EQ(tdm_display_get_output_count(dpy, &count), TDM_ERROR_NONE);
+ ASSERT_GT(count, 0);
+
+ for (o = 0; o < count; o++) {
+ output = tdm_display_get_output(dpy, o, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(output, NULL);
+ }
+}
+
+TEST_P(TDMDisplay, DisplayGetOutputNullAll)
+{
+ tdm_output *output;
+ int o, count = TDM_UT_INVALID_VALUE;
+
+ ASSERT_EQ(tdm_display_get_output_count(dpy, &count), TDM_ERROR_NONE);
+ ASSERT_GT(count, 0);
+
+ for (o = 0; o < count; o++) {
+ output = tdm_display_get_output(NULL, o, NULL);
+ ASSERT_EQ(output, NULL);
+ }
+}
+
+TEST_P(TDMDisplay, DisplayGetOutputNullObject)
+{
+ tdm_output *output;
+ tdm_error ret;
+
+ output = tdm_display_get_output(NULL, 0, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(output, NULL);
+}
+
+TEST_P(TDMDisplay, DisplayGetOutputNullOther)
+{
+ tdm_output *output;
+ int o, count = TDM_UT_INVALID_VALUE;
+
+ ASSERT_EQ(tdm_display_get_output_count(dpy, &count), TDM_ERROR_NONE);
+ ASSERT_GT(count, 0);
+
+ for (o = 0; o < count; o++) {
+ output = tdm_display_get_output(dpy, o, NULL);
+ ASSERT_NE(output, NULL);
+ }
+}
+
+TEST_P(TDMDisplay, DisplayGetOutputWrongIndex)
+{
+ tdm_output *output;
+ tdm_error ret;
+
+ output = tdm_display_get_output(dpy, -1, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_EQ(output, NULL);
+
+ output = tdm_display_get_output(dpy, INT_MAX, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_EQ(output, NULL);
+}
+
+TEST_P(TDMDisplay, DisplayFindOutput)
+{
+ tdm_output *output;
+ int count = TDM_UT_INVALID_VALUE;
+ tdm_error ret;
+
+ ASSERT_EQ(tdm_display_get_output_count(dpy, &count), TDM_ERROR_NONE);
+ ASSERT_GT(count, 0);
+
+ output = tdm_display_find_output(dpy, "primary", &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(output, NULL);
+
+ output = tdm_display_find_output(dpy, "invalid", &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_EQ(output, NULL);
+}
+
+TEST_P(TDMDisplay, DisplayCreatePp)
+{
+ tdm_pp *pp;
+ tdm_error ret;
+
+ if (!has_pp_cap)
+ return;
+
+ pp = tdm_display_create_pp(dpy, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(pp, NULL);
+
+ tdm_pp_destroy(pp);
+}
+
+TEST_P(TDMDisplay, DisplayCreatePpNullObject)
+{
+ tdm_pp *pp;
+ tdm_error ret;
+
+ if (!has_pp_cap)
+ return;
+
+ pp = tdm_display_create_pp(NULL, &ret);
+ ASSERT_NE(ret, TDM_ERROR_NONE);
+ ASSERT_EQ(pp, NULL);
+}
+
+TEST_P(TDMDisplay, ModuleGetInfo)
+{
+ tdm_output *output;
+ int o, count = TDM_UT_INVALID_VALUE;
+ tdm_error ret;
+
+ ASSERT_EQ(tdm_display_get_output_count(dpy, &count), TDM_ERROR_NONE);
+ ASSERT_GT(count, 0);
+
+ for (o = 0; o < count; o++) {
+ tdm_module *module;
+ const char *name = (const char *)TDM_UT_INVALID_VALUE;
+ const char *vendor = (const char *)TDM_UT_INVALID_VALUE;
+ int major = TDM_UT_INVALID_VALUE;
+ int minor = TDM_UT_INVALID_VALUE;
+
+ output = tdm_display_get_output(dpy, o, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(output, NULL);
+
+ module = tdm_output_get_backend_module(output, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(module, NULL);
+
+ ASSERT_EQ(tdm_module_get_info(module, &name, &vendor, &major, &minor), TDM_ERROR_NONE);
+ ASSERT_NE(name, (const char *)TDM_UT_INVALID_VALUE);
+ ASSERT_NE(vendor, (const char *)TDM_UT_INVALID_VALUE);
+ ASSERT_NE(major, TDM_UT_INVALID_VALUE);
+ ASSERT_NE(minor, TDM_UT_INVALID_VALUE);
+ }
+}
+
+TEST_P(TDMDisplay, ModuleGetInfoNullObject)
+{
+ const char *name = (const char *)TDM_UT_INVALID_VALUE;
+ const char *vendor = (const char *)TDM_UT_INVALID_VALUE;
+ int major = TDM_UT_INVALID_VALUE;
+ int minor = TDM_UT_INVALID_VALUE;
+
+ ASSERT_EQ(tdm_module_get_info(NULL, &name, &vendor, &major, &minor), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(name, (const char *)TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(vendor, (const char *)TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(major, TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(minor, TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMDisplay, ModuleGetInfoNullOther)
+{
+ tdm_output *output;
+ int o, count = TDM_UT_INVALID_VALUE;
+ tdm_error ret;
+
+ ASSERT_EQ(tdm_display_get_output_count(dpy, &count), TDM_ERROR_NONE);
+ ASSERT_GT(count, 0);
+
+ for (o = 0; o < count; o++) {
+ tdm_module *module;
+
+ output = tdm_display_get_output(dpy, o, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(output, NULL);
+
+ module = tdm_output_get_backend_module(output, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(module, NULL);
+
+ ASSERT_EQ(tdm_module_get_info(module, NULL, NULL, NULL, NULL), TDM_ERROR_NONE);
+ }
+}
+
+#ifdef TDM_UT_TEST_WITH_PARAMS
+INSTANTIATE_TEST_CASE_P(TDMDisplayParams,
+ TDMDisplay,
+ Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
+#else
+INSTANTIATE_TEST_CASE_P(TDMDisplayParams,
+ TDMDisplay,
+ Values(TDM_DEFAULT_MODULE));
+#endif
+
+/* LCOV_EXCL_END */
\ No newline at end of file
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
+ * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
+ * Contact: Roman Marchenko <r.marchenko@samsung.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+**************************************************************************/
+
+#include "tc_tdm.h"
+
+/* LCOV_EXCL_START */
+
+void TDMEnv::SetUp(void)
+{
+ const char *test_backend;
+ int thread = 1;
+
+ TDM_UT_ENTRY();
+
+ setenv("XDG_RUNTIME_DIR", "/run", 1);
+ setenv("TBM_DISPLAY_SERVER", "1", 1);
+
+#ifdef TDM_UT_TEST_WITH_PARAMS
+ /* commit_per_vblank depends on backend. can't choose it in frontend side.
+ * this is only for testing.
+ */
+ int commit_per_vblank = ::testing::get<0>(GetParam());
+ tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_COMMIT_PER_VBLANK, commit_per_vblank);
+
+ thread = ::testing::get<1>(GetParam());
+ test_backend = ::testing::get<2>(GetParam());
+#else
+ test_backend = ::testing::get<0>(GetParam());
+#endif
+
+ tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_THREAD, thread);
+
+ if (!test_backend)
+ test_backend = TDM_DEFAULT_MODULE;
+ tdm_config_set_string(TDM_CONFIG_KEY_GENERAL_BACKENDS, test_backend);
+
+ const char *debug = getenv("TDM_UT_DEBUG_MODULE");
+ if (debug && strstr(debug, "1"))
+ tdm_config_set_string(TDM_CONFIG_KEY_DEBUG_MODULE, "buffer,vblank,commit,pp,capture");
+
+ debug = getenv("TDM_UT_DEBUG_DUMP");
+ if (debug && (debug[0] == '1'))
+ tdm_config_set_string(TDM_CONFIG_KEY_DEBUG_DUMP, "all");
+}
+
+void TDMEnv::TearDown(void)
+{
+ unsetenv("XDG_RUNTIME_DIR");
+ unsetenv("TBM_DISPLAY_SERVER");
+}
+
+TEST_P(TDMEnv, DisplayInitDeinit)
+{
+ tdm_display *dpy;
+ tdm_error ret;
+
+ dpy = tdm_display_init(&ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(dpy, NULL);
+
+ tdm_display_deinit(dpy);
+}
+
+TEST_P(TDMEnv, DisplayInitDeinitWithoutEnv)
+{
+ tdm_display *dpy;
+ tdm_error ret;
+
+ TDMEnv::TearDown();
+
+ dpy = tdm_display_init(&ret);
+ ASSERT_EQ(ret, TDM_ERROR_OPERATION_FAILED);
+ ASSERT_EQ(dpy, NULL);
+}
+
+TEST_P(TDMEnv, DisplayInitFewTimes)
+{
+ tdm_display *dpy[10];
+ int d;
+ tdm_error ret;
+
+ for (d = 0; d < 10; d++) {
+ dpy[d] = tdm_display_init(&ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(dpy[d], NULL);
+ }
+
+ for (d = 0; d < 9; d++)
+ ASSERT_EQ(dpy[d], dpy[d + 1]);
+
+ for (d = 0; d < 10; d++)
+ tdm_display_deinit(dpy[d]);
+}
+
+TEST_P(TDMEnv, DisplayInitDeinitWithTBM)
+{
+ tdm_display *dpy;
+ tbm_bufmgr bufmgr;
+ tdm_error ret;
+
+ bufmgr = tbm_bufmgr_init(-1);
+ ASSERT_NE(bufmgr, NULL);
+
+ dpy = tdm_display_init(&ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(dpy, NULL);
+
+ tdm_display_deinit(dpy);
+ tbm_bufmgr_deinit(bufmgr);
+}
+
+TEST_P(TDMEnv, DisplayInitDeinitWithoutBackends)
+{
+}
+
+TEST_P(TDMEnv, DisplayDeinitWithNULL)
+{
+ tdm_display_deinit(NULL);
+}
+
+#ifdef TDM_UT_TEST_WITH_PARAMS
+INSTANTIATE_TEST_CASE_P(TDMEnvParams,
+ TDMEnv,
+ Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
+#else
+INSTANTIATE_TEST_CASE_P(TDMEnvParams,
+ TDMEnv,
+ Values(TDM_DEFAULT_MODULE));
+#endif
+
+/* LCOV_EXCL_END */
\ No newline at end of file
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
+ * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
+ * Contact: Roman Marchenko <r.marchenko@samsung.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+**************************************************************************/
+
+#include "tc_tdm.h"
+
+/* LCOV_EXCL_START */
+
+class TDMEventLoop : public TDMDisplay
+{
+public:
+ TDMEventLoop();
+ void SetUp(void);
+ void TearDown(void);
+};
+
+TDMEventLoop::TDMEventLoop()
+{
+}
+
+void TDMEventLoop::SetUp(void)
+{
+ TDMDisplay::SetUp();
+ tdm_display_lock(dpy);
+}
+
+void TDMEventLoop::TearDown(void)
+{
+ tdm_display_unlock(dpy);
+ TDMDisplay::TearDown();
+}
+
+static tdm_error
+_tc_tdm_event_loop_fd_cb(int fd, tdm_event_loop_mask mask, void *user_data)
+{
+ bool *done = (bool*)user_data;
+ if (done)
+ *done = true;
+ return TDM_ERROR_NONE;
+}
+
+TEST_P(TDMEventLoop, EventLoopAddFdHandler)
+{
+ tdm_error ret;
+ int pipes[2]; /* 0: read, 1: write */
+ tdm_event_loop_source *source;
+ bool done;
+ int len;
+
+ ASSERT_EQ(pipe(pipes), 0);
+
+ done = false;
+ source = tdm_event_loop_add_fd_handler(dpy, pipes[0], TDM_EVENT_LOOP_READABLE,
+ _tc_tdm_event_loop_fd_cb, &done, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(source, NULL);
+
+ len = write(pipes[1], "hello", 5);
+ ASSERT_EQ(len, 5);
+
+//TODO
+// while (!done)
+// ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+
+ tdm_event_loop_source_remove(source);
+
+ close(pipes[0]);
+ close(pipes[1]);
+}
+
+TEST_P(TDMEventLoop, EventLoopAddFdHandlerNullObject)
+{
+ tdm_error ret;
+ tdm_event_loop_source *source;
+ source = tdm_event_loop_add_fd_handler(NULL, 0, TDM_EVENT_LOOP_READABLE,
+ _tc_tdm_event_loop_fd_cb, NULL, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(source, NULL);
+}
+
+TEST_P(TDMEventLoop, EventLoopAddFdHandlerNullOther)
+{
+ tdm_error ret;
+ tdm_event_loop_source *source;
+ source = tdm_event_loop_add_fd_handler(NULL, -1, TDM_EVENT_LOOP_READABLE, NULL, NULL, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(source, NULL);
+}
+
+TEST_P(TDMEventLoop, EventLoopSourceFdUpdate)
+{
+ tdm_error ret;
+ int pipes[2]; /* 0: read, 1: write */
+ tdm_event_loop_source *source;
+ bool done;
+ int len;
+
+ ASSERT_EQ(pipe(pipes), 0);
+
+ done = false;
+ source = tdm_event_loop_add_fd_handler(dpy, pipes[0], TDM_EVENT_LOOP_WRITABLE,
+ _tc_tdm_event_loop_fd_cb, &done, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(source, NULL);
+
+ ASSERT_EQ(tdm_event_loop_source_fd_update(source, TDM_EVENT_LOOP_READABLE), TDM_ERROR_NONE);
+
+ len = write(pipes[1], "hello", 5);
+ ASSERT_EQ(len, 5);
+
+//TODO
+// while (!done)
+// ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+
+ tdm_event_loop_source_remove(source);
+
+ close(pipes[0]);
+ close(pipes[1]);
+}
+
+TEST_P(TDMEventLoop, EventLoopSourceFdUpdateNullObject)
+{
+ ASSERT_EQ(tdm_event_loop_source_fd_update(NULL, TDM_EVENT_LOOP_READABLE), TDM_ERROR_INVALID_PARAMETER);
+}
+
+static tdm_error
+_tc_tdm_event_loop_timer_cb(void *user_data)
+{
+ bool *done = (bool*)user_data;
+ if (done)
+ *done = true;
+ return TDM_ERROR_NONE;
+}
+
+TEST_P(TDMEventLoop, EventLoopAddTimerHandler)
+{
+ tdm_error ret;
+ tdm_event_loop_source *source;
+ source = tdm_event_loop_add_timer_handler(dpy, _tc_tdm_event_loop_timer_cb, NULL, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(source, NULL);
+ tdm_event_loop_source_remove(source);
+}
+
+TEST_P(TDMEventLoop, EventLoopAddTimerHandlerNullObject)
+{
+ tdm_error ret;
+ tdm_event_loop_source *source;
+ source = tdm_event_loop_add_timer_handler(NULL, _tc_tdm_event_loop_timer_cb, NULL, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(source, NULL);
+}
+
+
+TEST_P(TDMEventLoop, EventLoopAddTimerHandlerNullOther)
+{
+ tdm_error ret;
+ tdm_event_loop_source *source;
+ source = tdm_event_loop_add_timer_handler(dpy, NULL, NULL, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(source, NULL);
+}
+
+TEST_P(TDMEventLoop, EventLoopSourceTimerUpdate)
+{
+ tdm_error ret;
+ tdm_event_loop_source *source;
+ source = tdm_event_loop_add_timer_handler(dpy, _tc_tdm_event_loop_timer_cb, NULL, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(source, NULL);
+ ASSERT_EQ(tdm_event_loop_source_timer_update(source, 100), TDM_ERROR_NONE);
+//TODO
+// while (!done)
+// ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ tdm_event_loop_source_remove(source);
+}
+
+TEST_P(TDMEventLoop, EventLoopSourceTimerUpdateNullObject)
+{
+ ASSERT_EQ(tdm_event_loop_source_timer_update(NULL, 100), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMEventLoop, EventLoopSourceRemoveNullObject)
+{
+ tdm_event_loop_source_remove(NULL);
+}
+
+#ifdef TDM_UT_TEST_WITH_PARAMS
+INSTANTIATE_TEST_CASE_P(TDMEventLoopParams,
+ TDMEventLoop,
+ Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
+#else
+INSTANTIATE_TEST_CASE_P(TDMEventLoopParams,
+ TDMEventLoop,
+ Values(TDM_DEFAULT_MODULE));
+#endif
+
+/* LCOV_EXCL_END */
\ No newline at end of file
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
+ * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
+ * Contact: Roman Marchenko <r.marchenko@samsung.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+**************************************************************************/
+
+#include "tc_tdm.h"
+
+/* LCOV_EXCL_START */
+
+class TDMHelper : public TDMOutput
+{
+public:
+ TDMHelper();
+ void SetUp(void);
+ void TearDown(void);
+};
+
+TDMHelper::TDMHelper()
+{
+}
+
+void TDMHelper::SetUp(void)
+{
+ TDMOutput::SetUp();
+}
+
+void TDMHelper::TearDown(void)
+{
+ TDMOutput::TearDown();
+}
+
+TEST_P(TDMHelper, HelperGetTime)
+{
+ ASSERT_GT(tdm_helper_get_time(), 0.0);
+}
+
+TEST_P(TDMHelper, HelperDumpBufferXR24)
+{
+ tbm_surface_h buffer;
+
+ buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_XRGB8888);
+ ASSERT_NE(buffer, NULL);
+
+ tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
+
+ char filename[256];
+ snprintf(filename, sizeof filename, "%s.png", typeid(*this).name());
+ tdm_helper_dump_buffer(buffer, (const char*)filename);
+
+ tbm_surface_destroy(buffer);
+}
+
+TEST_P(TDMHelper, HelperDumpBufferAR24)
+{
+ tbm_surface_h buffer;
+
+ buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_ARGB8888);
+ ASSERT_NE(buffer, NULL);
+
+ tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
+
+ char filename[256];
+ snprintf(filename, sizeof filename, "%s.png", typeid(*this).name());
+ tdm_helper_dump_buffer(buffer, (const char*)filename);
+
+ tbm_surface_destroy(buffer);
+}
+
+TEST_P(TDMHelper, HelperDumpBufferNullObject)
+{
+ char filename[256];
+ tdm_helper_dump_buffer(NULL, (const char*)filename);
+}
+
+TEST_P(TDMHelper, HelperDumpBufferNullOther)
+{
+ tbm_surface_h buffer = (tbm_surface_h)TDM_UT_INVALID_VALUE;
+ tdm_helper_dump_buffer(buffer, NULL);
+}
+
+TEST_P(TDMHelper, HelperClearBufferPos)
+{
+ tbm_surface_h buffer;
+ tdm_pos pos = {.x = 40, .y = 40, .w = TDM_UT_BUFFER_SIZE - 80, .h = TDM_UT_BUFFER_SIZE - 80};
+
+ buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_ARGB8888);
+ ASSERT_NE(buffer, NULL);
+
+ tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
+
+ tdm_helper_clear_buffer_pos(buffer, &pos);
+
+ tdm_helper_dump_buffer_str(buffer, NULL, (char*)typeid(*this).name());
+
+ tbm_surface_destroy(buffer);
+}
+
+TEST_P(TDMHelper, HelperClearBufferColor)
+{
+ tbm_surface_h buffer;
+ tdm_pos pos = {.x = 40, .y = 40, .w = TDM_UT_BUFFER_SIZE - 80, .h = TDM_UT_BUFFER_SIZE - 80};
+ unsigned int color = 0xffffff00;
+
+ buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_ARGB8888);
+ ASSERT_NE(buffer, NULL);
+
+ tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
+
+ tdm_helper_clear_buffer_color(buffer, &pos, color);
+
+ tdm_helper_dump_buffer_str(buffer, NULL, (char*)typeid(*this).name());
+
+ tbm_surface_destroy(buffer);
+}
+
+TEST_P(TDMHelper, HelperClearBufferARGB)
+{
+ tbm_surface_h buffer;
+
+ buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_ARGB8888);
+ ASSERT_NE(buffer, NULL);
+
+ tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
+
+ tdm_helper_clear_buffer(buffer);
+
+ tdm_helper_dump_buffer_str(buffer, NULL, (char*)typeid(*this).name());
+
+ tbm_surface_destroy(buffer);
+}
+
+TEST_P(TDMHelper, HelperClearBufferXRGB)
+{
+ tbm_surface_h buffer;
+
+ buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_XRGB8888);
+ ASSERT_NE(buffer, NULL);
+
+ tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
+
+ tdm_helper_clear_buffer(buffer);
+
+ tdm_helper_dump_buffer_str(buffer, NULL, (char*)typeid(*this).name());
+
+ tbm_surface_destroy(buffer);
+}
+
+TEST_P(TDMHelper, HelperClearBufferYUV420)
+{
+ tbm_surface_h buffer;
+
+ buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_YUV420);
+ ASSERT_NE(buffer, NULL);
+
+ tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
+
+ tdm_helper_clear_buffer(buffer);
+
+ tdm_helper_dump_buffer_str(buffer, NULL, (char*)typeid(*this).name());
+
+ tbm_surface_destroy(buffer);
+}
+
+TEST_P(TDMHelper, HelperClearBufferNV12)
+{
+ tbm_surface_h buffer;
+
+ buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_NV12);
+ ASSERT_NE(buffer, NULL);
+
+ tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
+
+ tdm_helper_clear_buffer(buffer);
+
+ tdm_helper_dump_buffer_str(buffer, NULL, (char*)typeid(*this).name());
+
+ tbm_surface_destroy(buffer);
+}
+
+TEST_P(TDMHelper, HelperClearBufferNV21)
+{
+ tbm_surface_h buffer;
+
+ buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_NV21);
+ ASSERT_NE(buffer, NULL);
+
+ tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
+
+ tdm_helper_clear_buffer(buffer);
+
+ tdm_helper_dump_buffer_str(buffer, NULL, (char*)typeid(*this).name());
+
+ tbm_surface_destroy(buffer);
+}
+
+TEST_P(TDMHelper, HelperGetBufferFullSize)
+{
+ tbm_surface_h buffer;
+ int w = TDM_UT_INVALID_VALUE, h = TDM_UT_INVALID_VALUE;
+
+ buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_ARGB8888);
+ ASSERT_NE(buffer, NULL);
+
+ tdm_helper_get_buffer_full_size(buffer, &w, &h);
+ ASSERT_NE(w, TDM_UT_INVALID_VALUE);
+ ASSERT_GE(w, tbm_surface_get_width(buffer));
+ ASSERT_NE(h, TDM_UT_INVALID_VALUE);
+ ASSERT_GE(h, tbm_surface_get_height(buffer));
+
+ tbm_surface_destroy(buffer);
+}
+
+TEST_P(TDMHelper, HelperConvertBufferRotate0)
+{
+ tbm_surface_h buffer, temp;
+ tdm_pos sp, dp;
+
+ buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_ARGB8888);
+ ASSERT_NE(buffer, NULL);
+ tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
+
+ temp = tbm_surface_create(TDM_UT_BUFFER_SIZE * 2, TDM_UT_BUFFER_SIZE * 2, TBM_FORMAT_ARGB8888);
+ ASSERT_NE(temp, NULL);
+
+ sp.x = sp.y = 0, sp.w = sp.h = TDM_UT_BUFFER_SIZE;
+ dp.x = dp.y = 0, dp.w = dp.h = TDM_UT_BUFFER_SIZE * 2;
+
+ ASSERT_EQ(tdm_helper_convert_buffer(buffer, temp, &sp, &dp, TDM_TRANSFORM_NORMAL, 0), TDM_ERROR_NONE);
+
+ tdm_helper_dump_buffer_str(temp, NULL, (char*)typeid(*this).name());
+
+ tbm_surface_destroy(buffer);
+ tbm_surface_destroy(temp);
+}
+
+TEST_P(TDMHelper, HelperConvertBufferRotate0Flip)
+{
+ tbm_surface_h buffer, temp;
+ tdm_pos sp, dp;
+
+ buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_ARGB8888);
+ ASSERT_NE(buffer, NULL);
+ tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
+
+ temp = tbm_surface_create(TDM_UT_BUFFER_SIZE * 2, TDM_UT_BUFFER_SIZE * 2, TBM_FORMAT_ARGB8888);
+ ASSERT_NE(temp, NULL);
+
+ sp.x = sp.y = 0, sp.w = sp.h = TDM_UT_BUFFER_SIZE;
+ dp.x = dp.y = 0, dp.w = dp.h = TDM_UT_BUFFER_SIZE * 2;
+
+ ASSERT_EQ(tdm_helper_convert_buffer(buffer, temp, &sp, &dp, TDM_TRANSFORM_FLIPPED, 0), TDM_ERROR_NONE);
+
+ tdm_helper_dump_buffer_str(temp, NULL, (char*)typeid(*this).name());
+
+ tbm_surface_destroy(buffer);
+ tbm_surface_destroy(temp);
+}
+
+TEST_P(TDMHelper, HelperConvertBufferRotate90)
+{
+ tbm_surface_h buffer, temp;
+ tdm_pos sp, dp;
+
+ buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_ARGB8888);
+ ASSERT_NE(buffer, NULL);
+ tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
+
+ temp = tbm_surface_create(TDM_UT_BUFFER_SIZE * 2, TDM_UT_BUFFER_SIZE * 2, TBM_FORMAT_ARGB8888);
+ ASSERT_NE(temp, NULL);
+
+ sp.x = sp.y = 0, sp.w = sp.h = TDM_UT_BUFFER_SIZE;
+ dp.x = dp.y = 0, dp.w = dp.h = TDM_UT_BUFFER_SIZE * 2;
+
+ ASSERT_EQ(tdm_helper_convert_buffer(buffer, temp, &sp, &dp, TDM_TRANSFORM_90, 0), TDM_ERROR_NONE);
+
+ tdm_helper_dump_buffer_str(temp, NULL, (char*)typeid(*this).name());
+
+ tbm_surface_destroy(buffer);
+ tbm_surface_destroy(temp);
+}
+
+TEST_P(TDMHelper, HelperConvertBufferRotate180)
+{
+ tbm_surface_h buffer, temp;
+ tdm_pos sp, dp;
+
+ buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_ARGB8888);
+ ASSERT_NE(buffer, NULL);
+ tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
+
+ temp = tbm_surface_create(TDM_UT_BUFFER_SIZE * 2, TDM_UT_BUFFER_SIZE * 2, TBM_FORMAT_ARGB8888);
+ ASSERT_NE(temp, NULL);
+
+ sp.x = sp.y = 0, sp.w = sp.h = TDM_UT_BUFFER_SIZE;
+ dp.x = dp.y = 0, dp.w = dp.h = TDM_UT_BUFFER_SIZE * 2;
+
+ ASSERT_EQ(tdm_helper_convert_buffer(buffer, temp, &sp, &dp, TDM_TRANSFORM_180, 0), TDM_ERROR_NONE);
+
+ tdm_helper_dump_buffer_str(temp, NULL, (char*)typeid(*this).name());
+
+ tbm_surface_destroy(buffer);
+ tbm_surface_destroy(temp);
+}
+
+TEST_P(TDMHelper, HelperConvertBufferRotate270)
+{
+ tbm_surface_h buffer, temp;
+ tdm_pos sp, dp;
+
+ buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_ARGB8888);
+ ASSERT_NE(buffer, NULL);
+ tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
+
+ temp = tbm_surface_create(TDM_UT_BUFFER_SIZE * 2, TDM_UT_BUFFER_SIZE * 2, TBM_FORMAT_ARGB8888);
+ ASSERT_NE(temp, NULL);
+
+ sp.x = sp.y = 0, sp.w = sp.h = TDM_UT_BUFFER_SIZE;
+ dp.x = dp.y = 0, dp.w = dp.h = TDM_UT_BUFFER_SIZE * 2;
+
+ ASSERT_EQ(tdm_helper_convert_buffer(buffer, temp, &sp, &dp, TDM_TRANSFORM_270, 0), TDM_ERROR_NONE);
+
+ tdm_helper_dump_buffer_str(temp, NULL, (char*)typeid(*this).name());
+
+ tbm_surface_destroy(buffer);
+ tbm_surface_destroy(temp);
+}
+
+TEST_P(TDMHelper, HelperConvertBufferYUV420)
+{
+ tbm_surface_h buffer, temp;
+ tdm_pos sp, dp;
+
+ buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_YUV420);
+ ASSERT_NE(buffer, NULL);
+ tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
+
+ temp = tbm_surface_create(TDM_UT_BUFFER_SIZE * 2, TDM_UT_BUFFER_SIZE * 2, TBM_FORMAT_YUV420);
+ ASSERT_NE(temp, NULL);
+
+ sp.x = sp.y = 0, sp.w = sp.h = TDM_UT_BUFFER_SIZE;
+ dp.x = dp.y = 0, dp.w = dp.h = TDM_UT_BUFFER_SIZE * 2;
+
+ ASSERT_EQ(tdm_helper_convert_buffer(buffer, temp, &sp, &dp, TDM_TRANSFORM_NORMAL, 0), TDM_ERROR_OPERATION_FAILED);
+
+ tbm_surface_destroy(buffer);
+ tbm_surface_destroy(temp);
+}
+
+TEST_P(TDMHelper, HelperGetFD)
+{
+ int fd = tdm_helper_get_fd("TDM_DRM_MASTER_FD");
+ ASSERT_GE(fd, 0);
+ close(fd);
+ fd = tdm_helper_get_fd("BLURBLUR");
+ ASSERT_EQ(fd, -1);
+}
+
+TEST_P(TDMHelper, HelperSetFD)
+{
+ tdm_helper_set_fd("TDM_DRM_MASTER_FD", -1);
+ tdm_helper_set_fd("BLURBLUR", -1);
+}
+
+TEST_P(TDMHelper, HelperDumpStart)
+{
+ char path[256];
+ int count = 0;
+ snprintf(path, sizeof path, "blurblur");
+ tdm_helper_dump_start(path, &count);
+ tdm_helper_dump_stop();
+}
+
+static void
+_tc_tdm_helper_capture_cb(tbm_surface_h buffer, void *user_data)
+{
+}
+
+TEST_P(TDMHelper, HelperCaptureOutput)
+{
+ tdm_error ret;
+ tdm_output *output;
+
+ for (int o = 0; o < output_count; o++) {
+ tbm_surface_h dump;
+
+ output = tdm_display_get_output(dpy, o, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(output, NULL);
+
+ if (!tc_tdm_output_is_connected(output))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_prepare(dpy, output, true), true);
+
+ dump = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_ARGB8888);
+ ASSERT_NE(dump, NULL);
+
+ ASSERT_EQ(tdm_helper_capture_output(output, dump, 0, 0, TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE,
+ _tc_tdm_helper_capture_cb, NULL), TDM_ERROR_NONE);
+
+ tdm_helper_dump_buffer_str(dump, NULL, (char*)typeid(*this).name());
+
+ tbm_surface_destroy(dump);
+ }
+}
+
+
+TEST_P(TDMHelper, HelperCaptureOutputNullObject)
+{
+ tbm_surface_h dump = (tbm_surface_h)TDM_UT_INVALID_VALUE;
+
+ ASSERT_EQ(tdm_helper_capture_output(NULL, dump, 0, 0, TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE,
+ _tc_tdm_helper_capture_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMHelper, HelperCaptureOutputNullOther)
+{
+ for (int o = 0; o < output_count; o++) {
+ tdm_error ret;
+ tdm_output *output = tdm_display_get_output(dpy, o, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(output, NULL);
+ tdm_helper_output_commit_per_vblank_enabled(output);
+ }
+
+ tbm_surface_h dump = (tbm_surface_h)TDM_UT_INVALID_VALUE;
+
+ ASSERT_EQ(tdm_helper_capture_output(NULL, dump, 0, 0, TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE,
+ _tc_tdm_helper_capture_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMHelper, HelperGetDisplayInformation)
+{
+ char reply[8192];
+ int len = sizeof reply;
+
+ for (int o = 0; o < output_count; o++) {
+ tdm_error ret;
+ tdm_output *output = tdm_display_get_output(dpy, o, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(output, NULL);
+ if (!tc_tdm_output_is_connected(output))
+ continue;
+ ASSERT_EQ(tc_tdm_output_prepare(dpy, output, true), true);
+ }
+
+ tdm_helper_get_display_information(dpy, reply, &len);
+ TDM_INFO("%s", reply);
+}
+
+TEST_P(TDMHelper, HelperGetDisplayInformationNullObject)
+{
+ char reply[8192];
+ int len = sizeof reply;
+
+ tdm_helper_get_display_information(NULL, reply, &len);
+}
+
+TEST_P(TDMHelper, HelperGetDisplayInformationNullOther)
+{
+ tdm_helper_get_display_information(dpy, NULL, NULL);
+}
+
+TEST_P(TDMHelper, HelperCommitPerVblankEnabled)
+{
+ ASSERT_EQ(tdm_helper_commit_per_vblank_enabled(dpy), 0);
+}
+
+TEST_P(TDMHelper, HelperCommitPerVblankEnabledNullOBject)
+{
+ ASSERT_EQ(tdm_helper_commit_per_vblank_enabled(NULL), 0);
+}
+
+TEST_P(TDMHelper, HelperOutputCommitPerVblankEnabledNullObject)
+{
+ ASSERT_EQ(tdm_helper_output_commit_per_vblank_enabled(NULL), -1);
+}
+
+#ifdef TDM_UT_TEST_WITH_PARAMS
+INSTANTIATE_TEST_CASE_P(TDMHelperParams,
+ TDMHelper,
+ Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
+#else
+INSTANTIATE_TEST_CASE_P(TDMHelperParams,
+ TDMHelper,
+ Values(TDM_DEFAULT_MODULE));
+#endif
+
+/* LCOV_EXCL_END */
\ No newline at end of file
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
+ * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
+ * Contact: Roman Marchenko <r.marchenko@samsung.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+**************************************************************************/
+
+#include "tc_tdm.h"
+
+/* LCOV_EXCL_START */
+
+#define HWC_WIN_NUM 5
+
+class TDMHwcWindow : public TDMOutput
+{
+public:
+ TDMHwcWindow();
+ void SetUp(void);
+ void TearDown(void);
+
+ tdm_error error;
+ tdm_hwc_window **hwc_wins;
+ int hwc_count;
+};
+
+TDMHwcWindow::TDMHwcWindow()
+{
+ error = TDM_ERROR_NONE;
+ hwc_wins = NULL;
+ hwc_count = 0;
+ video_hwc_win = NULL;
+}
+
+void TDMHwcWindow::SetUp(void)
+{
+ tdm_hwc_window *hw = NULL;
+
+ TDMOutput::SetUp();
+
+ hwc_wins = (tdm_hwc_window **)calloc(output_count * HWC_WIN_NUM, sizeof(tdm_hwc_window *));
+
+ //create HWC_WIN_NUM hwc_windows for each outputs
+ for (int o = 0; o < output_count; o++) {
+ if (tc_tdm_output_is_hwc_enable(outputs[o])) {
+ for (int w = 0; w < HWC_WIN_NUM; w++) {
+ hw = tdm_hwc_create_window(outputs[w], &error);
+ ASSERT_EQ(TDM_ERROR_NONE, error);
+ hwc_wins[hwc_count++] = hw;
+ }
+ }
+ }
+}
+
+void TDMHwcWindow::TearDown(void)
+{
+ for (int w = 0; w < hwc_count; w++)
+ tdm_hwc_window_destroy(hwc_wins[w]);
+
+ TDMOutput::TearDown();
+}
+
+/* void tdm_hwc_window_destroy(tdm_hwc_window *hwc_window); */
+/*
+TEST_P(TDMHwcWindow, DestroyWindowFailNull)
+{
+ tdm_hwc_window_destroy(NULL);
+}
+
+TEST_P(TDMHwcWindow, DestroyWindowSuccessful)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ tdm_hwc_window *hw = NULL;
+
+ for (int o = 0; o < output_count; o++) {
+ if (tc_tdm_output_is_hwc_enable(outputs[o])) {
+ hw = tdm_hwc_create_window(outputs[o], &error);
+ ASSERT_EQ(TDM_ERROR_NONE, error);
+ error = tdm_hwc_window_destroy(outputs[o], hw);
+ ASSERT_EQ(TDM_ERROR_NONE, error);
+ }
+ }
+}
+*/
+
+/* tbm_surface_queue_h tdm_hwc_window_get_buffer_queue(tdm_hwc_window *hwc_window, tdm_error *error); */
+TEST_P(TDMHwcWindow, GetBufferQueueFailNull)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ tbm_surface_queue_h queue = NULL;
+
+ queue = tdm_hwc_window_get_buffer_queue(NULL, &error);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+ ASSERT_EQ(NULL, queue);
+
+ queue = tdm_hwc_window_get_buffer_queue(NULL, NULL);
+ ASSERT_EQ(NULL, queue);
+}
+
+TEST_P(TDMHwcWindow, GetBufferQueueSuccessful)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ tbm_surface_queue_h queue = NULL;
+ tdm_hwc_window_info info = { 0 };
+
+ info.src_config.format = TBM_FORMAT_ARGB8888;
+ info.src_config.size.h = info.src_config.size.v = 256;
+ info.src_config.pos.h = info.src_config.pos.w = 256;
+ info.dst_pos.h = info.dst_pos.w = 256;
+ info.transform = TDM_TRANSFORM_NORMAL;
+
+ for (int w = 0; w < hwc_count; w++) {
+ error = tdm_hwc_window_set_info(hwc_wins[w], &info);
+ ASSERT_EQ(TDM_ERROR_NONE, error);
+
+ queue = tdm_hwc_window_get_buffer_queue(hwc_wins[w], &error);
+ tbm_surface_queue_destroy(queue);
+ ASSERT_EQ(TDM_ERROR_NONE, error);
+ ASSERT_NE(NULL, queue);
+
+ queue = tdm_hwc_window_get_buffer_queue(hwc_wins[w], NULL);
+ tbm_surface_queue_destroy(queue);
+ ASSERT_NE(NULL, queue);
+ }
+}
+
+/* tdm_error tdm_hwc_window_set_composition_type(tdm_hwc_window *hwc_window,
+ tdm_hwc_window_composition composition_type); */
+TEST_P(TDMHwcWindow, SetCompositionTypeFailNull)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ error = tdm_hwc_window_set_composition_type(NULL, TDM_COMPOSITION_DEVICE);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+}
+
+TEST_P(TDMHwcWindow, SetCompositionTypeSuccessful)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int w = 0; w < hwc_count; w++) {
+ error = tdm_hwc_window_set_composition_type(hwc_wins[w], TDM_COMPOSITION_DEVICE);
+ ASSERT_EQ(TDM_ERROR_NONE, error);
+ error = tdm_hwc_window_set_composition_type(hwc_wins[w], TDM_COMPOSITION_CLIENT);
+ ASSERT_EQ(TDM_ERROR_NONE, error);
+ error = tdm_hwc_window_set_composition_type(hwc_wins[w], TDM_COMPOSITION_CURSOR);
+ ASSERT_EQ(TDM_ERROR_NONE, error);
+ }
+}
+
+TEST_P(TDMHwcWindow, SetCompositionTypeFailInvalieCompositionType)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int w = 0; w < hwc_count; w++) {
+ error = tdm_hwc_window_set_composition_type(hwc_wins[w], tdm_hwc_window_composition(TDM_COMPOSITION_NONE - 1));
+ ASSERT_NE(TDM_ERROR_NONE, error);
+ }
+}
+
+/* tdm_error tdm_hwc_window_set_buffer_damage(tdm_hwc_window *hwc_window, tdm_region damage); */
+TEST_P(TDMHwcWindow, SetBufferDamageFailNullHwcWindow)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ tdm_region damage = {.num_rects = 0, .rects = NULL};
+
+ error = tdm_hwc_window_set_buffer_damage(NULL, damage);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+}
+
+TEST_P(TDMHwcWindow, SetBufferDamageFailNullDamageRects)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ tdm_region damage = {.num_rects = 1, .rects = NULL};
+
+ for (int w = 0; w < hwc_count; w++) {
+ error = tdm_hwc_window_set_buffer_damage(hwc_wins[w], damage);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+ }
+}
+
+
+TEST_P(TDMHwcWindow, SetBufferDamageSuccessful)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ tdm_pos const rects[1] = {0};
+ tdm_region damage = {.num_rects = 1, .rects = rects};
+
+ for (int w = 0; w < hwc_count; w++) {
+ error = tdm_hwc_window_set_buffer_damage(hwc_wins[w], damage);
+ ASSERT_EQ(TDM_ERROR_NONE, error);
+ }
+}
+
+
+/* tdm_error tdm_hwc_window_set_info(tdm_hwc_window *hwc_window, tdm_hwc_window_info *info); */
+TEST_P(TDMHwcWindow, SetInfoFailNull)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ tdm_hwc_window_info info = { 0 };
+
+ error = tdm_hwc_window_set_info(NULL, &info);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+
+ if (hwc_count > 0) {
+ error = tdm_hwc_window_set_info(hwc_wins[0], NULL);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+ }
+}
+
+TEST_P(TDMHwcWindow, SetInfoSuccessful)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ tdm_hwc_window_info info = { 0 };
+
+ for (int w = 0; w < hwc_count; w++) {
+ error = tdm_hwc_window_set_info(hwc_wins[w], &info);
+ ASSERT_EQ(TDM_ERROR_NONE, error);
+ }
+}
+
+
+/* tdm_error tdm_hwc_window_set_buffer(tdm_hwc_window *hwc_window, tbm_surface_h buffer); */
+TEST_P(TDMHwcWindow, SetBufferFailNull)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ error = tdm_hwc_window_set_buffer(NULL, NULL);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+}
+
+TEST_P(TDMHwcWindow, SetBufferSuccessful)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int w = 0; w < hwc_count; w++) {
+
+ tbm_surface_h buff = tbm_surface_create(256, 256, TBM_FORMAT_ARGB8888);
+
+ /* test: set*/
+ error = tdm_hwc_window_set_buffer(hwc_wins[w], buff);
+ tbm_surface_destroy(buff);
+ ASSERT_EQ(TDM_ERROR_NONE, error);
+
+ /* test: reset*/
+ error = tdm_hwc_window_set_buffer(hwc_wins[w], NULL);
+ ASSERT_EQ(TDM_ERROR_NONE, error);
+ }
+}
+
+/* tdm_hwc_get_available_properties() */
+/*
+TEST_P(TDMHwcWindow, GetAvailablePropertiesFailNullWin)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ TDM_UT_SKIP_FLAG(video_hwc_win != NULL);
+ const tdm_prop *props;
+ int count;
+
+ error = tdm_hwc_get_available_properties(NULL, &props, &count);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+
+ error = tdm_hwc_get_available_properties(video_hwc_win, NULL, &count);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+
+ error = tdm_hwc_get_available_properties(video_hwc_win, &props, NULL);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+}
+
+TEST_P(TDMHwcWindow, GetAvailablePropertiesSuccess)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ TDM_UT_SKIP_FLAG(video_hwc_win != NULL);
+
+ const tdm_prop *props;
+ int count;
+
+ error = tdm_hwc_get_available_properties(video_hwc_win, &props, &count);
+ ASSERT_TRUE(TDM_ERROR_NONE == error || TDM_ERROR_NOT_IMPLEMENTED == error);
+}
+*/
+
+/* tdm_hwc_window_get_property() */
+TEST_P(TDMHwcWindow, GetPropertyFailNull)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+ TDM_UT_SKIP_FLAG(video_hwc_win != NULL);
+
+ tdm_value value;
+ int id = 1;
+
+ error = tdm_hwc_window_get_property(NULL, id, &value);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+
+ error = tdm_hwc_window_get_property(video_hwc_win, id, NULL);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+}
+
+TEST_P(TDMHwcWindow, GetPropertyFailWrongId)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+ TDM_UT_SKIP_FLAG(video_hwc_win != NULL);
+
+ tdm_value value;
+ int id = INT_MAX;
+
+ error = tdm_hwc_window_get_property(video_hwc_win, id, &value);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+}
+
+/* tdm_hwc_window_set_property() */
+TEST_P(TDMHwcWindow, SetPropertyFailNull)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+ TDM_UT_SKIP_FLAG(video_hwc_win != NULL);
+
+ tdm_value value;
+ int id = 1;
+
+ error = tdm_hwc_window_set_property(NULL, id, value);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+}
+
+TEST_P(TDMHwcWindow, SetPropertyFailWrongId)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+ TDM_UT_SKIP_FLAG(video_hwc_win != NULL);
+
+ tdm_value value;
+ int id = INT_MAX;
+
+ error = tdm_hwc_window_set_property(video_hwc_win, id, value);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+}
+
+#ifdef TDM_UT_TEST_WITH_PARAMS
+INSTANTIATE_TEST_CASE_P(TDMHwcWindowParams,
+ TDMHwcWindow,
+ Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
+#else
+INSTANTIATE_TEST_CASE_P(TDMHwcWindowParams,
+ TDMHwcWindow,
+ Values(TDM_DEFAULT_MODULE));
+#endif
+
+/* LCOV_EXCL_END */
\ No newline at end of file
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
+ * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
+ * Contact: Roman Marchenko <r.marchenko@samsung.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+**************************************************************************/
+
+#include "tc_tdm.h"
+
+/* LCOV_EXCL_START */
+
+#define BORDER_SIZE 20
+
+class TDMLayer : public TDMOutput
+{
+public:
+ bool has_layers;
+ tdm_layer **layers;
+ int layer_count;
+
+ tbm_surface_h buffers[3];
+ tbm_surface_queue_h buffer_queue;
+
+ TDMLayer();
+ void SetUp(void);
+ void TearDown(void);
+
+ void DestroyBuffers(void);
+};
+
+TDMLayer::TDMLayer()
+{
+ has_layers = false;
+ layers = NULL;
+ layer_count = TDM_UT_INVALID_VALUE;
+
+ for (int b = 0; b < 3; b++)
+ buffers[b] = NULL;
+
+ buffer_queue = NULL;
+}
+
+void TDMLayer::SetUp(void)
+{
+ TDMOutput::SetUp();
+
+ layer_count = 0;
+
+ for (int o = 0; o < output_count; o++) {
+ int old_layer_count = layer_count, count = TDM_UT_INVALID_VALUE;
+ tdm_error ret;
+
+ if (tc_tdm_output_is_hwc_enable(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tdm_output_get_layer_count(outputs[o], &count), TDM_ERROR_NONE);
+ ASSERT_GT(count, 0);
+
+ layer_count += count;
+ layers = (tdm_layer**)realloc(layers, sizeof(tdm_layer*) * layer_count);
+ ASSERT_NE(layers, NULL);
+
+ for (int l = 0; l < count; l++) {
+ tdm_layer *layer = tdm_output_get_layer(outputs[o], l, &ret);
+ ASSERT_NE(layer, NULL);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ layers[old_layer_count + l] = layer;
+ }
+ }
+
+ if (layer_count > 0)
+ has_layers = true;
+}
+
+void TDMLayer::TearDown(void)
+{
+ for (int l = 0; l < layer_count; l++) {
+ ASSERT_EQ(tdm_layer_unset_buffer(layers[l]), TDM_ERROR_NONE);
+ }
+
+ free(layers);
+
+ DestroyBuffers();
+
+ TDMOutput::TearDown();
+}
+
+void TDMLayer::DestroyBuffers(void)
+{
+ for (int b = 0; b < 3; b++) {
+ if (buffers[b]) {
+ tbm_surface_destroy(buffers[b]);
+ buffers[b] = NULL;
+ }
+ }
+
+ if (buffer_queue) {
+ tbm_surface_queue_destroy(buffer_queue);
+ buffer_queue = NULL;
+ }
+}
+
+bool
+tc_tdm_layer_is_cursor_layer(tdm_layer *layer)
+{
+ tdm_layer_capability capabilities = (tdm_layer_capability)TDM_UT_INVALID_VALUE;
+ if (tdm_layer_get_capabilities(layer, &capabilities) != TDM_ERROR_NONE)
+ return false;
+ return capabilities & TDM_LAYER_CAPABILITY_CURSOR;
+}
+
+bool
+tc_tdm_layer_is_primary_layer(tdm_layer *layer)
+{
+ tdm_layer_capability capabilities = (tdm_layer_capability)TDM_UT_INVALID_VALUE;
+ if (tdm_layer_get_capabilities(layer, &capabilities) != TDM_ERROR_NONE)
+ return false;
+ return capabilities & TDM_LAYER_CAPABILITY_PRIMARY;
+}
+
+bool
+tc_tdm_layer_is_video_layer(tdm_layer *layer)
+{
+ tdm_layer_capability capabilities = (tdm_layer_capability)TDM_UT_INVALID_VALUE;
+ if (tdm_layer_get_capabilities(layer, &capabilities) != TDM_ERROR_NONE)
+ return false;
+ return capabilities & TDM_LAYER_CAPABILITY_VIDEO;
+}
+
+bool
+tc_tdm_layer_support_scale(tdm_layer *layer)
+{
+ tdm_layer_capability capabilities = (tdm_layer_capability)TDM_UT_INVALID_VALUE;
+ if (tdm_layer_get_capabilities(layer, &capabilities) != TDM_ERROR_NONE)
+ return false;
+ return capabilities & TDM_LAYER_CAPABILITY_SCALE;
+}
+
+bool
+tc_tdm_layer_support_no_crop(tdm_layer *layer)
+{
+ tdm_layer_capability capabilities = (tdm_layer_capability)TDM_UT_INVALID_VALUE;
+ if (tdm_layer_get_capabilities(layer, &capabilities) != TDM_ERROR_NONE)
+ return false;
+ return capabilities & TDM_LAYER_CAPABILITY_NO_CROP;
+}
+
+unsigned int
+tc_tdm_layer_get_output_pipe(tdm_layer *layer)
+{
+ unsigned int pipe = (unsigned int)TDM_UT_INVALID_VALUE;
+ tdm_error ret;
+ tdm_output *output = tdm_layer_get_output(layer, &ret);
+ TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(output != NULL);
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_pipe(output, &pipe) == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(pipe != (unsigned int)TDM_UT_INVALID_VALUE);
+
+ return pipe;
+}
+
+tbm_format
+tc_tdm_layer_find_best_format(tdm_layer *layer)
+{
+ const tbm_format *formats = (const tbm_format *)TDM_UT_INVALID_VALUE;
+ int count = TDM_UT_INVALID_VALUE;
+ tdm_error ret;
+ ret = tdm_layer_get_available_formats(layer, &formats, &count);
+ TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
+
+ for (int f = 0; f < count; f++)
+ if (formats[f] == TBM_FORMAT_ARGB8888)
+ return TBM_FORMAT_ARGB8888;
+ for (int f = 0; f < count; f++)
+ if (formats[f] == TBM_FORMAT_XRGB8888)
+ return TBM_FORMAT_XRGB8888;
+ for (int f = 0; f < count; f++)
+ if (formats[f] == TBM_FORMAT_YUV420)
+ return TBM_FORMAT_YUV420;
+ for (int f = 0; f < count; f++)
+ if (formats[f] == TBM_FORMAT_NV12)
+ return TBM_FORMAT_NV12;
+
+ return 0;
+}
+
+bool
+tc_tdm_layer_prepare_buffer(tdm_layer *layer, tbm_surface_h *buffers, int buffer_count, bool fill)
+{
+ tdm_error ret;
+ unsigned int flags = 0;
+ tbm_format format = (tbm_format)0;
+ int w, h;
+ tdm_output *output;
+ const tdm_output_mode *mode = NULL;
+
+ /* create buffers */
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_buffer_flags(layer, &flags) == TDM_ERROR_NONE);
+
+ format = tc_tdm_layer_find_best_format(layer);
+ TDM_UT_RETURN_FALSE_IF_FAIL(format != 0);
+
+ output = tdm_layer_get_output(layer, &ret);
+ TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(output != NULL);
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_mode(output, &mode) == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(mode != NULL);
+
+ if (tc_tdm_layer_is_primary_layer(layer)) {
+ w = mode->hdisplay;
+ h = mode->vdisplay;
+ } else {
+ w = mode->hdisplay / 2;
+ h = mode->vdisplay / 2;
+ }
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(tc_tdm_buffer_create(w, h, format, flags | TBM_BO_SCANOUT, fill, buffer_count, buffers) == true);
+
+ TDM_INFO("preparing buffers done");
+
+ return true;
+}
+
+bool
+tc_tdm_layer_prepare_buffer_queue(tdm_layer *layer, tbm_surface_queue_h *buffer_queue)
+{
+ tdm_error ret;
+ unsigned int flags = 0;
+ tbm_format format = (tbm_format)0;
+ int w, h;
+
+ /* create buffers */
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_buffer_flags(layer, &flags) == TDM_ERROR_NONE);
+
+ format = tc_tdm_layer_find_best_format(layer);
+ TDM_UT_RETURN_FALSE_IF_FAIL(format != (tbm_format)0);
+
+ if (tc_tdm_layer_is_primary_layer(layer)) {
+ tdm_output *output;
+ const tdm_output_mode *mode = NULL;
+ output = tdm_layer_get_output(layer, &ret);
+ TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(output != NULL);
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_mode(output, &mode) == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(mode != NULL);
+
+ w = mode->hdisplay;
+ h = mode->vdisplay;
+ } else {
+ w = TDM_UT_BUFFER_SIZE;
+ h = TDM_UT_BUFFER_SIZE;
+ }
+
+ *buffer_queue = tbm_surface_queue_create(2, w, h, format, flags | TBM_BO_SCANOUT);
+ TDM_UT_RETURN_FALSE_IF_FAIL((*buffer_queue) != NULL);
+
+ TDM_INFO("preparing buffers done");
+
+ return true;
+}
+
+bool
+tc_tdm_layer_fill_info(tdm_layer *layer, tbm_surface_h buffer, tbm_surface_queue_h buffer_queue, tdm_info_layer *info)
+{
+ tdm_error ret;
+ tdm_output *output;
+ const tdm_output_mode *mode = NULL;
+ int count = 0;
+ int zpos = -1;
+ int bw, bh;
+ int w, h;
+ tbm_format format;
+
+ output = tdm_layer_get_output(layer, &ret);
+ TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(output != NULL);
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_mode(output, &mode) == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(mode != NULL);
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_layer_count(output, &count) == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(count > 0);
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_zpos(layer, &zpos) == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(zpos >= 0);
+
+ if (buffer) {
+ tdm_helper_get_buffer_full_size(buffer, &bw, &bh);
+ w = tbm_surface_get_width(buffer);
+ h = tbm_surface_get_height(buffer);
+ format = tbm_surface_get_format(buffer);
+ } else if (buffer_queue) {
+ bw = w = tbm_surface_queue_get_width(buffer_queue);
+ bh = h = tbm_surface_queue_get_height(buffer_queue);
+ format = tbm_surface_queue_get_format(buffer_queue);
+ } else {
+ bw = mode->hdisplay;
+ bh = mode->vdisplay;
+ w = mode->hdisplay;
+ h = mode->vdisplay;
+ format = tc_tdm_layer_find_best_format(layer);
+ }
+
+ /* TODO: check min,max,prefered size and avaiable formats */
+ memset(info, 0, sizeof *info);
+ info->src_config.size.h = bw;
+ info->src_config.size.v = bh;
+ info->src_config.pos.x = 0;
+ info->src_config.pos.y = 0;
+ info->src_config.pos.w = w;
+ info->src_config.pos.h = h;
+ info->src_config.format = format;
+ if (tc_tdm_layer_is_primary_layer(layer)) {
+ info->dst_pos.x = 0;
+ info->dst_pos.y = 0;
+ } else {
+ int x = (((int)mode->hdisplay - 2 * BORDER_SIZE - w) / count) * zpos + BORDER_SIZE;
+ int y = (((int)mode->vdisplay - 2 * BORDER_SIZE - h) / count) * zpos + BORDER_SIZE;
+ x = (x > 0) ? x : 0;
+ y = (y > 0) ? y : 0;
+ info->dst_pos.x = ((x + w) <= (int)mode->hdisplay) ? x : 0;
+ info->dst_pos.y = ((y + h) <= (int)mode->vdisplay) ? y : 0;
+ }
+ info->dst_pos.w = w;
+ info->dst_pos.h = h;
+ info->transform = TDM_TRANSFORM_NORMAL;
+
+ return true;
+}
+
+bool tc_tdm_layer_set_buffer(tdm_layer *layer, tbm_surface_h buffer)
+{
+ tdm_info_layer old_info, info;
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(buffer != NULL);
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_info(layer, &old_info) == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(tc_tdm_layer_fill_info(layer, buffer, NULL, &info) == true);
+
+ if (memcmp(&old_info, &info, sizeof info)) {
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_set_info(layer, &info) == TDM_ERROR_NONE);
+
+ tdm_output *output;
+ tdm_error ret;
+ int index = -1;
+ unsigned int pipe = 0;
+ output = tdm_layer_get_output(layer, &ret);
+ TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_index(layer, &index) == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_pipe(output, &pipe) == TDM_ERROR_NONE);
+ TDM_INFO("filling output(%d) layer(%d) info done: src_config(%dx%d: %d,%d %dx%d: %c%c%c%c) dst_pos(%d,%d %dx%d) transform(%s)",
+ pipe, index,
+ info.src_config.size.h, info.src_config.size.v,
+ info.src_config.pos.x, info.src_config.pos.y, info.src_config.pos.w, info.src_config.pos.h,
+ FOURCC_STR(info.src_config.format),
+ info.dst_pos.x, info.dst_pos.y, info.dst_pos.w, info.dst_pos.h,
+ tdm_transform_str(info.transform));
+ }
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_set_buffer(layer, buffer) == TDM_ERROR_NONE);
+
+ return true;
+}
+
+bool tc_tdm_layer_set_buffer_with_pos(tdm_layer *layer, tbm_surface_h buffer, tdm_pos *pos)
+{
+ tdm_info_layer old_info, info;
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(buffer != NULL);
+ TDM_UT_RETURN_FALSE_IF_FAIL(pos != NULL);
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_info(layer, &old_info) == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(tc_tdm_layer_fill_info(layer, buffer, NULL, &info) == true);
+
+ info.dst_pos.x = pos->x;
+ info.dst_pos.y = pos->y;
+ TDM_UT_RETURN_FALSE_IF_FAIL(info.dst_pos.w = pos->w);
+ TDM_UT_RETURN_FALSE_IF_FAIL(info.dst_pos.h = pos->h);
+
+ if (memcmp(&old_info, &info, sizeof info)) {
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_set_info(layer, &info) == TDM_ERROR_NONE);
+
+ tdm_output *output;
+ tdm_error ret;
+ int index = -1;
+ unsigned int pipe = 0;
+ output = tdm_layer_get_output(layer, &ret);
+ TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_index(layer, &index) == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_pipe(output, &pipe) == TDM_ERROR_NONE);
+ TDM_INFO("filling output(%d) layer(%d) info done: src_config(%dx%d: %d,%d %dx%d: %c%c%c%c) dst_pos(%d,%d %dx%d) transform(%s)",
+ pipe, index,
+ info.src_config.size.h, info.src_config.size.v,
+ info.src_config.pos.x, info.src_config.pos.y, info.src_config.pos.w, info.src_config.pos.h,
+ FOURCC_STR(info.src_config.format),
+ info.dst_pos.x, info.dst_pos.y, info.dst_pos.w, info.dst_pos.h,
+ tdm_transform_str(info.transform));
+ }
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_set_buffer(layer, buffer) == TDM_ERROR_NONE);
+
+ return true;
+}
+
+bool tc_tdm_layer_set_buffer_queue(tdm_layer *layer, tbm_surface_queue_h buffer_queue)
+{
+ tdm_info_layer old_info, info;
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(buffer_queue != NULL);
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_info(layer, &old_info) == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(tc_tdm_layer_fill_info(layer, NULL, buffer_queue, &info) == true);
+
+ if (memcmp(&old_info, &info, sizeof info))
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_set_info(layer, &info) == TDM_ERROR_NONE);
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_set_buffer_queue(layer, buffer_queue) == TDM_ERROR_NONE);
+
+ return true;
+}
+
+bool tc_tdm_layer_is_avaiable(tdm_layer *layer)
+{
+ tdm_error ret;
+ tdm_output *output = tdm_layer_get_output(layer, &ret);
+ TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(output != NULL);
+
+ /* only check if connected */
+ return tc_tdm_output_is_connected(output);
+}
+
+TEST_P(TDMLayer, LayerGetOutput)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ for (int l = 0; l < layer_count; l++) {
+ tdm_error ret;
+ tdm_output *output = tdm_layer_get_output(layers[l], &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(output, NULL);
+ }
+}
+
+TEST_P(TDMLayer, LayerGetOutputNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ tdm_error ret;
+ tdm_output *output = tdm_layer_get_output(NULL, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(output, NULL);
+}
+
+TEST_P(TDMLayer, LayerGetOutputNullParam)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ for (int l = 0; l < layer_count; l++) {
+ tdm_output *output = tdm_layer_get_output(layers[l], NULL);
+ ASSERT_NE(output, NULL);
+ }
+}
+
+TEST_P(TDMLayer, LayerGetCapabilities)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ for (int l = 0; l < layer_count; l++) {
+ tdm_layer_capability capabilities = (tdm_layer_capability)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_layer_get_capabilities(layers[l], &capabilities), TDM_ERROR_NONE);
+ ASSERT_NE(capabilities, TDM_UT_INVALID_VALUE);
+ }
+}
+
+TEST_P(TDMLayer, LayerGetCapabilitiesNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ tdm_layer_capability capabilities = (tdm_layer_capability)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_layer_get_capabilities(NULL, &capabilities), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(capabilities, TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMLayer, LayerGetCapabilitiesNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+ ASSERT_EQ(tdm_layer_get_capabilities(layers[0], NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMLayer, LayerGetAvailableFormats)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ for (int l = 0; l < layer_count; l++) {
+ if (!tc_tdm_layer_is_avaiable(layers[l]))
+ continue;
+ const tbm_format *formats = (const tbm_format *)TDM_UT_INVALID_VALUE;
+ int count = TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_layer_get_available_formats(layers[l], &formats, &count), TDM_ERROR_NONE);
+ ASSERT_NE(formats, NULL);
+ ASSERT_GT(count, 0);
+ }
+}
+
+TEST_P(TDMLayer, LayerGetAvailableFormatsNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ const tbm_format *formats = (const tbm_format *)TDM_UT_INVALID_VALUE;
+ int count = TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_layer_get_available_formats(NULL, &formats, &count), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(formats, (const tbm_format *)TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(count, TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMLayer, LayerGetAvailableFormatsNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+ if (!tc_tdm_layer_is_avaiable(layers[0]))
+ return;
+ ASSERT_EQ(tdm_layer_get_available_formats(layers[0], NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMLayer, LayerGetAvailableProperties)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ for (int l = 0; l < layer_count; l++) {
+ if (!tc_tdm_layer_is_avaiable(layers[l]))
+ continue;
+ const tdm_prop *props = (const tdm_prop *)TDM_UT_INVALID_VALUE;
+ int count = TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_layer_get_available_properties(layers[l], &props, &count), TDM_ERROR_NONE);
+ ASSERT_GE(count, 0);
+ if (count > 0)
+ ASSERT_TRUE(props != NULL && props != (const tdm_prop *)TDM_UT_INVALID_VALUE);
+ }
+}
+
+TEST_P(TDMLayer, LayerGetAvailablePropertiesNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ const tdm_prop *props = (const tdm_prop *)TDM_UT_INVALID_VALUE;
+ int count = TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_layer_get_available_properties(NULL, &props, &count), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(props, (const tdm_prop *)TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(count, TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMLayer, LayerGetAvailablePropertiesNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ ASSERT_EQ(tdm_layer_get_available_properties(layers[0], NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMLayer, LayerGetZpos)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ bool *check_table = (bool*)calloc(layer_count, output_count);
+ ASSERT_NE(check_table, NULL);
+
+ for (int l = 0; l < layer_count; l++) {
+ if (!tc_tdm_layer_is_avaiable(layers[l]))
+ continue;
+ unsigned int pipe = tc_tdm_layer_get_output_pipe(layers[l]);
+ int zpos = TDM_UT_INVALID_VALUE;
+ EXPECT_TRUE(tdm_layer_get_zpos(layers[l], &zpos) == TDM_ERROR_NONE);
+ EXPECT_TRUE(zpos != TDM_UT_INVALID_VALUE);
+ if (tc_tdm_layer_is_video_layer(layers[l]))
+ continue;
+ EXPECT_TRUE(zpos >= 0);
+ EXPECT_TRUE(pipe < (unsigned int)output_count);
+ EXPECT_TRUE(*(check_table + pipe * layer_count + zpos) == false);
+ *(check_table + pipe * layer_count + zpos) = true;
+ }
+
+ free(check_table);
+}
+
+TEST_P(TDMLayer, LayerGetZposNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ int zpos = TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_layer_get_zpos(NULL, &zpos), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(zpos, TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMLayer, LayerGetZposNullParam)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ ASSERT_EQ(tdm_layer_get_zpos(layers[0], NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMLayer, DISABLED_LayerSetProperty)
+{
+}
+
+TEST_P(TDMLayer, LayerSetPropertyNullObject)
+{
+ tdm_value value = {.s32 = 0};
+
+ ASSERT_EQ(tdm_layer_set_property(NULL, 0, value), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMLayer, LayerGetProperty)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ for (int l = 0; l < layer_count; l++) {
+ if (!tc_tdm_layer_is_avaiable(layers[l]))
+ continue;
+
+ const tdm_prop *props = (const tdm_prop *)TDM_UT_INVALID_VALUE;
+ int count = TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_layer_get_available_properties(layers[l], &props, &count), TDM_ERROR_NONE);
+ ASSERT_GE(count, 0);
+ if (count > 0) {
+ ASSERT_TRUE(props != NULL && props != (const tdm_prop *)TDM_UT_INVALID_VALUE);
+
+ for (int i = 0; i < count; i++) {
+ tdm_value value = {.s32 = TDM_UT_INVALID_VALUE};
+ ASSERT_EQ(tdm_layer_get_property(layers[l], props[i].id, &value), TDM_ERROR_NONE);
+ ASSERT_NE(value.s32, TDM_UT_INVALID_VALUE);
+ }
+ }
+ }
+}
+
+TEST_P(TDMLayer, LayerGetPropertyNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ tdm_value value = {.s32 = TDM_UT_INVALID_VALUE};
+ ASSERT_EQ(tdm_layer_get_property(NULL, 0, &value), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(value.s32, TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMLayer, LayerGetPropertyNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ ASSERT_EQ(tdm_layer_get_property(layers[0], 0, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMLayer, LayerSetInfo)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ tc_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
+
+ for (int l = 0; l < layer_count; l++) {
+ if (!tc_tdm_layer_is_avaiable(layers[l]))
+ continue;
+
+ tdm_info_layer info;
+ ASSERT_EQ(tc_tdm_layer_fill_info(layers[l], NULL, NULL, &info), true);
+ ASSERT_EQ(tdm_layer_set_info(layers[l], &info), TDM_ERROR_NONE);
+ }
+}
+
+TEST_P(TDMLayer, LayerSetInfoNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ tdm_info_layer info;
+ memset(&info, 0, sizeof info);
+ ASSERT_EQ(tdm_layer_set_info(NULL, &info), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMLayer, LayerSetInfoNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ ASSERT_EQ(tdm_layer_set_info(layers[0], NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMLayer, DISABLED_LayerGetInfo)
+{
+}
+
+TEST_P(TDMLayer, LayerGetInfoNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ tdm_info_layer temp;
+
+ ASSERT_EQ(tdm_layer_get_info(NULL, &temp), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMLayer, LayerGetInfoNullParam)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ ASSERT_EQ(tdm_layer_get_info(layers[0], NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMLayer, LayerGetBufferFlags)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ for (int l = 0; l < layer_count; l++) {
+ if (!tc_tdm_layer_is_avaiable(layers[l]))
+ continue;
+
+ unsigned int flags = (unsigned int)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_layer_get_buffer_flags(layers[l], &flags), TDM_ERROR_NONE);
+ ASSERT_NE(flags, (unsigned int)TDM_UT_INVALID_VALUE);
+ }
+}
+
+TEST_P(TDMLayer, LayerGetBufferFlagsNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ unsigned int flags = (unsigned int)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_layer_get_buffer_flags(NULL, &flags), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(flags, (unsigned int)TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMLayer, LayerGetBufferFlagsNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ ASSERT_EQ(tdm_layer_get_buffer_flags(layers[0], NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+static void
+_tc_tdm_layer_commit_cb(tdm_layer *layer, unsigned int sequence,
+ unsigned int tv_sec, unsigned int tv_usec,
+ void *user_data)
+{
+ bool *done = (bool*)user_data;
+ if (done)
+ *done = true;
+}
+
+TEST_P(TDMLayer, LayerSetBuffer)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ tdm_error ret;
+
+ tc_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
+
+ for (int l = 0; l < layer_count; l++) {
+ if (!tc_tdm_layer_is_avaiable(layers[l]))
+ continue;
+
+ int next_buffer = 0;
+
+ if (tc_tdm_layer_is_cursor_layer(layers[l]))
+ continue;
+ if (tc_tdm_layer_is_video_layer(layers[l]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_layer_prepare_buffer(layers[l], buffers, 3, true), true);
+
+ /* set buffer & commit for 100 times */
+ for (int t = 0; t < 10; t++) {
+ tbm_surface_h displaying_buffer = NULL;
+ ASSERT_EQ(tc_tdm_layer_set_buffer(layers[l], buffers[next_buffer]), true);
+ ASSERT_EQ(tdm_layer_commit(layers[l], _tc_tdm_layer_commit_cb, NULL), TDM_ERROR_NONE);
+ while (displaying_buffer != buffers[next_buffer]) {
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ displaying_buffer = tdm_layer_get_displaying_buffer(layers[l], &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ }
+ next_buffer++;
+ if (next_buffer == 3)
+ next_buffer = 0;
+ }
+
+ DestroyBuffers();
+ }
+}
+
+TEST_P(TDMLayer, LayerSetBufferFewTimeInOneCommit)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ tdm_error ret;
+
+ tc_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
+
+ for (int l = 0; l < layer_count; l++) {
+ if (!tc_tdm_layer_is_avaiable(layers[l]))
+ continue;
+
+ int next_buffer = 0;
+
+ if (tc_tdm_layer_is_cursor_layer(layers[l]))
+ continue;
+ if (tc_tdm_layer_is_video_layer(layers[l]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_layer_prepare_buffer(layers[l], buffers, 3, true), true);
+
+ /* set buffer & commit for 10 times */
+ for (int t = 0; t < 10; t++) {
+ tbm_surface_h displaying_buffer = NULL;
+ ASSERT_EQ(tc_tdm_layer_set_buffer(layers[l], buffers[next_buffer++]), true);
+ if (next_buffer == 3)
+ next_buffer = 0;
+ ASSERT_EQ(tc_tdm_layer_set_buffer(layers[l], buffers[next_buffer]), true);
+ ASSERT_EQ(tdm_layer_commit(layers[l], _tc_tdm_layer_commit_cb, NULL), TDM_ERROR_NONE);
+ while (displaying_buffer != buffers[next_buffer]) {
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ displaying_buffer = tdm_layer_get_displaying_buffer(layers[l], &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ }
+ next_buffer++;
+ if (next_buffer == 3)
+ next_buffer = 0;
+ }
+
+ DestroyBuffers();
+ }
+}
+
+TEST_P(TDMLayer, LayerSetBufferNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ tbm_surface_h buffer = (tbm_surface_h)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_layer_set_buffer(NULL, buffer), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMLayer, LayerSetBufferNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ ASSERT_EQ(tdm_layer_set_buffer(layers[0], NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMLayer, LayerUnsetBuffer)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ tc_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
+
+ for (int l = 0; l < layer_count; l++) {
+ if (!tc_tdm_layer_is_avaiable(layers[l]))
+ continue;
+
+ ASSERT_EQ(tdm_layer_unset_buffer(layers[l]), TDM_ERROR_NONE);
+ }
+}
+
+TEST_P(TDMLayer, LayerUnsetBufferNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ ASSERT_EQ(tdm_layer_unset_buffer(NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMLayer, LayerUnsetBufferBeforeCommit)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ tc_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
+
+ for (int l = 0; l < layer_count; l++) {
+ if (!tc_tdm_layer_is_avaiable(layers[l]))
+ continue;
+
+ int next_buffer = 0;
+
+ if (tc_tdm_layer_is_cursor_layer(layers[l]))
+ continue;
+ if (tc_tdm_layer_is_video_layer(layers[l]))
+ continue;
+ if (tc_tdm_layer_is_primary_layer(layers[l]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_layer_prepare_buffer(layers[l], buffers, 3, true), true);
+
+ /* set buffer & commit for 10 times */
+ for (int t = 0; t < 10; t++) {
+ ASSERT_EQ(tc_tdm_layer_set_buffer(layers[l], buffers[next_buffer++]), true);
+ if (next_buffer == 3)
+ next_buffer = 0;
+ ASSERT_EQ(tc_tdm_layer_set_buffer(layers[l], buffers[next_buffer++]), true);
+ if (next_buffer == 3)
+ next_buffer = 0;
+ }
+
+ ASSERT_EQ(tdm_layer_unset_buffer(layers[l]), TDM_ERROR_NONE);
+
+ DestroyBuffers();
+ }
+}
+
+TEST_P(TDMLayer, LayerUnsetBufferAfterOneCommit)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ tc_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
+
+ for (int l = 0; l < layer_count; l++) {
+ if (!tc_tdm_layer_is_avaiable(layers[l]))
+ continue;
+
+ int next_buffer = 0;
+
+ if (tc_tdm_layer_is_cursor_layer(layers[l]))
+ continue;
+ if (tc_tdm_layer_is_video_layer(layers[l]))
+ continue;
+ if (tc_tdm_layer_is_primary_layer(layers[l]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_layer_prepare_buffer(layers[l], buffers, 3, true), true);
+
+ ASSERT_EQ(tc_tdm_layer_set_buffer(layers[l], buffers[next_buffer++]), true);
+ ASSERT_EQ(tc_tdm_layer_set_buffer(layers[l], buffers[next_buffer++]), true);
+ ASSERT_EQ(tdm_layer_commit(layers[l], _tc_tdm_layer_commit_cb, NULL), TDM_ERROR_NONE);
+
+ ASSERT_EQ(tdm_layer_unset_buffer(layers[l]), TDM_ERROR_NONE);
+
+ DestroyBuffers();
+ }
+}
+
+/* drmModePageFlip can't be done twice in a vblank */
+TEST_P(TDMLayer, DISABLED_LayerUnsetBufferAfterTwoCommit)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ tc_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
+
+ for (int l = 0; l < layer_count; l++) {
+ if (!tc_tdm_layer_is_avaiable(layers[l]))
+ continue;
+
+ int next_buffer = 0;
+
+ if (tc_tdm_layer_is_cursor_layer(layers[l]))
+ continue;
+ if (tc_tdm_layer_is_video_layer(layers[l]))
+ continue;
+ if (tc_tdm_layer_is_primary_layer(layers[l]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_layer_prepare_buffer(layers[l], buffers, 3, true), true);
+
+ ASSERT_EQ(tc_tdm_layer_set_buffer(layers[l], buffers[next_buffer++]), true);
+ ASSERT_EQ(tdm_layer_commit(layers[l], _tc_tdm_layer_commit_cb, NULL), TDM_ERROR_NONE);
+
+ ASSERT_EQ(tc_tdm_layer_set_buffer(layers[l], buffers[next_buffer++]), true);
+ ASSERT_EQ(tdm_layer_commit(layers[l], _tc_tdm_layer_commit_cb, NULL), TDM_ERROR_NONE);
+
+ ASSERT_EQ(tdm_layer_unset_buffer(layers[l]), TDM_ERROR_NONE);
+
+ DestroyBuffers();
+ }
+}
+
+/* drmModePageFlip can't be done twice in a vblank */
+TEST_P(TDMLayer, DISABLED_LayerUnsetBufferAfterTwoCommitOneSetBuffer)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ tc_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
+
+ for (int l = 0; l < layer_count; l++) {
+ if (!tc_tdm_layer_is_avaiable(layers[l]))
+ continue;
+
+ int next_buffer = 0;
+
+ if (tc_tdm_layer_is_cursor_layer(layers[l]))
+ continue;
+ if (tc_tdm_layer_is_video_layer(layers[l]))
+ continue;
+ if (tc_tdm_layer_is_primary_layer(layers[l]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_layer_prepare_buffer(layers[l], buffers, 3, true), true);
+
+ ASSERT_EQ(tc_tdm_layer_set_buffer(layers[l], buffers[next_buffer++]), true);
+ ASSERT_EQ(tdm_layer_commit(layers[l], _tc_tdm_layer_commit_cb, NULL), TDM_ERROR_NONE);
+
+ ASSERT_EQ(tc_tdm_layer_set_buffer(layers[l], buffers[next_buffer++]), true);
+ ASSERT_EQ(tdm_layer_commit(layers[l], _tc_tdm_layer_commit_cb, NULL), TDM_ERROR_NONE);
+
+ ASSERT_EQ(tc_tdm_layer_set_buffer(layers[l], buffers[next_buffer]), true);
+
+ ASSERT_EQ(tdm_layer_unset_buffer(layers[l]), TDM_ERROR_NONE);
+
+ DestroyBuffers();
+ }
+}
+
+TEST_P(TDMLayer, LayerUnsetBufferAfterOneCommitOneDone)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ tc_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
+
+ for (int l = 0; l < layer_count; l++) {
+ if (!tc_tdm_layer_is_avaiable(layers[l]))
+ continue;
+
+ int next_buffer = 0;
+ bool done;
+
+ if (tc_tdm_layer_is_cursor_layer(layers[l]))
+ continue;
+ if (tc_tdm_layer_is_video_layer(layers[l]))
+ continue;
+ if (tc_tdm_layer_is_primary_layer(layers[l]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_layer_prepare_buffer(layers[l], buffers, 3, true), true);
+
+ /* set buffer & commit for 10 times */
+ ASSERT_EQ(tc_tdm_layer_set_buffer(layers[l], buffers[next_buffer++]), true);
+ ASSERT_EQ(tc_tdm_layer_set_buffer(layers[l], buffers[next_buffer++]), true);
+
+ done = false;
+ ASSERT_EQ(tdm_layer_commit(layers[l], _tc_tdm_layer_commit_cb, &done), TDM_ERROR_NONE);
+ while (!done) {
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ }
+
+ ASSERT_EQ(tdm_layer_unset_buffer(layers[l]), TDM_ERROR_NONE);
+
+ DestroyBuffers();
+ }
+}
+
+TEST_P(TDMLayer, LayerUnsetBufferAfterOneCommitOneDoneOneCommit)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ tc_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
+
+ for (int l = 0; l < layer_count; l++) {
+ if (!tc_tdm_layer_is_avaiable(layers[l]))
+ continue;
+
+ int next_buffer = 0;
+ bool done;
+
+ if (tc_tdm_layer_is_cursor_layer(layers[l]))
+ continue;
+ if (tc_tdm_layer_is_video_layer(layers[l]))
+ continue;
+ if (tc_tdm_layer_is_primary_layer(layers[l]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_layer_prepare_buffer(layers[l], buffers, 3, true), true);
+
+ /* set buffer & commit for 10 times */
+ ASSERT_EQ(tc_tdm_layer_set_buffer(layers[l], buffers[next_buffer++]), true);
+ ASSERT_EQ(tc_tdm_layer_set_buffer(layers[l], buffers[next_buffer++]), true);
+
+ done = false;
+ ASSERT_EQ(tdm_layer_commit(layers[l], _tc_tdm_layer_commit_cb, &done), TDM_ERROR_NONE);
+ while (!done) {
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ }
+
+ ASSERT_EQ(tc_tdm_layer_set_buffer(layers[l], buffers[next_buffer++]), true);
+ next_buffer = 0;
+ ASSERT_EQ(tdm_layer_commit(layers[l], _tc_tdm_layer_commit_cb, &done), TDM_ERROR_NONE);
+
+ ASSERT_EQ(tdm_layer_unset_buffer(layers[l]), TDM_ERROR_NONE);
+
+ DestroyBuffers();
+ }
+}
+
+TEST_P(TDMLayer, LayerCommitDPMSOff)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ tdm_error ret;
+ tdm_output *output = tdm_layer_get_output(layers[0], &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(output, NULL);
+
+ if (!tc_tdm_output_is_connected(output))
+ return;
+
+ EXPECT_TRUE(tc_tdm_output_prepare(dpy, output, true) == true);
+
+ EXPECT_TRUE(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF) == TDM_ERROR_NONE);
+
+ EXPECT_TRUE(tdm_layer_commit(layers[0], NULL, NULL) == TDM_ERROR_DPMS_OFF);
+
+ EXPECT_TRUE(tc_tdm_output_unset(dpy, output) == true);
+}
+
+TEST_P(TDMLayer, LayerCommitNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ ASSERT_EQ(tdm_layer_commit(NULL, _tc_tdm_layer_commit_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMLayer, LayerCommitNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ tc_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
+
+ ASSERT_EQ(tdm_layer_commit(layers[0], NULL, NULL), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMLayer, LayerIsCommittingNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ unsigned int committing = (unsigned int)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_layer_is_committing(NULL, &committing), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(committing, (unsigned int)TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMLayer, LayerIsCommittingNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ ASSERT_EQ(tdm_layer_is_committing(layers[0], NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMLayer, LayerRemoveCommitHandler)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ tc_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
+
+ for (int l = 0; l < layer_count; l++) {
+ if (!tc_tdm_layer_is_avaiable(layers[l]))
+ continue;
+
+ tdm_error ret;
+ tdm_output *output = tdm_layer_get_output(layers[l], &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(output, NULL);
+
+ if (tc_tdm_layer_is_cursor_layer(layers[l]))
+ continue;
+ if (tc_tdm_layer_is_video_layer(layers[l]))
+ continue;
+ if (tc_tdm_layer_is_primary_layer(layers[l]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_layer_prepare_buffer(layers[l], buffers, 1, true), true);
+
+ ASSERT_EQ(tc_tdm_layer_set_buffer(layers[l], buffers[0]), true);
+
+ for (int t = 0; t < 10; t++) {
+ bool done1 = false, done2 = false, done3 = false;
+ ASSERT_EQ(tdm_layer_commit(layers[l], _tc_tdm_layer_commit_cb, &done1), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_layer_commit(layers[l], _tc_tdm_layer_commit_cb, &done2), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_layer_commit(layers[l], _tc_tdm_layer_commit_cb, &done3), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_layer_remove_commit_handler(layers[l], _tc_tdm_layer_commit_cb, &done2), TDM_ERROR_NONE);
+ while (!done1 || done2 || !done3) {
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ }
+ }
+
+ DestroyBuffers();
+ }
+}
+
+TEST_P(TDMLayer, LayerRemoveCommitHandlerDifferentData)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ tc_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
+
+ for (int l = 0; l < layer_count; l++) {
+ if (!tc_tdm_layer_is_avaiable(layers[l]))
+ continue;
+
+ tdm_error ret;
+ tdm_output *output = tdm_layer_get_output(layers[l], &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(output, NULL);
+
+ if (tc_tdm_layer_is_cursor_layer(layers[l]))
+ continue;
+ if (tc_tdm_layer_is_video_layer(layers[l]))
+ continue;
+ if (tc_tdm_layer_is_primary_layer(layers[l]))
+ continue;
+
+ for (int t = 0; t < 10; t++) {
+ bool done1 = false, done2 = false, done3 = false;
+ ASSERT_EQ(tdm_layer_commit(layers[l], _tc_tdm_layer_commit_cb, &done1), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_layer_commit(layers[l], _tc_tdm_layer_commit_cb, &done2), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_layer_commit(layers[l], _tc_tdm_layer_commit_cb, &done3), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_layer_remove_commit_handler(layers[l], _tc_tdm_layer_commit_cb, NULL), TDM_ERROR_NONE);
+ while (!done1 || !done2 || !done3) {
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ }
+ }
+ }
+}
+static void
+_tc_tdm_layer_commit_cb2(tdm_layer *layer, unsigned int sequence,
+ unsigned int tv_sec, unsigned int tv_usec,
+ void *user_data)
+{
+ bool *done = (bool*)user_data;
+ if (done)
+ *done = true;
+ ASSERT_EQ(tdm_layer_remove_commit_handler(layer, _tc_tdm_layer_commit_cb2, user_data), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMLayer, LayerRemoveCommitHandlerInHandler)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ tc_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
+
+ for (int l = 0; l < layer_count; l++) {
+ if (!tc_tdm_layer_is_avaiable(layers[l]))
+ continue;
+
+ tdm_error ret;
+ tdm_output *output = tdm_layer_get_output(layers[l], &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(output, NULL);
+
+ if (tc_tdm_layer_is_cursor_layer(layers[l]))
+ continue;
+ if (tc_tdm_layer_is_video_layer(layers[l]))
+ continue;
+ if (tc_tdm_layer_is_primary_layer(layers[l]))
+ continue;
+
+ for (int t = 0; t < 10; t++) {
+ bool done1 = false, done2 = false, done3 = false;
+ ASSERT_EQ(tdm_layer_commit(layers[l], _tc_tdm_layer_commit_cb2, &done1), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_layer_commit(layers[l], _tc_tdm_layer_commit_cb2, &done2), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_layer_commit(layers[l], _tc_tdm_layer_commit_cb2, &done3), TDM_ERROR_NONE);
+ while (!done1 || !done2 || !done3) {
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ }
+ }
+ }
+}
+
+TEST_P(TDMLayer, LayerRemoveCommitHandlerNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ ASSERT_EQ(tdm_layer_remove_commit_handler(NULL, _tc_tdm_layer_commit_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMLayer, LayerRemoveCommitHandlerNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ ASSERT_EQ(tdm_layer_remove_commit_handler(layers[0], NULL, NULL), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMLayer, LayerGetDisplayingBufferNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ tbm_surface_h displaying_buffer;
+ tdm_error ret;
+ displaying_buffer = tdm_layer_get_displaying_buffer(NULL, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(displaying_buffer, NULL);
+}
+
+TEST_P(TDMLayer, LayerGetDisplayingBufferNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ tbm_surface_h displaying_buffer;
+ displaying_buffer = tdm_layer_get_displaying_buffer(layers[0], NULL);
+ ASSERT_EQ(displaying_buffer, NULL);
+}
+
+TEST_P(TDMLayer, LayerIsUsableNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ unsigned int usable = (unsigned int)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_layer_is_usable(NULL, &usable), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(usable, (unsigned int)TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMLayer, LayerSetBufferQueue)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ tdm_error ret;
+
+ tc_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
+
+ for (int l = 0; l < layer_count; l++) {
+ if (!tc_tdm_layer_is_avaiable(layers[l]))
+ continue;
+
+ tbm_surface_h buffer;
+ tbm_surface_h displaying_buffer;
+
+ if (tc_tdm_layer_is_cursor_layer(layers[l]))
+ continue;
+ if (tc_tdm_layer_is_video_layer(layers[l]))
+ continue;
+ if (tc_tdm_layer_is_primary_layer(layers[l]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_layer_prepare_buffer_queue(layers[l], &buffer_queue), true);
+ ASSERT_NE(buffer_queue, NULL);
+
+ ASSERT_EQ(tc_tdm_layer_set_buffer_queue(layers[l], buffer_queue), true);
+
+ ASSERT_EQ(tdm_layer_commit(layers[l], NULL, NULL), TDM_ERROR_NONE);
+
+ for (int t = 0; t < 10; t++) {
+ ASSERT_EQ(tbm_surface_queue_dequeue(buffer_queue, &buffer), TBM_SURFACE_QUEUE_ERROR_NONE);
+ ASSERT_NE(buffer, NULL);
+ tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
+ ASSERT_EQ(tbm_surface_queue_enqueue(buffer_queue, buffer), TBM_SURFACE_QUEUE_ERROR_NONE);
+
+ displaying_buffer = NULL;
+ while (displaying_buffer != buffer) {
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ displaying_buffer = tdm_layer_get_displaying_buffer(layers[l], &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ }
+ }
+
+ ASSERT_EQ(tdm_layer_unset_buffer_queue(layers[l]), TDM_ERROR_NONE);
+
+ DestroyBuffers();
+ }
+}
+
+TEST_P(TDMLayer, LayerSetBufferQueueTwice)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ tc_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
+
+ for (int l = 0; l < layer_count; l++) {
+ tbm_surface_queue_h buffer_queue1 = NULL;
+ tbm_surface_queue_h buffer_queue2 = NULL;
+
+ if (!tc_tdm_layer_is_avaiable(layers[l]))
+ continue;
+ if (tc_tdm_layer_is_cursor_layer(layers[l]))
+ continue;
+ if (tc_tdm_layer_is_video_layer(layers[l]))
+ continue;
+
+ EXPECT_TRUE(tc_tdm_layer_prepare_buffer_queue(layers[l], &buffer_queue1) == true);
+ EXPECT_TRUE(buffer_queue1 != NULL);
+ EXPECT_TRUE(tdm_layer_set_buffer_queue(layers[l], buffer_queue1) == TDM_ERROR_NONE);
+
+ EXPECT_TRUE(tc_tdm_layer_prepare_buffer_queue(layers[l], &buffer_queue2) == true);
+ EXPECT_TRUE(buffer_queue2 != NULL);
+ EXPECT_TRUE(tdm_layer_set_buffer_queue(layers[l], buffer_queue2) == TDM_ERROR_NONE);
+
+ if (buffer_queue1)
+ tbm_surface_queue_destroy(buffer_queue1);
+ if (buffer_queue2)
+ tbm_surface_queue_destroy(buffer_queue2);
+ }
+}
+
+TEST_P(TDMLayer, LayerSetBufferQueueNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ tbm_surface_queue_h buffer_queue = (tbm_surface_queue_h)TDM_UT_INVALID_VALUE;
+
+ ASSERT_EQ(tdm_layer_set_buffer_queue(NULL, buffer_queue), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMLayer, LayerSetBufferQueueNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ ASSERT_EQ(tdm_layer_set_buffer_queue(layers[0], NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMLayer, LayerUnsetBufferQueueNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ ASSERT_EQ(tdm_layer_unset_buffer_queue(NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMLayer, LayerIsUsableNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ ASSERT_EQ(tdm_layer_is_usable(layers[0], NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMLayer, LayerSetVideoPos)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ for (int l = 0; l < layer_count; ++l) {
+ if (!tc_tdm_layer_is_avaiable(layers[l]))
+ continue;
+
+ if (!tc_tdm_layer_is_video_layer(layers[l]))
+ continue;
+ ASSERT_EQ(tdm_layer_set_video_pos(layers[l], -1), TDM_ERROR_NONE);
+ }
+}
+
+TEST_P(TDMLayer, LayerSetVideoPosNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ ASSERT_EQ(tdm_layer_set_video_pos(NULL, -1), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMLayer, LayerSetVideoPosNoVideoLayer)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ for (int l = 0; l < layer_count; ++l) {
+ if (!tc_tdm_layer_is_avaiable(layers[l]))
+ continue;
+
+ if (tc_tdm_layer_is_video_layer(layers[l]))
+ continue;
+
+ ASSERT_EQ(tdm_layer_set_video_pos(layers[l], -1), TDM_ERROR_BAD_REQUEST);
+ }
+}
+
+TEST_P(TDMLayer, LayerCreateCapture)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ for (int l = 0; l < layer_count; ++l) {
+ tdm_error ret;
+ tdm_capture *capture;
+
+ if (!tc_tdm_layer_is_avaiable(layers[l]))
+ continue;
+
+ capture = tdm_layer_create_capture(layers[l], &ret);
+ if (ret == TDM_ERROR_NONE)
+ ASSERT_NE(capture, NULL);
+ }
+}
+
+TEST_P(TDMLayer, LayerCreateCaptureNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_layers);
+
+ tdm_error ret;
+ tdm_capture *capture = tdm_layer_create_capture(NULL, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(capture, NULL);
+}
+
+#ifdef TDM_UT_TEST_WITH_PARAMS
+INSTANTIATE_TEST_CASE_P(TDMLayerParams,
+ TDMLayer,
+ Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
+#else
+INSTANTIATE_TEST_CASE_P(TDMLayerParams,
+ TDMLayer,
+ Values(TDM_DEFAULT_MODULE));
+#endif
+
+/* LCOV_EXCL_END */
\ No newline at end of file
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
+ * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
+ * Contact: Roman Marchenko <r.marchenko@samsung.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+**************************************************************************/
+
+#include "tc_tdm.h"
+
+/* LCOV_EXCL_START */
+
+TEST(TDMLog, logPrintf)
+{
+ tdm_log_enable_color(1);
+ tdm_log_enable_dlog(0);
+ tdm_log_set_debug_level(2);
+ tdm_log_set_path("/tmp/tdm.log");
+ tdm_log_print(TDM_LOG_LEVEL_ERR, "haltest\n");
+ tdm_log_print(TDM_LOG_LEVEL_WRN, "haltest\n");
+ tdm_log_print(TDM_LOG_LEVEL_INFO, "haltest\n");
+ tdm_log_print(TDM_LOG_LEVEL_DBG, "haltest\n");
+ tdm_log_set_path(NULL);
+}
+
+TEST(TDMLog, logSetPath)
+{
+ tdm_log_enable_dlog(0);
+ tdm_log_set_path("/tmp/tdm.log");
+ tdm_log_print(TDM_LOG_LEVEL_ERR, "hello\n");
+ tdm_log_set_path(NULL);
+}
+
+TEST(TDMLog, logDlogNone)
+{
+ tdm_log_enable_color(0);
+ tdm_log_enable_dlog(1);
+ tdm_log_set_debug_level(0);
+ tdm_log_print(TDM_LOG_LEVEL_ERR, "haltest");
+ tdm_log_print(TDM_LOG_LEVEL_WRN, "haltest");
+ tdm_log_print(TDM_LOG_LEVEL_INFO, "haltest");
+ tdm_log_print(TDM_LOG_LEVEL_DBG, "haltest");
+}
+
+TEST(TDMLog, logDlog)
+{
+ tdm_log_enable_dlog(1);
+ tdm_log_print(TDM_LOG_LEVEL_ERR, "haltest");
+ tdm_log_print(TDM_LOG_LEVEL_WRN, "haltest");
+ tdm_log_print(TDM_LOG_LEVEL_INFO, "haltest");
+ tdm_log_print(TDM_LOG_LEVEL_DBG, "haltest");
+}
+
+TEST(TDMLog, logDlogNormal)
+{
+ tdm_log_enable_dlog(1);
+ tdm_log_print(TDM_LOG_LEVEL_ERR, "haltest");
+ tdm_log_print(TDM_LOG_LEVEL_WRN, "haltest");
+ tdm_log_print(TDM_LOG_LEVEL_INFO, "haltest");
+ tdm_log_print(TDM_LOG_LEVEL_DBG, "haltest");
+}
+
+TEST(TDMLog, logDlogUnknownLevel)
+{
+ tdm_log_enable_dlog(1);
+ tdm_log_print(TDM_UT_INVALID_VALUE, "haltest");
+}
+
+/* LCOV_EXCL_END */
\ No newline at end of file
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
+ * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
+ * Contact: Roman Marchenko <r.marchenko@samsung.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+**************************************************************************/
+
+#include "tc_tdm.h"
+
+/* LCOV_EXCL_START */
+
+int tdm_debug_module;
+
+int main(int argc, char **argv)
+{
+ auto AllTestSuccess = false;
+
+#ifdef TIZEN_TEST_GCOV
+ setenv("GCOV_PREFIX", "/tmp", 1);
+#endif
+
+ try {
+ ::testing::InitGoogleTest(&argc, argv);
+ ::testing::FLAGS_gtest_death_test_style = "fast";
+ } catch ( ... ) {
+ std::cout << "error while trying to init google tests.\n";
+ exit(EXIT_FAILURE);
+ }
+
+ try {
+ AllTestSuccess = RUN_ALL_TESTS() == 0 ? true : false;
+ } catch (const ::testing::internal::GoogleTestFailureException & e) {
+ AllTestSuccess = false;
+ std::cout << "GoogleTestFailureException was thrown:" << e.what() << std::endl;
+ std::cout << "\n";
+ }
+
+#ifdef TIZEN_TEST_GCOV
+ __gcov_flush();
+#endif
+
+ return AllTestSuccess;
+}
+
+/* LCOV_EXCL_END */
\ No newline at end of file
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
+ * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
+ * Contact: Roman Marchenko <r.marchenko@samsung.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+**************************************************************************/
+
+#include "tc_tdm.h"
+
+/* LCOV_EXCL_START */
+
+static void _tc_tdm_output_change_cb(tdm_output *output, tdm_output_change_type type, tdm_value value, void *user_data);
+static void _tc_tdm_output_change_cb2(tdm_output *output, tdm_output_change_type type, tdm_value value, void *user_data);
+
+TDMOutput::TDMOutput()
+{
+ has_outputs = false;
+ output_count = TDM_UT_INVALID_VALUE;
+ outputs = NULL;
+
+ done1 = done2 = done3 = false;
+}
+
+void TDMOutput::SetUp(void)
+{
+ TDMDisplay::SetUp();
+
+ ASSERT_EQ(tdm_display_get_output_count(dpy, &output_count), TDM_ERROR_NONE);
+ ASSERT_GE(output_count, 0);
+
+ if (output_count > 0) {
+ outputs = (tdm_output**)calloc(output_count, sizeof(tdm_output*));
+ ASSERT_NE(outputs, NULL);
+
+ for (int o = 0; o < output_count; o++) {
+ tdm_error ret;
+ tdm_output *output = tdm_display_get_output(dpy, o, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(output, NULL);
+ outputs[o] = output;
+ }
+ has_outputs = true;
+ } else {
+ has_outputs = false;
+ }
+}
+
+void TDMOutput::TearDown(void)
+{
+ if (outputs) {
+ for (int o = 0; o < output_count; o++) {
+ ASSERT_EQ(tc_tdm_output_unset(dpy, outputs[o]), true);
+ tdm_output_remove_change_handler(outputs[o], _tc_tdm_output_change_cb, &done1);
+ tdm_output_remove_change_handler(outputs[o], _tc_tdm_output_change_cb, &done2);
+ tdm_output_remove_change_handler(outputs[o], _tc_tdm_output_change_cb, &done3);
+ tdm_output_remove_change_handler(outputs[o], _tc_tdm_output_change_cb, NULL);
+ }
+ free(outputs);
+ }
+
+ TDMDisplay::TearDown();
+}
+
+bool
+tc_tdm_output_mode_setting(tdm_output *output)
+{
+ const tdm_output_mode *modes = (const tdm_output_mode *)TDM_UT_INVALID_VALUE;
+ const tdm_output_mode *found = NULL;
+ const tdm_output_mode *best = NULL;
+ int count = TDM_UT_INVALID_VALUE;
+ unsigned int pipe = 0;
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_available_modes(output, &modes, &count) == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(count > 0);
+ TDM_UT_RETURN_FALSE_IF_FAIL(modes != NULL && modes != (const tdm_output_mode *)TDM_UT_INVALID_VALUE);
+
+ for (int i = 0; i < count; i++) {
+ if (!best)
+ best = &modes[i];
+ if (modes[i].type & TDM_OUTPUT_MODE_TYPE_PREFERRED)
+ found = &modes[i];
+ }
+ if (!found && best)
+ found = best;
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(found != NULL);
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_set_mode(output, found) == TDM_ERROR_NONE);
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_pipe(output, &pipe) == TDM_ERROR_NONE);
+
+ TDM_INFO("setting output(%d) mode done: %dx%d %d", pipe, found->hdisplay, found->vdisplay, found->vrefresh);
+
+ return true;
+}
+
+bool
+tc_tdm_output_is_async_dpms_enable(tdm_output *output)
+{
+ tdm_output_capability capabilities = (tdm_output_capability)TDM_UT_INVALID_VALUE;
+ if (tdm_output_get_capabilities(output, &capabilities) != TDM_ERROR_NONE)
+ return false;
+ return capabilities & TDM_OUTPUT_CAPABILITY_ASYNC_DPMS;
+}
+
+bool
+tc_tdm_output_is_hwc_enable(tdm_output *output)
+{
+ tdm_output_capability capabilities = (tdm_output_capability)TDM_UT_INVALID_VALUE;
+ if (tdm_output_get_capabilities(output, &capabilities) != TDM_ERROR_NONE)
+ return false;
+ return capabilities & TDM_OUTPUT_CAPABILITY_HWC;
+}
+
+bool
+tc_tdm_output_is_aod_enable(tdm_output *output)
+{
+ tdm_output_capability capabilities = (tdm_output_capability)TDM_UT_INVALID_VALUE;
+ if (tdm_output_get_capabilities(output, &capabilities) != TDM_ERROR_NONE)
+ return false;
+ return capabilities & TDM_OUTPUT_CAPABILITY_EXTENDED_DPMS;
+}
+
+bool
+tc_tdm_output_is_connected(tdm_output *output)
+{
+ tdm_output_conn_status status;
+ if (tdm_output_get_conn_status(output, &status) != TDM_ERROR_NONE)
+ return false;
+ return (status != TDM_OUTPUT_CONN_STATUS_DISCONNECTED) ? true : false;
+}
+
+tdm_layer *
+tc_tdm_output_get_primary_layer(tdm_output *output)
+{
+ tdm_error ret;
+ tdm_layer *layer;
+ int primary_index = -1;
+
+ TDM_UT_RETURN_VAL_IF_FAIL(tdm_output_get_primary_index(output, &primary_index) == TDM_ERROR_NONE, NULL);
+ TDM_UT_RETURN_VAL_IF_FAIL(primary_index >= 0, NULL);
+
+ layer = tdm_output_get_layer(output, primary_index, &ret);
+ TDM_UT_RETURN_VAL_IF_FAIL(ret == TDM_ERROR_NONE, NULL);
+ TDM_UT_RETURN_VAL_IF_FAIL(layer != NULL, NULL);
+
+ return layer;
+}
+
+static void
+_tc_tdm_output_done_cb(tdm_output *output, unsigned int sequence,
+ unsigned int tv_sec, unsigned int tv_usec,
+ void *user_data)
+{
+ bool *done = (bool*)user_data;
+ if (done)
+ *done = true;
+}
+
+bool
+tc_tdm_output_prepare(tdm_display *dpy, tdm_output *output, bool fill)
+{
+ tbm_surface_h buffer = NULL;
+ tdm_error ret;
+ int primary_index = -1;
+ tdm_layer *layer;
+ bool done = false;
+ tdm_output_conn_status status;
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(tc_tdm_output_is_connected(output) == true);
+ TDM_UT_RETURN_FALSE_IF_FAIL(tc_tdm_output_mode_setting(output) == true);
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON) == TDM_ERROR_NONE);
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_primary_index(output, &primary_index) == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(primary_index >= 0);
+
+ layer = tdm_output_get_layer(output, primary_index, &ret);
+ TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(layer != NULL);
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(tc_tdm_layer_prepare_buffer(layer, &buffer, 1, fill) == true);
+ TDM_UT_RETURN_FALSE_IF_FAIL(buffer != NULL);
+
+ TDM_UT_GOTO_IF_FAIL(tc_tdm_layer_set_buffer(layer, buffer) == true, failed);
+
+ if (tdm_helper_output_commit_per_vblank_enabled(output))
+ TDM_UT_GOTO_IF_FAIL(tdm_layer_commit(layer, NULL, NULL) == TDM_ERROR_NONE, failed);
+ else
+ TDM_UT_GOTO_IF_FAIL(tdm_output_commit(output, 0, NULL, NULL) == TDM_ERROR_NONE, failed);
+
+ TDM_UT_GOTO_IF_FAIL(tdm_output_get_conn_status(output, &status) == TDM_ERROR_NONE, failed);
+ TDM_UT_GOTO_IF_FAIL(status == TDM_OUTPUT_CONN_STATUS_MODE_SETTED, failed);
+
+ while (!done) {
+ TDM_UT_GOTO_IF_FAIL(tdm_output_wait_vblank(output, 1, 0, _tc_tdm_output_done_cb, &done) == TDM_ERROR_NONE, failed);
+ TDM_UT_GOTO_IF_FAIL(tc_tdm_display_handle_events(dpy) == TDM_ERROR_NONE, failed);
+ }
+
+ tbm_surface_internal_unref(buffer);
+
+ return true;
+failed:
+ tbm_surface_internal_unref(buffer);
+
+ return false;
+}
+
+bool
+tc_tdm_output_prepare_all_output(tdm_display *dpy, tdm_output **outputs, int output_count, bool fill)
+{
+ for (int o = 0; o < output_count; o++) {
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+ if (!tc_tdm_output_prepare(dpy, outputs[o], fill))
+ return false;
+ }
+ return true;
+}
+
+bool
+tc_tdm_output_unset(tdm_display *dpy, tdm_output *output)
+{
+ tdm_error ret;
+ int count = 0;
+ unsigned int pipe = 0;
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_layer_count(output, &count) == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(count > 0);
+
+ for (int l = 0; l < count; l++) {
+ tdm_layer *layer = tdm_output_get_layer(output, l, &ret);
+ TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(layer != NULL);
+
+ if (tc_tdm_layer_is_cursor_layer(layer))
+ continue;
+ if (tc_tdm_layer_is_video_layer(layer))
+ continue;
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_unset_buffer(layer) == TDM_ERROR_NONE);
+ }
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_pipe(output, &pipe) == TDM_ERROR_NONE);
+
+ TDM_INFO("unsetting output(%d) done", pipe);
+
+ return true;
+}
+
+/* msec */
+double
+tc_tdm_output_get_vblank_interval_time(tdm_output *output)
+{
+ const tdm_output_mode *mode = (const tdm_output_mode *)TDM_UT_INVALID_VALUE;
+ tdm_error ret = tdm_output_get_mode(output, &mode);
+
+ assert(ret == TDM_ERROR_NONE);
+ assert(mode != NULL);
+ assert(mode->vrefresh > 0);
+
+ return (double)1.0 / (double)mode->vrefresh;
+}
+
+TEST_P(TDMOutput, OutputGetBackendModule)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ tdm_error ret = (tdm_error)TDM_UT_INVALID_VALUE;
+ ASSERT_NE(tdm_output_get_backend_module(outputs[o], &ret), NULL);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ }
+}
+
+TEST_P(TDMOutput, OutputGetBackendModuleNullOBject)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ tdm_error ret = (tdm_error)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_output_get_backend_module(NULL, &ret), NULL);
+ ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMOutput, OutputGetBackendModuleNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ ASSERT_NE(tdm_output_get_backend_module(outputs[o], NULL), NULL);
+ }
+}
+
+TEST_P(TDMOutput, OutputGetCapabilities)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ tdm_output_capability capabilities = (tdm_output_capability)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_output_get_capabilities(outputs[o], &capabilities), TDM_ERROR_NONE);
+ ASSERT_NE(capabilities, TDM_UT_INVALID_VALUE);
+ }
+}
+
+TEST_P(TDMOutput, OutputGetCapabilitiesNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ tdm_output_capability capabilities = (tdm_output_capability)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_output_get_capabilities(NULL, &capabilities), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(capabilities, (tdm_output_capability)TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMOutput, OutputGetCapabilitiesNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(tdm_output_get_capabilities(outputs[0], NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMOutput, OutputGetModelInfo)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ const char *maker = NULL, *model = NULL, *name = NULL;
+ ASSERT_EQ(tdm_output_get_model_info(outputs[o], &maker, &model, &name), TDM_ERROR_NONE);
+ ASSERT_NE(maker, NULL);
+ ASSERT_NE(model, NULL);
+ ASSERT_NE(name, NULL);
+ }
+}
+
+TEST_P(TDMOutput, OutputGetModelInfoNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ const char *maker = (const char*)TDM_UT_INVALID_VALUE;
+ const char *model = (const char*)TDM_UT_INVALID_VALUE;
+ const char *name = (const char*)TDM_UT_INVALID_VALUE;
+
+ ASSERT_EQ(tdm_output_get_model_info(NULL, &maker, &model, &name), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(maker, (const char*)TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(model, (const char*)TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(name, (const char*)TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMOutput, OutputGetModelInfoNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(tdm_output_get_model_info(outputs[0], NULL, NULL, NULL), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMOutput, OutputGetConnStatus)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ tdm_output_conn_status status = (tdm_output_conn_status)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_output_get_conn_status(outputs[o], &status), TDM_ERROR_NONE);
+ ASSERT_NE(status, TDM_UT_INVALID_VALUE);
+ }
+}
+
+TEST_P(TDMOutput, OutputGetConnStatusNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ tdm_output_conn_status status = (tdm_output_conn_status)TDM_UT_INVALID_VALUE;
+
+ ASSERT_EQ(tdm_output_get_conn_status(NULL, &status), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(status, (tdm_output_conn_status)TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMOutput, OutputGetConnStatusNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(tdm_output_get_conn_status(outputs[0], NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMOutput, OutputGetOutputType)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ tdm_output_type type = (tdm_output_type)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_output_get_output_type(outputs[o], &type), TDM_ERROR_NONE);
+ ASSERT_NE(type, TDM_UT_INVALID_VALUE);
+ }
+}
+
+TEST_P(TDMOutput, OutputGetOutputTypeNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ tdm_output_type type = (tdm_output_type)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_output_get_output_type(NULL, &type), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(type, (tdm_output_type)TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMOutput, OutputGetOutputTypeNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(tdm_output_get_output_type(outputs[0], NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMOutput, OutputGetLayerCount)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ int count = TDM_UT_INVALID_VALUE;
+ if (tc_tdm_output_is_hwc_enable(outputs[o])) {
+ ASSERT_EQ(tdm_output_get_layer_count(outputs[o], &count), TDM_ERROR_BAD_REQUEST);
+ ASSERT_EQ(count, 0);
+ } else {
+ ASSERT_EQ(tdm_output_get_layer_count(outputs[o], &count), TDM_ERROR_NONE);
+ ASSERT_GT(count, 0);
+ }
+ }
+}
+
+TEST_P(TDMOutput, OutputGetLayerCountNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ int count = TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_output_get_layer_count(NULL, &count), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(count, TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMOutput, OutputGetLayerCountNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(tdm_output_get_layer_count(outputs[0], NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMOutput, OutputGetLayer)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ tdm_error ret;
+ tdm_layer *layer;
+ int layer_count = TDM_UT_INVALID_VALUE;
+
+ if (tc_tdm_output_is_hwc_enable(outputs[o])) {
+ ASSERT_EQ(tdm_output_get_layer_count(outputs[o], &layer_count), TDM_ERROR_BAD_REQUEST);
+ ASSERT_EQ(layer_count, 0);
+
+ layer = tdm_output_get_layer(outputs[o], 0, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_BAD_REQUEST);
+ ASSERT_EQ(layer, NULL);
+ } else {
+ ASSERT_EQ(tdm_output_get_layer_count(outputs[o], &layer_count), TDM_ERROR_NONE);
+ ASSERT_GT(layer_count, 0);
+
+ for (int l = 0; l < layer_count; l++) {
+ tdm_layer *layer = tdm_output_get_layer(outputs[o], l, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(layer, NULL);
+ }
+ }
+ }
+}
+
+TEST_P(TDMOutput, OutputGetLayerNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ tdm_error ret;
+ tdm_layer *layer = tdm_output_get_layer(NULL, 0, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(layer, NULL);
+}
+
+TEST_P(TDMOutput, OutputGetLayerNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ tdm_layer *layer;
+ if (tc_tdm_output_is_hwc_enable(outputs[0])) {
+ layer = tdm_output_get_layer(outputs[0], 0, NULL);
+ ASSERT_EQ(layer, NULL);
+ } else {
+ layer = tdm_output_get_layer(outputs[0], 0, NULL);
+ ASSERT_NE(layer, NULL);
+ }
+}
+
+TEST_P(TDMOutput, OutputGetAvailableProperties)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ int count = TDM_UT_INVALID_VALUE;
+ const tdm_prop *props = (const tdm_prop *)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_output_get_available_properties(outputs[o], &props, &count), TDM_ERROR_NONE);
+ ASSERT_GE(count, 0);
+ if (count > 0)
+ ASSERT_TRUE(props != NULL && props != (const tdm_prop *)TDM_UT_INVALID_VALUE);
+ }
+}
+
+TEST_P(TDMOutput, OutputGetAvailablePropertiesNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ const tdm_prop *props = (const tdm_prop *)TDM_UT_INVALID_VALUE;
+ int count = TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_output_get_available_properties(NULL, &props, &count), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(props, (const tdm_prop *)TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(count, TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMOutput, OutputGetAvailablePropertiesNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(tdm_output_get_available_properties(outputs[0], NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMOutput, OutputGetAvailableModes)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ int count = TDM_UT_INVALID_VALUE;
+ const tdm_output_mode *modes_array = (const tdm_output_mode *) TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_output_get_available_modes(outputs[o], &modes_array, &count), TDM_ERROR_NONE);
+ ASSERT_GT(count, 0);
+ ASSERT_TRUE(modes_array != NULL && modes_array != (const tdm_output_mode *)TDM_UT_INVALID_VALUE);
+ }
+}
+
+TEST_P(TDMOutput, OutputGetAvailableModesNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ int count = TDM_UT_INVALID_VALUE;
+ const tdm_output_mode *modes_array = (const tdm_output_mode *) TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_output_get_available_modes(NULL, &modes_array, &count), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(count, TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(modes_array, (const tdm_output_mode *) TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMOutput, OutputGetAvailableModesNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(tdm_output_get_available_modes(outputs[0], NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMOutput, OutputGetAvailableSize)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ int min_w = TDM_UT_INVALID_VALUE, min_h = TDM_UT_INVALID_VALUE;
+ int max_w = TDM_UT_INVALID_VALUE, max_h = TDM_UT_INVALID_VALUE;
+ int preferred_align = TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_output_get_available_size(outputs[o], &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_NONE);
+ ASSERT_NE(min_w, TDM_UT_INVALID_VALUE);
+ ASSERT_NE(min_h, TDM_UT_INVALID_VALUE);
+ ASSERT_NE(max_w, TDM_UT_INVALID_VALUE);
+ ASSERT_NE(max_h, TDM_UT_INVALID_VALUE);
+ ASSERT_NE(preferred_align, TDM_UT_INVALID_VALUE);
+ }
+}
+
+TEST_P(TDMOutput, OutputGetAvailableSizeNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ int min_w = TDM_UT_INVALID_VALUE, min_h = TDM_UT_INVALID_VALUE;
+ int max_w = TDM_UT_INVALID_VALUE, max_h = TDM_UT_INVALID_VALUE;
+ int preferred_align = TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_output_get_available_size(NULL, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(min_w, TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(min_h, TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(max_w, TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(max_h, TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(preferred_align, TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMOutput, OutputGetAvailableSizeNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(tdm_output_get_available_size(outputs[0], NULL, NULL, NULL, NULL, NULL), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMOutput, OutputGetCursorAvailableSize)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ int major = TDM_UT_INVALID_VALUE;
+ int minor = TDM_UT_INVALID_VALUE;
+
+ ASSERT_EQ(tdm_display_get_backend_info(dpy, NULL, NULL, &major, &minor), TDM_ERROR_NONE);
+ if (major > 1 || (major >= 1 && minor >= 5)) {
+ for (int o = 0; o < output_count; o++) {
+ int min_w = TDM_UT_INVALID_VALUE, min_h = TDM_UT_INVALID_VALUE;
+ int max_w = TDM_UT_INVALID_VALUE, max_h = TDM_UT_INVALID_VALUE;
+ int preferred_align = TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_output_get_cursor_available_size(outputs[o], &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_NONE);
+ ASSERT_NE(min_w, TDM_UT_INVALID_VALUE);
+ ASSERT_NE(min_h, TDM_UT_INVALID_VALUE);
+ ASSERT_NE(max_w, TDM_UT_INVALID_VALUE);
+ ASSERT_NE(max_h, TDM_UT_INVALID_VALUE);
+ ASSERT_NE(preferred_align, TDM_UT_INVALID_VALUE);
+ }
+ }
+}
+
+TEST_P(TDMOutput, OutputGetCursorAvailableSizeNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ int major = TDM_UT_INVALID_VALUE;
+ int minor = TDM_UT_INVALID_VALUE;
+
+ ASSERT_EQ(tdm_display_get_backend_info(dpy, NULL, NULL, &major, &minor), TDM_ERROR_NONE);
+ if (major > 1 || (major >= 1 && minor >= 5)) {
+ for (int o = 0; o < output_count; o++) {
+ int min_w = TDM_UT_INVALID_VALUE, min_h = TDM_UT_INVALID_VALUE;
+ int max_w = TDM_UT_INVALID_VALUE, max_h = TDM_UT_INVALID_VALUE;
+ int preferred_align = TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_output_get_cursor_available_size(NULL, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(min_w, TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(min_h, TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(max_w, TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(max_h, TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(preferred_align, TDM_UT_INVALID_VALUE);
+ }
+ }
+}
+
+TEST_P(TDMOutput, OutputGetCursorAvailableSizeNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ int major = TDM_UT_INVALID_VALUE;
+ int minor = TDM_UT_INVALID_VALUE;
+
+ ASSERT_EQ(tdm_display_get_backend_info(dpy, NULL, NULL, &major, &minor), TDM_ERROR_NONE);
+ if (major > 1 || (major >= 1 && minor >= 5))
+ ASSERT_EQ(tdm_output_get_cursor_available_size(outputs[0], NULL, NULL, NULL, NULL, NULL), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMOutput, OutputGetCursorAvailableSizeNoMatchVersion)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ int major = TDM_UT_INVALID_VALUE;
+ int minor = TDM_UT_INVALID_VALUE;
+
+ ASSERT_EQ(tdm_display_get_backend_info(dpy, NULL, NULL, &major, &minor), TDM_ERROR_NONE);
+ if (major <= 1 && minor < 5) {
+ for (int o = 0; o < output_count; o++) {
+ int min_w = TDM_UT_INVALID_VALUE, min_h = TDM_UT_INVALID_VALUE;
+ int max_w = TDM_UT_INVALID_VALUE, max_h = TDM_UT_INVALID_VALUE;
+ int preferred_align = TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_output_get_cursor_available_size(outputs[o], &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_BAD_REQUEST);
+ ASSERT_EQ(min_w, TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(min_h, TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(max_w, TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(max_h, TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(preferred_align, TDM_UT_INVALID_VALUE);
+ }
+ }
+}
+
+TEST_P(TDMOutput, OutputGetPhysicalSize)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ unsigned int mmWidth = (unsigned int)TDM_UT_INVALID_VALUE;
+ unsigned int mmHeight = (unsigned int)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_output_get_physical_size(outputs[o], &mmWidth, &mmHeight), TDM_ERROR_NONE);
+ ASSERT_NE(mmWidth, (unsigned int)TDM_UT_INVALID_VALUE);
+ ASSERT_NE(mmHeight, (unsigned int)TDM_UT_INVALID_VALUE);
+ }
+}
+
+TEST_P(TDMOutput, OutputGetPhysicalSizeNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ unsigned int mmWidth = (unsigned int)TDM_UT_INVALID_VALUE;
+ unsigned int mmHeight = (unsigned int)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_output_get_physical_size(NULL, &mmWidth, &mmHeight), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(mmWidth, (unsigned int)TDM_UT_INVALID_VALUE);
+ ASSERT_EQ(mmHeight, (unsigned int)TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMOutput, OutputGetPhysicalSizeNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(tdm_output_get_physical_size(outputs[0], NULL, NULL), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMOutput, OutputGetSubpixel)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ unsigned int subpixel = (unsigned int)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_output_get_subpixel(outputs[o], &subpixel), TDM_ERROR_NONE);
+ ASSERT_NE(subpixel, (unsigned int)TDM_UT_INVALID_VALUE);
+ }
+}
+
+TEST_P(TDMOutput, OutputGetSubpixelNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ unsigned int subpixel = (unsigned int)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_output_get_subpixel(NULL, &subpixel), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(subpixel, (unsigned int)TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMOutput, OutputGetSubpixelNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(tdm_output_get_subpixel(outputs[0], NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMOutput, OutputGetPipe)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ unsigned int pipe = (unsigned int)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_output_get_pipe(outputs[o], &pipe), TDM_ERROR_NONE);
+ ASSERT_NE(pipe, (unsigned int)TDM_UT_INVALID_VALUE);
+ }
+}
+
+TEST_P(TDMOutput, OutputGetPipeNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ unsigned int pipe = (unsigned int)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_output_get_pipe(NULL, &pipe), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(pipe, (unsigned int)TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMOutput, OutputGetPipeNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(tdm_output_get_pipe(outputs[0], NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMOutput, OutputGetPrimaryIndex)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ int primary_index = TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_output_get_primary_index(outputs[o], &primary_index), TDM_ERROR_NONE);
+ ASSERT_NE(primary_index, TDM_UT_INVALID_VALUE);
+ }
+}
+
+TEST_P(TDMOutput, OutputGetPrimaryIndexNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ int primary_index = TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_output_get_primary_index(NULL, &primary_index), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(primary_index, TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMOutput, OutputGetPrimaryIndexNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(tdm_output_get_primary_index(outputs[0], NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMOutput, DISABLED_OutputSetProperty)
+{
+}
+
+TEST_P(TDMOutput, OutputSetPropertyNullObject)
+{
+ tdm_value value = {.s32 = 0};
+
+ ASSERT_EQ(tdm_output_set_property(NULL, 0, value), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMOutput, OutputGetProperty)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ int count = TDM_UT_INVALID_VALUE;
+ const tdm_prop *props = (const tdm_prop *)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_output_get_available_properties(outputs[o], &props, &count), TDM_ERROR_NONE);
+ ASSERT_GE(count, 0);
+ if (count > 0) {
+ ASSERT_TRUE(props != NULL && props != (const tdm_prop *)TDM_UT_INVALID_VALUE);
+
+ for (int i = 0; i < count; i++) {
+ tdm_value value = {.s32 = TDM_UT_INVALID_VALUE};
+ ASSERT_EQ(tdm_output_get_property(outputs[o], props[i].id, &value), TDM_ERROR_NONE);
+ ASSERT_NE(value.s32, TDM_UT_INVALID_VALUE);
+ }
+ }
+ }
+}
+
+TEST_P(TDMOutput, OutputGetPropertyNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ tdm_value value = {.s32 = TDM_UT_INVALID_VALUE};
+ ASSERT_EQ(tdm_output_get_property(NULL, 0, &value), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(value.s32, TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMOutput, OutputGetPropertyNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(tdm_output_get_property(outputs[0], 0, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+static void
+_tc_tdm_output_change_cb(tdm_output *output, tdm_output_change_type type, tdm_value value, void *user_data)
+{
+ bool *done = (bool *)user_data;
+ if (done)
+ *done = true;
+}
+
+TEST_P(TDMOutput, OutputAddChangeHandler)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_prepare(dpy, outputs[o], true), true);
+
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
+
+ done1 = false;
+ ASSERT_EQ(tdm_output_add_change_handler(outputs[o], _tc_tdm_output_change_cb, &done1), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
+ ASSERT_EQ(done1, true);
+ }
+}
+
+TEST_P(TDMOutput, OutputAddChangeHandlerTwice)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(tdm_output_add_change_handler(outputs[0], _tc_tdm_output_change_cb, NULL), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_add_change_handler(outputs[0], _tc_tdm_output_change_cb, NULL), TDM_ERROR_BAD_REQUEST);
+}
+
+TEST_P(TDMOutput, OutputAddChangeHandlerNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(tdm_output_add_change_handler(NULL, _tc_tdm_output_change_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMOutput, OutputAddChangeHandlerNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(tdm_output_add_change_handler(outputs[0], NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMOutput, OutputRemoveChangeHandler)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ for (int t = 0; t < 10; t++) {
+ ASSERT_EQ(tdm_output_add_change_handler(outputs[o], _tc_tdm_output_change_cb, NULL), TDM_ERROR_NONE);
+ tdm_output_remove_change_handler(outputs[o], _tc_tdm_output_change_cb, NULL);
+ }
+ }
+}
+
+TEST_P(TDMOutput, OutputRemoveChangeHandlerDifferentData)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
+
+ done1 = false;
+ ASSERT_EQ(tdm_output_add_change_handler(outputs[o], _tc_tdm_output_change_cb, &done1), TDM_ERROR_NONE);
+ tdm_output_remove_change_handler(outputs[o], _tc_tdm_output_change_cb, NULL);
+
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
+ ASSERT_EQ(done1, true);
+ }
+}
+
+static void
+_tc_tdm_output_change_cb2(tdm_output *output, tdm_output_change_type type, tdm_value value, void *user_data)
+{
+ bool *done = (bool*)user_data;
+ if (done)
+ *done = true;
+ tdm_output_remove_change_handler(output, _tc_tdm_output_change_cb2, user_data);
+}
+
+TEST_P(TDMOutput, OutputRemoveChangeHandlerInHandler)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
+
+ done1 = false;
+ ASSERT_EQ(tdm_output_add_change_handler(outputs[o], _tc_tdm_output_change_cb2, &done1), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
+ ASSERT_EQ(done1, true);
+
+ done2 = false;
+ ASSERT_EQ(tdm_output_add_change_handler(outputs[o], _tc_tdm_output_change_cb, &done2), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
+ ASSERT_EQ(done2, true);
+
+ done3 = false;
+ ASSERT_EQ(tdm_output_add_change_handler(outputs[o], _tc_tdm_output_change_cb2, &done3), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
+ ASSERT_EQ(done3, true);
+ }
+}
+
+TEST_P(TDMOutput, OutputRemoveChangeHandlerNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ tdm_output_remove_change_handler(NULL, _tc_tdm_output_change_cb, NULL);
+}
+
+TEST_P(TDMOutput, OutputRemoveChangeHandlerNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ tdm_output_remove_change_handler(outputs[0], NULL, NULL);
+}
+
+TEST_P(TDMOutput, OutputSetMode)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ const tdm_output_mode *modes;
+ int count;
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tdm_output_get_available_modes(outputs[o], &modes, &count), TDM_ERROR_NONE);
+ ASSERT_NE(modes, NULL);
+ ASSERT_GT(count, 0);
+
+ for (int m = 0; m < count; m++)
+ ASSERT_EQ(tdm_output_set_mode(outputs[o], modes + m), TDM_ERROR_NONE);
+ }
+}
+
+TEST_P(TDMOutput, OutputSetModeNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ const tdm_output_mode *mode = (const tdm_output_mode *)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_output_set_mode(NULL, mode), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMOutput, OutputSetModeNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tdm_output_set_mode(outputs[o], NULL), TDM_ERROR_INVALID_PARAMETER);
+ }
+}
+
+TEST_P(TDMOutput, OutputGetMode)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ const tdm_output_mode *modes;
+ int count;
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tdm_output_get_available_modes(outputs[o], &modes, &count), TDM_ERROR_NONE);
+ ASSERT_NE(modes, NULL);
+ ASSERT_GT(count, 0);
+
+ for (int m = 0; m < count; m++) {
+ const tdm_output_mode *current_mode;
+ ASSERT_EQ(tdm_output_set_mode(outputs[o], modes + m), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_get_mode(outputs[o], ¤t_mode), TDM_ERROR_NONE);
+ ASSERT_EQ(current_mode, modes + m);
+ }
+ }
+}
+
+TEST_P(TDMOutput, OutputGetModeNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ const tdm_output_mode *current_mode = (const tdm_output_mode *)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_output_get_mode(NULL, ¤t_mode), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(current_mode, (const tdm_output_mode *)TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMOutput, OutputGetModeNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(tdm_output_get_mode(outputs[0], NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMOutput, OutputGetModeNoSet)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ const tdm_output_mode *mode;
+ ASSERT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE);
+ ASSERT_EQ(mode, NULL);
+ }
+}
+
+TEST_P(TDMOutput, OutputSetDpms)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_STANDBY), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_SUSPEND), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
+ if (tc_tdm_output_is_aod_enable(outputs[o])) {
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_AOD), TDM_ERROR_NONE);
+ } else {
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_AOD), TDM_ERROR_BAD_REQUEST);
+ }
+ }
+}
+
+TEST_P(TDMOutput, OutputSetDpmsNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(tdm_output_set_dpms(NULL, TDM_OUTPUT_DPMS_OFF), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMOutput, OutputSetDpmsNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(tdm_output_set_dpms(outputs[0], (tdm_output_dpms)-1), TDM_ERROR_BAD_REQUEST);
+ ASSERT_EQ(tdm_output_set_dpms(outputs[0], (tdm_output_dpms)INT_MAX), TDM_ERROR_BAD_REQUEST);
+}
+
+TEST_P(TDMOutput, OutputSetDpmsAsync)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+ if (!tc_tdm_output_is_async_dpms_enable(outputs[o]))
+ continue;
+
+ done1 = false;
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_add_change_handler(outputs[o], _tc_tdm_output_change_cb, &done1), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_set_dpms_async(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
+ while (!done1)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ tdm_output_remove_change_handler(outputs[o], _tc_tdm_output_change_cb, &done1);
+ }
+}
+
+TEST_P(TDMOutput, OutputGetDpms)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ tdm_output_dpms dpms_value;
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_get_dpms(outputs[o], &dpms_value), TDM_ERROR_NONE);
+ ASSERT_EQ(dpms_value, TDM_OUTPUT_DPMS_OFF);
+
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_STANDBY), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_get_dpms(outputs[o], &dpms_value), TDM_ERROR_NONE);
+ ASSERT_EQ(dpms_value, TDM_OUTPUT_DPMS_STANDBY);
+
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_SUSPEND), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_get_dpms(outputs[o], &dpms_value), TDM_ERROR_NONE);
+ ASSERT_EQ(dpms_value, TDM_OUTPUT_DPMS_SUSPEND);
+
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_get_dpms(outputs[o], &dpms_value), TDM_ERROR_NONE);
+ ASSERT_EQ(dpms_value, TDM_OUTPUT_DPMS_ON);
+
+ if (tc_tdm_output_is_aod_enable(outputs[o])) {
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_AOD), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_get_dpms(outputs[o], &dpms_value), TDM_ERROR_NONE);
+ ASSERT_EQ(dpms_value, TDM_OUTPUT_DPMS_AOD);
+ } else {
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_AOD), TDM_ERROR_BAD_REQUEST);
+ }
+ }
+}
+
+TEST_P(TDMOutput, OutputGetDpmsNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ tdm_output_dpms dpms_value = (tdm_output_dpms)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_output_get_dpms(NULL, &dpms_value), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(dpms_value, (tdm_output_dpms)TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMOutput, OutputGetDpmsNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(tdm_output_get_dpms(outputs[0], NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMOutput, OutputWaitVblank)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_prepare(dpy, outputs[o], true), true);
+
+ for (int t = 0; t < 10; t++) {
+ double start, end, interval;
+
+ interval = tc_tdm_output_get_vblank_interval_time(outputs[o]);
+
+ done1 = false;
+ start = tdm_helper_get_time();
+ ASSERT_EQ(tdm_output_wait_vblank(outputs[o], 1, 0, _tc_tdm_output_done_cb, &done1), TDM_ERROR_NONE);
+ while (!done1)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ end = tdm_helper_get_time();
+
+ /* "+ interval" consider the delay of socket communication between kernel and platform */
+ ASSERT_LT((end - start), (interval + interval));
+ }
+ }
+}
+
+TEST_P(TDMOutput, OutputWaitVblankNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(tdm_output_wait_vblank(NULL, 1, 0, _tc_tdm_output_done_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMOutput, OutputWaitVblankNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_prepare(dpy, outputs[o], true), true);
+
+ ASSERT_EQ(tdm_output_wait_vblank(outputs[o], 1, 0, NULL, NULL), TDM_ERROR_NONE);
+ }
+}
+
+TEST_P(TDMOutput, OutputWaitVblankTimeout)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_prepare(dpy, outputs[o], true), true);
+
+ ASSERT_EQ(tdm_output_wait_vblank(outputs[o], 1, 0, _tc_tdm_output_done_cb, NULL), TDM_ERROR_NONE);
+
+ usleep(1100000);
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+
+ ASSERT_GT(tdm_helper_output_vblank_timer_expired(outputs[o]), 0);
+ }
+}
+
+TEST_P(TDMOutput, OutputWaitVblankInterval0)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(tdm_output_wait_vblank(outputs[0], 0, 0, _tc_tdm_output_done_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMOutput, OutputWaitVblankInterval)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_prepare(dpy, outputs[o], true), true);
+
+ /* start from 1 */
+ for (int t = 1; t < 10; t++) {
+ double start, end, interval;
+
+ interval = tc_tdm_output_get_vblank_interval_time(outputs[o]);
+
+ done1 = false;
+ start = tdm_helper_get_time();
+ ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _tc_tdm_output_done_cb, &done1), TDM_ERROR_NONE);
+ while (!done1)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ end = tdm_helper_get_time();
+
+ /* "+ interval" consider the delay of socket communication between kernel and platform */
+ ASSERT_GT((end - start), (interval * (t - 1)));
+ ASSERT_LT((end - start), (interval * t + interval));
+ }
+ }
+}
+
+TEST_P(TDMOutput, OutputWaitVblankFewTimesInOneVblank)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_prepare(dpy, outputs[o], true), true);
+
+ /* start from 1 */
+ for (int t = 1; t < 10; t++) {
+ double start, end, interval;
+
+ interval = tc_tdm_output_get_vblank_interval_time(outputs[o]);
+
+ done1 = done2 = done3 = false;
+ ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _tc_tdm_output_done_cb, &done1), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _tc_tdm_output_done_cb, &done2), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _tc_tdm_output_done_cb, &done3), TDM_ERROR_NONE);
+
+ start = tdm_helper_get_time();
+ while (!done1 || !done2 || !done3)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ end = tdm_helper_get_time();
+
+ /* "+ interval" consider the delay of socket communication between kernel and platform */
+ ASSERT_GT((end - start), (interval * (t - 1)));
+ ASSERT_LT((end - start), (interval * t + interval));
+ }
+ }
+}
+
+TEST_P(TDMOutput, OutputWaitVblankBeforeDpmsOff)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_prepare(dpy, outputs[o], false), true);
+
+ for (int t = 0; t < 10; t++) {
+ bool done = false;
+
+ ASSERT_EQ(tdm_output_wait_vblank(outputs[o], 1, 0, _tc_tdm_output_done_cb, &done), TDM_ERROR_NONE);
+ if (t == 9)
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
+ while (!done)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ }
+ }
+}
+
+TEST_P(TDMOutput, OutputRemoveVblankHandler)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_prepare(dpy, outputs[o], true), true);
+
+ /* start from 1 */
+ for (int t = 1; t < 10; t++) {
+ done1 = done2 = done3 = false;
+ ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _tc_tdm_output_done_cb, &done1), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _tc_tdm_output_done_cb, &done2), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _tc_tdm_output_done_cb, &done3), TDM_ERROR_NONE);
+ tdm_output_remove_vblank_handler(outputs[o], _tc_tdm_output_done_cb, &done2);
+ while (!done1 || done2 || !done3)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ }
+ }
+}
+
+TEST_P(TDMOutput, OutputRemoveVblankHandlerDifferentData)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ tc_tdm_output_prepare(dpy, outputs[o], true);
+
+ /* start from 1 */
+ for (int t = 1; t < 10; t++) {
+ done1 = done2 = done3 = false;
+ ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _tc_tdm_output_done_cb, &done1), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _tc_tdm_output_done_cb, &done2), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _tc_tdm_output_done_cb, &done3), TDM_ERROR_NONE);
+ tdm_output_remove_vblank_handler(outputs[o], _tc_tdm_output_done_cb, NULL);
+ while (!done1 || !done2 || !done3)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ }
+ }
+}
+
+static void
+_tc_tdm_output_done_cb2(tdm_output *output, unsigned int sequence,
+ unsigned int tv_sec, unsigned int tv_usec,
+ void *user_data)
+{
+ bool *done = (bool*)user_data;
+ if (done)
+ *done = true;
+ tdm_output_remove_commit_handler(output, _tc_tdm_output_done_cb2, user_data);
+}
+
+TEST_P(TDMOutput, OutputRemoveVblankHandlerInHandler)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_prepare(dpy, outputs[o], true), true);
+
+ /* start from 1 */
+ for (int t = 1; t < 10; t++) {
+ done1 = done2 = done3 = false;
+ ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _tc_tdm_output_done_cb, &done1), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _tc_tdm_output_done_cb, &done2), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _tc_tdm_output_done_cb, &done3), TDM_ERROR_NONE);
+ while (!done1 || !done2 || !done3)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ }
+ }
+}
+
+TEST_P(TDMOutput, OutputCommit)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ /* if true, have to use tdm_layer_commit. so skip */
+ if (tdm_helper_output_commit_per_vblank_enabled(outputs[o]))
+ continue;
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_prepare(dpy, outputs[o], true), true);
+
+ for (int t = 0; t < 10; t++) {
+ double start, end, interval;
+
+ interval = tc_tdm_output_get_vblank_interval_time(outputs[o]);
+
+ done1 = false;
+ start = tdm_helper_get_time();
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, _tc_tdm_output_done_cb, &done1), TDM_ERROR_NONE);
+ while (!done1)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ end = tdm_helper_get_time();
+
+ /* "+ interval" consider the delay of socket communication between kernel and platform */
+ ASSERT_LT((end - start), (interval + interval));
+ }
+ }
+}
+
+TEST_P(TDMOutput, OutputCommitNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(tdm_output_commit(NULL, 0, _tc_tdm_output_done_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMOutput, OutputCommitNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ /* if true, have to use tdm_layer_commit. so skip */
+ if (tdm_helper_output_commit_per_vblank_enabled(outputs[o]))
+ continue;
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
+ }
+}
+
+TEST_P(TDMOutput, OutputCommitDpmsSuspend)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ /* if true, have to use tdm_layer_commit. so skip */
+ if (tdm_helper_output_commit_per_vblank_enabled(outputs[o]))
+ continue;
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_prepare(dpy, outputs[o], true), true);
+
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_SUSPEND), TDM_ERROR_NONE);
+
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, _tc_tdm_output_done_cb, NULL), TDM_ERROR_DPMS_OFF);
+ }
+}
+
+TEST_P(TDMOutput, OutputCommitDpmsOff)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ /* if true, have to use tdm_layer_commit. so skip */
+ if (tdm_helper_output_commit_per_vblank_enabled(outputs[o]))
+ continue;
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_prepare(dpy, outputs[o], true), true);
+
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
+
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, _tc_tdm_output_done_cb, NULL), TDM_ERROR_DPMS_OFF);
+ }
+}
+
+TEST_P(TDMOutput, OutputCommitDpmsAOD)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ /* if true, have to use tdm_layer_commit. so skip */
+ if (tdm_helper_output_commit_per_vblank_enabled(outputs[o]))
+ continue;
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ if (!tc_tdm_output_is_aod_enable(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_prepare(dpy, outputs[o], true), true);
+
+ ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_AOD), TDM_ERROR_NONE);
+
+ for (int t = 0; t < 10; t++) {
+ done1 = false;
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, _tc_tdm_output_done_cb, &done1), TDM_ERROR_NONE);
+ while (!done1)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ }
+ }
+}
+
+TEST_P(TDMOutput, OutputCommitAfterLayerCommit)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ int index = TDM_UT_INVALID_VALUE;
+ tdm_layer *layer;
+ tdm_error ret;
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_prepare(dpy, outputs[o], true), true);
+
+ ASSERT_EQ(tdm_output_get_primary_index(outputs[o], &index), TDM_ERROR_NONE);
+ ASSERT_NE(index, TDM_UT_INVALID_VALUE);
+
+ layer = tdm_output_get_layer(outputs[o], index, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(layer, NULL);
+
+ ASSERT_EQ(tdm_layer_commit(layer, NULL, NULL), TDM_ERROR_NONE);
+
+ if (!tdm_helper_output_commit_per_vblank_enabled(outputs[o]))
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
+ else
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_BAD_REQUEST);
+ }
+}
+
+TEST_P(TDMOutput, OutputCommitMismatchCommitType)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ if (!tdm_helper_output_commit_per_vblank_enabled(outputs[o]))
+ continue;
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_BAD_REQUEST);
+ }
+}
+
+TEST_P(TDMOutput, OutputCommitFewTimesInOneVblank)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ /* if true, have to use tdm_layer_commit. so skip */
+ if (tdm_helper_output_commit_per_vblank_enabled(outputs[o]))
+ continue;
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_prepare(dpy, outputs[o], true), true);
+
+ for (int t = 0; t < 10; t++) {
+ done1 = done2 = done3 = false;
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, _tc_tdm_output_done_cb, &done1), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, _tc_tdm_output_done_cb, &done2), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, _tc_tdm_output_done_cb, &done3), TDM_ERROR_NONE);
+ while (!done1 || !done2 || !done3)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ }
+ }
+}
+
+//TODO
+TEST_P(TDMOutput, DISABLED_OutputCommitBeforeDpmsOff)
+{
+ /* output commit -> dpms off -> then? (commit handler is called? or not?) */
+}
+
+TEST_P(TDMOutput, OutputRemoveCommitHandler)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ /* if true, have to use tdm_layer_commit. so skip */
+ if (tdm_helper_output_commit_per_vblank_enabled(outputs[o]))
+ continue;
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_prepare(dpy, outputs[o], true), true);
+
+ for (int t = 0; t < 10; t++) {
+ done1 = done2 = done3 = false;
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, _tc_tdm_output_done_cb, &done1), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, _tc_tdm_output_done_cb, &done2), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, _tc_tdm_output_done_cb, &done3), TDM_ERROR_NONE);
+ tdm_output_remove_commit_handler(outputs[o], _tc_tdm_output_done_cb, &done2);
+ while (!done1 || done2 || !done3)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ }
+ }
+}
+
+TEST_P(TDMOutput, OutputRemoveCommitHandlerDifferentData)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ /* if true, have to use tdm_layer_commit. so skip */
+ if (tdm_helper_output_commit_per_vblank_enabled(outputs[o]))
+ continue;
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_prepare(dpy, outputs[o], true), true);
+
+ for (int t = 0; t < 10; t++) {
+ done1 = done2 = done3 = false;
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, _tc_tdm_output_done_cb, &done1), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, _tc_tdm_output_done_cb, &done2), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, _tc_tdm_output_done_cb, &done3), TDM_ERROR_NONE);
+ tdm_output_remove_commit_handler(outputs[o], _tc_tdm_output_done_cb, NULL);
+ while (!done1 || !done2 || !done3)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ }
+ }
+}
+
+TEST_P(TDMOutput, OutputRemoveCommitHandlerInHandler)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ /* if true, have to use tdm_layer_commit. so skip */
+ if (tdm_helper_output_commit_per_vblank_enabled(outputs[o]))
+ continue;
+
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_EQ(tc_tdm_output_prepare(dpy, outputs[o], true), true);
+
+ for (int t = 0; t < 10; t++) {
+ done1 = done2 = done3 = false;
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, _tc_tdm_output_done_cb2, &done1), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, _tc_tdm_output_done_cb2, &done2), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_output_commit(outputs[o], 0, _tc_tdm_output_done_cb2, &done3), TDM_ERROR_NONE);
+ while (!done1 || !done2 || !done3)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ }
+ }
+}
+
+#ifdef TDM_UT_TEST_WITH_PARAMS
+INSTANTIATE_TEST_CASE_P(TDMOutputParams,
+ TDMOutput,
+ Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
+#else
+INSTANTIATE_TEST_CASE_P(TDMOutputParams,
+ TDMOutput,
+ Values(TDM_DEFAULT_MODULE));
+#endif
+
+/* LCOV_EXCL_END */
\ No newline at end of file
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
+ * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
+ * Contact: Roman Marchenko <r.marchenko@samsung.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+**************************************************************************/
+
+#include "tc_tdm.h"
+
+/* LCOV_EXCL_START */
+
+class TDMOutputHwc : public TDMOutput
+{
+public:
+ TDMOutputHwc();
+ void SetUp(void);
+ void TearDown(void);
+
+ tdm_error error;
+};
+
+TDMOutputHwc::TDMOutputHwc()
+{
+ error = TDM_ERROR_NONE;
+}
+
+void TDMOutputHwc::SetUp(void)
+{
+ TDMOutput::SetUp();
+}
+
+void TDMOutputHwc::TearDown(void)
+{
+ TDMOutput::TearDown();
+}
+
+/* tdm_hwc_window * tdm_hwc_create_window(tdm_output *output, tdm_error *error); */
+TEST_P(TDMOutputHwc, CreateWindowFailNull)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(NULL, tdm_hwc_create_window(NULL, &error));
+ ASSERT_NE(TDM_ERROR_NONE, error);
+}
+
+/*
+TEST_P(TDMOutputHwc, CreateWindowSuccessful)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ tdm_hwc_window * hw = NULL;
+
+ for (int o = 0; o < output_count; o++) {
+ if (tc_tdm_output_is_hwc_enable(outputs[o])) {
+ hw = tdm_hwc_create_window(hwc[o], &error);
+ ASSERT_EQ(TDM_ERROR_NONE, error);
+ tdm_hwc_window_destroy(hw);
+ } else {
+ ASSERT_EQ(NULL, tdm_hwc_create_window(outputs[o], &error));
+ ASSERT_NE(TDM_ERROR_NONE, error);
+ }
+ }
+}
+*/
+
+/* tdm_error tdm_hwc_set_client_target_buffer(tdm_output *output,
+ tbm_surface_h target_buffer, tdm_region damage,
+ tdm_hwc_window *composited_wnds, uint32_t num_wnds); */
+/* TDOO: need to be fixed
+TEST_P(TDMOutputHwc, SetClientTargetBufferFailNullOutput)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ tdm_region reg;
+ tbm_surface_h target_buff = CreateBufferForOutput(0);
+ error = tdm_hwc_set_client_target_buffer(NULL, target_buff, reg, NULL, 0 );
+ tbm_surface_internal_destroy(target_buff);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+}
+
+TEST_P(TDMOutputHwc, SetClientTargetBufferFailNoHwc)
+{
+ tdm_region damage = {.num_rects = 0, .rects = NULL};
+
+ for (int o = 0; o < output_count; o++) {
+ tbm_surface_h target_buff = CreateBufferForOutput(i);
+ ASSERT_NE(NULL, target_buff);
+ error = tdm_hwc_set_client_target_buffer(outputs[o], target_buff, damage, NULL, 0);
+ tbm_surface_internal_destroy(target_buff);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+ }
+}
+
+TEST_P(TDMOutputHwc, SetClientTargetBufferSuccessfulSetBuff)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ tdm_region damage = {.num_rects = 0, .rects = NULL};
+
+ for (int o = 0; o < output_count; o++) {
+ tbm_surface_h target_buff = CreateBufferForOutput(i);
+ ASSERT_NE(NULL, target_buff);
+ if (tc_tdm_output_is_hwc_enable(outputs[o])) {
+ error = tdm_hwc_set_client_target_buffer(outputs[o], target_buff, damage,
+ NULL, 0);
+ tbm_surface_internal_destroy(target_buff);
+ ASSERT_EQ(TDM_ERROR_NONE, error);
+ } else {
+ error = tdm_hwc_set_client_target_buffer(outputs[o], target_buff, damage,
+ NULL, 0);
+ tbm_surface_internal_destroy(target_buff);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+ }
+ }
+}
+
+TEST_P(TDMOutputHwc, SetClientTargetBufferSuccessfulResetBuff)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ tdm_region damage = {.num_rects = 0, .rects = NULL};
+
+ for (int o = 0; o < output_count; o++) {
+ if (tc_tdm_output_is_hwc_enable(outputs[o])) {
+ error = tdm_hwc_set_client_target_buffer(outputs[o], NULL, damage,
+ NULL, 0);
+ ASSERT_EQ(TDM_ERROR_NONE, error);
+ } else {
+ error = tdm_hwc_set_client_target_buffer(outputs[o], NULL, damage,
+ NULL, 0);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+ }
+ }
+}
+*/
+
+/* tbm_surface_queue_h tdm_hwc_get_client_target_buffer_queue(tdm_output *output, tdm_error *error); */
+/*
+TEST_P(TDMOutputHwc, GetTargetBufferQueueFailNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ tbm_surface_queue_h queue = NULL;
+
+ queue = tdm_hwc_get_client_target_buffer_queue(NULL, &error);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+ ASSERT_EQ(NULL, queue);
+
+ queue = tdm_hwc_get_client_target_buffer_queue(NULL, NULL);
+ ASSERT_EQ(NULL, queue);
+}
+
+TEST_P(TDMOutputHwc, GetTargetBufferQueueFainNoHwc)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ tbm_surface_queue_h queue = NULL;
+
+ for (int o = 0; o < output_count; o++) {
+ queue = tdm_hwc_get_client_target_buffer_queue(outputs[o], &error);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+ ASSERT_EQ(NULL, queue);
+ }
+}
+*/
+
+TEST_P(TDMOutputHwc, GetTargetBufferQueueSuccessful)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ tbm_surface_queue_h queue = NULL;
+
+ for (int o = 0; o < output_count; o++) {
+ if (tc_tdm_output_is_hwc_enable(outputs[o])) {
+ queue = tdm_hwc_get_client_target_buffer_queue(outputs[o], &error);
+ tbm_surface_queue_destroy(queue);
+ ASSERT_EQ(TDM_ERROR_NONE, error);
+ ASSERT_NE(NULL, queue);
+
+ queue = tdm_hwc_get_client_target_buffer_queue(outputs[o], NULL);
+ tbm_surface_queue_destroy(queue);
+ ASSERT_EQ(TDM_ERROR_NONE, error);
+ ASSERT_NE(NULL, queue);
+ } else {
+ queue = tdm_hwc_get_client_target_buffer_queue(outputs[o], &error);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+ ASSERT_EQ(NULL, queue);
+
+ queue = tdm_hwc_get_client_target_buffer_queue(outputs[o], NULL);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+ ASSERT_EQ(NULL, queue);
+ }
+ }
+}
+
+/* tdm_error tdm_hwc_validate(tdm_output *output, tdm_hwc_window **composited_wnds, uint32_t num_wnds,
+ uint32_t *num_types); */
+/* TODO: fix the validate test later.
+TEST_P(TDMOutputHwc, ValidateFailNull)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ uint32_t num_types;
+ error = tdm_hwc_validate(NULL, NULL, 0, &num_types);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+
+ if (outputs[0]) {
+ error = tdm_hwc_validate(outputs[0], NULL, 0, NULL);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+ }
+}
+
+TEST_P(TDMOutputHwc, ValidateFailNoHwc)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ uint32_t num_types;
+
+ for (int o = 0; o < output_count; o++) {
+ error = tdm_hwc_validate(outputs[o], &num_types);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+ }
+}
+
+TEST_P(TDMOutputHwc, ValidateSuccessful)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ uint32_t num_types;
+ for (int o = 0; o < output_count; o++) {
+ if (tc_tdm_output_is_hwc_enable(outputs[o])) {
+ error = tdm_hwc_validate(outputs[o], &num_types);
+ ASSERT_EQ(TDM_ERROR_NONE, error);
+ } else {
+ error = tdm_hwc_validate(outputs[o], &num_types);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+ }
+ }
+}
+TODO: */
+
+/* tdm_error tdm_hwc_get_changed_composition_types(tdm_hwc *hwc,
+ uint32_t *num_elements, tdm_hwc_window **hwc_window,
+ tdm_hwc_window_composition *composition_types); */
+/*
+TEST_P(TDMOutputHwc, GetChangedCompositionTypesFailNull)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ uint32_t num_elements;
+
+ error = tdm_hwc_get_changed_composition_types(NULL, &num_elements, NULL, NULL);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+
+ if (outputs[0]) {
+ error = tdm_hwc_get_changed_composition_types(outputs[0], NULL, NULL, NULL);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+ }
+}
+
+TEST_P(TDMOutputHwc, GetChangedCompositionTypesFailNoHwc)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ uint32_t get_num = 10;
+
+ for (int o = 0; o < output_count; o++) {
+ error = tdm_hwc_get_changed_composition_types(outputs[o], &get_num, NULL, NULL);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+ }
+}
+*/
+/* TODO: fix the validate test later.
+TEST_P(TDMHwcWindow, GetChangedCompositionTypesSuccessful)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ uint32_t validate_num;
+ uint32_t get_num = 0;
+
+ tdm_hwc_window_composition *composition_types;
+ tdm_hwc_window **hwc_wnds;
+
+ for (int i = 0; i < hwc_count; i++) {
+ error = tdm_hwc_window_set_composition_type(hwc_wins[o], TDM_COMPOSITION_DEVICE);
+ ASSERT_EQ(TDM_ERROR_NONE, error);
+ }
+
+
+ for (int i = 0; i < output_count; i++) {
+ if (tc_tdm_output_is_hwc_enable(outputs[o])) {
+ error = tdm_hwc_validate(outputs[o], &validate_num);
+ ASSERT_EQ(TDM_ERROR_NONE, error);
+
+ error = tdm_hwc_get_changed_composition_types(outputs[o], &get_num, NULL, NULL);
+ ASSERT_EQ(TDM_ERROR_NONE, error);
+
+ ASSERT_EQ(get_num, validate_num);
+ hwc_wnds = (tdm_hwc_window **)calloc(get_num, sizeof(tdm_hwc_window *));
+ composition_types = (tdm_hwc_window_composition *)calloc(get_num, sizeof(tdm_hwc_window_composition));
+
+ error = tdm_hwc_get_changed_composition_types(outputs[o], &get_num, hwc_wnds, composition_types);
+
+ free(hwc_wnds);
+ free(composition_types);
+
+ ASSERT_EQ(TDM_ERROR_NONE, error);
+ } else {
+ error = tdm_hwc_get_changed_composition_types(outputs[o], &get_num, NULL, NULL);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+ }
+ }
+}
+*/
+
+/* tdm_error tdm_hwc_accept_changes(tdm_hwc *hwc); */
+/*
+TEST_P(TDMOutputHwc, AcceptChangesFailNull)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ error = tdm_hwc_accept_changes(NULL);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+}
+
+TEST_P(TDMOutputHwc, AcceptChangesFailNoHwc)
+{
+ for (int o = 0; o < output_count; o++) {
+ error = tdm_hwc_accept_changes(outputs[o]);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+ }
+}
+*/
+/* TODO: fix the validate test later.
+TEST_P(TDMHwcWindow, AcceptChangesSuccessful)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ uint32_t validate_num;
+
+ for (int i = 0; i < hwc_count; i++) {
+ error = tdm_hwc_window_set_composition_type(hwc_wins[o], TDM_COMPOSITION_DEVICE);
+ ASSERT_EQ(TDM_ERROR_NONE, error);
+ }
+
+ for (int i = 0; i < output_count; i++) {
+ if (tc_tdm_output_is_hwc_enable(outputs[o])) {
+ error = tdm_hwc_validate(outputs[o], &validate_num);
+ ASSERT_EQ(TDM_ERROR_NONE, error);
+
+ if (validate_num > 0) {
+ error = tdm_hwc_accept_changes(outputs[o]);
+ ASSERT_EQ(TDM_ERROR_NONE, error);
+ }
+ }
+ }
+}
+*/
+
+/* tdm_hwc_get_supported_formats() */
+/*
+TEST_P(TDMOutputHwc, GetVideoSupportedFormatsFailNull)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ tdm_error error;
+
+ error = tdm_hwc_get_supported_formats(NULL, NULL, NULL);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+}
+
+TEST_P(TDMOutputHwc, GetVideoSupportedFormatsSuccessful)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ tdm_error error;
+ const tbm_format *formats;
+ int count;
+
+ for (int o = 0; o < output_count; o++) {
+ if (tc_tdm_output_is_hwc_enable(outputs[o])) {
+ error = tdm_hwc_get_supported_formats(outputs[o], &formats, &count);
+ if (error != TDM_ERROR_NOT_IMPLEMENTED) {
+ ASSERT_EQ(TDM_ERROR_NONE, error);
+ if (count > 0)
+ ASSERT_NE(NULL, formats);
+ }
+ } else {
+ error = tdm_hwc_get_supported_formats(outputs[o], &formats, &count);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+ }
+ }
+}
+*/
+
+#ifdef TDM_UT_TEST_WITH_PARAMS
+INSTANTIATE_TEST_CASE_P(TDMOutputHwcParams,
+ TDMOutputHwc,
+ Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
+#else
+INSTANTIATE_TEST_CASE_P(TDMOutputHwcParams,
+ TDMOutputHwc,
+ Values(TDM_DEFAULT_MODULE));
+#endif
+
+/* LCOV_EXCL_END */
\ No newline at end of file
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
+ * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
+ * Contact: Roman Marchenko <r.marchenko@samsung.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+**************************************************************************/
+
+#include "tc_tdm.h"
+
+/* LCOV_EXCL_START */
+
+static void _tc_tdm_vblank_create_cb(tdm_vblank *vblank, void *user_data);
+static void _tc_tdm_vblank_create_cb2(tdm_vblank *vblank, void *user_data);
+
+class TDMVblank : public TDMOutput
+{
+public:
+ bool has_vblanks;
+
+ tdm_vblank **vblanks;
+ int vblank_count;
+
+ bool done;
+
+ TDMVblank();
+ void SetUp(void);
+ void TearDown(void);
+
+ bool TestCreateVblanks(void);
+ bool TestCreateVblanks3(void);
+ void TestDestroyVblanks(void);
+
+ bool TestPrepareOutput(void);
+};
+
+TDMVblank::TDMVblank()
+{
+ has_vblanks = false;
+ vblanks = NULL;
+ vblank_count = 0;
+ done = false;
+}
+
+void TDMVblank::SetUp(void)
+{
+ TDMOutput::SetUp();
+}
+
+void TDMVblank::TearDown(void)
+{
+ tdm_vblank_remove_create_handler(dpy, _tc_tdm_vblank_create_cb, this);
+ tdm_vblank_remove_create_handler(dpy, _tc_tdm_vblank_create_cb, NULL);
+ tdm_vblank_remove_create_handler(dpy, _tc_tdm_vblank_create_cb2, this);
+ tdm_vblank_remove_create_handler(dpy, _tc_tdm_vblank_create_cb2, NULL);
+
+ TestDestroyVblanks();
+
+ tdm_vblank_enable_global_fps(0, 0);
+
+ TDMOutput::TearDown();
+}
+
+bool TDMVblank::TestCreateVblanks(void)
+{
+ TDM_UT_GOTO_IF_FAIL(output_count > 0, failed);
+
+ vblanks = (tdm_vblank**)calloc(output_count, sizeof(tdm_vblank*));
+ TDM_UT_GOTO_IF_FAIL(vblanks != NULL, failed);
+
+ vblank_count = output_count;
+ has_vblanks = true;
+
+ for (int v = 0; v < vblank_count; v++) {
+ tdm_error ret;
+ vblanks[v] = tdm_vblank_create(dpy, outputs[v], &ret);
+ TDM_UT_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, failed);
+ TDM_UT_GOTO_IF_FAIL(vblanks[v] != NULL, failed);
+ }
+
+ return true;
+failed:
+ TestDestroyVblanks();
+ has_vblanks = false;
+ return false;
+}
+
+bool TDMVblank::TestCreateVblanks3(void)
+{
+ TDM_UT_GOTO_IF_FAIL(output_count > 0, failed);
+
+ tdm_error ret;
+
+ vblank_count = 0;
+
+ for (int o = 0; o < output_count; o++) {
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ vblank_count = 3;
+ has_vblanks = true;
+
+ vblanks = (tdm_vblank**)calloc(vblank_count, sizeof(tdm_vblank*));
+ TDM_UT_GOTO_IF_FAIL(vblanks != NULL, failed);
+
+ for (int v = 0; v < vblank_count; v++) {
+ vblanks[v] = tdm_vblank_create(dpy, outputs[o], &ret);
+ TDM_UT_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, failed);
+ TDM_UT_GOTO_IF_FAIL(vblanks[v] != NULL, failed);
+ }
+
+ break;
+ }
+
+ return true;
+failed:
+ TestDestroyVblanks();
+ has_vblanks = false;
+ return false;
+}
+
+void TDMVblank::TestDestroyVblanks(void)
+{
+ if (vblanks) {
+ for (int v = 0; v < vblank_count; v++)
+ tdm_vblank_destroy(vblanks[v]);
+ free(vblanks);
+ vblanks = NULL;
+ }
+ vblank_count = 0;
+
+}
+
+bool TDMVblank::TestPrepareOutput(void)
+{
+ for (int o = 0; o < output_count; o++) {
+ if (!tc_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(tc_tdm_output_prepare(dpy, outputs[o], false) == true);
+ }
+
+ return true;
+}
+
+bool tc_tdm_vblank_is_avaiable(tdm_vblank *vblank)
+{
+ tdm_error ret;
+ tdm_output *output = tdm_vblank_get_output(vblank, &ret);
+ TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(output != NULL);
+
+ /* only check if connected */
+ return tc_tdm_output_is_connected(output);
+}
+
+/* tdm_vblank_set_client_vblank_fps */
+TEST_P(TDMVblank, DISABLED_VblankSetClientVblankFps)
+{
+ /* tested in tc_tdm_client.c */
+}
+
+TEST_P(TDMVblank, VblankSetClientVblankFpsNullObject)
+{
+ ASSERT_EQ(tdm_vblank_set_client_vblank_fps(0, NULL, 60), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(tdm_vblank_set_client_vblank_fps(123, NULL, 0), TDM_ERROR_INVALID_PARAMETER);
+}
+
+/* tdm_vblank_set_client_vblank_fps */
+TEST_P(TDMVblank, DISABLED_VblankSetClientIgnoreGlobalFps)
+{
+ /* tested in tc_tdm_client.c */
+}
+
+TEST_P(TDMVblank, VblankSetClientIgnoreGlobalFpsNullObject)
+{
+ ASSERT_EQ(tdm_vblank_set_client_ignore_global_fps(0, NULL, 0), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(tdm_vblank_set_client_ignore_global_fps(0, NULL, 1), TDM_ERROR_INVALID_PARAMETER);
+}
+
+/* tdm_vblank_create() */
+TEST_P(TDMVblank, VblankCreateDestroy)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ for (int o = 0; o < output_count; o++) {
+ tdm_error ret;
+ tdm_vblank *vblank = tdm_vblank_create(dpy, outputs[o], &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(vblank, NULL);
+
+ tdm_vblank_destroy(vblank);
+ }
+}
+
+TEST_P(TDMVblank, VblankCreateNullDpy)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ tdm_error ret;
+
+ tdm_vblank *vblank = tdm_vblank_create(NULL, outputs[0], &ret);
+ ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(vblank, NULL);
+}
+
+TEST_P(TDMVblank, VblankCreateNullOutput)
+{
+ tdm_error ret;
+
+ tdm_vblank *vblank = tdm_vblank_create(dpy, NULL, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(vblank, NULL);
+}
+
+TEST_P(TDMVblank, VblankCreateNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ tdm_vblank *vblank = tdm_vblank_create(dpy, outputs[0], NULL);
+ ASSERT_NE(vblank, NULL);
+
+ tdm_vblank_destroy(vblank);
+}
+
+/* tdm_vblank_destroy() */
+TEST_P(TDMVblank, VblankDestroyNullObject)
+{
+ tdm_vblank_destroy(NULL);
+}
+
+static void
+_tc_tdm_vblank_create_cb(tdm_vblank *vblank, void *user_data)
+{
+ TDMVblank *test_vblank = (TDMVblank*)user_data;
+ if (test_vblank)
+ test_vblank->done = true;
+}
+
+/* tdm_vblank_add_create_handler */
+TEST_P(TDMVblank, VblankAddCreateHandler)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(tdm_vblank_add_create_handler(dpy, _tc_tdm_vblank_create_cb, this), TDM_ERROR_NONE);
+
+ for (int o = 0; o < output_count; o++) {
+ tdm_error ret;
+
+ done = false;
+
+ tdm_vblank *vblank = tdm_vblank_create(dpy, outputs[o], &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(vblank, NULL);
+ ASSERT_EQ(done, true);
+
+ tdm_vblank_destroy(vblank);
+ }
+}
+
+TEST_P(TDMVblank, VblankAddCreateHandlerTwice)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(tdm_vblank_add_create_handler(dpy, _tc_tdm_vblank_create_cb, NULL), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_vblank_add_create_handler(dpy, _tc_tdm_vblank_create_cb, NULL), TDM_ERROR_BAD_REQUEST);
+}
+
+TEST_P(TDMVblank, VblankAddCreateHandlerNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(tdm_vblank_add_create_handler(NULL, _tc_tdm_vblank_create_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMVblank, VblankAddCreateHandlerNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(tdm_vblank_add_create_handler(dpy, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+/* tdm_vblank_remove_create_handler */
+TEST_P(TDMVblank, VblankRemoveCreateHandler)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(tdm_vblank_add_create_handler(dpy, _tc_tdm_vblank_create_cb, this), TDM_ERROR_NONE);
+ tdm_vblank_remove_create_handler(dpy, _tc_tdm_vblank_create_cb, this);
+
+ for (int o = 0; o < output_count; o++) {
+ tdm_error ret;
+
+ done = false;
+
+ tdm_vblank *vblank = tdm_vblank_create(dpy, outputs[o], &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(vblank, NULL);
+ ASSERT_EQ(done, false);
+
+ tdm_vblank_destroy(vblank);
+ }
+}
+
+TEST_P(TDMVblank, VblankRemoveCreateHandlerFewTimes)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(tdm_vblank_add_create_handler(dpy, _tc_tdm_vblank_create_cb, this), TDM_ERROR_NONE);
+
+ tdm_vblank_remove_create_handler(dpy, _tc_tdm_vblank_create_cb, this);
+ tdm_vblank_remove_create_handler(dpy, _tc_tdm_vblank_create_cb, this);
+ tdm_vblank_remove_create_handler(dpy, _tc_tdm_vblank_create_cb, this);
+
+ for (int o = 0; o < output_count; o++) {
+ tdm_error ret;
+
+ done = false;
+
+ tdm_vblank *vblank = tdm_vblank_create(dpy, outputs[o], &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(vblank, NULL);
+ ASSERT_EQ(done, false);
+
+ tdm_vblank_destroy(vblank);
+ }
+}
+
+TEST_P(TDMVblank, VblankRemoveCreateHandlerDifferentData)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(tdm_vblank_add_create_handler(dpy, _tc_tdm_vblank_create_cb, this), TDM_ERROR_NONE);
+
+ tdm_vblank_remove_create_handler(dpy, _tc_tdm_vblank_create_cb, NULL);
+
+ for (int o = 0; o < output_count; o++) {
+ tdm_error ret;
+
+ done = false;
+
+ tdm_vblank *vblank = tdm_vblank_create(dpy, outputs[o], &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(vblank, NULL);
+ ASSERT_EQ(done, true);
+
+ tdm_vblank_destroy(vblank);
+ }
+}
+
+static void
+_tc_tdm_vblank_create_cb2(tdm_vblank *vblank, void *user_data)
+{
+ TDMVblank *test_vblank = (TDMVblank*)user_data;
+ test_vblank->done = true;
+ tdm_vblank_remove_create_handler(test_vblank->dpy, _tc_tdm_vblank_create_cb2, user_data);
+}
+
+TEST_P(TDMVblank, VblankRemoveCreateHandlerInHandler)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(tdm_vblank_add_create_handler(dpy, _tc_tdm_vblank_create_cb2, this), TDM_ERROR_NONE);
+
+ for (int o = 0; o < output_count; o++) {
+ tdm_error ret;
+
+ done = false;
+
+ tdm_vblank *vblank = tdm_vblank_create(dpy, outputs[o], &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(vblank, NULL);
+ if (o == 0)
+ ASSERT_EQ(done, true);
+ else
+ ASSERT_EQ(done, false);
+
+ tdm_vblank_destroy(vblank);
+ }
+}
+
+TEST_P(TDMVblank, VblankRemoveCreateHandlerNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ tdm_vblank_remove_create_handler(NULL, _tc_tdm_vblank_create_cb, NULL);
+}
+
+TEST_P(TDMVblank, VblankRemoveCreateHandlerNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ tdm_vblank_remove_create_handler(dpy, NULL, NULL);
+}
+
+/* tdm_vblank_get_output() */
+TEST_P(TDMVblank, VblankGetOutput)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++) {
+ tdm_error ret;
+ ASSERT_NE(tdm_vblank_get_output(vblanks[v], &ret), NULL);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ }
+}
+
+TEST_P(TDMVblank, VblankGetOutputNullObject)
+{
+ tdm_error ret;
+ ASSERT_EQ(tdm_vblank_get_output(NULL, &ret), NULL);
+ ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMVblank, VblankGetOutputNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ ASSERT_NE(tdm_vblank_get_output(vblanks[0], NULL), NULL);
+}
+
+/* tdm_vblank_get_client_pid() */
+TEST_P(TDMVblank, VblankGetClientPid)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++) {
+ pid_t pid = (pid_t)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_vblank_get_client_pid(vblanks[v], &pid), TDM_ERROR_NONE);
+ /* client pid should be 0 in case vblank is created in server side */
+ ASSERT_EQ(pid, 0);
+ }
+}
+
+TEST_P(TDMVblank, VblankGetClientPidNullObject)
+{
+ pid_t pid = (pid_t)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_vblank_get_client_pid(NULL, &pid), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(pid, (pid_t)TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMVblank, VblankGetClientPidNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ ASSERT_EQ(tdm_vblank_get_client_pid(vblanks[0], NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+/* tdm_vblank_set_name() */
+TEST_P(TDMVblank, VblankSetName)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++)
+ ASSERT_EQ(tdm_vblank_set_name(vblanks[v], TDM_UT_VBLANK_NAME), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMVblank, VblankSetNameNullObject)
+{
+ ASSERT_EQ(tdm_vblank_set_name(NULL, TDM_UT_VBLANK_NAME), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMVblank, VblankSetNameNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++)
+ ASSERT_EQ(tdm_vblank_set_name(vblanks[v], NULL), TDM_ERROR_NONE);
+}
+
+/* tdm_vblank_get_name() */
+TEST_P(TDMVblank, VblankGetName)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++) {
+ const char *name = (const char *)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_vblank_set_name(vblanks[v], TDM_UT_VBLANK_NAME), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_vblank_get_name(vblanks[v], &name), TDM_ERROR_NONE);
+ ASSERT_STREQ(name, TDM_UT_VBLANK_NAME);
+ }
+}
+
+TEST_P(TDMVblank, VblankGetNameNullObject)
+{
+ const char *name = (const char *)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_vblank_get_name(NULL, &name), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(name, (const char *)TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMVblank, VblankGetNameNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ ASSERT_EQ(tdm_vblank_get_name(vblanks[0], NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMVblank, VblankGetNameNoSet)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++) {
+ const char *name = (const char *)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_vblank_get_name(vblanks[v], &name), TDM_ERROR_NONE);
+ ASSERT_STREQ(name, TDM_VBLANK_DEFAULT_NAME);
+ }
+}
+
+/* tdm_vblank_set_fps() */
+TEST_P(TDMVblank, VblankSetFps)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++)
+ ASSERT_EQ(tdm_vblank_set_fps(vblanks[v], 60), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMVblank, VblankSetFpsNullObject)
+{
+ ASSERT_EQ(tdm_vblank_set_fps(NULL, 60), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMVblank, VblankSetFpsTwice)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++) {
+ ASSERT_EQ(tdm_vblank_set_fps(vblanks[v], 60), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_vblank_set_fps(vblanks[v], 60), TDM_ERROR_NONE);
+ }
+}
+
+/* tdm_vblank_set_fixed_fps() */
+TEST_P(TDMVblank, VblankSetFixedFps)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++)
+ ASSERT_EQ(tdm_vblank_set_fixed_fps(vblanks[v], 60), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMVblank, VblankSetFixedFpsNullObject)
+{
+ ASSERT_EQ(tdm_vblank_set_fixed_fps(NULL, 60), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMVblank, VblankSetFixedFpsTwice)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++) {
+ ASSERT_EQ(tdm_vblank_set_fixed_fps(vblanks[v], 60), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_vblank_set_fixed_fps(vblanks[v], 60), TDM_ERROR_NONE);
+ }
+}
+
+/* tdm_vblank_get_fps() */
+TEST_P(TDMVblank, VblankGetFps)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++) {
+ unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_vblank_set_fps(vblanks[v], 60), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_vblank_get_fps(vblanks[v], &fps), TDM_ERROR_NONE);
+ ASSERT_EQ(fps, 60);
+ }
+}
+
+TEST_P(TDMVblank, VblankGetFpsNullObject)
+{
+ unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_vblank_get_fps(NULL, &fps), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(fps, (unsigned int)TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMVblank, VblankGetFpsNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ ASSERT_EQ(tdm_vblank_get_fps(vblanks[0], NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMVblank, VblankGetFpsNoSet)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestPrepareOutput(), true);
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++) {
+ unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
+ const tdm_output_mode *mode = (const tdm_output_mode *)TDM_UT_INVALID_VALUE;
+ tdm_error ret;
+
+ if (!tc_tdm_vblank_is_avaiable(vblanks[v]))
+ continue;
+
+ ASSERT_EQ(tdm_vblank_get_fps(vblanks[v], &fps), TDM_ERROR_NONE);
+ ASSERT_TRUE(fps != 0 && fps != (unsigned int)TDM_UT_INVALID_VALUE);
+
+ tdm_output *output = tdm_vblank_get_output(vblanks[v], &ret);
+ ASSERT_NE(output, NULL);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+
+ ASSERT_EQ(tdm_output_get_mode(output, &mode), TDM_ERROR_NONE);
+ ASSERT_TRUE(mode != NULL && mode != (const tdm_output_mode *)TDM_UT_INVALID_VALUE);
+
+ ASSERT_EQ(fps, mode->vrefresh);
+ }
+}
+
+TEST_P(TDMVblank, VblankGetFpsAfterSetFixedFps)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++) {
+ unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
+
+ ASSERT_EQ(tdm_vblank_set_fps(vblanks[v], 60), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_vblank_get_fps(vblanks[v], &fps), TDM_ERROR_NONE);
+ ASSERT_EQ(fps, 60);
+
+ ASSERT_EQ(tdm_vblank_set_fixed_fps(vblanks[v], 10), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_vblank_get_fps(vblanks[v], &fps), TDM_ERROR_NONE);
+ ASSERT_EQ(fps, 10);
+
+ /* should return TDM_ERROR_NONE because tdm_vblank_set_fixed_fps would be
+ * called by other who call tdm_vblank_set_fps. If returns error, other
+ * can't handle error.
+ */
+ ASSERT_EQ(tdm_vblank_set_fps(vblanks[v], 60), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_vblank_get_fps(vblanks[v], &fps), TDM_ERROR_NONE);
+ ASSERT_EQ(fps, 10);
+ }
+}
+
+/* tdm_vblank_ignore_global_fps() */
+TEST_P(TDMVblank, VblankIgnoreGlobalFpsNullObject)
+{
+ ASSERT_EQ(tdm_vblank_ignore_global_fps(NULL, 1), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMVblank, VblankIgnoreGlobalFpsSet)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++)
+ ASSERT_EQ(tdm_vblank_ignore_global_fps(vblanks[v], 1), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMVblank, VblankIgnoreGlobalFpsSetTwice)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++) {
+ ASSERT_EQ(tdm_vblank_ignore_global_fps(vblanks[v], 1), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_vblank_ignore_global_fps(vblanks[v], 1), TDM_ERROR_NONE);
+ }
+}
+
+TEST_P(TDMVblank, VblankIgnoreGlobalFpsUnset)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++)
+ ASSERT_EQ(tdm_vblank_ignore_global_fps(vblanks[v], 0), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMVblank, VblankIgnoreGlobalFpsUnsetTwice)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++) {
+ ASSERT_EQ(tdm_vblank_ignore_global_fps(vblanks[v], 0), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_vblank_ignore_global_fps(vblanks[v], 0), TDM_ERROR_NONE);
+ }
+}
+
+/* tdm_vblank_set_offset() */
+TEST_P(TDMVblank, VblankSetOffset)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++)
+ ASSERT_EQ(tdm_vblank_set_offset(vblanks[v], 10), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMVblank, VblankSetOffsetNullObject)
+{
+ ASSERT_EQ(tdm_vblank_set_offset(NULL, 10), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMVblank, VblankSetOffsetTwice)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++) {
+ ASSERT_EQ(tdm_vblank_set_offset(vblanks[v], 10), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_vblank_set_offset(vblanks[v], 10), TDM_ERROR_NONE);
+ }
+}
+
+/* tdm_vblank_get_offset() */
+TEST_P(TDMVblank, VblankGetOffset)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++) {
+ int offset = TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_vblank_set_offset(vblanks[v], 10), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_vblank_get_offset(vblanks[v], &offset), TDM_ERROR_NONE);
+ ASSERT_EQ(offset, 10);
+ }
+}
+
+TEST_P(TDMVblank, VblankGetOffsetNullObject)
+{
+ int offset = TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_vblank_get_offset(NULL, &offset), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(offset, TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMVblank, VblankGetOffsetNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ ASSERT_EQ(tdm_vblank_get_offset(vblanks[0], NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMVblank, VblankGetOffsetNoSet)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++) {
+ int offset = TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_vblank_get_offset(vblanks[v], &offset), TDM_ERROR_NONE);
+ ASSERT_EQ(offset, 0);
+ }
+}
+
+/* tdm_vblank_set_enable_fake() */
+TEST_P(TDMVblank, VblankSetEnableFake)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++)
+ ASSERT_EQ(tdm_vblank_set_enable_fake(vblanks[v], 1), TDM_ERROR_NONE);
+}
+
+TEST_P(TDMVblank, VblankSetEnableFakeNullObject)
+{
+ ASSERT_EQ(tdm_vblank_set_enable_fake(NULL, 1), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMVblank, VblankSetEnableFakeTwice)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++) {
+ ASSERT_EQ(tdm_vblank_set_enable_fake(vblanks[v], 1), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_vblank_set_enable_fake(vblanks[v], 1), TDM_ERROR_NONE);
+ }
+}
+
+/* tdm_vblank_get_enable_fake() */
+TEST_P(TDMVblank, VblankGetEnableFake)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++) {
+ unsigned int enable_fake;
+ ASSERT_EQ(tdm_vblank_set_enable_fake(vblanks[v], 1), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_vblank_get_enable_fake(vblanks[v], &enable_fake), TDM_ERROR_NONE);
+ ASSERT_EQ(enable_fake, 1);
+
+ ASSERT_EQ(tdm_vblank_set_enable_fake(vblanks[v], 0), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_vblank_get_enable_fake(vblanks[v], &enable_fake), TDM_ERROR_NONE);
+ ASSERT_EQ(enable_fake, 0);
+ }
+}
+
+TEST_P(TDMVblank, VblankGetEnableFakeNullObject)
+{
+ unsigned int enable_fake = (unsigned int)TDM_UT_INVALID_VALUE;
+ ASSERT_EQ(tdm_vblank_get_enable_fake(NULL, &enable_fake), TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(enable_fake, (unsigned int)TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMVblank, VblankGetEnableFakeNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ ASSERT_EQ(tdm_vblank_get_enable_fake(vblanks[0], NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMVblank, VblankGetEnableFakeNoSet)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++) {
+ unsigned int enable_fake;
+ ASSERT_EQ(tdm_vblank_get_enable_fake(vblanks[v], &enable_fake), TDM_ERROR_NONE);
+ ASSERT_EQ(enable_fake, 0);
+ }
+}
+
+static void
+_tc_tdm_vblank_cb(tdm_vblank *vblank, tdm_error error, unsigned int sequence,
+ unsigned int tv_sec, unsigned int tv_usec, void *user_data)
+{
+ unsigned int *cur_seq = (unsigned int *)user_data;
+ if (cur_seq)
+ *cur_seq = (error == TDM_ERROR_NONE) ? sequence : ((unsigned int)-1);
+}
+
+TEST_P(TDMVblank, VblankWait)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestPrepareOutput(), true);
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++) {
+ unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
+ double start, end, interval;
+
+ if (!tc_tdm_vblank_is_avaiable(vblanks[v]))
+ continue;
+
+ ASSERT_EQ(tdm_vblank_get_fps(vblanks[v], &fps), TDM_ERROR_NONE);
+ ASSERT_TRUE(fps > 0 && fps != (unsigned int)TDM_UT_INVALID_VALUE);
+ interval = 1.0 / (double)fps;
+
+ for (int t = 0; t < 10; t++) {
+ unsigned int cur_seq = 0;
+
+ start = tdm_helper_get_time();
+ ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _tc_tdm_vblank_cb, &cur_seq), TDM_ERROR_NONE);
+ while (cur_seq == 0)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ end = tdm_helper_get_time();
+
+ /* "+ interval" consider the delay of socket communication between kernel and platform */
+ ASSERT_LT((end - start), (interval + interval));
+ }
+ }
+}
+
+TEST_P(TDMVblank, VblankWaitFewTime)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestPrepareOutput(), true);
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++) {
+ unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
+ double start, end, interval;
+
+ if (!tc_tdm_vblank_is_avaiable(vblanks[v]))
+ continue;
+
+ ASSERT_EQ(tdm_vblank_get_fps(vblanks[v], &fps), TDM_ERROR_NONE);
+ ASSERT_TRUE(fps > 0 && fps != (unsigned int)TDM_UT_INVALID_VALUE);
+ interval = 1.0 / (double)fps;
+
+ for (int t = 0; t < 10; t++) {
+ unsigned int cur_seq, seq1, seq2;
+
+ cur_seq = seq1 = seq2 = 0;
+ start = tdm_helper_get_time();
+ ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _tc_tdm_vblank_cb, &cur_seq), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _tc_tdm_vblank_cb, &seq1), TDM_ERROR_NONE);
+ ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _tc_tdm_vblank_cb, &seq2), TDM_ERROR_NONE);
+ while (cur_seq == 0)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ end = tdm_helper_get_time();
+
+ ASSERT_NE(seq1, 0);
+ ASSERT_NE(seq2, 0);
+
+ /* "+ interval" consider the delay of socket communication between kernel and platform */
+ ASSERT_LT((end - start), (interval + interval));
+ }
+ }
+}
+
+TEST_P(TDMVblank, VblankWaitInterval0)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestPrepareOutput(), true);
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ ASSERT_EQ(tdm_vblank_wait(vblanks[0], 0, 0, 0, _tc_tdm_vblank_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMVblank, VblankWaitInterval)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestPrepareOutput(), true);
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++) {
+ unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
+ double start, end, interval;
+
+ if (!tc_tdm_vblank_is_avaiable(vblanks[v]))
+ continue;
+
+ ASSERT_EQ(tdm_vblank_get_fps(vblanks[v], &fps), TDM_ERROR_NONE);
+ ASSERT_TRUE(fps > 0 && fps != (unsigned int)TDM_UT_INVALID_VALUE);
+ interval = 1.0 / (double)fps;
+
+ /* start from 1 */
+ for (int t = 1; t < 10; t++) {
+ unsigned int cur_seq = 0;
+
+ start = tdm_helper_get_time();
+ ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, t, _tc_tdm_vblank_cb, &cur_seq), TDM_ERROR_NONE);
+ while (cur_seq == 0)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ end = tdm_helper_get_time();
+
+ /* "+ interval" consider the delay of socket communication between kernel and platform */
+ ASSERT_GT((end - start), interval * (t - 1));
+ ASSERT_LT((end - start), interval * t + interval);
+ }
+ }
+}
+
+TEST_P(TDMVblank, VblankWaitSeq)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestPrepareOutput(), true);
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++) {
+ unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
+ double start, end, interval;
+
+ if (!tc_tdm_vblank_is_avaiable(vblanks[v]))
+ continue;
+
+ ASSERT_EQ(tdm_vblank_get_fps(vblanks[v], &fps), TDM_ERROR_NONE);
+ ASSERT_TRUE(fps > 0 && fps != (unsigned int)TDM_UT_INVALID_VALUE);
+ interval = 1.0 / (double)fps;
+
+ for (int t = 0; t < 10; t++) {
+ unsigned int cur_seq = 0, temp = 0;
+
+ ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _tc_tdm_vblank_cb, &cur_seq), TDM_ERROR_NONE);
+ while (cur_seq == 0)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+
+ start = tdm_helper_get_time();
+ ASSERT_EQ(tdm_vblank_wait_seq(vblanks[v], 0, 0, cur_seq + 1, _tc_tdm_vblank_cb, &temp), TDM_ERROR_NONE);
+ while (temp == 0)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ end = tdm_helper_get_time();
+
+ /* "+ interval" consider the delay of socket communication between kernel and platform */
+ ASSERT_LT((end - start), (interval + interval));
+ }
+ }
+}
+
+TEST_P(TDMVblank, VblankWaitSeqInterval)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestPrepareOutput(), true);
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++) {
+ unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
+ double start, end, interval;
+
+ if (!tc_tdm_vblank_is_avaiable(vblanks[v]))
+ continue;
+
+ ASSERT_EQ(tdm_vblank_get_fps(vblanks[v], &fps), TDM_ERROR_NONE);
+ ASSERT_TRUE(fps > 0 && fps != (unsigned int)TDM_UT_INVALID_VALUE);
+ interval = 1.0 / (double)fps;
+
+ /* start from 1 */
+ for (int t = 1; t < 10; t++) {
+ unsigned int cur_seq = 0, temp = 0;
+
+ ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _tc_tdm_vblank_cb, &cur_seq), TDM_ERROR_NONE);
+ while (cur_seq == 0)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+
+ start = tdm_helper_get_time();
+ ASSERT_EQ(tdm_vblank_wait_seq(vblanks[v], 0, 0, cur_seq + t, _tc_tdm_vblank_cb, &temp), TDM_ERROR_NONE);
+ while (temp == 0)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ end = tdm_helper_get_time();
+
+ /* "+ interval" consider the delay of socket communication between kernel and platform */
+ ASSERT_GT((end - start), (interval * (t - 1)));
+ ASSERT_LT((end - start), (interval * t + interval));
+ }
+ }
+}
+
+TEST_P(TDMVblank, VblankWaitNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ unsigned int cur_seq = 0;
+
+ ASSERT_EQ(tdm_vblank_wait(NULL, 0, 0, 1, _tc_tdm_vblank_cb, &cur_seq), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMVblank, VblankWaitNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ ASSERT_EQ(tdm_vblank_wait(vblanks[0], 0, 0, 0, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMVblank, VblankWaitDpmsOff)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestPrepareOutput(), true);
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++) {
+ tdm_error ret;
+ tdm_output *output = tdm_vblank_get_output(vblanks[v], &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+
+ if (!tc_tdm_output_is_connected(output))
+ continue;
+
+ ASSERT_EQ(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
+
+ ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _tc_tdm_vblank_cb, NULL), TDM_ERROR_DPMS_OFF);
+ }
+}
+
+TEST_P(TDMVblank, VblankWaitBeforeDpmsOff)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestPrepareOutput(), true);
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++) {
+ unsigned int temp = 0;
+ tdm_error ret;
+ tdm_output *output = tdm_vblank_get_output(vblanks[v], &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+
+ if (!tc_tdm_output_is_connected(output))
+ continue;
+
+ ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _tc_tdm_vblank_cb, &temp), TDM_ERROR_NONE);
+
+ ASSERT_EQ(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
+
+ while (temp == 0)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ }
+}
+
+TEST_P(TDMVblank, VblankWaitSetEnableFakeDpmsOff)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestPrepareOutput(), true);
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++) {
+ tdm_error ret;
+ tdm_output *output = tdm_vblank_get_output(vblanks[v], &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+
+ if (!tc_tdm_vblank_is_avaiable(vblanks[v]))
+ continue;
+
+ if (!tc_tdm_output_is_connected(output))
+ continue;
+
+ ASSERT_EQ(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
+
+ ASSERT_EQ(tdm_vblank_set_enable_fake(vblanks[v], 1), TDM_ERROR_NONE);
+
+ ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _tc_tdm_vblank_cb, NULL), TDM_ERROR_NONE);
+ }
+}
+
+TEST_P(TDMVblank, VblankWaitDisconnectedOutput)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestPrepareOutput(), true);
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++) {
+ tdm_error ret;
+ tdm_output *output = tdm_vblank_get_output(vblanks[v], &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+
+ if (tc_tdm_output_is_connected(output))
+ continue;
+
+ ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _tc_tdm_vblank_cb, NULL), TDM_ERROR_OUTPUT_DISCONNECTED);
+ }
+}
+
+TEST_P(TDMVblank, VblankWaitSetOffset)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestPrepareOutput(), true);
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++) {
+ unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
+ double start, end, interval;
+
+ if (!tc_tdm_vblank_is_avaiable(vblanks[v]))
+ continue;
+
+ ASSERT_EQ(tdm_vblank_set_offset(vblanks[v], 100), TDM_ERROR_NONE);
+
+ ASSERT_EQ(tdm_vblank_get_fps(vblanks[v], &fps), TDM_ERROR_NONE);
+ ASSERT_TRUE(fps > 0 && fps != (unsigned int)TDM_UT_INVALID_VALUE);
+ interval = 1.0 / (double)fps;
+
+ for (int t = 0; t < 3; t++) {
+ unsigned int cur_seq = 0;
+
+ start = tdm_helper_get_time();
+ ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _tc_tdm_vblank_cb, &cur_seq), TDM_ERROR_NONE);
+ while (cur_seq == 0)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ end = tdm_helper_get_time();
+
+ /* "+ interval" consider the delay of socket communication between kernel and platform */
+ ASSERT_GT((end - start), (0.1));
+ ASSERT_LT((end - start), (interval + interval + 0.1));
+ }
+ }
+}
+
+TEST_P(TDMVblank, VblankWaitSetFps)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestPrepareOutput(), true);
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++) {
+ unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
+ double start, end, interval, vrefresh_interval;
+
+ if (!tc_tdm_vblank_is_avaiable(vblanks[v]))
+ continue;
+
+ ASSERT_EQ(tdm_vblank_get_fps(vblanks[v], &fps), TDM_ERROR_NONE);
+ ASSERT_TRUE(fps > 0 && fps != (unsigned int)TDM_UT_INVALID_VALUE);
+ vrefresh_interval = 1.0 / (double)fps;
+
+ fps /= 2;
+ ASSERT_EQ(tdm_vblank_set_fps(vblanks[v], fps), TDM_ERROR_NONE);
+ interval = 1.0 / (double)fps;
+
+ for (int t = 0; t < 3; t++) {
+ unsigned int cur_seq = 0;
+
+ start = tdm_helper_get_time();
+ ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _tc_tdm_vblank_cb, &cur_seq), TDM_ERROR_NONE);
+ while (cur_seq == 0)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ end = tdm_helper_get_time();
+
+ /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
+ ASSERT_GT((end - start), (interval - vrefresh_interval));
+ ASSERT_LT((end - start), (interval + vrefresh_interval));
+ }
+ }
+}
+
+TEST_P(TDMVblank, VblankWaitSetFixedFps)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestPrepareOutput(), true);
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++) {
+ unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
+ double start, end, interval;
+
+ if (!tc_tdm_vblank_is_avaiable(vblanks[v]))
+ continue;
+
+ ASSERT_EQ(tdm_vblank_get_fps(vblanks[v], &fps), TDM_ERROR_NONE);
+ ASSERT_TRUE(fps > 0 && fps != (unsigned int)TDM_UT_INVALID_VALUE);
+ interval = 1.0 / (double)fps;
+
+ ASSERT_EQ(tdm_vblank_set_fixed_fps(vblanks[v], fps), TDM_ERROR_NONE);
+
+ /* this fps will be ignored because it has fixed fps value */
+ fps /= 2;
+ ASSERT_EQ(tdm_vblank_set_fps(vblanks[v], fps), TDM_ERROR_NONE);
+
+ for (int t = 0; t < 3; t++) {
+ unsigned int cur_seq = 0;
+
+ start = tdm_helper_get_time();
+ ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _tc_tdm_vblank_cb, &cur_seq), TDM_ERROR_NONE);
+ while (cur_seq == 0)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ end = tdm_helper_get_time();
+
+ /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
+ ASSERT_LT((end - start), (interval + interval));
+ }
+ }
+}
+
+TEST_P(TDMVblank, VblankWaitEnableDisableGlobalFps)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
+ double vrefresh_interval;
+ unsigned int cur_seq[3];
+ unsigned int global_fps = 5;
+ double start, end, interval;
+
+ ASSERT_EQ(TestPrepareOutput(), true);
+ ASSERT_EQ(TestCreateVblanks3(), true);
+ ASSERT_EQ(vblank_count, 3);
+
+ if (!tc_tdm_vblank_is_avaiable(vblanks[0]))
+ return;
+
+ ASSERT_EQ(tdm_vblank_get_fps(vblanks[0], &fps), TDM_ERROR_NONE);
+ ASSERT_TRUE(fps >= 30 && fps != (unsigned int)TDM_UT_INVALID_VALUE);
+ vrefresh_interval = 1.0 / (double)fps;
+
+ for (int v = 0; v < 3; v++) {
+ ASSERT_EQ(tdm_vblank_set_fixed_fps(vblanks[v], 10 * (v + 1)), TDM_ERROR_NONE);
+ interval = 1.0 / (double)(10 * (v + 1));
+ }
+
+ /* enable test. global fps doesn't effect server's vblanks */
+ tdm_vblank_enable_global_fps(1, global_fps);
+
+ for (int v = 0; v < 3; v++) {
+ cur_seq[v] = 0;
+ ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _tc_tdm_vblank_cb, &cur_seq[v]), TDM_ERROR_NONE);
+ }
+
+ start = tdm_helper_get_time();
+ while (cur_seq[2] == 0)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ end = tdm_helper_get_time();
+
+ /* "+- vrefresh_interval" consider the delay of socket communication between kernel and platform */
+ ASSERT_GT((end - start), (interval - vrefresh_interval));
+ ASSERT_LT((end - start), (interval + vrefresh_interval));
+
+ ASSERT_EQ(cur_seq[1], 0);
+ ASSERT_EQ(cur_seq[0], 0);
+
+ while (cur_seq[1] == 0)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ ASSERT_EQ(cur_seq[0], 0);
+
+ while (cur_seq[0] == 0)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+
+ /* disable test. global fps doesn't effect server's vblanks */
+ tdm_vblank_enable_global_fps(0, 0);
+
+ for (int v = 0; v < 3; v++) {
+ cur_seq[v] = 0;
+ ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _tc_tdm_vblank_cb, &cur_seq[v]), TDM_ERROR_NONE);
+ }
+
+ while (cur_seq[2] == 0)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ ASSERT_EQ(cur_seq[1], 0);
+ ASSERT_EQ(cur_seq[0], 0);
+
+ while (cur_seq[1] == 0)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ ASSERT_EQ(cur_seq[0], 0);
+}
+
+TEST_P(TDMVblank, VblankWaitSetEnableFakeDisconnected)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestPrepareOutput(), true);
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ for (int v = 0; v < vblank_count; v++) {
+ tdm_error ret;
+ tdm_output *output = tdm_vblank_get_output(vblanks[v], &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+
+ if (!tc_tdm_vblank_is_avaiable(vblanks[v]))
+ continue;
+
+ if (tc_tdm_output_is_connected(output))
+ continue;
+
+ ASSERT_EQ(tdm_vblank_set_enable_fake(vblanks[v], 1), TDM_ERROR_DPMS_OFF);
+
+ ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _tc_tdm_vblank_cb, NULL), TDM_ERROR_NONE);
+ }
+}
+
+TEST_P(TDMVblank, DISABLED_VblankWaitBeforeDpmsOff)
+{
+ /* wait vblank -> dpms off -> then? (vblank handler is called? or not?) */
+}
+
+TEST_P(TDMVblank, VblankWaitTimeout)
+{
+ TDM_UT_SKIP_FLAG(has_outputs);
+
+ ASSERT_EQ(TestPrepareOutput(), true);
+ ASSERT_EQ(TestCreateVblanks(), true);
+
+ if (vblank_count > 0) {
+ tdm_vblank *vblank = vblanks[0];
+ unsigned int cur_seq = 0;
+
+ ASSERT_EQ(tdm_vblank_wait(vblank, 0, 0, 1, _tc_tdm_vblank_cb, &cur_seq), TDM_ERROR_NONE);
+ usleep(1200000);
+ while (cur_seq == 0)
+ ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
+ }
+}
+
+#ifdef TDM_UT_TEST_WITH_PARAMS
+INSTANTIATE_TEST_CASE_P(TDMVblankParams,
+ TDMVblank,
+ Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
+#else
+INSTANTIATE_TEST_CASE_P(TDMVblankParams,
+ TDMVblank,
+ Values(TDM_DEFAULT_MODULE));
+#endif
+
+/* LCOV_EXCL_END */
\ No newline at end of file
-%define UTEST_PACKAGE 1
-%define UTEST_GCOV 0
+%define HALTESTS_PACKAGE 1
+%define HALTESTS_GCOV 0
Name: libtdm
Version: 1.18.0
%description client-devel
Tizen Display Manager Client Library headers
-%if "%{UTEST_PACKAGE}" == "1"
+%if "%{HALTESTS_PACKAGE}" == "1"
%package haltests
Summary: Tizen Display Manager unit tests package
Group: Development/Libraries
cp %{SOURCE1001} .
%build
-UTEST="no"
+HALTESTS="no"
-%if "%{UTEST_PACKAGE}" == "1"
-UTEST="yes"
+%if "%{HALTESTS_PACKAGE}" == "1"
+HALTESTS="yes"
%endif
-%if "%{UTEST_GCOV}" == "1"
+%if "%{HALTESTS_GCOV}" == "1"
CFLAGS+=" -fprofile-arcs -ftest-coverage -DTIZEN_TEST_GCOV"
CXXFLAGS+=" -fprofile-arcs -ftest-coverage -DTIZEN_TEST_GCOV"
LDFLAGS+=" -lgcov"
%endif
-%reconfigure --disable-static --with-utests=${UTEST} \
+%reconfigure --disable-static --with-haltests=${HALTESTS} \
--with-tdm-data-path=%{TZ_SYS_RO_SHARE}/tdm \
CFLAGS="${CFLAGS} -Wall -Werror" \
CXXFLAGS="${CXXFLAGS} -Wall -Werror" \
%attr(750,root,root) %{_bindir}/tdm-test-server
%{_bindir}/tdm-test-client
-%if "%{UTEST_PACKAGE}" == "1"
+%if "%{HALTESTS_PACKAGE}" == "1"
%files haltests
%defattr(-,root,root,-)
-%{_bindir}/tdm-utests
+%{_bindir}/tdm-haltests
%endif
%changelog
+++ /dev/null
-bin_PROGRAMS = tdm-utests
-
-tdm_utests_SOURCES = \
- src/ut_tdm_main.cpp \
- src/ut_tdm_log.cpp \
- src/ut_tdm_env.cpp \
- src/ut_tdm_event_loop.cpp \
- src/ut_tdm_buffer.cpp \
- src/ut_tdm_helper.cpp \
- src/ut_tdm_vblank.cpp \
- src/ut_tdm_display.cpp \
- src/ut_tdm_output.cpp \
- src/ut_tdm_layer.cpp \
- src/ut_tdm_client.cpp \
- src/ut_tdm_backend_env.cpp \
- src/ut_tdm_backend_display.cpp \
- src/ut_tdm_backend_pp.cpp \
- src/ut_tdm_backend_capture.cpp
-
-tdm_utests_SOURCES += \
- ../tools/buffers.c
-
-tdm_utests_CXXFLAGS = \
- $(CXXFLAGS) \
- $(TDM_CFLAGS) \
- -I../src \
- -I../include \
- -I../client \
- -I../tools \
- -I$(includedir)/gtest \
- -fpermissive
-# The flag -w is used, because there are many warnings in libtdm's sources.
-# Warnings occur because we build project with g++.
-# In C++ we need to use explicit types conversion.
-
-tdm_utests_LDFLAGS = \
- ${LDFLAGS} \
- $(TDM_LIBS) \
- $(top_builddir)/src/libtdm.la \
- $(top_builddir)/client/libtdm-client.la \
- $(top_builddir)/common/libtdm-common.la \
- -lgtest
-
-check:
- ./tdm-utests
+++ /dev/null
-#ifndef _UT_TDM_H_
-#define _UT_TDM_H_
-
-#include <sys/epoll.h>
-#include <sys/timerfd.h>
-#include <limits.h>
-#include <vector>
-#include <list>
-#include <climits>
-#include <pthread.h>
-#include <gtest/gtest.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <poll.h>
-
-extern "C" {
-#include <tbm_bufmgr.h>
-#include <tbm_drm_helper.h>
-}
-
-/* LCOV_EXCL_START */
-
-#include "tdm.h"
-#include "tdm_helper.h"
-#include "tdm_config.h"
-#include "tdm_log.h"
-#include "tdm_macro.h"
-#include "buffers.h"
-
-//#define TDM_UT_TEST_WITH_PARAMS
-
-extern bool enable_porting_debug;
-
-#undef TDM_DBG
-#undef TDM_INFO
-#undef TDM_WRN
-#undef TDM_ERR
-#define TDM_DBG(fmt, args...) tdm_log_print(TDM_LOG_LEVEL_DBG, fmt, ##args)
-#define TDM_INFO(fmt, args...) tdm_log_print(TDM_LOG_LEVEL_INFO, fmt, ##args)
-#define TDM_WRN(fmt, args...) tdm_log_print(TDM_LOG_LEVEL_WRN, fmt, ##args)
-#define TDM_ERR(fmt, args...) tdm_log_print(TDM_LOG_LEVEL_ERR, fmt, ##args)
-
-#define TDM_UT_INFO(fmt, args...) tdm_log_printf(TDM_LOG_LEVEL_INFO, fmt, ##args)
-#define TDM_UT_WRN(fmt, args...) tdm_log_printf(TDM_LOG_LEVEL_WRN, fmt, ##args)
-#define TDM_UT_ERR(fmt, args...) tdm_log_printf(TDM_LOG_LEVEL_ERR, fmt, ##args)
-
-#define TDM_UT_ENTRY() \
- TDM_ERR("--------------------------------------------- %s", typeid(*this).name())
-
-#define TDM_UT_CHECK_FLAG(FLAG) \
- do {\
- if(!(FLAG)) \
- TDM_UT_WRN("[ ] not supported");\
- } while(0)
-
-#define TDM_UT_SKIP_FLAG(FLAG) \
- do {\
- if(!(FLAG)) {\
- TDM_UT_WRN("[ SKIPPED ] not supported");\
- return;\
- }\
- } while(0)
-
-#define TDM_UT_RETURN_IF_FAIL(cond) \
- do { \
- if (!(cond)) { \
- TDM_UT_ERR("[%s,%d] '%s' failed", __FUNCTION__, __LINE__, #cond); \
- return; \
- } \
- } while(0)
-#define TDM_UT_RETURN_FALSE_IF_FAIL(cond) \
- do { \
- if (!(cond)) { \
- TDM_UT_ERR("[%s,%d] '%s' failed", __FUNCTION__, __LINE__, #cond); \
- return false; \
- } \
- } while(0)
-#define TDM_UT_RETURN_VAL_IF_FAIL(cond, val) \
- do { \
- if (!(cond)) { \
- TDM_UT_ERR("[%s,%d] '%s' failed", __FUNCTION__, __LINE__, #cond); \
- return val; \
- } \
- } while(0)
-#define TDM_UT_GOTO_IF_FAIL(cond, dst) \
- do { \
- if (!(cond)) { \
- TDM_UT_ERR("[%s,%d] '%s' failed", __FUNCTION__, __LINE__, #cond); \
- goto dst; \
- } \
- } while(0)
-
-#define TDM_UT_ASSERT_TRUE(cond, fmt, args...) \
- do { \
- if (!(cond)) { \
- if (enable_porting_debug) \
- TDM_UT_ERR(fmt, ##args); \
- GTEST_TEST_BOOLEAN_((cond), #cond, false, true, GTEST_FATAL_FAILURE_); \
- } \
- } while(0)
-#define TDM_UT_EXPECT_TRUE(cond, fmt, args...) \
- do { \
- if (!(cond)) { \
- if (enable_porting_debug) \
- TDM_UT_ERR(fmt, ##args); \
- GTEST_TEST_BOOLEAN_((cond), #cond, false, true, GTEST_NONFATAL_FAILURE_); \
- } \
- } while(0)
-
-#define TDM_UT_SIZE_ALIGN(value, base) (((value) + ((base) - 1)) & ~((base) - 1))
-
-#define TDM_UT_DUMP_DIR "/tmp/tdm_dump"
-#define TDM_UT_INVALID_VALUE -42
-#define TDM_UT_BUFFER_SIZE 256
-#define TDM_UT_VBLANK_NAME "ut_tdm_vblank"
-
-using ::testing::TestWithParam;
-using ::testing::Bool;
-using ::testing::Values;
-using ::testing::Combine;
-
-#ifdef TDM_UT_TEST_WITH_PARAMS
-class TDMEnv : public TestWithParam< ::testing::tuple<bool, bool, const char*> >
-{
-public:
- void SetUp(void);
- void TearDown(void);
-};
-#else
-class TDMEnv : public TestWithParam< ::testing::tuple<const char*> >
-{
-public:
- void SetUp(void);
- void TearDown(void);
-};
-#endif
-
-class TDMDisplay : public TDMEnv
-{
-public:
- tdm_display *dpy;
- tbm_bufmgr bufmgr;
-
- bool has_pp_cap;
- bool has_capture_cap;
-
- TDMDisplay();
- void SetUp(void);
- void TearDown(void);
-};
-
-class TDMOutput : public TDMDisplay
-{
-public:
- bool has_outputs;
- tdm_output **outputs;
- int output_count;
-
- bool done1, done2, done3;
-
- TDMOutput();
- void SetUp(void);
- void TearDown(void);
-};
-
-#ifdef TIZEN_TEST_GCOV
-extern "C" void __gcov_flush(void);
-#endif
-
-tdm_error ut_tdm_display_handle_events(tdm_display *dpy);
-bool ut_tdm_display_has_pp_capability(tdm_display *dpy);
-bool ut_tdm_display_has_capture_capability(tdm_display *dpy);
-
-bool ut_tdm_buffer_create(int width, int height, tbm_format format, int flags, bool fill,
- int count, tbm_surface_h *buffers);
-
-bool ut_tdm_output_is_async_dpms_enable(tdm_output *output);
-bool ut_tdm_output_is_hwc_enable(tdm_output *output);
-bool ut_tdm_output_is_aod_enable(tdm_output *output);
-bool ut_tdm_output_is_connected(tdm_output *output);
-bool ut_tdm_output_mode_setting(tdm_output *output);
-bool ut_tdm_output_prepare(tdm_display *dpy, tdm_output *output, bool fill);
-bool ut_tdm_output_prepare_all_output(tdm_display *dpy, tdm_output **outputs, int output_count, bool fill);
-bool ut_tdm_output_unset(tdm_display *dpy, tdm_output *output);
-double ut_tdm_output_get_vblank_interval_time(tdm_output *output);
-tdm_layer *ut_tdm_output_get_primary_layer(tdm_output *output);
-
-bool ut_tdm_layer_is_cursor_layer(tdm_layer *layer);
-bool ut_tdm_layer_is_primary_layer(tdm_layer *layer);
-bool ut_tdm_layer_is_video_layer(tdm_layer *layer);
-bool ut_tdm_layer_support_scale(tdm_layer *layer);
-bool ut_tdm_layer_support_no_crop(tdm_layer *layer);
-bool ut_tdm_layer_prepare_buffer(tdm_layer *layer, tbm_surface_h *buffers, int buffer_count, bool fill);
-bool ut_tdm_layer_prepare_buffer_queue(tdm_layer *layer, tbm_surface_queue_h *buffer_queue);
-bool ut_tdm_layer_fill_info(tdm_layer *layer, tbm_surface_h buffer, tbm_surface_queue_h buffer_queue, tdm_info_layer *info);
-bool ut_tdm_layer_set_buffer(tdm_layer *layer, tbm_surface_h buffer);
-bool ut_tdm_layer_set_buffer_with_pos(tdm_layer *layer, tbm_surface_h buffer, tdm_pos *pos);
-unsigned int ut_tdm_layer_get_output_pipe(tdm_layer *layer);
-tbm_format ut_tdm_layer_find_best_format(tdm_layer *layer);
-bool ut_tdm_layer_is_avaiable(tdm_layer *layer);
-
-bool ut_tdm_pp_fill_info(tbm_surface_h srcbuf, tbm_surface_h dstbuf, tdm_transform transform, tdm_info_pp *info);
-bool ut_tdm_capture_fill_info(tdm_output *output, tbm_surface_h buffer, tdm_transform transform,
- tdm_capture_type type, int frequency, bool stretch, tdm_info_capture *info);
-
-/******************************************************************************/
-/** testing for checking backend's basic implementation **/
-/******************************************************************************/
-class TDMBackendEnv : public TDMEnv
-{
-public:
- void SetUp(void);
- void TearDown(void);
-};
-
-class TDMBackendBasic : public TDMBackendEnv
-{
-public:
- tdm_display *dpy;
-
- tdm_output **outputs;
- int output_count;
-
- tdm_layer **layers;
- int layer_count;
-
- tbm_surface_h buffers[3];
-
- TDMBackendBasic();
- void SetUp(void);
- void TearDown(void);
- void UnsetOutput(void);
- void DestroyBuffers(void);
-};
-
-class TDMBackendDisplay : public TDMBackendBasic
-{
-public:
- void SetUp(void) { TDMBackendBasic::SetUp(); }
- void TearDown(void) { TDMBackendBasic::TearDown(); }
-};
-
-char ut_tdm_backend_getchar(void);
-
-#define TDM_UT_ASK_YNR(fmt, ...) \
- do { \
- if (enable_porting_debug) { \
- char ch; \
- do { \
- printf(fmt" [Y]es, [n]o, [r]etry): ", ##__VA_ARGS__); \
- ch = ut_tdm_backend_getchar(); \
- } while(ch != 'y' && ch != 'n' && ch != 'r'); \
- if (ch == 'n') \
- GTEST_FATAL_FAILURE_("tc failed"); \
- if (ch == 'r') \
- goto retry; \
- } \
- } while (0)
-
-/* LCOV_EXCL_STOP */
-
-#endif // _UT_TDM_H_
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
- *
- * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
- * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
- * Contact: Roman Marchenko <r.marchenko@samsung.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
-**************************************************************************/
-
-#include "ut_tdm.h"
-
-/* LCOV_EXCL_START */
-class TDMBackendCapture : public TDMBackendDisplay
-{
-public:
- bool has_capture_cap;
-
- tdm_capture *capture;
- tdm_capture_capability capabilities;
- const tbm_format *formats;
- int format_count;
- int min_w;
- int min_h;
- int max_w;
- int max_h;
- int preferred_align;
-
- tbm_surface_h buffers[3];
-
- tdm_info_capture info;
-
- tdm_output *output;
- unsigned int pipe;
- const tdm_output_mode *mode;
-
- tdm_layer *dst_layer;
- int dst_zpos;
- int dst_layer_index;
- tdm_pos dst_pos;
-
- bool stream_exit;
- int stream_count;
-
- TDMBackendCapture();
- void SetUp(void);
- void TearDown(void);
-
- bool FindLayer(int output_idx, tbm_format fmt, tdm_pos *punch);
- bool TestPrepareDefault(void);
- bool TestPrepare(int output_idx, int w, int h, tbm_format fmt, tdm_transform t, tdm_capture_type c, int frequency, bool stretch);
- void TestDone(void);
- void ShowBuffer(int b, tdm_pos *pos);
- void HideLayer(void);
- void DumpBuffer(int b, char *test);
- void DestroyBuffers(void);
-};
-
-TDMBackendCapture::TDMBackendCapture()
-{
- has_capture_cap = false;
- capture = NULL;
- capabilities = (tdm_capture_capability)0;
- formats = NULL;
- format_count = 0;
- min_w = min_h = max_w = max_h = preferred_align = -1;
-
- for (int b = 0; b < 3; b++)
- buffers[b] = NULL;
- memset(&info, 0, sizeof info);
-
- output = NULL;
- pipe = 0;
- mode = NULL;
-
- dst_layer = NULL;
- dst_zpos = 0;
- dst_layer_index = 0;
- memset(&dst_pos, 0, sizeof dst_pos);
-
- stream_exit = false;
- stream_count = 0;
-}
-
-void TDMBackendCapture::SetUp(void)
-{
- tdm_display_capability dpy_capabilities;
-
- TDMBackendDisplay::SetUp();
-
- ASSERT_EQ(tdm_display_get_capabilities(dpy, &dpy_capabilities), TDM_ERROR_NONE);
- has_capture_cap = dpy_capabilities & TDM_DISPLAY_CAPABILITY_CAPTURE;
-
- if (!has_capture_cap)
- return;
-
- ASSERT_EQ(tdm_display_get_capture_capabilities(dpy, &capabilities), TDM_ERROR_NONE);
- ASSERT_GT(capabilities, 0);
- ASSERT_EQ(tdm_display_get_capture_available_formats(dpy, &formats, &format_count), TDM_ERROR_NONE);
- ASSERT_NE(formats, NULL);
- ASSERT_GT(format_count, 0);
- ASSERT_EQ(tdm_display_get_capture_available_size(dpy, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_NONE);
- ASSERT_TRUE(min_w == -1 || min_w > 0);
- ASSERT_TRUE(min_h == -1 || min_h > 0);
- ASSERT_TRUE(max_w == -1 || max_w > 0);
- ASSERT_TRUE(max_h == -1 || max_h > 0);
- ASSERT_TRUE(preferred_align == -1 || preferred_align > 0);
-
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_prepare(dpy, outputs[o], true), true);
- }
-}
-
-void TDMBackendCapture::TearDown(void)
-{
- if (capture)
- tdm_capture_destroy(capture);
-
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_unset(dpy, outputs[o]), true);
- }
-
- DestroyBuffers();
-
- TDMBackendDisplay::TearDown();
-}
-
-bool TDMBackendCapture::FindLayer(int output_idx, tbm_format fmt, tdm_pos *punch)
-{
- tdm_error ret;
- int count;
- int primary_zpos, zpos;
- tdm_layer *primary = ut_tdm_output_get_primary_layer(outputs[output_idx]);
- TDM_UT_RETURN_FALSE_IF_FAIL(primary != NULL);
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_layer_count(outputs[output_idx], &count) == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_zpos(primary, &primary_zpos) == TDM_ERROR_NONE);
-
- dst_layer = NULL;
-
- for (int l = 0; l < count; l++) {
- unsigned int usable;
- const tbm_format *dst_formats;
- int dst_format_count;
-
- tdm_layer *temp = tdm_output_get_layer(outputs[output_idx], l, &ret);
- TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(temp != NULL);
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_is_usable(temp, &usable) == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_zpos(temp, &zpos) == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_available_formats(temp, &dst_formats, &dst_format_count) == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(dst_formats != NULL);
- TDM_UT_RETURN_FALSE_IF_FAIL(dst_format_count > 0);
-
- if (usable) {
- bool found = false;
- for (int f = 0; f < dst_format_count; f++) {
- if (dst_formats[f] == fmt) {
- found = true;
- break;
- }
- }
- if (!found)
- continue;
- dst_layer = temp;
- dst_zpos = zpos;
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_index(dst_layer, &dst_layer_index) == TDM_ERROR_NONE);
- break;
- }
- }
-
- if (dst_layer && (dst_zpos < primary_zpos)) {
- tbm_surface_h displaying_buffer = tdm_layer_get_displaying_buffer(primary, &ret);
- TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(displaying_buffer != NULL);
- tdm_helper_clear_buffer_pos(displaying_buffer, punch);
- }
-
- return true;
-}
-
-bool TDMBackendCapture::TestPrepareDefault(void)
-{
- tdm_error ret;
-
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- capture = tdm_output_create_capture(outputs[o], &ret);
- TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(capture != NULL);
-
- TDM_UT_RETURN_FALSE_IF_FAIL(ut_tdm_buffer_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[0], 0, false, 3, buffers) == true);
- TDM_UT_RETURN_FALSE_IF_FAIL(ut_tdm_capture_fill_info(outputs[o], buffers[0], TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1, false, &info) == true);
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_capture_set_info(capture, &info) == TDM_ERROR_NONE);
-
- output = outputs[o];
-
- if (capture)
- break;
- }
-
- return (capture) ? true : false;
-}
-
-bool TDMBackendCapture::TestPrepare(int output_idx, int w, int h, tbm_format fmt, tdm_transform t, tdm_capture_type c, int frequency, bool stretch)
-{
- tdm_error ret;
- int flags = 0;
-
- TDM_UT_RETURN_FALSE_IF_FAIL(outputs != NULL);
- TDM_UT_RETURN_FALSE_IF_FAIL(output_count > 0);
- TDM_UT_RETURN_FALSE_IF_FAIL(output_count >= output_idx);
-
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_display_get_capture_capabilities(dpy, &capabilities) == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(capabilities > 0);
-
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_display_get_capture_available_size(dpy, &min_w, &min_h, &max_w, &max_h, &preferred_align) == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(min_w == -1 || min_w > 0);
- TDM_UT_RETURN_FALSE_IF_FAIL(min_h == -1 || min_h > 0);
- TDM_UT_RETURN_FALSE_IF_FAIL(max_w == -1 || max_w > 0);
- TDM_UT_RETURN_FALSE_IF_FAIL(max_h == -1 || max_h > 0);
- TDM_UT_RETURN_FALSE_IF_FAIL(preferred_align == -1 || preferred_align > 0);
-
- capture = tdm_output_create_capture(outputs[output_idx], &ret);
- TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(capture != NULL);
-
- if (dst_layer) {
- tdm_layer_capability capabilities;
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_capabilities(dst_layer, &capabilities) == TDM_ERROR_NONE);
- if (capabilities & TDM_LAYER_CAPABILITY_SCANOUT)
- flags |= TBM_BO_SCANOUT;
- }
-
- TDM_UT_RETURN_FALSE_IF_FAIL(ut_tdm_buffer_create(w, h, fmt, flags, false, 3, buffers) == true);
- TDM_UT_RETURN_FALSE_IF_FAIL(ut_tdm_capture_fill_info(outputs[output_idx], buffers[0], t, c, frequency, stretch, &info) == true);
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_capture_set_info(capture, &info) == TDM_ERROR_NONE);
-
- output = outputs[output_idx];
-
- return true;
-}
-
-void TDMBackendCapture::TestDone(void)
-{
- if (capture) {
- tdm_capture_destroy(capture);
- capture = NULL;
- }
-
- DestroyBuffers();
-}
-
-void TDMBackendCapture::DumpBuffer(int b, char *test)
-{
- char filename[256];
- if (test)
- snprintf(filename, sizeof filename, "%s_%s_%d", typeid(*this).name(), test, b);
- else
- snprintf(filename, sizeof filename, "%s_%d", typeid(*this).name(), b);
- tdm_helper_dump_buffer_str(buffers[b], NULL, filename);
-}
-
-void TDMBackendCapture::ShowBuffer(int b, tdm_pos *pos)
-{
- ASSERT_NE(output, NULL);
- ASSERT_NE(dst_layer, NULL);
-
- ASSERT_EQ(ut_tdm_layer_set_buffer_with_pos(dst_layer, buffers[b], pos), true);
- ASSERT_EQ(tdm_output_commit(output, 0, NULL, NULL), TDM_ERROR_NONE);
-}
-
-void TDMBackendCapture::HideLayer(void)
-{
- ASSERT_NE(output, NULL);
- ASSERT_NE(dst_layer, NULL);
-
- tdm_layer_unset_buffer(dst_layer);
- tdm_output_commit(output, 0, NULL, NULL);
-
- dst_layer = NULL;
-}
-
-void TDMBackendCapture::DestroyBuffers(void)
-{
- for (int b = 0; b < 3; b++) {
- tbm_surface_destroy(buffers[b]);
- buffers[b] = NULL;
- }
-}
-
-static void
-_ut_tdm_capture_fit_rect(int src_w, int src_h, int dst_w, int dst_h, tdm_pos *fit)
-{
- float rw, rh;
-
- if (src_w <= 0 || src_h <= 0 || dst_w <= 0 || dst_h <= 0 || !fit)
- return;
-
- rw = (float)src_w / dst_w;
- rh = (float)src_h / dst_h;
-
- if (rw > rh) {
- fit->w = dst_w;
- fit->h = src_h / rw;
- fit->x = 0;
- fit->y = (dst_h - fit->h) / 2;
- } else if (rw < rh) {
- fit->w = src_w / rh;
- fit->h = dst_h;
- fit->x = (dst_w - fit->w) / 2;
- fit->y = 0;
- } else {
- fit->w = dst_w;
- fit->h = dst_h;
- fit->x = 0;
- fit->y = 0;
- }
-
- if (fit->x % 2)
- fit->x = fit->x - 1;
-}
-
-bool
-ut_tdm_capture_fill_info(tdm_output *output, tbm_surface_h buffer, tdm_transform transform,
- tdm_capture_type type, int frequency, bool stretch, tdm_info_capture *info)
-{
- int bw, bh;
- const tdm_output_mode *mode = NULL;
-
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_mode(output, &mode) == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(mode != NULL);
-
- memset(info, 0, sizeof *info);
-
- bw = bh = TDM_UT_INVALID_VALUE;
- tdm_helper_get_buffer_full_size(buffer, &bw, &bh);
-
- TDM_UT_RETURN_FALSE_IF_FAIL(bw != TDM_UT_INVALID_VALUE);
- TDM_UT_RETURN_FALSE_IF_FAIL(bw >= tbm_surface_get_width(buffer));
- TDM_UT_RETURN_FALSE_IF_FAIL(bh != TDM_UT_INVALID_VALUE);
- TDM_UT_RETURN_FALSE_IF_FAIL(bh >= tbm_surface_get_height(buffer));
- info->dst_config.size.h = bw;
- info->dst_config.size.v = bh;
-
- if (stretch) {
- info->dst_config.pos.x = 0;
- info->dst_config.pos.y = 0;
- info->dst_config.pos.w = tbm_surface_get_width(buffer);
- info->dst_config.pos.h = tbm_surface_get_height(buffer);
- } else {
- _ut_tdm_capture_fit_rect(mode->hdisplay, mode->vdisplay,
- tbm_surface_get_width(buffer), tbm_surface_get_height(buffer),
- &info->dst_config.pos);
- }
-
- info->dst_config.format = tbm_surface_get_format(buffer);
-
- info->transform = transform;
- info->type = type;
- info->flags = 0;
-
- if (frequency <= 0)
- frequency = mode->vrefresh;
-
- info->frequency = frequency;
-
- TDM_UT_INFO("filling capture info done: dst_config(%dx%d: %d,%d %dx%d: %c%c%c%c) transform(%s) type(%s) freq(%d)",
- info->dst_config.size.h, info->dst_config.size.v,
- info->dst_config.pos.x, info->dst_config.pos.y, info->dst_config.pos.w, info->dst_config.pos.h,
- FOURCC_STR(info->dst_config.format),
- tdm_transform_str(info->transform), tdm_capture_type_str(info->type), info->frequency);
-
- return true;
-}
-
-TEST_P(TDMBackendCapture, CaptureDispalyGetAvaiableFormats)
-{
- const tbm_format *formats = (const tbm_format *)TDM_UT_INVALID_VALUE;
- int count = TDM_UT_INVALID_VALUE;
- if (has_capture_cap) {
- ASSERT_EQ(tdm_display_get_capture_available_formats(dpy, &formats, &count), TDM_ERROR_NONE);
- ASSERT_TRUE(formats != NULL && formats != (const tbm_format *)TDM_UT_INVALID_VALUE);
- ASSERT_TRUE(count > 0 && count != TDM_UT_INVALID_VALUE);
- } else {
- ASSERT_EQ(tdm_display_get_capture_available_formats(dpy, &formats, &count), TDM_ERROR_NO_CAPABILITY);
- ASSERT_EQ(formats, (const tbm_format *)TDM_UT_INVALID_VALUE);
- ASSERT_EQ(count, TDM_UT_INVALID_VALUE);
- }
-}
-
-TEST_P(TDMBackendCapture, CaptureDispalyGetAvaiableFormatsNullObject)
-{
- const tbm_format *formats = (const tbm_format *)TDM_UT_INVALID_VALUE;
- int count = TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_display_get_capture_available_formats(NULL, &formats, &count), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(formats, (const tbm_format *)TDM_UT_INVALID_VALUE);
- ASSERT_EQ(count, TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMBackendCapture, CaptureDispalyGetAvaiableFormatsNullOther)
-{
- ASSERT_EQ(tdm_display_get_capture_available_formats(dpy, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMBackendCapture, CaptureDispalyGetAvaiableSize)
-{
- int min_w = TDM_UT_INVALID_VALUE;
- int min_h = TDM_UT_INVALID_VALUE;
- int max_w = TDM_UT_INVALID_VALUE;
- int max_h = TDM_UT_INVALID_VALUE;
- int preferred_align = TDM_UT_INVALID_VALUE;
- if (has_capture_cap) {
- ASSERT_EQ(tdm_display_get_capture_available_size(dpy, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_NONE);
- ASSERT_NE(min_w, TDM_UT_INVALID_VALUE);
- ASSERT_NE(min_h, TDM_UT_INVALID_VALUE);
- ASSERT_NE(max_w, TDM_UT_INVALID_VALUE);
- ASSERT_NE(max_h, TDM_UT_INVALID_VALUE);
- ASSERT_NE(preferred_align, TDM_UT_INVALID_VALUE);
- } else {
- ASSERT_EQ(tdm_display_get_capture_available_size(dpy, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_NO_CAPABILITY);
- ASSERT_EQ(min_w, TDM_UT_INVALID_VALUE);
- ASSERT_EQ(min_h, TDM_UT_INVALID_VALUE);
- ASSERT_EQ(max_w, TDM_UT_INVALID_VALUE);
- ASSERT_EQ(max_h, TDM_UT_INVALID_VALUE);
- ASSERT_EQ(preferred_align, TDM_UT_INVALID_VALUE);
- }
-}
-
-TEST_P(TDMBackendCapture, CaptureDispalyGetAvaiableSizeNullObject)
-{
- int min_w = TDM_UT_INVALID_VALUE;
- int min_h = TDM_UT_INVALID_VALUE;
- int max_w = TDM_UT_INVALID_VALUE;
- int max_h = TDM_UT_INVALID_VALUE;
- int preferred_align = TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_display_get_capture_available_size(NULL, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(min_w, TDM_UT_INVALID_VALUE);
- ASSERT_EQ(min_h, TDM_UT_INVALID_VALUE);
- ASSERT_EQ(max_w, TDM_UT_INVALID_VALUE);
- ASSERT_EQ(max_h, TDM_UT_INVALID_VALUE);
- ASSERT_EQ(preferred_align, TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMBackendCapture, CaptureDispalyGetAvaiableSizeNullOther)
-{
- if (has_capture_cap)
- ASSERT_EQ(tdm_display_get_capture_available_size(dpy, NULL, NULL, NULL, NULL, NULL), TDM_ERROR_NONE);
- else
- ASSERT_EQ(tdm_display_get_capture_available_size(dpy, NULL, NULL, NULL, NULL, NULL), TDM_ERROR_NO_CAPABILITY);
-}
-
-TEST_P(TDMBackendCapture, CaptureDestroy)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
- TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
-
- ASSERT_EQ(TestPrepareDefault(), true);
-
- TestDone();
-}
-
-TEST_P(TDMBackendCapture, CaptureDestroyNullObject)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
- TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
-
- tdm_capture_destroy(NULL);
-}
-
-TEST_P(TDMBackendCapture, CaptureSetInfo)
-{
- /* tested in CaptureNoScaleNoTransformNoCSC */
-}
-
-TEST_P(TDMBackendCapture, CaptureSetInfoNullObject)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
- TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
-
- tdm_info_capture info;
- memset(&info, 0, sizeof info);
- ASSERT_EQ(tdm_capture_set_info(NULL, &info), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMBackendCapture, CaptureSetInfoNullOther)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
- TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
-
- ASSERT_EQ(TestPrepareDefault(), true);
-
- ASSERT_EQ(tdm_capture_set_info(capture, NULL), TDM_ERROR_INVALID_PARAMETER);
-
- TestDone();
-}
-
-static void
-_ut_tdm_capture_done_cb(tdm_capture *capture, tbm_surface_h buffer, void *user_data)
-{
- bool *done = (bool*)user_data;
- if (done)
- *done = true;
-}
-
-TEST_P(TDMBackendCapture, CaptureSetDoneHandler)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
- TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
-
- ASSERT_EQ(TestPrepareDefault(), true);
-
- ASSERT_EQ(tdm_capture_set_done_handler(capture, _ut_tdm_capture_done_cb, NULL), TDM_ERROR_NONE);
-
- TestDone();
-}
-
-TEST_P(TDMBackendCapture, CaptureSetDoneHandlerNullObject)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
- TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
-
- ASSERT_EQ(tdm_capture_set_done_handler(NULL, _ut_tdm_capture_done_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMBackendCapture, CaptureSetDoneHandlerNullOther)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
- TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
-
- ASSERT_EQ(TestPrepareDefault(), true);
-
- ASSERT_EQ(tdm_capture_set_done_handler(capture, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
-
- TestDone();
-}
-
-TEST_P(TDMBackendCapture, CaptureAttach)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
- TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
-
- for (int o = 0; o < output_count; o++) {
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- for (int f = 0; f < format_count; f++) {
- FindLayer(o, formats[f], &dst_pos);
-
- ASSERT_EQ(TestPrepare(o, TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
- TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1, false), true);
-
- for (int b = 0; b < 3; b++)
- ASSERT_EQ(tdm_capture_attach(capture, buffers[b]), TDM_ERROR_NONE);
-
- TestDone();
- }
- }
-}
-
-TEST_P(TDMBackendCapture, CaptureAttachNullObject)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
- TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
-
- tbm_surface_h buffer = (tbm_surface_h)TDM_UT_BUFFER_SIZE;
-
- ASSERT_EQ(tdm_capture_attach(NULL, buffer), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMBackendCapture, CaptureAttachNullOther)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
- TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
-
- ASSERT_EQ(TestPrepareDefault(), true);
-
- ASSERT_EQ(tdm_capture_attach(capture, NULL), TDM_ERROR_INVALID_PARAMETER);
-
- TestDone();
-}
-
-TEST_P(TDMBackendCapture, CaptureCommit)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
- TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
-
- ASSERT_EQ(TestPrepareDefault(), true);
-
- ASSERT_EQ(tdm_capture_commit(capture), TDM_ERROR_NONE);
-
- TestDone();
-}
-
-TEST_P(TDMBackendCapture, CaptureCommitNullOBject)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
- TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
-
- ASSERT_EQ(tdm_capture_commit(NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMBackendCapture, CaptureCommitDpmsOff)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
- TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
-
- ASSERT_EQ(TestPrepareDefault(), true);
-
- ASSERT_EQ(ut_tdm_output_unset(dpy, output), true);
-
- ASSERT_EQ(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
-
- ASSERT_EQ(tdm_capture_commit(capture), TDM_ERROR_BAD_REQUEST);
-
- TestDone();
-}
-
-static void
-_ut_tdm_capture_done_cb2(tdm_capture *capture, tbm_surface_h buffer, void *user_data)
-{
- int *done = (int*)user_data;
- if (done)
- (*done)++;
-}
-
-TEST_P(TDMBackendCapture, CaptureDestroyWithoutCommit)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
- TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
-
- for (int o = 0; o < output_count; o++) {
- const tdm_output_mode *mode = NULL;
- int f = 0;
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE);
-
- FindLayer(o, formats[f], &dst_pos);
-
- ASSERT_EQ(TestPrepare(o, TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
- TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1, false), true);
-
- ASSERT_EQ(tdm_capture_set_done_handler(capture, _ut_tdm_capture_done_cb2, NULL), TDM_ERROR_NONE);
-
- for (int b = 0; b < 3; b++)
- ASSERT_EQ(tdm_capture_attach(capture, buffers[b]), TDM_ERROR_NONE);
-
- tdm_capture_destroy(capture);
- capture = NULL;
-
- TestDone();
- }
-}
-
-TEST_P(TDMBackendCapture, CaptureDestroyBeforeDone)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
- TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
-
- for (int o = 0; o < output_count; o++) {
- const tdm_output_mode *mode = NULL;
- int f = 0;
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE);
-
- FindLayer(o, formats[f], &dst_pos);
-
- ASSERT_EQ(TestPrepare(o, TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
- TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1, false), true);
-
- ASSERT_EQ(tdm_capture_set_done_handler(capture, _ut_tdm_capture_done_cb2, NULL), TDM_ERROR_NONE);
-
- for (int b = 0; b < 3; b++)
- ASSERT_EQ(tdm_capture_attach(capture, buffers[b]), TDM_ERROR_NONE);
-
- ASSERT_EQ(tdm_capture_commit(capture), TDM_ERROR_NONE);
-
- tdm_capture_destroy(capture);
- capture = NULL;
-
- TestDone();
- }
-}
-
-TEST_P(TDMBackendCapture, CaptureOneshotLetterboxSize)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
- TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
- TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_ONESHOT);
-
- bool done;
-
- for (int o = 0; o < output_count; o++) {
- const tdm_output_mode *mode = NULL;
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE);
-
- for (int f = 0; f < format_count; f++) {
- int half_size = ((mode->hdisplay <= mode->vdisplay) ? mode->hdisplay : mode->vdisplay) / 2;
-
- dst_pos.x = (mode->hdisplay - half_size) / 2;
- dst_pos.y = (mode->vdisplay - half_size) / 2;
- dst_pos.w = half_size;
- dst_pos.h = half_size;
-
- TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(formats[f]));
-
- FindLayer(o, formats[f], &dst_pos);
-
- if (!dst_layer) {
- TDM_UT_INFO("no proper layer for %c%c%c%c", FOURCC_STR(formats[f]));
- continue;
- }
-
- ASSERT_EQ(TestPrepare(o, half_size, half_size, formats[f],
- TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1, false), true);
-
- ASSERT_EQ(tdm_capture_set_done_handler(capture, _ut_tdm_capture_done_cb, &done), TDM_ERROR_NONE);
-
-retry:
- for (int b = 0; b < 3; b++) {
- done = false;
- ASSERT_EQ(tdm_capture_attach(capture, buffers[b]), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_capture_commit(capture), TDM_ERROR_NONE);
-
- while (!done)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
-
-#if 0
- char temp[256];
- snprintf(temp, sizeof temp, "f%d_b%d", f, b);
- DumpBuffer(b, temp);
-#endif
- ShowBuffer(b, &dst_pos);
- }
-
- TDM_UT_ASK_YNR("* Successed to capture a output to a '%c%c%c%c' buffer as letterbox size and show? (output: %d, layer: %d)",
- FOURCC_STR(formats[f]), pipe, dst_layer_index);
-
-
- HideLayer();
-
- TestDone();
- }
- }
-}
-
-TEST_P(TDMBackendCapture, CaptureOneshotFullSize)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
- TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
- TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_ONESHOT);
-
- bool done;
-
- for (int o = 0; o < output_count; o++) {
- const tdm_output_mode *mode = NULL;
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE);
-
- for (int f = 0; f < format_count; f++) {
- int half_size = ((mode->hdisplay <= mode->vdisplay) ? mode->hdisplay : mode->vdisplay) / 2;
-
- dst_pos.x = (mode->hdisplay - half_size) / 2;
- dst_pos.y = (mode->vdisplay - half_size) / 2;
- dst_pos.w = half_size;
- dst_pos.h = half_size;
-
- TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(formats[f]));
-
- FindLayer(o, formats[f], &dst_pos);
-
- if (!dst_layer) {
- TDM_UT_INFO("no proper layer for %c%c%c%c", FOURCC_STR(formats[f]));
- continue;
- }
-
- ASSERT_EQ(TestPrepare(o, half_size, half_size, formats[f],
- TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1, true), true);
-
- ASSERT_EQ(tdm_capture_set_done_handler(capture, _ut_tdm_capture_done_cb, &done), TDM_ERROR_NONE);
-
-retry:
- for (int b = 0; b < 3; b++) {
- done = false;
- ASSERT_EQ(tdm_capture_attach(capture, buffers[b]), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_capture_commit(capture), TDM_ERROR_NONE);
-
- while (!done)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
-
-#if 0
- char temp[256];
- snprintf(temp, sizeof temp, "f%d_b%d", f, b);
- DumpBuffer(b, temp);
-#endif
- ShowBuffer(b, &dst_pos);
- }
-
- TDM_UT_ASK_YNR("* Successed to capture a output to a '%c%c%c%c' buffer as full size and show? (output: %d, layer: %d)",
- FOURCC_STR(formats[f]), pipe, dst_layer_index);
-
-
- HideLayer();
-
- TestDone();
- }
- }
-}
-
-TEST_P(TDMBackendCapture, CaptureOneshotAttachFewTimesInOneCommit)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
- TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
- TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_ONESHOT);
-
- int done;
-
- for (int o = 0; o < output_count; o++) {
- const tdm_output_mode *mode = NULL;
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE);
-
- for (int f = 0; f < format_count; f++) {
- int half_size = ((mode->hdisplay <= mode->vdisplay) ? mode->hdisplay : mode->vdisplay) / 2;
-
- dst_pos.x = (mode->hdisplay - half_size) / 2;
- dst_pos.y = (mode->vdisplay - half_size) / 2;
- dst_pos.w = half_size;
- dst_pos.h = half_size;
-
- TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(formats[f]));
-
- FindLayer(o, formats[f], &dst_pos);
-
- if (!dst_layer) {
- TDM_UT_INFO("no proper layer for %c%c%c%c", FOURCC_STR(formats[f]));
- continue;
- }
-
- ASSERT_EQ(TestPrepare(o, half_size, half_size, formats[f],
- TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1, false), true);
-
- done = 0;
- ASSERT_EQ(tdm_capture_set_done_handler(capture, _ut_tdm_capture_done_cb2, &done), TDM_ERROR_NONE);
-
-retry:
- for (int b = 0; b < 3; b++)
- ASSERT_EQ(tdm_capture_attach(capture, buffers[b]), TDM_ERROR_NONE);
-
- ASSERT_EQ(tdm_capture_commit(capture), TDM_ERROR_NONE);
-
- while (done != 3)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
-
- for (int b = 0; b < 3; b++) {
-#if 0
- char temp[256];
- snprintf(temp, sizeof temp, "f%d_b%d", f, b);
- DumpBuffer(b, temp);
-#endif
- ShowBuffer(b, &dst_pos);
- }
-
- TDM_UT_ASK_YNR("* Successed to capture a output to a '%c%c%c%c' buffer as letterbox size and show? (output: %d, layer: %d)",
- FOURCC_STR(formats[f]), pipe, dst_layer_index);
-
-
- HideLayer();
-
- TestDone();
- }
- }
-}
-
-static void
-_ut_tdm_backend_capture_buffer_release_cb(tbm_surface_h buffer, void *user_data)
-{
- TDMBackendCapture *backend_capture = (TDMBackendCapture*)user_data;
-
- tdm_buffer_remove_release_handler(buffer, _ut_tdm_backend_capture_buffer_release_cb, backend_capture);
-
- ASSERT_EQ(tdm_capture_attach(backend_capture->capture, buffer), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_capture_commit(backend_capture->capture), TDM_ERROR_NONE);
-}
-
-static void
-_ut_tdm_capture_stream_done_cb(tdm_capture *capture, tbm_surface_h buffer, void *user_data)
-{
- TDMBackendCapture *backend_capture = (TDMBackendCapture*)user_data;
-
- for (int b = 0; b < 3; b++) {
- if (backend_capture->buffers[b] == buffer) {
-#if 0
- char temp[256];
- snprintf(temp, sizeof temp, "f%d_b%d", f, b);
- DumpBuffer(b, temp);
-#endif
- tdm_buffer_add_release_handler(buffer, _ut_tdm_backend_capture_buffer_release_cb, (void*)backend_capture);
- backend_capture->ShowBuffer(b, &backend_capture->dst_pos);
- break;
- }
- }
-
- if (--backend_capture->stream_count == 0) {
- backend_capture->stream_exit = 1;
- }
-}
-
-TEST_P(TDMBackendCapture, CaptureStreamLetterboxSize)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
- TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
- TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_STREAM);
-
- for (int o = 0; o < output_count; o++) {
- const tdm_output_mode *mode = NULL;
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE);
-
- for (int f = 0; f < format_count; f++) {
- int half_size = ((mode->hdisplay <= mode->vdisplay) ? mode->hdisplay : mode->vdisplay) / 2;
-
- dst_pos.x = (mode->hdisplay - half_size) / 2;
- dst_pos.y = (mode->vdisplay - half_size) / 2;
- dst_pos.w = half_size;
- dst_pos.h = half_size;
-
- TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(formats[f]));
-
- FindLayer(o, formats[f], &dst_pos);
-
- if (!dst_layer) {
- TDM_UT_INFO("no proper layer for %c%c%c%c", FOURCC_STR(formats[f]));
- continue;
- }
-
- ASSERT_EQ(TestPrepare(o, half_size, half_size, formats[f],
- TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_STREAM, -1, false), true);
-
- ASSERT_EQ(tdm_capture_set_done_handler(capture, _ut_tdm_capture_stream_done_cb, (void*)this), TDM_ERROR_NONE);
-
- for (int b = 0; b < 3; b++)
- ASSERT_EQ(tdm_capture_attach(capture, buffers[b]), TDM_ERROR_NONE);
-
-retry:
-
- stream_exit = false;
- stream_count = 30;
-
- ASSERT_EQ(tdm_capture_commit(capture), TDM_ERROR_NONE);
-
- while (!stream_exit)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
-
- TDM_UT_ASK_YNR("* Successed to capture a output to a '%c%c%c%c' buffer as letterbox size and show? (output: %d, layer: %d)",
- FOURCC_STR(formats[f]), pipe, dst_layer_index);
-
-
- HideLayer();
-
- TestDone();
- }
- }
-}
-
-TEST_P(TDMBackendCapture, CaptureStreamFullSize)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
- TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
- TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_STREAM);
-
- for (int o = 0; o < output_count; o++) {
- const tdm_output_mode *mode = NULL;
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE);
-
- for (int f = 0; f < format_count; f++) {
- int half_size = ((mode->hdisplay <= mode->vdisplay) ? mode->hdisplay : mode->vdisplay) / 2;
-
- dst_pos.x = (mode->hdisplay - half_size) / 2;
- dst_pos.y = (mode->vdisplay - half_size) / 2;
- dst_pos.w = half_size;
- dst_pos.h = half_size;
-
- TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(formats[f]));
-
- FindLayer(o, formats[f], &dst_pos);
-
- if (!dst_layer) {
- TDM_UT_INFO("no proper layer for %c%c%c%c", FOURCC_STR(formats[f]));
- continue;
- }
-
- ASSERT_EQ(TestPrepare(o, half_size, half_size, formats[f],
- TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_STREAM, -1, true), true);
-
- ASSERT_EQ(tdm_capture_set_done_handler(capture, _ut_tdm_capture_stream_done_cb, (void*)this), TDM_ERROR_NONE);
-
- for (int b = 0; b < 3; b++)
- ASSERT_EQ(tdm_capture_attach(capture, buffers[b]), TDM_ERROR_NONE);
-
-retry:
-
- stream_exit = false;
- stream_count = 30;
-
- ASSERT_EQ(tdm_capture_commit(capture), TDM_ERROR_NONE);
-
- while (!stream_exit)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
-
- TDM_UT_ASK_YNR("* Successed to capture a output to a '%c%c%c%c' buffer as full size and show? (output: %d, layer: %d)",
- FOURCC_STR(formats[f]), pipe, dst_layer_index);
-
-
- HideLayer();
-
- TestDone();
- }
- }
-}
-
-#ifdef TDM_UT_TEST_WITH_PARAMS
-INSTANTIATE_TEST_CASE_P(TDMBackendCaptureParams,
- TDMBackendCapture,
- Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
-#else
-INSTANTIATE_TEST_CASE_P(TDMBackendCaptureParams,
- TDMBackendCapture,
- Values(TDM_DEFAULT_MODULE));
-#endif
-
-/* LCOV_EXCL_END */
\ No newline at end of file
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
- *
- * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
- * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
- * Contact: Roman Marchenko <r.marchenko@samsung.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
-**************************************************************************/
-
-#include "ut_tdm.h"
-
-/* LCOV_EXCL_START */
-
-#define TDM_UT_BACKEND_TEST_CNT 20
-
-TDMBackendBasic::TDMBackendBasic()
-{
- dpy = NULL;
- outputs = NULL;
- output_count = 0;
- layers = NULL;
- layer_count = 0;
-
- for (int b = 0; b < 3; b++)
- buffers[b] = NULL;
-}
-
-void TDMBackendBasic::SetUp(void)
-{
- tdm_error ret;
-
- TDMBackendEnv::SetUp();
-
- dpy = tdm_display_init(&ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(dpy, NULL);
-
- ASSERT_EQ(tdm_display_get_output_count(dpy, &output_count), TDM_ERROR_NONE);
- ASSERT_GE(output_count, 0);
-
- if (output_count > 0) {
- outputs = (tdm_output**)calloc(output_count, sizeof(tdm_output*));
- ASSERT_NE(outputs, NULL);
-
- for (int o = 0; o < output_count; o++) {
- tdm_error ret;
- tdm_output *output = tdm_display_get_output(dpy, o, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(output, NULL);
- outputs[o] = output;
- }
- }
-
- for (int o = 0; o < output_count; o++) {
- int old_layer_count = layer_count, count = TDM_UT_INVALID_VALUE;
- tdm_error ret;
-
- if (ut_tdm_output_is_hwc_enable(outputs[o]))
- continue;
-
- ASSERT_EQ(tdm_output_get_layer_count(outputs[o], &count), TDM_ERROR_NONE);
- ASSERT_GT(count, 0);
-
- layer_count += count;
- layers = (tdm_layer**)realloc(layers, layer_count * sizeof(tdm_layer*));
- ASSERT_NE(layers, NULL);
-
- for (int l = 0; l < count; l++) {
- tdm_layer *layer = tdm_output_get_layer(outputs[o], l, &ret);
- ASSERT_NE(layer, NULL);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- layers[old_layer_count + l] = layer;
- }
- }
-}
-
-void TDMBackendBasic::TearDown(void)
-{
- tdm_display_deinit(dpy);
- dpy = NULL;
-
- free(outputs);
- outputs = NULL;
- output_count = 0;
-
- free(layers);
- layers = NULL;
- layer_count = 0;
-
- DestroyBuffers();
-
- ASSERT_EQ(tbm_bufmgr_debug_get_ref_count(), 0);
-
- TDMBackendEnv::TearDown();
-}
-
-void TDMBackendBasic::DestroyBuffers(void)
-{
- for (int b = 0; b < 3; b++) {
- if (buffers[b])
- tbm_surface_destroy(buffers[b]);
- buffers[b] = NULL;
- }
-}
-
-char
-ut_tdm_backend_getchar(void)
-{
- int c = getchar();
- int ch = c;
-
- if (ch == '\n' || ch == '\r')
- ch = 'y';
- else if (ch < 'a')
- ch += ('a' - 'A');
-
- while (c != '\n' && c != EOF)
- c = getchar();
-
- return ch;
-}
-
-TEST_P(TDMBackendBasic, VerifyOutputObject)
-{
- tdm_error ret;
- int output_count = 0;
-
- ASSERT_EQ(tdm_display_get_output_count(dpy, &output_count), TDM_ERROR_NONE);
- TDM_UT_ASSERT_TRUE(output_count > 0, "output count(%d) should be greater than 0. Check display_get_outputs().");
-
- for (int o = 0; o < output_count; o++) {
- tdm_output *output = tdm_display_get_output(dpy, o, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- TDM_UT_ASSERT_TRUE(output != NULL, "no output. (output: %d). Check display_get_outputs().", o);
- }
-}
-
-TEST_P(TDMBackendBasic, VerifyLayerObject)
-{
- tdm_error ret;
- int output_count = 0;
-
- ASSERT_EQ(tdm_display_get_output_count(dpy, &output_count), TDM_ERROR_NONE);
-
- for (int o = 0; o < output_count; o++) {
- tdm_output *output = tdm_display_get_output(dpy, o, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
-
- int layer_count = 0;
- ASSERT_EQ(tdm_output_get_layer_count(output, &layer_count), TDM_ERROR_NONE);
- TDM_UT_ASSERT_TRUE(layer_count > 0,
- "layer count(%d) should be greater than 0. (output: %d). Check output_get_layers().",
- layer_count, o);
-
- for (int l = 0; l < layer_count; l++) {
- tdm_layer *layer = tdm_output_get_layer(output, l, &ret);
- TDM_UT_ASSERT_TRUE(layer != NULL, "no layer. (output: %d, layer: %d). Check output_get_layers().", o, l);
- }
- }
-}
-
-TEST_P(TDMBackendBasic, VerifyOutputGetProperty)
-{
- tdm_error ret;
- int output_count = 0;
-
- ASSERT_EQ(tdm_display_get_output_count(dpy, &output_count), TDM_ERROR_NONE);
-
- for (int o = 0; o < output_count; o++) {
- tdm_output *output = tdm_display_get_output(dpy, o, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
-
- const tdm_prop *props = NULL;
- int prop_count = 0;
- ASSERT_EQ(tdm_output_get_available_properties(output, &props, &prop_count), TDM_ERROR_NONE);
-
- if (prop_count > 0)
- TDM_UT_ASSERT_TRUE(props != NULL, "no props. (output: %d). Check output_get_capability(), tdm_caps_output.", o);
-
- for (int p = 0; p < prop_count; p++) {
- tdm_value value;
- value.s32 = TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_output_get_property(output, props[p].id, &value), TDM_ERROR_NONE);
- TDM_UT_ASSERT_TRUE(value.s32 != TDM_UT_INVALID_VALUE,
- "Getting a prop failed. (output: %d, prop_id: %d). Check output_get_property().",
- o, props[p].id);
- }
- }
-}
-
-TEST_P(TDMBackendBasic, VerifyLayerGetProperty)
-{
- tdm_error ret;
- int output_count = 0;
-
- ASSERT_EQ(tdm_display_get_output_count(dpy, &output_count), TDM_ERROR_NONE);
-
- for (int o = 0; o < output_count; o++) {
- tdm_output *output = tdm_display_get_output(dpy, o, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
-
- int layer_count = 0;
- ASSERT_EQ(tdm_output_get_layer_count(output, &layer_count), TDM_ERROR_NONE);
-
- for (int l = 0; l < layer_count; l++) {
- tdm_layer *layer = tdm_output_get_layer(output, l, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
-
- const tdm_prop *props = NULL;
- int prop_count = 0;
- ASSERT_EQ(tdm_layer_get_available_properties(layer, &props, &prop_count), TDM_ERROR_NONE);
-
- if (prop_count > 0)
- TDM_UT_ASSERT_TRUE(props != NULL, "no props. (output: %d, layer: %d). Check output_get_capability(), tdm_caps_output.", o, l);
-
- for (int p = 0; p < prop_count; p++) {
- tdm_value value;
- value.s32 = TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_layer_get_property(layer, props[p].id, &value), TDM_ERROR_NONE);
- TDM_UT_ASSERT_TRUE(value.s32 != TDM_UT_INVALID_VALUE,
- "Getting a prop failed. (output: %d, layer: %d, prop_id: %d). Check output_get_property().",
- o, l, props[p].id);
- }
- }
- }
-}
-
-TEST_P(TDMBackendBasic, VerifyOutputSetMode)
-{
- for (int o = 0; o < output_count; o++) {
- const tdm_output_mode *got_mode = NULL;
- const tdm_output_mode *modes = (const tdm_output_mode *)TDM_UT_INVALID_VALUE;
- const tdm_output_mode *set_mode = NULL;
- const tdm_output_mode *best = NULL;
- int count = TDM_UT_INVALID_VALUE;
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(tdm_output_get_available_modes(outputs[o], &modes, &count), TDM_ERROR_NONE);
- TDM_UT_ASSERT_TRUE(count > 0, "mode's count should be greater than 0. Check output_get_capability(), tdm_caps_output.");
- TDM_UT_ASSERT_TRUE(modes != NULL, "mode's count should be greater than 0. Check output_get_capability(), tdm_caps_output.");
-
- for (int i = 0; i < count; i++) {
- if (!best)
- best = &modes[i];
- if (modes[i].type & TDM_OUTPUT_MODE_TYPE_PREFERRED)
- set_mode = &modes[i];
- }
- if (!set_mode && best)
- set_mode = best;
- ASSERT_NE(set_mode, NULL);
-
- ASSERT_EQ(tdm_output_set_mode(outputs[o], set_mode), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_get_mode(outputs[o], &got_mode), TDM_ERROR_NONE);
- TDM_UT_ASSERT_TRUE(set_mode == got_mode, "The mode which is set and got are different. Check output_set_mode(), output_get_mode()");
- }
-}
-
-TEST_P(TDMBackendBasic, VerifyOutputSetDpms)
-{
- for (int o = 0; o < output_count; o++) {
- const tdm_output_mode *got_mode = NULL;
- const tdm_output_mode *modes = (const tdm_output_mode *)TDM_UT_INVALID_VALUE;
- const tdm_output_mode *set_mode = NULL;
- const tdm_output_mode *best = NULL;
- int count = TDM_UT_INVALID_VALUE;
- tdm_output_dpms got_dpms = TDM_OUTPUT_DPMS_OFF;
- tdm_output_dpms set_dpms = TDM_OUTPUT_DPMS_ON;
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(tdm_output_get_available_modes(outputs[o], &modes, &count), TDM_ERROR_NONE);
- ASSERT_GT(count, 0);
- ASSERT_NE(modes, NULL);
-
- for (int i = 0; i < count; i++) {
- if (!best)
- best = &modes[i];
- if (modes[i].type & TDM_OUTPUT_MODE_TYPE_PREFERRED)
- set_mode = &modes[i];
- }
- if (!set_mode && best)
- set_mode = best;
-
- ASSERT_NE(set_mode, NULL);
- ASSERT_EQ(tdm_output_set_mode(outputs[o], set_mode), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_get_mode(outputs[o], &got_mode), TDM_ERROR_NONE);
- ASSERT_EQ(set_mode, got_mode);
-
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], set_dpms), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_get_dpms(outputs[o], &got_dpms), TDM_ERROR_NONE);
- TDM_UT_ASSERT_TRUE(set_dpms == got_dpms, "The dpms value which is set and got are different. Check output_set_dpms(), output_get_dpms()");
- }
-}
-
-TEST_P(TDMBackendBasic, VerifyPrimaryLayerShowOneFrame)
-{
- for (int o = 0; o < output_count; o++) {
- tdm_layer *layer;
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_mode_setting(outputs[o]), true);
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
-
- layer = ut_tdm_output_get_primary_layer(outputs[o]);
- ASSERT_NE(layer, NULL);
-
-retry:
- ASSERT_EQ(ut_tdm_layer_prepare_buffer(layer, buffers, 1, true), true);
- ASSERT_EQ(ut_tdm_layer_set_buffer(layer, buffers[0]), true);
- DestroyBuffers();
-
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
-
- TDM_UT_ASK_YNR("* Successed to display a frame to a primary layer? (output: %d)", o);
-
- ASSERT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
-
- }
-}
-
-TEST_P(TDMBackendBasic, VerifyPrimaryLayerShowManyFrames)
-{
- for (int o = 0; o < output_count; o++) {
- tdm_layer *layer;
- int next_buffer = 0;
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_mode_setting(outputs[o]), true);
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
-
- layer = ut_tdm_output_get_primary_layer(outputs[o]);
- ASSERT_NE(layer, NULL);
-
-retry:
- ASSERT_EQ(ut_tdm_layer_prepare_buffer(layer, buffers, 3, true), true);
-
- /* set buffer & commit for TDM_UT_BACKEND_TEST_CNT times */
- for (int t = 0; t < TDM_UT_BACKEND_TEST_CNT; t++) {
- ASSERT_EQ(ut_tdm_layer_set_buffer(layer, buffers[next_buffer]), true);
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
- usleep(40000); /* 40 ms */
- next_buffer++;
- if (next_buffer == 3)
- next_buffer = 0;
- }
-
- DestroyBuffers();
-
- TDM_UT_ASK_YNR("* Successed to display many frames to a primary layer? (output: %d)", o);
-
- ASSERT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
- }
-}
-
-static void
-_ut_tdm_backend_output_commit_cb(tdm_output *output, unsigned int sequence,
- unsigned int tv_sec, unsigned int tv_usec,
- void *user_data)
-{
- bool *done = (bool*)user_data;
- if (done)
- *done = true;
-}
-
-TEST_P(TDMBackendBasic, VerifyPrimaryLayerShowOneFrameWithCommitHandler)
-{
- for (int o = 0; o < output_count; o++) {
- tdm_layer *layer;
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_mode_setting(outputs[o]), true);
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
-
- layer = ut_tdm_output_get_primary_layer(outputs[o]);
- ASSERT_NE(layer, NULL);
-
-retry:
- ASSERT_EQ(ut_tdm_layer_prepare_buffer(layer, buffers, 1, true), true);
- ASSERT_EQ(ut_tdm_layer_set_buffer(layer, buffers[0]), true);
- DestroyBuffers();
-
- bool done = false;
- TDM_UT_ASSERT_TRUE(tdm_output_commit(outputs[o], 0, _ut_tdm_backend_output_commit_cb, &done) == TDM_ERROR_NONE,
- "Check output_commit(), output_set_commit_handler()");
- while (!done)
- TDM_UT_ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE,
- "Check display_get_fd(), display_handle_events()");
-
- TDM_UT_ASK_YNR("* Successed to display a frame to a primary layer? (output: %d)", o);
-
- ASSERT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
- }
-}
-
-TEST_P(TDMBackendBasic, VerifyOverlayLayersShowOneFrame)
-{
- for (int o = 0; o < output_count; o++) {
- tdm_layer *layer;
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_mode_setting(outputs[o]), true);
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
-
- layer = ut_tdm_output_get_primary_layer(outputs[o]);
- ASSERT_NE(layer, NULL);
-
- ASSERT_EQ(ut_tdm_layer_prepare_buffer(layer, buffers, 1, false), true);
- ASSERT_EQ(ut_tdm_layer_set_buffer(layer, buffers[0]), true);
- DestroyBuffers();
-
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
- usleep(40000); /* 40 ms */
-
-retry:
- for (int l = 0; l < layer_count; l++) {
- tdm_error ret;
-
- if (tdm_layer_get_output(layers[l], &ret) != outputs[o])
- continue;
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- if (ut_tdm_layer_is_primary_layer(layers[l]))
- continue;
- if (ut_tdm_layer_is_cursor_layer(layers[l]))
- continue;
- ASSERT_EQ(ut_tdm_layer_prepare_buffer(layers[l], buffers, 1, true), true);
- ASSERT_EQ(ut_tdm_layer_set_buffer(layers[l], buffers[0]), true);
- DestroyBuffers();
- }
-
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
-
- TDM_UT_ASK_YNR("* Successed to display frames to all overlay layers? (output: %d)", o);
-
- for (int l = 0; l < layer_count; l++)
- ASSERT_EQ(tdm_layer_unset_buffer(layers[l]), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
- }
-}
-
-TEST_P(TDMBackendBasic, VerifyOverlayLayersShowManyFrames)
-{
- for (int o = 0; o < output_count; o++) {
- tdm_layer *layer;
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_mode_setting(outputs[o]), true);
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
-
- layer = ut_tdm_output_get_primary_layer(outputs[o]);
- ASSERT_NE(layer, NULL);
-
- ASSERT_EQ(ut_tdm_layer_prepare_buffer(layer, buffers, 1, false), true);
- ASSERT_EQ(ut_tdm_layer_set_buffer(layer, buffers[0]), true);
- DestroyBuffers();
-
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
- usleep(40000); /* 40 ms */
-
- for (int l = 0; l < layer_count; l++) {
- tdm_error ret;
- int next_buffer = 0;
-
- if (tdm_layer_get_output(layers[l], &ret) != outputs[o])
- continue;
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- if (ut_tdm_layer_is_primary_layer(layers[l]))
- continue;
- if (ut_tdm_layer_is_cursor_layer(layers[l]))
- continue;
-
-retry:
- ASSERT_EQ(ut_tdm_layer_prepare_buffer(layers[l], buffers, 3, true), true);
-
- /* set buffer & commit for TDM_UT_BACKEND_TEST_CNT times */
- for (int t = 0; t < TDM_UT_BACKEND_TEST_CNT; t++) {
- ASSERT_EQ(ut_tdm_layer_set_buffer(layers[l], buffers[next_buffer]), true);
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
- usleep(40000); /* 40 ms */
- next_buffer++;
- if (next_buffer == 3)
- next_buffer = 0;
- }
-
- DestroyBuffers();
-
- TDM_UT_ASK_YNR("* Successed to display many frames to a layer? (output: %d, layer: %d)", o, l);
-
- ASSERT_EQ(tdm_layer_unset_buffer(layers[l]), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
- usleep(40000); /* 40 ms */
- }
- }
-}
-
-TEST_P(TDMBackendBasic, DISABLED_VerifyCursorLayer)
-{
-}
-
-static void
-_ut_tdm_backend_output_done_cb(tdm_output *output, unsigned int sequence,
- unsigned int tv_sec, unsigned int tv_usec,
- void *user_data)
-{
- bool *done = (bool*)user_data;
- if (done)
- *done = true;
-}
-
-TEST_P(TDMBackendBasic, VerifyOutputWaitVblank)
-{
- for (int o = 0; o < output_count; o++) {
- tdm_layer *layer;
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_mode_setting(outputs[o]), true);
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
-
- layer = ut_tdm_output_get_primary_layer(outputs[o]);
- ASSERT_NE(layer, NULL);
-
- ASSERT_EQ(ut_tdm_layer_prepare_buffer(layer, buffers, 1, true), true);
- ASSERT_EQ(ut_tdm_layer_set_buffer(layer, buffers[0]), true);
- DestroyBuffers();
-
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
-
- /* start from 1 */
- for (int t = 1; t < 10; t++) {
- double start, end, interval;
- bool done;
-
- interval = ut_tdm_output_get_vblank_interval_time(outputs[o]);
-
- done = false;
- start = tdm_helper_get_time();
- TDM_UT_ASSERT_TRUE(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_backend_output_done_cb, &done) == TDM_ERROR_NONE,
- "Check output_wait_vblank(), output_set_vblank_handler()");
- while (!done)
- TDM_UT_ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE,
- "Check display_get_fd(), display_handle_events()");
- end = tdm_helper_get_time();
-
- /* "+ interval" consider the delay of socket communication between kernel and platform */
- TDM_UT_ASSERT_TRUE((end - start) > (interval * (t - 1)),
- "The vblank event should happen after %d vsync intervals(%d ms).\n"
- "\t But it happened at %d ms. Check output_wait_vblank(), output_set_vblank_handler()",
- t, (int)(t * interval * 1000), (int)((end - start) * 1000));
- TDM_UT_ASSERT_TRUE((end - start) < (interval * t + interval),
- "The vblank event should happen after %d vsync intervals(%d ms).\n"
- "\t But it happened at %d ms. Check output_wait_vblank(), output_set_vblank_handler()",
- t, (int)(t * interval * 1000), (int)((end - start) * 1000));
-
- }
- }
-}
-
-TEST_P(TDMBackendBasic, VerifyOutputWaitVblankInterval)
-{
- for (int o = 0; o < output_count; o++) {
- tdm_layer *layer;
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_mode_setting(outputs[o]), true);
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
-
- layer = ut_tdm_output_get_primary_layer(outputs[o]);
- ASSERT_NE(layer, NULL);
-
- ASSERT_EQ(ut_tdm_layer_prepare_buffer(layer, buffers, 1, true), true);
- ASSERT_EQ(ut_tdm_layer_set_buffer(layer, buffers[0]), true);
- DestroyBuffers();
-
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
-
- /* start from 1 */
- for (int t = 1; t < 10; t++) {
- double start, end, interval;
- bool done;
-
- interval = ut_tdm_output_get_vblank_interval_time(outputs[o]);
-
- done = false;
- start = tdm_helper_get_time();
- ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_backend_output_done_cb, &done), TDM_ERROR_NONE);
- while (!done)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- end = tdm_helper_get_time();
-
- /* "+ interval" consider the delay of socket communication between kernel and platform */
- TDM_UT_ASSERT_TRUE((end - start) > (interval * (t - 1)),
- "The vblank event should happen after %d vsync intervals(%d ms).\n"
- "\t But it happened at %d ms. Check output_wait_vblank(), output_set_vblank_handler()",
- t, (int)(t * interval * 1000), (int)((end - start) * 1000));
- TDM_UT_ASSERT_TRUE((end - start) < (interval * t + interval),
- "The vblank event should happen after %d vsync intervals(%d ms).\n"
- "\t But it happened at %d ms. Check output_wait_vblank(), output_set_vblank_handler()",
- t, (int)(t * interval * 1000), (int)((end - start) * 1000));
- }
- }
-}
-
-TEST_P(TDMBackendBasic, VerifyOutputWaitVblankFewTimesInOneVblank)
-{
- for (int o = 0; o < output_count; o++) {
- tdm_layer *layer;
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_mode_setting(outputs[o]), true);
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
-
- layer = ut_tdm_output_get_primary_layer(outputs[o]);
- ASSERT_NE(layer, NULL);
-
- ASSERT_EQ(ut_tdm_layer_prepare_buffer(layer, buffers, 1, true), true);
- ASSERT_EQ(ut_tdm_layer_set_buffer(layer, buffers[0]), true);
- DestroyBuffers();
-
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
-
- /* start from 1 */
- for (int t = 1; t < 10; t++) {
- double start, end, interval;
- bool done1, done2, done3;
-
- interval = ut_tdm_output_get_vblank_interval_time(outputs[o]);
-
- done1 = done2 = done3 = false;
- ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_backend_output_done_cb, &done1), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_backend_output_done_cb, &done2), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_backend_output_done_cb, &done3), TDM_ERROR_NONE);
- start = tdm_helper_get_time();
- while (!done1 || !done2 || !done3)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- end = tdm_helper_get_time();
-
- /* "+ interval" consider the delay of socket communication between kernel and platform */
- TDM_UT_ASSERT_TRUE((end - start) > (interval * (t - 1)),
- "The vblank event should happen after %d vsync intervals(%d ms).\n"
- "\t But it happened at %d ms. Check output_wait_vblank(), output_set_vblank_handler()",
- t, (int)(t * interval * 1000), (int)((end - start) * 1000));
- TDM_UT_ASSERT_TRUE((end - start) < (interval * t + interval),
- "The vblank event should happen after %d vsync intervals(%d ms).\n"
- "\t But it happened at %d ms. Check output_wait_vblank(), output_set_vblank_handler()",
- t, (int)(t * interval * 1000), (int)((end - start) * 1000));
- }
- }
-}
-
-TEST_P(TDMBackendBasic, VerifyPPObject)
-{
- tdm_error ret;
- tdm_pp *pp;
-
- if (!ut_tdm_display_has_pp_capability(dpy)) {
- TDM_UT_INFO("PP not supported");
- return;
- }
-
- pp = tdm_display_create_pp(dpy, &ret);
- TDM_UT_ASSERT_TRUE(ret == TDM_ERROR_NONE, "can't create a PP object. Check display_create_pp()");
- TDM_UT_ASSERT_TRUE(pp != NULL, "can't create a PP object. Check display_create_pp()");
-
- tdm_pp_destroy(pp);
-}
-
-TEST_P(TDMBackendBasic, VerifyPPCapabilities)
-{
- tdm_pp_capability capabilities = (tdm_pp_capability)0;
-
- if (!ut_tdm_display_has_pp_capability(dpy)) {
- TDM_UT_INFO("PP not supported");
- return;
- }
-
- TDM_UT_ASSERT_TRUE(tdm_display_get_pp_capabilities(dpy, &capabilities) == TDM_ERROR_NONE,
- "Check display_get_pp_capability(), tdm_caps_pp, tdm_pp_capability.");
- TDM_UT_ASSERT_TRUE(capabilities != (tdm_pp_capability)0,
- "PP has no capability. Check display_get_pp_capability(), tdm_caps_pp, tdm_pp_capability.");
-}
-
-TEST_P(TDMBackendBasic, VerifyPPAvaiableSize)
-{
- if (!ut_tdm_display_has_pp_capability(dpy)) {
- TDM_UT_INFO("PP not supported");
- return;
- }
-
- int min_w = 0;
- int min_h = 0;
- int max_w = 0;
- int max_h = 0;
- int preferred_align = 0;
- ASSERT_EQ(tdm_display_get_pp_available_size(dpy, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_NONE);
- ASSERT_NE(min_w, 0);
- ASSERT_NE(min_h, 0);
- ASSERT_NE(max_w, 0);
- ASSERT_NE(max_h, 0);
- ASSERT_NE(preferred_align, 0);
-}
-
-TEST_P(TDMBackendBasic, VerifyPPAvaiableFormats)
-{
- if (!ut_tdm_display_has_pp_capability(dpy)) {
- TDM_UT_INFO("PP not supported");
- return;
- }
-
- const tbm_format *formats = NULL;
- int format_count = 0;
- TDM_UT_ASSERT_TRUE(tdm_display_get_pp_available_formats(dpy, &formats, &format_count) == TDM_ERROR_NONE,
- "Check display_get_pp_capability(), tdm_caps_pp");
- TDM_UT_ASSERT_TRUE(formats != NULL, "Should have a format table. Check display_get_pp_capability(), tdm_caps_pp.");
- TDM_UT_ASSERT_TRUE(format_count > 0, "Format count should be greater than 0. Check display_get_pp_capability(), tdm_caps_pp.");
-}
-
-TEST_P(TDMBackendBasic, VerifyCaptureObject)
-{
- if (!ut_tdm_display_has_capture_capability(dpy)) {
- TDM_UT_INFO("Capture not supported.");
- return;
- }
-
- for (int o = 0; o < output_count; o++) {
- tdm_capture *capture;
- tdm_error ret;
-
- unsigned int has_capability = 0;
- ASSERT_EQ(tdm_output_has_capture_capability(outputs[o], &has_capability), TDM_ERROR_NONE);
- if (!has_capability) {
- TDM_UT_INFO("Capture not supported. (output: %d)", o);
- continue;
- }
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- capture = tdm_output_create_capture(outputs[o], &ret);
- TDM_UT_ASSERT_TRUE(ret == TDM_ERROR_NONE, "Can't create a capture object. Check output_create_capture().");
- TDM_UT_ASSERT_TRUE(capture != NULL, "Can't create a capture object. Check output_create_capture().");
-
- tdm_capture_destroy(capture);
- }
-}
-
-TEST_P(TDMBackendBasic, VerifyCaptureAvaiableSize)
-{
- if (!ut_tdm_display_has_capture_capability(dpy)) {
- TDM_UT_INFO("Capture not supported.");
- return;
- }
-
- int min_w = 0;
- int min_h = 0;
- int max_w = 0;
- int max_h = 0;
- int preferred_align = 0;
- ASSERT_EQ(tdm_display_get_capture_available_size(dpy, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_NONE);
- ASSERT_NE(min_w, 0);
- ASSERT_NE(min_h, 0);
- ASSERT_NE(max_w, 0);
- ASSERT_NE(max_h, 0);
- ASSERT_NE(preferred_align, 0);
-}
-
-TEST_P(TDMBackendBasic, VerifyCaptureAvaiableFormats)
-{
- if (!ut_tdm_display_has_capture_capability(dpy)) {
- TDM_UT_INFO("Capture not supported.");
- return;
- }
-
- const tbm_format *formats = NULL;
- int format_count = 0;
- TDM_UT_ASSERT_TRUE(tdm_display_get_capture_available_formats(dpy, &formats, &format_count) == TDM_ERROR_NONE,
- "Check display_get_capture_capability(), tdm_caps_capture.");
- TDM_UT_ASSERT_TRUE(formats != NULL, "Should have a format table. Check display_get_capture_capability(), tdm_caps_capture.");
- TDM_UT_ASSERT_TRUE(format_count > 0, "The format count should be greater than 0. Check display_get_capture_capability(), tdm_caps_capture.");
-}
-
-#ifdef TDM_UT_TEST_WITH_PARAMS
-INSTANTIATE_TEST_CASE_P(TDMBackendBasicParams,
- TDMBackendBasic,
- Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
-#else
-INSTANTIATE_TEST_CASE_P(TDMBackendBasicParams,
- TDMBackendBasic,
- Values(TDM_DEFAULT_MODULE));
-#endif
-
-TEST_P(TDMBackendDisplay, VerifyPirmaryLayerFormat)
-{
- for (int o = 0; o < output_count; o++) {
- tdm_layer *layer;
- int next_buffer = 0;
- bool done = false;
- tdm_error ret;
- const tbm_format *formats;
- int format_count = 0;
- const tdm_output_mode *mode = NULL;
- unsigned int flags = 0;
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- layer = ut_tdm_output_get_primary_layer(outputs[o]);
- ASSERT_NE(layer, NULL);
-
- ASSERT_EQ(tdm_layer_get_buffer_flags(layer, &flags), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_layer_get_available_formats(layer, &formats, &format_count), TDM_ERROR_NONE);
-
- for (int f = 0; f < format_count; f++) {
- ASSERT_EQ(ut_tdm_output_mode_setting(outputs[o]), true);
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE);
- ASSERT_NE(mode, NULL);
-
-retry:
- TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(formats[f]));
- ASSERT_EQ(ut_tdm_buffer_create(mode->hdisplay, mode->vdisplay, formats[f], flags | TBM_BO_SCANOUT, true, 3, buffers), true);
-
- /* set buffer & commit for 60 times */
- for (int t = 0; t < 60; t++) {
- tbm_surface_h displaying_buffer;
- ASSERT_EQ(ut_tdm_layer_set_buffer(layer, buffers[next_buffer]), true);
- done = false;
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, _ut_tdm_backend_output_commit_cb, &done), TDM_ERROR_NONE);
- while (!done)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_EQ(displaying_buffer, buffers[next_buffer]);
- next_buffer++;
- if (next_buffer == 3)
- next_buffer = 0;
- }
-
- DestroyBuffers();
-
- TDM_UT_ASK_YNR("* Successed to display '%c%c%c%c' frames to a primary layer? (output: %d)", FOURCC_STR(formats[f]), o);
- }
- }
-}
-
-TEST_P(TDMBackendDisplay, VerifyOverlayLayerFormat)
-{
- ASSERT_EQ(ut_tdm_output_prepare_all_output(dpy, outputs, output_count, false), true);
-
- for (int l = 0; l < layer_count; l++) {
- tdm_error ret;
- tdm_output *output;
- tdm_layer *layer;
- int next_buffer = 0;
- bool done = false;
- const tbm_format *formats;
- int format_count = 0;
- const tdm_output_mode *mode = NULL;
- unsigned int flags = 0;
- unsigned int pipe = 0;
-
- layer = layers[l];
-
- output = tdm_layer_get_output(layer, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
-
- if (!ut_tdm_output_is_connected(output))
- continue;
- if (ut_tdm_layer_is_primary_layer(layer))
- continue;
- if (ut_tdm_layer_is_cursor_layer(layer))
- continue;
-
- ASSERT_EQ(tdm_output_get_pipe(output, &pipe), TDM_ERROR_NONE);
-
- TDM_UT_INFO("* testing for (output: %d, layer: %d)", pipe, l);
-
- ASSERT_EQ(tdm_layer_get_buffer_flags(layer, &flags), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_get_mode(output, &mode), TDM_ERROR_NONE);
- ASSERT_NE(mode, NULL);
-
- ASSERT_EQ(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
-
- ASSERT_EQ(tdm_layer_get_available_formats(layer, &formats, &format_count), TDM_ERROR_NONE);
-
- for (int f = 0; f < format_count; f++) {
-retry:
- TDM_UT_INFO("** testing for %c%c%c%c", FOURCC_STR(formats[f]));
- ASSERT_EQ(ut_tdm_buffer_create(mode->hdisplay, mode->vdisplay, formats[f], flags | TBM_BO_SCANOUT, true, 3, buffers), true);
-
- /* set buffer & commit for TDM_UT_BACKEND_TEST_CNT times */
- for (int t = 0; t < TDM_UT_BACKEND_TEST_CNT; t++) {
- tbm_surface_h displaying_buffer;
- ASSERT_EQ(ut_tdm_layer_set_buffer(layer, buffers[next_buffer]), true);
- done = false;
- ASSERT_EQ(tdm_output_commit(output, 0, _ut_tdm_backend_output_commit_cb, &done), TDM_ERROR_NONE);
- while (!done)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_EQ(displaying_buffer, buffers[next_buffer]);
- next_buffer++;
- if (next_buffer == 3)
- next_buffer = 0;
- }
-
- TDM_UT_ASK_YNR("* Successed to display '%c%c%c%c' frames to a layer? (output: %d, layer: %d)", FOURCC_STR(formats[f]), pipe, l);
-
- DestroyBuffers();
- }
-
- ASSERT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE);
- }
-}
-
-TEST_P(TDMBackendDisplay, VerifyOverlayLayerSize)
-{
- ASSERT_EQ(ut_tdm_output_prepare_all_output(dpy, outputs, output_count, false), true);
-
- for (int l = 0; l < layer_count; l++) {
- tdm_error ret;
- tdm_output *output;
- tdm_layer *layer;
- int next_buffer = 0;
- bool done = false;
- const tbm_format *formats;
- int format_count = 0;
- const tdm_output_mode *mode = NULL;
- unsigned int flags = 0;
- unsigned int pipe = 0;
-
- layer = layers[l];
-
- output = tdm_layer_get_output(layer, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
-
- if (!ut_tdm_output_is_connected(output))
- continue;
- if (ut_tdm_layer_is_primary_layer(layer))
- continue;
- if (ut_tdm_layer_is_cursor_layer(layer))
- continue;
-
- ASSERT_EQ(tdm_output_get_pipe(output, &pipe), TDM_ERROR_NONE);
-
- TDM_UT_INFO("* testing for (output: %d, layer: %d)", pipe, l);
-
- ASSERT_EQ(tdm_layer_get_buffer_flags(layer, &flags), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_get_mode(output, &mode), TDM_ERROR_NONE);
- ASSERT_NE(mode, NULL);
-
- ASSERT_EQ(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
-
- ASSERT_EQ(tdm_layer_get_available_formats(layer, &formats, &format_count), TDM_ERROR_NONE);
-
- for (int f = 0; f < format_count; f++) {
- int diffw = mode->hdisplay / (format_count + 2);
- int diffh = mode->vdisplay / (format_count + 2);
- int w = mode->hdisplay - diffw * (f + 1);
- int h = mode->vdisplay - diffh * (f + 1);
-retry:
- TDM_UT_INFO("** testing for %c%c%c%c", FOURCC_STR(formats[f]));
- ASSERT_EQ(ut_tdm_buffer_create(w, h, formats[f], flags | TBM_BO_SCANOUT, true, 3, buffers), true);
-
- /* set buffer & commit for TDM_UT_BACKEND_TEST_CNT times */
- for (int t = 0; t < TDM_UT_BACKEND_TEST_CNT; t++) {
- tbm_surface_h displaying_buffer;
- ASSERT_EQ(ut_tdm_layer_set_buffer(layer, buffers[next_buffer]), true);
- done = false;
- ASSERT_EQ(tdm_output_commit(output, 0, _ut_tdm_backend_output_commit_cb, &done), TDM_ERROR_NONE);
- while (!done)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_EQ(displaying_buffer, buffers[next_buffer]);
- next_buffer++;
- if (next_buffer == 3)
- next_buffer = 0;
- }
-
- DestroyBuffers();
-
- TDM_UT_ASK_YNR("* Successed to display '%c%c%c%c' small size(%dx%d) frames to a layer? (output: %d, layer: %d)",
- FOURCC_STR(formats[f]), w, h, pipe, l);
- }
-
- ASSERT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE);
- }
-}
-
-TEST_P(TDMBackendDisplay, VerifyOverlayLayerScale)
-{
- ASSERT_EQ(ut_tdm_output_prepare_all_output(dpy, outputs, output_count, false), true);
-
- for (int l = 0; l < layer_count; l++) {
- tdm_error ret;
- tdm_output *output;
- tdm_layer *layer;
- int next_buffer = 0;
- bool done = false;
- const tbm_format *formats;
- int format_count = 0;
- const tdm_output_mode *mode = NULL;
- unsigned int flags = 0;
- unsigned int pipe = 0;
-
- layer = layers[l];
-
- output = tdm_layer_get_output(layer, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
-
- ASSERT_EQ(tdm_output_get_pipe(output, &pipe), TDM_ERROR_NONE);
-
- if (!ut_tdm_output_is_connected(output))
- continue;
- if (ut_tdm_layer_is_primary_layer(layer))
- continue;
- if (ut_tdm_layer_is_cursor_layer(layer))
- continue;
- if (!ut_tdm_layer_support_scale(layer)) {
- TDM_UT_INFO("no scale capability. (output: %d, layer: %d)", pipe, l);
- continue;
- }
-
- ASSERT_EQ(tdm_layer_get_buffer_flags(layer, &flags), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_get_mode(output, &mode), TDM_ERROR_NONE);
- ASSERT_NE(mode, NULL);
-
- ASSERT_EQ(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
-
- ASSERT_EQ(tdm_layer_get_available_formats(layer, &formats, &format_count), TDM_ERROR_NONE);
-
- for (int f = 0; f < format_count; f++) {
-retry:
- TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(formats[f]));
- ASSERT_EQ(ut_tdm_buffer_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f], flags | TBM_BO_SCANOUT, true, 3, buffers), true);
-
- tdm_info_layer info;
- memset(&info, 0, sizeof info);
- info.src_config.size.h = TDM_UT_BUFFER_SIZE;
- info.src_config.size.v = TDM_UT_BUFFER_SIZE;
- info.src_config.pos.x = 0;
- info.src_config.pos.y = 0;
- info.src_config.pos.w = TDM_UT_BUFFER_SIZE;
- info.src_config.pos.h = TDM_UT_BUFFER_SIZE;
- info.src_config.format = formats[f];
- info.dst_pos.x = 0;
- info.dst_pos.y = 0;
- info.dst_pos.w = mode->hdisplay;
- info.dst_pos.h = mode->vdisplay;
- info.transform = TDM_TRANSFORM_NORMAL;
- ASSERT_EQ(tdm_layer_set_info(layer, &info), TDM_ERROR_NONE);
-
- /* set buffer & commit for TDM_UT_BACKEND_TEST_CNT times */
- for (int t = 0; t < TDM_UT_BACKEND_TEST_CNT; t++) {
- tbm_surface_h displaying_buffer;
- ASSERT_EQ(tdm_layer_set_buffer(layer, buffers[next_buffer]), TDM_ERROR_NONE);
- done = false;
- ASSERT_EQ(tdm_output_commit(output, 0, _ut_tdm_backend_output_commit_cb, &done), TDM_ERROR_NONE);
- while (!done)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_EQ(displaying_buffer, buffers[next_buffer]);
- next_buffer++;
- if (next_buffer == 3)
- next_buffer = 0;
- }
-
- DestroyBuffers();
-
- TDM_UT_ASK_YNR("* Successed to scale '%c%c%c%c' small size(%dx%d) frames to fullsreen? (output: %d, layer: %d)",
- FOURCC_STR(formats[f]), TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, pipe, l);
- }
-
- ASSERT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE);
- }
-}
-
-TEST_P(TDMBackendDisplay, VerifyOverlayLayerMovePosition)
-{
- ASSERT_EQ(ut_tdm_output_prepare_all_output(dpy, outputs, output_count, false), true);
-
- for (int l = 0; l < layer_count; l++) {
- tdm_error ret;
- tdm_output *output;
- tdm_layer *layer;
- int next_buffer = 0;
- bool done = false;
- const tbm_format *formats;
- int format_count = 0;
- const tdm_output_mode *mode = NULL;
- unsigned int flags = 0;
- unsigned int pipe = 0;
-
- layer = layers[l];
-
- output = tdm_layer_get_output(layer, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
-
- if (!ut_tdm_output_is_connected(output))
- continue;
- if (ut_tdm_layer_is_primary_layer(layer))
- continue;
- if (ut_tdm_layer_is_cursor_layer(layer))
- continue;
-
- ASSERT_EQ(tdm_output_get_pipe(output, &pipe), TDM_ERROR_NONE);
-
- TDM_UT_INFO("* testing for (output: %d, layer: %d)", pipe, l);
-
- ASSERT_EQ(tdm_layer_get_buffer_flags(layer, &flags), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_get_mode(output, &mode), TDM_ERROR_NONE);
- ASSERT_NE(mode, NULL);
-
- ASSERT_EQ(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
-
- ASSERT_EQ(tdm_layer_get_available_formats(layer, &formats, &format_count), TDM_ERROR_NONE);
-
- for (int f = 0; f < format_count; f++) {
-retry:
- TDM_UT_INFO("** testing for %c%c%c%c", FOURCC_STR(formats[f]));
- ASSERT_EQ(ut_tdm_buffer_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f], flags | TBM_BO_SCANOUT, true, 3, buffers), true);
-
- /* set buffer & commit for TDM_UT_BACKEND_TEST_CNT times */
- for (int t = 0; t < TDM_UT_BACKEND_TEST_CNT; t++) {
- tbm_surface_h displaying_buffer;
-
- tdm_info_layer info;
- memset(&info, 0, sizeof info);
- info.src_config.size.h = TDM_UT_BUFFER_SIZE;
- info.src_config.size.v = TDM_UT_BUFFER_SIZE;
- info.src_config.pos.x = 0;
- info.src_config.pos.y = 0;
- info.src_config.pos.w = TDM_UT_BUFFER_SIZE;
- info.src_config.pos.h = TDM_UT_BUFFER_SIZE;
- info.src_config.format = formats[f];
- info.dst_pos.x = ((mode->hdisplay - TDM_UT_BUFFER_SIZE) / TDM_UT_BACKEND_TEST_CNT) * t;
- info.dst_pos.y = ((mode->vdisplay - TDM_UT_BUFFER_SIZE) / TDM_UT_BACKEND_TEST_CNT) * t;
- info.dst_pos.w = TDM_UT_BUFFER_SIZE;
- info.dst_pos.h = TDM_UT_BUFFER_SIZE;
- info.transform = TDM_TRANSFORM_NORMAL;
- ASSERT_EQ(tdm_layer_set_info(layer, &info), TDM_ERROR_NONE);
-
- ASSERT_EQ(tdm_layer_set_buffer(layer, buffers[next_buffer]), TDM_ERROR_NONE);
- done = false;
- ASSERT_EQ(tdm_output_commit(output, 0, _ut_tdm_backend_output_commit_cb, &done), TDM_ERROR_NONE);
- while (!done)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_EQ(displaying_buffer, buffers[next_buffer]);
- next_buffer++;
- if (next_buffer == 3)
- next_buffer = 0;
- }
-
- DestroyBuffers();
-
- TDM_UT_ASK_YNR("* Successed to move '%c%c%c%c' small size(%dx%d) frames on screen? (output: %d, layer: %d)",
- FOURCC_STR(formats[f]), TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, pipe, l);
- }
-
- ASSERT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE);
- }
-}
-
-TEST_P(TDMBackendDisplay, VerifyOverlayLayerCrop)
-{
- ASSERT_EQ(ut_tdm_output_prepare_all_output(dpy, outputs, output_count, false), true);
-
- for (int l = 0; l < layer_count; l++) {
- tdm_error ret;
- tdm_output *output;
- tdm_layer *layer;
- int next_buffer = 0;
- bool done = false;
- const tbm_format *formats;
- int format_count = 0;
- const tdm_output_mode *mode = NULL;
- unsigned int flags = 0;
- unsigned int pipe = 0;
-
- layer = layers[l];
-
- output = tdm_layer_get_output(layer, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
-
- ASSERT_EQ(tdm_output_get_pipe(output, &pipe), TDM_ERROR_NONE);
-
- if (!ut_tdm_output_is_connected(output))
- continue;
- if (ut_tdm_layer_is_primary_layer(layer))
- continue;
- if (ut_tdm_layer_is_cursor_layer(layer))
- continue;
- if (ut_tdm_layer_support_no_crop(layer)) {
- TDM_UT_INFO("no crop capability. (output: %d, layer: %d)", pipe, l);
- continue;
- }
-
- TDM_UT_INFO("* testing for (output: %d, layer: %d)", pipe, l);
-
- ASSERT_EQ(tdm_layer_get_buffer_flags(layer, &flags), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_get_mode(output, &mode), TDM_ERROR_NONE);
- ASSERT_NE(mode, NULL);
-
- ASSERT_EQ(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
-
- ASSERT_EQ(tdm_layer_get_available_formats(layer, &formats, &format_count), TDM_ERROR_NONE);
-
- for (int f = 0; f < format_count; f++) {
-retry:
- TDM_UT_INFO("** testing for %c%c%c%c", FOURCC_STR(formats[f]));
- ASSERT_EQ(ut_tdm_buffer_create(mode->hdisplay, mode->vdisplay, formats[f], flags | TBM_BO_SCANOUT, true, 3, buffers), true);
-
- tdm_info_layer info;
- memset(&info, 0, sizeof info);
- info.src_config.size.h = mode->hdisplay;
- info.src_config.size.v = mode->vdisplay;
- info.src_config.pos.x = mode->hdisplay / 2;
- info.src_config.pos.y = mode->vdisplay / 2;
- info.src_config.pos.w = info.src_config.size.h / 2;
- info.src_config.pos.h = info.src_config.size.v / 2;
- info.src_config.format = formats[f];
- info.dst_pos.x = info.src_config.pos.x;
- info.dst_pos.y = info.src_config.pos.y;
- info.dst_pos.w = info.src_config.pos.w;
- info.dst_pos.h = info.src_config.pos.h;
- info.transform = TDM_TRANSFORM_NORMAL;
- ASSERT_EQ(tdm_layer_set_info(layer, &info), TDM_ERROR_NONE);
-
- /* set buffer & commit for TDM_UT_BACKEND_TEST_CNT times */
- for (int t = 0; t < TDM_UT_BACKEND_TEST_CNT; t++) {
- tbm_surface_h displaying_buffer;
- ASSERT_EQ(tdm_layer_set_buffer(layer, buffers[next_buffer]), TDM_ERROR_NONE);
- done = false;
- ASSERT_EQ(tdm_output_commit(output, 0, _ut_tdm_backend_output_commit_cb, &done), TDM_ERROR_NONE);
- while (!done)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_EQ(displaying_buffer, buffers[next_buffer]);
- next_buffer++;
- if (next_buffer == 3)
- next_buffer = 0;
- }
-
- DestroyBuffers();
-
- TDM_UT_ASK_YNR("* Successed to crop '%c%c%c%c' frames and display it? (output: %d, layer: %d)",
- FOURCC_STR(formats[f]), pipe, l);
- }
-
- ASSERT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE);
- }
-}
-
-/* should be debugged int emulator kernel */
-TEST_P(TDMBackendDisplay, DISABLED_VerifyOutputSetDpmsFromOnToOff)
-{
- ASSERT_EQ(ut_tdm_output_prepare_all_output(dpy, outputs, output_count, true), true);
-
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
- }
-}
-
-/* should be debugged int emulator kernel */
-TEST_P(TDMBackendDisplay, DISABLED_VerifyOutputSetDpmsFromOffToOn)
-{
- ASSERT_EQ(ut_tdm_output_prepare_all_output(dpy, outputs, output_count, true), true);
-
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
- }
-}
-
-/* should be debugged int emulator kernel */
-TEST_P(TDMBackendDisplay, DISABLED_VerifyOutputSetDpmsToOnBeforeSet)
-{
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_mode_setting(outputs[o]), true);
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
- }
-}
-
-/* should be debugged int emulator kernel */
-TEST_P(TDMBackendDisplay, DISABLED_VerifyOutputSetDpmsToOffBeforeSet)
-{
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_mode_setting(outputs[o]), true);
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
- }
-}
-
-/* should be debugged int emulator kernel */
-TEST_P(TDMBackendDisplay, DISABLED_VerifyOutputSetDpmsToOffAfterUnsetWithoutCommit)
-{
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_prepare(dpy, outputs[o], true), true);
-
- tdm_layer *layer = ut_tdm_output_get_primary_layer(outputs[o]);
- ASSERT_NE(layer, NULL);
-
- ASSERT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE);
-
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
- }
-}
-
-/* should be debugged int emulator kernel */
-TEST_P(TDMBackendDisplay, DISABLED_VerifyOutputSetDpmsToOffAfterUnsetWithCommit)
-{
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_prepare(dpy, outputs[o], true), true);
-
- tdm_layer *layer = ut_tdm_output_get_primary_layer(outputs[o]);
- ASSERT_NE(layer, NULL);
-
- ASSERT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
-
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
- }
-}
-
-TEST_P(TDMBackendDisplay, DISABLED_VerifyOutputSetDpmsAsync)
-{
-}
-
-TEST_P(TDMBackendDisplay, VerifyLayerGetInfo)
-{
- ASSERT_EQ(ut_tdm_output_prepare_all_output(dpy, outputs, output_count, true), true);
-
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- tbm_surface_h displaying_buffer;
- tdm_error ret;
- tdm_info_layer info, temp;
- tdm_layer *layer = ut_tdm_output_get_primary_layer(outputs[o]);
- ASSERT_NE(layer, NULL);
-
- displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret);
- ASSERT_NE(displaying_buffer, NULL);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_EQ(ut_tdm_layer_fill_info(layer, displaying_buffer, NULL, &info), true);
- ASSERT_EQ(tdm_layer_get_info(layer, &temp), TDM_ERROR_NONE);
- ASSERT_EQ(memcmp(&info, &temp, sizeof info), 0);
- }
-}
-
-TEST_P(TDMBackendDisplay, DISABLED_VerifyOutputWaitVblankBeforeDpmsOff) /* TODO */
-{
-}
-
-TEST_P(TDMBackendDisplay, DISABLED_VerifyLayerSetVideoPos)
-{
-}
-
-#ifdef TDM_UT_TEST_WITH_PARAMS
-INSTANTIATE_TEST_CASE_P(TDMBackendDisplayParams,
- TDMBackendDisplay,
- Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
-#else
-INSTANTIATE_TEST_CASE_P(TDMBackendDisplayParams,
- TDMBackendDisplay,
- Values(TDM_DEFAULT_MODULE));
-#endif
-
-/* LCOV_EXCL_END */
\ No newline at end of file
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
- *
- * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
- * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
- * Contact: Roman Marchenko <r.marchenko@samsung.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
-**************************************************************************/
-
-#include "ut_tdm.h"
-
-/* LCOV_EXCL_START */
-
-bool enable_porting_debug = false;
-
-void TDMBackendEnv::SetUp(void)
-{
- const char *debug;
-
- TDMEnv::SetUp();
-
- /* thread, commit_per_vblank should be turned off for testing TDMBackend
- * all TDMBackend's tcs should call tdm_output_commit once in a vblank.
- * don't call tdm_layer_commit.
- */
- tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_THREAD, 0);
- tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_COMMIT_PER_VBLANK, 0);
-
- debug = getenv("TDM_UT_DEBUG_BACKEND");
- if (debug && (debug[0] == '1'))
- enable_porting_debug = true;
-}
-
-void TDMBackendEnv::TearDown(void)
-{
- TDMEnv::TearDown();
-}
-
-TEST_P(TDMBackendEnv, VerifyDisplay)
-{
- tdm_display *dpy;
- tdm_error ret;
-
- dpy = tdm_display_init(&ret);
- TDM_UT_ASSERT_TRUE(dpy != NULL, "display init failed: %s", tdm_error_str(ret));
-
- TDM_UT_INFO("display init success");
-
- tdm_display_deinit(dpy);
-}
-
-#ifdef TDM_UT_TEST_WITH_PARAMS
-INSTANTIATE_TEST_CASE_P(TDMBackendEnvParams,
- TDMBackendEnv,
- Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
-#else
-INSTANTIATE_TEST_CASE_P(TDMBackendEnvParams,
- TDMBackendEnv,
- Values(TDM_DEFAULT_MODULE));
-#endif
-
-/* LCOV_EXCL_END */
\ No newline at end of file
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
- *
- * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
- * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
- * Contact: Roman Marchenko <r.marchenko@samsung.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
-**************************************************************************/
-
-#include "ut_tdm.h"
-
-/* LCOV_EXCL_START */
-
-class TDMBackendPP : public TDMBackendDisplay
-{
-public:
- tdm_pp *pp;
- tdm_pp_capability capabilities;
- const tbm_format *formats;
- int format_count;
- int min_w;
- int min_h;
- int max_w;
- int max_h;
- int preferred_align;
-
- tbm_surface_h srcbuf[3];
- tbm_surface_h dstbuf[3];
-
- tdm_info_pp info;
-
- tdm_output *output;
- unsigned int pipe;
- const tdm_output_mode *mode;
-
- tdm_layer *dst_layer;
- const tbm_format *dst_formats;
- int dst_format_count;
- int dst_zpos;
- int dst_layer_index;
-
- TDMBackendPP();
- void SetUp(void);
- void TearDown(void);
-
- bool FindLayerUnderPrimary(void);
- bool FindLayerOverPrimary(void);
- bool PreparePP(void);
- bool PrepareBuffers(int sw, int sh, tbm_format sf, int dw, int dh, tbm_format df, tdm_transform t);
- void ShowBuffer(int b);
- void HideLayer(void);
- void DumpBuffer(int b, char *test);
- void DestroyBuffers(void);
- void DestroyPP(void);
-};
-
-TDMBackendPP::TDMBackendPP()
-{
- pp = NULL;
- capabilities = (tdm_pp_capability)0;
- formats = NULL;
- format_count = 0;
- min_w = min_h = max_w = max_h = preferred_align = -1;
-
- for (int b = 0; b < 3; b++)
- srcbuf[b] = dstbuf[b] = NULL;
- memset(&info, 0, sizeof info);
-
- output = NULL;
- pipe = 0;
- mode = NULL;
-
- dst_layer = NULL;
- dst_formats = NULL;
- dst_format_count = 0;
- dst_zpos = 0;
- dst_layer_index = 0;
-}
-
-void TDMBackendPP::SetUp(void)
-{
- TDMBackendDisplay::SetUp();
-
- if (!ut_tdm_display_has_pp_capability(dpy))
- return;
-
- ASSERT_EQ(tdm_display_get_pp_capabilities(dpy, &capabilities), TDM_ERROR_NONE);
- ASSERT_GT(capabilities, 0);
- ASSERT_EQ(tdm_display_get_pp_available_formats(dpy, &formats, &format_count), TDM_ERROR_NONE);
- ASSERT_NE(formats, NULL);
- ASSERT_GT(format_count, 0);
- ASSERT_EQ(tdm_display_get_pp_available_size(dpy, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_NONE);
- ASSERT_TRUE(min_w == -1 || min_w > 0);
- ASSERT_TRUE(min_h == -1 || min_h > 0);
- ASSERT_TRUE(max_w == -1 || max_w > 0);
- ASSERT_TRUE(max_h == -1 || max_h > 0);
- ASSERT_TRUE(preferred_align == -1 || preferred_align > 0);
-
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- output = outputs[o];
- ASSERT_EQ(tdm_output_get_pipe(output, &pipe), TDM_ERROR_NONE);
- ASSERT_EQ(ut_tdm_output_prepare(dpy, output, false), true);
- ASSERT_EQ(tdm_output_get_mode(output, &mode), TDM_ERROR_NONE);
- ASSERT_NE(mode, NULL);
- break;
- }
-}
-
-void TDMBackendPP::TearDown(void)
-{
- if (pp)
- tdm_pp_destroy(pp);
-
- DestroyBuffers();
-
- TDMBackendDisplay::TearDown();
-}
-
-bool TDMBackendPP::PreparePP(void)
-{
- tdm_error ret;
- pp = tdm_display_create_pp(dpy, &ret);
- TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(pp != NULL);
- return true;
-}
-
-void TDMBackendPP::DestroyPP(void)
-{
- if (pp) {
- tdm_pp_destroy(pp);
- pp = NULL;
- }
-}
-
-bool TDMBackendPP::PrepareBuffers(int sw, int sh, tbm_format sf, int dw, int dh, tbm_format df, tdm_transform t)
-{
- int src_flags = 0, dst_flags = 0;
-
- sw = TDM_UT_SIZE_ALIGN(sw, preferred_align);
- dw = TDM_UT_SIZE_ALIGN(dw, preferred_align);
-
- if (capabilities & TDM_PP_CAPABILITY_SCANOUT)
- src_flags = dst_flags |= TBM_BO_SCANOUT;
-
- if (dst_layer) {
- tdm_layer_capability capabilities;
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_capabilities(dst_layer, &capabilities) == TDM_ERROR_NONE);
- if (capabilities & TDM_LAYER_CAPABILITY_SCANOUT)
- dst_flags |= TBM_BO_SCANOUT;
- }
-
- TDM_UT_RETURN_FALSE_IF_FAIL(ut_tdm_buffer_create(sw, sh, sf, src_flags, true, 3, srcbuf) == true);
- TDM_UT_RETURN_FALSE_IF_FAIL(ut_tdm_buffer_create(dw, dh, df, dst_flags, false, 3, dstbuf) == true);
- TDM_UT_RETURN_FALSE_IF_FAIL(ut_tdm_pp_fill_info(srcbuf[0], dstbuf[0], t, &info) == true);
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_pp_set_info(pp, &info) == TDM_ERROR_NONE);
-
- return true;
-}
-
-bool TDMBackendPP::FindLayerUnderPrimary(void)
-{
- tdm_error ret;
- int count;
- int primary_zpos, zpos;
- tdm_layer *primary = ut_tdm_output_get_primary_layer(output);
- TDM_UT_RETURN_FALSE_IF_FAIL(primary != NULL);
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_layer_count(output, &count) == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_zpos(primary, &primary_zpos) == TDM_ERROR_NONE);
-
- for (int l = 0; l < count; l++) {
- unsigned int usable;
- tdm_layer *temp = tdm_output_get_layer(output, l, &ret);
- TDM_UT_RETURN_FALSE_IF_FAIL(temp != NULL);
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_is_usable(temp, &usable) == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_zpos(temp, &zpos) == TDM_ERROR_NONE);
- if (zpos < primary_zpos && usable) {
- dst_layer = temp;
- dst_zpos = zpos;
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_available_formats(dst_layer, &dst_formats, &dst_format_count) == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(dst_formats != NULL);
- TDM_UT_RETURN_FALSE_IF_FAIL(dst_format_count > 0);
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_index(dst_layer, &dst_layer_index) == TDM_ERROR_NONE);
- break;
- }
- }
-
- return true;
-}
-
-bool TDMBackendPP::FindLayerOverPrimary(void)
-{
- tdm_error ret;
- int count;
- int primary_zpos, zpos;
- tdm_layer *primary = ut_tdm_output_get_primary_layer(output);
- TDM_UT_RETURN_FALSE_IF_FAIL(primary != NULL);
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_layer_count(output, &count) == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_zpos(primary, &primary_zpos) == TDM_ERROR_NONE);
-
- for (int l = 0; l < count; l++) {
- tdm_layer *temp = tdm_output_get_layer(output, l, &ret);
- TDM_UT_RETURN_FALSE_IF_FAIL(temp != NULL);
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_zpos(temp, &zpos) == TDM_ERROR_NONE);
- if (zpos > primary_zpos) {
- dst_layer = temp;
- dst_zpos = zpos;
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_available_formats(dst_layer, &dst_formats, &dst_format_count) == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(dst_formats != NULL);
- TDM_UT_RETURN_FALSE_IF_FAIL(dst_format_count > 0);
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_index(dst_layer, &dst_layer_index) == TDM_ERROR_NONE);
- break;
- }
- }
-
- return true;
-
-}
-
-static void
-_ut_tdm_backend_pp_output_commit_cb(tdm_output *output, unsigned int sequence,
- unsigned int tv_sec, unsigned int tv_usec,
- void *user_data)
-{
- bool *done = (bool *)user_data;
- if (done)
- *done = true;
-}
-
-void TDMBackendPP::ShowBuffer(int b)
-{
- ASSERT_NE(output, NULL);
- ASSERT_NE(dst_layer, NULL);
-
- bool done = false;
-
- ASSERT_EQ(ut_tdm_layer_set_buffer(dst_layer, dstbuf[b]), true);
- ASSERT_EQ(tdm_output_commit(output, 0, _ut_tdm_backend_pp_output_commit_cb, &done), TDM_ERROR_NONE);
- while (!done) {
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- }
-}
-
-void TDMBackendPP::HideLayer(void)
-{
- ASSERT_NE(output, NULL);
- ASSERT_NE(dst_layer, NULL);
-
- tdm_layer_unset_buffer(dst_layer);
- tdm_output_commit(output, 0, NULL, NULL);
-}
-
-void TDMBackendPP::DumpBuffer(int b, char *test)
-{
- char filename[256];
- if (test)
- snprintf(filename, sizeof filename, "%s_%s_src_%d", typeid(*this).name(), test, b);
- else
- snprintf(filename, sizeof filename, "%s_src_%d", typeid(*this).name(), b);
- tdm_helper_dump_buffer_str(srcbuf[b], NULL, filename);
- if (test)
- snprintf(filename, sizeof filename, "%s_%s_dst_%d", typeid(*this).name(), test, b);
- else
- snprintf(filename, sizeof filename, "%s_dst_%d", typeid(*this).name(), b);
- tdm_helper_dump_buffer_str(dstbuf[b], NULL, filename);
-}
-
-void TDMBackendPP::DestroyBuffers(void)
-{
- for (int b = 0; b < 3; b++) {
- if (srcbuf[b])
- tbm_surface_destroy(srcbuf[b]);
- if (dstbuf[b])
- tbm_surface_destroy(dstbuf[b]);
- srcbuf[b] = dstbuf[b] = NULL;
- }
-}
-
-bool
-ut_tdm_pp_fill_info(tbm_surface_h srcbuf, tbm_surface_h dstbuf, tdm_transform transform, tdm_info_pp *info)
-{
- int bw, bh;
-
- memset(info, 0, sizeof *info);
-
- bw = bh = TDM_UT_INVALID_VALUE;
- tdm_helper_get_buffer_full_size(srcbuf, &bw, &bh);
- TDM_UT_RETURN_FALSE_IF_FAIL(bw != TDM_UT_INVALID_VALUE);
- TDM_UT_RETURN_FALSE_IF_FAIL(bw >= tbm_surface_get_width(srcbuf));
- TDM_UT_RETURN_FALSE_IF_FAIL(bh != TDM_UT_INVALID_VALUE);
- TDM_UT_RETURN_FALSE_IF_FAIL(bh >= tbm_surface_get_height(srcbuf));
- info->src_config.size.h = bw;
- info->src_config.size.v = bh;
- info->src_config.pos.x = 0;
- info->src_config.pos.y = 0;
- info->src_config.pos.w = tbm_surface_get_width(srcbuf);
- info->src_config.pos.h = tbm_surface_get_height(srcbuf);
- info->src_config.format = tbm_surface_get_format(srcbuf);
-
- bw = bh = TDM_UT_INVALID_VALUE;
- tdm_helper_get_buffer_full_size(dstbuf, &bw, &bh);
- TDM_UT_RETURN_FALSE_IF_FAIL(bw != TDM_UT_INVALID_VALUE);
- TDM_UT_RETURN_FALSE_IF_FAIL(bw >= tbm_surface_get_width(dstbuf));
- TDM_UT_RETURN_FALSE_IF_FAIL(bh != TDM_UT_INVALID_VALUE);
- TDM_UT_RETURN_FALSE_IF_FAIL(bh >= tbm_surface_get_height(dstbuf));
- info->dst_config.size.h = bw;
- info->dst_config.size.v = bh;
- info->dst_config.pos.x = 0;
- info->dst_config.pos.y = 0;
- info->dst_config.pos.w = tbm_surface_get_width(dstbuf);
- info->dst_config.pos.h = tbm_surface_get_height(dstbuf);
- info->dst_config.format = tbm_surface_get_format(dstbuf);
-
- info->transform = transform;
- info->sync = 0;
- info->flags = 0;
-
- TDM_UT_INFO("src_config(%dx%d: %d,%d %dx%d: %c%c%c%c) dst_config(%dx%d: %d,%d %dx%d: %c%c%c%c) transform(%s) sync(%d) info->flags(%x)",
- info->src_config.size.h, info->src_config.size.v,
- info->src_config.pos.x, info->src_config.pos.y, info->src_config.pos.w, info->src_config.pos.h,
- FOURCC_STR(info->src_config.format),
- info->dst_config.size.h, info->dst_config.size.v,
- info->dst_config.pos.x, info->dst_config.pos.y, info->dst_config.pos.w, info->dst_config.pos.h,
- FOURCC_STR(info->dst_config.format),
- tdm_transform_str(transform), info->sync, info->flags);
-
- return true;
-}
-
-TEST_P(TDMBackendPP, PPDispalyGetAvaiableFormatsNullObject)
-{
- const tbm_format *formats = (const tbm_format *)TDM_UT_INVALID_VALUE;
- int count = TDM_UT_INVALID_VALUE;
- if (ut_tdm_display_has_pp_capability(dpy))
- ASSERT_EQ(tdm_display_get_pp_available_formats(NULL, &formats, &count), TDM_ERROR_INVALID_PARAMETER);
- else
- ASSERT_EQ(tdm_display_get_pp_available_formats(NULL, &formats, &count), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(formats, (const tbm_format *)TDM_UT_INVALID_VALUE);
- ASSERT_EQ(count, TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMBackendPP, PPDispalyGetAvaiableFormatsNullOther)
-{
- if (ut_tdm_display_has_pp_capability(dpy)) {
- ASSERT_EQ(PreparePP(), true);
- ASSERT_EQ(tdm_display_get_pp_available_formats(pp, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
- }
-}
-
-TEST_P(TDMBackendPP, PPDispalyGetAvaiableSizeNullObject)
-{
- int min_w = TDM_UT_INVALID_VALUE;
- int min_h = TDM_UT_INVALID_VALUE;
- int max_w = TDM_UT_INVALID_VALUE;
- int max_h = TDM_UT_INVALID_VALUE;
- int preferred_align = TDM_UT_INVALID_VALUE;
- if (ut_tdm_display_has_pp_capability(dpy))
- ASSERT_EQ(tdm_display_get_pp_available_size(NULL, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_INVALID_PARAMETER);
- else
- ASSERT_EQ(tdm_display_get_pp_available_size(NULL, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(min_w, TDM_UT_INVALID_VALUE);
- ASSERT_EQ(min_h, TDM_UT_INVALID_VALUE);
- ASSERT_EQ(max_w, TDM_UT_INVALID_VALUE);
- ASSERT_EQ(max_h, TDM_UT_INVALID_VALUE);
- ASSERT_EQ(preferred_align, TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMBackendPP, PPDispalyGetAvaiableSizeNullOther)
-{
- if (ut_tdm_display_has_pp_capability(dpy)) {
- ASSERT_EQ(PreparePP(), true);
- ASSERT_EQ(tdm_display_get_pp_available_size(dpy, NULL, NULL, NULL, NULL, NULL), TDM_ERROR_NONE);
- }
-}
-
-TEST_P(TDMBackendPP, PPDestroy)
-{
- TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
-
- ASSERT_EQ(PreparePP(), true);
- tdm_pp_destroy(pp);
- pp = NULL;
-}
-
-TEST_P(TDMBackendPP, PPDestroyNullObject)
-{
- TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
-
- tdm_pp_destroy(NULL);
-}
-
-TEST_P(TDMBackendPP, PPSetInfo)
-{
- /* tested in PPNoScaleNoTransformNoCSC */
-}
-
-TEST_P(TDMBackendPP, PPSetInfoNullObject)
-{
- TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
-
- tdm_info_pp info;
- memset(&info, 0, sizeof info);
- ASSERT_EQ(tdm_pp_set_info(NULL, &info), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMBackendPP, PPSetInfoNullOther)
-{
- TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
-
- ASSERT_EQ(PreparePP(), true);
- ASSERT_EQ(tdm_pp_set_info(pp, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-static void
-_ut_tdm_pp_done_cb(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst, void *user_data)
-{
- bool *done = (bool*)user_data;
- if (done)
- *done = true;
-}
-
-TEST_P(TDMBackendPP, PPSetDoneHandler)
-{
- TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
-
- ASSERT_EQ(PreparePP(), true);
- ASSERT_EQ(tdm_pp_set_done_handler(pp, _ut_tdm_pp_done_cb, NULL), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMBackendPP, PPSetDoneHandlerNullObject)
-{
- TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
-
- ASSERT_EQ(tdm_pp_set_done_handler(NULL, _ut_tdm_pp_done_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMBackendPP, PPSetDoneHandlerNullOther)
-{
- TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
-
- ASSERT_EQ(PreparePP(), true);
- ASSERT_EQ(tdm_pp_set_done_handler(pp, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMBackendPP, PPAttach)
-{
- TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
-
- ASSERT_EQ(PreparePP(), true);
-
- for (int f = 0; f < format_count; f++) {
- ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
- TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
- TDM_TRANSFORM_NORMAL), true);
-
- for (int b = 0; b < 3; b++)
- ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
-
- DestroyBuffers();
- }
-}
-
-TEST_P(TDMBackendPP, PPAttachNullObject)
-{
- TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
-
- tbm_surface_h srcbuf = (tbm_surface_h)TDM_UT_BUFFER_SIZE;
- tbm_surface_h dstbuf = (tbm_surface_h)TDM_UT_BUFFER_SIZE;
-
- ASSERT_EQ(tdm_pp_attach(NULL, srcbuf, dstbuf), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMBackendPP, PPAttachNullOther)
-{
- TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
-
- ASSERT_EQ(PreparePP(), true);
-
- ASSERT_EQ(tdm_pp_attach(pp, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMBackendPP, PPCommit)
-{
- TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
-
- ASSERT_EQ(PreparePP(), true);
-
- ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMBackendPP, PPCommitNullOBject)
-{
- TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
-
- ASSERT_EQ(tdm_pp_commit(NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMBackendPP, PPConvertUnderlay)
-{
- TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
-
- FindLayerUnderPrimary();
-
- ASSERT_NE(dst_layer, NULL);
-
- for (int f = 0; f < dst_format_count; f++) {
- bool done;
-
- TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(dst_formats[f]));
-
- ASSERT_EQ(PreparePP(), true);
-
- ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
- TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
- TDM_TRANSFORM_NORMAL), true);
-
- ASSERT_EQ(tdm_pp_set_done_handler(pp, _ut_tdm_pp_done_cb, &done), TDM_ERROR_NONE);
-
-retry:
- for (int b = 0; b < 3; b++) {
- done = false;
-
- ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
-
- while (!done)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
-
-#if 0
- char temp[256];
- snprintf(temp, sizeof temp, "f%d_b%d", f, b);
- DumpBuffer(b, temp);
-#endif
- ShowBuffer(b);
- }
-
- TDM_UT_ASK_YNR("* Successed to convert to '%c%c%c%c' buffers and show them to a underlay layer? (output: %d, layer: %d)",
- FOURCC_STR(dst_formats[f]), pipe, dst_layer_index);
-
- DestroyPP();
- DestroyBuffers();
- }
-}
-
-TEST_P(TDMBackendPP, PPConvertOverlay)
-{
- TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
-
- FindLayerOverPrimary();
-
- TDM_UT_SKIP_FLAG(dst_layer != NULL);
-
- for (int f = 0; f < dst_format_count; f++) {
- bool done;
-
- TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(dst_formats[f]));
-
- ASSERT_EQ(PreparePP(), true);
-
- ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
- TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
- TDM_TRANSFORM_NORMAL), true);
-
- ASSERT_EQ(tdm_pp_set_done_handler(pp, _ut_tdm_pp_done_cb, &done), TDM_ERROR_NONE);
-
-retry:
- for (int b = 0; b < 3; b++) {
- done = false;
-
- ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
-
- while (!done)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
-
-#if 0
- char temp[256];
- snprintf(temp, sizeof temp, "f%d_b%d", f, b);
- DumpBuffer(b, temp);
-#endif
- ShowBuffer(b);
- }
-
- TDM_UT_ASK_YNR("* Successed to convert '%c%c%c%c' buffers and show them to a overlay layer? (output: %d, layer: %d)",
- FOURCC_STR(dst_formats[f]), pipe, dst_layer_index);
-
- DestroyPP();
- DestroyBuffers();
- }
-}
-
-TEST_P(TDMBackendPP, PPConvertScale)
-{
- TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
-
- FindLayerUnderPrimary();
-
- ASSERT_NE(dst_layer, NULL);
-
- for (int f = 0; f < dst_format_count; f++) {
- bool done;
-
- TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(dst_formats[f]));
-
- ASSERT_EQ(PreparePP(), true);
-
- ASSERT_EQ(PrepareBuffers(640, 480, dst_formats[f],
- mode->hdisplay, mode->vdisplay, dst_formats[f],
- TDM_TRANSFORM_NORMAL), true);
-
- ASSERT_EQ(tdm_pp_set_done_handler(pp, _ut_tdm_pp_done_cb, &done), TDM_ERROR_NONE);
-
-retry:
- for (int b = 0; b < 3; b++) {
- done = false;
-
- ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
-
- while (!done)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
-
-#if 0
- char temp[256];
- snprintf(temp, sizeof temp, "f%d_b%d", f, b);
- DumpBuffer(b, temp);
-#endif
- ShowBuffer(b);
- }
-
- TDM_UT_ASK_YNR("* Successed to scale '%c%c%c%c' buffers? (output: %d, layer: %d)",
- FOURCC_STR(dst_formats[f]), pipe, dst_layer_index);
-
- DestroyPP();
- DestroyBuffers();
- }
-}
-
-TEST_P(TDMBackendPP, PPConvertTransform)
-{
- TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
-
- FindLayerUnderPrimary();
-
- ASSERT_NE(dst_layer, NULL);
-
- for (int f = 0; f < dst_format_count; f++) {
- for (int t = (int)TDM_TRANSFORM_90; t <= (int)TDM_TRANSFORM_FLIPPED_270; t++) {
- bool done;
-
- TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(dst_formats[f]));
-
- ASSERT_EQ(PreparePP(), true);
-
- ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
- TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
- (tdm_transform)t), true);
-
- ASSERT_EQ(tdm_pp_set_done_handler(pp, _ut_tdm_pp_done_cb, &done), TDM_ERROR_NONE);
-
-retry:
- for (int b = 0; b < 3; b++) {
- done = false;
-
- ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
-
- while (!done)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
-
-#if 0
- char temp[256];
- snprintf(temp, sizeof temp, "f%d_b%d_t%d", f, b, t);
- DumpBuffer(b, temp);
-#endif
- ShowBuffer(b);
- }
-
- TDM_UT_ASK_YNR("* Successed to rotate '%c%c%c%c' buffers? (transform: %s, output: %d, layer: %d)",
- FOURCC_STR(dst_formats[f]), tdm_transform_str(t), pipe, dst_layer_index);
-
- DestroyPP();
- DestroyBuffers();
- }
- }
-}
-
-TEST_P(TDMBackendPP, PPConvertCSC)
-{
- TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
- TDM_UT_SKIP_FLAG(!(capabilities & TDM_PP_CAPABILITY_NO_CSC));
-
- FindLayerUnderPrimary();
-
- ASSERT_NE(dst_layer, NULL);
-
- for (int df = 0; df < dst_format_count; df++) {
- for (int sf = 0; sf < format_count; sf++) {
- bool done;
-
- TDM_UT_INFO("* testing for format(%c%c%c%c) -> format(%c%c%c%c)",
- FOURCC_STR(formats[sf]), FOURCC_STR(dst_formats[df]));
-
- ASSERT_EQ(PreparePP(), true);
-
- ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, formats[sf],
- TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[df],
- TDM_TRANSFORM_NORMAL), true);
-
- ASSERT_EQ(tdm_pp_set_done_handler(pp, _ut_tdm_pp_done_cb, &done), TDM_ERROR_NONE);
-
-retry:
- for (int b = 0; b < 3; b++) {
- done = false;
-
- ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
-
- while (!done)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
-
-#if 0
- char temp[256];
- snprintf(temp, sizeof temp, "sf%d_df%d_b%d", sf, df, b);
- DumpBuffer(b, temp);
-#endif
- ShowBuffer(b);
- }
-
- TDM_UT_ASK_YNR("* Successed to convert from '%c%c%c%c' to '%c%c%c%c'? (output: %d, layer: %d)",
- FOURCC_STR(formats[sf]), FOURCC_STR(dst_formats[df]), pipe, dst_layer_index);
-
- DestroyPP();
- DestroyBuffers();
- }
- }
-}
-
-
-
-static void
-_ut_tdm_pp_done_cb2(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst, void *user_data)
-{
- int *done = (int*)user_data;
- if (done)
- (*done)++;
-}
-
-/* some backend doens't implement correctly for attaching */
-TEST_P(TDMBackendPP, DISABLED_PPAttachFewTimesInOneCommit)
-{
- TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
-
- ASSERT_EQ(PreparePP(), true);
-
- int done = 0;
- int f = 0;
- char temp[256];
- snprintf(temp, sizeof temp, "%c%c%c%c", FOURCC_STR(formats[f]));
-
- ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
- TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
- TDM_TRANSFORM_NORMAL), true);
-
- ASSERT_EQ(tdm_pp_set_done_handler(pp, _ut_tdm_pp_done_cb2, &done), TDM_ERROR_NONE);
- for (int b = 0; b < 3; b++)
- ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
-
- ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
-
- while (done != 3)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
-
- for (int b = 0; b < 3; b++)
- ShowBuffer(b);
-
- DestroyBuffers();
-}
-
-TEST_P(TDMBackendPP, PPDestroyWithoutCommit)
-{
- TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
-
- ASSERT_EQ(PreparePP(), true);
-
- int f = 0;
-
- ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
- TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
- TDM_TRANSFORM_NORMAL), true);
-
- ASSERT_EQ(tdm_pp_set_done_handler(pp, _ut_tdm_pp_done_cb2, NULL), TDM_ERROR_NONE);
- for (int b = 0; b < 3; b++)
- ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
-
- tdm_pp_destroy(pp);
- pp = NULL;
-
- DestroyBuffers();
-}
-
-TEST_P(TDMBackendPP, PPDestroyBeforeDone)
-{
- TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
-
- ASSERT_EQ(PreparePP(), true);
-
- int f = 0;
-
- ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
- TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
- TDM_TRANSFORM_NORMAL), true);
-
- ASSERT_EQ(tdm_pp_set_done_handler(pp, _ut_tdm_pp_done_cb2, NULL), TDM_ERROR_NONE);
- for (int b = 0; b < 3; b++)
- ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
-
- ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
-
- tdm_pp_destroy(pp);
- pp = NULL;
-
- DestroyBuffers();
-}
-
-#ifdef TDM_UT_TEST_WITH_PARAMS
-INSTANTIATE_TEST_CASE_P(TDMBackendPPParams,
- TDMBackendPP,
- Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
-#else
-INSTANTIATE_TEST_CASE_P(TDMBackendPPParams,
- TDMBackendPP,
- Values(TDM_DEFAULT_MODULE));
-#endif
-
-/* LCOV_EXCL_END */
\ No newline at end of file
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
- *
- * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
- * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
- * Contact: Roman Marchenko <r.marchenko@samsung.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
-**************************************************************************/
-
-#include "ut_tdm.h"
-
-/* LCOV_EXCL_START */
-
-class TDMBuffer : public TDMDisplay
-{
-public:
- tbm_surface_h buffer;
- TDMBuffer();
- void SetUp(void);
- void TearDown(void);
-};
-
-TDMBuffer::TDMBuffer()
-{
- buffer = NULL;
-}
-
-void TDMBuffer::SetUp(void)
-{
- TDMDisplay::SetUp();
-
- buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_ARGB8888);
- ASSERT_NE(buffer, NULL);
-}
-
-void TDMBuffer::TearDown(void)
-{
- if (buffer) {
- tbm_surface_destroy(buffer);
- buffer = NULL;
- }
- TDMDisplay::TearDown();
-}
-
-bool
-ut_tdm_buffer_create(int width, int height, tbm_format format, int flags, bool fill, int count, tbm_surface_h *buffers)
-{
- TDM_UT_GOTO_IF_FAIL(width > 0, failed);
- TDM_UT_GOTO_IF_FAIL(height > 0, failed);
-
- for (int b = 0; b < count; b++) {
- buffers[b] = tbm_surface_internal_create_with_flags(width, height, format, flags);
- TDM_UT_GOTO_IF_FAIL(buffers[b] != NULL, failed);
- if (fill)
- tdm_test_buffer_fill(buffers[b], PATTERN_SMPTE);
-
- TDM_INFO("creating buffer(%p) done: width(%d) height(%d), format(%c%c%c%c) flags(%x) fill(%d), count(%d)",
- buffers[b], width, height, FOURCC_STR(format), flags, fill, count);
- }
-
- return true;
-failed:
- for (int b = 0; b < count; b++) {
- if (buffers[b]) {
- tbm_surface_destroy(buffers[b]);
- buffers[b] = NULL;
- }
- }
- return false;
-}
-
-TEST_P(TDMBuffer, BufferRefBackend)
-{
- ASSERT_EQ(tdm_buffer_ref_backend(buffer), buffer);
- tdm_buffer_unref_backend(buffer);
-}
-
-TEST_P(TDMBuffer, BufferRefBackendNullOBject)
-{
- ASSERT_EQ(tdm_buffer_ref_backend(NULL), NULL);
-}
-
-TEST_P(TDMBuffer, BufferUnrefBackend)
-{
- tdm_buffer_unref_backend(buffer);
-}
-
-TEST_P(TDMBuffer, BufferUnrefBackendNullOBject)
-{
- tdm_buffer_unref_backend(NULL);
-}
-
-static void
-_ut_tdm_buffer_destroy_cb(tbm_surface_h buffer, void *user_data)
-{
- bool *done = (bool*)user_data;
- if (done)
- *done = true;
-}
-
-TEST_P(TDMBuffer, BufferAddDestroyHandler)
-{
- bool done = false;
- ASSERT_EQ(tdm_buffer_add_destroy_handler(buffer, _ut_tdm_buffer_destroy_cb, &done), TDM_ERROR_NONE);
- tbm_surface_destroy(buffer);
- buffer = NULL;
- ASSERT_EQ(done, true);
-}
-
-TEST_P(TDMBuffer, BufferAddDestroyHandlerTwice)
-{
- ASSERT_EQ(tdm_buffer_add_destroy_handler(buffer, _ut_tdm_buffer_destroy_cb, NULL), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_buffer_add_destroy_handler(buffer, _ut_tdm_buffer_destroy_cb, NULL), TDM_ERROR_BAD_REQUEST);
-}
-
-TEST_P(TDMBuffer, BufferAddDestroyHandlerNullObject)
-{
- ASSERT_EQ(tdm_buffer_add_destroy_handler(NULL, _ut_tdm_buffer_destroy_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMBuffer, BufferAddDestroyHandlerNullOther)
-{
- ASSERT_EQ(tdm_buffer_add_destroy_handler(buffer, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMBuffer, BufferRemoveDestroyHandler)
-{
- bool done = false;
- ASSERT_EQ(tdm_buffer_add_destroy_handler(buffer, _ut_tdm_buffer_destroy_cb, &done), TDM_ERROR_NONE);
- tdm_buffer_remove_destroy_handler(buffer, _ut_tdm_buffer_destroy_cb, &done);
- tbm_surface_destroy(buffer);
- buffer = NULL;
- ASSERT_EQ(done, false);
-}
-
-TEST_P(TDMBuffer, BufferRemoveDestroyHandlerDifferentData)
-{
- bool done = false;
- ASSERT_EQ(tdm_buffer_add_destroy_handler(buffer, _ut_tdm_buffer_destroy_cb, &done), TDM_ERROR_NONE);
- tdm_buffer_remove_destroy_handler(buffer, _ut_tdm_buffer_destroy_cb, NULL);
- tbm_surface_destroy(buffer);
- buffer = NULL;
- ASSERT_EQ(done, true);
-}
-
-TEST_P(TDMBuffer, BufferRemoveDestroyHandlerNullObject)
-{
- tdm_buffer_remove_destroy_handler(NULL, _ut_tdm_buffer_destroy_cb, NULL);
-}
-
-TEST_P(TDMBuffer, BufferRemoveDestroyHandlerNullOther)
-{
- tdm_buffer_remove_destroy_handler(buffer, NULL, NULL);
-}
-
-static void
-_ut_tdm_buffer_release_cb(tbm_surface_h buffer, void *user_data)
-{
- bool *done = (bool*)user_data;
- if (done)
- *done = true;
-}
-
-TEST_P(TDMBuffer, BufferAddReleaseHandler)
-{
- bool done = false;
- ASSERT_EQ(tdm_buffer_add_release_handler(buffer, _ut_tdm_buffer_release_cb, &done), TDM_ERROR_NONE);
- tdm_buffer_ref_backend(buffer);
- ASSERT_EQ(done, false);
- tdm_buffer_unref_backend(buffer);
- ASSERT_EQ(done, true);
-}
-
-TEST_P(TDMBuffer, BufferAddReleaseHandlerTwice)
-{
- ASSERT_EQ(tdm_buffer_add_release_handler(buffer, _ut_tdm_buffer_release_cb, NULL), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_buffer_add_release_handler(buffer, _ut_tdm_buffer_release_cb, NULL), TDM_ERROR_BAD_REQUEST);
-}
-
-TEST_P(TDMBuffer, BufferAddReleaseHandlerNullObject)
-{
- bool done = false;
- ASSERT_EQ(tdm_buffer_add_release_handler(NULL, _ut_tdm_buffer_release_cb, &done), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(done, false);
-}
-
-TEST_P(TDMBuffer, BufferAddReleaseHandlerNullOther)
-{
- ASSERT_EQ(tdm_buffer_add_release_handler(buffer, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMBuffer, BufferRemoveReleaseHandler)
-{
- bool done = false;
- ASSERT_EQ(tdm_buffer_add_release_handler(buffer, _ut_tdm_buffer_release_cb, &done), TDM_ERROR_NONE);
- tdm_buffer_ref_backend(buffer);
- ASSERT_EQ(done, false);
- tdm_buffer_remove_release_handler(buffer, _ut_tdm_buffer_release_cb, &done);
- tdm_buffer_unref_backend(buffer);
- ASSERT_EQ(done, false);
-}
-
-TEST_P(TDMBuffer, BufferRemoveReleaseHandlerDifferentData)
-{
- bool done = false;
- ASSERT_EQ(tdm_buffer_add_release_handler(buffer, _ut_tdm_buffer_release_cb, &done), TDM_ERROR_NONE);
- tdm_buffer_ref_backend(buffer);
- ASSERT_EQ(done, false);
- tdm_buffer_remove_release_handler(buffer, _ut_tdm_buffer_release_cb, NULL);
- tdm_buffer_unref_backend(buffer);
- ASSERT_EQ(done, true);
-}
-
-static void
-_ut_tdm_buffer_release_cb2(tbm_surface_h buffer, void *user_data)
-{
- bool *done = (bool*)user_data;
- if (done)
- *done = true;
- tdm_buffer_remove_release_handler(buffer, _ut_tdm_buffer_release_cb2, user_data);
-}
-
-TEST_P(TDMBuffer, BufferRemoveReleaseHandlerInHandler)
-{
- bool done = false;
- ASSERT_EQ(tdm_buffer_add_release_handler(buffer, _ut_tdm_buffer_release_cb2, &done), TDM_ERROR_NONE);
- tdm_buffer_ref_backend(buffer);
- ASSERT_EQ(done, false);
- tdm_buffer_unref_backend(buffer);
- ASSERT_EQ(done, true);
-
- done = false;
- ASSERT_EQ(tdm_buffer_add_release_handler(buffer, _ut_tdm_buffer_release_cb2, &done), TDM_ERROR_NONE);
- tdm_buffer_ref_backend(buffer);
- ASSERT_EQ(done, false);
- tdm_buffer_unref_backend(buffer);
- ASSERT_EQ(done, true);
-
- done = false;
- ASSERT_EQ(tdm_buffer_add_release_handler(buffer, _ut_tdm_buffer_release_cb2, &done), TDM_ERROR_NONE);
- tdm_buffer_ref_backend(buffer);
- ASSERT_EQ(done, false);
- tdm_buffer_unref_backend(buffer);
- ASSERT_EQ(done, true);
-}
-
-TEST_P(TDMBuffer, BufferRemoveReleaseHandlerNullObject)
-{
- bool done = false;
- ASSERT_EQ(tdm_buffer_add_release_handler(buffer, _ut_tdm_buffer_release_cb, &done), TDM_ERROR_NONE);
- tdm_buffer_ref_backend(buffer);
- ASSERT_EQ(done, false);
- tdm_buffer_remove_release_handler(NULL, _ut_tdm_buffer_release_cb, &done);
- tdm_buffer_unref_backend(buffer);
- ASSERT_EQ(done, true);
-}
-
-TEST_P(TDMBuffer, BufferRemoveReleaseHandlerNullOther)
-{
- tdm_buffer_remove_release_handler(buffer, NULL, NULL);
-}
-
-TEST_P(TDMBuffer, BufferRemoveReleaseHandlerNoAdd)
-{
- tdm_buffer_remove_release_handler(buffer, _ut_tdm_buffer_release_cb, NULL);
-}
-
-#ifdef TDM_UT_TEST_WITH_PARAMS
-INSTANTIATE_TEST_CASE_P(TDMBufferParams,
- TDMBuffer,
- Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
-#else
-INSTANTIATE_TEST_CASE_P(TDMBufferParams,
- TDMBuffer,
- Values(TDM_DEFAULT_MODULE));
-#endif
-
-/* LCOV_EXCL_END */
\ No newline at end of file
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2017 Samsung Electronics co., Ltd. All Rights Reserved.
- *
- * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
- * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
- * Contact: Roman Marchenko <r.marchenko@samsung.com>
- * Contact: Sergey Sizonov <s.sizonov@samsung.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
-**************************************************************************/
-
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/signalfd.h>
-#include <poll.h>
-#include <sys/prctl.h>
-
-#include "ut_tdm.h"
-#include "tdm_client.h"
-
-/* LCOV_EXCL_START */
-
-enum {
- TDM_UT_PIPE_MSG_NONE,
- TDM_UT_PIPE_MSG_REPLY,
- TDM_UT_PIPE_MSG_SERVER_READY,
- TDM_UT_PIPE_MSG_SERVER_FAILED,
- TDM_UT_PIPE_MSG_DPMS_ON,
- TDM_UT_PIPE_MSG_DPMS_OFF,
- TDM_UT_PIPE_MSG_TERMINATE_SERVER,
-};
-
-static int _ut_tdm_pipe_read_msg(int fd);
-static bool _ut_tdm_pipe_write_msg(int fd, int reply_fd, int msg);
-static pid_t _ut_tdm_client_server_fork(int *pipe_to_parent, int *pipe_to_child);
-
-class TDMClient : public TDMEnv
-{
-public:
- static pid_t server_pid;
-
- /* 0: read, 1: write */
- static int pipe_parent[2];
- static int pipe_child[2];
-
- tdm_client *client;
- tdm_client_output *output;
- tdm_client_vblank *vblank;
-
- double vrefresh_interval, start, end;
-
- TDMClient();
-
- void SetUp(void);
- void TearDown(void);
- bool PrepareClient(void);
- bool PrepareOutput(void);
- bool PrepareVblank(void);
-
- static void TearDownTestCase(void);
- static void ServerFork(void);
- static void ServerKill(void);
-};
-
-pid_t TDMClient::server_pid = -1;
-int TDMClient::pipe_parent[2] = {-1, -1};
-int TDMClient::pipe_child[2] = {-1, -1};
-
-void TDMClient::TearDownTestCase(void)
-{
- ServerKill();
-}
-
-void TDMClient::ServerFork(void)
-{
- if (server_pid > 0)
- return;
-
- server_pid = _ut_tdm_client_server_fork(pipe_parent, pipe_child);
- ASSERT_GT(server_pid, 0);
-}
-
-void TDMClient::ServerKill(void)
-{
- if (pipe_child[0] >= 0)
- close(pipe_child[0]);
- if (pipe_child[1] >= 0) {
- if (server_pid > 0) {
- bool ret = _ut_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_TERMINATE_SERVER);
- if (ret) {
- if (waitpid(server_pid, NULL, 0) == server_pid)
- TDM_INFO("*** server terminated ***");
- else
- TDM_ERR("*** failed to terminate server ***");
- } else {
- if (kill(server_pid, 9) < 0)
- TDM_ERR("*** failed to kill server ***");
- }
- }
- close(pipe_child[1]);
- }
-
- if (pipe_parent[0] >= 0)
- close(pipe_parent[0]);
- if (pipe_parent[1] >= 0)
- close(pipe_parent[1]);
-
- server_pid = -1;
- pipe_parent[0] = pipe_parent[1] = -1;
- pipe_child[0] = pipe_child[1] = -1;
-}
-
-TDMClient::TDMClient()
-{
- client = NULL;
- output = NULL;
- vblank = NULL;
- vrefresh_interval = start = end = 0.0;
-}
-
-void TDMClient::SetUp(void)
-{
- TDMEnv::SetUp();
-
- if (server_pid == -1)
- ServerFork();
-}
-
-void TDMClient::TearDown(void)
-{
- if (vblank)
- tdm_client_vblank_destroy(vblank);
- if (client)
- tdm_client_destroy(client);
-
- TDMEnv::TearDown();
-}
-
-bool TDMClient::PrepareClient(void)
-{
- tdm_error ret;
- client = tdm_client_create(&ret);
- TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(client != NULL);
-
- return true;
-}
-
-bool TDMClient::PrepareOutput(void)
-{
- tdm_error ret;
-
- TDM_UT_RETURN_FALSE_IF_FAIL(client != NULL);
-
- output = tdm_client_get_output(client, NULL, &ret);
- TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(output != NULL);
-
- return true;
-}
-
-bool TDMClient::PrepareVblank(void)
-{
- tdm_error ret;
- unsigned int refresh;
-
- TDM_UT_RETURN_FALSE_IF_FAIL(output != NULL);
-
- vblank = tdm_client_output_create_vblank(output, &ret);
- TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(vblank != NULL);
-
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_client_output_get_refresh_rate(output, &refresh) == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(refresh > 0);
-
- vrefresh_interval = 1.0 / (double)refresh;
- TDM_UT_RETURN_FALSE_IF_FAIL(vrefresh_interval > 0);
-
- return true;
-}
-
-static int
-_ut_tdm_pipe_read_msg(int fd)
-{
- ssize_t len;
- int msg;
-
- do {
- len = read(fd, &msg, sizeof msg);
- } while (len < 0 && errno == EINTR);
-
- if (len <= 0)
- msg = TDM_UT_PIPE_MSG_NONE;
-
- return msg;
-}
-
-static bool
-_ut_tdm_pipe_write_msg(int fd, int reply_fd, int msg)
-{
- ssize_t len = write(fd, &msg, sizeof msg);
- TDM_UT_RETURN_FALSE_IF_FAIL(len == sizeof msg);
-
- if (reply_fd >= 0) {
- int reply = _ut_tdm_pipe_read_msg(reply_fd);
- TDM_UT_RETURN_FALSE_IF_FAIL(reply == TDM_UT_PIPE_MSG_REPLY);
- }
-
- return true;
-}
-
-static bool
-_ut_tdm_server_set_output_dpms(tdm_display *dpy, int msg)
-{
- tdm_error ret;
- tdm_output *output;
- tdm_output_dpms dpms;
-
- output = tdm_display_find_output(dpy, "primary", &ret);
- TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(output != NULL);
-
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_dpms(output, &dpms) == TDM_ERROR_NONE);
-
- switch (msg) {
- case TDM_UT_PIPE_MSG_DPMS_ON:
- if (dpms != TDM_OUTPUT_DPMS_ON)
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON) == TDM_ERROR_NONE);
- break;
- case TDM_UT_PIPE_MSG_DPMS_OFF:
- if (dpms != TDM_OUTPUT_DPMS_OFF)
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF) == TDM_ERROR_NONE);
- break;
- default:
- break;
- }
-
- return true;
-}
-
-static void
-_ut_tdm_server_run(int *pipe_parent, int *pipe_child)
-{
- tdm_display *dpy = NULL;
- tdm_error ret;
- struct pollfd fds[2];
- int tdm_fd, err;
- int output_count = 0;
-
- dpy = tdm_display_init(&ret);
- TDM_UT_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, failed);
- TDM_UT_GOTO_IF_FAIL(dpy != NULL, failed);
-
- TDM_UT_GOTO_IF_FAIL(tdm_display_get_output_count(dpy, &output_count) == TDM_ERROR_NONE, failed);
-
- for (int o = 0; o < output_count; o++) {
- tdm_output *output = tdm_display_get_output(dpy, o, &ret);
- TDM_UT_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, failed);
- TDM_UT_GOTO_IF_FAIL(output != NULL, failed);
-
- if (!ut_tdm_output_is_connected(output))
- continue;
-
- TDM_UT_GOTO_IF_FAIL(ut_tdm_output_prepare(dpy, output, true) == true, failed);
- }
-
- TDM_UT_GOTO_IF_FAIL(_ut_tdm_pipe_write_msg(pipe_parent[1], -1, TDM_UT_PIPE_MSG_SERVER_READY) == true, done);
-
- TDM_INFO("*** server ready ***");
-
- ret = tdm_display_get_fd(dpy, &tdm_fd);
- TDM_UT_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, done);
-
- fds[0].events = POLLIN;
- fds[0].fd = tdm_fd;
- fds[0].revents = 0;
-
- fds[1].events = POLLIN;
- fds[1].fd = pipe_child[0];
- fds[1].revents = 0;
-
- while (1) {
- /* make sure all events are flushed to clients before falling in sleep */
- tdm_display_flush(dpy);
-
- err = poll(fds, 2, -1);
- if (err < 0) {
- if (errno == EINTR || errno == EAGAIN) {
- continue;
- } else {
- TDM_ERR("server-process: poll failed: %m\n");
- goto done;
- }
- }
-
- if (fds[0].revents & POLLIN)
- ret = ut_tdm_display_handle_events(dpy);
-
- if (fds[1].revents & POLLIN) {
- int msg = _ut_tdm_pipe_read_msg(pipe_child[0]);
- _ut_tdm_pipe_write_msg(pipe_parent[1], -1, TDM_UT_PIPE_MSG_REPLY);
-
- switch (msg) {
- case TDM_UT_PIPE_MSG_DPMS_ON:
- case TDM_UT_PIPE_MSG_DPMS_OFF:
- _ut_tdm_server_set_output_dpms(dpy, msg);
- break;
- case TDM_UT_PIPE_MSG_TERMINATE_SERVER:
- goto done;
- default:
- break;
- }
- }
- }
-
-done:
- if (dpy)
- tdm_display_deinit(dpy);
- return;
-
-failed:
- TDM_UT_GOTO_IF_FAIL(_ut_tdm_pipe_write_msg(pipe_parent[1], -1, TDM_UT_PIPE_MSG_SERVER_FAILED) == true, done);
- TDM_INFO("*** server failed ***");
-
- if (dpy)
- tdm_display_deinit(dpy);
- return;
-
-}
-
-static void _ut_tdm_client_sig_handler(int sig)
-{
- TDM_UT_ERR("got signal: %d", sig);
- kill(TDMClient::server_pid, 9);
- abort();
-}
-
-static pid_t
-_ut_tdm_client_server_fork(int *pipe_parent, int *pipe_child)
-{
- pid_t pid;
- int msg;
-
- TDM_UT_GOTO_IF_FAIL(pipe(pipe_parent) == 0, failed);
- TDM_UT_GOTO_IF_FAIL(pipe(pipe_child) == 0, failed);
-
- signal(SIGCHLD, SIG_IGN);
- signal(SIGSEGV, _ut_tdm_client_sig_handler);
-
- prctl(PR_SET_PDEATHSIG, SIGHUP);
-
- pid = fork();
- TDM_UT_GOTO_IF_FAIL(pid >= 0, failed);
-
- if (pid == 0) {
- _ut_tdm_server_run(pipe_parent, pipe_child);
- close(pipe_child[0]);
- close(pipe_child[1]);
- close(pipe_parent[0]);
- close(pipe_parent[1]);
-
-#ifdef TIZEN_TEST_GCOV
- __gcov_flush();
-#endif
-
- exit(0);
- }
-
- msg = _ut_tdm_pipe_read_msg(pipe_parent[0]);
- TDM_UT_GOTO_IF_FAIL(msg == TDM_UT_PIPE_MSG_SERVER_READY, failed);
-
- TDM_INFO("*** server fork done ***");
-
- return pid;
-
-failed:
- return -1;
-}
-
-TEST_P(TDMClient, ClientCreate)
-{
- tdm_error ret;
-
- client = tdm_client_create(&ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(client, NULL);
-}
-
-TEST_P(TDMClient, ClientCreateNullOther)
-{
- client = tdm_client_create(NULL);
- ASSERT_NE(client, NULL);
-}
-
-TEST_P(TDMClient, ClientDestroy)
-{
- tdm_error ret;
-
- client = tdm_client_create(&ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(client, NULL);
-
- tdm_client_destroy(client);
- client = NULL;
-}
-
-TEST_P(TDMClient, ClientNullObject)
-{
- tdm_client_destroy(NULL);
-}
-
-/* tdm_client_get_fd */
-TEST_P(TDMClient, ClientGetFd)
-{
- int fd = TDM_UT_INVALID_VALUE;
-
- ASSERT_EQ(PrepareClient(), true);
-
- ASSERT_EQ(tdm_client_get_fd(client, &fd), TDM_ERROR_NONE);
- ASSERT_GE(fd, 0);
-}
-
-TEST_P(TDMClient, ClientGetFdNullObject)
-{
- int fd = TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_client_get_fd(NULL, &fd), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(fd, TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMClient, ClientGetFdNullOther)
-{
- ASSERT_EQ(PrepareClient(), true);
-
- ASSERT_EQ(tdm_client_get_fd(client, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-static void
-_ut_tdm_client_vblank_cb(unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec, void *user_data)
-{
- bool *done = (bool *)user_data;
- if (done)
- *done = true;
-}
-
-/* tdm_client_handle_events_timeout */
-TEST_P(TDMClient, ClientHandleEvent)
-{
- bool done = false;
-
- ASSERT_EQ(PrepareClient(), true);
-
- ASSERT_EQ(tdm_client_wait_vblank(client, NULL, 1, 1, 0, _ut_tdm_client_vblank_cb, &done), TDM_ERROR_NONE);
- ASSERT_EQ(done, false);
-
- while (!done)
- ASSERT_EQ(tdm_client_handle_events(client), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMClient, ClientHandleEventNullObject)
-{
- ASSERT_EQ(tdm_client_handle_events(NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-/* tdm_client_wait_vblank, deprecated */
-TEST_P(TDMClient, ClientWaitVblank)
-{
- bool done = false;
-
- ASSERT_EQ(PrepareClient(), true);
-
- ASSERT_EQ(tdm_client_wait_vblank(client, NULL, 1, 1, 0, _ut_tdm_client_vblank_cb, &done), TDM_ERROR_NONE);
- ASSERT_EQ(done, false);
-
- while (!done)
- ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
-}
-
-/* tdm_client_get_output */
-TEST_P(TDMClient, ClientGetOutput)
-{
- tdm_error ret;
-
- ASSERT_EQ(PrepareClient(), true);
-
- output = tdm_client_get_output(client, NULL, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(output, NULL);
-}
-
-TEST_P(TDMClient, ClientGetOutputPrimary)
-{
- tdm_error ret;
-
- ASSERT_EQ(PrepareClient(), true);
-
- output = tdm_client_get_output(client, (char*)"primary", &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(output, NULL);
-}
-
-TEST_P(TDMClient, ClientGetOutputDefault)
-{
- tdm_error ret;
-
- ASSERT_EQ(PrepareClient(), true);
-
- output = tdm_client_get_output(client, (char*)"default", &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(output, NULL);
-}
-
-TEST_P(TDMClient, ClientGetOutputInvalidName)
-{
- tdm_error ret;
-
- ASSERT_EQ(PrepareClient(), true);
-
- output = tdm_client_get_output(client, (char*)"invalid", &ret);
- ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(output, NULL);
-}
-
-TEST_P(TDMClient, ClientGetOutputNullObject)
-{
- tdm_error ret;
-
- output = tdm_client_get_output(NULL, NULL, &ret);
- ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(output, NULL);
-}
-
-TEST_P(TDMClient, ClientGetOutputNullOther)
-{
- ASSERT_EQ(PrepareClient(), true);
-
- output = tdm_client_get_output(client, NULL, NULL);
- ASSERT_NE(output, NULL);
-}
-
-static void
-_ut_tdm_client_output_change_dpms_cb(tdm_client_output *output,
- tdm_output_change_type type,
- tdm_value value,
- void *user_data)
-{
- bool *done = (bool *)user_data;
-
- switch (type) {
- case TDM_OUTPUT_CHANGE_DPMS:
- if (done)
- *done = true;
- break;
- default:
- break;
- }
-}
-
-/* tdm_client_output_add_change_handler */
-TEST_P(TDMClient, ClientOutputAddChangeHandler)
-{
- bool done = false;
- tdm_output_dpms dpms;
-
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
-
- ASSERT_EQ(tdm_client_output_add_change_handler(output, _ut_tdm_client_output_change_dpms_cb, &done), TDM_ERROR_NONE);
- ASSERT_EQ(_ut_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_OFF), true);
-
- while (!done)
- ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
-
- ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
- ASSERT_EQ(dpms, TDM_OUTPUT_DPMS_OFF);
-
- ASSERT_EQ(_ut_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_ON), true);
- while (dpms != TDM_OUTPUT_DPMS_ON) {
- ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
- }
-}
-
-TEST_P(TDMClient, ClientOutputAddChangeHandlerTwice)
-{
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
-
- ASSERT_EQ(tdm_client_output_add_change_handler(output, _ut_tdm_client_output_change_dpms_cb, NULL), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_client_output_add_change_handler(output, _ut_tdm_client_output_change_dpms_cb, NULL), TDM_ERROR_BAD_REQUEST);
-}
-
-TEST_P(TDMClient, ClientOutputAddChangeHandlerNullObject)
-{
- ASSERT_EQ(tdm_client_output_add_change_handler(NULL, _ut_tdm_client_output_change_dpms_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMClient, ClientOutputAddChangeHandlerNullOther)
-{
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
-
- ASSERT_EQ(tdm_client_output_add_change_handler(output, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-/* tdm_client_output_remove_change_handler */
-TEST_P(TDMClient, ClientOutputRemoveChangeHandler)
-{
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
-
- ASSERT_EQ(tdm_client_output_add_change_handler(output, _ut_tdm_client_output_change_dpms_cb, NULL), TDM_ERROR_NONE);
- tdm_client_output_remove_change_handler(output, _ut_tdm_client_output_change_dpms_cb, NULL);
-}
-
-TEST_P(TDMClient, ClientOutputRemoveChangeHandlerDifferentData)
-{
- bool done = (bool)TDM_UT_INVALID_VALUE;
-
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
-
- ASSERT_EQ(tdm_client_output_add_change_handler(output, _ut_tdm_client_output_change_dpms_cb, &done), TDM_ERROR_NONE);
- tdm_client_output_remove_change_handler(output, _ut_tdm_client_output_change_dpms_cb, NULL);
-}
-
-static void
-_ut_tdm_client_output_change_dpms_cb2(tdm_client_output *output,
- tdm_output_change_type type,
- tdm_value value,
- void *user_data)
-{
- switch (type) {
- case TDM_OUTPUT_CHANGE_DPMS:
- tdm_client_output_remove_change_handler(output, _ut_tdm_client_output_change_dpms_cb2, user_data);
- break;
- default:
- break;
- }
-}
-
-TEST_P(TDMClient, ClientOutputRemoveChangeHandlerInHandler)
-{
- tdm_output_dpms dpms = TDM_OUTPUT_DPMS_ON;
-
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
-
- ASSERT_EQ(tdm_client_output_add_change_handler(output, _ut_tdm_client_output_change_dpms_cb2, NULL), TDM_ERROR_NONE);
- ASSERT_EQ(_ut_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_OFF), true);
- ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
- while (dpms != TDM_OUTPUT_DPMS_OFF) {
- ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
- }
-
- ASSERT_EQ(_ut_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_ON), true);
- while (dpms != TDM_OUTPUT_DPMS_ON)
- ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMClient, ClientOutputRemoveChangeHandlerNullObject)
-{
- tdm_client_output_remove_change_handler(NULL, _ut_tdm_client_output_change_dpms_cb, NULL);
-}
-
-TEST_P(TDMClient, ClientOutputRemoveChangeHandlerNullOther)
-{
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
-
- tdm_client_output_remove_change_handler(output, NULL, NULL);
-}
-
-/* tdm_client_output_get_refresh_rate */
-TEST_P(TDMClient, ClientOutputGetRefreshRate)
-{
- unsigned int refresh = 0;
-
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
-
- ASSERT_EQ(tdm_client_output_get_refresh_rate(output, &refresh), TDM_ERROR_NONE);
- ASSERT_GT(refresh, 0);
-}
-
-TEST_P(TDMClient, ClientOutputGetRefreshRateNullObject)
-{
- unsigned int refresh = (unsigned int)TDM_UT_INVALID_VALUE;
-
- ASSERT_EQ(tdm_client_output_get_refresh_rate(NULL, &refresh), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(refresh, (unsigned int)TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMClient, ClientOutputGetRefreshRateNullOther)
-{
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
-
- ASSERT_EQ(tdm_client_output_get_refresh_rate(output, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-/* tdm_client_output_get_refresh_rate */
-TEST_P(TDMClient, ClientOutputGetConnStatus)
-{
- tdm_output_conn_status status = (tdm_output_conn_status)TDM_UT_INVALID_VALUE;
-
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
-
- ASSERT_EQ(tdm_client_output_get_conn_status(output, &status), TDM_ERROR_NONE);
- ASSERT_NE(status, (tdm_output_conn_status)TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMClient, ClientOutputGetConnStatusNullObject)
-{
- tdm_output_conn_status status = (tdm_output_conn_status)TDM_UT_INVALID_VALUE;
-
- ASSERT_EQ(tdm_client_output_get_conn_status(NULL, &status), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(status, (tdm_output_conn_status)TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMClient, ClientOutputGetConnStatusNullOther)
-{
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
-
- ASSERT_EQ(tdm_client_output_get_conn_status(output, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-/* tdm_client_output_get_dpms */
-TEST_P(TDMClient, ClientOutputGetDpms)
-{
- tdm_output_dpms dpms = (tdm_output_dpms)TDM_UT_INVALID_VALUE;
-
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
-
- ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
- ASSERT_NE(dpms, (tdm_output_dpms)TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMClient, ClientOutputGetDpmsNullObject)
-{
- tdm_output_dpms dpms = (tdm_output_dpms)TDM_UT_INVALID_VALUE;
-
- ASSERT_EQ(tdm_client_output_get_dpms(NULL, &dpms), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(dpms, (tdm_output_dpms)TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMClient, ClientOutputGetDpmsNullOther)
-{
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
-
- ASSERT_EQ(tdm_client_output_get_dpms(output, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-/* tdm_client_output_create_vblank */
-TEST_P(TDMClient, ClientOutputCreateVblank)
-{
- tdm_error ret;
-
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
-
- vblank = tdm_client_output_create_vblank(output, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(vblank, NULL);
-}
-
-TEST_P(TDMClient, ClientOutputCreateVblankNullObject)
-{
- tdm_error ret;
-
- vblank = tdm_client_output_create_vblank(NULL, &ret);
- ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(vblank, NULL);
-}
-
-TEST_P(TDMClient, ClientOutputCreateVblankNullOther)
-{
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
-
- vblank = tdm_client_output_create_vblank(output, NULL);
- ASSERT_NE(vblank, NULL);
-}
-
-/* tdm_client_vblank_destroy */
-TEST_P(TDMClient, ClientVblankDestroy)
-{
- tdm_error ret;
-
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
-
- vblank = tdm_client_output_create_vblank(output, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(vblank, NULL);
-
- tdm_client_vblank_destroy(vblank);
- vblank = NULL;
-}
-
-TEST_P(TDMClient, ClientVblankDestroyNullObject)
-{
- tdm_client_vblank_destroy(NULL);
-}
-
-/* tdm_client_vblank_set_name */
-TEST_P(TDMClient, ClientVblankSetName)
-{
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
- ASSERT_EQ(PrepareVblank(), true);
-
- ASSERT_EQ(tdm_client_vblank_set_name(vblank, TDM_UT_VBLANK_NAME), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMClient, ClientVblankSetNameTwice)
-{
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
- ASSERT_EQ(PrepareVblank(), true);
-
- ASSERT_EQ(tdm_client_vblank_set_name(vblank, TDM_UT_VBLANK_NAME), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_client_vblank_set_name(vblank, TDM_UT_VBLANK_NAME), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMClient, ClientVblankSetNameNullObject)
-{
- ASSERT_EQ(tdm_client_vblank_set_name(NULL, TDM_UT_VBLANK_NAME), TDM_ERROR_INVALID_PARAMETER);
-}
-
-/* tdm_client_vblank_set_sync */
-TEST_P(TDMClient, ClientVblankSetSync)
-{
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
- ASSERT_EQ(PrepareVblank(), true);
-
- ASSERT_EQ(tdm_client_vblank_set_sync(vblank, 1), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMClient, ClientVblankSetSyncTwice)
-{
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
- ASSERT_EQ(PrepareVblank(), true);
-
- ASSERT_EQ(tdm_client_vblank_set_sync(vblank, 1), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_client_vblank_set_sync(vblank, 1), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMClient, ClientVblankSetSyncNullObject)
-{
- ASSERT_EQ(tdm_client_vblank_set_sync(NULL, 1), TDM_ERROR_INVALID_PARAMETER);
-}
-
-/* tdm_client_vblank_set_fps */
-TEST_P(TDMClient, ClientVblankSetFps)
-{
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
- ASSERT_EQ(PrepareVblank(), true);
-
- ASSERT_EQ(tdm_client_vblank_set_fps(vblank, 30), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMClient, ClientVblankSetFpsTwice)
-{
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
- ASSERT_EQ(PrepareVblank(), true);
-
- ASSERT_EQ(tdm_client_vblank_set_fps(vblank, 30), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_client_vblank_set_fps(vblank, 30), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMClient, ClientVblankSetFpsNullObject)
-{
- ASSERT_EQ(tdm_client_vblank_set_fps(NULL, 30), TDM_ERROR_INVALID_PARAMETER);
-}
-
-/* tdm_client_vblank_set_offset */
-TEST_P(TDMClient, ClientVblankSetOffset)
-{
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
- ASSERT_EQ(PrepareVblank(), true);
-
- ASSERT_EQ(tdm_client_vblank_set_offset(vblank, 10), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMClient, ClientVblankSetOffsetTwice)
-{
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
- ASSERT_EQ(PrepareVblank(), true);
-
- ASSERT_EQ(tdm_client_vblank_set_offset(vblank, 10), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_client_vblank_set_offset(vblank, 10), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMClient, ClientVblankSetOffsetNullObject)
-{
- ASSERT_EQ(tdm_client_vblank_set_offset(NULL, 10), TDM_ERROR_INVALID_PARAMETER);
-}
-
-/* tdm_client_vblank_set_enable_fake */
-TEST_P(TDMClient, ClientVblankSetEnableFake)
-{
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
- ASSERT_EQ(PrepareVblank(), true);
-
- ASSERT_EQ(tdm_client_vblank_set_enable_fake(vblank, 1), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMClient, ClientVblankSetEnableFakeTwice)
-{
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
- ASSERT_EQ(PrepareVblank(), true);
-
- ASSERT_EQ(tdm_client_vblank_set_enable_fake(vblank, 1), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_client_vblank_set_enable_fake(vblank, 1), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMClient, ClientVblankSetEnableFakeNullObject)
-{
- ASSERT_EQ(tdm_client_vblank_set_enable_fake(NULL, 1), TDM_ERROR_INVALID_PARAMETER);
-}
-
-static void
-_ut_tdm_client_vblank_cb2(tdm_client_vblank *vblank,
- tdm_error error,
- unsigned int sequence,
- unsigned int tv_sec,
- unsigned int tv_usec,
- void *user_data)
-{
- bool *done = (bool *)user_data;
- if (done)
- *done = true;
-}
-
-/* tdm_client_vblank_wait */
-TEST_P(TDMClient, ClientVblankWait)
-{
- bool done;
-
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
- ASSERT_EQ(PrepareVblank(), true);
-
- done = false;
- ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _ut_tdm_client_vblank_cb2, &done), TDM_ERROR_NONE);
-
- start = tdm_helper_get_time();
- while (!done)
- ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
- end = tdm_helper_get_time();
-
- /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
- ASSERT_LT((end - start), (vrefresh_interval + vrefresh_interval));
-}
-
-TEST_P(TDMClient, ClientVblankWaitFewTime)
-{
- bool done1, done2, done3;
-
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
- ASSERT_EQ(PrepareVblank(), true);
-
- done1 = done2 = done3 = false;
- ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _ut_tdm_client_vblank_cb2, &done1), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _ut_tdm_client_vblank_cb2, &done2), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _ut_tdm_client_vblank_cb2, &done3), TDM_ERROR_NONE);
-
- start = tdm_helper_get_time();
- while (!done1 || !done2 || !done3)
- ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
- end = tdm_helper_get_time();
-
- /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
- ASSERT_LT((end - start), (vrefresh_interval + vrefresh_interval));
-
-}
-
-TEST_P(TDMClient, ClientVblankWaitInterval0)
-{
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
- ASSERT_EQ(PrepareVblank(), true);
-
- ASSERT_EQ(tdm_client_vblank_wait(vblank, 0, _ut_tdm_client_vblank_cb2, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMClient, ClientVblankWaitInterval)
-{
- bool done;
-
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
- ASSERT_EQ(PrepareVblank(), true);
-
- /* start from 1 */
- for (int t = 1; t < 10; t++) {
- done = false;
- ASSERT_EQ(tdm_client_vblank_wait(vblank, t, _ut_tdm_client_vblank_cb2, &done), TDM_ERROR_NONE);
-
- start = tdm_helper_get_time();
- while (!done)
- ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
- end = tdm_helper_get_time();
-
- /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
- ASSERT_GT((end - start), (vrefresh_interval * (t - 1)));
- ASSERT_LT((end - start), (vrefresh_interval * t + vrefresh_interval));
- }
-}
-
-static void
-_ut_tdm_client_vblank_cb3(tdm_client_vblank *vblank,
- tdm_error error,
- unsigned int sequence,
- unsigned int tv_sec,
- unsigned int tv_usec,
- void *user_data)
-{
- unsigned int *cur_seq = (unsigned int *)user_data;
- if (cur_seq)
- *cur_seq = sequence;
-}
-
-TEST_P(TDMClient, ClientVblankWaitSeq)
-{
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
- ASSERT_EQ(PrepareVblank(), true);
-
- for (int t = 0; t < 10; t++) {
- unsigned int cur_seq = 0, temp = 0;
-
- ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _ut_tdm_client_vblank_cb3, &cur_seq), TDM_ERROR_NONE);
- while (cur_seq == 0)
- ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
-
- start = tdm_helper_get_time();
- ASSERT_EQ(tdm_client_vblank_wait_seq(vblank, cur_seq + 1, _ut_tdm_client_vblank_cb3, &temp), TDM_ERROR_NONE);
- while (temp == 0)
- ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
- end = tdm_helper_get_time();
-
- /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
- ASSERT_LT((end - start), (vrefresh_interval + vrefresh_interval));
- }
-}
-
-TEST_P(TDMClient, ClientVblankWaitSeqInterval)
-{
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
- ASSERT_EQ(PrepareVblank(), true);
-
- /* start from 1 */
- for (int t = 1; t < 10; t++) {
- unsigned int cur_seq = 0, temp = 0;
-
- ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _ut_tdm_client_vblank_cb3, &cur_seq), TDM_ERROR_NONE);
- while (cur_seq == 0)
- ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
-
- start = tdm_helper_get_time();
- ASSERT_EQ(tdm_client_vblank_wait_seq(vblank, cur_seq + t, _ut_tdm_client_vblank_cb3, &temp), TDM_ERROR_NONE);
- while (temp == 0)
- ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
- end = tdm_helper_get_time();
-
- /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
- ASSERT_GT((end - start), (vrefresh_interval * (t - 1)));
- ASSERT_LT((end - start), (vrefresh_interval * t + vrefresh_interval));
- }
-}
-
-TEST_P(TDMClient, ClientVblankWaitSetOffset)
-{
- bool done;
-
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
- ASSERT_EQ(PrepareVblank(), true);
-
- ASSERT_EQ(tdm_client_vblank_set_offset(vblank, 100), TDM_ERROR_NONE);
-
- done = false;
- ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _ut_tdm_client_vblank_cb2, &done), TDM_ERROR_NONE);
-
- start = tdm_helper_get_time();
- while (!done)
- ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
- end = tdm_helper_get_time();
-
- /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
- ASSERT_GT((end - start), (0.1));
- ASSERT_LT((end - start), (vrefresh_interval + vrefresh_interval + 0.1));
-}
-
-TEST_P(TDMClient, ClientVblankWaitSetFps)
-{
- bool done;
- double interval;
- unsigned int fps = 10;
-
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
- ASSERT_EQ(PrepareVblank(), true);
-
- ASSERT_EQ(tdm_client_vblank_set_fps(vblank, fps), TDM_ERROR_NONE);
- interval = 1.0 / (double)fps;
-
- done = false;
- ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _ut_tdm_client_vblank_cb2, &done), TDM_ERROR_NONE);
-
- start = tdm_helper_get_time();
- while (!done)
- ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
- end = tdm_helper_get_time();
-
- /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
- ASSERT_GT((end - start), (interval - vrefresh_interval));
- ASSERT_LT((end - start), (interval + vrefresh_interval));
-}
-
-#if 0
-
-TEST_P(TDMVblank, VblankWaitEnableDisableGlobalFps)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
- double vrefresh_interval;
- unsigned int cur_seq[3];
- unsigned int global_fps = 5;
- double start, end, interval;
-
- ASSERT_EQ(TestPrepareOutput(), true);
- ASSERT_EQ(TestCreateVblanks3(), true);
- ASSERT_EQ(vblank_count, 3);
-
- ASSERT_EQ(tdm_vblank_get_fps(vblanks[0], &fps), TDM_ERROR_NONE);
- ASSERT_TRUE(fps >= 30 && fps != (unsigned int)TDM_UT_INVALID_VALUE);
- vrefresh_interval = 1.0 / (double)fps;
-
- for (int v = 0; v < 3; v++)
- ASSERT_EQ(tdm_vblank_set_fixed_fps(vblanks[v], 10 * (v + 1)), TDM_ERROR_NONE);
-
- /* enable test */
- tdm_vblank_enable_global_fps(1, global_fps);
- interval = 1.0 / (double)global_fps;
-
- for (int v = 0; v < 3; v++) {
- cur_seq[v] = 0;
- ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _ut_tdm_vblank_cb, &cur_seq[v]), TDM_ERROR_NONE);
- }
-
- start = tdm_helper_get_time();
- while (cur_seq[0] == 0)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- end = tdm_helper_get_time();
-
- ASSERT_NE(cur_seq[1], 0);
- ASSERT_NE(cur_seq[2], 0);
-
- /* "+- vrefresh_interval" consider the delay of socket communication between kernel and platform */
- ASSERT_GT((end - start), (interval - vrefresh_interval));
- ASSERT_LT((end - start), (interval + vrefresh_interval));
-
- /* disable test */
- tdm_vblank_enable_global_fps(0, 0);
-
- for (int v = 0; v < 3; v++) {
- cur_seq[v] = 0;
- ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _ut_tdm_vblank_cb, &cur_seq[v]), TDM_ERROR_NONE);
- }
-
- while (cur_seq[0] == 0)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- ASSERT_EQ(cur_seq[1], 0);
- ASSERT_EQ(cur_seq[2], 0);
-
- while (cur_seq[1] == 0)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- ASSERT_EQ(cur_seq[2], 0);
-}
-
-TEST_P(TDMVblank, VblankWaitIgnoreGlobalFps)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
- unsigned int cur_seq[3];
- unsigned int global_fps = 5;
- double start, end, interval;
-
- ASSERT_EQ(TestPrepareOutput(), true);
- ASSERT_EQ(TestCreateVblanks3(), true);
- ASSERT_EQ(vblank_count, 3);
-
- ASSERT_EQ(tdm_vblank_get_fps(vblanks[0], &fps), TDM_ERROR_NONE);
- ASSERT_TRUE(fps >= 30 && fps != (unsigned int)TDM_UT_INVALID_VALUE);
- interval = 1.0 / (double)fps;
-
- /* 2nd vblank will ignore the global fps. */
- ASSERT_EQ(tdm_vblank_ignore_global_fps(vblanks[1], 1), TDM_ERROR_NONE);
-
- tdm_vblank_enable_global_fps(1, global_fps);
-
- for (int v = 0; v < 3; v++) {
- cur_seq[v] = 0;
- ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _ut_tdm_vblank_cb, &cur_seq[v]), TDM_ERROR_NONE);
- }
-
- start = tdm_helper_get_time();
- while (cur_seq[1] == 0)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- end = tdm_helper_get_time();
-
- ASSERT_EQ(cur_seq[0], 0);
- ASSERT_EQ(cur_seq[2], 0);
-
- /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
- ASSERT_LT((end - start), (interval + interval));
-
- while (cur_seq[0] == 0)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- ASSERT_NE(cur_seq[2], 0);
-}
-
-#endif
-
-TEST_P(TDMClient, ClientVblankWaitNullObject)
-{
- unsigned int cur_seq = 0;
-
- ASSERT_EQ(tdm_client_vblank_wait(NULL, 1, _ut_tdm_client_vblank_cb3, &cur_seq), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMClient, ClientVblankWaitNullOther)
-{
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
- ASSERT_EQ(PrepareVblank(), true);
-
- ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMClient, ClientVblankWaitDpmsOff)
-{
- tdm_output_dpms dpms = (tdm_output_dpms)TDM_UT_INVALID_VALUE;
-
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
- ASSERT_EQ(PrepareVblank(), true);
-
- ASSERT_EQ(_ut_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_OFF), true);
- while (dpms != TDM_OUTPUT_DPMS_OFF)
- ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
- ASSERT_EQ(dpms, TDM_OUTPUT_DPMS_OFF);
-
- ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _ut_tdm_client_vblank_cb2, NULL), TDM_ERROR_DPMS_OFF);
-
- ASSERT_EQ(_ut_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_ON), true);
- while (dpms != TDM_OUTPUT_DPMS_ON)
- ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMClient, ClientVblankWaitSetEnableFakeDpmsOff)
-{
- tdm_output_dpms dpms = (tdm_output_dpms)TDM_UT_INVALID_VALUE;
- bool done;
-
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
- ASSERT_EQ(PrepareVblank(), true);
-
- ASSERT_EQ(_ut_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_OFF), true);
- while (dpms != TDM_OUTPUT_DPMS_OFF)
- ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
-
- ASSERT_EQ(tdm_client_vblank_set_enable_fake(vblank, 1), TDM_ERROR_NONE);
-
- done = false;
- ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _ut_tdm_client_vblank_cb2, &done), TDM_ERROR_NONE);
-
- while (!done)
- ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
-
- ASSERT_EQ(_ut_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_ON), true);
- while (dpms != TDM_OUTPUT_DPMS_ON)
- ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
-}
-
-/* tdm_client_vblank_wait */
-TEST_P(TDMClient, ClientVblankIsWaiting)
-{
- bool done;
- unsigned int waiting;
-
- ASSERT_EQ(PrepareClient(), true);
- ASSERT_EQ(PrepareOutput(), true);
- ASSERT_EQ(PrepareVblank(), true);
-
- done = false;
- ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _ut_tdm_client_vblank_cb2, &done), TDM_ERROR_NONE);
-
- waiting = tdm_client_vblank_is_waiting(vblank);
- ASSERT_EQ(waiting, 1);
-
- start = tdm_helper_get_time();
- while (!done)
- ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
- end = tdm_helper_get_time();
-
- /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
- ASSERT_LT((end - start), (vrefresh_interval + vrefresh_interval));
-
- waiting = tdm_client_vblank_is_waiting(vblank);
- ASSERT_EQ(waiting, 0);
-}
-
-/* tdm_client_vblank_wait */
-TEST_P(TDMClient, ClientVblankIsWaitingNullObject)
-{
- unsigned int waiting = tdm_client_vblank_is_waiting(NULL);
- ASSERT_EQ(waiting, 0);
-}
-
-#ifdef TDM_UT_TEST_WITH_PARAMS
-INSTANTIATE_TEST_CASE_P(TDMClientParams,
- TDMClient,
- Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
-#else
-INSTANTIATE_TEST_CASE_P(TDMClientParams,
- TDMClient,
- Values(TDM_DEFAULT_MODULE));
-#endif
-
-/* LCOV_EXCL_END */
\ No newline at end of file
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
- *
- * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
- * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
- * Contact: Roman Marchenko <r.marchenko@samsung.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
-**************************************************************************/
-
-#include "ut_tdm.h"
-
-/* LCOV_EXCL_START */
-
-TDMDisplay::TDMDisplay()
-{
- dpy = NULL;
- bufmgr = NULL;
- has_pp_cap = false;
- has_capture_cap = false;
-}
-
-void TDMDisplay::SetUp(void)
-{
- tdm_error ret;
- int count = TDM_UT_INVALID_VALUE;
- tdm_display_capability capabilities = (tdm_display_capability)TDM_UT_INVALID_VALUE;
-
- TDMEnv::SetUp();
-
- dpy = tdm_display_init(&ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(dpy, NULL);
-
- bufmgr = tbm_bufmgr_init(-1);
- ASSERT_NE(bufmgr, NULL);
-
- ASSERT_EQ(tdm_display_get_output_count(dpy, &count), TDM_ERROR_NONE);
- ASSERT_GT(count, 0);
-
- ASSERT_EQ(tdm_display_get_capabilities(dpy, &capabilities), TDM_ERROR_NONE);
- has_pp_cap = capabilities & TDM_DISPLAY_CAPABILITY_PP;
- has_capture_cap = capabilities & TDM_DISPLAY_CAPABILITY_CAPTURE;
-}
-
-void TDMDisplay::TearDown(void)
-{
- tbm_bufmgr_deinit(bufmgr);
- tdm_display_deinit(dpy);
-
- ASSERT_EQ(tbm_bufmgr_debug_get_ref_count(), 0);
-
- TDMEnv::TearDown();
-}
-
-tdm_error
-ut_tdm_display_handle_events(tdm_display *dpy)
-{
- struct pollfd fds;
- int fd = -1;
- tdm_error ret;
- int result;
-
- ret = tdm_display_get_fd(dpy, &fd);
- TDM_UT_RETURN_VAL_IF_FAIL(fd >= 0, ret);
-
- fds.events = POLLIN;
- fds.fd = fd;
- fds.revents = 0;
-
- do {
- result = poll(&fds, 1, 3000);
- } while (result == -1 && errno == EINTR);
-
- if (result == 0) {
- TDM_UT_ERR("polling tdm_fd timeout.");
- return TDM_ERROR_TIMEOUT;
- }
-
- return tdm_display_handle_events(dpy);
-}
-
-bool
-ut_tdm_display_has_pp_capability(tdm_display *dpy)
-{
- tdm_display_capability capabilities = (tdm_display_capability)0;
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_display_get_capabilities(dpy, &capabilities) == TDM_ERROR_NONE);
- return capabilities & TDM_DISPLAY_CAPABILITY_PP;
-}
-
-bool
-ut_tdm_display_has_capture_capability(tdm_display *dpy)
-{
- tdm_display_capability capabilities = (tdm_display_capability)0;
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_display_get_capabilities(dpy, &capabilities) == TDM_ERROR_NONE);
- return capabilities & TDM_DISPLAY_CAPABILITY_CAPTURE;
-}
-
-TEST_P(TDMDisplay, DisplayUpdate)
-{
- ASSERT_EQ(tdm_display_update(dpy), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMDisplay, DisplayUpdateNullObject)
-{
- ASSERT_EQ(tdm_display_update(NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMDisplay, DisplayGetFDSuccesful)
-{
- int fd = TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_display_get_fd(dpy, &fd), TDM_ERROR_NONE);
- ASSERT_NE(fd, TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMDisplay, DisplayGetFDNullObject)
-{
- int fd = TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_display_get_fd(NULL, &fd), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(fd, TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMDisplay, DisplayGetFDNullFD)
-{
- ASSERT_EQ(tdm_display_get_fd(dpy, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-/* DISABLED */
-TEST_P(TDMDisplay, DISABLED_DisplayHandleEvents)
-{
- /* TODO Generate events*/
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMDisplay, DisplayFlush)
-{
- tdm_display_flush(dpy);
-}
-
-TEST_P(TDMDisplay, DisplayFlushNullObject)
-{
- tdm_display_flush(NULL);
-}
-
-TEST_P(TDMDisplay, DisplayGetBackendInfo)
-{
- const char *name = (const char*)TDM_UT_INVALID_VALUE;
- const char *vendor = (const char*)TDM_UT_INVALID_VALUE;
- int major = TDM_UT_INVALID_VALUE, minor = TDM_UT_INVALID_VALUE;
-
- ASSERT_EQ(tdm_display_get_backend_info(dpy, &name, &vendor, &major, &minor), TDM_ERROR_NONE);
- ASSERT_NE(name, (const char*)TDM_UT_INVALID_VALUE);
- ASSERT_NE(vendor, (const char*)TDM_UT_INVALID_VALUE);
- ASSERT_NE(major, TDM_UT_INVALID_VALUE);
- ASSERT_NE(minor, TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMDisplay, DisplayGetBackendInfoNullObject)
-{
- const char *name = (const char*)TDM_UT_INVALID_VALUE;
- const char *vendor = (const char*)TDM_UT_INVALID_VALUE;
- int major = TDM_UT_INVALID_VALUE, minor = TDM_UT_INVALID_VALUE;
-
- ASSERT_EQ(tdm_display_get_backend_info(NULL, &name, &vendor, &major, &minor), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(name, (const char*)TDM_UT_INVALID_VALUE);
- ASSERT_EQ(vendor, (const char*)TDM_UT_INVALID_VALUE);
- ASSERT_EQ(major, TDM_UT_INVALID_VALUE);
- ASSERT_EQ(minor, TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMDisplay, DisplayGetBackendInfoNullOther)
-{
- ASSERT_EQ(tdm_display_get_backend_info(dpy, NULL, NULL, NULL, NULL), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMDisplay, DisplayGetCapabilities)
-{
- tdm_display_capability capabilities = (tdm_display_capability)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_display_get_capabilities(dpy, &capabilities), TDM_ERROR_NONE);
- ASSERT_NE(capabilities, TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMDisplay, DisplayGetCapabilitiesNullObject)
-{
- tdm_display_capability capabilities = (tdm_display_capability)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_display_get_capabilities(NULL, &capabilities), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(capabilities, (tdm_display_capability)TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMDisplay, DisplayGetCapabilitiesNullOther)
-{
- ASSERT_EQ(tdm_display_get_capabilities(dpy, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMDisplay, DisplayGetPPCapabilities)
-{
- tdm_pp_capability capabilities = (tdm_pp_capability) TDM_UT_INVALID_VALUE;
- tdm_error ret;
- if (!has_pp_cap)
- return;
- ret = tdm_display_get_pp_capabilities(dpy, &capabilities);
- ASSERT_TRUE(ret == TDM_ERROR_NONE || ret == TDM_ERROR_NO_CAPABILITY);
-
- if (ret == TDM_ERROR_NONE)
- ASSERT_NE(capabilities, TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMDisplay, DisplayGetPPCapabilitiesNullObject)
-{
- tdm_pp_capability capabilities = (tdm_pp_capability)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_display_get_pp_capabilities(NULL, &capabilities), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(capabilities, (tdm_pp_capability)TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMDisplay, DisplayGetPPCapabilitiesNullOther)
-{
- ASSERT_EQ(tdm_display_get_pp_capabilities(dpy, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMDisplay, DisplayGetCaptureCapabilities)
-{
- tdm_capture_capability capabilities = (tdm_capture_capability)TDM_UT_INVALID_VALUE;
- tdm_error ret;
-
- if (!has_capture_cap)
- return;
-
- ret = tdm_display_get_capture_capabilities(dpy, &capabilities);
- ASSERT_TRUE(ret == TDM_ERROR_NONE || ret == TDM_ERROR_NO_CAPABILITY);
-
- if (ret == TDM_ERROR_NONE)
- ASSERT_NE(capabilities, (tdm_capture_capability)TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMDisplay, DisplayGetCaptureCapabilitiesNullObject)
-{
- tdm_capture_capability capabilities = (tdm_capture_capability)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_display_get_capture_capabilities(NULL, &capabilities), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(capabilities, (tdm_capture_capability)TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMDisplay, DisplayGetCaptureCapabilitiesNullOther)
-{
- ASSERT_EQ(tdm_display_get_capture_capabilities(dpy, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMDisplay, DisplayGetMaxLayerCount)
-{
- int max_count = TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_display_get_max_layer_count(dpy, &max_count), TDM_ERROR_NONE);
- ASSERT_NE(max_count, TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMDisplay, DisplayGetMaxLayerCountNullObject)
-{
- int max_count = TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_display_get_max_layer_count(NULL, &max_count), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(max_count, TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMDisplay, DisplayGetMaxLayerCountNullOther)
-{
- ASSERT_EQ(tdm_display_get_max_layer_count(dpy, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMDisplay, DisplayGetOutputCount)
-{
- int count = TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_display_get_output_count(dpy, &count), TDM_ERROR_NONE);
- ASSERT_NE(count, TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMDisplay, DisplayGetOutputCountNullObject)
-{
- int count = TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_display_get_output_count(NULL, &count), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(count, TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMDisplay, DisplayGetOutputCountNullOther)
-{
- ASSERT_EQ(tdm_display_get_output_count(dpy, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMDisplay, DisplayGetOutput)
-{
- tdm_output *output;
- int o, count = TDM_UT_INVALID_VALUE;
- tdm_error ret;
-
- ASSERT_EQ(tdm_display_get_output_count(dpy, &count), TDM_ERROR_NONE);
- ASSERT_GT(count, 0);
-
- for (o = 0; o < count; o++) {
- output = tdm_display_get_output(dpy, o, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(output, NULL);
- }
-}
-
-TEST_P(TDMDisplay, DisplayGetOutputNullAll)
-{
- tdm_output *output;
- int o, count = TDM_UT_INVALID_VALUE;
-
- ASSERT_EQ(tdm_display_get_output_count(dpy, &count), TDM_ERROR_NONE);
- ASSERT_GT(count, 0);
-
- for (o = 0; o < count; o++) {
- output = tdm_display_get_output(NULL, o, NULL);
- ASSERT_EQ(output, NULL);
- }
-}
-
-TEST_P(TDMDisplay, DisplayGetOutputNullObject)
-{
- tdm_output *output;
- tdm_error ret;
-
- output = tdm_display_get_output(NULL, 0, &ret);
- ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(output, NULL);
-}
-
-TEST_P(TDMDisplay, DisplayGetOutputNullOther)
-{
- tdm_output *output;
- int o, count = TDM_UT_INVALID_VALUE;
-
- ASSERT_EQ(tdm_display_get_output_count(dpy, &count), TDM_ERROR_NONE);
- ASSERT_GT(count, 0);
-
- for (o = 0; o < count; o++) {
- output = tdm_display_get_output(dpy, o, NULL);
- ASSERT_NE(output, NULL);
- }
-}
-
-TEST_P(TDMDisplay, DisplayGetOutputWrongIndex)
-{
- tdm_output *output;
- tdm_error ret;
-
- output = tdm_display_get_output(dpy, -1, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_EQ(output, NULL);
-
- output = tdm_display_get_output(dpy, INT_MAX, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_EQ(output, NULL);
-}
-
-TEST_P(TDMDisplay, DisplayFindOutput)
-{
- tdm_output *output;
- int count = TDM_UT_INVALID_VALUE;
- tdm_error ret;
-
- ASSERT_EQ(tdm_display_get_output_count(dpy, &count), TDM_ERROR_NONE);
- ASSERT_GT(count, 0);
-
- output = tdm_display_find_output(dpy, "primary", &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(output, NULL);
-
- output = tdm_display_find_output(dpy, "invalid", &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_EQ(output, NULL);
-}
-
-TEST_P(TDMDisplay, DisplayCreatePp)
-{
- tdm_pp *pp;
- tdm_error ret;
-
- if (!has_pp_cap)
- return;
-
- pp = tdm_display_create_pp(dpy, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(pp, NULL);
-
- tdm_pp_destroy(pp);
-}
-
-TEST_P(TDMDisplay, DisplayCreatePpNullObject)
-{
- tdm_pp *pp;
- tdm_error ret;
-
- if (!has_pp_cap)
- return;
-
- pp = tdm_display_create_pp(NULL, &ret);
- ASSERT_NE(ret, TDM_ERROR_NONE);
- ASSERT_EQ(pp, NULL);
-}
-
-TEST_P(TDMDisplay, ModuleGetInfo)
-{
- tdm_output *output;
- int o, count = TDM_UT_INVALID_VALUE;
- tdm_error ret;
-
- ASSERT_EQ(tdm_display_get_output_count(dpy, &count), TDM_ERROR_NONE);
- ASSERT_GT(count, 0);
-
- for (o = 0; o < count; o++) {
- tdm_module *module;
- const char *name = (const char *)TDM_UT_INVALID_VALUE;
- const char *vendor = (const char *)TDM_UT_INVALID_VALUE;
- int major = TDM_UT_INVALID_VALUE;
- int minor = TDM_UT_INVALID_VALUE;
-
- output = tdm_display_get_output(dpy, o, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(output, NULL);
-
- module = tdm_output_get_backend_module(output, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(module, NULL);
-
- ASSERT_EQ(tdm_module_get_info(module, &name, &vendor, &major, &minor), TDM_ERROR_NONE);
- ASSERT_NE(name, (const char *)TDM_UT_INVALID_VALUE);
- ASSERT_NE(vendor, (const char *)TDM_UT_INVALID_VALUE);
- ASSERT_NE(major, TDM_UT_INVALID_VALUE);
- ASSERT_NE(minor, TDM_UT_INVALID_VALUE);
- }
-}
-
-TEST_P(TDMDisplay, ModuleGetInfoNullObject)
-{
- const char *name = (const char *)TDM_UT_INVALID_VALUE;
- const char *vendor = (const char *)TDM_UT_INVALID_VALUE;
- int major = TDM_UT_INVALID_VALUE;
- int minor = TDM_UT_INVALID_VALUE;
-
- ASSERT_EQ(tdm_module_get_info(NULL, &name, &vendor, &major, &minor), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(name, (const char *)TDM_UT_INVALID_VALUE);
- ASSERT_EQ(vendor, (const char *)TDM_UT_INVALID_VALUE);
- ASSERT_EQ(major, TDM_UT_INVALID_VALUE);
- ASSERT_EQ(minor, TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMDisplay, ModuleGetInfoNullOther)
-{
- tdm_output *output;
- int o, count = TDM_UT_INVALID_VALUE;
- tdm_error ret;
-
- ASSERT_EQ(tdm_display_get_output_count(dpy, &count), TDM_ERROR_NONE);
- ASSERT_GT(count, 0);
-
- for (o = 0; o < count; o++) {
- tdm_module *module;
-
- output = tdm_display_get_output(dpy, o, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(output, NULL);
-
- module = tdm_output_get_backend_module(output, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(module, NULL);
-
- ASSERT_EQ(tdm_module_get_info(module, NULL, NULL, NULL, NULL), TDM_ERROR_NONE);
- }
-}
-
-#ifdef TDM_UT_TEST_WITH_PARAMS
-INSTANTIATE_TEST_CASE_P(TDMDisplayParams,
- TDMDisplay,
- Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
-#else
-INSTANTIATE_TEST_CASE_P(TDMDisplayParams,
- TDMDisplay,
- Values(TDM_DEFAULT_MODULE));
-#endif
-
-/* LCOV_EXCL_END */
\ No newline at end of file
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
- *
- * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
- * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
- * Contact: Roman Marchenko <r.marchenko@samsung.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
-**************************************************************************/
-
-#include "ut_tdm.h"
-
-/* LCOV_EXCL_START */
-
-void TDMEnv::SetUp(void)
-{
- const char *test_backend;
- int thread = 1;
-
- TDM_UT_ENTRY();
-
- setenv("XDG_RUNTIME_DIR", "/run", 1);
- setenv("TBM_DISPLAY_SERVER", "1", 1);
-
-#ifdef TDM_UT_TEST_WITH_PARAMS
- /* commit_per_vblank depends on backend. can't choose it in frontend side.
- * this is only for testing.
- */
- int commit_per_vblank = ::testing::get<0>(GetParam());
- tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_COMMIT_PER_VBLANK, commit_per_vblank);
-
- thread = ::testing::get<1>(GetParam());
- test_backend = ::testing::get<2>(GetParam());
-#else
- test_backend = ::testing::get<0>(GetParam());
-#endif
-
- tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_THREAD, thread);
-
- if (!test_backend)
- test_backend = TDM_DEFAULT_MODULE;
- tdm_config_set_string(TDM_CONFIG_KEY_GENERAL_BACKENDS, test_backend);
-
- const char *debug = getenv("TDM_UT_DEBUG_MODULE");
- if (debug && strstr(debug, "1"))
- tdm_config_set_string(TDM_CONFIG_KEY_DEBUG_MODULE, "buffer,vblank,commit,pp,capture");
-
- debug = getenv("TDM_UT_DEBUG_DUMP");
- if (debug && (debug[0] == '1'))
- tdm_config_set_string(TDM_CONFIG_KEY_DEBUG_DUMP, "all");
-}
-
-void TDMEnv::TearDown(void)
-{
- unsetenv("XDG_RUNTIME_DIR");
- unsetenv("TBM_DISPLAY_SERVER");
-}
-
-TEST_P(TDMEnv, DisplayInitDeinit)
-{
- tdm_display *dpy;
- tdm_error ret;
-
- dpy = tdm_display_init(&ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(dpy, NULL);
-
- tdm_display_deinit(dpy);
-}
-
-TEST_P(TDMEnv, DisplayInitDeinitWithoutEnv)
-{
- tdm_display *dpy;
- tdm_error ret;
-
- TDMEnv::TearDown();
-
- dpy = tdm_display_init(&ret);
- ASSERT_EQ(ret, TDM_ERROR_OPERATION_FAILED);
- ASSERT_EQ(dpy, NULL);
-}
-
-TEST_P(TDMEnv, DisplayInitFewTimes)
-{
- tdm_display *dpy[10];
- int d;
- tdm_error ret;
-
- for (d = 0; d < 10; d++) {
- dpy[d] = tdm_display_init(&ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(dpy[d], NULL);
- }
-
- for (d = 0; d < 9; d++)
- ASSERT_EQ(dpy[d], dpy[d + 1]);
-
- for (d = 0; d < 10; d++)
- tdm_display_deinit(dpy[d]);
-}
-
-TEST_P(TDMEnv, DisplayInitDeinitWithTBM)
-{
- tdm_display *dpy;
- tbm_bufmgr bufmgr;
- tdm_error ret;
-
- bufmgr = tbm_bufmgr_init(-1);
- ASSERT_NE(bufmgr, NULL);
-
- dpy = tdm_display_init(&ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(dpy, NULL);
-
- tdm_display_deinit(dpy);
- tbm_bufmgr_deinit(bufmgr);
-}
-
-TEST_P(TDMEnv, DisplayInitDeinitWithoutBackends)
-{
-}
-
-TEST_P(TDMEnv, DisplayDeinitWithNULL)
-{
- tdm_display_deinit(NULL);
-}
-
-#ifdef TDM_UT_TEST_WITH_PARAMS
-INSTANTIATE_TEST_CASE_P(TDMEnvParams,
- TDMEnv,
- Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
-#else
-INSTANTIATE_TEST_CASE_P(TDMEnvParams,
- TDMEnv,
- Values(TDM_DEFAULT_MODULE));
-#endif
-
-/* LCOV_EXCL_END */
\ No newline at end of file
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
- *
- * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
- * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
- * Contact: Roman Marchenko <r.marchenko@samsung.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
-**************************************************************************/
-
-#include "ut_tdm.h"
-
-/* LCOV_EXCL_START */
-
-class TDMEventLoop : public TDMDisplay
-{
-public:
- TDMEventLoop();
- void SetUp(void);
- void TearDown(void);
-};
-
-TDMEventLoop::TDMEventLoop()
-{
-}
-
-void TDMEventLoop::SetUp(void)
-{
- TDMDisplay::SetUp();
- tdm_display_lock(dpy);
-}
-
-void TDMEventLoop::TearDown(void)
-{
- tdm_display_unlock(dpy);
- TDMDisplay::TearDown();
-}
-
-static tdm_error
-_ut_tdm_event_loop_fd_cb(int fd, tdm_event_loop_mask mask, void *user_data)
-{
- bool *done = (bool*)user_data;
- if (done)
- *done = true;
- return TDM_ERROR_NONE;
-}
-
-TEST_P(TDMEventLoop, EventLoopAddFdHandler)
-{
- tdm_error ret;
- int pipes[2]; /* 0: read, 1: write */
- tdm_event_loop_source *source;
- bool done;
- int len;
-
- ASSERT_EQ(pipe(pipes), 0);
-
- done = false;
- source = tdm_event_loop_add_fd_handler(dpy, pipes[0], TDM_EVENT_LOOP_READABLE,
- _ut_tdm_event_loop_fd_cb, &done, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(source, NULL);
-
- len = write(pipes[1], "hello", 5);
- ASSERT_EQ(len, 5);
-
-//TODO
-// while (!done)
-// ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
-
- tdm_event_loop_source_remove(source);
-
- close(pipes[0]);
- close(pipes[1]);
-}
-
-TEST_P(TDMEventLoop, EventLoopAddFdHandlerNullObject)
-{
- tdm_error ret;
- tdm_event_loop_source *source;
- source = tdm_event_loop_add_fd_handler(NULL, 0, TDM_EVENT_LOOP_READABLE,
- _ut_tdm_event_loop_fd_cb, NULL, &ret);
- ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(source, NULL);
-}
-
-TEST_P(TDMEventLoop, EventLoopAddFdHandlerNullOther)
-{
- tdm_error ret;
- tdm_event_loop_source *source;
- source = tdm_event_loop_add_fd_handler(NULL, -1, TDM_EVENT_LOOP_READABLE, NULL, NULL, &ret);
- ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(source, NULL);
-}
-
-TEST_P(TDMEventLoop, EventLoopSourceFdUpdate)
-{
- tdm_error ret;
- int pipes[2]; /* 0: read, 1: write */
- tdm_event_loop_source *source;
- bool done;
- int len;
-
- ASSERT_EQ(pipe(pipes), 0);
-
- done = false;
- source = tdm_event_loop_add_fd_handler(dpy, pipes[0], TDM_EVENT_LOOP_WRITABLE,
- _ut_tdm_event_loop_fd_cb, &done, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(source, NULL);
-
- ASSERT_EQ(tdm_event_loop_source_fd_update(source, TDM_EVENT_LOOP_READABLE), TDM_ERROR_NONE);
-
- len = write(pipes[1], "hello", 5);
- ASSERT_EQ(len, 5);
-
-//TODO
-// while (!done)
-// ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
-
- tdm_event_loop_source_remove(source);
-
- close(pipes[0]);
- close(pipes[1]);
-}
-
-TEST_P(TDMEventLoop, EventLoopSourceFdUpdateNullObject)
-{
- ASSERT_EQ(tdm_event_loop_source_fd_update(NULL, TDM_EVENT_LOOP_READABLE), TDM_ERROR_INVALID_PARAMETER);
-}
-
-static tdm_error
-_ut_tdm_event_loop_timer_cb(void *user_data)
-{
- bool *done = (bool*)user_data;
- if (done)
- *done = true;
- return TDM_ERROR_NONE;
-}
-
-TEST_P(TDMEventLoop, EventLoopAddTimerHandler)
-{
- tdm_error ret;
- tdm_event_loop_source *source;
- source = tdm_event_loop_add_timer_handler(dpy, _ut_tdm_event_loop_timer_cb, NULL, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(source, NULL);
- tdm_event_loop_source_remove(source);
-}
-
-TEST_P(TDMEventLoop, EventLoopAddTimerHandlerNullObject)
-{
- tdm_error ret;
- tdm_event_loop_source *source;
- source = tdm_event_loop_add_timer_handler(NULL, _ut_tdm_event_loop_timer_cb, NULL, &ret);
- ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(source, NULL);
-}
-
-
-TEST_P(TDMEventLoop, EventLoopAddTimerHandlerNullOther)
-{
- tdm_error ret;
- tdm_event_loop_source *source;
- source = tdm_event_loop_add_timer_handler(dpy, NULL, NULL, &ret);
- ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(source, NULL);
-}
-
-TEST_P(TDMEventLoop, EventLoopSourceTimerUpdate)
-{
- tdm_error ret;
- tdm_event_loop_source *source;
- source = tdm_event_loop_add_timer_handler(dpy, _ut_tdm_event_loop_timer_cb, NULL, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(source, NULL);
- ASSERT_EQ(tdm_event_loop_source_timer_update(source, 100), TDM_ERROR_NONE);
-//TODO
-// while (!done)
-// ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- tdm_event_loop_source_remove(source);
-}
-
-TEST_P(TDMEventLoop, EventLoopSourceTimerUpdateNullObject)
-{
- ASSERT_EQ(tdm_event_loop_source_timer_update(NULL, 100), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMEventLoop, EventLoopSourceRemoveNullObject)
-{
- tdm_event_loop_source_remove(NULL);
-}
-
-#ifdef TDM_UT_TEST_WITH_PARAMS
-INSTANTIATE_TEST_CASE_P(TDMEventLoopParams,
- TDMEventLoop,
- Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
-#else
-INSTANTIATE_TEST_CASE_P(TDMEventLoopParams,
- TDMEventLoop,
- Values(TDM_DEFAULT_MODULE));
-#endif
-
-/* LCOV_EXCL_END */
\ No newline at end of file
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
- *
- * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
- * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
- * Contact: Roman Marchenko <r.marchenko@samsung.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
-**************************************************************************/
-
-#include "ut_tdm.h"
-
-/* LCOV_EXCL_START */
-
-class TDMHelper : public TDMOutput
-{
-public:
- TDMHelper();
- void SetUp(void);
- void TearDown(void);
-};
-
-TDMHelper::TDMHelper()
-{
-}
-
-void TDMHelper::SetUp(void)
-{
- TDMOutput::SetUp();
-}
-
-void TDMHelper::TearDown(void)
-{
- TDMOutput::TearDown();
-}
-
-TEST_P(TDMHelper, HelperGetTime)
-{
- ASSERT_GT(tdm_helper_get_time(), 0.0);
-}
-
-TEST_P(TDMHelper, HelperDumpBufferXR24)
-{
- tbm_surface_h buffer;
-
- buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_XRGB8888);
- ASSERT_NE(buffer, NULL);
-
- tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
-
- char filename[256];
- snprintf(filename, sizeof filename, "%s.png", typeid(*this).name());
- tdm_helper_dump_buffer(buffer, (const char*)filename);
-
- tbm_surface_destroy(buffer);
-}
-
-TEST_P(TDMHelper, HelperDumpBufferAR24)
-{
- tbm_surface_h buffer;
-
- buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_ARGB8888);
- ASSERT_NE(buffer, NULL);
-
- tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
-
- char filename[256];
- snprintf(filename, sizeof filename, "%s.png", typeid(*this).name());
- tdm_helper_dump_buffer(buffer, (const char*)filename);
-
- tbm_surface_destroy(buffer);
-}
-
-TEST_P(TDMHelper, HelperDumpBufferNullObject)
-{
- char filename[256];
- tdm_helper_dump_buffer(NULL, (const char*)filename);
-}
-
-TEST_P(TDMHelper, HelperDumpBufferNullOther)
-{
- tbm_surface_h buffer = (tbm_surface_h)TDM_UT_INVALID_VALUE;
- tdm_helper_dump_buffer(buffer, NULL);
-}
-
-TEST_P(TDMHelper, HelperClearBufferPos)
-{
- tbm_surface_h buffer;
- tdm_pos pos = {.x = 40, .y = 40, .w = TDM_UT_BUFFER_SIZE - 80, .h = TDM_UT_BUFFER_SIZE - 80};
-
- buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_ARGB8888);
- ASSERT_NE(buffer, NULL);
-
- tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
-
- tdm_helper_clear_buffer_pos(buffer, &pos);
-
- tdm_helper_dump_buffer_str(buffer, NULL, (char*)typeid(*this).name());
-
- tbm_surface_destroy(buffer);
-}
-
-TEST_P(TDMHelper, HelperClearBufferColor)
-{
- tbm_surface_h buffer;
- tdm_pos pos = {.x = 40, .y = 40, .w = TDM_UT_BUFFER_SIZE - 80, .h = TDM_UT_BUFFER_SIZE - 80};
- unsigned int color = 0xffffff00;
-
- buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_ARGB8888);
- ASSERT_NE(buffer, NULL);
-
- tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
-
- tdm_helper_clear_buffer_color(buffer, &pos, color);
-
- tdm_helper_dump_buffer_str(buffer, NULL, (char*)typeid(*this).name());
-
- tbm_surface_destroy(buffer);
-}
-
-TEST_P(TDMHelper, HelperClearBufferARGB)
-{
- tbm_surface_h buffer;
-
- buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_ARGB8888);
- ASSERT_NE(buffer, NULL);
-
- tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
-
- tdm_helper_clear_buffer(buffer);
-
- tdm_helper_dump_buffer_str(buffer, NULL, (char*)typeid(*this).name());
-
- tbm_surface_destroy(buffer);
-}
-
-TEST_P(TDMHelper, HelperClearBufferXRGB)
-{
- tbm_surface_h buffer;
-
- buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_XRGB8888);
- ASSERT_NE(buffer, NULL);
-
- tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
-
- tdm_helper_clear_buffer(buffer);
-
- tdm_helper_dump_buffer_str(buffer, NULL, (char*)typeid(*this).name());
-
- tbm_surface_destroy(buffer);
-}
-
-TEST_P(TDMHelper, HelperClearBufferYUV420)
-{
- tbm_surface_h buffer;
-
- buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_YUV420);
- ASSERT_NE(buffer, NULL);
-
- tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
-
- tdm_helper_clear_buffer(buffer);
-
- tdm_helper_dump_buffer_str(buffer, NULL, (char*)typeid(*this).name());
-
- tbm_surface_destroy(buffer);
-}
-
-TEST_P(TDMHelper, HelperClearBufferNV12)
-{
- tbm_surface_h buffer;
-
- buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_NV12);
- ASSERT_NE(buffer, NULL);
-
- tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
-
- tdm_helper_clear_buffer(buffer);
-
- tdm_helper_dump_buffer_str(buffer, NULL, (char*)typeid(*this).name());
-
- tbm_surface_destroy(buffer);
-}
-
-TEST_P(TDMHelper, HelperClearBufferNV21)
-{
- tbm_surface_h buffer;
-
- buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_NV21);
- ASSERT_NE(buffer, NULL);
-
- tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
-
- tdm_helper_clear_buffer(buffer);
-
- tdm_helper_dump_buffer_str(buffer, NULL, (char*)typeid(*this).name());
-
- tbm_surface_destroy(buffer);
-}
-
-TEST_P(TDMHelper, HelperGetBufferFullSize)
-{
- tbm_surface_h buffer;
- int w = TDM_UT_INVALID_VALUE, h = TDM_UT_INVALID_VALUE;
-
- buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_ARGB8888);
- ASSERT_NE(buffer, NULL);
-
- tdm_helper_get_buffer_full_size(buffer, &w, &h);
- ASSERT_NE(w, TDM_UT_INVALID_VALUE);
- ASSERT_GE(w, tbm_surface_get_width(buffer));
- ASSERT_NE(h, TDM_UT_INVALID_VALUE);
- ASSERT_GE(h, tbm_surface_get_height(buffer));
-
- tbm_surface_destroy(buffer);
-}
-
-TEST_P(TDMHelper, HelperConvertBufferRotate0)
-{
- tbm_surface_h buffer, temp;
- tdm_pos sp, dp;
-
- buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_ARGB8888);
- ASSERT_NE(buffer, NULL);
- tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
-
- temp = tbm_surface_create(TDM_UT_BUFFER_SIZE * 2, TDM_UT_BUFFER_SIZE * 2, TBM_FORMAT_ARGB8888);
- ASSERT_NE(temp, NULL);
-
- sp.x = sp.y = 0, sp.w = sp.h = TDM_UT_BUFFER_SIZE;
- dp.x = dp.y = 0, dp.w = dp.h = TDM_UT_BUFFER_SIZE * 2;
-
- ASSERT_EQ(tdm_helper_convert_buffer(buffer, temp, &sp, &dp, TDM_TRANSFORM_NORMAL, 0), TDM_ERROR_NONE);
-
- tdm_helper_dump_buffer_str(temp, NULL, (char*)typeid(*this).name());
-
- tbm_surface_destroy(buffer);
- tbm_surface_destroy(temp);
-}
-
-TEST_P(TDMHelper, HelperConvertBufferRotate0Flip)
-{
- tbm_surface_h buffer, temp;
- tdm_pos sp, dp;
-
- buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_ARGB8888);
- ASSERT_NE(buffer, NULL);
- tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
-
- temp = tbm_surface_create(TDM_UT_BUFFER_SIZE * 2, TDM_UT_BUFFER_SIZE * 2, TBM_FORMAT_ARGB8888);
- ASSERT_NE(temp, NULL);
-
- sp.x = sp.y = 0, sp.w = sp.h = TDM_UT_BUFFER_SIZE;
- dp.x = dp.y = 0, dp.w = dp.h = TDM_UT_BUFFER_SIZE * 2;
-
- ASSERT_EQ(tdm_helper_convert_buffer(buffer, temp, &sp, &dp, TDM_TRANSFORM_FLIPPED, 0), TDM_ERROR_NONE);
-
- tdm_helper_dump_buffer_str(temp, NULL, (char*)typeid(*this).name());
-
- tbm_surface_destroy(buffer);
- tbm_surface_destroy(temp);
-}
-
-TEST_P(TDMHelper, HelperConvertBufferRotate90)
-{
- tbm_surface_h buffer, temp;
- tdm_pos sp, dp;
-
- buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_ARGB8888);
- ASSERT_NE(buffer, NULL);
- tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
-
- temp = tbm_surface_create(TDM_UT_BUFFER_SIZE * 2, TDM_UT_BUFFER_SIZE * 2, TBM_FORMAT_ARGB8888);
- ASSERT_NE(temp, NULL);
-
- sp.x = sp.y = 0, sp.w = sp.h = TDM_UT_BUFFER_SIZE;
- dp.x = dp.y = 0, dp.w = dp.h = TDM_UT_BUFFER_SIZE * 2;
-
- ASSERT_EQ(tdm_helper_convert_buffer(buffer, temp, &sp, &dp, TDM_TRANSFORM_90, 0), TDM_ERROR_NONE);
-
- tdm_helper_dump_buffer_str(temp, NULL, (char*)typeid(*this).name());
-
- tbm_surface_destroy(buffer);
- tbm_surface_destroy(temp);
-}
-
-TEST_P(TDMHelper, HelperConvertBufferRotate180)
-{
- tbm_surface_h buffer, temp;
- tdm_pos sp, dp;
-
- buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_ARGB8888);
- ASSERT_NE(buffer, NULL);
- tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
-
- temp = tbm_surface_create(TDM_UT_BUFFER_SIZE * 2, TDM_UT_BUFFER_SIZE * 2, TBM_FORMAT_ARGB8888);
- ASSERT_NE(temp, NULL);
-
- sp.x = sp.y = 0, sp.w = sp.h = TDM_UT_BUFFER_SIZE;
- dp.x = dp.y = 0, dp.w = dp.h = TDM_UT_BUFFER_SIZE * 2;
-
- ASSERT_EQ(tdm_helper_convert_buffer(buffer, temp, &sp, &dp, TDM_TRANSFORM_180, 0), TDM_ERROR_NONE);
-
- tdm_helper_dump_buffer_str(temp, NULL, (char*)typeid(*this).name());
-
- tbm_surface_destroy(buffer);
- tbm_surface_destroy(temp);
-}
-
-TEST_P(TDMHelper, HelperConvertBufferRotate270)
-{
- tbm_surface_h buffer, temp;
- tdm_pos sp, dp;
-
- buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_ARGB8888);
- ASSERT_NE(buffer, NULL);
- tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
-
- temp = tbm_surface_create(TDM_UT_BUFFER_SIZE * 2, TDM_UT_BUFFER_SIZE * 2, TBM_FORMAT_ARGB8888);
- ASSERT_NE(temp, NULL);
-
- sp.x = sp.y = 0, sp.w = sp.h = TDM_UT_BUFFER_SIZE;
- dp.x = dp.y = 0, dp.w = dp.h = TDM_UT_BUFFER_SIZE * 2;
-
- ASSERT_EQ(tdm_helper_convert_buffer(buffer, temp, &sp, &dp, TDM_TRANSFORM_270, 0), TDM_ERROR_NONE);
-
- tdm_helper_dump_buffer_str(temp, NULL, (char*)typeid(*this).name());
-
- tbm_surface_destroy(buffer);
- tbm_surface_destroy(temp);
-}
-
-TEST_P(TDMHelper, HelperConvertBufferYUV420)
-{
- tbm_surface_h buffer, temp;
- tdm_pos sp, dp;
-
- buffer = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_YUV420);
- ASSERT_NE(buffer, NULL);
- tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
-
- temp = tbm_surface_create(TDM_UT_BUFFER_SIZE * 2, TDM_UT_BUFFER_SIZE * 2, TBM_FORMAT_YUV420);
- ASSERT_NE(temp, NULL);
-
- sp.x = sp.y = 0, sp.w = sp.h = TDM_UT_BUFFER_SIZE;
- dp.x = dp.y = 0, dp.w = dp.h = TDM_UT_BUFFER_SIZE * 2;
-
- ASSERT_EQ(tdm_helper_convert_buffer(buffer, temp, &sp, &dp, TDM_TRANSFORM_NORMAL, 0), TDM_ERROR_OPERATION_FAILED);
-
- tbm_surface_destroy(buffer);
- tbm_surface_destroy(temp);
-}
-
-TEST_P(TDMHelper, HelperGetFD)
-{
- int fd = tdm_helper_get_fd("TDM_DRM_MASTER_FD");
- ASSERT_GE(fd, 0);
- close(fd);
- fd = tdm_helper_get_fd("BLURBLUR");
- ASSERT_EQ(fd, -1);
-}
-
-TEST_P(TDMHelper, HelperSetFD)
-{
- tdm_helper_set_fd("TDM_DRM_MASTER_FD", -1);
- tdm_helper_set_fd("BLURBLUR", -1);
-}
-
-TEST_P(TDMHelper, HelperDumpStart)
-{
- char path[256];
- int count = 0;
- snprintf(path, sizeof path, "blurblur");
- tdm_helper_dump_start(path, &count);
- tdm_helper_dump_stop();
-}
-
-static void
-_ut_tdm_helper_capture_cb(tbm_surface_h buffer, void *user_data)
-{
-}
-
-TEST_P(TDMHelper, HelperCaptureOutput)
-{
- tdm_error ret;
- tdm_output *output;
-
- for (int o = 0; o < output_count; o++) {
- tbm_surface_h dump;
-
- output = tdm_display_get_output(dpy, o, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(output, NULL);
-
- if (!ut_tdm_output_is_connected(output))
- continue;
-
- ASSERT_EQ(ut_tdm_output_prepare(dpy, output, true), true);
-
- dump = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_ARGB8888);
- ASSERT_NE(dump, NULL);
-
- ASSERT_EQ(tdm_helper_capture_output(output, dump, 0, 0, TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE,
- _ut_tdm_helper_capture_cb, NULL), TDM_ERROR_NONE);
-
- tdm_helper_dump_buffer_str(dump, NULL, (char*)typeid(*this).name());
-
- tbm_surface_destroy(dump);
- }
-}
-
-
-TEST_P(TDMHelper, HelperCaptureOutputNullObject)
-{
- tbm_surface_h dump = (tbm_surface_h)TDM_UT_INVALID_VALUE;
-
- ASSERT_EQ(tdm_helper_capture_output(NULL, dump, 0, 0, TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE,
- _ut_tdm_helper_capture_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMHelper, HelperCaptureOutputNullOther)
-{
- for (int o = 0; o < output_count; o++) {
- tdm_error ret;
- tdm_output *output = tdm_display_get_output(dpy, o, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(output, NULL);
- tdm_helper_output_commit_per_vblank_enabled(output);
- }
-
- tbm_surface_h dump = (tbm_surface_h)TDM_UT_INVALID_VALUE;
-
- ASSERT_EQ(tdm_helper_capture_output(NULL, dump, 0, 0, TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE,
- _ut_tdm_helper_capture_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMHelper, HelperGetDisplayInformation)
-{
- char reply[8192];
- int len = sizeof reply;
-
- for (int o = 0; o < output_count; o++) {
- tdm_error ret;
- tdm_output *output = tdm_display_get_output(dpy, o, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(output, NULL);
- if (!ut_tdm_output_is_connected(output))
- continue;
- ASSERT_EQ(ut_tdm_output_prepare(dpy, output, true), true);
- }
-
- tdm_helper_get_display_information(dpy, reply, &len);
- TDM_INFO("%s", reply);
-}
-
-TEST_P(TDMHelper, HelperGetDisplayInformationNullObject)
-{
- char reply[8192];
- int len = sizeof reply;
-
- tdm_helper_get_display_information(NULL, reply, &len);
-}
-
-TEST_P(TDMHelper, HelperGetDisplayInformationNullOther)
-{
- tdm_helper_get_display_information(dpy, NULL, NULL);
-}
-
-TEST_P(TDMHelper, HelperCommitPerVblankEnabled)
-{
- ASSERT_EQ(tdm_helper_commit_per_vblank_enabled(dpy), 0);
-}
-
-TEST_P(TDMHelper, HelperCommitPerVblankEnabledNullOBject)
-{
- ASSERT_EQ(tdm_helper_commit_per_vblank_enabled(NULL), 0);
-}
-
-TEST_P(TDMHelper, HelperOutputCommitPerVblankEnabledNullObject)
-{
- ASSERT_EQ(tdm_helper_output_commit_per_vblank_enabled(NULL), -1);
-}
-
-#ifdef TDM_UT_TEST_WITH_PARAMS
-INSTANTIATE_TEST_CASE_P(TDMHelperParams,
- TDMHelper,
- Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
-#else
-INSTANTIATE_TEST_CASE_P(TDMHelperParams,
- TDMHelper,
- Values(TDM_DEFAULT_MODULE));
-#endif
-
-/* LCOV_EXCL_END */
\ No newline at end of file
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
- *
- * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
- * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
- * Contact: Roman Marchenko <r.marchenko@samsung.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
-**************************************************************************/
-
-#include "ut_tdm.h"
-
-/* LCOV_EXCL_START */
-
-#define HWC_WIN_NUM 5
-
-class TDMHwcWindow : public TDMOutput
-{
-public:
- TDMHwcWindow();
- void SetUp(void);
- void TearDown(void);
-
- tdm_error error;
- tdm_hwc_window **hwc_wins;
- int hwc_count;
-};
-
-TDMHwcWindow::TDMHwcWindow()
-{
- error = TDM_ERROR_NONE;
- hwc_wins = NULL;
- hwc_count = 0;
- video_hwc_win = NULL;
-}
-
-void TDMHwcWindow::SetUp(void)
-{
- tdm_hwc_window *hw = NULL;
-
- TDMOutput::SetUp();
-
- hwc_wins = (tdm_hwc_window **)calloc(output_count * HWC_WIN_NUM, sizeof(tdm_hwc_window *));
-
- //create HWC_WIN_NUM hwc_windows for each outputs
- for (int o = 0; o < output_count; o++) {
- if (ut_tdm_output_is_hwc_enable(outputs[o])) {
- for (int w = 0; w < HWC_WIN_NUM; w++) {
- hw = tdm_hwc_create_window(outputs[w], &error);
- ASSERT_EQ(TDM_ERROR_NONE, error);
- hwc_wins[hwc_count++] = hw;
- }
- }
- }
-}
-
-void TDMHwcWindow::TearDown(void)
-{
- for (int w = 0; w < hwc_count; w++)
- tdm_hwc_window_destroy(hwc_wins[w]);
-
- TDMOutput::TearDown();
-}
-
-/* void tdm_hwc_window_destroy(tdm_hwc_window *hwc_window); */
-/*
-TEST_P(TDMHwcWindow, DestroyWindowFailNull)
-{
- tdm_hwc_window_destroy(NULL);
-}
-
-TEST_P(TDMHwcWindow, DestroyWindowSuccessful)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- tdm_hwc_window *hw = NULL;
-
- for (int o = 0; o < output_count; o++) {
- if (ut_tdm_output_is_hwc_enable(outputs[o])) {
- hw = tdm_hwc_create_window(outputs[o], &error);
- ASSERT_EQ(TDM_ERROR_NONE, error);
- error = tdm_hwc_window_destroy(outputs[o], hw);
- ASSERT_EQ(TDM_ERROR_NONE, error);
- }
- }
-}
-*/
-
-/* tbm_surface_queue_h tdm_hwc_window_get_buffer_queue(tdm_hwc_window *hwc_window, tdm_error *error); */
-TEST_P(TDMHwcWindow, GetBufferQueueFailNull)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- tbm_surface_queue_h queue = NULL;
-
- queue = tdm_hwc_window_get_buffer_queue(NULL, &error);
- ASSERT_NE(TDM_ERROR_NONE, error);
- ASSERT_EQ(NULL, queue);
-
- queue = tdm_hwc_window_get_buffer_queue(NULL, NULL);
- ASSERT_EQ(NULL, queue);
-}
-
-TEST_P(TDMHwcWindow, GetBufferQueueSuccessful)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- tbm_surface_queue_h queue = NULL;
- tdm_hwc_window_info info = { 0 };
-
- info.src_config.format = TBM_FORMAT_ARGB8888;
- info.src_config.size.h = info.src_config.size.v = 256;
- info.src_config.pos.h = info.src_config.pos.w = 256;
- info.dst_pos.h = info.dst_pos.w = 256;
- info.transform = TDM_TRANSFORM_NORMAL;
-
- for (int w = 0; w < hwc_count; w++) {
- error = tdm_hwc_window_set_info(hwc_wins[w], &info);
- ASSERT_EQ(TDM_ERROR_NONE, error);
-
- queue = tdm_hwc_window_get_buffer_queue(hwc_wins[w], &error);
- tbm_surface_queue_destroy(queue);
- ASSERT_EQ(TDM_ERROR_NONE, error);
- ASSERT_NE(NULL, queue);
-
- queue = tdm_hwc_window_get_buffer_queue(hwc_wins[w], NULL);
- tbm_surface_queue_destroy(queue);
- ASSERT_NE(NULL, queue);
- }
-}
-
-/* tdm_error tdm_hwc_window_set_composition_type(tdm_hwc_window *hwc_window,
- tdm_hwc_window_composition composition_type); */
-TEST_P(TDMHwcWindow, SetCompositionTypeFailNull)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- error = tdm_hwc_window_set_composition_type(NULL, TDM_COMPOSITION_DEVICE);
- ASSERT_NE(TDM_ERROR_NONE, error);
-}
-
-TEST_P(TDMHwcWindow, SetCompositionTypeSuccessful)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int w = 0; w < hwc_count; w++) {
- error = tdm_hwc_window_set_composition_type(hwc_wins[w], TDM_COMPOSITION_DEVICE);
- ASSERT_EQ(TDM_ERROR_NONE, error);
- error = tdm_hwc_window_set_composition_type(hwc_wins[w], TDM_COMPOSITION_CLIENT);
- ASSERT_EQ(TDM_ERROR_NONE, error);
- error = tdm_hwc_window_set_composition_type(hwc_wins[w], TDM_COMPOSITION_CURSOR);
- ASSERT_EQ(TDM_ERROR_NONE, error);
- }
-}
-
-TEST_P(TDMHwcWindow, SetCompositionTypeFailInvalieCompositionType)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int w = 0; w < hwc_count; w++) {
- error = tdm_hwc_window_set_composition_type(hwc_wins[w], tdm_hwc_window_composition(TDM_COMPOSITION_NONE - 1));
- ASSERT_NE(TDM_ERROR_NONE, error);
- }
-}
-
-/* tdm_error tdm_hwc_window_set_buffer_damage(tdm_hwc_window *hwc_window, tdm_region damage); */
-TEST_P(TDMHwcWindow, SetBufferDamageFailNullHwcWindow)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- tdm_region damage = {.num_rects = 0, .rects = NULL};
-
- error = tdm_hwc_window_set_buffer_damage(NULL, damage);
- ASSERT_NE(TDM_ERROR_NONE, error);
-}
-
-TEST_P(TDMHwcWindow, SetBufferDamageFailNullDamageRects)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- tdm_region damage = {.num_rects = 1, .rects = NULL};
-
- for (int w = 0; w < hwc_count; w++) {
- error = tdm_hwc_window_set_buffer_damage(hwc_wins[w], damage);
- ASSERT_NE(TDM_ERROR_NONE, error);
- }
-}
-
-
-TEST_P(TDMHwcWindow, SetBufferDamageSuccessful)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- tdm_pos const rects[1] = {0};
- tdm_region damage = {.num_rects = 1, .rects = rects};
-
- for (int w = 0; w < hwc_count; w++) {
- error = tdm_hwc_window_set_buffer_damage(hwc_wins[w], damage);
- ASSERT_EQ(TDM_ERROR_NONE, error);
- }
-}
-
-
-/* tdm_error tdm_hwc_window_set_info(tdm_hwc_window *hwc_window, tdm_hwc_window_info *info); */
-TEST_P(TDMHwcWindow, SetInfoFailNull)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- tdm_hwc_window_info info = { 0 };
-
- error = tdm_hwc_window_set_info(NULL, &info);
- ASSERT_NE(TDM_ERROR_NONE, error);
-
- if (hwc_count > 0) {
- error = tdm_hwc_window_set_info(hwc_wins[0], NULL);
- ASSERT_NE(TDM_ERROR_NONE, error);
- }
-}
-
-TEST_P(TDMHwcWindow, SetInfoSuccessful)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- tdm_hwc_window_info info = { 0 };
-
- for (int w = 0; w < hwc_count; w++) {
- error = tdm_hwc_window_set_info(hwc_wins[w], &info);
- ASSERT_EQ(TDM_ERROR_NONE, error);
- }
-}
-
-
-/* tdm_error tdm_hwc_window_set_buffer(tdm_hwc_window *hwc_window, tbm_surface_h buffer); */
-TEST_P(TDMHwcWindow, SetBufferFailNull)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- error = tdm_hwc_window_set_buffer(NULL, NULL);
- ASSERT_NE(TDM_ERROR_NONE, error);
-}
-
-TEST_P(TDMHwcWindow, SetBufferSuccessful)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int w = 0; w < hwc_count; w++) {
-
- tbm_surface_h buff = tbm_surface_create(256, 256, TBM_FORMAT_ARGB8888);
-
- /* test: set*/
- error = tdm_hwc_window_set_buffer(hwc_wins[w], buff);
- tbm_surface_destroy(buff);
- ASSERT_EQ(TDM_ERROR_NONE, error);
-
- /* test: reset*/
- error = tdm_hwc_window_set_buffer(hwc_wins[w], NULL);
- ASSERT_EQ(TDM_ERROR_NONE, error);
- }
-}
-
-/* tdm_hwc_get_available_properties() */
-/*
-TEST_P(TDMHwcWindow, GetAvailablePropertiesFailNullWin)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- TDM_UT_SKIP_FLAG(video_hwc_win != NULL);
- const tdm_prop *props;
- int count;
-
- error = tdm_hwc_get_available_properties(NULL, &props, &count);
- ASSERT_NE(TDM_ERROR_NONE, error);
-
- error = tdm_hwc_get_available_properties(video_hwc_win, NULL, &count);
- ASSERT_NE(TDM_ERROR_NONE, error);
-
- error = tdm_hwc_get_available_properties(video_hwc_win, &props, NULL);
- ASSERT_NE(TDM_ERROR_NONE, error);
-}
-
-TEST_P(TDMHwcWindow, GetAvailablePropertiesSuccess)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- TDM_UT_SKIP_FLAG(video_hwc_win != NULL);
-
- const tdm_prop *props;
- int count;
-
- error = tdm_hwc_get_available_properties(video_hwc_win, &props, &count);
- ASSERT_TRUE(TDM_ERROR_NONE == error || TDM_ERROR_NOT_IMPLEMENTED == error);
-}
-*/
-
-/* tdm_hwc_window_get_property() */
-TEST_P(TDMHwcWindow, GetPropertyFailNull)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
- TDM_UT_SKIP_FLAG(video_hwc_win != NULL);
-
- tdm_value value;
- int id = 1;
-
- error = tdm_hwc_window_get_property(NULL, id, &value);
- ASSERT_NE(TDM_ERROR_NONE, error);
-
- error = tdm_hwc_window_get_property(video_hwc_win, id, NULL);
- ASSERT_NE(TDM_ERROR_NONE, error);
-}
-
-TEST_P(TDMHwcWindow, GetPropertyFailWrongId)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
- TDM_UT_SKIP_FLAG(video_hwc_win != NULL);
-
- tdm_value value;
- int id = INT_MAX;
-
- error = tdm_hwc_window_get_property(video_hwc_win, id, &value);
- ASSERT_NE(TDM_ERROR_NONE, error);
-}
-
-/* tdm_hwc_window_set_property() */
-TEST_P(TDMHwcWindow, SetPropertyFailNull)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
- TDM_UT_SKIP_FLAG(video_hwc_win != NULL);
-
- tdm_value value;
- int id = 1;
-
- error = tdm_hwc_window_set_property(NULL, id, value);
- ASSERT_NE(TDM_ERROR_NONE, error);
-}
-
-TEST_P(TDMHwcWindow, SetPropertyFailWrongId)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
- TDM_UT_SKIP_FLAG(video_hwc_win != NULL);
-
- tdm_value value;
- int id = INT_MAX;
-
- error = tdm_hwc_window_set_property(video_hwc_win, id, value);
- ASSERT_NE(TDM_ERROR_NONE, error);
-}
-
-#ifdef TDM_UT_TEST_WITH_PARAMS
-INSTANTIATE_TEST_CASE_P(TDMHwcWindowParams,
- TDMHwcWindow,
- Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
-#else
-INSTANTIATE_TEST_CASE_P(TDMHwcWindowParams,
- TDMHwcWindow,
- Values(TDM_DEFAULT_MODULE));
-#endif
-
-/* LCOV_EXCL_END */
\ No newline at end of file
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
- *
- * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
- * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
- * Contact: Roman Marchenko <r.marchenko@samsung.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
-**************************************************************************/
-
-#include "ut_tdm.h"
-
-/* LCOV_EXCL_START */
-
-#define BORDER_SIZE 20
-
-class TDMLayer : public TDMOutput
-{
-public:
- bool has_layers;
- tdm_layer **layers;
- int layer_count;
-
- tbm_surface_h buffers[3];
- tbm_surface_queue_h buffer_queue;
-
- TDMLayer();
- void SetUp(void);
- void TearDown(void);
-
- void DestroyBuffers(void);
-};
-
-TDMLayer::TDMLayer()
-{
- has_layers = false;
- layers = NULL;
- layer_count = TDM_UT_INVALID_VALUE;
-
- for (int b = 0; b < 3; b++)
- buffers[b] = NULL;
-
- buffer_queue = NULL;
-}
-
-void TDMLayer::SetUp(void)
-{
- TDMOutput::SetUp();
-
- layer_count = 0;
-
- for (int o = 0; o < output_count; o++) {
- int old_layer_count = layer_count, count = TDM_UT_INVALID_VALUE;
- tdm_error ret;
-
- if (ut_tdm_output_is_hwc_enable(outputs[o]))
- continue;
-
- ASSERT_EQ(tdm_output_get_layer_count(outputs[o], &count), TDM_ERROR_NONE);
- ASSERT_GT(count, 0);
-
- layer_count += count;
- layers = (tdm_layer**)realloc(layers, sizeof(tdm_layer*) * layer_count);
- ASSERT_NE(layers, NULL);
-
- for (int l = 0; l < count; l++) {
- tdm_layer *layer = tdm_output_get_layer(outputs[o], l, &ret);
- ASSERT_NE(layer, NULL);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- layers[old_layer_count + l] = layer;
- }
- }
-
- if (layer_count > 0)
- has_layers = true;
-}
-
-void TDMLayer::TearDown(void)
-{
- for (int l = 0; l < layer_count; l++) {
- ASSERT_EQ(tdm_layer_unset_buffer(layers[l]), TDM_ERROR_NONE);
- }
-
- free(layers);
-
- DestroyBuffers();
-
- TDMOutput::TearDown();
-}
-
-void TDMLayer::DestroyBuffers(void)
-{
- for (int b = 0; b < 3; b++) {
- if (buffers[b]) {
- tbm_surface_destroy(buffers[b]);
- buffers[b] = NULL;
- }
- }
-
- if (buffer_queue) {
- tbm_surface_queue_destroy(buffer_queue);
- buffer_queue = NULL;
- }
-}
-
-bool
-ut_tdm_layer_is_cursor_layer(tdm_layer *layer)
-{
- tdm_layer_capability capabilities = (tdm_layer_capability)TDM_UT_INVALID_VALUE;
- if (tdm_layer_get_capabilities(layer, &capabilities) != TDM_ERROR_NONE)
- return false;
- return capabilities & TDM_LAYER_CAPABILITY_CURSOR;
-}
-
-bool
-ut_tdm_layer_is_primary_layer(tdm_layer *layer)
-{
- tdm_layer_capability capabilities = (tdm_layer_capability)TDM_UT_INVALID_VALUE;
- if (tdm_layer_get_capabilities(layer, &capabilities) != TDM_ERROR_NONE)
- return false;
- return capabilities & TDM_LAYER_CAPABILITY_PRIMARY;
-}
-
-bool
-ut_tdm_layer_is_video_layer(tdm_layer *layer)
-{
- tdm_layer_capability capabilities = (tdm_layer_capability)TDM_UT_INVALID_VALUE;
- if (tdm_layer_get_capabilities(layer, &capabilities) != TDM_ERROR_NONE)
- return false;
- return capabilities & TDM_LAYER_CAPABILITY_VIDEO;
-}
-
-bool
-ut_tdm_layer_support_scale(tdm_layer *layer)
-{
- tdm_layer_capability capabilities = (tdm_layer_capability)TDM_UT_INVALID_VALUE;
- if (tdm_layer_get_capabilities(layer, &capabilities) != TDM_ERROR_NONE)
- return false;
- return capabilities & TDM_LAYER_CAPABILITY_SCALE;
-}
-
-bool
-ut_tdm_layer_support_no_crop(tdm_layer *layer)
-{
- tdm_layer_capability capabilities = (tdm_layer_capability)TDM_UT_INVALID_VALUE;
- if (tdm_layer_get_capabilities(layer, &capabilities) != TDM_ERROR_NONE)
- return false;
- return capabilities & TDM_LAYER_CAPABILITY_NO_CROP;
-}
-
-unsigned int
-ut_tdm_layer_get_output_pipe(tdm_layer *layer)
-{
- unsigned int pipe = (unsigned int)TDM_UT_INVALID_VALUE;
- tdm_error ret;
- tdm_output *output = tdm_layer_get_output(layer, &ret);
- TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(output != NULL);
-
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_pipe(output, &pipe) == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(pipe != (unsigned int)TDM_UT_INVALID_VALUE);
-
- return pipe;
-}
-
-tbm_format
-ut_tdm_layer_find_best_format(tdm_layer *layer)
-{
- const tbm_format *formats = (const tbm_format *)TDM_UT_INVALID_VALUE;
- int count = TDM_UT_INVALID_VALUE;
- tdm_error ret;
- ret = tdm_layer_get_available_formats(layer, &formats, &count);
- TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
-
- for (int f = 0; f < count; f++)
- if (formats[f] == TBM_FORMAT_ARGB8888)
- return TBM_FORMAT_ARGB8888;
- for (int f = 0; f < count; f++)
- if (formats[f] == TBM_FORMAT_XRGB8888)
- return TBM_FORMAT_XRGB8888;
- for (int f = 0; f < count; f++)
- if (formats[f] == TBM_FORMAT_YUV420)
- return TBM_FORMAT_YUV420;
- for (int f = 0; f < count; f++)
- if (formats[f] == TBM_FORMAT_NV12)
- return TBM_FORMAT_NV12;
-
- return 0;
-}
-
-bool
-ut_tdm_layer_prepare_buffer(tdm_layer *layer, tbm_surface_h *buffers, int buffer_count, bool fill)
-{
- tdm_error ret;
- unsigned int flags = 0;
- tbm_format format = (tbm_format)0;
- int w, h;
- tdm_output *output;
- const tdm_output_mode *mode = NULL;
-
- /* create buffers */
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_buffer_flags(layer, &flags) == TDM_ERROR_NONE);
-
- format = ut_tdm_layer_find_best_format(layer);
- TDM_UT_RETURN_FALSE_IF_FAIL(format != 0);
-
- output = tdm_layer_get_output(layer, &ret);
- TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(output != NULL);
-
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_mode(output, &mode) == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(mode != NULL);
-
- if (ut_tdm_layer_is_primary_layer(layer)) {
- w = mode->hdisplay;
- h = mode->vdisplay;
- } else {
- w = mode->hdisplay / 2;
- h = mode->vdisplay / 2;
- }
-
- TDM_UT_RETURN_FALSE_IF_FAIL(ut_tdm_buffer_create(w, h, format, flags | TBM_BO_SCANOUT, fill, buffer_count, buffers) == true);
-
- TDM_INFO("preparing buffers done");
-
- return true;
-}
-
-bool
-ut_tdm_layer_prepare_buffer_queue(tdm_layer *layer, tbm_surface_queue_h *buffer_queue)
-{
- tdm_error ret;
- unsigned int flags = 0;
- tbm_format format = (tbm_format)0;
- int w, h;
-
- /* create buffers */
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_buffer_flags(layer, &flags) == TDM_ERROR_NONE);
-
- format = ut_tdm_layer_find_best_format(layer);
- TDM_UT_RETURN_FALSE_IF_FAIL(format != (tbm_format)0);
-
- if (ut_tdm_layer_is_primary_layer(layer)) {
- tdm_output *output;
- const tdm_output_mode *mode = NULL;
- output = tdm_layer_get_output(layer, &ret);
- TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(output != NULL);
-
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_mode(output, &mode) == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(mode != NULL);
-
- w = mode->hdisplay;
- h = mode->vdisplay;
- } else {
- w = TDM_UT_BUFFER_SIZE;
- h = TDM_UT_BUFFER_SIZE;
- }
-
- *buffer_queue = tbm_surface_queue_create(2, w, h, format, flags | TBM_BO_SCANOUT);
- TDM_UT_RETURN_FALSE_IF_FAIL((*buffer_queue) != NULL);
-
- TDM_INFO("preparing buffers done");
-
- return true;
-}
-
-bool
-ut_tdm_layer_fill_info(tdm_layer *layer, tbm_surface_h buffer, tbm_surface_queue_h buffer_queue, tdm_info_layer *info)
-{
- tdm_error ret;
- tdm_output *output;
- const tdm_output_mode *mode = NULL;
- int count = 0;
- int zpos = -1;
- int bw, bh;
- int w, h;
- tbm_format format;
-
- output = tdm_layer_get_output(layer, &ret);
- TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(output != NULL);
-
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_mode(output, &mode) == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(mode != NULL);
-
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_layer_count(output, &count) == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(count > 0);
-
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_zpos(layer, &zpos) == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(zpos >= 0);
-
- if (buffer) {
- tdm_helper_get_buffer_full_size(buffer, &bw, &bh);
- w = tbm_surface_get_width(buffer);
- h = tbm_surface_get_height(buffer);
- format = tbm_surface_get_format(buffer);
- } else if (buffer_queue) {
- bw = w = tbm_surface_queue_get_width(buffer_queue);
- bh = h = tbm_surface_queue_get_height(buffer_queue);
- format = tbm_surface_queue_get_format(buffer_queue);
- } else {
- bw = mode->hdisplay;
- bh = mode->vdisplay;
- w = mode->hdisplay;
- h = mode->vdisplay;
- format = ut_tdm_layer_find_best_format(layer);
- }
-
- /* TODO: check min,max,prefered size and avaiable formats */
- memset(info, 0, sizeof *info);
- info->src_config.size.h = bw;
- info->src_config.size.v = bh;
- info->src_config.pos.x = 0;
- info->src_config.pos.y = 0;
- info->src_config.pos.w = w;
- info->src_config.pos.h = h;
- info->src_config.format = format;
- if (ut_tdm_layer_is_primary_layer(layer)) {
- info->dst_pos.x = 0;
- info->dst_pos.y = 0;
- } else {
- int x = (((int)mode->hdisplay - 2 * BORDER_SIZE - w) / count) * zpos + BORDER_SIZE;
- int y = (((int)mode->vdisplay - 2 * BORDER_SIZE - h) / count) * zpos + BORDER_SIZE;
- x = (x > 0) ? x : 0;
- y = (y > 0) ? y : 0;
- info->dst_pos.x = ((x + w) <= (int)mode->hdisplay) ? x : 0;
- info->dst_pos.y = ((y + h) <= (int)mode->vdisplay) ? y : 0;
- }
- info->dst_pos.w = w;
- info->dst_pos.h = h;
- info->transform = TDM_TRANSFORM_NORMAL;
-
- return true;
-}
-
-bool ut_tdm_layer_set_buffer(tdm_layer *layer, tbm_surface_h buffer)
-{
- tdm_info_layer old_info, info;
-
- TDM_UT_RETURN_FALSE_IF_FAIL(buffer != NULL);
-
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_info(layer, &old_info) == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(ut_tdm_layer_fill_info(layer, buffer, NULL, &info) == true);
-
- if (memcmp(&old_info, &info, sizeof info)) {
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_set_info(layer, &info) == TDM_ERROR_NONE);
-
- tdm_output *output;
- tdm_error ret;
- int index = -1;
- unsigned int pipe = 0;
- output = tdm_layer_get_output(layer, &ret);
- TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_index(layer, &index) == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_pipe(output, &pipe) == TDM_ERROR_NONE);
- TDM_INFO("filling output(%d) layer(%d) info done: src_config(%dx%d: %d,%d %dx%d: %c%c%c%c) dst_pos(%d,%d %dx%d) transform(%s)",
- pipe, index,
- info.src_config.size.h, info.src_config.size.v,
- info.src_config.pos.x, info.src_config.pos.y, info.src_config.pos.w, info.src_config.pos.h,
- FOURCC_STR(info.src_config.format),
- info.dst_pos.x, info.dst_pos.y, info.dst_pos.w, info.dst_pos.h,
- tdm_transform_str(info.transform));
- }
-
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_set_buffer(layer, buffer) == TDM_ERROR_NONE);
-
- return true;
-}
-
-bool ut_tdm_layer_set_buffer_with_pos(tdm_layer *layer, tbm_surface_h buffer, tdm_pos *pos)
-{
- tdm_info_layer old_info, info;
-
- TDM_UT_RETURN_FALSE_IF_FAIL(buffer != NULL);
- TDM_UT_RETURN_FALSE_IF_FAIL(pos != NULL);
-
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_info(layer, &old_info) == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(ut_tdm_layer_fill_info(layer, buffer, NULL, &info) == true);
-
- info.dst_pos.x = pos->x;
- info.dst_pos.y = pos->y;
- TDM_UT_RETURN_FALSE_IF_FAIL(info.dst_pos.w = pos->w);
- TDM_UT_RETURN_FALSE_IF_FAIL(info.dst_pos.h = pos->h);
-
- if (memcmp(&old_info, &info, sizeof info)) {
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_set_info(layer, &info) == TDM_ERROR_NONE);
-
- tdm_output *output;
- tdm_error ret;
- int index = -1;
- unsigned int pipe = 0;
- output = tdm_layer_get_output(layer, &ret);
- TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_index(layer, &index) == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_pipe(output, &pipe) == TDM_ERROR_NONE);
- TDM_INFO("filling output(%d) layer(%d) info done: src_config(%dx%d: %d,%d %dx%d: %c%c%c%c) dst_pos(%d,%d %dx%d) transform(%s)",
- pipe, index,
- info.src_config.size.h, info.src_config.size.v,
- info.src_config.pos.x, info.src_config.pos.y, info.src_config.pos.w, info.src_config.pos.h,
- FOURCC_STR(info.src_config.format),
- info.dst_pos.x, info.dst_pos.y, info.dst_pos.w, info.dst_pos.h,
- tdm_transform_str(info.transform));
- }
-
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_set_buffer(layer, buffer) == TDM_ERROR_NONE);
-
- return true;
-}
-
-bool ut_tdm_layer_set_buffer_queue(tdm_layer *layer, tbm_surface_queue_h buffer_queue)
-{
- tdm_info_layer old_info, info;
-
- TDM_UT_RETURN_FALSE_IF_FAIL(buffer_queue != NULL);
-
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_info(layer, &old_info) == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(ut_tdm_layer_fill_info(layer, NULL, buffer_queue, &info) == true);
-
- if (memcmp(&old_info, &info, sizeof info))
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_set_info(layer, &info) == TDM_ERROR_NONE);
-
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_set_buffer_queue(layer, buffer_queue) == TDM_ERROR_NONE);
-
- return true;
-}
-
-bool ut_tdm_layer_is_avaiable(tdm_layer *layer)
-{
- tdm_error ret;
- tdm_output *output = tdm_layer_get_output(layer, &ret);
- TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(output != NULL);
-
- /* only check if connected */
- return ut_tdm_output_is_connected(output);
-}
-
-TEST_P(TDMLayer, LayerGetOutput)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- for (int l = 0; l < layer_count; l++) {
- tdm_error ret;
- tdm_output *output = tdm_layer_get_output(layers[l], &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(output, NULL);
- }
-}
-
-TEST_P(TDMLayer, LayerGetOutputNullObject)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- tdm_error ret;
- tdm_output *output = tdm_layer_get_output(NULL, &ret);
- ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(output, NULL);
-}
-
-TEST_P(TDMLayer, LayerGetOutputNullParam)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- for (int l = 0; l < layer_count; l++) {
- tdm_output *output = tdm_layer_get_output(layers[l], NULL);
- ASSERT_NE(output, NULL);
- }
-}
-
-TEST_P(TDMLayer, LayerGetCapabilities)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- for (int l = 0; l < layer_count; l++) {
- tdm_layer_capability capabilities = (tdm_layer_capability)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_layer_get_capabilities(layers[l], &capabilities), TDM_ERROR_NONE);
- ASSERT_NE(capabilities, TDM_UT_INVALID_VALUE);
- }
-}
-
-TEST_P(TDMLayer, LayerGetCapabilitiesNullObject)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- tdm_layer_capability capabilities = (tdm_layer_capability)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_layer_get_capabilities(NULL, &capabilities), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(capabilities, TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMLayer, LayerGetCapabilitiesNullOther)
-{
- TDM_UT_SKIP_FLAG(has_layers);
- ASSERT_EQ(tdm_layer_get_capabilities(layers[0], NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMLayer, LayerGetAvailableFormats)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- for (int l = 0; l < layer_count; l++) {
- if (!ut_tdm_layer_is_avaiable(layers[l]))
- continue;
- const tbm_format *formats = (const tbm_format *)TDM_UT_INVALID_VALUE;
- int count = TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_layer_get_available_formats(layers[l], &formats, &count), TDM_ERROR_NONE);
- ASSERT_NE(formats, NULL);
- ASSERT_GT(count, 0);
- }
-}
-
-TEST_P(TDMLayer, LayerGetAvailableFormatsNullObject)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- const tbm_format *formats = (const tbm_format *)TDM_UT_INVALID_VALUE;
- int count = TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_layer_get_available_formats(NULL, &formats, &count), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(formats, (const tbm_format *)TDM_UT_INVALID_VALUE);
- ASSERT_EQ(count, TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMLayer, LayerGetAvailableFormatsNullOther)
-{
- TDM_UT_SKIP_FLAG(has_layers);
- if (!ut_tdm_layer_is_avaiable(layers[0]))
- return;
- ASSERT_EQ(tdm_layer_get_available_formats(layers[0], NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMLayer, LayerGetAvailableProperties)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- for (int l = 0; l < layer_count; l++) {
- if (!ut_tdm_layer_is_avaiable(layers[l]))
- continue;
- const tdm_prop *props = (const tdm_prop *)TDM_UT_INVALID_VALUE;
- int count = TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_layer_get_available_properties(layers[l], &props, &count), TDM_ERROR_NONE);
- ASSERT_GE(count, 0);
- if (count > 0)
- ASSERT_TRUE(props != NULL && props != (const tdm_prop *)TDM_UT_INVALID_VALUE);
- }
-}
-
-TEST_P(TDMLayer, LayerGetAvailablePropertiesNullObject)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- const tdm_prop *props = (const tdm_prop *)TDM_UT_INVALID_VALUE;
- int count = TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_layer_get_available_properties(NULL, &props, &count), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(props, (const tdm_prop *)TDM_UT_INVALID_VALUE);
- ASSERT_EQ(count, TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMLayer, LayerGetAvailablePropertiesNullOther)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- ASSERT_EQ(tdm_layer_get_available_properties(layers[0], NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMLayer, LayerGetZpos)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- bool *check_table = (bool*)calloc(layer_count, output_count);
- ASSERT_NE(check_table, NULL);
-
- for (int l = 0; l < layer_count; l++) {
- if (!ut_tdm_layer_is_avaiable(layers[l]))
- continue;
- unsigned int pipe = ut_tdm_layer_get_output_pipe(layers[l]);
- int zpos = TDM_UT_INVALID_VALUE;
- EXPECT_TRUE(tdm_layer_get_zpos(layers[l], &zpos) == TDM_ERROR_NONE);
- EXPECT_TRUE(zpos != TDM_UT_INVALID_VALUE);
- if (ut_tdm_layer_is_video_layer(layers[l]))
- continue;
- EXPECT_TRUE(zpos >= 0);
- EXPECT_TRUE(pipe < (unsigned int)output_count);
- EXPECT_TRUE(*(check_table + pipe * layer_count + zpos) == false);
- *(check_table + pipe * layer_count + zpos) = true;
- }
-
- free(check_table);
-}
-
-TEST_P(TDMLayer, LayerGetZposNullObject)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- int zpos = TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_layer_get_zpos(NULL, &zpos), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(zpos, TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMLayer, LayerGetZposNullParam)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- ASSERT_EQ(tdm_layer_get_zpos(layers[0], NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMLayer, DISABLED_LayerSetProperty)
-{
-}
-
-TEST_P(TDMLayer, LayerSetPropertyNullObject)
-{
- tdm_value value = {.s32 = 0};
-
- ASSERT_EQ(tdm_layer_set_property(NULL, 0, value), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMLayer, LayerGetProperty)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- for (int l = 0; l < layer_count; l++) {
- if (!ut_tdm_layer_is_avaiable(layers[l]))
- continue;
-
- const tdm_prop *props = (const tdm_prop *)TDM_UT_INVALID_VALUE;
- int count = TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_layer_get_available_properties(layers[l], &props, &count), TDM_ERROR_NONE);
- ASSERT_GE(count, 0);
- if (count > 0) {
- ASSERT_TRUE(props != NULL && props != (const tdm_prop *)TDM_UT_INVALID_VALUE);
-
- for (int i = 0; i < count; i++) {
- tdm_value value = {.s32 = TDM_UT_INVALID_VALUE};
- ASSERT_EQ(tdm_layer_get_property(layers[l], props[i].id, &value), TDM_ERROR_NONE);
- ASSERT_NE(value.s32, TDM_UT_INVALID_VALUE);
- }
- }
- }
-}
-
-TEST_P(TDMLayer, LayerGetPropertyNullObject)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- tdm_value value = {.s32 = TDM_UT_INVALID_VALUE};
- ASSERT_EQ(tdm_layer_get_property(NULL, 0, &value), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(value.s32, TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMLayer, LayerGetPropertyNullOther)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- ASSERT_EQ(tdm_layer_get_property(layers[0], 0, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMLayer, LayerSetInfo)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- ut_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
-
- for (int l = 0; l < layer_count; l++) {
- if (!ut_tdm_layer_is_avaiable(layers[l]))
- continue;
-
- tdm_info_layer info;
- ASSERT_EQ(ut_tdm_layer_fill_info(layers[l], NULL, NULL, &info), true);
- ASSERT_EQ(tdm_layer_set_info(layers[l], &info), TDM_ERROR_NONE);
- }
-}
-
-TEST_P(TDMLayer, LayerSetInfoNullObject)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- tdm_info_layer info;
- memset(&info, 0, sizeof info);
- ASSERT_EQ(tdm_layer_set_info(NULL, &info), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMLayer, LayerSetInfoNullOther)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- ASSERT_EQ(tdm_layer_set_info(layers[0], NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMLayer, DISABLED_LayerGetInfo)
-{
-}
-
-TEST_P(TDMLayer, LayerGetInfoNullObject)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- tdm_info_layer temp;
-
- ASSERT_EQ(tdm_layer_get_info(NULL, &temp), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMLayer, LayerGetInfoNullParam)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- ASSERT_EQ(tdm_layer_get_info(layers[0], NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMLayer, LayerGetBufferFlags)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- for (int l = 0; l < layer_count; l++) {
- if (!ut_tdm_layer_is_avaiable(layers[l]))
- continue;
-
- unsigned int flags = (unsigned int)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_layer_get_buffer_flags(layers[l], &flags), TDM_ERROR_NONE);
- ASSERT_NE(flags, (unsigned int)TDM_UT_INVALID_VALUE);
- }
-}
-
-TEST_P(TDMLayer, LayerGetBufferFlagsNullObject)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- unsigned int flags = (unsigned int)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_layer_get_buffer_flags(NULL, &flags), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(flags, (unsigned int)TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMLayer, LayerGetBufferFlagsNullOther)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- ASSERT_EQ(tdm_layer_get_buffer_flags(layers[0], NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-static void
-_ut_tdm_layer_commit_cb(tdm_layer *layer, unsigned int sequence,
- unsigned int tv_sec, unsigned int tv_usec,
- void *user_data)
-{
- bool *done = (bool*)user_data;
- if (done)
- *done = true;
-}
-
-TEST_P(TDMLayer, LayerSetBuffer)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- tdm_error ret;
-
- ut_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
-
- for (int l = 0; l < layer_count; l++) {
- if (!ut_tdm_layer_is_avaiable(layers[l]))
- continue;
-
- int next_buffer = 0;
-
- if (ut_tdm_layer_is_cursor_layer(layers[l]))
- continue;
- if (ut_tdm_layer_is_video_layer(layers[l]))
- continue;
-
- ASSERT_EQ(ut_tdm_layer_prepare_buffer(layers[l], buffers, 3, true), true);
-
- /* set buffer & commit for 100 times */
- for (int t = 0; t < 10; t++) {
- tbm_surface_h displaying_buffer = NULL;
- ASSERT_EQ(ut_tdm_layer_set_buffer(layers[l], buffers[next_buffer]), true);
- ASSERT_EQ(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb, NULL), TDM_ERROR_NONE);
- while (displaying_buffer != buffers[next_buffer]) {
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- displaying_buffer = tdm_layer_get_displaying_buffer(layers[l], &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- }
- next_buffer++;
- if (next_buffer == 3)
- next_buffer = 0;
- }
-
- DestroyBuffers();
- }
-}
-
-TEST_P(TDMLayer, LayerSetBufferFewTimeInOneCommit)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- tdm_error ret;
-
- ut_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
-
- for (int l = 0; l < layer_count; l++) {
- if (!ut_tdm_layer_is_avaiable(layers[l]))
- continue;
-
- int next_buffer = 0;
-
- if (ut_tdm_layer_is_cursor_layer(layers[l]))
- continue;
- if (ut_tdm_layer_is_video_layer(layers[l]))
- continue;
-
- ASSERT_EQ(ut_tdm_layer_prepare_buffer(layers[l], buffers, 3, true), true);
-
- /* set buffer & commit for 10 times */
- for (int t = 0; t < 10; t++) {
- tbm_surface_h displaying_buffer = NULL;
- ASSERT_EQ(ut_tdm_layer_set_buffer(layers[l], buffers[next_buffer++]), true);
- if (next_buffer == 3)
- next_buffer = 0;
- ASSERT_EQ(ut_tdm_layer_set_buffer(layers[l], buffers[next_buffer]), true);
- ASSERT_EQ(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb, NULL), TDM_ERROR_NONE);
- while (displaying_buffer != buffers[next_buffer]) {
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- displaying_buffer = tdm_layer_get_displaying_buffer(layers[l], &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- }
- next_buffer++;
- if (next_buffer == 3)
- next_buffer = 0;
- }
-
- DestroyBuffers();
- }
-}
-
-TEST_P(TDMLayer, LayerSetBufferNullObject)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- tbm_surface_h buffer = (tbm_surface_h)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_layer_set_buffer(NULL, buffer), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMLayer, LayerSetBufferNullOther)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- ASSERT_EQ(tdm_layer_set_buffer(layers[0], NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMLayer, LayerUnsetBuffer)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- ut_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
-
- for (int l = 0; l < layer_count; l++) {
- if (!ut_tdm_layer_is_avaiable(layers[l]))
- continue;
-
- ASSERT_EQ(tdm_layer_unset_buffer(layers[l]), TDM_ERROR_NONE);
- }
-}
-
-TEST_P(TDMLayer, LayerUnsetBufferNullObject)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- ASSERT_EQ(tdm_layer_unset_buffer(NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMLayer, LayerUnsetBufferBeforeCommit)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- ut_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
-
- for (int l = 0; l < layer_count; l++) {
- if (!ut_tdm_layer_is_avaiable(layers[l]))
- continue;
-
- int next_buffer = 0;
-
- if (ut_tdm_layer_is_cursor_layer(layers[l]))
- continue;
- if (ut_tdm_layer_is_video_layer(layers[l]))
- continue;
- if (ut_tdm_layer_is_primary_layer(layers[l]))
- continue;
-
- ASSERT_EQ(ut_tdm_layer_prepare_buffer(layers[l], buffers, 3, true), true);
-
- /* set buffer & commit for 10 times */
- for (int t = 0; t < 10; t++) {
- ASSERT_EQ(ut_tdm_layer_set_buffer(layers[l], buffers[next_buffer++]), true);
- if (next_buffer == 3)
- next_buffer = 0;
- ASSERT_EQ(ut_tdm_layer_set_buffer(layers[l], buffers[next_buffer++]), true);
- if (next_buffer == 3)
- next_buffer = 0;
- }
-
- ASSERT_EQ(tdm_layer_unset_buffer(layers[l]), TDM_ERROR_NONE);
-
- DestroyBuffers();
- }
-}
-
-TEST_P(TDMLayer, LayerUnsetBufferAfterOneCommit)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- ut_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
-
- for (int l = 0; l < layer_count; l++) {
- if (!ut_tdm_layer_is_avaiable(layers[l]))
- continue;
-
- int next_buffer = 0;
-
- if (ut_tdm_layer_is_cursor_layer(layers[l]))
- continue;
- if (ut_tdm_layer_is_video_layer(layers[l]))
- continue;
- if (ut_tdm_layer_is_primary_layer(layers[l]))
- continue;
-
- ASSERT_EQ(ut_tdm_layer_prepare_buffer(layers[l], buffers, 3, true), true);
-
- ASSERT_EQ(ut_tdm_layer_set_buffer(layers[l], buffers[next_buffer++]), true);
- ASSERT_EQ(ut_tdm_layer_set_buffer(layers[l], buffers[next_buffer++]), true);
- ASSERT_EQ(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb, NULL), TDM_ERROR_NONE);
-
- ASSERT_EQ(tdm_layer_unset_buffer(layers[l]), TDM_ERROR_NONE);
-
- DestroyBuffers();
- }
-}
-
-/* drmModePageFlip can't be done twice in a vblank */
-TEST_P(TDMLayer, DISABLED_LayerUnsetBufferAfterTwoCommit)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- ut_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
-
- for (int l = 0; l < layer_count; l++) {
- if (!ut_tdm_layer_is_avaiable(layers[l]))
- continue;
-
- int next_buffer = 0;
-
- if (ut_tdm_layer_is_cursor_layer(layers[l]))
- continue;
- if (ut_tdm_layer_is_video_layer(layers[l]))
- continue;
- if (ut_tdm_layer_is_primary_layer(layers[l]))
- continue;
-
- ASSERT_EQ(ut_tdm_layer_prepare_buffer(layers[l], buffers, 3, true), true);
-
- ASSERT_EQ(ut_tdm_layer_set_buffer(layers[l], buffers[next_buffer++]), true);
- ASSERT_EQ(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb, NULL), TDM_ERROR_NONE);
-
- ASSERT_EQ(ut_tdm_layer_set_buffer(layers[l], buffers[next_buffer++]), true);
- ASSERT_EQ(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb, NULL), TDM_ERROR_NONE);
-
- ASSERT_EQ(tdm_layer_unset_buffer(layers[l]), TDM_ERROR_NONE);
-
- DestroyBuffers();
- }
-}
-
-/* drmModePageFlip can't be done twice in a vblank */
-TEST_P(TDMLayer, DISABLED_LayerUnsetBufferAfterTwoCommitOneSetBuffer)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- ut_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
-
- for (int l = 0; l < layer_count; l++) {
- if (!ut_tdm_layer_is_avaiable(layers[l]))
- continue;
-
- int next_buffer = 0;
-
- if (ut_tdm_layer_is_cursor_layer(layers[l]))
- continue;
- if (ut_tdm_layer_is_video_layer(layers[l]))
- continue;
- if (ut_tdm_layer_is_primary_layer(layers[l]))
- continue;
-
- ASSERT_EQ(ut_tdm_layer_prepare_buffer(layers[l], buffers, 3, true), true);
-
- ASSERT_EQ(ut_tdm_layer_set_buffer(layers[l], buffers[next_buffer++]), true);
- ASSERT_EQ(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb, NULL), TDM_ERROR_NONE);
-
- ASSERT_EQ(ut_tdm_layer_set_buffer(layers[l], buffers[next_buffer++]), true);
- ASSERT_EQ(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb, NULL), TDM_ERROR_NONE);
-
- ASSERT_EQ(ut_tdm_layer_set_buffer(layers[l], buffers[next_buffer]), true);
-
- ASSERT_EQ(tdm_layer_unset_buffer(layers[l]), TDM_ERROR_NONE);
-
- DestroyBuffers();
- }
-}
-
-TEST_P(TDMLayer, LayerUnsetBufferAfterOneCommitOneDone)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- ut_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
-
- for (int l = 0; l < layer_count; l++) {
- if (!ut_tdm_layer_is_avaiable(layers[l]))
- continue;
-
- int next_buffer = 0;
- bool done;
-
- if (ut_tdm_layer_is_cursor_layer(layers[l]))
- continue;
- if (ut_tdm_layer_is_video_layer(layers[l]))
- continue;
- if (ut_tdm_layer_is_primary_layer(layers[l]))
- continue;
-
- ASSERT_EQ(ut_tdm_layer_prepare_buffer(layers[l], buffers, 3, true), true);
-
- /* set buffer & commit for 10 times */
- ASSERT_EQ(ut_tdm_layer_set_buffer(layers[l], buffers[next_buffer++]), true);
- ASSERT_EQ(ut_tdm_layer_set_buffer(layers[l], buffers[next_buffer++]), true);
-
- done = false;
- ASSERT_EQ(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb, &done), TDM_ERROR_NONE);
- while (!done) {
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- }
-
- ASSERT_EQ(tdm_layer_unset_buffer(layers[l]), TDM_ERROR_NONE);
-
- DestroyBuffers();
- }
-}
-
-TEST_P(TDMLayer, LayerUnsetBufferAfterOneCommitOneDoneOneCommit)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- ut_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
-
- for (int l = 0; l < layer_count; l++) {
- if (!ut_tdm_layer_is_avaiable(layers[l]))
- continue;
-
- int next_buffer = 0;
- bool done;
-
- if (ut_tdm_layer_is_cursor_layer(layers[l]))
- continue;
- if (ut_tdm_layer_is_video_layer(layers[l]))
- continue;
- if (ut_tdm_layer_is_primary_layer(layers[l]))
- continue;
-
- ASSERT_EQ(ut_tdm_layer_prepare_buffer(layers[l], buffers, 3, true), true);
-
- /* set buffer & commit for 10 times */
- ASSERT_EQ(ut_tdm_layer_set_buffer(layers[l], buffers[next_buffer++]), true);
- ASSERT_EQ(ut_tdm_layer_set_buffer(layers[l], buffers[next_buffer++]), true);
-
- done = false;
- ASSERT_EQ(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb, &done), TDM_ERROR_NONE);
- while (!done) {
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- }
-
- ASSERT_EQ(ut_tdm_layer_set_buffer(layers[l], buffers[next_buffer++]), true);
- next_buffer = 0;
- ASSERT_EQ(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb, &done), TDM_ERROR_NONE);
-
- ASSERT_EQ(tdm_layer_unset_buffer(layers[l]), TDM_ERROR_NONE);
-
- DestroyBuffers();
- }
-}
-
-TEST_P(TDMLayer, LayerCommitDPMSOff)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- tdm_error ret;
- tdm_output *output = tdm_layer_get_output(layers[0], &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(output, NULL);
-
- if (!ut_tdm_output_is_connected(output))
- return;
-
- EXPECT_TRUE(ut_tdm_output_prepare(dpy, output, true) == true);
-
- EXPECT_TRUE(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF) == TDM_ERROR_NONE);
-
- EXPECT_TRUE(tdm_layer_commit(layers[0], NULL, NULL) == TDM_ERROR_DPMS_OFF);
-
- EXPECT_TRUE(ut_tdm_output_unset(dpy, output) == true);
-}
-
-TEST_P(TDMLayer, LayerCommitNullObject)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- ASSERT_EQ(tdm_layer_commit(NULL, _ut_tdm_layer_commit_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMLayer, LayerCommitNullOther)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- ut_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
-
- ASSERT_EQ(tdm_layer_commit(layers[0], NULL, NULL), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMLayer, LayerIsCommittingNullObject)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- unsigned int committing = (unsigned int)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_layer_is_committing(NULL, &committing), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(committing, (unsigned int)TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMLayer, LayerIsCommittingNullOther)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- ASSERT_EQ(tdm_layer_is_committing(layers[0], NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMLayer, LayerRemoveCommitHandler)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- ut_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
-
- for (int l = 0; l < layer_count; l++) {
- if (!ut_tdm_layer_is_avaiable(layers[l]))
- continue;
-
- tdm_error ret;
- tdm_output *output = tdm_layer_get_output(layers[l], &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(output, NULL);
-
- if (ut_tdm_layer_is_cursor_layer(layers[l]))
- continue;
- if (ut_tdm_layer_is_video_layer(layers[l]))
- continue;
- if (ut_tdm_layer_is_primary_layer(layers[l]))
- continue;
-
- ASSERT_EQ(ut_tdm_layer_prepare_buffer(layers[l], buffers, 1, true), true);
-
- ASSERT_EQ(ut_tdm_layer_set_buffer(layers[l], buffers[0]), true);
-
- for (int t = 0; t < 10; t++) {
- bool done1 = false, done2 = false, done3 = false;
- ASSERT_EQ(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb, &done1), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb, &done2), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb, &done3), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_layer_remove_commit_handler(layers[l], _ut_tdm_layer_commit_cb, &done2), TDM_ERROR_NONE);
- while (!done1 || done2 || !done3) {
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- }
- }
-
- DestroyBuffers();
- }
-}
-
-TEST_P(TDMLayer, LayerRemoveCommitHandlerDifferentData)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- ut_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
-
- for (int l = 0; l < layer_count; l++) {
- if (!ut_tdm_layer_is_avaiable(layers[l]))
- continue;
-
- tdm_error ret;
- tdm_output *output = tdm_layer_get_output(layers[l], &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(output, NULL);
-
- if (ut_tdm_layer_is_cursor_layer(layers[l]))
- continue;
- if (ut_tdm_layer_is_video_layer(layers[l]))
- continue;
- if (ut_tdm_layer_is_primary_layer(layers[l]))
- continue;
-
- for (int t = 0; t < 10; t++) {
- bool done1 = false, done2 = false, done3 = false;
- ASSERT_EQ(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb, &done1), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb, &done2), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb, &done3), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_layer_remove_commit_handler(layers[l], _ut_tdm_layer_commit_cb, NULL), TDM_ERROR_NONE);
- while (!done1 || !done2 || !done3) {
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- }
- }
- }
-}
-static void
-_ut_tdm_layer_commit_cb2(tdm_layer *layer, unsigned int sequence,
- unsigned int tv_sec, unsigned int tv_usec,
- void *user_data)
-{
- bool *done = (bool*)user_data;
- if (done)
- *done = true;
- ASSERT_EQ(tdm_layer_remove_commit_handler(layer, _ut_tdm_layer_commit_cb2, user_data), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMLayer, LayerRemoveCommitHandlerInHandler)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- ut_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
-
- for (int l = 0; l < layer_count; l++) {
- if (!ut_tdm_layer_is_avaiable(layers[l]))
- continue;
-
- tdm_error ret;
- tdm_output *output = tdm_layer_get_output(layers[l], &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(output, NULL);
-
- if (ut_tdm_layer_is_cursor_layer(layers[l]))
- continue;
- if (ut_tdm_layer_is_video_layer(layers[l]))
- continue;
- if (ut_tdm_layer_is_primary_layer(layers[l]))
- continue;
-
- for (int t = 0; t < 10; t++) {
- bool done1 = false, done2 = false, done3 = false;
- ASSERT_EQ(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb2, &done1), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb2, &done2), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb2, &done3), TDM_ERROR_NONE);
- while (!done1 || !done2 || !done3) {
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- }
- }
- }
-}
-
-TEST_P(TDMLayer, LayerRemoveCommitHandlerNullObject)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- ASSERT_EQ(tdm_layer_remove_commit_handler(NULL, _ut_tdm_layer_commit_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMLayer, LayerRemoveCommitHandlerNullOther)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- ASSERT_EQ(tdm_layer_remove_commit_handler(layers[0], NULL, NULL), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMLayer, LayerGetDisplayingBufferNullObject)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- tbm_surface_h displaying_buffer;
- tdm_error ret;
- displaying_buffer = tdm_layer_get_displaying_buffer(NULL, &ret);
- ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(displaying_buffer, NULL);
-}
-
-TEST_P(TDMLayer, LayerGetDisplayingBufferNullOther)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- tbm_surface_h displaying_buffer;
- displaying_buffer = tdm_layer_get_displaying_buffer(layers[0], NULL);
- ASSERT_EQ(displaying_buffer, NULL);
-}
-
-TEST_P(TDMLayer, LayerIsUsableNullObject)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- unsigned int usable = (unsigned int)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_layer_is_usable(NULL, &usable), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(usable, (unsigned int)TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMLayer, LayerSetBufferQueue)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- tdm_error ret;
-
- ut_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
-
- for (int l = 0; l < layer_count; l++) {
- if (!ut_tdm_layer_is_avaiable(layers[l]))
- continue;
-
- tbm_surface_h buffer;
- tbm_surface_h displaying_buffer;
-
- if (ut_tdm_layer_is_cursor_layer(layers[l]))
- continue;
- if (ut_tdm_layer_is_video_layer(layers[l]))
- continue;
- if (ut_tdm_layer_is_primary_layer(layers[l]))
- continue;
-
- ASSERT_EQ(ut_tdm_layer_prepare_buffer_queue(layers[l], &buffer_queue), true);
- ASSERT_NE(buffer_queue, NULL);
-
- ASSERT_EQ(ut_tdm_layer_set_buffer_queue(layers[l], buffer_queue), true);
-
- ASSERT_EQ(tdm_layer_commit(layers[l], NULL, NULL), TDM_ERROR_NONE);
-
- for (int t = 0; t < 10; t++) {
- ASSERT_EQ(tbm_surface_queue_dequeue(buffer_queue, &buffer), TBM_SURFACE_QUEUE_ERROR_NONE);
- ASSERT_NE(buffer, NULL);
- tdm_test_buffer_fill(buffer, PATTERN_SMPTE);
- ASSERT_EQ(tbm_surface_queue_enqueue(buffer_queue, buffer), TBM_SURFACE_QUEUE_ERROR_NONE);
-
- displaying_buffer = NULL;
- while (displaying_buffer != buffer) {
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- displaying_buffer = tdm_layer_get_displaying_buffer(layers[l], &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- }
- }
-
- ASSERT_EQ(tdm_layer_unset_buffer_queue(layers[l]), TDM_ERROR_NONE);
-
- DestroyBuffers();
- }
-}
-
-TEST_P(TDMLayer, LayerSetBufferQueueTwice)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- ut_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
-
- for (int l = 0; l < layer_count; l++) {
- tbm_surface_queue_h buffer_queue1 = NULL;
- tbm_surface_queue_h buffer_queue2 = NULL;
-
- if (!ut_tdm_layer_is_avaiable(layers[l]))
- continue;
- if (ut_tdm_layer_is_cursor_layer(layers[l]))
- continue;
- if (ut_tdm_layer_is_video_layer(layers[l]))
- continue;
-
- EXPECT_TRUE(ut_tdm_layer_prepare_buffer_queue(layers[l], &buffer_queue1) == true);
- EXPECT_TRUE(buffer_queue1 != NULL);
- EXPECT_TRUE(tdm_layer_set_buffer_queue(layers[l], buffer_queue1) == TDM_ERROR_NONE);
-
- EXPECT_TRUE(ut_tdm_layer_prepare_buffer_queue(layers[l], &buffer_queue2) == true);
- EXPECT_TRUE(buffer_queue2 != NULL);
- EXPECT_TRUE(tdm_layer_set_buffer_queue(layers[l], buffer_queue2) == TDM_ERROR_NONE);
-
- if (buffer_queue1)
- tbm_surface_queue_destroy(buffer_queue1);
- if (buffer_queue2)
- tbm_surface_queue_destroy(buffer_queue2);
- }
-}
-
-TEST_P(TDMLayer, LayerSetBufferQueueNullObject)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- tbm_surface_queue_h buffer_queue = (tbm_surface_queue_h)TDM_UT_INVALID_VALUE;
-
- ASSERT_EQ(tdm_layer_set_buffer_queue(NULL, buffer_queue), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMLayer, LayerSetBufferQueueNullOther)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- ASSERT_EQ(tdm_layer_set_buffer_queue(layers[0], NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMLayer, LayerUnsetBufferQueueNullObject)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- ASSERT_EQ(tdm_layer_unset_buffer_queue(NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMLayer, LayerIsUsableNullOther)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- ASSERT_EQ(tdm_layer_is_usable(layers[0], NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMLayer, LayerSetVideoPos)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- for (int l = 0; l < layer_count; ++l) {
- if (!ut_tdm_layer_is_avaiable(layers[l]))
- continue;
-
- if (!ut_tdm_layer_is_video_layer(layers[l]))
- continue;
- ASSERT_EQ(tdm_layer_set_video_pos(layers[l], -1), TDM_ERROR_NONE);
- }
-}
-
-TEST_P(TDMLayer, LayerSetVideoPosNullObject)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- ASSERT_EQ(tdm_layer_set_video_pos(NULL, -1), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMLayer, LayerSetVideoPosNoVideoLayer)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- for (int l = 0; l < layer_count; ++l) {
- if (!ut_tdm_layer_is_avaiable(layers[l]))
- continue;
-
- if (ut_tdm_layer_is_video_layer(layers[l]))
- continue;
-
- ASSERT_EQ(tdm_layer_set_video_pos(layers[l], -1), TDM_ERROR_BAD_REQUEST);
- }
-}
-
-TEST_P(TDMLayer, LayerCreateCapture)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- for (int l = 0; l < layer_count; ++l) {
- tdm_error ret;
- tdm_capture *capture;
-
- if (!ut_tdm_layer_is_avaiable(layers[l]))
- continue;
-
- capture = tdm_layer_create_capture(layers[l], &ret);
- if (ret == TDM_ERROR_NONE)
- ASSERT_NE(capture, NULL);
- }
-}
-
-TEST_P(TDMLayer, LayerCreateCaptureNullObject)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- tdm_error ret;
- tdm_capture *capture = tdm_layer_create_capture(NULL, &ret);
- ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(capture, NULL);
-}
-
-#ifdef TDM_UT_TEST_WITH_PARAMS
-INSTANTIATE_TEST_CASE_P(TDMLayerParams,
- TDMLayer,
- Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
-#else
-INSTANTIATE_TEST_CASE_P(TDMLayerParams,
- TDMLayer,
- Values(TDM_DEFAULT_MODULE));
-#endif
-
-/* LCOV_EXCL_END */
\ No newline at end of file
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
- *
- * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
- * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
- * Contact: Roman Marchenko <r.marchenko@samsung.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
-**************************************************************************/
-
-#include "ut_tdm.h"
-
-/* LCOV_EXCL_START */
-
-TEST(TDMLog, logPrintf)
-{
- tdm_log_enable_color(1);
- tdm_log_enable_dlog(0);
- tdm_log_set_debug_level(2);
- tdm_log_set_path("/tmp/tdm.log");
- tdm_log_print(TDM_LOG_LEVEL_ERR, "utest\n");
- tdm_log_print(TDM_LOG_LEVEL_WRN, "utest\n");
- tdm_log_print(TDM_LOG_LEVEL_INFO, "utest\n");
- tdm_log_print(TDM_LOG_LEVEL_DBG, "utest\n");
- tdm_log_set_path(NULL);
-}
-
-TEST(TDMLog, logSetPath)
-{
- tdm_log_enable_dlog(0);
- tdm_log_set_path("/tmp/tdm.log");
- tdm_log_print(TDM_LOG_LEVEL_ERR, "hello\n");
- tdm_log_set_path(NULL);
-}
-
-TEST(TDMLog, logDlogNone)
-{
- tdm_log_enable_color(0);
- tdm_log_enable_dlog(1);
- tdm_log_set_debug_level(0);
- tdm_log_print(TDM_LOG_LEVEL_ERR, "utest");
- tdm_log_print(TDM_LOG_LEVEL_WRN, "utest");
- tdm_log_print(TDM_LOG_LEVEL_INFO, "utest");
- tdm_log_print(TDM_LOG_LEVEL_DBG, "utest");
-}
-
-TEST(TDMLog, logDlog)
-{
- tdm_log_enable_dlog(1);
- tdm_log_print(TDM_LOG_LEVEL_ERR, "utest");
- tdm_log_print(TDM_LOG_LEVEL_WRN, "utest");
- tdm_log_print(TDM_LOG_LEVEL_INFO, "utest");
- tdm_log_print(TDM_LOG_LEVEL_DBG, "utest");
-}
-
-TEST(TDMLog, logDlogNormal)
-{
- tdm_log_enable_dlog(1);
- tdm_log_print(TDM_LOG_LEVEL_ERR, "utest");
- tdm_log_print(TDM_LOG_LEVEL_WRN, "utest");
- tdm_log_print(TDM_LOG_LEVEL_INFO, "utest");
- tdm_log_print(TDM_LOG_LEVEL_DBG, "utest");
-}
-
-TEST(TDMLog, logDlogUnknownLevel)
-{
- tdm_log_enable_dlog(1);
- tdm_log_print(TDM_UT_INVALID_VALUE, "utest");
-}
-
-/* LCOV_EXCL_END */
\ No newline at end of file
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
- *
- * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
- * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
- * Contact: Roman Marchenko <r.marchenko@samsung.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
-**************************************************************************/
-
-#include "ut_tdm.h"
-
-/* LCOV_EXCL_START */
-
-int tdm_debug_module;
-
-int main(int argc, char **argv)
-{
- auto AllTestSuccess = false;
-
-#ifdef TIZEN_TEST_GCOV
- setenv("GCOV_PREFIX", "/tmp", 1);
-#endif
-
- try {
- ::testing::InitGoogleTest(&argc, argv);
- ::testing::FLAGS_gtest_death_test_style = "fast";
- } catch ( ... ) {
- std::cout << "error while trying to init google tests.\n";
- exit(EXIT_FAILURE);
- }
-
- try {
- AllTestSuccess = RUN_ALL_TESTS() == 0 ? true : false;
- } catch (const ::testing::internal::GoogleTestFailureException & e) {
- AllTestSuccess = false;
- std::cout << "GoogleTestFailureException was thrown:" << e.what() << std::endl;
- std::cout << "\n";
- }
-
-#ifdef TIZEN_TEST_GCOV
- __gcov_flush();
-#endif
-
- return AllTestSuccess;
-}
-
-/* LCOV_EXCL_END */
\ No newline at end of file
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
- *
- * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
- * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
- * Contact: Roman Marchenko <r.marchenko@samsung.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
-**************************************************************************/
-
-#include "ut_tdm.h"
-
-/* LCOV_EXCL_START */
-
-static void _ut_tdm_output_change_cb(tdm_output *output, tdm_output_change_type type, tdm_value value, void *user_data);
-static void _ut_tdm_output_change_cb2(tdm_output *output, tdm_output_change_type type, tdm_value value, void *user_data);
-
-TDMOutput::TDMOutput()
-{
- has_outputs = false;
- output_count = TDM_UT_INVALID_VALUE;
- outputs = NULL;
-
- done1 = done2 = done3 = false;
-}
-
-void TDMOutput::SetUp(void)
-{
- TDMDisplay::SetUp();
-
- ASSERT_EQ(tdm_display_get_output_count(dpy, &output_count), TDM_ERROR_NONE);
- ASSERT_GE(output_count, 0);
-
- if (output_count > 0) {
- outputs = (tdm_output**)calloc(output_count, sizeof(tdm_output*));
- ASSERT_NE(outputs, NULL);
-
- for (int o = 0; o < output_count; o++) {
- tdm_error ret;
- tdm_output *output = tdm_display_get_output(dpy, o, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(output, NULL);
- outputs[o] = output;
- }
- has_outputs = true;
- } else {
- has_outputs = false;
- }
-}
-
-void TDMOutput::TearDown(void)
-{
- if (outputs) {
- for (int o = 0; o < output_count; o++) {
- ASSERT_EQ(ut_tdm_output_unset(dpy, outputs[o]), true);
- tdm_output_remove_change_handler(outputs[o], _ut_tdm_output_change_cb, &done1);
- tdm_output_remove_change_handler(outputs[o], _ut_tdm_output_change_cb, &done2);
- tdm_output_remove_change_handler(outputs[o], _ut_tdm_output_change_cb, &done3);
- tdm_output_remove_change_handler(outputs[o], _ut_tdm_output_change_cb, NULL);
- }
- free(outputs);
- }
-
- TDMDisplay::TearDown();
-}
-
-bool
-ut_tdm_output_mode_setting(tdm_output *output)
-{
- const tdm_output_mode *modes = (const tdm_output_mode *)TDM_UT_INVALID_VALUE;
- const tdm_output_mode *found = NULL;
- const tdm_output_mode *best = NULL;
- int count = TDM_UT_INVALID_VALUE;
- unsigned int pipe = 0;
-
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_available_modes(output, &modes, &count) == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(count > 0);
- TDM_UT_RETURN_FALSE_IF_FAIL(modes != NULL && modes != (const tdm_output_mode *)TDM_UT_INVALID_VALUE);
-
- for (int i = 0; i < count; i++) {
- if (!best)
- best = &modes[i];
- if (modes[i].type & TDM_OUTPUT_MODE_TYPE_PREFERRED)
- found = &modes[i];
- }
- if (!found && best)
- found = best;
-
- TDM_UT_RETURN_FALSE_IF_FAIL(found != NULL);
-
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_set_mode(output, found) == TDM_ERROR_NONE);
-
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_pipe(output, &pipe) == TDM_ERROR_NONE);
-
- TDM_INFO("setting output(%d) mode done: %dx%d %d", pipe, found->hdisplay, found->vdisplay, found->vrefresh);
-
- return true;
-}
-
-bool
-ut_tdm_output_is_async_dpms_enable(tdm_output *output)
-{
- tdm_output_capability capabilities = (tdm_output_capability)TDM_UT_INVALID_VALUE;
- if (tdm_output_get_capabilities(output, &capabilities) != TDM_ERROR_NONE)
- return false;
- return capabilities & TDM_OUTPUT_CAPABILITY_ASYNC_DPMS;
-}
-
-bool
-ut_tdm_output_is_hwc_enable(tdm_output *output)
-{
- tdm_output_capability capabilities = (tdm_output_capability)TDM_UT_INVALID_VALUE;
- if (tdm_output_get_capabilities(output, &capabilities) != TDM_ERROR_NONE)
- return false;
- return capabilities & TDM_OUTPUT_CAPABILITY_HWC;
-}
-
-bool
-ut_tdm_output_is_aod_enable(tdm_output *output)
-{
- tdm_output_capability capabilities = (tdm_output_capability)TDM_UT_INVALID_VALUE;
- if (tdm_output_get_capabilities(output, &capabilities) != TDM_ERROR_NONE)
- return false;
- return capabilities & TDM_OUTPUT_CAPABILITY_EXTENDED_DPMS;
-}
-
-bool
-ut_tdm_output_is_connected(tdm_output *output)
-{
- tdm_output_conn_status status;
- if (tdm_output_get_conn_status(output, &status) != TDM_ERROR_NONE)
- return false;
- return (status != TDM_OUTPUT_CONN_STATUS_DISCONNECTED) ? true : false;
-}
-
-tdm_layer *
-ut_tdm_output_get_primary_layer(tdm_output *output)
-{
- tdm_error ret;
- tdm_layer *layer;
- int primary_index = -1;
-
- TDM_UT_RETURN_VAL_IF_FAIL(tdm_output_get_primary_index(output, &primary_index) == TDM_ERROR_NONE, NULL);
- TDM_UT_RETURN_VAL_IF_FAIL(primary_index >= 0, NULL);
-
- layer = tdm_output_get_layer(output, primary_index, &ret);
- TDM_UT_RETURN_VAL_IF_FAIL(ret == TDM_ERROR_NONE, NULL);
- TDM_UT_RETURN_VAL_IF_FAIL(layer != NULL, NULL);
-
- return layer;
-}
-
-static void
-_ut_tdm_output_done_cb(tdm_output *output, unsigned int sequence,
- unsigned int tv_sec, unsigned int tv_usec,
- void *user_data)
-{
- bool *done = (bool*)user_data;
- if (done)
- *done = true;
-}
-
-bool
-ut_tdm_output_prepare(tdm_display *dpy, tdm_output *output, bool fill)
-{
- tbm_surface_h buffer = NULL;
- tdm_error ret;
- int primary_index = -1;
- tdm_layer *layer;
- bool done = false;
- tdm_output_conn_status status;
-
- TDM_UT_RETURN_FALSE_IF_FAIL(ut_tdm_output_is_connected(output) == true);
- TDM_UT_RETURN_FALSE_IF_FAIL(ut_tdm_output_mode_setting(output) == true);
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON) == TDM_ERROR_NONE);
-
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_primary_index(output, &primary_index) == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(primary_index >= 0);
-
- layer = tdm_output_get_layer(output, primary_index, &ret);
- TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(layer != NULL);
-
- TDM_UT_RETURN_FALSE_IF_FAIL(ut_tdm_layer_prepare_buffer(layer, &buffer, 1, fill) == true);
- TDM_UT_RETURN_FALSE_IF_FAIL(buffer != NULL);
-
- TDM_UT_GOTO_IF_FAIL(ut_tdm_layer_set_buffer(layer, buffer) == true, failed);
-
- if (tdm_helper_output_commit_per_vblank_enabled(output))
- TDM_UT_GOTO_IF_FAIL(tdm_layer_commit(layer, NULL, NULL) == TDM_ERROR_NONE, failed);
- else
- TDM_UT_GOTO_IF_FAIL(tdm_output_commit(output, 0, NULL, NULL) == TDM_ERROR_NONE, failed);
-
- TDM_UT_GOTO_IF_FAIL(tdm_output_get_conn_status(output, &status) == TDM_ERROR_NONE, failed);
- TDM_UT_GOTO_IF_FAIL(status == TDM_OUTPUT_CONN_STATUS_MODE_SETTED, failed);
-
- while (!done) {
- TDM_UT_GOTO_IF_FAIL(tdm_output_wait_vblank(output, 1, 0, _ut_tdm_output_done_cb, &done) == TDM_ERROR_NONE, failed);
- TDM_UT_GOTO_IF_FAIL(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE, failed);
- }
-
- tbm_surface_internal_unref(buffer);
-
- return true;
-failed:
- tbm_surface_internal_unref(buffer);
-
- return false;
-}
-
-bool
-ut_tdm_output_prepare_all_output(tdm_display *dpy, tdm_output **outputs, int output_count, bool fill)
-{
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
- if (!ut_tdm_output_prepare(dpy, outputs[o], fill))
- return false;
- }
- return true;
-}
-
-bool
-ut_tdm_output_unset(tdm_display *dpy, tdm_output *output)
-{
- tdm_error ret;
- int count = 0;
- unsigned int pipe = 0;
-
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_layer_count(output, &count) == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(count > 0);
-
- for (int l = 0; l < count; l++) {
- tdm_layer *layer = tdm_output_get_layer(output, l, &ret);
- TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(layer != NULL);
-
- if (ut_tdm_layer_is_cursor_layer(layer))
- continue;
- if (ut_tdm_layer_is_video_layer(layer))
- continue;
-
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_unset_buffer(layer) == TDM_ERROR_NONE);
- }
-
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_pipe(output, &pipe) == TDM_ERROR_NONE);
-
- TDM_INFO("unsetting output(%d) done", pipe);
-
- return true;
-}
-
-/* msec */
-double
-ut_tdm_output_get_vblank_interval_time(tdm_output *output)
-{
- const tdm_output_mode *mode = (const tdm_output_mode *)TDM_UT_INVALID_VALUE;
- tdm_error ret = tdm_output_get_mode(output, &mode);
-
- assert(ret == TDM_ERROR_NONE);
- assert(mode != NULL);
- assert(mode->vrefresh > 0);
-
- return (double)1.0 / (double)mode->vrefresh;
-}
-
-TEST_P(TDMOutput, OutputGetBackendModule)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- tdm_error ret = (tdm_error)TDM_UT_INVALID_VALUE;
- ASSERT_NE(tdm_output_get_backend_module(outputs[o], &ret), NULL);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- }
-}
-
-TEST_P(TDMOutput, OutputGetBackendModuleNullOBject)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- tdm_error ret = (tdm_error)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_output_get_backend_module(NULL, &ret), NULL);
- ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMOutput, OutputGetBackendModuleNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- ASSERT_NE(tdm_output_get_backend_module(outputs[o], NULL), NULL);
- }
-}
-
-TEST_P(TDMOutput, OutputGetCapabilities)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- tdm_output_capability capabilities = (tdm_output_capability)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_output_get_capabilities(outputs[o], &capabilities), TDM_ERROR_NONE);
- ASSERT_NE(capabilities, TDM_UT_INVALID_VALUE);
- }
-}
-
-TEST_P(TDMOutput, OutputGetCapabilitiesNullObject)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- tdm_output_capability capabilities = (tdm_output_capability)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_output_get_capabilities(NULL, &capabilities), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(capabilities, (tdm_output_capability)TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMOutput, OutputGetCapabilitiesNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(tdm_output_get_capabilities(outputs[0], NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMOutput, OutputGetModelInfo)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- const char *maker = NULL, *model = NULL, *name = NULL;
- ASSERT_EQ(tdm_output_get_model_info(outputs[o], &maker, &model, &name), TDM_ERROR_NONE);
- ASSERT_NE(maker, NULL);
- ASSERT_NE(model, NULL);
- ASSERT_NE(name, NULL);
- }
-}
-
-TEST_P(TDMOutput, OutputGetModelInfoNullObject)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- const char *maker = (const char*)TDM_UT_INVALID_VALUE;
- const char *model = (const char*)TDM_UT_INVALID_VALUE;
- const char *name = (const char*)TDM_UT_INVALID_VALUE;
-
- ASSERT_EQ(tdm_output_get_model_info(NULL, &maker, &model, &name), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(maker, (const char*)TDM_UT_INVALID_VALUE);
- ASSERT_EQ(model, (const char*)TDM_UT_INVALID_VALUE);
- ASSERT_EQ(name, (const char*)TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMOutput, OutputGetModelInfoNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(tdm_output_get_model_info(outputs[0], NULL, NULL, NULL), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMOutput, OutputGetConnStatus)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- tdm_output_conn_status status = (tdm_output_conn_status)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_output_get_conn_status(outputs[o], &status), TDM_ERROR_NONE);
- ASSERT_NE(status, TDM_UT_INVALID_VALUE);
- }
-}
-
-TEST_P(TDMOutput, OutputGetConnStatusNullObject)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- tdm_output_conn_status status = (tdm_output_conn_status)TDM_UT_INVALID_VALUE;
-
- ASSERT_EQ(tdm_output_get_conn_status(NULL, &status), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(status, (tdm_output_conn_status)TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMOutput, OutputGetConnStatusNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(tdm_output_get_conn_status(outputs[0], NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMOutput, OutputGetOutputType)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- tdm_output_type type = (tdm_output_type)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_output_get_output_type(outputs[o], &type), TDM_ERROR_NONE);
- ASSERT_NE(type, TDM_UT_INVALID_VALUE);
- }
-}
-
-TEST_P(TDMOutput, OutputGetOutputTypeNullObject)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- tdm_output_type type = (tdm_output_type)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_output_get_output_type(NULL, &type), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(type, (tdm_output_type)TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMOutput, OutputGetOutputTypeNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(tdm_output_get_output_type(outputs[0], NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMOutput, OutputGetLayerCount)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- int count = TDM_UT_INVALID_VALUE;
- if (ut_tdm_output_is_hwc_enable(outputs[o])) {
- ASSERT_EQ(tdm_output_get_layer_count(outputs[o], &count), TDM_ERROR_BAD_REQUEST);
- ASSERT_EQ(count, 0);
- } else {
- ASSERT_EQ(tdm_output_get_layer_count(outputs[o], &count), TDM_ERROR_NONE);
- ASSERT_GT(count, 0);
- }
- }
-}
-
-TEST_P(TDMOutput, OutputGetLayerCountNullObject)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- int count = TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_output_get_layer_count(NULL, &count), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(count, TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMOutput, OutputGetLayerCountNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(tdm_output_get_layer_count(outputs[0], NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMOutput, OutputGetLayer)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- tdm_error ret;
- tdm_layer *layer;
- int layer_count = TDM_UT_INVALID_VALUE;
-
- if (ut_tdm_output_is_hwc_enable(outputs[o])) {
- ASSERT_EQ(tdm_output_get_layer_count(outputs[o], &layer_count), TDM_ERROR_BAD_REQUEST);
- ASSERT_EQ(layer_count, 0);
-
- layer = tdm_output_get_layer(outputs[o], 0, &ret);
- ASSERT_EQ(ret, TDM_ERROR_BAD_REQUEST);
- ASSERT_EQ(layer, NULL);
- } else {
- ASSERT_EQ(tdm_output_get_layer_count(outputs[o], &layer_count), TDM_ERROR_NONE);
- ASSERT_GT(layer_count, 0);
-
- for (int l = 0; l < layer_count; l++) {
- tdm_layer *layer = tdm_output_get_layer(outputs[o], l, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(layer, NULL);
- }
- }
- }
-}
-
-TEST_P(TDMOutput, OutputGetLayerNullObject)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- tdm_error ret;
- tdm_layer *layer = tdm_output_get_layer(NULL, 0, &ret);
- ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(layer, NULL);
-}
-
-TEST_P(TDMOutput, OutputGetLayerNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- tdm_layer *layer;
- if (ut_tdm_output_is_hwc_enable(outputs[0])) {
- layer = tdm_output_get_layer(outputs[0], 0, NULL);
- ASSERT_EQ(layer, NULL);
- } else {
- layer = tdm_output_get_layer(outputs[0], 0, NULL);
- ASSERT_NE(layer, NULL);
- }
-}
-
-TEST_P(TDMOutput, OutputGetAvailableProperties)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- int count = TDM_UT_INVALID_VALUE;
- const tdm_prop *props = (const tdm_prop *)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_output_get_available_properties(outputs[o], &props, &count), TDM_ERROR_NONE);
- ASSERT_GE(count, 0);
- if (count > 0)
- ASSERT_TRUE(props != NULL && props != (const tdm_prop *)TDM_UT_INVALID_VALUE);
- }
-}
-
-TEST_P(TDMOutput, OutputGetAvailablePropertiesNullObject)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- const tdm_prop *props = (const tdm_prop *)TDM_UT_INVALID_VALUE;
- int count = TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_output_get_available_properties(NULL, &props, &count), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(props, (const tdm_prop *)TDM_UT_INVALID_VALUE);
- ASSERT_EQ(count, TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMOutput, OutputGetAvailablePropertiesNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(tdm_output_get_available_properties(outputs[0], NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMOutput, OutputGetAvailableModes)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- int count = TDM_UT_INVALID_VALUE;
- const tdm_output_mode *modes_array = (const tdm_output_mode *) TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_output_get_available_modes(outputs[o], &modes_array, &count), TDM_ERROR_NONE);
- ASSERT_GT(count, 0);
- ASSERT_TRUE(modes_array != NULL && modes_array != (const tdm_output_mode *)TDM_UT_INVALID_VALUE);
- }
-}
-
-TEST_P(TDMOutput, OutputGetAvailableModesNullObject)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- int count = TDM_UT_INVALID_VALUE;
- const tdm_output_mode *modes_array = (const tdm_output_mode *) TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_output_get_available_modes(NULL, &modes_array, &count), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(count, TDM_UT_INVALID_VALUE);
- ASSERT_EQ(modes_array, (const tdm_output_mode *) TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMOutput, OutputGetAvailableModesNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(tdm_output_get_available_modes(outputs[0], NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMOutput, OutputGetAvailableSize)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- int min_w = TDM_UT_INVALID_VALUE, min_h = TDM_UT_INVALID_VALUE;
- int max_w = TDM_UT_INVALID_VALUE, max_h = TDM_UT_INVALID_VALUE;
- int preferred_align = TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_output_get_available_size(outputs[o], &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_NONE);
- ASSERT_NE(min_w, TDM_UT_INVALID_VALUE);
- ASSERT_NE(min_h, TDM_UT_INVALID_VALUE);
- ASSERT_NE(max_w, TDM_UT_INVALID_VALUE);
- ASSERT_NE(max_h, TDM_UT_INVALID_VALUE);
- ASSERT_NE(preferred_align, TDM_UT_INVALID_VALUE);
- }
-}
-
-TEST_P(TDMOutput, OutputGetAvailableSizeNullObject)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- int min_w = TDM_UT_INVALID_VALUE, min_h = TDM_UT_INVALID_VALUE;
- int max_w = TDM_UT_INVALID_VALUE, max_h = TDM_UT_INVALID_VALUE;
- int preferred_align = TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_output_get_available_size(NULL, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(min_w, TDM_UT_INVALID_VALUE);
- ASSERT_EQ(min_h, TDM_UT_INVALID_VALUE);
- ASSERT_EQ(max_w, TDM_UT_INVALID_VALUE);
- ASSERT_EQ(max_h, TDM_UT_INVALID_VALUE);
- ASSERT_EQ(preferred_align, TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMOutput, OutputGetAvailableSizeNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(tdm_output_get_available_size(outputs[0], NULL, NULL, NULL, NULL, NULL), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMOutput, OutputGetCursorAvailableSize)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- int major = TDM_UT_INVALID_VALUE;
- int minor = TDM_UT_INVALID_VALUE;
-
- ASSERT_EQ(tdm_display_get_backend_info(dpy, NULL, NULL, &major, &minor), TDM_ERROR_NONE);
- if (major > 1 || (major >= 1 && minor >= 5)) {
- for (int o = 0; o < output_count; o++) {
- int min_w = TDM_UT_INVALID_VALUE, min_h = TDM_UT_INVALID_VALUE;
- int max_w = TDM_UT_INVALID_VALUE, max_h = TDM_UT_INVALID_VALUE;
- int preferred_align = TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_output_get_cursor_available_size(outputs[o], &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_NONE);
- ASSERT_NE(min_w, TDM_UT_INVALID_VALUE);
- ASSERT_NE(min_h, TDM_UT_INVALID_VALUE);
- ASSERT_NE(max_w, TDM_UT_INVALID_VALUE);
- ASSERT_NE(max_h, TDM_UT_INVALID_VALUE);
- ASSERT_NE(preferred_align, TDM_UT_INVALID_VALUE);
- }
- }
-}
-
-TEST_P(TDMOutput, OutputGetCursorAvailableSizeNullObject)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- int major = TDM_UT_INVALID_VALUE;
- int minor = TDM_UT_INVALID_VALUE;
-
- ASSERT_EQ(tdm_display_get_backend_info(dpy, NULL, NULL, &major, &minor), TDM_ERROR_NONE);
- if (major > 1 || (major >= 1 && minor >= 5)) {
- for (int o = 0; o < output_count; o++) {
- int min_w = TDM_UT_INVALID_VALUE, min_h = TDM_UT_INVALID_VALUE;
- int max_w = TDM_UT_INVALID_VALUE, max_h = TDM_UT_INVALID_VALUE;
- int preferred_align = TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_output_get_cursor_available_size(NULL, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(min_w, TDM_UT_INVALID_VALUE);
- ASSERT_EQ(min_h, TDM_UT_INVALID_VALUE);
- ASSERT_EQ(max_w, TDM_UT_INVALID_VALUE);
- ASSERT_EQ(max_h, TDM_UT_INVALID_VALUE);
- ASSERT_EQ(preferred_align, TDM_UT_INVALID_VALUE);
- }
- }
-}
-
-TEST_P(TDMOutput, OutputGetCursorAvailableSizeNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- int major = TDM_UT_INVALID_VALUE;
- int minor = TDM_UT_INVALID_VALUE;
-
- ASSERT_EQ(tdm_display_get_backend_info(dpy, NULL, NULL, &major, &minor), TDM_ERROR_NONE);
- if (major > 1 || (major >= 1 && minor >= 5))
- ASSERT_EQ(tdm_output_get_cursor_available_size(outputs[0], NULL, NULL, NULL, NULL, NULL), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMOutput, OutputGetCursorAvailableSizeNoMatchVersion)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- int major = TDM_UT_INVALID_VALUE;
- int minor = TDM_UT_INVALID_VALUE;
-
- ASSERT_EQ(tdm_display_get_backend_info(dpy, NULL, NULL, &major, &minor), TDM_ERROR_NONE);
- if (major <= 1 && minor < 5) {
- for (int o = 0; o < output_count; o++) {
- int min_w = TDM_UT_INVALID_VALUE, min_h = TDM_UT_INVALID_VALUE;
- int max_w = TDM_UT_INVALID_VALUE, max_h = TDM_UT_INVALID_VALUE;
- int preferred_align = TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_output_get_cursor_available_size(outputs[o], &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_BAD_REQUEST);
- ASSERT_EQ(min_w, TDM_UT_INVALID_VALUE);
- ASSERT_EQ(min_h, TDM_UT_INVALID_VALUE);
- ASSERT_EQ(max_w, TDM_UT_INVALID_VALUE);
- ASSERT_EQ(max_h, TDM_UT_INVALID_VALUE);
- ASSERT_EQ(preferred_align, TDM_UT_INVALID_VALUE);
- }
- }
-}
-
-TEST_P(TDMOutput, OutputGetPhysicalSize)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- unsigned int mmWidth = (unsigned int)TDM_UT_INVALID_VALUE;
- unsigned int mmHeight = (unsigned int)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_output_get_physical_size(outputs[o], &mmWidth, &mmHeight), TDM_ERROR_NONE);
- ASSERT_NE(mmWidth, (unsigned int)TDM_UT_INVALID_VALUE);
- ASSERT_NE(mmHeight, (unsigned int)TDM_UT_INVALID_VALUE);
- }
-}
-
-TEST_P(TDMOutput, OutputGetPhysicalSizeNullObject)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- unsigned int mmWidth = (unsigned int)TDM_UT_INVALID_VALUE;
- unsigned int mmHeight = (unsigned int)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_output_get_physical_size(NULL, &mmWidth, &mmHeight), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(mmWidth, (unsigned int)TDM_UT_INVALID_VALUE);
- ASSERT_EQ(mmHeight, (unsigned int)TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMOutput, OutputGetPhysicalSizeNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(tdm_output_get_physical_size(outputs[0], NULL, NULL), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMOutput, OutputGetSubpixel)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- unsigned int subpixel = (unsigned int)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_output_get_subpixel(outputs[o], &subpixel), TDM_ERROR_NONE);
- ASSERT_NE(subpixel, (unsigned int)TDM_UT_INVALID_VALUE);
- }
-}
-
-TEST_P(TDMOutput, OutputGetSubpixelNullObject)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- unsigned int subpixel = (unsigned int)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_output_get_subpixel(NULL, &subpixel), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(subpixel, (unsigned int)TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMOutput, OutputGetSubpixelNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(tdm_output_get_subpixel(outputs[0], NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMOutput, OutputGetPipe)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- unsigned int pipe = (unsigned int)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_output_get_pipe(outputs[o], &pipe), TDM_ERROR_NONE);
- ASSERT_NE(pipe, (unsigned int)TDM_UT_INVALID_VALUE);
- }
-}
-
-TEST_P(TDMOutput, OutputGetPipeNullObject)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- unsigned int pipe = (unsigned int)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_output_get_pipe(NULL, &pipe), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(pipe, (unsigned int)TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMOutput, OutputGetPipeNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(tdm_output_get_pipe(outputs[0], NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMOutput, OutputGetPrimaryIndex)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- int primary_index = TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_output_get_primary_index(outputs[o], &primary_index), TDM_ERROR_NONE);
- ASSERT_NE(primary_index, TDM_UT_INVALID_VALUE);
- }
-}
-
-TEST_P(TDMOutput, OutputGetPrimaryIndexNullObject)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- int primary_index = TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_output_get_primary_index(NULL, &primary_index), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(primary_index, TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMOutput, OutputGetPrimaryIndexNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(tdm_output_get_primary_index(outputs[0], NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMOutput, DISABLED_OutputSetProperty)
-{
-}
-
-TEST_P(TDMOutput, OutputSetPropertyNullObject)
-{
- tdm_value value = {.s32 = 0};
-
- ASSERT_EQ(tdm_output_set_property(NULL, 0, value), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMOutput, OutputGetProperty)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- int count = TDM_UT_INVALID_VALUE;
- const tdm_prop *props = (const tdm_prop *)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_output_get_available_properties(outputs[o], &props, &count), TDM_ERROR_NONE);
- ASSERT_GE(count, 0);
- if (count > 0) {
- ASSERT_TRUE(props != NULL && props != (const tdm_prop *)TDM_UT_INVALID_VALUE);
-
- for (int i = 0; i < count; i++) {
- tdm_value value = {.s32 = TDM_UT_INVALID_VALUE};
- ASSERT_EQ(tdm_output_get_property(outputs[o], props[i].id, &value), TDM_ERROR_NONE);
- ASSERT_NE(value.s32, TDM_UT_INVALID_VALUE);
- }
- }
- }
-}
-
-TEST_P(TDMOutput, OutputGetPropertyNullObject)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- tdm_value value = {.s32 = TDM_UT_INVALID_VALUE};
- ASSERT_EQ(tdm_output_get_property(NULL, 0, &value), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(value.s32, TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMOutput, OutputGetPropertyNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(tdm_output_get_property(outputs[0], 0, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-static void
-_ut_tdm_output_change_cb(tdm_output *output, tdm_output_change_type type, tdm_value value, void *user_data)
-{
- bool *done = (bool *)user_data;
- if (done)
- *done = true;
-}
-
-TEST_P(TDMOutput, OutputAddChangeHandler)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_prepare(dpy, outputs[o], true), true);
-
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
-
- done1 = false;
- ASSERT_EQ(tdm_output_add_change_handler(outputs[o], _ut_tdm_output_change_cb, &done1), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
- ASSERT_EQ(done1, true);
- }
-}
-
-TEST_P(TDMOutput, OutputAddChangeHandlerTwice)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(tdm_output_add_change_handler(outputs[0], _ut_tdm_output_change_cb, NULL), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_add_change_handler(outputs[0], _ut_tdm_output_change_cb, NULL), TDM_ERROR_BAD_REQUEST);
-}
-
-TEST_P(TDMOutput, OutputAddChangeHandlerNullObject)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(tdm_output_add_change_handler(NULL, _ut_tdm_output_change_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMOutput, OutputAddChangeHandlerNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(tdm_output_add_change_handler(outputs[0], NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMOutput, OutputRemoveChangeHandler)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- for (int t = 0; t < 10; t++) {
- ASSERT_EQ(tdm_output_add_change_handler(outputs[o], _ut_tdm_output_change_cb, NULL), TDM_ERROR_NONE);
- tdm_output_remove_change_handler(outputs[o], _ut_tdm_output_change_cb, NULL);
- }
- }
-}
-
-TEST_P(TDMOutput, OutputRemoveChangeHandlerDifferentData)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
-
- done1 = false;
- ASSERT_EQ(tdm_output_add_change_handler(outputs[o], _ut_tdm_output_change_cb, &done1), TDM_ERROR_NONE);
- tdm_output_remove_change_handler(outputs[o], _ut_tdm_output_change_cb, NULL);
-
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
- ASSERT_EQ(done1, true);
- }
-}
-
-static void
-_ut_tdm_output_change_cb2(tdm_output *output, tdm_output_change_type type, tdm_value value, void *user_data)
-{
- bool *done = (bool*)user_data;
- if (done)
- *done = true;
- tdm_output_remove_change_handler(output, _ut_tdm_output_change_cb2, user_data);
-}
-
-TEST_P(TDMOutput, OutputRemoveChangeHandlerInHandler)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
-
- done1 = false;
- ASSERT_EQ(tdm_output_add_change_handler(outputs[o], _ut_tdm_output_change_cb2, &done1), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
- ASSERT_EQ(done1, true);
-
- done2 = false;
- ASSERT_EQ(tdm_output_add_change_handler(outputs[o], _ut_tdm_output_change_cb, &done2), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
- ASSERT_EQ(done2, true);
-
- done3 = false;
- ASSERT_EQ(tdm_output_add_change_handler(outputs[o], _ut_tdm_output_change_cb2, &done3), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
- ASSERT_EQ(done3, true);
- }
-}
-
-TEST_P(TDMOutput, OutputRemoveChangeHandlerNullObject)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- tdm_output_remove_change_handler(NULL, _ut_tdm_output_change_cb, NULL);
-}
-
-TEST_P(TDMOutput, OutputRemoveChangeHandlerNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- tdm_output_remove_change_handler(outputs[0], NULL, NULL);
-}
-
-TEST_P(TDMOutput, OutputSetMode)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- const tdm_output_mode *modes;
- int count;
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(tdm_output_get_available_modes(outputs[o], &modes, &count), TDM_ERROR_NONE);
- ASSERT_NE(modes, NULL);
- ASSERT_GT(count, 0);
-
- for (int m = 0; m < count; m++)
- ASSERT_EQ(tdm_output_set_mode(outputs[o], modes + m), TDM_ERROR_NONE);
- }
-}
-
-TEST_P(TDMOutput, OutputSetModeNullObject)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- const tdm_output_mode *mode = (const tdm_output_mode *)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_output_set_mode(NULL, mode), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMOutput, OutputSetModeNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(tdm_output_set_mode(outputs[o], NULL), TDM_ERROR_INVALID_PARAMETER);
- }
-}
-
-TEST_P(TDMOutput, OutputGetMode)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- const tdm_output_mode *modes;
- int count;
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(tdm_output_get_available_modes(outputs[o], &modes, &count), TDM_ERROR_NONE);
- ASSERT_NE(modes, NULL);
- ASSERT_GT(count, 0);
-
- for (int m = 0; m < count; m++) {
- const tdm_output_mode *current_mode;
- ASSERT_EQ(tdm_output_set_mode(outputs[o], modes + m), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_get_mode(outputs[o], ¤t_mode), TDM_ERROR_NONE);
- ASSERT_EQ(current_mode, modes + m);
- }
- }
-}
-
-TEST_P(TDMOutput, OutputGetModeNullObject)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- const tdm_output_mode *current_mode = (const tdm_output_mode *)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_output_get_mode(NULL, ¤t_mode), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(current_mode, (const tdm_output_mode *)TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMOutput, OutputGetModeNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(tdm_output_get_mode(outputs[0], NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMOutput, OutputGetModeNoSet)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- const tdm_output_mode *mode;
- ASSERT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE);
- ASSERT_EQ(mode, NULL);
- }
-}
-
-TEST_P(TDMOutput, OutputSetDpms)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_STANDBY), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_SUSPEND), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
- if (ut_tdm_output_is_aod_enable(outputs[o])) {
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_AOD), TDM_ERROR_NONE);
- } else {
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_AOD), TDM_ERROR_BAD_REQUEST);
- }
- }
-}
-
-TEST_P(TDMOutput, OutputSetDpmsNullObject)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(tdm_output_set_dpms(NULL, TDM_OUTPUT_DPMS_OFF), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMOutput, OutputSetDpmsNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(tdm_output_set_dpms(outputs[0], (tdm_output_dpms)-1), TDM_ERROR_BAD_REQUEST);
- ASSERT_EQ(tdm_output_set_dpms(outputs[0], (tdm_output_dpms)INT_MAX), TDM_ERROR_BAD_REQUEST);
-}
-
-TEST_P(TDMOutput, OutputSetDpmsAsync)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
- if (!ut_tdm_output_is_async_dpms_enable(outputs[o]))
- continue;
-
- done1 = false;
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_add_change_handler(outputs[o], _ut_tdm_output_change_cb, &done1), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_set_dpms_async(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
- while (!done1)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- tdm_output_remove_change_handler(outputs[o], _ut_tdm_output_change_cb, &done1);
- }
-}
-
-TEST_P(TDMOutput, OutputGetDpms)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- tdm_output_dpms dpms_value;
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_get_dpms(outputs[o], &dpms_value), TDM_ERROR_NONE);
- ASSERT_EQ(dpms_value, TDM_OUTPUT_DPMS_OFF);
-
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_STANDBY), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_get_dpms(outputs[o], &dpms_value), TDM_ERROR_NONE);
- ASSERT_EQ(dpms_value, TDM_OUTPUT_DPMS_STANDBY);
-
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_SUSPEND), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_get_dpms(outputs[o], &dpms_value), TDM_ERROR_NONE);
- ASSERT_EQ(dpms_value, TDM_OUTPUT_DPMS_SUSPEND);
-
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_get_dpms(outputs[o], &dpms_value), TDM_ERROR_NONE);
- ASSERT_EQ(dpms_value, TDM_OUTPUT_DPMS_ON);
-
- if (ut_tdm_output_is_aod_enable(outputs[o])) {
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_AOD), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_get_dpms(outputs[o], &dpms_value), TDM_ERROR_NONE);
- ASSERT_EQ(dpms_value, TDM_OUTPUT_DPMS_AOD);
- } else {
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_AOD), TDM_ERROR_BAD_REQUEST);
- }
- }
-}
-
-TEST_P(TDMOutput, OutputGetDpmsNullObject)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- tdm_output_dpms dpms_value = (tdm_output_dpms)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_output_get_dpms(NULL, &dpms_value), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(dpms_value, (tdm_output_dpms)TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMOutput, OutputGetDpmsNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(tdm_output_get_dpms(outputs[0], NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMOutput, OutputWaitVblank)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_prepare(dpy, outputs[o], true), true);
-
- for (int t = 0; t < 10; t++) {
- double start, end, interval;
-
- interval = ut_tdm_output_get_vblank_interval_time(outputs[o]);
-
- done1 = false;
- start = tdm_helper_get_time();
- ASSERT_EQ(tdm_output_wait_vblank(outputs[o], 1, 0, _ut_tdm_output_done_cb, &done1), TDM_ERROR_NONE);
- while (!done1)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- end = tdm_helper_get_time();
-
- /* "+ interval" consider the delay of socket communication between kernel and platform */
- ASSERT_LT((end - start), (interval + interval));
- }
- }
-}
-
-TEST_P(TDMOutput, OutputWaitVblankNullObject)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(tdm_output_wait_vblank(NULL, 1, 0, _ut_tdm_output_done_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMOutput, OutputWaitVblankNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_prepare(dpy, outputs[o], true), true);
-
- ASSERT_EQ(tdm_output_wait_vblank(outputs[o], 1, 0, NULL, NULL), TDM_ERROR_NONE);
- }
-}
-
-TEST_P(TDMOutput, OutputWaitVblankTimeout)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_prepare(dpy, outputs[o], true), true);
-
- ASSERT_EQ(tdm_output_wait_vblank(outputs[o], 1, 0, _ut_tdm_output_done_cb, NULL), TDM_ERROR_NONE);
-
- usleep(1100000);
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
-
- ASSERT_GT(tdm_helper_output_vblank_timer_expired(outputs[o]), 0);
- }
-}
-
-TEST_P(TDMOutput, OutputWaitVblankInterval0)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(tdm_output_wait_vblank(outputs[0], 0, 0, _ut_tdm_output_done_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMOutput, OutputWaitVblankInterval)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_prepare(dpy, outputs[o], true), true);
-
- /* start from 1 */
- for (int t = 1; t < 10; t++) {
- double start, end, interval;
-
- interval = ut_tdm_output_get_vblank_interval_time(outputs[o]);
-
- done1 = false;
- start = tdm_helper_get_time();
- ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_output_done_cb, &done1), TDM_ERROR_NONE);
- while (!done1)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- end = tdm_helper_get_time();
-
- /* "+ interval" consider the delay of socket communication between kernel and platform */
- ASSERT_GT((end - start), (interval * (t - 1)));
- ASSERT_LT((end - start), (interval * t + interval));
- }
- }
-}
-
-TEST_P(TDMOutput, OutputWaitVblankFewTimesInOneVblank)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_prepare(dpy, outputs[o], true), true);
-
- /* start from 1 */
- for (int t = 1; t < 10; t++) {
- double start, end, interval;
-
- interval = ut_tdm_output_get_vblank_interval_time(outputs[o]);
-
- done1 = done2 = done3 = false;
- ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_output_done_cb, &done1), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_output_done_cb, &done2), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_output_done_cb, &done3), TDM_ERROR_NONE);
-
- start = tdm_helper_get_time();
- while (!done1 || !done2 || !done3)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- end = tdm_helper_get_time();
-
- /* "+ interval" consider the delay of socket communication between kernel and platform */
- ASSERT_GT((end - start), (interval * (t - 1)));
- ASSERT_LT((end - start), (interval * t + interval));
- }
- }
-}
-
-TEST_P(TDMOutput, OutputWaitVblankBeforeDpmsOff)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_prepare(dpy, outputs[o], false), true);
-
- for (int t = 0; t < 10; t++) {
- bool done = false;
-
- ASSERT_EQ(tdm_output_wait_vblank(outputs[o], 1, 0, _ut_tdm_output_done_cb, &done), TDM_ERROR_NONE);
- if (t == 9)
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
- while (!done)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- }
- }
-}
-
-TEST_P(TDMOutput, OutputRemoveVblankHandler)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_prepare(dpy, outputs[o], true), true);
-
- /* start from 1 */
- for (int t = 1; t < 10; t++) {
- done1 = done2 = done3 = false;
- ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_output_done_cb, &done1), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_output_done_cb, &done2), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_output_done_cb, &done3), TDM_ERROR_NONE);
- tdm_output_remove_vblank_handler(outputs[o], _ut_tdm_output_done_cb, &done2);
- while (!done1 || done2 || !done3)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- }
- }
-}
-
-TEST_P(TDMOutput, OutputRemoveVblankHandlerDifferentData)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ut_tdm_output_prepare(dpy, outputs[o], true);
-
- /* start from 1 */
- for (int t = 1; t < 10; t++) {
- done1 = done2 = done3 = false;
- ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_output_done_cb, &done1), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_output_done_cb, &done2), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_output_done_cb, &done3), TDM_ERROR_NONE);
- tdm_output_remove_vblank_handler(outputs[o], _ut_tdm_output_done_cb, NULL);
- while (!done1 || !done2 || !done3)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- }
- }
-}
-
-static void
-_ut_tdm_output_done_cb2(tdm_output *output, unsigned int sequence,
- unsigned int tv_sec, unsigned int tv_usec,
- void *user_data)
-{
- bool *done = (bool*)user_data;
- if (done)
- *done = true;
- tdm_output_remove_commit_handler(output, _ut_tdm_output_done_cb2, user_data);
-}
-
-TEST_P(TDMOutput, OutputRemoveVblankHandlerInHandler)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_prepare(dpy, outputs[o], true), true);
-
- /* start from 1 */
- for (int t = 1; t < 10; t++) {
- done1 = done2 = done3 = false;
- ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_output_done_cb, &done1), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_output_done_cb, &done2), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_output_done_cb, &done3), TDM_ERROR_NONE);
- while (!done1 || !done2 || !done3)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- }
- }
-}
-
-TEST_P(TDMOutput, OutputCommit)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- /* if true, have to use tdm_layer_commit. so skip */
- if (tdm_helper_output_commit_per_vblank_enabled(outputs[o]))
- continue;
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_prepare(dpy, outputs[o], true), true);
-
- for (int t = 0; t < 10; t++) {
- double start, end, interval;
-
- interval = ut_tdm_output_get_vblank_interval_time(outputs[o]);
-
- done1 = false;
- start = tdm_helper_get_time();
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, _ut_tdm_output_done_cb, &done1), TDM_ERROR_NONE);
- while (!done1)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- end = tdm_helper_get_time();
-
- /* "+ interval" consider the delay of socket communication between kernel and platform */
- ASSERT_LT((end - start), (interval + interval));
- }
- }
-}
-
-TEST_P(TDMOutput, OutputCommitNullObject)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(tdm_output_commit(NULL, 0, _ut_tdm_output_done_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMOutput, OutputCommitNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- /* if true, have to use tdm_layer_commit. so skip */
- if (tdm_helper_output_commit_per_vblank_enabled(outputs[o]))
- continue;
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
- }
-}
-
-TEST_P(TDMOutput, OutputCommitDpmsSuspend)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- /* if true, have to use tdm_layer_commit. so skip */
- if (tdm_helper_output_commit_per_vblank_enabled(outputs[o]))
- continue;
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_prepare(dpy, outputs[o], true), true);
-
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_SUSPEND), TDM_ERROR_NONE);
-
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, _ut_tdm_output_done_cb, NULL), TDM_ERROR_DPMS_OFF);
- }
-}
-
-TEST_P(TDMOutput, OutputCommitDpmsOff)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- /* if true, have to use tdm_layer_commit. so skip */
- if (tdm_helper_output_commit_per_vblank_enabled(outputs[o]))
- continue;
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_prepare(dpy, outputs[o], true), true);
-
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
-
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, _ut_tdm_output_done_cb, NULL), TDM_ERROR_DPMS_OFF);
- }
-}
-
-TEST_P(TDMOutput, OutputCommitDpmsAOD)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- /* if true, have to use tdm_layer_commit. so skip */
- if (tdm_helper_output_commit_per_vblank_enabled(outputs[o]))
- continue;
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- if (!ut_tdm_output_is_aod_enable(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_prepare(dpy, outputs[o], true), true);
-
- ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_AOD), TDM_ERROR_NONE);
-
- for (int t = 0; t < 10; t++) {
- done1 = false;
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, _ut_tdm_output_done_cb, &done1), TDM_ERROR_NONE);
- while (!done1)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- }
- }
-}
-
-TEST_P(TDMOutput, OutputCommitAfterLayerCommit)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- int index = TDM_UT_INVALID_VALUE;
- tdm_layer *layer;
- tdm_error ret;
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_prepare(dpy, outputs[o], true), true);
-
- ASSERT_EQ(tdm_output_get_primary_index(outputs[o], &index), TDM_ERROR_NONE);
- ASSERT_NE(index, TDM_UT_INVALID_VALUE);
-
- layer = tdm_output_get_layer(outputs[o], index, &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(layer, NULL);
-
- ASSERT_EQ(tdm_layer_commit(layer, NULL, NULL), TDM_ERROR_NONE);
-
- if (!tdm_helper_output_commit_per_vblank_enabled(outputs[o]))
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
- else
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_BAD_REQUEST);
- }
-}
-
-TEST_P(TDMOutput, OutputCommitMismatchCommitType)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- if (!tdm_helper_output_commit_per_vblank_enabled(outputs[o]))
- continue;
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_BAD_REQUEST);
- }
-}
-
-TEST_P(TDMOutput, OutputCommitFewTimesInOneVblank)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- /* if true, have to use tdm_layer_commit. so skip */
- if (tdm_helper_output_commit_per_vblank_enabled(outputs[o]))
- continue;
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_prepare(dpy, outputs[o], true), true);
-
- for (int t = 0; t < 10; t++) {
- done1 = done2 = done3 = false;
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, _ut_tdm_output_done_cb, &done1), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, _ut_tdm_output_done_cb, &done2), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, _ut_tdm_output_done_cb, &done3), TDM_ERROR_NONE);
- while (!done1 || !done2 || !done3)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- }
- }
-}
-
-//TODO
-TEST_P(TDMOutput, DISABLED_OutputCommitBeforeDpmsOff)
-{
- /* output commit -> dpms off -> then? (commit handler is called? or not?) */
-}
-
-TEST_P(TDMOutput, OutputRemoveCommitHandler)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- /* if true, have to use tdm_layer_commit. so skip */
- if (tdm_helper_output_commit_per_vblank_enabled(outputs[o]))
- continue;
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_prepare(dpy, outputs[o], true), true);
-
- for (int t = 0; t < 10; t++) {
- done1 = done2 = done3 = false;
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, _ut_tdm_output_done_cb, &done1), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, _ut_tdm_output_done_cb, &done2), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, _ut_tdm_output_done_cb, &done3), TDM_ERROR_NONE);
- tdm_output_remove_commit_handler(outputs[o], _ut_tdm_output_done_cb, &done2);
- while (!done1 || done2 || !done3)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- }
- }
-}
-
-TEST_P(TDMOutput, OutputRemoveCommitHandlerDifferentData)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- /* if true, have to use tdm_layer_commit. so skip */
- if (tdm_helper_output_commit_per_vblank_enabled(outputs[o]))
- continue;
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_prepare(dpy, outputs[o], true), true);
-
- for (int t = 0; t < 10; t++) {
- done1 = done2 = done3 = false;
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, _ut_tdm_output_done_cb, &done1), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, _ut_tdm_output_done_cb, &done2), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, _ut_tdm_output_done_cb, &done3), TDM_ERROR_NONE);
- tdm_output_remove_commit_handler(outputs[o], _ut_tdm_output_done_cb, NULL);
- while (!done1 || !done2 || !done3)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- }
- }
-}
-
-TEST_P(TDMOutput, OutputRemoveCommitHandlerInHandler)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- /* if true, have to use tdm_layer_commit. so skip */
- if (tdm_helper_output_commit_per_vblank_enabled(outputs[o]))
- continue;
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_EQ(ut_tdm_output_prepare(dpy, outputs[o], true), true);
-
- for (int t = 0; t < 10; t++) {
- done1 = done2 = done3 = false;
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, _ut_tdm_output_done_cb2, &done1), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, _ut_tdm_output_done_cb2, &done2), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_output_commit(outputs[o], 0, _ut_tdm_output_done_cb2, &done3), TDM_ERROR_NONE);
- while (!done1 || !done2 || !done3)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- }
- }
-}
-
-#ifdef TDM_UT_TEST_WITH_PARAMS
-INSTANTIATE_TEST_CASE_P(TDMOutputParams,
- TDMOutput,
- Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
-#else
-INSTANTIATE_TEST_CASE_P(TDMOutputParams,
- TDMOutput,
- Values(TDM_DEFAULT_MODULE));
-#endif
-
-/* LCOV_EXCL_END */
\ No newline at end of file
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
- *
- * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
- * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
- * Contact: Roman Marchenko <r.marchenko@samsung.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
-**************************************************************************/
-
-#include "ut_tdm.h"
-
-/* LCOV_EXCL_START */
-
-class TDMOutputHwc : public TDMOutput
-{
-public:
- TDMOutputHwc();
- void SetUp(void);
- void TearDown(void);
-
- tdm_error error;
-};
-
-TDMOutputHwc::TDMOutputHwc()
-{
- error = TDM_ERROR_NONE;
-}
-
-void TDMOutputHwc::SetUp(void)
-{
- TDMOutput::SetUp();
-}
-
-void TDMOutputHwc::TearDown(void)
-{
- TDMOutput::TearDown();
-}
-
-/* tdm_hwc_window * tdm_hwc_create_window(tdm_output *output, tdm_error *error); */
-TEST_P(TDMOutputHwc, CreateWindowFailNull)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(NULL, tdm_hwc_create_window(NULL, &error));
- ASSERT_NE(TDM_ERROR_NONE, error);
-}
-
-/*
-TEST_P(TDMOutputHwc, CreateWindowSuccessful)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- tdm_hwc_window * hw = NULL;
-
- for (int o = 0; o < output_count; o++) {
- if (ut_tdm_output_is_hwc_enable(outputs[o])) {
- hw = tdm_hwc_create_window(hwc[o], &error);
- ASSERT_EQ(TDM_ERROR_NONE, error);
- tdm_hwc_window_destroy(hw);
- } else {
- ASSERT_EQ(NULL, tdm_hwc_create_window(outputs[o], &error));
- ASSERT_NE(TDM_ERROR_NONE, error);
- }
- }
-}
-*/
-
-/* tdm_error tdm_hwc_set_client_target_buffer(tdm_output *output,
- tbm_surface_h target_buffer, tdm_region damage,
- tdm_hwc_window *composited_wnds, uint32_t num_wnds); */
-/* TDOO: need to be fixed
-TEST_P(TDMOutputHwc, SetClientTargetBufferFailNullOutput)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- tdm_region reg;
- tbm_surface_h target_buff = CreateBufferForOutput(0);
- error = tdm_hwc_set_client_target_buffer(NULL, target_buff, reg, NULL, 0 );
- tbm_surface_internal_destroy(target_buff);
- ASSERT_NE(TDM_ERROR_NONE, error);
-}
-
-TEST_P(TDMOutputHwc, SetClientTargetBufferFailNoHwc)
-{
- tdm_region damage = {.num_rects = 0, .rects = NULL};
-
- for (int o = 0; o < output_count; o++) {
- tbm_surface_h target_buff = CreateBufferForOutput(i);
- ASSERT_NE(NULL, target_buff);
- error = tdm_hwc_set_client_target_buffer(outputs[o], target_buff, damage, NULL, 0);
- tbm_surface_internal_destroy(target_buff);
- ASSERT_NE(TDM_ERROR_NONE, error);
- }
-}
-
-TEST_P(TDMOutputHwc, SetClientTargetBufferSuccessfulSetBuff)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- tdm_region damage = {.num_rects = 0, .rects = NULL};
-
- for (int o = 0; o < output_count; o++) {
- tbm_surface_h target_buff = CreateBufferForOutput(i);
- ASSERT_NE(NULL, target_buff);
- if (ut_tdm_output_is_hwc_enable(outputs[o])) {
- error = tdm_hwc_set_client_target_buffer(outputs[o], target_buff, damage,
- NULL, 0);
- tbm_surface_internal_destroy(target_buff);
- ASSERT_EQ(TDM_ERROR_NONE, error);
- } else {
- error = tdm_hwc_set_client_target_buffer(outputs[o], target_buff, damage,
- NULL, 0);
- tbm_surface_internal_destroy(target_buff);
- ASSERT_NE(TDM_ERROR_NONE, error);
- }
- }
-}
-
-TEST_P(TDMOutputHwc, SetClientTargetBufferSuccessfulResetBuff)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- tdm_region damage = {.num_rects = 0, .rects = NULL};
-
- for (int o = 0; o < output_count; o++) {
- if (ut_tdm_output_is_hwc_enable(outputs[o])) {
- error = tdm_hwc_set_client_target_buffer(outputs[o], NULL, damage,
- NULL, 0);
- ASSERT_EQ(TDM_ERROR_NONE, error);
- } else {
- error = tdm_hwc_set_client_target_buffer(outputs[o], NULL, damage,
- NULL, 0);
- ASSERT_NE(TDM_ERROR_NONE, error);
- }
- }
-}
-*/
-
-/* tbm_surface_queue_h tdm_hwc_get_client_target_buffer_queue(tdm_output *output, tdm_error *error); */
-/*
-TEST_P(TDMOutputHwc, GetTargetBufferQueueFailNullObject)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- tbm_surface_queue_h queue = NULL;
-
- queue = tdm_hwc_get_client_target_buffer_queue(NULL, &error);
- ASSERT_NE(TDM_ERROR_NONE, error);
- ASSERT_EQ(NULL, queue);
-
- queue = tdm_hwc_get_client_target_buffer_queue(NULL, NULL);
- ASSERT_EQ(NULL, queue);
-}
-
-TEST_P(TDMOutputHwc, GetTargetBufferQueueFainNoHwc)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- tbm_surface_queue_h queue = NULL;
-
- for (int o = 0; o < output_count; o++) {
- queue = tdm_hwc_get_client_target_buffer_queue(outputs[o], &error);
- ASSERT_NE(TDM_ERROR_NONE, error);
- ASSERT_EQ(NULL, queue);
- }
-}
-*/
-
-TEST_P(TDMOutputHwc, GetTargetBufferQueueSuccessful)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- tbm_surface_queue_h queue = NULL;
-
- for (int o = 0; o < output_count; o++) {
- if (ut_tdm_output_is_hwc_enable(outputs[o])) {
- queue = tdm_hwc_get_client_target_buffer_queue(outputs[o], &error);
- tbm_surface_queue_destroy(queue);
- ASSERT_EQ(TDM_ERROR_NONE, error);
- ASSERT_NE(NULL, queue);
-
- queue = tdm_hwc_get_client_target_buffer_queue(outputs[o], NULL);
- tbm_surface_queue_destroy(queue);
- ASSERT_EQ(TDM_ERROR_NONE, error);
- ASSERT_NE(NULL, queue);
- } else {
- queue = tdm_hwc_get_client_target_buffer_queue(outputs[o], &error);
- ASSERT_NE(TDM_ERROR_NONE, error);
- ASSERT_EQ(NULL, queue);
-
- queue = tdm_hwc_get_client_target_buffer_queue(outputs[o], NULL);
- ASSERT_NE(TDM_ERROR_NONE, error);
- ASSERT_EQ(NULL, queue);
- }
- }
-}
-
-/* tdm_error tdm_hwc_validate(tdm_output *output, tdm_hwc_window **composited_wnds, uint32_t num_wnds,
- uint32_t *num_types); */
-/* TODO: fix the validate test later.
-TEST_P(TDMOutputHwc, ValidateFailNull)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- uint32_t num_types;
- error = tdm_hwc_validate(NULL, NULL, 0, &num_types);
- ASSERT_NE(TDM_ERROR_NONE, error);
-
- if (outputs[0]) {
- error = tdm_hwc_validate(outputs[0], NULL, 0, NULL);
- ASSERT_NE(TDM_ERROR_NONE, error);
- }
-}
-
-TEST_P(TDMOutputHwc, ValidateFailNoHwc)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- uint32_t num_types;
-
- for (int o = 0; o < output_count; o++) {
- error = tdm_hwc_validate(outputs[o], &num_types);
- ASSERT_NE(TDM_ERROR_NONE, error);
- }
-}
-
-TEST_P(TDMOutputHwc, ValidateSuccessful)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- uint32_t num_types;
- for (int o = 0; o < output_count; o++) {
- if (ut_tdm_output_is_hwc_enable(outputs[o])) {
- error = tdm_hwc_validate(outputs[o], &num_types);
- ASSERT_EQ(TDM_ERROR_NONE, error);
- } else {
- error = tdm_hwc_validate(outputs[o], &num_types);
- ASSERT_NE(TDM_ERROR_NONE, error);
- }
- }
-}
-TODO: */
-
-/* tdm_error tdm_hwc_get_changed_composition_types(tdm_hwc *hwc,
- uint32_t *num_elements, tdm_hwc_window **hwc_window,
- tdm_hwc_window_composition *composition_types); */
-/*
-TEST_P(TDMOutputHwc, GetChangedCompositionTypesFailNull)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- uint32_t num_elements;
-
- error = tdm_hwc_get_changed_composition_types(NULL, &num_elements, NULL, NULL);
- ASSERT_NE(TDM_ERROR_NONE, error);
-
- if (outputs[0]) {
- error = tdm_hwc_get_changed_composition_types(outputs[0], NULL, NULL, NULL);
- ASSERT_NE(TDM_ERROR_NONE, error);
- }
-}
-
-TEST_P(TDMOutputHwc, GetChangedCompositionTypesFailNoHwc)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- uint32_t get_num = 10;
-
- for (int o = 0; o < output_count; o++) {
- error = tdm_hwc_get_changed_composition_types(outputs[o], &get_num, NULL, NULL);
- ASSERT_NE(TDM_ERROR_NONE, error);
- }
-}
-*/
-/* TODO: fix the validate test later.
-TEST_P(TDMHwcWindow, GetChangedCompositionTypesSuccessful)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- uint32_t validate_num;
- uint32_t get_num = 0;
-
- tdm_hwc_window_composition *composition_types;
- tdm_hwc_window **hwc_wnds;
-
- for (int i = 0; i < hwc_count; i++) {
- error = tdm_hwc_window_set_composition_type(hwc_wins[o], TDM_COMPOSITION_DEVICE);
- ASSERT_EQ(TDM_ERROR_NONE, error);
- }
-
-
- for (int i = 0; i < output_count; i++) {
- if (ut_tdm_output_is_hwc_enable(outputs[o])) {
- error = tdm_hwc_validate(outputs[o], &validate_num);
- ASSERT_EQ(TDM_ERROR_NONE, error);
-
- error = tdm_hwc_get_changed_composition_types(outputs[o], &get_num, NULL, NULL);
- ASSERT_EQ(TDM_ERROR_NONE, error);
-
- ASSERT_EQ(get_num, validate_num);
- hwc_wnds = (tdm_hwc_window **)calloc(get_num, sizeof(tdm_hwc_window *));
- composition_types = (tdm_hwc_window_composition *)calloc(get_num, sizeof(tdm_hwc_window_composition));
-
- error = tdm_hwc_get_changed_composition_types(outputs[o], &get_num, hwc_wnds, composition_types);
-
- free(hwc_wnds);
- free(composition_types);
-
- ASSERT_EQ(TDM_ERROR_NONE, error);
- } else {
- error = tdm_hwc_get_changed_composition_types(outputs[o], &get_num, NULL, NULL);
- ASSERT_NE(TDM_ERROR_NONE, error);
- }
- }
-}
-*/
-
-/* tdm_error tdm_hwc_accept_changes(tdm_hwc *hwc); */
-/*
-TEST_P(TDMOutputHwc, AcceptChangesFailNull)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- error = tdm_hwc_accept_changes(NULL);
- ASSERT_NE(TDM_ERROR_NONE, error);
-}
-
-TEST_P(TDMOutputHwc, AcceptChangesFailNoHwc)
-{
- for (int o = 0; o < output_count; o++) {
- error = tdm_hwc_accept_changes(outputs[o]);
- ASSERT_NE(TDM_ERROR_NONE, error);
- }
-}
-*/
-/* TODO: fix the validate test later.
-TEST_P(TDMHwcWindow, AcceptChangesSuccessful)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- uint32_t validate_num;
-
- for (int i = 0; i < hwc_count; i++) {
- error = tdm_hwc_window_set_composition_type(hwc_wins[o], TDM_COMPOSITION_DEVICE);
- ASSERT_EQ(TDM_ERROR_NONE, error);
- }
-
- for (int i = 0; i < output_count; i++) {
- if (ut_tdm_output_is_hwc_enable(outputs[o])) {
- error = tdm_hwc_validate(outputs[o], &validate_num);
- ASSERT_EQ(TDM_ERROR_NONE, error);
-
- if (validate_num > 0) {
- error = tdm_hwc_accept_changes(outputs[o]);
- ASSERT_EQ(TDM_ERROR_NONE, error);
- }
- }
- }
-}
-*/
-
-/* tdm_hwc_get_supported_formats() */
-/*
-TEST_P(TDMOutputHwc, GetVideoSupportedFormatsFailNull)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- tdm_error error;
-
- error = tdm_hwc_get_supported_formats(NULL, NULL, NULL);
- ASSERT_NE(TDM_ERROR_NONE, error);
-}
-
-TEST_P(TDMOutputHwc, GetVideoSupportedFormatsSuccessful)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- tdm_error error;
- const tbm_format *formats;
- int count;
-
- for (int o = 0; o < output_count; o++) {
- if (ut_tdm_output_is_hwc_enable(outputs[o])) {
- error = tdm_hwc_get_supported_formats(outputs[o], &formats, &count);
- if (error != TDM_ERROR_NOT_IMPLEMENTED) {
- ASSERT_EQ(TDM_ERROR_NONE, error);
- if (count > 0)
- ASSERT_NE(NULL, formats);
- }
- } else {
- error = tdm_hwc_get_supported_formats(outputs[o], &formats, &count);
- ASSERT_NE(TDM_ERROR_NONE, error);
- }
- }
-}
-*/
-
-#ifdef TDM_UT_TEST_WITH_PARAMS
-INSTANTIATE_TEST_CASE_P(TDMOutputHwcParams,
- TDMOutputHwc,
- Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
-#else
-INSTANTIATE_TEST_CASE_P(TDMOutputHwcParams,
- TDMOutputHwc,
- Values(TDM_DEFAULT_MODULE));
-#endif
-
-/* LCOV_EXCL_END */
\ No newline at end of file
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
- *
- * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
- * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
- * Contact: Roman Marchenko <r.marchenko@samsung.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
-**************************************************************************/
-
-#include "ut_tdm.h"
-
-/* LCOV_EXCL_START */
-
-static void _ut_tdm_vblank_create_cb(tdm_vblank *vblank, void *user_data);
-static void _ut_tdm_vblank_create_cb2(tdm_vblank *vblank, void *user_data);
-
-class TDMVblank : public TDMOutput
-{
-public:
- bool has_vblanks;
-
- tdm_vblank **vblanks;
- int vblank_count;
-
- bool done;
-
- TDMVblank();
- void SetUp(void);
- void TearDown(void);
-
- bool TestCreateVblanks(void);
- bool TestCreateVblanks3(void);
- void TestDestroyVblanks(void);
-
- bool TestPrepareOutput(void);
-};
-
-TDMVblank::TDMVblank()
-{
- has_vblanks = false;
- vblanks = NULL;
- vblank_count = 0;
- done = false;
-}
-
-void TDMVblank::SetUp(void)
-{
- TDMOutput::SetUp();
-}
-
-void TDMVblank::TearDown(void)
-{
- tdm_vblank_remove_create_handler(dpy, _ut_tdm_vblank_create_cb, this);
- tdm_vblank_remove_create_handler(dpy, _ut_tdm_vblank_create_cb, NULL);
- tdm_vblank_remove_create_handler(dpy, _ut_tdm_vblank_create_cb2, this);
- tdm_vblank_remove_create_handler(dpy, _ut_tdm_vblank_create_cb2, NULL);
-
- TestDestroyVblanks();
-
- tdm_vblank_enable_global_fps(0, 0);
-
- TDMOutput::TearDown();
-}
-
-bool TDMVblank::TestCreateVblanks(void)
-{
- TDM_UT_GOTO_IF_FAIL(output_count > 0, failed);
-
- vblanks = (tdm_vblank**)calloc(output_count, sizeof(tdm_vblank*));
- TDM_UT_GOTO_IF_FAIL(vblanks != NULL, failed);
-
- vblank_count = output_count;
- has_vblanks = true;
-
- for (int v = 0; v < vblank_count; v++) {
- tdm_error ret;
- vblanks[v] = tdm_vblank_create(dpy, outputs[v], &ret);
- TDM_UT_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, failed);
- TDM_UT_GOTO_IF_FAIL(vblanks[v] != NULL, failed);
- }
-
- return true;
-failed:
- TestDestroyVblanks();
- has_vblanks = false;
- return false;
-}
-
-bool TDMVblank::TestCreateVblanks3(void)
-{
- TDM_UT_GOTO_IF_FAIL(output_count > 0, failed);
-
- tdm_error ret;
-
- vblank_count = 0;
-
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- vblank_count = 3;
- has_vblanks = true;
-
- vblanks = (tdm_vblank**)calloc(vblank_count, sizeof(tdm_vblank*));
- TDM_UT_GOTO_IF_FAIL(vblanks != NULL, failed);
-
- for (int v = 0; v < vblank_count; v++) {
- vblanks[v] = tdm_vblank_create(dpy, outputs[o], &ret);
- TDM_UT_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, failed);
- TDM_UT_GOTO_IF_FAIL(vblanks[v] != NULL, failed);
- }
-
- break;
- }
-
- return true;
-failed:
- TestDestroyVblanks();
- has_vblanks = false;
- return false;
-}
-
-void TDMVblank::TestDestroyVblanks(void)
-{
- if (vblanks) {
- for (int v = 0; v < vblank_count; v++)
- tdm_vblank_destroy(vblanks[v]);
- free(vblanks);
- vblanks = NULL;
- }
- vblank_count = 0;
-
-}
-
-bool TDMVblank::TestPrepareOutput(void)
-{
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- TDM_UT_RETURN_FALSE_IF_FAIL(ut_tdm_output_prepare(dpy, outputs[o], false) == true);
- }
-
- return true;
-}
-
-bool ut_tdm_vblank_is_avaiable(tdm_vblank *vblank)
-{
- tdm_error ret;
- tdm_output *output = tdm_vblank_get_output(vblank, &ret);
- TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(output != NULL);
-
- /* only check if connected */
- return ut_tdm_output_is_connected(output);
-}
-
-/* tdm_vblank_set_client_vblank_fps */
-TEST_P(TDMVblank, DISABLED_VblankSetClientVblankFps)
-{
- /* tested in ut_tdm_client.c */
-}
-
-TEST_P(TDMVblank, VblankSetClientVblankFpsNullObject)
-{
- ASSERT_EQ(tdm_vblank_set_client_vblank_fps(0, NULL, 60), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(tdm_vblank_set_client_vblank_fps(123, NULL, 0), TDM_ERROR_INVALID_PARAMETER);
-}
-
-/* tdm_vblank_set_client_vblank_fps */
-TEST_P(TDMVblank, DISABLED_VblankSetClientIgnoreGlobalFps)
-{
- /* tested in ut_tdm_client.c */
-}
-
-TEST_P(TDMVblank, VblankSetClientIgnoreGlobalFpsNullObject)
-{
- ASSERT_EQ(tdm_vblank_set_client_ignore_global_fps(0, NULL, 0), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(tdm_vblank_set_client_ignore_global_fps(0, NULL, 1), TDM_ERROR_INVALID_PARAMETER);
-}
-
-/* tdm_vblank_create() */
-TEST_P(TDMVblank, VblankCreateDestroy)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- for (int o = 0; o < output_count; o++) {
- tdm_error ret;
- tdm_vblank *vblank = tdm_vblank_create(dpy, outputs[o], &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(vblank, NULL);
-
- tdm_vblank_destroy(vblank);
- }
-}
-
-TEST_P(TDMVblank, VblankCreateNullDpy)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- tdm_error ret;
-
- tdm_vblank *vblank = tdm_vblank_create(NULL, outputs[0], &ret);
- ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(vblank, NULL);
-}
-
-TEST_P(TDMVblank, VblankCreateNullOutput)
-{
- tdm_error ret;
-
- tdm_vblank *vblank = tdm_vblank_create(dpy, NULL, &ret);
- ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(vblank, NULL);
-}
-
-TEST_P(TDMVblank, VblankCreateNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- tdm_vblank *vblank = tdm_vblank_create(dpy, outputs[0], NULL);
- ASSERT_NE(vblank, NULL);
-
- tdm_vblank_destroy(vblank);
-}
-
-/* tdm_vblank_destroy() */
-TEST_P(TDMVblank, VblankDestroyNullObject)
-{
- tdm_vblank_destroy(NULL);
-}
-
-static void
-_ut_tdm_vblank_create_cb(tdm_vblank *vblank, void *user_data)
-{
- TDMVblank *test_vblank = (TDMVblank*)user_data;
- if (test_vblank)
- test_vblank->done = true;
-}
-
-/* tdm_vblank_add_create_handler */
-TEST_P(TDMVblank, VblankAddCreateHandler)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(tdm_vblank_add_create_handler(dpy, _ut_tdm_vblank_create_cb, this), TDM_ERROR_NONE);
-
- for (int o = 0; o < output_count; o++) {
- tdm_error ret;
-
- done = false;
-
- tdm_vblank *vblank = tdm_vblank_create(dpy, outputs[o], &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(vblank, NULL);
- ASSERT_EQ(done, true);
-
- tdm_vblank_destroy(vblank);
- }
-}
-
-TEST_P(TDMVblank, VblankAddCreateHandlerTwice)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(tdm_vblank_add_create_handler(dpy, _ut_tdm_vblank_create_cb, NULL), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_vblank_add_create_handler(dpy, _ut_tdm_vblank_create_cb, NULL), TDM_ERROR_BAD_REQUEST);
-}
-
-TEST_P(TDMVblank, VblankAddCreateHandlerNullObject)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(tdm_vblank_add_create_handler(NULL, _ut_tdm_vblank_create_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMVblank, VblankAddCreateHandlerNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(tdm_vblank_add_create_handler(dpy, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-/* tdm_vblank_remove_create_handler */
-TEST_P(TDMVblank, VblankRemoveCreateHandler)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(tdm_vblank_add_create_handler(dpy, _ut_tdm_vblank_create_cb, this), TDM_ERROR_NONE);
- tdm_vblank_remove_create_handler(dpy, _ut_tdm_vblank_create_cb, this);
-
- for (int o = 0; o < output_count; o++) {
- tdm_error ret;
-
- done = false;
-
- tdm_vblank *vblank = tdm_vblank_create(dpy, outputs[o], &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(vblank, NULL);
- ASSERT_EQ(done, false);
-
- tdm_vblank_destroy(vblank);
- }
-}
-
-TEST_P(TDMVblank, VblankRemoveCreateHandlerFewTimes)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(tdm_vblank_add_create_handler(dpy, _ut_tdm_vblank_create_cb, this), TDM_ERROR_NONE);
-
- tdm_vblank_remove_create_handler(dpy, _ut_tdm_vblank_create_cb, this);
- tdm_vblank_remove_create_handler(dpy, _ut_tdm_vblank_create_cb, this);
- tdm_vblank_remove_create_handler(dpy, _ut_tdm_vblank_create_cb, this);
-
- for (int o = 0; o < output_count; o++) {
- tdm_error ret;
-
- done = false;
-
- tdm_vblank *vblank = tdm_vblank_create(dpy, outputs[o], &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(vblank, NULL);
- ASSERT_EQ(done, false);
-
- tdm_vblank_destroy(vblank);
- }
-}
-
-TEST_P(TDMVblank, VblankRemoveCreateHandlerDifferentData)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(tdm_vblank_add_create_handler(dpy, _ut_tdm_vblank_create_cb, this), TDM_ERROR_NONE);
-
- tdm_vblank_remove_create_handler(dpy, _ut_tdm_vblank_create_cb, NULL);
-
- for (int o = 0; o < output_count; o++) {
- tdm_error ret;
-
- done = false;
-
- tdm_vblank *vblank = tdm_vblank_create(dpy, outputs[o], &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(vblank, NULL);
- ASSERT_EQ(done, true);
-
- tdm_vblank_destroy(vblank);
- }
-}
-
-static void
-_ut_tdm_vblank_create_cb2(tdm_vblank *vblank, void *user_data)
-{
- TDMVblank *test_vblank = (TDMVblank*)user_data;
- test_vblank->done = true;
- tdm_vblank_remove_create_handler(test_vblank->dpy, _ut_tdm_vblank_create_cb2, user_data);
-}
-
-TEST_P(TDMVblank, VblankRemoveCreateHandlerInHandler)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(tdm_vblank_add_create_handler(dpy, _ut_tdm_vblank_create_cb2, this), TDM_ERROR_NONE);
-
- for (int o = 0; o < output_count; o++) {
- tdm_error ret;
-
- done = false;
-
- tdm_vblank *vblank = tdm_vblank_create(dpy, outputs[o], &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- ASSERT_NE(vblank, NULL);
- if (o == 0)
- ASSERT_EQ(done, true);
- else
- ASSERT_EQ(done, false);
-
- tdm_vblank_destroy(vblank);
- }
-}
-
-TEST_P(TDMVblank, VblankRemoveCreateHandlerNullObject)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- tdm_vblank_remove_create_handler(NULL, _ut_tdm_vblank_create_cb, NULL);
-}
-
-TEST_P(TDMVblank, VblankRemoveCreateHandlerNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- tdm_vblank_remove_create_handler(dpy, NULL, NULL);
-}
-
-/* tdm_vblank_get_output() */
-TEST_P(TDMVblank, VblankGetOutput)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++) {
- tdm_error ret;
- ASSERT_NE(tdm_vblank_get_output(vblanks[v], &ret), NULL);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
- }
-}
-
-TEST_P(TDMVblank, VblankGetOutputNullObject)
-{
- tdm_error ret;
- ASSERT_EQ(tdm_vblank_get_output(NULL, &ret), NULL);
- ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMVblank, VblankGetOutputNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestCreateVblanks(), true);
-
- ASSERT_NE(tdm_vblank_get_output(vblanks[0], NULL), NULL);
-}
-
-/* tdm_vblank_get_client_pid() */
-TEST_P(TDMVblank, VblankGetClientPid)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++) {
- pid_t pid = (pid_t)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_vblank_get_client_pid(vblanks[v], &pid), TDM_ERROR_NONE);
- /* client pid should be 0 in case vblank is created in server side */
- ASSERT_EQ(pid, 0);
- }
-}
-
-TEST_P(TDMVblank, VblankGetClientPidNullObject)
-{
- pid_t pid = (pid_t)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_vblank_get_client_pid(NULL, &pid), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(pid, (pid_t)TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMVblank, VblankGetClientPidNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestCreateVblanks(), true);
-
- ASSERT_EQ(tdm_vblank_get_client_pid(vblanks[0], NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-/* tdm_vblank_set_name() */
-TEST_P(TDMVblank, VblankSetName)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++)
- ASSERT_EQ(tdm_vblank_set_name(vblanks[v], TDM_UT_VBLANK_NAME), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMVblank, VblankSetNameNullObject)
-{
- ASSERT_EQ(tdm_vblank_set_name(NULL, TDM_UT_VBLANK_NAME), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMVblank, VblankSetNameNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++)
- ASSERT_EQ(tdm_vblank_set_name(vblanks[v], NULL), TDM_ERROR_NONE);
-}
-
-/* tdm_vblank_get_name() */
-TEST_P(TDMVblank, VblankGetName)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++) {
- const char *name = (const char *)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_vblank_set_name(vblanks[v], TDM_UT_VBLANK_NAME), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_vblank_get_name(vblanks[v], &name), TDM_ERROR_NONE);
- ASSERT_STREQ(name, TDM_UT_VBLANK_NAME);
- }
-}
-
-TEST_P(TDMVblank, VblankGetNameNullObject)
-{
- const char *name = (const char *)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_vblank_get_name(NULL, &name), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(name, (const char *)TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMVblank, VblankGetNameNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestCreateVblanks(), true);
-
- ASSERT_EQ(tdm_vblank_get_name(vblanks[0], NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMVblank, VblankGetNameNoSet)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++) {
- const char *name = (const char *)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_vblank_get_name(vblanks[v], &name), TDM_ERROR_NONE);
- ASSERT_STREQ(name, TDM_VBLANK_DEFAULT_NAME);
- }
-}
-
-/* tdm_vblank_set_fps() */
-TEST_P(TDMVblank, VblankSetFps)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++)
- ASSERT_EQ(tdm_vblank_set_fps(vblanks[v], 60), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMVblank, VblankSetFpsNullObject)
-{
- ASSERT_EQ(tdm_vblank_set_fps(NULL, 60), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMVblank, VblankSetFpsTwice)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++) {
- ASSERT_EQ(tdm_vblank_set_fps(vblanks[v], 60), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_vblank_set_fps(vblanks[v], 60), TDM_ERROR_NONE);
- }
-}
-
-/* tdm_vblank_set_fixed_fps() */
-TEST_P(TDMVblank, VblankSetFixedFps)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++)
- ASSERT_EQ(tdm_vblank_set_fixed_fps(vblanks[v], 60), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMVblank, VblankSetFixedFpsNullObject)
-{
- ASSERT_EQ(tdm_vblank_set_fixed_fps(NULL, 60), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMVblank, VblankSetFixedFpsTwice)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++) {
- ASSERT_EQ(tdm_vblank_set_fixed_fps(vblanks[v], 60), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_vblank_set_fixed_fps(vblanks[v], 60), TDM_ERROR_NONE);
- }
-}
-
-/* tdm_vblank_get_fps() */
-TEST_P(TDMVblank, VblankGetFps)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++) {
- unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_vblank_set_fps(vblanks[v], 60), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_vblank_get_fps(vblanks[v], &fps), TDM_ERROR_NONE);
- ASSERT_EQ(fps, 60);
- }
-}
-
-TEST_P(TDMVblank, VblankGetFpsNullObject)
-{
- unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_vblank_get_fps(NULL, &fps), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(fps, (unsigned int)TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMVblank, VblankGetFpsNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestCreateVblanks(), true);
-
- ASSERT_EQ(tdm_vblank_get_fps(vblanks[0], NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMVblank, VblankGetFpsNoSet)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestPrepareOutput(), true);
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++) {
- unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
- const tdm_output_mode *mode = (const tdm_output_mode *)TDM_UT_INVALID_VALUE;
- tdm_error ret;
-
- if (!ut_tdm_vblank_is_avaiable(vblanks[v]))
- continue;
-
- ASSERT_EQ(tdm_vblank_get_fps(vblanks[v], &fps), TDM_ERROR_NONE);
- ASSERT_TRUE(fps != 0 && fps != (unsigned int)TDM_UT_INVALID_VALUE);
-
- tdm_output *output = tdm_vblank_get_output(vblanks[v], &ret);
- ASSERT_NE(output, NULL);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
-
- ASSERT_EQ(tdm_output_get_mode(output, &mode), TDM_ERROR_NONE);
- ASSERT_TRUE(mode != NULL && mode != (const tdm_output_mode *)TDM_UT_INVALID_VALUE);
-
- ASSERT_EQ(fps, mode->vrefresh);
- }
-}
-
-TEST_P(TDMVblank, VblankGetFpsAfterSetFixedFps)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++) {
- unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
-
- ASSERT_EQ(tdm_vblank_set_fps(vblanks[v], 60), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_vblank_get_fps(vblanks[v], &fps), TDM_ERROR_NONE);
- ASSERT_EQ(fps, 60);
-
- ASSERT_EQ(tdm_vblank_set_fixed_fps(vblanks[v], 10), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_vblank_get_fps(vblanks[v], &fps), TDM_ERROR_NONE);
- ASSERT_EQ(fps, 10);
-
- /* should return TDM_ERROR_NONE because tdm_vblank_set_fixed_fps would be
- * called by other who call tdm_vblank_set_fps. If returns error, other
- * can't handle error.
- */
- ASSERT_EQ(tdm_vblank_set_fps(vblanks[v], 60), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_vblank_get_fps(vblanks[v], &fps), TDM_ERROR_NONE);
- ASSERT_EQ(fps, 10);
- }
-}
-
-/* tdm_vblank_ignore_global_fps() */
-TEST_P(TDMVblank, VblankIgnoreGlobalFpsNullObject)
-{
- ASSERT_EQ(tdm_vblank_ignore_global_fps(NULL, 1), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMVblank, VblankIgnoreGlobalFpsSet)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++)
- ASSERT_EQ(tdm_vblank_ignore_global_fps(vblanks[v], 1), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMVblank, VblankIgnoreGlobalFpsSetTwice)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++) {
- ASSERT_EQ(tdm_vblank_ignore_global_fps(vblanks[v], 1), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_vblank_ignore_global_fps(vblanks[v], 1), TDM_ERROR_NONE);
- }
-}
-
-TEST_P(TDMVblank, VblankIgnoreGlobalFpsUnset)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++)
- ASSERT_EQ(tdm_vblank_ignore_global_fps(vblanks[v], 0), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMVblank, VblankIgnoreGlobalFpsUnsetTwice)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++) {
- ASSERT_EQ(tdm_vblank_ignore_global_fps(vblanks[v], 0), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_vblank_ignore_global_fps(vblanks[v], 0), TDM_ERROR_NONE);
- }
-}
-
-/* tdm_vblank_set_offset() */
-TEST_P(TDMVblank, VblankSetOffset)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++)
- ASSERT_EQ(tdm_vblank_set_offset(vblanks[v], 10), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMVblank, VblankSetOffsetNullObject)
-{
- ASSERT_EQ(tdm_vblank_set_offset(NULL, 10), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMVblank, VblankSetOffsetTwice)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++) {
- ASSERT_EQ(tdm_vblank_set_offset(vblanks[v], 10), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_vblank_set_offset(vblanks[v], 10), TDM_ERROR_NONE);
- }
-}
-
-/* tdm_vblank_get_offset() */
-TEST_P(TDMVblank, VblankGetOffset)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++) {
- int offset = TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_vblank_set_offset(vblanks[v], 10), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_vblank_get_offset(vblanks[v], &offset), TDM_ERROR_NONE);
- ASSERT_EQ(offset, 10);
- }
-}
-
-TEST_P(TDMVblank, VblankGetOffsetNullObject)
-{
- int offset = TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_vblank_get_offset(NULL, &offset), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(offset, TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMVblank, VblankGetOffsetNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestCreateVblanks(), true);
-
- ASSERT_EQ(tdm_vblank_get_offset(vblanks[0], NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMVblank, VblankGetOffsetNoSet)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++) {
- int offset = TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_vblank_get_offset(vblanks[v], &offset), TDM_ERROR_NONE);
- ASSERT_EQ(offset, 0);
- }
-}
-
-/* tdm_vblank_set_enable_fake() */
-TEST_P(TDMVblank, VblankSetEnableFake)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++)
- ASSERT_EQ(tdm_vblank_set_enable_fake(vblanks[v], 1), TDM_ERROR_NONE);
-}
-
-TEST_P(TDMVblank, VblankSetEnableFakeNullObject)
-{
- ASSERT_EQ(tdm_vblank_set_enable_fake(NULL, 1), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMVblank, VblankSetEnableFakeTwice)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++) {
- ASSERT_EQ(tdm_vblank_set_enable_fake(vblanks[v], 1), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_vblank_set_enable_fake(vblanks[v], 1), TDM_ERROR_NONE);
- }
-}
-
-/* tdm_vblank_get_enable_fake() */
-TEST_P(TDMVblank, VblankGetEnableFake)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++) {
- unsigned int enable_fake;
- ASSERT_EQ(tdm_vblank_set_enable_fake(vblanks[v], 1), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_vblank_get_enable_fake(vblanks[v], &enable_fake), TDM_ERROR_NONE);
- ASSERT_EQ(enable_fake, 1);
-
- ASSERT_EQ(tdm_vblank_set_enable_fake(vblanks[v], 0), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_vblank_get_enable_fake(vblanks[v], &enable_fake), TDM_ERROR_NONE);
- ASSERT_EQ(enable_fake, 0);
- }
-}
-
-TEST_P(TDMVblank, VblankGetEnableFakeNullObject)
-{
- unsigned int enable_fake = (unsigned int)TDM_UT_INVALID_VALUE;
- ASSERT_EQ(tdm_vblank_get_enable_fake(NULL, &enable_fake), TDM_ERROR_INVALID_PARAMETER);
- ASSERT_EQ(enable_fake, (unsigned int)TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMVblank, VblankGetEnableFakeNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestCreateVblanks(), true);
-
- ASSERT_EQ(tdm_vblank_get_enable_fake(vblanks[0], NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMVblank, VblankGetEnableFakeNoSet)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++) {
- unsigned int enable_fake;
- ASSERT_EQ(tdm_vblank_get_enable_fake(vblanks[v], &enable_fake), TDM_ERROR_NONE);
- ASSERT_EQ(enable_fake, 0);
- }
-}
-
-static void
-_ut_tdm_vblank_cb(tdm_vblank *vblank, tdm_error error, unsigned int sequence,
- unsigned int tv_sec, unsigned int tv_usec, void *user_data)
-{
- unsigned int *cur_seq = (unsigned int *)user_data;
- if (cur_seq)
- *cur_seq = (error == TDM_ERROR_NONE) ? sequence : ((unsigned int)-1);
-}
-
-TEST_P(TDMVblank, VblankWait)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestPrepareOutput(), true);
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++) {
- unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
- double start, end, interval;
-
- if (!ut_tdm_vblank_is_avaiable(vblanks[v]))
- continue;
-
- ASSERT_EQ(tdm_vblank_get_fps(vblanks[v], &fps), TDM_ERROR_NONE);
- ASSERT_TRUE(fps > 0 && fps != (unsigned int)TDM_UT_INVALID_VALUE);
- interval = 1.0 / (double)fps;
-
- for (int t = 0; t < 10; t++) {
- unsigned int cur_seq = 0;
-
- start = tdm_helper_get_time();
- ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _ut_tdm_vblank_cb, &cur_seq), TDM_ERROR_NONE);
- while (cur_seq == 0)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- end = tdm_helper_get_time();
-
- /* "+ interval" consider the delay of socket communication between kernel and platform */
- ASSERT_LT((end - start), (interval + interval));
- }
- }
-}
-
-TEST_P(TDMVblank, VblankWaitFewTime)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestPrepareOutput(), true);
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++) {
- unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
- double start, end, interval;
-
- if (!ut_tdm_vblank_is_avaiable(vblanks[v]))
- continue;
-
- ASSERT_EQ(tdm_vblank_get_fps(vblanks[v], &fps), TDM_ERROR_NONE);
- ASSERT_TRUE(fps > 0 && fps != (unsigned int)TDM_UT_INVALID_VALUE);
- interval = 1.0 / (double)fps;
-
- for (int t = 0; t < 10; t++) {
- unsigned int cur_seq, seq1, seq2;
-
- cur_seq = seq1 = seq2 = 0;
- start = tdm_helper_get_time();
- ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _ut_tdm_vblank_cb, &cur_seq), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _ut_tdm_vblank_cb, &seq1), TDM_ERROR_NONE);
- ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _ut_tdm_vblank_cb, &seq2), TDM_ERROR_NONE);
- while (cur_seq == 0)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- end = tdm_helper_get_time();
-
- ASSERT_NE(seq1, 0);
- ASSERT_NE(seq2, 0);
-
- /* "+ interval" consider the delay of socket communication between kernel and platform */
- ASSERT_LT((end - start), (interval + interval));
- }
- }
-}
-
-TEST_P(TDMVblank, VblankWaitInterval0)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestPrepareOutput(), true);
- ASSERT_EQ(TestCreateVblanks(), true);
-
- ASSERT_EQ(tdm_vblank_wait(vblanks[0], 0, 0, 0, _ut_tdm_vblank_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMVblank, VblankWaitInterval)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestPrepareOutput(), true);
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++) {
- unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
- double start, end, interval;
-
- if (!ut_tdm_vblank_is_avaiable(vblanks[v]))
- continue;
-
- ASSERT_EQ(tdm_vblank_get_fps(vblanks[v], &fps), TDM_ERROR_NONE);
- ASSERT_TRUE(fps > 0 && fps != (unsigned int)TDM_UT_INVALID_VALUE);
- interval = 1.0 / (double)fps;
-
- /* start from 1 */
- for (int t = 1; t < 10; t++) {
- unsigned int cur_seq = 0;
-
- start = tdm_helper_get_time();
- ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, t, _ut_tdm_vblank_cb, &cur_seq), TDM_ERROR_NONE);
- while (cur_seq == 0)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- end = tdm_helper_get_time();
-
- /* "+ interval" consider the delay of socket communication between kernel and platform */
- ASSERT_GT((end - start), interval * (t - 1));
- ASSERT_LT((end - start), interval * t + interval);
- }
- }
-}
-
-TEST_P(TDMVblank, VblankWaitSeq)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestPrepareOutput(), true);
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++) {
- unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
- double start, end, interval;
-
- if (!ut_tdm_vblank_is_avaiable(vblanks[v]))
- continue;
-
- ASSERT_EQ(tdm_vblank_get_fps(vblanks[v], &fps), TDM_ERROR_NONE);
- ASSERT_TRUE(fps > 0 && fps != (unsigned int)TDM_UT_INVALID_VALUE);
- interval = 1.0 / (double)fps;
-
- for (int t = 0; t < 10; t++) {
- unsigned int cur_seq = 0, temp = 0;
-
- ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _ut_tdm_vblank_cb, &cur_seq), TDM_ERROR_NONE);
- while (cur_seq == 0)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
-
- start = tdm_helper_get_time();
- ASSERT_EQ(tdm_vblank_wait_seq(vblanks[v], 0, 0, cur_seq + 1, _ut_tdm_vblank_cb, &temp), TDM_ERROR_NONE);
- while (temp == 0)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- end = tdm_helper_get_time();
-
- /* "+ interval" consider the delay of socket communication between kernel and platform */
- ASSERT_LT((end - start), (interval + interval));
- }
- }
-}
-
-TEST_P(TDMVblank, VblankWaitSeqInterval)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestPrepareOutput(), true);
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++) {
- unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
- double start, end, interval;
-
- if (!ut_tdm_vblank_is_avaiable(vblanks[v]))
- continue;
-
- ASSERT_EQ(tdm_vblank_get_fps(vblanks[v], &fps), TDM_ERROR_NONE);
- ASSERT_TRUE(fps > 0 && fps != (unsigned int)TDM_UT_INVALID_VALUE);
- interval = 1.0 / (double)fps;
-
- /* start from 1 */
- for (int t = 1; t < 10; t++) {
- unsigned int cur_seq = 0, temp = 0;
-
- ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _ut_tdm_vblank_cb, &cur_seq), TDM_ERROR_NONE);
- while (cur_seq == 0)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
-
- start = tdm_helper_get_time();
- ASSERT_EQ(tdm_vblank_wait_seq(vblanks[v], 0, 0, cur_seq + t, _ut_tdm_vblank_cb, &temp), TDM_ERROR_NONE);
- while (temp == 0)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- end = tdm_helper_get_time();
-
- /* "+ interval" consider the delay of socket communication between kernel and platform */
- ASSERT_GT((end - start), (interval * (t - 1)));
- ASSERT_LT((end - start), (interval * t + interval));
- }
- }
-}
-
-TEST_P(TDMVblank, VblankWaitNullObject)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- unsigned int cur_seq = 0;
-
- ASSERT_EQ(tdm_vblank_wait(NULL, 0, 0, 1, _ut_tdm_vblank_cb, &cur_seq), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMVblank, VblankWaitNullOther)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestCreateVblanks(), true);
-
- ASSERT_EQ(tdm_vblank_wait(vblanks[0], 0, 0, 0, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMVblank, VblankWaitDpmsOff)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestPrepareOutput(), true);
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++) {
- tdm_error ret;
- tdm_output *output = tdm_vblank_get_output(vblanks[v], &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
-
- if (!ut_tdm_output_is_connected(output))
- continue;
-
- ASSERT_EQ(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
-
- ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _ut_tdm_vblank_cb, NULL), TDM_ERROR_DPMS_OFF);
- }
-}
-
-TEST_P(TDMVblank, VblankWaitBeforeDpmsOff)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestPrepareOutput(), true);
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++) {
- unsigned int temp = 0;
- tdm_error ret;
- tdm_output *output = tdm_vblank_get_output(vblanks[v], &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
-
- if (!ut_tdm_output_is_connected(output))
- continue;
-
- ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _ut_tdm_vblank_cb, &temp), TDM_ERROR_NONE);
-
- ASSERT_EQ(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
-
- while (temp == 0)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- }
-}
-
-TEST_P(TDMVblank, VblankWaitSetEnableFakeDpmsOff)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestPrepareOutput(), true);
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++) {
- tdm_error ret;
- tdm_output *output = tdm_vblank_get_output(vblanks[v], &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
-
- if (!ut_tdm_vblank_is_avaiable(vblanks[v]))
- continue;
-
- if (!ut_tdm_output_is_connected(output))
- continue;
-
- ASSERT_EQ(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
-
- ASSERT_EQ(tdm_vblank_set_enable_fake(vblanks[v], 1), TDM_ERROR_NONE);
-
- ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _ut_tdm_vblank_cb, NULL), TDM_ERROR_NONE);
- }
-}
-
-TEST_P(TDMVblank, VblankWaitDisconnectedOutput)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestPrepareOutput(), true);
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++) {
- tdm_error ret;
- tdm_output *output = tdm_vblank_get_output(vblanks[v], &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
-
- if (ut_tdm_output_is_connected(output))
- continue;
-
- ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _ut_tdm_vblank_cb, NULL), TDM_ERROR_OUTPUT_DISCONNECTED);
- }
-}
-
-TEST_P(TDMVblank, VblankWaitSetOffset)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestPrepareOutput(), true);
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++) {
- unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
- double start, end, interval;
-
- if (!ut_tdm_vblank_is_avaiable(vblanks[v]))
- continue;
-
- ASSERT_EQ(tdm_vblank_set_offset(vblanks[v], 100), TDM_ERROR_NONE);
-
- ASSERT_EQ(tdm_vblank_get_fps(vblanks[v], &fps), TDM_ERROR_NONE);
- ASSERT_TRUE(fps > 0 && fps != (unsigned int)TDM_UT_INVALID_VALUE);
- interval = 1.0 / (double)fps;
-
- for (int t = 0; t < 3; t++) {
- unsigned int cur_seq = 0;
-
- start = tdm_helper_get_time();
- ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _ut_tdm_vblank_cb, &cur_seq), TDM_ERROR_NONE);
- while (cur_seq == 0)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- end = tdm_helper_get_time();
-
- /* "+ interval" consider the delay of socket communication between kernel and platform */
- ASSERT_GT((end - start), (0.1));
- ASSERT_LT((end - start), (interval + interval + 0.1));
- }
- }
-}
-
-TEST_P(TDMVblank, VblankWaitSetFps)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestPrepareOutput(), true);
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++) {
- unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
- double start, end, interval, vrefresh_interval;
-
- if (!ut_tdm_vblank_is_avaiable(vblanks[v]))
- continue;
-
- ASSERT_EQ(tdm_vblank_get_fps(vblanks[v], &fps), TDM_ERROR_NONE);
- ASSERT_TRUE(fps > 0 && fps != (unsigned int)TDM_UT_INVALID_VALUE);
- vrefresh_interval = 1.0 / (double)fps;
-
- fps /= 2;
- ASSERT_EQ(tdm_vblank_set_fps(vblanks[v], fps), TDM_ERROR_NONE);
- interval = 1.0 / (double)fps;
-
- for (int t = 0; t < 3; t++) {
- unsigned int cur_seq = 0;
-
- start = tdm_helper_get_time();
- ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _ut_tdm_vblank_cb, &cur_seq), TDM_ERROR_NONE);
- while (cur_seq == 0)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- end = tdm_helper_get_time();
-
- /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
- ASSERT_GT((end - start), (interval - vrefresh_interval));
- ASSERT_LT((end - start), (interval + vrefresh_interval));
- }
- }
-}
-
-TEST_P(TDMVblank, VblankWaitSetFixedFps)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestPrepareOutput(), true);
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++) {
- unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
- double start, end, interval;
-
- if (!ut_tdm_vblank_is_avaiable(vblanks[v]))
- continue;
-
- ASSERT_EQ(tdm_vblank_get_fps(vblanks[v], &fps), TDM_ERROR_NONE);
- ASSERT_TRUE(fps > 0 && fps != (unsigned int)TDM_UT_INVALID_VALUE);
- interval = 1.0 / (double)fps;
-
- ASSERT_EQ(tdm_vblank_set_fixed_fps(vblanks[v], fps), TDM_ERROR_NONE);
-
- /* this fps will be ignored because it has fixed fps value */
- fps /= 2;
- ASSERT_EQ(tdm_vblank_set_fps(vblanks[v], fps), TDM_ERROR_NONE);
-
- for (int t = 0; t < 3; t++) {
- unsigned int cur_seq = 0;
-
- start = tdm_helper_get_time();
- ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _ut_tdm_vblank_cb, &cur_seq), TDM_ERROR_NONE);
- while (cur_seq == 0)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- end = tdm_helper_get_time();
-
- /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
- ASSERT_LT((end - start), (interval + interval));
- }
- }
-}
-
-TEST_P(TDMVblank, VblankWaitEnableDisableGlobalFps)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
- double vrefresh_interval;
- unsigned int cur_seq[3];
- unsigned int global_fps = 5;
- double start, end, interval;
-
- ASSERT_EQ(TestPrepareOutput(), true);
- ASSERT_EQ(TestCreateVblanks3(), true);
- ASSERT_EQ(vblank_count, 3);
-
- if (!ut_tdm_vblank_is_avaiable(vblanks[0]))
- return;
-
- ASSERT_EQ(tdm_vblank_get_fps(vblanks[0], &fps), TDM_ERROR_NONE);
- ASSERT_TRUE(fps >= 30 && fps != (unsigned int)TDM_UT_INVALID_VALUE);
- vrefresh_interval = 1.0 / (double)fps;
-
- for (int v = 0; v < 3; v++) {
- ASSERT_EQ(tdm_vblank_set_fixed_fps(vblanks[v], 10 * (v + 1)), TDM_ERROR_NONE);
- interval = 1.0 / (double)(10 * (v + 1));
- }
-
- /* enable test. global fps doesn't effect server's vblanks */
- tdm_vblank_enable_global_fps(1, global_fps);
-
- for (int v = 0; v < 3; v++) {
- cur_seq[v] = 0;
- ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _ut_tdm_vblank_cb, &cur_seq[v]), TDM_ERROR_NONE);
- }
-
- start = tdm_helper_get_time();
- while (cur_seq[2] == 0)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- end = tdm_helper_get_time();
-
- /* "+- vrefresh_interval" consider the delay of socket communication between kernel and platform */
- ASSERT_GT((end - start), (interval - vrefresh_interval));
- ASSERT_LT((end - start), (interval + vrefresh_interval));
-
- ASSERT_EQ(cur_seq[1], 0);
- ASSERT_EQ(cur_seq[0], 0);
-
- while (cur_seq[1] == 0)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- ASSERT_EQ(cur_seq[0], 0);
-
- while (cur_seq[0] == 0)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
-
- /* disable test. global fps doesn't effect server's vblanks */
- tdm_vblank_enable_global_fps(0, 0);
-
- for (int v = 0; v < 3; v++) {
- cur_seq[v] = 0;
- ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _ut_tdm_vblank_cb, &cur_seq[v]), TDM_ERROR_NONE);
- }
-
- while (cur_seq[2] == 0)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- ASSERT_EQ(cur_seq[1], 0);
- ASSERT_EQ(cur_seq[0], 0);
-
- while (cur_seq[1] == 0)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- ASSERT_EQ(cur_seq[0], 0);
-}
-
-TEST_P(TDMVblank, VblankWaitSetEnableFakeDisconnected)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestPrepareOutput(), true);
- ASSERT_EQ(TestCreateVblanks(), true);
-
- for (int v = 0; v < vblank_count; v++) {
- tdm_error ret;
- tdm_output *output = tdm_vblank_get_output(vblanks[v], &ret);
- ASSERT_EQ(ret, TDM_ERROR_NONE);
-
- if (!ut_tdm_vblank_is_avaiable(vblanks[v]))
- continue;
-
- if (ut_tdm_output_is_connected(output))
- continue;
-
- ASSERT_EQ(tdm_vblank_set_enable_fake(vblanks[v], 1), TDM_ERROR_DPMS_OFF);
-
- ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _ut_tdm_vblank_cb, NULL), TDM_ERROR_NONE);
- }
-}
-
-TEST_P(TDMVblank, DISABLED_VblankWaitBeforeDpmsOff)
-{
- /* wait vblank -> dpms off -> then? (vblank handler is called? or not?) */
-}
-
-TEST_P(TDMVblank, VblankWaitTimeout)
-{
- TDM_UT_SKIP_FLAG(has_outputs);
-
- ASSERT_EQ(TestPrepareOutput(), true);
- ASSERT_EQ(TestCreateVblanks(), true);
-
- if (vblank_count > 0) {
- tdm_vblank *vblank = vblanks[0];
- unsigned int cur_seq = 0;
-
- ASSERT_EQ(tdm_vblank_wait(vblank, 0, 0, 1, _ut_tdm_vblank_cb, &cur_seq), TDM_ERROR_NONE);
- usleep(1200000);
- while (cur_seq == 0)
- ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
- }
-}
-
-#ifdef TDM_UT_TEST_WITH_PARAMS
-INSTANTIATE_TEST_CASE_P(TDMVblankParams,
- TDMVblank,
- Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
-#else
-INSTANTIATE_TEST_CASE_P(TDMVblankParams,
- TDMVblank,
- Values(TDM_DEFAULT_MODULE));
-#endif
-
-/* LCOV_EXCL_END */
\ No newline at end of file