src/ut_tdm_layer.cpp \
src/ut_tdm_output_hwc.cpp \
src/ut_tdm_hwc_window.cpp \
- src/ut_tdm_pp.cpp \
- src/ut_tdm_capture.cpp \
- src/ut_tdm_client.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
#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 "tdm_macro.h"
#include "buffers.h"
-#define UT_TDM_BUFFER_ENABLE
-#define UT_TDM_CAPTURE_ENABLE
-#define UT_TDM_CLIENT_ENABLE
-#define UT_TDM_DISPLAY_ENABLE
-#define UT_TDM_ENV_ENABLE
-#define UT_TDM_EVENT_LOOP_ENABLE
-#define UT_TDM_HELPER_ENABLE
-#define UT_TDM_OUTPUT_HWC_ENABLE
-#define UT_TDM_HWC_WINDOW_ENABLE
-#define UT_TDM_LAYER_ENABLE
-#define UT_TDM_LOG_ENABLE
-#define UT_TDM_OUTPUT_ENABLE
-#define UT_TDM_PP_ENABLE
-#define UT_TDM_VBLANK_ENABLE
+//#define TDM_UT_TEST_WITH_PARAMS
+
+extern bool enable_porting_debug;
#undef TDM_DBG
-#define TDM_DBG(fmt, args...) \
- tdm_log_print(TDM_LOG_LEVEL_DBG, fmt, ##args);
#undef TDM_INFO
-#define TDM_INFO(fmt, args...) \
- tdm_log_print(TDM_LOG_LEVEL_INFO, fmt, ##args);
#undef TDM_WRN
-#define TDM_WRN(fmt, args...) \
- tdm_log_print(TDM_LOG_LEVEL_WRN, fmt, ##args);
#undef TDM_ERR
-#define TDM_ERR(fmt, args...) \
- tdm_log_print(TDM_LOG_LEVEL_ERR, fmt, ##args);
+#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_print_stdout(TDM_LOG_LEVEL_INFO, fmt, ##args)
+#define TDM_UT_ERR(fmt, args...) tdm_log_print_stdout(TDM_LOG_LEVEL_ERR, fmt, ##args)
#define TDM_UT_ENTRY() \
- TDM_INFO("--------------------------------------------- %s", typeid(*this).name())
+ TDM_ERR("--------------------------------------------- %s", typeid(*this).name())
#define TDM_UT_CHECK_FLAG(FLAG) \
do {\
if(!(FLAG)) \
- TDM_INFO("[ ] not supported");\
+ TDM_UT_INFO("[ ] not supported");\
} while(0)
#define TDM_UT_SKIP_FLAG(FLAG) \
do {\
if(!(FLAG)) {\
- TDM_INFO("[ SKIPPED ] not supported");\
+ TDM_UT_INFO("[ SKIPPED ] not supported");\
return;\
}\
} while(0)
-#define TDM_UT_NEVER_GET_HERE() \
- do {\
- TDM_INFO("!!! TDM UT NEVER GET HERE !!!");\
+#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_RETURN_IF_FAIL(cond) { \
- if (!(cond)) { \
- TDM_ERR("[%s,%d] '%s' failed", __FUNCTION__, __LINE__, #cond); \
- return; \
- } \
-}
-#define TDM_UT_RETURN_FALSE_IF_FAIL(cond) { \
- if (!(cond)) { \
- TDM_ERR("[%s,%d] '%s' failed", __FUNCTION__, __LINE__, #cond); \
- return false; \
- } \
-}
-#define TDM_UT_GOTO_IF_FAIL(cond, dst) { \
- if (!(cond)) { \
- TDM_ERR("[%s,%d] '%s' failed", __FUNCTION__, __LINE__, #cond); \
- goto dst; \
- } \
-}
+
+#define TDM_UT_ASK_YNR(fmt, ...) \
+ do { \
+ if (enable_porting_debug) { \
+ char ch; \
+ printf(fmt" [Y]es, [n]o, [r]etry: ", ##__VA_ARGS__); \
+ do { \
+ ch = getchar(); \
+ if (ch == '\n') \
+ ch = 'y'; \
+ else { \
+ char tch; \
+ while ((tch = getchar()) != '\n' && tch != EOF); \
+ } \
+ } while (ch != 'y' && ch != 'Y' && ch != 'n' && ch != 'N' && ch != 'r' && ch != 'R'); \
+ if (ch == 'n' || ch == 'N') \
+ GTEST_FATAL_FAILURE_("tc failed"); \
+ if (ch == 'r' || ch == 'R') \
+ goto retry; \
+ } else { \
+ usleep(1000000); /* 1000 ms */ \
+ } \
+ } while (0)
#define TDM_UT_SIZE_ALIGN(value, base) (((value) + ((base) - 1)) & ~((base) - 1))
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
{
bool has_outputs;
tdm_output **outputs;
int output_count;
+
+ bool done1, done2, done3;
+
TDMOutput();
void SetUp(void);
void TearDown(void);
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_mode_setting(tdm_output *output);
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_prepare(tdm_display *dpy, 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_prepare_buffer(tdm_layer *layer, tbm_surface_h *buffers, int buffer_count);
+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, int w, int h, tbm_format format, tdm_info_layer *info);
+bool ut_tdm_layer_set_buffer(tdm_layer *layer, tbm_surface_h buffer);
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, 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(); }
+};
#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"
+
+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;
+
+ TDMBackendCapture();
+ void SetUp(void);
+ void TearDown(void);
+
+ bool FindFormat(tbm_format fmt);
+ bool TestPrepareDefault(void);
+ bool TestPrepare(int output_idx, int w, int h, tbm_format fmt, tdm_transform t, tdm_capture_type c, int frequency);
+ void TestDone(void);
+ void DumpBuffers(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;
+}
+
+void TDMBackendCapture::SetUp(void)
+{
+ tdm_display_capability dpy_capabilities;
+
+ TDMBackendDisplay::SetUp();
+
+ ASSERT_TRUE(tdm_display_get_capabilities(dpy, &dpy_capabilities) == TDM_ERROR_NONE);
+ has_capture_cap = dpy_capabilities & TDM_DISPLAY_CAPABILITY_CAPTURE;
+
+ if (!has_capture_cap)
+ return;
+
+ for (int o = 0; o < output_count; o++) {
+ if (!ut_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_TRUE(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_TRUE(ut_tdm_output_unset(dpy, outputs[o]) == true);
+ }
+
+ DestroyBuffers();
+
+ TDMBackendDisplay::TearDown();
+}
+
+bool TDMBackendCapture::TestPrepareDefault(void)
+{
+ tdm_error ret;
+
+ 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_formats(dpy, &formats, &format_count) == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(formats != NULL);
+ TDM_UT_RETURN_FALSE_IF_FAIL(format_count > 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);
+
+ 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, &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::FindFormat(tbm_format fmt)
+{
+ bool found = false;
+
+ 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_formats(dpy, &formats, &format_count) == TDM_ERROR_NONE);
+ TDM_UT_RETURN_FALSE_IF_FAIL(formats != NULL);
+ TDM_UT_RETURN_FALSE_IF_FAIL(format_count > 0);
+
+ for (int f = 0; f < format_count; f++) {
+ if (formats[f] == fmt) {
+ found = true;
+ break;
+ }
+ }
+
+ return found;
+}
+
+bool TDMBackendCapture::TestPrepare(int output_idx, int w, int h, tbm_format fmt, tdm_transform t, tdm_capture_type c, int frequency)
+{
+ tdm_error ret;
+
+ 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(FindFormat(fmt) == true);
+
+ 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);
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(ut_tdm_buffer_create(w, h, fmt, 0, false, 3, buffers) == true);
+ TDM_UT_RETURN_FALSE_IF_FAIL(ut_tdm_capture_fill_info(outputs[output_idx], buffers[0], t, c, frequency, &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::DumpBuffers(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::DestroyBuffers(void)
+{
+ for (int b = 0; b < 3; b++) {
+ tbm_surface_destroy(buffers[b]);
+ buffers[b] = NULL;
+ }
+}
+
+bool
+ut_tdm_capture_fill_info(tdm_output *output, tbm_surface_h buffer, tdm_transform transform,
+ tdm_capture_type type, int frequency, tdm_info_capture *info)
+{
+ int bw, bh;
+
+ 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;
+ 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);
+ info->dst_config.format = tbm_surface_get_format(buffer);
+
+ info->transform = transform;
+ info->type = type;
+ info->flags = 0;
+
+ if (frequency <= 0) {
+ 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);
+ frequency = mode->vrefresh;
+ }
+
+ info->frequency = frequency;
+
+ TDM_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.h,
+ 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;
+}
+
+static tbm_format test_formats[] = {
+ TBM_FORMAT_ARGB8888,
+ TBM_FORMAT_XRGB8888,
+ TBM_FORMAT_YUV420,
+ TBM_FORMAT_YVU420,
+ TBM_FORMAT_NV12,
+ TBM_FORMAT_NV21,
+};
+
+#define TEST_FORMAT_CNT (int)(sizeof(test_formats) / sizeof((test_formats)[0]))
+
+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_TRUE(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_TRUE(tdm_display_get_capture_available_formats(dpy, &formats, &count) == TDM_ERROR_NO_CAPABILITY);
+ ASSERT_TRUE(formats == (const tbm_format *)TDM_UT_INVALID_VALUE);
+ ASSERT_TRUE(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_TRUE(tdm_display_get_capture_available_formats(NULL, &formats, &count) == TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_TRUE(formats == (const tbm_format *)TDM_UT_INVALID_VALUE);
+ ASSERT_TRUE(count == TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMBackendCapture, CaptureDispalyGetAvaiableFormatsNullOther)
+{
+ ASSERT_TRUE(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_TRUE(tdm_display_get_capture_available_size(dpy, &min_w, &min_h, &max_w, &max_h, &preferred_align) == TDM_ERROR_NONE);
+ ASSERT_TRUE(min_w != TDM_UT_INVALID_VALUE);
+ ASSERT_TRUE(min_h != TDM_UT_INVALID_VALUE);
+ ASSERT_TRUE(max_w != TDM_UT_INVALID_VALUE);
+ ASSERT_TRUE(max_h != TDM_UT_INVALID_VALUE);
+ ASSERT_TRUE(preferred_align != TDM_UT_INVALID_VALUE);
+ } else {
+ ASSERT_TRUE(tdm_display_get_capture_available_size(dpy, &min_w, &min_h, &max_w, &max_h, &preferred_align) == TDM_ERROR_NO_CAPABILITY);
+ ASSERT_TRUE(min_w == TDM_UT_INVALID_VALUE);
+ ASSERT_TRUE(min_h == TDM_UT_INVALID_VALUE);
+ ASSERT_TRUE(max_w == TDM_UT_INVALID_VALUE);
+ ASSERT_TRUE(max_h == TDM_UT_INVALID_VALUE);
+ ASSERT_TRUE(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_TRUE(tdm_display_get_capture_available_size(NULL, &min_w, &min_h, &max_w, &max_h, &preferred_align) == TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_TRUE(min_w == TDM_UT_INVALID_VALUE);
+ ASSERT_TRUE(min_h == TDM_UT_INVALID_VALUE);
+ ASSERT_TRUE(max_w == TDM_UT_INVALID_VALUE);
+ ASSERT_TRUE(max_h == TDM_UT_INVALID_VALUE);
+ ASSERT_TRUE(preferred_align == TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMBackendCapture, CaptureDispalyGetAvaiableSizeNullOther)
+{
+ if (has_capture_cap)
+ ASSERT_TRUE(tdm_display_get_capture_available_size(dpy, NULL, NULL, NULL, NULL, NULL) == TDM_ERROR_NONE);
+ else
+ ASSERT_TRUE(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);
+
+ ASSERT_TRUE(TestPrepareDefault() == true);
+
+ TestDone();
+}
+
+TEST_P(TDMBackendCapture, CaptureDestroyNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+
+ tdm_capture_destroy(NULL);
+}
+
+TEST_P(TDMBackendCapture, CaptureSetInfo)
+{
+ /* tested in CaptureNoScaleNoTransformNoCSC */
+}
+
+TEST_P(TDMBackendCapture, CaptureSetInfoNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+
+ tdm_info_capture info;
+ memset(&info, 0, sizeof info);
+ ASSERT_TRUE(tdm_capture_set_info(NULL, &info) == TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMBackendCapture, CaptureSetInfoNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+
+ ASSERT_TRUE(TestPrepareDefault() == true);
+
+ ASSERT_TRUE(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);
+
+ ASSERT_TRUE(TestPrepareDefault() == true);
+
+ ASSERT_TRUE(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);
+
+ ASSERT_TRUE(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);
+
+ ASSERT_TRUE(TestPrepareDefault() == true);
+
+ ASSERT_TRUE(tdm_capture_set_done_handler(capture, NULL, NULL) == TDM_ERROR_INVALID_PARAMETER);
+
+ TestDone();
+}
+
+TEST_P(TDMBackendCapture, CaptureAttach)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+
+ for (int o = 0; o < output_count; o++) {
+
+ if (!ut_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ for (int f = 0; f < TEST_FORMAT_CNT; f++) {
+ if (!FindFormat(test_formats[f]))
+ continue;
+
+ ASSERT_TRUE(TestPrepare(o, TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, test_formats[f],
+ TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1) == true);
+
+ for (int b = 0; b < 3; b++)
+ ASSERT_TRUE(tdm_capture_attach(capture, buffers[b]) == TDM_ERROR_NONE);
+
+ TestDone();
+ }
+ }
+}
+
+TEST_P(TDMBackendCapture, CaptureAttachNullObject)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+
+ tbm_surface_h buffer = (tbm_surface_h)TDM_UT_BUFFER_SIZE;
+
+ ASSERT_TRUE(tdm_capture_attach(NULL, buffer) == TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMBackendCapture, CaptureAttachNullOther)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+
+ ASSERT_TRUE(TestPrepareDefault() == true);
+
+ ASSERT_TRUE(tdm_capture_attach(capture, NULL) == TDM_ERROR_INVALID_PARAMETER);
+
+ TestDone();
+}
+
+TEST_P(TDMBackendCapture, CaptureCommit)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+
+ ASSERT_TRUE(TestPrepareDefault() == true);
+
+ ASSERT_TRUE(tdm_capture_commit(capture) == TDM_ERROR_NONE);
+
+ TestDone();
+}
+
+TEST_P(TDMBackendCapture, CaptureCommitNullOBject)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+
+ ASSERT_TRUE(tdm_capture_commit(NULL) == TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMBackendCapture, CaptureCommitDpmsOff)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+
+ ASSERT_TRUE(TestPrepareDefault() == true);
+
+ ASSERT_TRUE(ut_tdm_output_unset(dpy, output) == true);
+
+ ASSERT_TRUE(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF) == TDM_ERROR_NONE);
+
+ ASSERT_TRUE(tdm_capture_commit(capture) == TDM_ERROR_BAD_REQUEST);
+
+ TestDone();
+}
+
+TEST_P(TDMBackendCapture, CaptureNoScaleNoTransformNoCSC)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+
+ 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_TRUE(tdm_output_get_mode(outputs[o], &mode) == TDM_ERROR_NONE);
+
+ for (int f = 0; f < TEST_FORMAT_CNT; f++) {
+ char temp[256];
+ snprintf(temp, sizeof temp, "%c%c%c%c", FOURCC_STR(test_formats[f]));
+
+ if (!FindFormat(test_formats[f]))
+ continue;
+
+ ASSERT_TRUE(TestPrepare(o, mode->hdisplay, mode->vdisplay, test_formats[f],
+ TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1) == true);
+
+ ASSERT_TRUE(tdm_capture_set_done_handler(capture, _ut_tdm_capture_done_cb, &done) == TDM_ERROR_NONE);
+
+ for (int b = 0; b < 3; b++) {
+ done = false;
+ ASSERT_TRUE(tdm_capture_attach(capture, buffers[b]) == TDM_ERROR_NONE);
+ ASSERT_TRUE(tdm_capture_commit(capture) == TDM_ERROR_NONE);
+
+ while (!done)
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+
+ DumpBuffers(b, temp);
+ }
+
+ TestDone();
+ }
+ }
+}
+
+TEST_P(TDMBackendCapture, CaptureScaleTransformCSC)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+
+ 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_TRUE(tdm_output_get_mode(outputs[o], &mode) == TDM_ERROR_NONE);
+
+ for (int f = 0; f < TEST_FORMAT_CNT; f++) {
+ char temp[256];
+ snprintf(temp, sizeof temp, "%c%c%c%c", FOURCC_STR(test_formats[f]));
+
+ if (!FindFormat(test_formats[f]))
+ continue;
+
+ ASSERT_TRUE(TestPrepare(o, TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, test_formats[f],
+ TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1) == true);
+
+ ASSERT_TRUE(tdm_capture_set_done_handler(capture, _ut_tdm_capture_done_cb, &done) == TDM_ERROR_NONE);
+
+ for (int b = 0; b < 3; b++) {
+ done = false;
+ ASSERT_TRUE(tdm_capture_attach(capture, buffers[b]) == TDM_ERROR_NONE);
+ ASSERT_TRUE(tdm_capture_commit(capture) == TDM_ERROR_NONE);
+
+ while (!done)
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+
+ DumpBuffers(b, temp);
+ }
+
+ 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, CaptureAttachFewTimesInOneCommit)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+
+ for (int o = 0; o < output_count; o++) {
+ const tdm_output_mode *mode = NULL;
+ int done = 0;
+ int f = 0;
+
+ if (!ut_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_TRUE(tdm_output_get_mode(outputs[o], &mode) == TDM_ERROR_NONE);
+
+ char temp[256];
+ snprintf(temp, sizeof temp, "%c%c%c%c", FOURCC_STR(test_formats[f]));
+
+ if (!FindFormat(test_formats[f]))
+ continue;
+
+ ASSERT_TRUE(TestPrepare(o, TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, test_formats[f],
+ TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1) == true);
+
+ ASSERT_TRUE(tdm_capture_set_done_handler(capture, _ut_tdm_capture_done_cb2, &done) == TDM_ERROR_NONE);
+
+ done = 0;
+
+ for (int b = 0; b < 3; b++)
+ ASSERT_TRUE(tdm_capture_attach(capture, buffers[b]) == TDM_ERROR_NONE);
+
+ ASSERT_TRUE(tdm_capture_commit(capture) == TDM_ERROR_NONE);
+ while (done != 3)
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+
+ for (int b = 0; b < 3; b++)
+ DumpBuffers(b, temp);
+
+ TestDone();
+ }
+}
+
+TEST_P(TDMBackendCapture, CaptureDestroyWithoutCommit)
+{
+ TDM_UT_SKIP_FLAG(has_capture_cap);
+
+ 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_TRUE(tdm_output_get_mode(outputs[o], &mode) == TDM_ERROR_NONE);
+
+ if (!FindFormat(test_formats[f]))
+ continue;
+
+ ASSERT_TRUE(TestPrepare(o, TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, test_formats[f],
+ TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1) == true);
+
+ ASSERT_TRUE(tdm_capture_set_done_handler(capture, _ut_tdm_capture_done_cb2, NULL) == TDM_ERROR_NONE);
+
+ for (int b = 0; b < 3; b++)
+ ASSERT_TRUE(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);
+
+ 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_TRUE(tdm_output_get_mode(outputs[o], &mode) == TDM_ERROR_NONE);
+
+ if (!FindFormat(test_formats[f]))
+ continue;
+
+ ASSERT_TRUE(TestPrepare(o, TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, test_formats[f],
+ TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1) == true);
+
+ ASSERT_TRUE(tdm_capture_set_done_handler(capture, _ut_tdm_capture_done_cb2, NULL) == TDM_ERROR_NONE);
+
+ for (int b = 0; b < 3; b++)
+ ASSERT_TRUE(tdm_capture_attach(capture, buffers[b]) == TDM_ERROR_NONE);
+
+ ASSERT_TRUE(tdm_capture_commit(capture) == TDM_ERROR_NONE);
+
+ tdm_capture_destroy(capture);
+ capture = NULL;
+
+ 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
--- /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"
+
+#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_TRUE(ret == TDM_ERROR_NONE);
+ ASSERT_TRUE(dpy != NULL);
+
+ ASSERT_TRUE(tdm_display_get_output_count(dpy, &output_count) == TDM_ERROR_NONE);
+ ASSERT_TRUE(output_count >= 0);
+
+ if (output_count > 0) {
+ outputs = (tdm_output**)calloc(output_count, sizeof (tdm_output*));
+ ASSERT_TRUE(outputs != NULL);
+
+ for (int o = 0; o < output_count; o++) {
+ tdm_error ret;
+ tdm_output *output = tdm_display_get_output(dpy, o, &ret);
+ ASSERT_TRUE(ret == TDM_ERROR_NONE);
+ ASSERT_TRUE(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_TRUE(tdm_output_get_layer_count(outputs[o], &count) == TDM_ERROR_NONE);
+ ASSERT_TRUE(count > 0);
+
+ layer_count += count;
+ layers = (tdm_layer**)realloc((void*)layers, sizeof(tdm_layer*) * layer_count);
+ ASSERT_TRUE(layers != NULL);
+
+ for (int l = 0; l < count; l++) {
+ tdm_layer *layer = tdm_output_get_layer(outputs[o], l, &ret);
+ ASSERT_TRUE(layer != NULL);
+ ASSERT_TRUE(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_TRUE(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;
+ }
+}
+
+TEST_P(TDMBackendBasic, VerifyOutputObject)
+{
+ tdm_error ret;
+ int output_count = 0;
+
+ ASSERT_TRUE(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_TRUE(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_TRUE(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_TRUE(ret == TDM_ERROR_NONE);
+
+ int layer_count = 0;
+ ASSERT_TRUE(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_TRUE(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_TRUE(ret == TDM_ERROR_NONE);
+
+ const tdm_prop *props = NULL;
+ int prop_count = 0;
+ ASSERT_TRUE(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_TRUE(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_TRUE(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_TRUE(ret == TDM_ERROR_NONE);
+
+ int layer_count = 0;
+ ASSERT_TRUE(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_TRUE(ret == TDM_ERROR_NONE);
+
+ const tdm_prop *props = NULL;
+ int prop_count = 0;
+ ASSERT_TRUE(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_TRUE(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_TRUE(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_TRUE(set_mode != NULL);
+
+ ASSERT_TRUE(tdm_output_set_mode(outputs[o], set_mode) == TDM_ERROR_NONE);
+ ASSERT_TRUE(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_TRUE(tdm_output_get_available_modes(outputs[o], &modes, &count) == TDM_ERROR_NONE);
+ ASSERT_TRUE(count > 0);
+ ASSERT_TRUE(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_TRUE(set_mode != NULL);
+ ASSERT_TRUE(tdm_output_set_mode(outputs[o], set_mode) == TDM_ERROR_NONE);
+ ASSERT_TRUE(tdm_output_get_mode(outputs[o], &got_mode) == TDM_ERROR_NONE);
+ ASSERT_TRUE(set_mode == got_mode);
+
+ ASSERT_TRUE(tdm_output_set_dpms(outputs[o], set_dpms) == TDM_ERROR_NONE);
+ ASSERT_TRUE(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_TRUE(ut_tdm_output_mode_setting(outputs[o]) == true);
+ ASSERT_TRUE(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON) == TDM_ERROR_NONE);
+
+ layer = ut_tdm_output_get_primary_layer(outputs[o]);
+ ASSERT_TRUE(layer != NULL);
+
+retry:
+ ASSERT_TRUE(ut_tdm_layer_prepare_buffer(layer, buffers, 1, true) == true);
+ ASSERT_TRUE(ut_tdm_layer_set_buffer(layer, buffers[0]) == true);
+ DestroyBuffers();
+
+ ASSERT_TRUE(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_TRUE(tdm_layer_unset_buffer(layer) == TDM_ERROR_NONE);
+ ASSERT_TRUE(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_TRUE(ut_tdm_output_mode_setting(outputs[o]) == true);
+ ASSERT_TRUE(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON) == TDM_ERROR_NONE);
+
+ layer = ut_tdm_output_get_primary_layer(outputs[o]);
+ ASSERT_TRUE(layer != NULL);
+
+retry:
+ ASSERT_TRUE(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_TRUE(ut_tdm_layer_set_buffer(layer, buffers[next_buffer]) == true);
+ ASSERT_TRUE(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_TRUE(tdm_layer_unset_buffer(layer) == TDM_ERROR_NONE);
+ ASSERT_TRUE(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_TRUE(ut_tdm_output_mode_setting(outputs[o]) == true);
+ ASSERT_TRUE(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON) == TDM_ERROR_NONE);
+
+ layer = ut_tdm_output_get_primary_layer(outputs[o]);
+ ASSERT_TRUE(layer != NULL);
+
+retry:
+ ASSERT_TRUE(ut_tdm_layer_prepare_buffer(layer, buffers, 1, true) == true);
+ ASSERT_TRUE(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_TRUE(tdm_layer_unset_buffer(layer) == TDM_ERROR_NONE);
+ ASSERT_TRUE(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_TRUE(ut_tdm_output_mode_setting(outputs[o]) == true);
+ ASSERT_TRUE(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON) == TDM_ERROR_NONE);
+
+ layer = ut_tdm_output_get_primary_layer(outputs[o]);
+ ASSERT_TRUE(layer != NULL);
+
+ ASSERT_TRUE(ut_tdm_layer_prepare_buffer(layer, buffers, 1, false) == true);
+ ASSERT_TRUE(ut_tdm_layer_set_buffer(layer, buffers[0]) == true);
+ DestroyBuffers();
+
+ ASSERT_TRUE(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_TRUE(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_TRUE(ut_tdm_layer_prepare_buffer(layers[l], buffers, 1, true) == true);
+ ASSERT_TRUE(ut_tdm_layer_set_buffer(layers[l], buffers[0]) == true);
+ DestroyBuffers();
+ }
+
+ ASSERT_TRUE(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_TRUE(tdm_layer_unset_buffer(layers[l]) == TDM_ERROR_NONE);
+ ASSERT_TRUE(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_TRUE(ut_tdm_output_mode_setting(outputs[o]) == true);
+ ASSERT_TRUE(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON) == TDM_ERROR_NONE);
+
+ layer = ut_tdm_output_get_primary_layer(outputs[o]);
+ ASSERT_TRUE(layer != NULL);
+
+ ASSERT_TRUE(ut_tdm_layer_prepare_buffer(layer, buffers, 1, false) == true);
+ ASSERT_TRUE(ut_tdm_layer_set_buffer(layer, buffers[0]) == true);
+ DestroyBuffers();
+
+ ASSERT_TRUE(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_TRUE(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_TRUE(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_TRUE(ut_tdm_layer_set_buffer(layers[l], buffers[next_buffer]) == true);
+ ASSERT_TRUE(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_TRUE(tdm_layer_unset_buffer(layers[l]) == TDM_ERROR_NONE);
+ ASSERT_TRUE(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_TRUE(ut_tdm_output_mode_setting(outputs[o]) == true);
+ ASSERT_TRUE(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON) == TDM_ERROR_NONE);
+
+ layer = ut_tdm_output_get_primary_layer(outputs[o]);
+ ASSERT_TRUE(layer != NULL);
+
+ ASSERT_TRUE(ut_tdm_layer_prepare_buffer(layer, buffers, 1, true) == true);
+ ASSERT_TRUE(ut_tdm_layer_set_buffer(layer, buffers[0]) == true);
+ DestroyBuffers();
+
+ ASSERT_TRUE(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_TRUE(ut_tdm_output_mode_setting(outputs[o]) == true);
+ ASSERT_TRUE(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON) == TDM_ERROR_NONE);
+
+ layer = ut_tdm_output_get_primary_layer(outputs[o]);
+ ASSERT_TRUE(layer != NULL);
+
+ ASSERT_TRUE(ut_tdm_layer_prepare_buffer(layer, buffers, 1, true) == true);
+ ASSERT_TRUE(ut_tdm_layer_set_buffer(layer, buffers[0]) == true);
+ DestroyBuffers();
+
+ ASSERT_TRUE(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_TRUE(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_backend_output_done_cb, &done) == TDM_ERROR_NONE);
+ while (!done)
+ ASSERT_TRUE(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_TRUE(ut_tdm_output_mode_setting(outputs[o]) == true);
+ ASSERT_TRUE(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON) == TDM_ERROR_NONE);
+
+ layer = ut_tdm_output_get_primary_layer(outputs[o]);
+ ASSERT_TRUE(layer != NULL);
+
+ ASSERT_TRUE(ut_tdm_layer_prepare_buffer(layer, buffers, 1, true) == true);
+ ASSERT_TRUE(ut_tdm_layer_set_buffer(layer, buffers[0]) == true);
+ DestroyBuffers();
+
+ ASSERT_TRUE(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_TRUE(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_backend_output_done_cb, &done1) == TDM_ERROR_NONE);
+ ASSERT_TRUE(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_backend_output_done_cb, &done2) == TDM_ERROR_NONE);
+ ASSERT_TRUE(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_TRUE(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_TRUE(tdm_display_get_pp_available_size(dpy, &min_w, &min_h, &max_w, &max_h, &preferred_align) == TDM_ERROR_NONE);
+ ASSERT_TRUE(min_w != 0);
+ ASSERT_TRUE(min_h != 0);
+ ASSERT_TRUE(max_w != 0);
+ ASSERT_TRUE(max_h != 0);
+ ASSERT_TRUE(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_TRUE(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_TRUE(tdm_display_get_capture_available_size(dpy, &min_w, &min_h, &max_w, &max_h, &preferred_align) == TDM_ERROR_NONE);
+ ASSERT_TRUE(min_w != 0);
+ ASSERT_TRUE(min_h != 0);
+ ASSERT_TRUE(max_w != 0);
+ ASSERT_TRUE(max_h != 0);
+ ASSERT_TRUE(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_TRUE(layer != NULL);
+
+ ASSERT_TRUE(tdm_layer_get_buffer_flags(layer, &flags) == TDM_ERROR_NONE);
+ ASSERT_TRUE(tdm_layer_get_available_formats(layer, &formats, &format_count) == TDM_ERROR_NONE);
+
+ for (int f = 0; f < format_count; f++) {
+ ASSERT_TRUE(ut_tdm_output_mode_setting(outputs[o]) == true);
+ ASSERT_TRUE(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON) == TDM_ERROR_NONE);
+ ASSERT_TRUE(tdm_output_get_mode(outputs[o], &mode) == TDM_ERROR_NONE);
+ ASSERT_TRUE(mode != NULL);
+
+retry:
+ TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(formats[f]));
+ ASSERT_TRUE(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_TRUE(ut_tdm_layer_set_buffer(layer, buffers[next_buffer]) == true);
+ done = false;
+ ASSERT_TRUE(tdm_output_commit(outputs[o], 0, _ut_tdm_backend_output_commit_cb, &done) == TDM_ERROR_NONE);
+ while (!done)
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret);
+ ASSERT_TRUE(ret == TDM_ERROR_NONE);
+ ASSERT_TRUE(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_TRUE(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_TRUE(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_TRUE(tdm_output_get_pipe(output, &pipe) == TDM_ERROR_NONE);
+
+ ASSERT_TRUE(tdm_layer_get_buffer_flags(layer, &flags) == TDM_ERROR_NONE);
+ ASSERT_TRUE(tdm_output_get_mode(output, &mode) == TDM_ERROR_NONE);
+ ASSERT_TRUE(mode != NULL);
+
+ ASSERT_TRUE(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON) == TDM_ERROR_NONE);
+
+ ASSERT_TRUE(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_TRUE(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_TRUE(ut_tdm_layer_set_buffer(layer, buffers[next_buffer]) == true);
+ done = false;
+ ASSERT_TRUE(tdm_output_commit(output, 0, _ut_tdm_backend_output_commit_cb, &done) == TDM_ERROR_NONE);
+ while (!done)
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret);
+ ASSERT_TRUE(ret == TDM_ERROR_NONE);
+ ASSERT_TRUE(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_TRUE(tdm_layer_unset_buffer(layer) == TDM_ERROR_NONE);
+ }
+}
+
+TEST_P(TDMBackendDisplay, VerifyOverlayLayerSize)
+{
+ ASSERT_TRUE(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_TRUE(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_TRUE(tdm_output_get_pipe(output, &pipe) == TDM_ERROR_NONE);
+
+ ASSERT_TRUE(tdm_layer_get_buffer_flags(layer, &flags) == TDM_ERROR_NONE);
+ ASSERT_TRUE(tdm_output_get_mode(output, &mode) == TDM_ERROR_NONE);
+ ASSERT_TRUE(mode != NULL);
+
+ ASSERT_TRUE(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON) == TDM_ERROR_NONE);
+
+ ASSERT_TRUE(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_TRUE(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_TRUE(ut_tdm_layer_set_buffer(layer, buffers[next_buffer]) == true);
+ done = false;
+ ASSERT_TRUE(tdm_output_commit(output, 0, _ut_tdm_backend_output_commit_cb, &done) == TDM_ERROR_NONE);
+ while (!done)
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret);
+ ASSERT_TRUE(ret == TDM_ERROR_NONE);
+ ASSERT_TRUE(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_TRUE(tdm_layer_unset_buffer(layer) == TDM_ERROR_NONE);
+ }
+}
+
+TEST_P(TDMBackendDisplay, VerifyOverlayLayerScale)
+{
+ ASSERT_TRUE(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_TRUE(ret == TDM_ERROR_NONE);
+
+ ASSERT_TRUE(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_TRUE(tdm_layer_get_buffer_flags(layer, &flags) == TDM_ERROR_NONE);
+ ASSERT_TRUE(tdm_output_get_mode(output, &mode) == TDM_ERROR_NONE);
+ ASSERT_TRUE(mode != NULL);
+
+ ASSERT_TRUE(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON) == TDM_ERROR_NONE);
+
+ ASSERT_TRUE(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_TRUE(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_TRUE(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_TRUE(tdm_layer_set_buffer(layer, buffers[next_buffer]) == TDM_ERROR_NONE);
+ done = false;
+ ASSERT_TRUE(tdm_output_commit(output, 0, _ut_tdm_backend_output_commit_cb, &done) == TDM_ERROR_NONE);
+ while (!done)
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret);
+ ASSERT_TRUE(ret == TDM_ERROR_NONE);
+ ASSERT_TRUE(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_TRUE(tdm_layer_unset_buffer(layer) == TDM_ERROR_NONE);
+ }
+}
+
+TEST_P(TDMBackendDisplay, VerifyOverlayLayerMovePosition)
+{
+ ASSERT_TRUE(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_TRUE(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_TRUE(tdm_output_get_pipe(output, &pipe) == TDM_ERROR_NONE);
+
+ ASSERT_TRUE(tdm_layer_get_buffer_flags(layer, &flags) == TDM_ERROR_NONE);
+ ASSERT_TRUE(tdm_output_get_mode(output, &mode) == TDM_ERROR_NONE);
+ ASSERT_TRUE(mode != NULL);
+
+ ASSERT_TRUE(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON) == TDM_ERROR_NONE);
+
+ ASSERT_TRUE(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_TRUE(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_TRUE(tdm_layer_set_info(layer, &info) == TDM_ERROR_NONE);
+
+ ASSERT_TRUE(tdm_layer_set_buffer(layer, buffers[next_buffer]) == TDM_ERROR_NONE);
+ done = false;
+ ASSERT_TRUE(tdm_output_commit(output, 0, _ut_tdm_backend_output_commit_cb, &done) == TDM_ERROR_NONE);
+ while (!done)
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret);
+ ASSERT_TRUE(ret == TDM_ERROR_NONE);
+ ASSERT_TRUE(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_TRUE(tdm_layer_unset_buffer(layer) == TDM_ERROR_NONE);
+ }
+}
+
+TEST_P(TDMBackendDisplay, VerifyOverlayLayerCrop)
+{
+ ASSERT_TRUE(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_TRUE(ret == TDM_ERROR_NONE);
+
+ ASSERT_TRUE(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;
+ }
+
+ ASSERT_TRUE(tdm_layer_get_buffer_flags(layer, &flags) == TDM_ERROR_NONE);
+ ASSERT_TRUE(tdm_output_get_mode(output, &mode) == TDM_ERROR_NONE);
+ ASSERT_TRUE(mode != NULL);
+
+ ASSERT_TRUE(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON) == TDM_ERROR_NONE);
+
+ ASSERT_TRUE(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_TRUE(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_TRUE(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_TRUE(tdm_layer_set_buffer(layer, buffers[next_buffer]) == TDM_ERROR_NONE);
+ done = false;
+ ASSERT_TRUE(tdm_output_commit(output, 0, _ut_tdm_backend_output_commit_cb, &done) == TDM_ERROR_NONE);
+ while (!done)
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret);
+ ASSERT_TRUE(ret == TDM_ERROR_NONE);
+ ASSERT_TRUE(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_TRUE(tdm_layer_unset_buffer(layer) == TDM_ERROR_NONE);
+ }
+}
+
+/* should be debugged int emulator kernel */
+TEST_P(TDMBackendDisplay, DISABLED_VerifyOutputSetDpmsFromOnToOff)
+{
+ ASSERT_TRUE(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_TRUE(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_TRUE(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_TRUE(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF) == TDM_ERROR_NONE);
+ ASSERT_TRUE(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_TRUE(ut_tdm_output_mode_setting(outputs[o]) == true);
+ ASSERT_TRUE(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_TRUE(ut_tdm_output_mode_setting(outputs[o]) == true);
+ ASSERT_TRUE(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_TRUE(ut_tdm_output_prepare(dpy, outputs[o], true) == true);
+
+ tdm_layer *layer = ut_tdm_output_get_primary_layer(outputs[o]);
+ ASSERT_TRUE(layer != NULL);
+
+ ASSERT_TRUE(tdm_layer_unset_buffer(layer) == TDM_ERROR_NONE);
+
+ ASSERT_TRUE(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_TRUE(ut_tdm_output_prepare(dpy, outputs[o], true) == true);
+
+ tdm_layer *layer = ut_tdm_output_get_primary_layer(outputs[o]);
+ ASSERT_TRUE(layer != NULL);
+
+ ASSERT_TRUE(tdm_layer_unset_buffer(layer) == TDM_ERROR_NONE);
+ ASSERT_TRUE(tdm_output_commit(outputs[o], 0, NULL, NULL) == TDM_ERROR_NONE);
+
+ ASSERT_TRUE(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF) == TDM_ERROR_NONE);
+ }
+}
+
+TEST_P(TDMBackendDisplay, DISABLED_VerifyOutputSetDpmsAsync)
+{
+}
+
+TEST_P(TDMBackendDisplay, VerifyLayerGetInfo)
+{
+ ASSERT_TRUE(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;
+
+ tdm_info_layer info, temp;
+ tdm_layer *layer = ut_tdm_output_get_primary_layer(outputs[o]);
+ ASSERT_TRUE(layer != NULL);
+ ASSERT_TRUE(ut_tdm_layer_fill_info(layer, -1, -1, 0, &info) == true);
+ ASSERT_TRUE(tdm_layer_get_info(layer, &temp) == TDM_ERROR_NONE);
+ ASSERT_TRUE(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
--- /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"
+
+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
--- /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"
+
+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;
+
+ TDMBackendPP();
+ void SetUp(void);
+ void TearDown(void);
+
+ bool PreparePP(void);
+ bool PrepareBuffers(int sw, int sh, tbm_format sf, int dw, int dh, tbm_format df, tdm_transform t);
+ void DumpBuffers(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);
+}
+
+void TDMBackendPP::SetUp(void)
+{
+ TDMBackendDisplay::SetUp();
+
+ ASSERT_TRUE(tdm_display_get_pp_capabilities(dpy, &capabilities) == TDM_ERROR_NONE);
+ ASSERT_TRUE(capabilities > 0);
+ ASSERT_TRUE(tdm_display_get_pp_available_formats(dpy, &formats, &format_count) == TDM_ERROR_NONE);
+ ASSERT_TRUE(formats != NULL);
+ ASSERT_TRUE(format_count > 0);
+ ASSERT_TRUE(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);
+}
+
+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 flags = 0;
+
+ sw = TDM_UT_SIZE_ALIGN(sw, preferred_align);
+ dw = TDM_UT_SIZE_ALIGN(dw, preferred_align);
+
+ if (capabilities & TDM_PP_CAPABILITY_SCANOUT)
+ flags = TBM_BO_SCANOUT;
+
+ TDM_UT_RETURN_FALSE_IF_FAIL(ut_tdm_buffer_create(sw, sh, sf, flags, true, 3, srcbuf) == true);
+ TDM_UT_RETURN_FALSE_IF_FAIL(ut_tdm_buffer_create(dw, dh, df, 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;
+}
+
+void TDMBackendPP::DumpBuffers(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_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_TRUE(tdm_display_get_pp_available_formats(NULL, &formats, &count) == TDM_ERROR_INVALID_PARAMETER);
+ else
+ ASSERT_TRUE(tdm_display_get_pp_available_formats(NULL, &formats, &count) == TDM_ERROR_NO_CAPABILITY);
+ ASSERT_TRUE(formats == (const tbm_format *)TDM_UT_INVALID_VALUE);
+ ASSERT_TRUE(count == TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMBackendPP, PPDispalyGetAvaiableFormatsNullOther)
+{
+ if (ut_tdm_display_has_pp_capability(dpy)) {
+ ASSERT_TRUE(PreparePP() == true);
+ ASSERT_TRUE(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_TRUE(tdm_display_get_pp_available_size(NULL, &min_w, &min_h, &max_w, &max_h, &preferred_align) == TDM_ERROR_INVALID_PARAMETER);
+ else
+ ASSERT_TRUE(tdm_display_get_pp_available_size(NULL, &min_w, &min_h, &max_w, &max_h, &preferred_align) == TDM_ERROR_NO_CAPABILITY);
+ ASSERT_TRUE(min_w == TDM_UT_INVALID_VALUE);
+ ASSERT_TRUE(min_h == TDM_UT_INVALID_VALUE);
+ ASSERT_TRUE(max_w == TDM_UT_INVALID_VALUE);
+ ASSERT_TRUE(max_h == TDM_UT_INVALID_VALUE);
+ ASSERT_TRUE(preferred_align == TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMBackendPP, PPDispalyGetAvaiableSizeNullOther)
+{
+ if (ut_tdm_display_has_pp_capability(dpy)) {
+ ASSERT_TRUE(PreparePP() == true);
+ ASSERT_TRUE(tdm_display_get_pp_available_size(pp, NULL, NULL, NULL, NULL, NULL) == TDM_ERROR_INVALID_PARAMETER);
+ }
+}
+
+TEST_P(TDMBackendPP, PPDestroy)
+{
+ TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
+
+ ASSERT_TRUE(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_TRUE(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_TRUE(PreparePP() == true);
+ ASSERT_TRUE(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_TRUE(PreparePP() == true);
+ ASSERT_TRUE(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_TRUE(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_TRUE(PreparePP() == true);
+ ASSERT_TRUE(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_TRUE(PreparePP() == true);
+
+ for (int f = 0; f < format_count; f++) {
+ ASSERT_TRUE(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_TRUE(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_TRUE(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_TRUE(PreparePP() == true);
+
+ ASSERT_TRUE(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_TRUE(PreparePP() == true);
+
+ ASSERT_TRUE(tdm_pp_commit(pp) == TDM_ERROR_NONE);
+}
+
+TEST_P(TDMBackendPP, PPCommitNullOBject)
+{
+ TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
+
+ ASSERT_TRUE(tdm_pp_commit(NULL) == TDM_ERROR_INVALID_PARAMETER);
+}
+
+TEST_P(TDMBackendPP, PPNoScaleNoTransformNoCSC)
+{
+ TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
+
+ bool done;
+ char temp[256];
+ snprintf(temp, sizeof temp, "%c%c%c%c", FOURCC_STR(formats[0]));
+
+ TDM_INFO("---- format(%c%c%c%c)", FOURCC_STR(formats[0]));
+
+ ASSERT_TRUE(PreparePP() == true);
+
+ ASSERT_TRUE(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, formats[0],
+ TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, formats[0],
+ TDM_TRANSFORM_NORMAL) == true);
+
+ ASSERT_TRUE(tdm_pp_set_done_handler(pp, _ut_tdm_pp_done_cb, &done) == TDM_ERROR_NONE);
+
+ for (int b = 0; b < 3; b++) {
+ done = false;
+
+ ASSERT_TRUE(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]) == TDM_ERROR_NONE);
+ ASSERT_TRUE(tdm_pp_commit(pp) == TDM_ERROR_NONE);
+
+ while (!done)
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+
+ DumpBuffers(b, temp);
+ }
+
+ DestroyPP();
+ DestroyBuffers();
+}
+
+TEST_P(TDMBackendPP, PPScaleTransformCSC)
+{
+ TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
+
+ ASSERT_TRUE(PreparePP() == true);
+
+ bool done;
+ tbm_format format1, format2;
+
+ format1 = formats[0];
+ if (format_count > 1)
+ format2 = formats[1];
+ else
+ format2 = formats[0];
+
+ TDM_INFO("format(%c%c%c%c) ------> format(%c%c%c%c)", FOURCC_STR(format1), FOURCC_STR(format2));
+
+ ASSERT_TRUE(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, format1,
+ TDM_UT_BUFFER_SIZE * 2, TDM_UT_BUFFER_SIZE * 2, format2,
+ TDM_TRANSFORM_NORMAL) == true);
+
+ ASSERT_TRUE(tdm_pp_set_done_handler(pp, _ut_tdm_pp_done_cb, &done) == TDM_ERROR_NONE);
+
+ for (int b = 0; b < 3; b++) {
+ done = false;
+
+ ASSERT_TRUE(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]) == TDM_ERROR_NONE);
+ ASSERT_TRUE(tdm_pp_commit(pp) == TDM_ERROR_NONE);
+
+ while (!done)
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+
+ DumpBuffers(b, NULL);
+ }
+
+ 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_TRUE(PreparePP() == true);
+
+ int done = 0;
+ int f = 0;
+ char temp[256];
+ snprintf(temp, sizeof temp, "%c%c%c%c", FOURCC_STR(formats[f]));
+
+ ASSERT_TRUE(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_TRUE(tdm_pp_set_done_handler(pp, _ut_tdm_pp_done_cb2, &done) == TDM_ERROR_NONE);
+ for (int b = 0; b < 3; b++)
+ ASSERT_TRUE(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]) == TDM_ERROR_NONE);
+
+ ASSERT_TRUE(tdm_pp_commit(pp) == TDM_ERROR_NONE);
+
+ while (done != 3)
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+
+ for (int b = 0; b < 3; b++)
+ DumpBuffers(b, temp);
+
+ DestroyBuffers();
+}
+
+TEST_P(TDMBackendPP, PPDestroyWithoutCommit)
+{
+ TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
+
+ ASSERT_TRUE(PreparePP() == true);
+
+ int f = 0;
+
+ ASSERT_TRUE(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_TRUE(tdm_pp_set_done_handler(pp, _ut_tdm_pp_done_cb2, NULL) == TDM_ERROR_NONE);
+ for (int b = 0; b < 3; b++)
+ ASSERT_TRUE(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_TRUE(PreparePP() == true);
+
+ int f = 0;
+
+ ASSERT_TRUE(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_TRUE(tdm_pp_set_done_handler(pp, _ut_tdm_pp_done_cb2, NULL) == TDM_ERROR_NONE);
+ for (int b = 0; b < 3; b++)
+ ASSERT_TRUE(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]) == TDM_ERROR_NONE);
+
+ ASSERT_TRUE(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
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);
return false;
}
-#ifdef UT_TDM_BUFFER_ENABLE
-
TEST_P(TDMBuffer, BufferRefBackend)
{
ASSERT_TRUE(tdm_buffer_ref_backend(buffer) == buffer);
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
+++ /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"
-
-class TDMCapture : public TDMOutput {
-public:
- 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;
-
- TDMCapture();
- void SetUp(void);
- void TearDown(void);
-
- bool FindFormat(tbm_format fmt);
- bool TestPrepareDefault(void);
- bool TestPrepare(int output_idx, int w, int h, tbm_format fmt, tdm_transform t, tdm_capture_type c, int frequency);
- void TestDone(void);
- void DumpBuffers(int b, char *test);
- void DestroyBuffers(void);
-};
-
-TDMCapture::TDMCapture()
-{
- 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;
-}
-
-void TDMCapture::SetUp(void)
-{
- TDMOutput::SetUp();
-
- tdm_error ret;
- tdm_output *output;
-
- if (!has_capture_cap)
- return;
-
- for (int o = 0; o < output_count; o++) {
- output = tdm_display_get_output(dpy, o, &ret);
- ASSERT_TRUE(ret == TDM_ERROR_NONE);
- ASSERT_TRUE(output != NULL);
-
- if (!ut_tdm_output_is_connected(output))
- continue;
-
- ASSERT_TRUE(ut_tdm_output_prepare(dpy, output) == true);
- }
-}
-
-void TDMCapture::TearDown(void)
-{
- if (capture)
- tdm_capture_destroy(capture);
-
- DestroyBuffers();
-
- TDMOutput::TearDown();
-}
-
-bool TDMCapture::TestPrepareDefault(void)
-{
- tdm_error ret;
-
- TDM_UT_RETURN_FALSE_IF_FAIL(has_outputs == true);
- TDM_UT_RETURN_FALSE_IF_FAIL(outputs != NULL);
- TDM_UT_RETURN_FALSE_IF_FAIL(output_count > 0);
-
- 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_formats(dpy, &formats, &format_count) == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(formats != NULL);
- TDM_UT_RETURN_FALSE_IF_FAIL(format_count > 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);
-
- 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, &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 TDMCapture::FindFormat(tbm_format fmt)
-{
- bool found = false;
-
- 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_formats(dpy, &formats, &format_count) == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(formats != NULL);
- TDM_UT_RETURN_FALSE_IF_FAIL(format_count > 0);
-
- for (int f = 0; f < format_count; f++) {
- if (formats[f] == fmt) {
- found = true;
- break;
- }
- }
-
- return found;
-}
-
-bool TDMCapture::TestPrepare(int output_idx, int w, int h, tbm_format fmt, tdm_transform t, tdm_capture_type c, int frequency)
-{
- tdm_error ret;
-
- TDM_UT_RETURN_FALSE_IF_FAIL(has_outputs == true);
- 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(FindFormat(fmt) == true);
-
- 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);
-
- TDM_UT_RETURN_FALSE_IF_FAIL(ut_tdm_buffer_create(w, h, fmt, 0, false, 3, buffers) == true);
- TDM_UT_RETURN_FALSE_IF_FAIL(ut_tdm_capture_fill_info(outputs[output_idx], buffers[0], t, c, frequency, &info) == true);
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_capture_set_info(capture, &info) == TDM_ERROR_NONE);
-
- output = outputs[output_idx];
-
- return true;
-}
-
-void TDMCapture::TestDone(void)
-{
- if (capture) {
- tdm_capture_destroy(capture);
- capture = NULL;
- }
-
- DestroyBuffers();
-}
-
-void TDMCapture::DumpBuffers(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 TDMCapture::DestroyBuffers(void)
-{
- for (int b = 0; b < 3; b++) {
- tbm_surface_destroy(buffers[b]);
- buffers[b] = NULL;
- }
-}
-
-bool
-ut_tdm_capture_fill_info(tdm_output *output, tbm_surface_h buffer, tdm_transform transform,
- tdm_capture_type type, int frequency, tdm_info_capture *info)
-{
- int bw, bh;
-
- 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;
- 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);
- info->dst_config.format = tbm_surface_get_format(buffer);
-
- info->transform = transform;
- info->type = type;
- info->flags = 0;
-
- if (frequency <= 0) {
- 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);
- frequency = mode->vrefresh;
- }
-
- info->frequency = frequency;
-
- TDM_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.h,
- 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;
-}
-
-#ifdef UT_TDM_CAPTURE_ENABLE
-
-static tbm_format test_formats[] = {
- TBM_FORMAT_ARGB8888,
- TBM_FORMAT_XRGB8888,
- TBM_FORMAT_YUV420,
- TBM_FORMAT_YVU420,
- TBM_FORMAT_NV12,
- TBM_FORMAT_NV21,
-};
-
-#define TEST_FORMAT_CNT (int)(sizeof(test_formats) / sizeof((test_formats)[0]))
-
-TEST_P(TDMCapture, CaptureDispalyGetAvaiableFormats)
-{
- const tbm_format *formats = (const tbm_format *)TDM_UT_INVALID_VALUE;
- int count = TDM_UT_INVALID_VALUE;
- if (has_capture_cap) {
- ASSERT_TRUE(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_TRUE(tdm_display_get_capture_available_formats(dpy, &formats, &count) == TDM_ERROR_NO_CAPABILITY);
- ASSERT_TRUE(formats == (const tbm_format *)TDM_UT_INVALID_VALUE);
- ASSERT_TRUE(count == TDM_UT_INVALID_VALUE);
- }
-}
-
-TEST_P(TDMCapture, CaptureDispalyGetAvaiableFormatsNullObject)
-{
- const tbm_format *formats = (const tbm_format *)TDM_UT_INVALID_VALUE;
- int count = TDM_UT_INVALID_VALUE;
- ASSERT_TRUE(tdm_display_get_capture_available_formats(NULL, &formats, &count) == TDM_ERROR_INVALID_PARAMETER);
- ASSERT_TRUE(formats == (const tbm_format *)TDM_UT_INVALID_VALUE);
- ASSERT_TRUE(count == TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMCapture, CaptureDispalyGetAvaiableFormatsNullOther)
-{
- ASSERT_TRUE(tdm_display_get_capture_available_formats(dpy, NULL, NULL) == TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMCapture, 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_TRUE(tdm_display_get_capture_available_size(dpy, &min_w, &min_h, &max_w, &max_h, &preferred_align) == TDM_ERROR_NONE);
- ASSERT_TRUE(min_w != TDM_UT_INVALID_VALUE);
- ASSERT_TRUE(min_h != TDM_UT_INVALID_VALUE);
- ASSERT_TRUE(max_w != TDM_UT_INVALID_VALUE);
- ASSERT_TRUE(max_h != TDM_UT_INVALID_VALUE);
- ASSERT_TRUE(preferred_align != TDM_UT_INVALID_VALUE);
- } else {
- ASSERT_TRUE(tdm_display_get_capture_available_size(dpy, &min_w, &min_h, &max_w, &max_h, &preferred_align) == TDM_ERROR_NO_CAPABILITY);
- ASSERT_TRUE(min_w == TDM_UT_INVALID_VALUE);
- ASSERT_TRUE(min_h == TDM_UT_INVALID_VALUE);
- ASSERT_TRUE(max_w == TDM_UT_INVALID_VALUE);
- ASSERT_TRUE(max_h == TDM_UT_INVALID_VALUE);
- ASSERT_TRUE(preferred_align == TDM_UT_INVALID_VALUE);
- }
-}
-
-TEST_P(TDMCapture, 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_TRUE(tdm_display_get_capture_available_size(NULL, &min_w, &min_h, &max_w, &max_h, &preferred_align) == TDM_ERROR_INVALID_PARAMETER);
- ASSERT_TRUE(min_w == TDM_UT_INVALID_VALUE);
- ASSERT_TRUE(min_h == TDM_UT_INVALID_VALUE);
- ASSERT_TRUE(max_w == TDM_UT_INVALID_VALUE);
- ASSERT_TRUE(max_h == TDM_UT_INVALID_VALUE);
- ASSERT_TRUE(preferred_align == TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMCapture, CaptureDispalyGetAvaiableSizeNullOther)
-{
- if (has_capture_cap)
- ASSERT_TRUE(tdm_display_get_capture_available_size(dpy, NULL, NULL, NULL, NULL, NULL) == TDM_ERROR_NONE);
- else
- ASSERT_TRUE(tdm_display_get_capture_available_size(dpy, NULL, NULL, NULL, NULL, NULL) == TDM_ERROR_NO_CAPABILITY);
-}
-
-TEST_P(TDMCapture, CaptureDestroy)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
-
- ASSERT_TRUE(TestPrepareDefault() == true);
-
- TestDone();
-}
-
-TEST_P(TDMCapture, CaptureDestroyNullObject)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
-
- tdm_capture_destroy(NULL);
-}
-
-TEST_P(TDMCapture, CaptureSetInfo)
-{
- /* tested in CaptureNoScaleNoTransformNoCSC */
-}
-
-TEST_P(TDMCapture, CaptureSetInfoNullObject)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
-
- tdm_info_capture info;
- memset(&info, 0, sizeof info);
- ASSERT_TRUE(tdm_capture_set_info(NULL, &info) == TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMCapture, CaptureSetInfoNullOther)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
-
- ASSERT_TRUE(TestPrepareDefault() == true);
-
- ASSERT_TRUE(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(TDMCapture, CaptureSetDoneHandler)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
-
- ASSERT_TRUE(TestPrepareDefault() == true);
-
- ASSERT_TRUE(tdm_capture_set_done_handler(capture, _ut_tdm_capture_done_cb, NULL) == TDM_ERROR_NONE);
-
- TestDone();
-}
-
-TEST_P(TDMCapture, CaptureSetDoneHandlerNullObject)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
-
- ASSERT_TRUE(tdm_capture_set_done_handler(NULL, _ut_tdm_capture_done_cb, NULL) == TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMCapture, CaptureSetDoneHandlerNullOther)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
-
- ASSERT_TRUE(TestPrepareDefault() == true);
-
- ASSERT_TRUE(tdm_capture_set_done_handler(capture, NULL, NULL) == TDM_ERROR_INVALID_PARAMETER);
-
- TestDone();
-}
-
-TEST_P(TDMCapture, CaptureAttach)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
-
- for (int o = 0; o < output_count; o++) {
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- for (int f = 0; f < TEST_FORMAT_CNT; f++) {
- if (!FindFormat(test_formats[f]))
- continue;
-
- ASSERT_TRUE(TestPrepare(o, TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, test_formats[f],
- TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1) == true);
-
- for (int b = 0; b < 3; b++)
- ASSERT_TRUE(tdm_capture_attach(capture, buffers[b]) == TDM_ERROR_NONE);
-
- TestDone();
- }
- }
-}
-
-TEST_P(TDMCapture, CaptureAttachNullObject)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
-
- tbm_surface_h buffer = (tbm_surface_h)TDM_UT_BUFFER_SIZE;
-
- ASSERT_TRUE(tdm_capture_attach(NULL, buffer) == TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMCapture, CaptureAttachNullOther)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
-
- ASSERT_TRUE(TestPrepareDefault() == true);
-
- ASSERT_TRUE(tdm_capture_attach(capture, NULL) == TDM_ERROR_INVALID_PARAMETER);
-
- TestDone();
-}
-
-TEST_P(TDMCapture, CaptureCommit)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
-
- ASSERT_TRUE(TestPrepareDefault() == true);
-
- ASSERT_TRUE(tdm_capture_commit(capture) == TDM_ERROR_NONE);
-
- TestDone();
-}
-
-TEST_P(TDMCapture, CaptureCommitNullOBject)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
-
- ASSERT_TRUE(tdm_capture_commit(NULL) == TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMCapture, CaptureCommitDpmsOff)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
-
- ASSERT_TRUE(TestPrepareDefault() == true);
-
- ASSERT_TRUE(ut_tdm_output_unset(dpy, output) == true);
-
- ASSERT_TRUE(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF) == TDM_ERROR_NONE);
-
- ASSERT_TRUE(tdm_capture_commit(capture) == TDM_ERROR_BAD_REQUEST);
-
- TestDone();
-}
-
-TEST_P(TDMCapture, CaptureNoScaleNoTransformNoCSC)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
-
- 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_TRUE(tdm_output_get_mode(outputs[o], &mode) == TDM_ERROR_NONE);
-
- for (int f = 0; f < TEST_FORMAT_CNT; f++) {
- char temp[256];
- snprintf(temp, sizeof temp, "%c%c%c%c", FOURCC_STR(test_formats[f]));
-
- if (!FindFormat(test_formats[f]))
- continue;
-
- ASSERT_TRUE(TestPrepare(o, mode->hdisplay, mode->vdisplay, test_formats[f],
- TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1) == true);
-
- ASSERT_TRUE(tdm_capture_set_done_handler(capture, _ut_tdm_capture_done_cb, &done) == TDM_ERROR_NONE);
-
- for (int b = 0; b < 3; b++) {
- done = false;
- ASSERT_TRUE(tdm_capture_attach(capture, buffers[b]) == TDM_ERROR_NONE);
- ASSERT_TRUE(tdm_capture_commit(capture) == TDM_ERROR_NONE);
-
- while (!done)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
-
- DumpBuffers(b, temp);
- }
-
- TestDone();
- }
- }
-}
-
-TEST_P(TDMCapture, CaptureScaleTransformCSC)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
-
- 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_TRUE(tdm_output_get_mode(outputs[o], &mode) == TDM_ERROR_NONE);
-
- for (int f = 0; f < TEST_FORMAT_CNT; f++) {
- char temp[256];
- snprintf(temp, sizeof temp, "%c%c%c%c", FOURCC_STR(test_formats[f]));
-
- if (!FindFormat(test_formats[f]))
- continue;
-
- ASSERT_TRUE(TestPrepare(o, TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, test_formats[f],
- TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1) == true);
-
- ASSERT_TRUE(tdm_capture_set_done_handler(capture, _ut_tdm_capture_done_cb, &done) == TDM_ERROR_NONE);
-
- for (int b = 0; b < 3; b++) {
- done = false;
- ASSERT_TRUE(tdm_capture_attach(capture, buffers[b]) == TDM_ERROR_NONE);
- ASSERT_TRUE(tdm_capture_commit(capture) == TDM_ERROR_NONE);
-
- while (!done)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
-
- DumpBuffers(b, temp);
- }
-
- 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(TDMCapture, CaptureAttachFewTimesInOneCommit)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
-
- for (int o = 0; o < output_count; o++) {
- const tdm_output_mode *mode = NULL;
- int done = 0;
- int f = 0;
-
- if (!ut_tdm_output_is_connected(outputs[o]))
- continue;
-
- ASSERT_TRUE(tdm_output_get_mode(outputs[o], &mode) == TDM_ERROR_NONE);
-
- char temp[256];
- snprintf(temp, sizeof temp, "%c%c%c%c", FOURCC_STR(test_formats[f]));
-
- if (!FindFormat(test_formats[f]))
- continue;
-
- ASSERT_TRUE(TestPrepare(o, TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, test_formats[f],
- TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1) == true);
-
- ASSERT_TRUE(tdm_capture_set_done_handler(capture, _ut_tdm_capture_done_cb2, &done) == TDM_ERROR_NONE);
-
- done = 0;
-
- for (int b = 0; b < 3; b++)
- ASSERT_TRUE(tdm_capture_attach(capture, buffers[b]) == TDM_ERROR_NONE);
-
- ASSERT_TRUE(tdm_capture_commit(capture) == TDM_ERROR_NONE);
- while (done != 3)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
-
- for (int b = 0; b < 3; b++)
- DumpBuffers(b, temp);
-
- TestDone();
- }
-}
-
-TEST_P(TDMCapture, CaptureDestroyWithoutCommit)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
-
- 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_TRUE(tdm_output_get_mode(outputs[o], &mode) == TDM_ERROR_NONE);
-
- if (!FindFormat(test_formats[f]))
- continue;
-
- ASSERT_TRUE(TestPrepare(o, TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, test_formats[f],
- TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1) == true);
-
- ASSERT_TRUE(tdm_capture_set_done_handler(capture, _ut_tdm_capture_done_cb2, NULL) == TDM_ERROR_NONE);
-
- for (int b = 0; b < 3; b++)
- ASSERT_TRUE(tdm_capture_attach(capture, buffers[b]) == TDM_ERROR_NONE);
-
- tdm_capture_destroy(capture);
- capture = NULL;
-
- TestDone();
- }
-}
-
-TEST_P(TDMCapture, CaptureDestroyBeforeDone)
-{
- TDM_UT_SKIP_FLAG(has_capture_cap);
-
- 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_TRUE(tdm_output_get_mode(outputs[o], &mode) == TDM_ERROR_NONE);
-
- if (!FindFormat(test_formats[f]))
- continue;
-
- ASSERT_TRUE(TestPrepare(o, TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, test_formats[f],
- TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1) == true);
-
- ASSERT_TRUE(tdm_capture_set_done_handler(capture, _ut_tdm_capture_done_cb2, NULL) == TDM_ERROR_NONE);
-
- for (int b = 0; b < 3; b++)
- ASSERT_TRUE(tdm_capture_attach(capture, buffers[b]) == TDM_ERROR_NONE);
-
- ASSERT_TRUE(tdm_capture_commit(capture) == TDM_ERROR_NONE);
-
- tdm_capture_destroy(capture);
- capture = NULL;
-
- TestDone();
- }
-}
-
-INSTANTIATE_TEST_CASE_P(TDMCaptureParams,
- TDMCapture,
- Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
-
-#endif
enum {
TDM_UT_PIPE_MSG_NONE,
+ TDM_UT_PIPE_MSG_REPLY,
TDM_UT_PIPE_MSG_SERVER_READY,
TDM_UT_PIPE_MSG_DPMS_ON,
TDM_UT_PIPE_MSG_DPMS_OFF,
};
static int _ut_tdm_pipe_read_msg(int fd);
-static bool _ut_tdm_pipe_write_msg(int fd, int msg);
+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:
- pid_t server_pid;
+ static pid_t server_pid;
/* 0: read, 1: write */
- int pipe_parent[2];
- int pipe_child[2];
+ static int pipe_parent[2];
+ static int pipe_child[2];
tdm_client *client;
tdm_client_output *output;
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);
};
-TDMClient::TDMClient()
+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_TRUE(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) {
+ _ut_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_TERMINATE_SERVER);
+ waitpid(server_pid, NULL, 0);
+ TDM_INFO("*** server terminated ***");
+ }
+ 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;
{
TDMEnv::SetUp();
- server_pid = _ut_tdm_client_server_fork(pipe_parent, pipe_child);
- ASSERT_TRUE(server_pid > 0);
+ if (server_pid == -1)
+ ServerFork();
}
void TDMClient::TearDown(void)
{
+ ASSERT_TRUE(_ut_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_ON) == true);
+
if (vblank)
tdm_client_vblank_destroy(vblank);
if (client)
tdm_client_destroy(client);
- if (pipe_child[0] >= 0)
- close(pipe_child[0]);
- if (pipe_child[1] >= 0) {
- _ut_tdm_pipe_write_msg(pipe_child[1], TDM_UT_PIPE_MSG_TERMINATE_SERVER);
- if (server_pid > 0)
- waitpid(server_pid, NULL, 0);
- TDM_INFO("*** server terminated ***");
- close(pipe_child[1]);
- }
-
- if (pipe_parent[0] >= 0)
- close(pipe_parent[0]);
- if (pipe_parent[1] >= 0)
- close(pipe_parent[1]);
-
TDMEnv::TearDown();
}
static int
_ut_tdm_pipe_read_msg(int fd)
{
- char buffer[1024];
ssize_t len;
- int *msg;
+ int msg;
do {
- len = read(fd, buffer, sizeof buffer);
+ len = read(fd, &msg, sizeof msg);
} while (len < 0 && errno == EINTR);
if (len <= 0)
- return TDM_UT_PIPE_MSG_NONE;
-
- msg = (int*)buffer;
+ msg = TDM_UT_PIPE_MSG_NONE;
- return *msg;
+ return msg;
}
static bool
-_ut_tdm_pipe_write_msg(int fd, int msg)
+_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;
}
if (!ut_tdm_output_is_connected(output))
continue;
- TDM_UT_GOTO_IF_FAIL(ut_tdm_output_prepare(dpy, output) == true, done);
+ TDM_UT_GOTO_IF_FAIL(ut_tdm_output_prepare(dpy, output, true) == true, done);
}
- TDM_UT_GOTO_IF_FAIL(_ut_tdm_pipe_write_msg(pipe_parent[1], TDM_UT_PIPE_MSG_SERVER_READY) == true, done);
+ 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 ***");
}
if (fds[0].revents & POLLIN)
- ret = tdm_display_handle_events(dpy);
+ 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:
return -1;
}
-#ifdef UT_TDM_CLIENT_ENABLE
-
TEST_P(TDMClient, ClientCreate)
{
tdm_error ret;
ASSERT_TRUE(tdm_client_get_fd(client, NULL) == TDM_ERROR_INVALID_PARAMETER);
}
-/* tdm_client_handle_events */
+/* tdm_client_handle_events_timeout */
TEST_P(TDMClient, DISABLED_ClientHandleEvent)
{
ASSERT_TRUE(PrepareClient() == true);
-// ASSERT_TRUE(tdm_client_handle_events(client) == TDM_ERROR_NONE);
+// ASSERT_TRUE(tdm_client_handle_events_timeout(client, 3000) == TDM_ERROR_NONE);
}
TEST_P(TDMClient, ClientHandleEventNullObject)
{
- ASSERT_TRUE(tdm_client_handle_events(NULL) == TDM_ERROR_INVALID_PARAMETER);
+ ASSERT_TRUE(tdm_client_handle_events_timeout(NULL, 3000) == TDM_ERROR_INVALID_PARAMETER);
}
static void
ASSERT_TRUE(done == false);
while (!done)
- ASSERT_TRUE(tdm_client_handle_events(client) == TDM_ERROR_NONE);
+ ASSERT_TRUE(tdm_client_handle_events_timeout(client, 3000) == TDM_ERROR_NONE);
}
/* tdm_client_get_output */
ASSERT_TRUE(PrepareOutput() == true);
ASSERT_TRUE(tdm_client_output_add_change_handler(output, _ut_tdm_client_output_change_dpms_cb, &done) == TDM_ERROR_NONE);
- ASSERT_TRUE(_ut_tdm_pipe_write_msg(pipe_child[1], TDM_UT_PIPE_MSG_DPMS_OFF) == true);
+ ASSERT_TRUE(_ut_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_OFF) == true);
while (!done)
- ASSERT_TRUE(tdm_client_handle_events(client) == TDM_ERROR_NONE);
+ ASSERT_TRUE(tdm_client_handle_events_timeout(client, 3000) == TDM_ERROR_NONE);
ASSERT_TRUE(tdm_client_output_get_dpms(output, &dpms) == TDM_ERROR_NONE);
ASSERT_TRUE(dpms == TDM_OUTPUT_DPMS_OFF);
tdm_value value,
void *user_data)
{
- bool *done = (bool *)user_data;
-
switch (type) {
case TDM_OUTPUT_CHANGE_DPMS:
- if (done)
- *done = true;
tdm_client_output_remove_change_handler(output, _ut_tdm_client_output_change_dpms_cb2, user_data);
break;
default:
TEST_P(TDMClient, ClientOutputRemoveChangeHandlerInHandler)
{
- bool done;
- tdm_output_dpms dpms;
+ tdm_output_dpms dpms = TDM_OUTPUT_DPMS_ON;
ASSERT_TRUE(PrepareClient() == true);
ASSERT_TRUE(PrepareOutput() == true);
- done = false;
- ASSERT_TRUE(tdm_client_output_add_change_handler(output, _ut_tdm_client_output_change_dpms_cb2, &done) == TDM_ERROR_NONE);
-
- ASSERT_TRUE(_ut_tdm_pipe_write_msg(pipe_child[1], TDM_UT_PIPE_MSG_DPMS_OFF) == true);
- while (!done)
- ASSERT_TRUE(tdm_client_handle_events(client) == TDM_ERROR_NONE);
- ASSERT_TRUE(tdm_client_output_get_dpms(output, &dpms) == TDM_ERROR_NONE);
- ASSERT_TRUE(dpms == TDM_OUTPUT_DPMS_OFF);
-
- done = false;
- ASSERT_TRUE(tdm_client_output_add_change_handler(output, _ut_tdm_client_output_change_dpms_cb2, &done) == TDM_ERROR_NONE);
- ASSERT_TRUE(_ut_tdm_pipe_write_msg(pipe_child[1], TDM_UT_PIPE_MSG_DPMS_ON) == true);
- while (!done)
- ASSERT_TRUE(tdm_client_handle_events(client) == TDM_ERROR_NONE);
- ASSERT_TRUE(tdm_client_output_get_dpms(output, &dpms) == TDM_ERROR_NONE);
- ASSERT_TRUE(dpms == TDM_OUTPUT_DPMS_ON);
-
- done = false;
- ASSERT_TRUE(tdm_client_output_add_change_handler(output, _ut_tdm_client_output_change_dpms_cb2, &done) == TDM_ERROR_NONE);
- ASSERT_TRUE(_ut_tdm_pipe_write_msg(pipe_child[1], TDM_UT_PIPE_MSG_DPMS_OFF) == true);
- while (!done)
- ASSERT_TRUE(tdm_client_handle_events(client) == TDM_ERROR_NONE);
+ ASSERT_TRUE(tdm_client_output_add_change_handler(output, _ut_tdm_client_output_change_dpms_cb2, NULL) == TDM_ERROR_NONE);
+ ASSERT_TRUE(_ut_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_OFF) == true);
ASSERT_TRUE(tdm_client_output_get_dpms(output, &dpms) == TDM_ERROR_NONE);
- ASSERT_TRUE(dpms == TDM_OUTPUT_DPMS_OFF);
+ while (dpms != TDM_OUTPUT_DPMS_OFF) {
+ ASSERT_TRUE(tdm_client_handle_events_timeout(client, 3000) == TDM_ERROR_NONE);
+ ASSERT_TRUE(tdm_client_output_get_dpms(output, &dpms) == TDM_ERROR_NONE);
+ }
}
TEST_P(TDMClient, ClientOutputRemoveChangeHandlerNullObject)
start = tdm_helper_get_time();
while (!done)
- ASSERT_TRUE(tdm_client_handle_events(client) == TDM_ERROR_NONE);
+ ASSERT_TRUE(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 */
start = tdm_helper_get_time();
while(!done1 || !done2 || !done3)
- ASSERT_TRUE(tdm_client_handle_events(client) == TDM_ERROR_NONE);
+ ASSERT_TRUE(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 */
start = tdm_helper_get_time();
while (!done)
- ASSERT_TRUE(tdm_client_handle_events(client) == TDM_ERROR_NONE);
+ ASSERT_TRUE(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_TRUE(tdm_client_vblank_wait(vblank, 1, _ut_tdm_client_vblank_cb3, &cur_seq) == TDM_ERROR_NONE);
while (cur_seq == 0)
- ASSERT_TRUE(tdm_client_handle_events(client) == TDM_ERROR_NONE);
+ ASSERT_TRUE(tdm_client_handle_events_timeout(client, 3000) == TDM_ERROR_NONE);
start = tdm_helper_get_time();
ASSERT_TRUE(tdm_client_vblank_wait_seq(vblank, cur_seq + 1, _ut_tdm_client_vblank_cb3, &temp) == TDM_ERROR_NONE);
while (temp == 0)
- ASSERT_TRUE(tdm_client_handle_events(client) == TDM_ERROR_NONE);
+ ASSERT_TRUE(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_TRUE(tdm_client_vblank_wait(vblank, 1, _ut_tdm_client_vblank_cb3, &cur_seq) == TDM_ERROR_NONE);
while (cur_seq == 0)
- ASSERT_TRUE(tdm_client_handle_events(client) == TDM_ERROR_NONE);
+ ASSERT_TRUE(tdm_client_handle_events_timeout(client, 3000) == TDM_ERROR_NONE);
start = tdm_helper_get_time();
ASSERT_TRUE(tdm_client_vblank_wait_seq(vblank, cur_seq + t, _ut_tdm_client_vblank_cb3, &temp) == TDM_ERROR_NONE);
while (temp == 0)
- ASSERT_TRUE(tdm_client_handle_events(client) == TDM_ERROR_NONE);
+ ASSERT_TRUE(tdm_client_handle_events_timeout(client, 3000) == TDM_ERROR_NONE);
end = tdm_helper_get_time();
-#if 0
-printf("@@@ %s(%d) cur_seq(%d) t(%d) start(%.6f) end(%.6f) diff(%.6f) (%.6f~%.6f)\n",
-__FUNCTION__, __LINE__, cur_seq, t, start, end, end - start, (interval * (t - 1)), (interval * t + interval));
-#endif
-
/* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
ASSERT_TRUE((end - start) > (vrefresh_interval * (t - 1)));
ASSERT_TRUE((end - start) < (vrefresh_interval * t + vrefresh_interval));
ASSERT_TRUE(PrepareOutput() == true);
ASSERT_TRUE(PrepareVblank() == true);
- ASSERT_TRUE(_ut_tdm_pipe_write_msg(pipe_child[1], TDM_UT_PIPE_MSG_DPMS_OFF) == true);
+ ASSERT_TRUE(_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_TRUE(tdm_client_output_get_dpms(output, &dpms) == TDM_ERROR_NONE);
ASSERT_TRUE(dpms == TDM_OUTPUT_DPMS_OFF);
ASSERT_TRUE(PrepareOutput() == true);
ASSERT_TRUE(PrepareVblank() == true);
- ASSERT_TRUE(_ut_tdm_pipe_write_msg(pipe_child[1], TDM_UT_PIPE_MSG_DPMS_OFF) == true);
+ ASSERT_TRUE(_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_TRUE(tdm_client_output_get_dpms(output, &dpms) == TDM_ERROR_NONE);
ASSERT_TRUE(tdm_client_vblank_wait(vblank, 1, _ut_tdm_client_vblank_cb2, &done) == TDM_ERROR_NONE);
while (!done)
- ASSERT_TRUE(tdm_client_handle_events(client) == TDM_ERROR_NONE);
+ ASSERT_TRUE(tdm_client_handle_events_timeout(client, 3000) == TDM_ERROR_NONE);
}
TEST_P(TDMClient, ClientVblankWaitSetOffset)
start = tdm_helper_get_time();
while (!done)
- ASSERT_TRUE(tdm_client_handle_events(client) == TDM_ERROR_NONE);
+ ASSERT_TRUE(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 */
start = tdm_helper_get_time();
while (!done)
- ASSERT_TRUE(tdm_client_handle_events(client) == TDM_ERROR_NONE);
+ ASSERT_TRUE(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 */
start = tdm_helper_get_time();
while (cur_seq[0] == 0)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
end = tdm_helper_get_time();
ASSERT_TRUE(cur_seq[1] != 0);
}
while (cur_seq[0] == 0)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
ASSERT_TRUE(cur_seq[1] == 0);
ASSERT_TRUE(cur_seq[2] == 0);
while (cur_seq[1] == 0)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
ASSERT_TRUE(cur_seq[2] == 0);
}
start = tdm_helper_get_time();
while (cur_seq[1] == 0)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
end = tdm_helper_get_time();
ASSERT_TRUE(cur_seq[0] == 0);
ASSERT_TRUE((end - start) < (interval + interval));
while (cur_seq[0] == 0)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
ASSERT_TRUE(cur_seq[2] != 0);
}
#endif
+#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
TDMEnv::TearDown();
}
-#ifdef UT_TDM_DISPLAY_ENABLE
+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)
{
TEST_P(TDMDisplay, DISABLED_DisplayHandleEvents)
{
/* TODO Generate events*/
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
}
TEST_P(TDMDisplay, DisplayFlush)
ASSERT_TRUE(pp == NULL);
}
-TEST_P(TDMDisplay, BackendGetInfo)
+TEST_P(TDMDisplay, ModuleGetInfo)
{
tdm_output *output;
int o, count = TDM_UT_INVALID_VALUE;
}
}
-TEST_P(TDMDisplay, BackendGetInfoNullObject)
+TEST_P(TDMDisplay, ModuleGetInfoNullObject)
{
const char *name = (const char *)TDM_UT_INVALID_VALUE;
const char *vendor = (const char *)TDM_UT_INVALID_VALUE;
ASSERT_TRUE(minor == TDM_UT_INVALID_VALUE);
}
-TEST_P(TDMDisplay, BackendGetInfoNullOther)
+TEST_P(TDMDisplay, ModuleGetInfoNullOther)
{
tdm_output *output;
int o, count = TDM_UT_INVALID_VALUE;
}
}
+#ifdef TDM_UT_TEST_WITH_PARAMS
INSTANTIATE_TEST_CASE_P(TDMDisplayParams,
TDMDisplay,
Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
-
-#endif
+#else
+INSTANTIATE_TEST_CASE_P(TDMDisplayParams,
+ TDMDisplay,
+ Values(TDM_DEFAULT_MODULE));
+#endif
\ No newline at end of file
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);
- tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_THREAD, ::testing::get<0>(GetParam()));
- tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_COMMIT_PER_VBLANK, ::testing::get<1>(GetParam()));
-
- const char *debug = getenv("TDM_DEBUG_MODULE");
- if (debug && strstr(debug, "1"))
- tdm_config_set_string(TDM_CONFIG_KEY_DEBUG_MODULE, "buffer,thread,event,vblank,commit,pp,capture");
+#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,thread,event,vblank,commit,pp,capture");
}
void TDMEnv::TearDown(void)
unsetenv("TBM_DISPLAY_SERVER");
}
-#ifdef UT_TDM_ENV_ENABLE
-
TEST_P(TDMEnv, DisplayInitDeinit)
{
tdm_display *dpy;
tdm_display_deinit(dpy);
}
+#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
TDMDisplay::TearDown();
}
-#ifdef UT_TDM_EVENT_LOOP_ENABLE
-
static tdm_error
_ut_tdm_event_loop_fd_cb(int fd, tdm_event_loop_mask mask, void *user_data)
{
//TODO
// while (!done)
-// ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+// ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
tdm_event_loop_source_remove(source);
//TODO
// while (!done)
-// ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+// ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
tdm_event_loop_source_remove(source);
ASSERT_TRUE(tdm_event_loop_source_timer_update(source, 100) == TDM_ERROR_NONE);
//TODO
// while (!done)
-// ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+// ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
tdm_event_loop_source_remove(source);
}
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
TDMOutput::TearDown();
}
-#ifdef UT_TDM_HELPER_ENABLE
-
TEST_P(TDMHelper, HelperGetTime)
{
ASSERT_TRUE(tdm_helper_get_time() > 0.0);
if (!ut_tdm_output_is_connected(output))
continue;
- ASSERT_TRUE(ut_tdm_output_prepare(dpy, output) == true);
+ ASSERT_TRUE(ut_tdm_output_prepare(dpy, output, true) == true);
dump = tbm_surface_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, TBM_FORMAT_ARGB8888);
ASSERT_TRUE(dump != NULL);
ASSERT_TRUE(output != NULL);
if (!ut_tdm_output_is_connected(output))
continue;
- ASSERT_TRUE(ut_tdm_output_prepare(dpy, output) == true);
+ ASSERT_TRUE(ut_tdm_output_prepare(dpy, output, true) == true);
}
tdm_helper_get_display_information(dpy, reply, &len);
tdm_helper_output_commit_per_vblank_enabled(NULL);
}
+#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
TDMOutput::TearDown();
}
-#ifdef UT_TDM_HWC_WINDOW_ENABLE
-
/* tdm_error tdm_output_hwc_destroy_window(tdm_output *output, tdm_hwc_window *hwc_window); */
TEST_P(TDMHwcWindow, DestroyWindowFailNull)
{
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)));
-#endif
+#else
+INSTANTIATE_TEST_CASE_P(TDMHwcWindowParams,
+ TDMHwcWindow,
+ Values(TDM_DEFAULT_MODULE));
+#endif
\ No newline at end of file
void TDMLayer::TearDown(void)
{
+ for (int l = 0; l < layer_count; l++) {
+ ASSERT_TRUE(tdm_layer_unset_buffer(layers[l]) == TDM_ERROR_NONE);
+ }
+
free(layers);
DestroyBuffers();
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)
{
}
bool
-ut_tdm_layer_prepare_buffer(tdm_layer *layer, tbm_surface_h *buffers, int buffer_count)
+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);
- 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);
+ 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_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 = TDM_UT_BUFFER_SIZE;
- h = TDM_UT_BUFFER_SIZE;
+ 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, true, buffer_count, buffers) == true);
+ 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");
TDM_UT_RETURN_FALSE_IF_FAIL(zpos >= 0);
if (w == -1 || h == -1 || format == 0) {
- w = TDM_UT_BUFFER_SIZE;
- h = TDM_UT_BUFFER_SIZE;
- format = TBM_FORMAT_ARGB8888;
+ w = mode->hdisplay;
+ h = mode->vdisplay;
+ format = ut_tdm_layer_find_best_format(layer);
}
/* TODO: check min,max,prefered size and avaiable formats */
info->dst_pos.x = 0;
info->dst_pos.y = 0;
} else {
- info->dst_pos.x = (mode->hdisplay - w) / count * zpos;
- info->dst_pos.y = (mode->vdisplay - h) / count * zpos;
+ info->dst_pos.x = ((mode->hdisplay - w) / count) * (zpos + 1);
+ info->dst_pos.y = ((mode->vdisplay - h) / count) * (zpos + 1);
}
info->dst_pos.w = w;
info->dst_pos.h = h;
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, zpos,
- info->src_config.size.h, info->src_config.size.h,
+ 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,
return true;
}
-#ifdef UT_TDM_LAYER_ENABLE
+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);
+
+ int bw = tbm_surface_get_width(buffer);
+ int bh = tbm_surface_get_height(buffer);
+ tbm_format bf = tbm_surface_get_format(buffer);
+
+ 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, bw, bh, bf, &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(layer, buffer) == 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++) {
+ 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_TRUE(tdm_layer_get_available_formats(layers[l], &formats, &count) == TDM_ERROR_NONE);
TEST_P(TDMLayer, LayerGetAvailableFormatsNullOther)
{
TDM_UT_SKIP_FLAG(has_layers);
-
+ if (!ut_tdm_layer_is_avaiable(layers[0]))
+ return;
ASSERT_TRUE(tdm_layer_get_available_formats(layers[0], NULL, NULL) == TDM_ERROR_INVALID_PARAMETER);
}
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_TRUE(tdm_layer_get_available_properties(layers[l], &props, &count) == TDM_ERROR_NONE);
ASSERT_TRUE(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);
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;
tdm_value value = {.s32 = 0};
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_TRUE(tdm_layer_get_available_properties(layers[l], &props, &count) == TDM_ERROR_NONE);
ASSERT_TRUE(tdm_layer_get_property(layers[0], 0, NULL) == TDM_ERROR_INVALID_PARAMETER);
}
-static bool
-_ut_tdm_layer_mode_setting_all_output(tdm_display *dpy, tdm_output **outputs, int output_count)
-{
- for (int o = 0; o < output_count; o++) {
- if (!ut_tdm_output_mode_setting(outputs[o]))
- return false;
- if (tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON) != TDM_ERROR_NONE)
- return false;
- }
- return true;
-}
-
TEST_P(TDMLayer, LayerSetInfo)
{
TDM_UT_SKIP_FLAG(has_layers);
- _ut_tdm_layer_mode_setting_all_output(dpy, outputs, output_count);
+ 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_TRUE(ut_tdm_layer_fill_info(layers[l], -1, -1, 0, &info) == true);
ASSERT_TRUE(tdm_layer_set_info(layers[l], &info) == TDM_ERROR_NONE);
ASSERT_TRUE(tdm_layer_set_info(layers[0], NULL) == TDM_ERROR_INVALID_PARAMETER);
}
-TEST_P(TDMLayer, LayerGetInfo)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- _ut_tdm_layer_mode_setting_all_output(dpy, outputs, output_count);
-
- for (int l = 0; l < layer_count; l++) {
- tdm_info_layer info, temp;
- ASSERT_TRUE(ut_tdm_layer_fill_info(layers[l], -1, -1, 0, &info) == true);
- ASSERT_TRUE(tdm_layer_set_info(layers[l], &info) == TDM_ERROR_NONE);
- ASSERT_TRUE(tdm_layer_commit(layers[l], NULL, NULL) == TDM_ERROR_NONE);
- ASSERT_TRUE(tdm_layer_get_info(layers[l], &temp) == TDM_ERROR_NONE);
- ASSERT_TRUE(memcmp(&info, &temp, sizeof info) == 0);
- }
-}
-
-TEST_P(TDMLayer, LayerGetInfoNoCommit)
+TEST_P(TDMLayer, DISABLED_LayerGetInfo)
{
- TDM_UT_SKIP_FLAG(has_layers);
-
- _ut_tdm_layer_mode_setting_all_output(dpy, outputs, output_count);
-
- for (int l = 0; l < layer_count; l++) {
- tdm_info_layer info, temp;
- ASSERT_TRUE(ut_tdm_layer_fill_info(layers[l], -1, -1, 0, &info) == true);
- ASSERT_TRUE(tdm_layer_set_info(layers[l], &info) == TDM_ERROR_NONE);
- ASSERT_TRUE(tdm_layer_get_info(layers[l], &temp) == TDM_ERROR_NONE);
- ASSERT_TRUE(memcmp(&info, &temp, sizeof info) != 0);
- }
}
TEST_P(TDMLayer, LayerGetInfoNullObject)
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_TRUE(tdm_layer_get_buffer_flags(layers[l], &flags) == TDM_ERROR_NONE);
ASSERT_TRUE(flags != (unsigned int)TDM_UT_INVALID_VALUE);
tdm_error ret;
- _ut_tdm_layer_mode_setting_all_output(dpy, outputs, output_count);
+ ut_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
for (int l = 0; l < layer_count; l++) {
- unsigned int usable;
+ if (!ut_tdm_layer_is_avaiable(layers[l]))
+ continue;
+
tdm_info_layer info;
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;
- ASSERT_TRUE(ut_tdm_layer_prepare_buffer(layers[l], buffers, 3) == true);
+ ASSERT_TRUE(ut_tdm_layer_prepare_buffer(layers[l], buffers, 3, true) == true);
/* set info */
int bw = tbm_surface_get_width(buffers[0]);
tbm_format bf = tbm_surface_get_format(buffers[0]);
ASSERT_TRUE(ut_tdm_layer_fill_info(layers[l], bw, bh, bf, &info) == true);
- ASSERT_TRUE(tdm_layer_is_usable(layers[l], &usable) == TDM_ERROR_NONE);
- ASSERT_TRUE(usable == 1);
ASSERT_TRUE(tdm_layer_set_info(layers[l], &info) == TDM_ERROR_NONE);
- ASSERT_TRUE(tdm_layer_is_usable(layers[l], &usable) == TDM_ERROR_NONE);
- ASSERT_TRUE(usable == 0);
/* set buffer & commit for 100 times */
- for (int t = 0; t < 100; t++) {
- tbm_surface_h displaying_buffer;
+ for (int t = 0; t < 10; t++) {
+ tbm_surface_h displaying_buffer = NULL;
ASSERT_TRUE(tdm_layer_set_buffer(layers[l], buffers[next_buffer]) == TDM_ERROR_NONE);
- done = false;
- ASSERT_TRUE(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb, &done) == TDM_ERROR_NONE);
- while (!done)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
- displaying_buffer = tdm_layer_get_displaying_buffer(layers[l], &ret);
- ASSERT_TRUE(ret == TDM_ERROR_NONE);
- ASSERT_TRUE(displaying_buffer == buffers[next_buffer]);
+ ASSERT_TRUE(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb, NULL) == TDM_ERROR_NONE);
+ while (displaying_buffer != buffers[next_buffer]) {
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ displaying_buffer = tdm_layer_get_displaying_buffer(layers[l], &ret);
+ ASSERT_TRUE(ret == TDM_ERROR_NONE);
+ }
next_buffer++;
if (next_buffer == 3)
next_buffer = 0;
}
- ASSERT_TRUE(tdm_layer_is_usable(layers[l], &usable) == TDM_ERROR_NONE);
- ASSERT_TRUE(usable == 0);
- ASSERT_TRUE(tdm_layer_unset_buffer(layers[l]) == TDM_ERROR_NONE);
- ASSERT_TRUE(tdm_layer_is_usable(layers[l], &usable) == TDM_ERROR_NONE);
- ASSERT_TRUE(usable == 1);
-
DestroyBuffers();
}
}
tdm_error ret;
- _ut_tdm_layer_mode_setting_all_output(dpy, outputs, output_count);
+ 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;
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;
- ASSERT_TRUE(ut_tdm_layer_prepare_buffer(layers[l], buffers, 3) == true);
+ ASSERT_TRUE(ut_tdm_layer_prepare_buffer(layers[l], buffers, 3, true) == true);
/* set info */
int bw = tbm_surface_get_width(buffers[0]);
/* set buffer & commit for 10 times */
for (int t = 0; t < 10; t++) {
- tbm_surface_h displaying_buffer;
+ tbm_surface_h displaying_buffer = NULL;
ASSERT_TRUE(tdm_layer_set_buffer(layers[l], buffers[next_buffer++]) == TDM_ERROR_NONE);
if (next_buffer == 3)
next_buffer = 0;
ASSERT_TRUE(tdm_layer_set_buffer(layers[l], buffers[next_buffer]) == TDM_ERROR_NONE);
- done = false;
- ASSERT_TRUE(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb, &done) == TDM_ERROR_NONE);
- while (!done) {
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ ASSERT_TRUE(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb, NULL) == TDM_ERROR_NONE);
+ while (displaying_buffer != buffers[next_buffer]) {
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ displaying_buffer = tdm_layer_get_displaying_buffer(layers[l], &ret);
+ ASSERT_TRUE(ret == TDM_ERROR_NONE);
}
- displaying_buffer = tdm_layer_get_displaying_buffer(layers[l], &ret);
- ASSERT_TRUE(ret == TDM_ERROR_NONE);
- ASSERT_TRUE(displaying_buffer == buffers[next_buffer]);
next_buffer++;
if (next_buffer == 3)
next_buffer = 0;
}
- ASSERT_TRUE(tdm_layer_unset_buffer(layers[l]) == TDM_ERROR_NONE);
-
DestroyBuffers();
}
}
{
TDM_UT_SKIP_FLAG(has_layers);
- _ut_tdm_layer_mode_setting_all_output(dpy, outputs, output_count);
+ 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;
- for (int l = 0; l < layer_count; l++)
ASSERT_TRUE(tdm_layer_unset_buffer(layers[l]) == TDM_ERROR_NONE);
+ }
}
TEST_P(TDMLayer, LayerUnsetBufferNullObject)
{
TDM_UT_SKIP_FLAG(has_layers);
- _ut_tdm_layer_mode_setting_all_output(dpy, outputs, output_count);
+ 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;
int next_buffer = 0;
continue;
if (ut_tdm_layer_is_video_layer(layers[l]))
continue;
+ if (ut_tdm_layer_is_primary_layer(layers[l]))
+ continue;
- ASSERT_TRUE(ut_tdm_layer_prepare_buffer(layers[l], buffers, 3) == true);
+ ASSERT_TRUE(ut_tdm_layer_prepare_buffer(layers[l], buffers, 3, true) == true);
/* set info */
int bw = tbm_surface_get_width(buffers[0]);
{
TDM_UT_SKIP_FLAG(has_layers);
- _ut_tdm_layer_mode_setting_all_output(dpy, outputs, output_count);
+ 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;
int next_buffer = 0;
continue;
if (ut_tdm_layer_is_video_layer(layers[l]))
continue;
+ if (ut_tdm_layer_is_primary_layer(layers[l]))
+ continue;
- ASSERT_TRUE(ut_tdm_layer_prepare_buffer(layers[l], buffers, 3) == true);
+ ASSERT_TRUE(ut_tdm_layer_prepare_buffer(layers[l], buffers, 3, true) == true);
/* set info */
int bw = tbm_surface_get_width(buffers[0]);
}
}
-TEST_P(TDMLayer, LayerUnsetBufferAfterTwoCommit)
+/* drmModePageFlip can't be done twice in a vblank */
+TEST_P(TDMLayer, DISABLED_LayerUnsetBufferAfterTwoCommit)
{
TDM_UT_SKIP_FLAG(has_layers);
- _ut_tdm_layer_mode_setting_all_output(dpy, outputs, output_count);
+ 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;
int next_buffer = 0;
continue;
if (ut_tdm_layer_is_video_layer(layers[l]))
continue;
+ if (ut_tdm_layer_is_primary_layer(layers[l]))
+ continue;
- ASSERT_TRUE(ut_tdm_layer_prepare_buffer(layers[l], buffers, 3) == true);
+ ASSERT_TRUE(ut_tdm_layer_prepare_buffer(layers[l], buffers, 3, true) == true);
/* set info */
int bw = tbm_surface_get_width(buffers[0]);
}
}
-TEST_P(TDMLayer, LayerUnsetBufferAfterTwoCommitOneSetBuffer)
+/* drmModePageFlip can't be done twice in a vblank */
+TEST_P(TDMLayer, DISABLED_LayerUnsetBufferAfterTwoCommitOneSetBuffer)
{
TDM_UT_SKIP_FLAG(has_layers);
- _ut_tdm_layer_mode_setting_all_output(dpy, outputs, output_count);
+ 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;
int next_buffer = 0;
continue;
if (ut_tdm_layer_is_video_layer(layers[l]))
continue;
+ if (ut_tdm_layer_is_primary_layer(layers[l]))
+ continue;
- ASSERT_TRUE(ut_tdm_layer_prepare_buffer(layers[l], buffers, 3) == true);
+ ASSERT_TRUE(ut_tdm_layer_prepare_buffer(layers[l], buffers, 3, true) == true);
/* set info */
int bw = tbm_surface_get_width(buffers[0]);
{
TDM_UT_SKIP_FLAG(has_layers);
- _ut_tdm_layer_mode_setting_all_output(dpy, outputs, output_count);
+ 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;
int next_buffer = 0;
bool done;
continue;
if (ut_tdm_layer_is_video_layer(layers[l]))
continue;
+ if (ut_tdm_layer_is_primary_layer(layers[l]))
+ continue;
- ASSERT_TRUE(ut_tdm_layer_prepare_buffer(layers[l], buffers, 3) == true);
+ ASSERT_TRUE(ut_tdm_layer_prepare_buffer(layers[l], buffers, 3, true) == true);
/* set info */
int bw = tbm_surface_get_width(buffers[0]);
done = false;
ASSERT_TRUE(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb, &done) == TDM_ERROR_NONE);
while (!done) {
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
}
ASSERT_TRUE(tdm_layer_unset_buffer(layers[l]) == TDM_ERROR_NONE);
{
TDM_UT_SKIP_FLAG(has_layers);
- _ut_tdm_layer_mode_setting_all_output(dpy, outputs, output_count);
+ 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;
int next_buffer = 0;
bool done;
continue;
if (ut_tdm_layer_is_video_layer(layers[l]))
continue;
+ if (ut_tdm_layer_is_primary_layer(layers[l]))
+ continue;
- ASSERT_TRUE(ut_tdm_layer_prepare_buffer(layers[l], buffers, 3) == true);
+ ASSERT_TRUE(ut_tdm_layer_prepare_buffer(layers[l], buffers, 3, true) == true);
/* set info */
int bw = tbm_surface_get_width(buffers[0]);
done = false;
ASSERT_TRUE(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb, &done) == TDM_ERROR_NONE);
while (!done) {
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
}
ASSERT_TRUE(tdm_layer_set_buffer(layers[l], buffers[next_buffer++]) == TDM_ERROR_NONE);
}
}
-TEST_P(TDMLayer, LayerCommit)
+TEST_P(TDMLayer, LayerCommitDPMSOff)
{
TDM_UT_SKIP_FLAG(has_layers);
- _ut_tdm_layer_mode_setting_all_output(dpy, outputs, output_count);
+ tdm_error ret;
+ tdm_output *output = tdm_layer_get_output(layers[0], &ret);
+ ASSERT_TRUE(ret == TDM_ERROR_NONE);
+ ASSERT_TRUE(output != NULL);
- for (int l = 0; l < layer_count; l++) {
- if (ut_tdm_layer_is_cursor_layer(layers[l]))
- continue;
- if (ut_tdm_layer_is_video_layer(layers[l]))
- continue;
+ if (!ut_tdm_output_is_connected(output))
+ return;
- for (int t = 0; t < 10; t++) {
- unsigned int committing;
- bool done = false;
- ASSERT_TRUE(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb, &done) == TDM_ERROR_NONE);
- ASSERT_TRUE(tdm_layer_is_committing(layers[l], &committing) == TDM_ERROR_NONE);
- ASSERT_TRUE(committing == 1);
- while (!done)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
- ASSERT_TRUE(tdm_layer_is_committing(layers[l], &committing) == TDM_ERROR_NONE);
- ASSERT_TRUE(committing == 0);
- }
- }
-}
+ EXPECT_TRUE(ut_tdm_output_prepare(dpy, output, true) == true);
-TEST_P(TDMLayer, LayerCommitDPMSOff)
-{
- TDM_UT_SKIP_FLAG(has_layers);
+ 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);
- ASSERT_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);
- _ut_tdm_layer_mode_setting_all_output(dpy, outputs, output_count);
+ ut_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
ASSERT_TRUE(tdm_layer_commit(layers[0], NULL, NULL) == TDM_ERROR_NONE);
}
-TEST_P(TDMLayer, LayerCommitFewTimesInOneVblank)
-{
- TDM_UT_SKIP_FLAG(has_layers);
-
- _ut_tdm_layer_mode_setting_all_output(dpy, outputs, output_count);
-
- for (int l = 0; l < layer_count; l++) {
- tdm_error ret;
- tdm_output *output = tdm_layer_get_output(layers[l], &ret);
- ASSERT_TRUE(ret == TDM_ERROR_NONE);
- ASSERT_TRUE(output != NULL);
-
- if (ut_tdm_layer_is_cursor_layer(layers[l]))
- continue;
- if (ut_tdm_layer_is_video_layer(layers[l]))
- continue;
-
- for (int t = 0; t < 10; t++) {
- unsigned int committing;
- bool done1 = false, done2 = false, done3 = false;
- ASSERT_TRUE(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb, &done1) == TDM_ERROR_NONE);
- ASSERT_TRUE(tdm_layer_is_committing(layers[l], &committing) == TDM_ERROR_NONE);
- ASSERT_TRUE(committing == 1);
- ASSERT_TRUE(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb, &done2) == TDM_ERROR_NONE);
- ASSERT_TRUE(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb, &done3) == TDM_ERROR_NONE);
- while (!done1 || !done2 || !done3)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
- ASSERT_TRUE(tdm_layer_is_committing(layers[l], &committing) == TDM_ERROR_NONE);
- ASSERT_TRUE(committing == 0);
- }
- }
-}
-
TEST_P(TDMLayer, LayerIsCommittingNullObject)
{
TDM_UT_SKIP_FLAG(has_layers);
{
TDM_UT_SKIP_FLAG(has_layers);
- _ut_tdm_layer_mode_setting_all_output(dpy, outputs, output_count);
+ 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_TRUE(ret == TDM_ERROR_NONE);
continue;
if (ut_tdm_layer_is_video_layer(layers[l]))
continue;
+ if (ut_tdm_layer_is_primary_layer(layers[l]))
+ continue;
+
+ ASSERT_TRUE(ut_tdm_layer_prepare_buffer(layers[l], buffers, 1, true) == true);
+
+ /* set info */
+ tdm_info_layer info;
+ int bw = tbm_surface_get_width(buffers[0]);
+ int bh = tbm_surface_get_height(buffers[0]);
+ tbm_format bf = tbm_surface_get_format(buffers[0]);
+ ASSERT_TRUE(ut_tdm_layer_fill_info(layers[l], bw, bh, bf, &info) == true);
+ ASSERT_TRUE(tdm_layer_set_info(layers[l], &info) == TDM_ERROR_NONE);
+ ASSERT_TRUE(tdm_layer_set_buffer(layers[l], buffers[0]) == TDM_ERROR_NONE);
for (int t = 0; t < 10; t++) {
bool done1 = false, done2 = false, done3 = false;
ASSERT_TRUE(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb, &done3) == TDM_ERROR_NONE);
ASSERT_TRUE(tdm_layer_remove_commit_handler(layers[l], _ut_tdm_layer_commit_cb, &done2) == TDM_ERROR_NONE);
while (!done1 || done2 || !done3) {
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
}
}
+
+ DestroyBuffers();
}
}
{
TDM_UT_SKIP_FLAG(has_layers);
- _ut_tdm_layer_mode_setting_all_output(dpy, outputs, output_count);
+ 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_TRUE(ret == TDM_ERROR_NONE);
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_TRUE(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb, &done3) == TDM_ERROR_NONE);
ASSERT_TRUE(tdm_layer_remove_commit_handler(layers[l], _ut_tdm_layer_commit_cb, NULL) == TDM_ERROR_NONE);
while (!done1 || !done2 || !done3) {
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
}
}
}
{
TDM_UT_SKIP_FLAG(has_layers);
- _ut_tdm_layer_mode_setting_all_output(dpy, outputs, output_count);
+ 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_TRUE(ret == TDM_ERROR_NONE);
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_TRUE(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb2, &done2) == TDM_ERROR_NONE);
ASSERT_TRUE(tdm_layer_commit(layers[l], _ut_tdm_layer_commit_cb2, &done3) == TDM_ERROR_NONE);
while (!done1 || !done2 || !done3) {
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
}
}
}
tdm_error ret;
- _ut_tdm_layer_mode_setting_all_output(dpy, outputs, output_count);
+ ut_tdm_output_prepare_all_output(dpy, outputs, output_count, true);
for (int l = 0; l < layer_count; l++) {
- unsigned int usable;
+ if (!ut_tdm_layer_is_avaiable(layers[l]))
+ continue;
+
tdm_info_layer info;
tbm_surface_h buffer;
tbm_surface_h displaying_buffer;
continue;
if (ut_tdm_layer_is_video_layer(layers[l]))
continue;
+ if (ut_tdm_layer_is_primary_layer(layers[l]))
+ continue;
ASSERT_TRUE(ut_tdm_layer_prepare_buffer_queue(layers[l], &buffer_queue) == true);
ASSERT_TRUE(buffer_queue != NULL);
tbm_format bf = tbm_surface_queue_get_format(buffer_queue);
ASSERT_TRUE(ut_tdm_layer_fill_info(layers[l], bw, bh, bf, &info) == true);
- ASSERT_TRUE(tdm_layer_is_usable(layers[l], &usable) == TDM_ERROR_NONE);
- ASSERT_TRUE(usable == 1);
ASSERT_TRUE(tdm_layer_set_info(layers[l], &info) == TDM_ERROR_NONE);
- ASSERT_TRUE(tdm_layer_is_usable(layers[l], &usable) == TDM_ERROR_NONE);
- ASSERT_TRUE(usable == 0);
-
ASSERT_TRUE(tdm_layer_set_buffer_queue(layers[l], buffer_queue) == TDM_ERROR_NONE);
ASSERT_TRUE(tdm_layer_commit(layers[l], NULL, NULL) == TDM_ERROR_NONE);
ASSERT_TRUE(tbm_surface_queue_enqueue(buffer_queue, buffer) == TBM_SURFACE_QUEUE_ERROR_NONE);
displaying_buffer = NULL;
- while (!displaying_buffer) {
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ while (displaying_buffer != buffer) {
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
displaying_buffer = tdm_layer_get_displaying_buffer(layers[l], &ret);
ASSERT_TRUE(ret == TDM_ERROR_NONE);
}
- ASSERT_TRUE(displaying_buffer == buffer);
}
ASSERT_TRUE(tdm_layer_unset_buffer_queue(layers[l]) == TDM_ERROR_NONE);
{
TDM_UT_SKIP_FLAG(has_layers);
- _ut_tdm_layer_mode_setting_all_output(dpy, outputs, output_count);
+ 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]))
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_TRUE(tdm_layer_set_video_pos(layers[l], -1) == TDM_ERROR_NONE);
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;
for (int l = 0; l < layer_count; ++l) {
tdm_error ret;
- tdm_capture *capture = tdm_layer_create_capture(layers[l], &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_TRUE(capture != NULL);
}
ASSERT_TRUE(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
#include "ut_tdm.h"
-#ifdef UT_TDM_LOG_ENABLE
-
TEST(TDMLog, logPrintf)
{
tdm_log_enable_color(1);
tdm_log_print(TDM_UT_INVALID_VALUE, "utest");
}
-#endif
#include "ut_tdm.h"
+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)
void TDMOutput::TearDown(void)
{
- free(outputs);
+ if (outputs) {
+ for (int o = 0; o < output_count; o++) {
+ ASSERT_TRUE(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();
}
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,
}
bool
-ut_tdm_output_prepare(tdm_display *dpy, tdm_output *output)
+ut_tdm_output_prepare(tdm_display *dpy, tdm_output *output, bool fill)
{
- tbm_surface_h *buffers = NULL;
+ tbm_surface_h buffer = NULL;
tdm_error ret;
- int count = 0, commit_buffer_count = 0, display_buffer_count = 0;
- unsigned int pipe = 0;
+ int primary_index = -1;
+ tdm_info_layer info;
+ tdm_layer *layer;
+ bool done = false;
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_layer_count(output, &count) == TDM_ERROR_NONE);
- TDM_UT_RETURN_FALSE_IF_FAIL(count > 0);
+ 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);
- buffers = (tbm_surface_h *)calloc(count, sizeof (tbm_surface_h));
- TDM_UT_RETURN_FALSE_IF_FAIL(buffers != NULL);
+ 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);
- for (int l = 0; l < count; l++) {
- tdm_info_layer info;
- tdm_layer *layer = tdm_output_get_layer(output, l, &ret);
- TDM_UT_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, failed);
- TDM_UT_GOTO_IF_FAIL(layer != NULL, failed);
-
- if (ut_tdm_layer_is_cursor_layer(layer))
- continue;
- if (ut_tdm_layer_is_video_layer(layer))
- continue;
+ 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_prepare_buffer(layer, &buffers[l], 1) == true, failed);
- TDM_UT_GOTO_IF_FAIL(buffers[l] != NULL, failed);
+ int bw = tbm_surface_get_width(buffer);
+ int bh = tbm_surface_get_height(buffer);
+ tbm_format bf = tbm_surface_get_format(buffer);
+ TDM_UT_GOTO_IF_FAIL(ut_tdm_layer_fill_info(layer, bw, bh, bf, &info) == true, failed);
- int bw = tbm_surface_get_width(buffers[l]);
- int bh = tbm_surface_get_height(buffers[l]);
- tbm_format bf = tbm_surface_get_format(buffers[l]);
- TDM_UT_GOTO_IF_FAIL(ut_tdm_layer_fill_info(layer, bw, bh, bf, &info) == true, failed);
+ TDM_UT_GOTO_IF_FAIL(tdm_layer_set_info(layer, &info) == TDM_ERROR_NONE, failed);
+ TDM_UT_GOTO_IF_FAIL(tdm_layer_set_buffer(layer, buffer) == TDM_ERROR_NONE, failed);
- TDM_UT_GOTO_IF_FAIL(tdm_layer_set_info(layer, &info) == TDM_ERROR_NONE, failed);
- TDM_UT_GOTO_IF_FAIL(tdm_layer_set_buffer(layer, buffers[l]) == TDM_ERROR_NONE, 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);
- commit_buffer_count++;
- }
+ else
+ TDM_UT_GOTO_IF_FAIL(tdm_output_commit(output, 0, NULL, NULL) == TDM_ERROR_NONE, failed);
- while (commit_buffer_count != display_buffer_count) {
- TDM_UT_GOTO_IF_FAIL(tdm_output_wait_vblank(output, 1, 0, _ut_tdm_output_done_cb, NULL) == TDM_ERROR_NONE, failed);
- TDM_UT_GOTO_IF_FAIL(tdm_display_handle_events(dpy) == TDM_ERROR_NONE, failed);
-
- display_buffer_count = 0;
- for (int l = 0; l < count; l++) {
- tbm_surface_h displaying_buffer;
- tdm_layer *layer = tdm_output_get_layer(output, l, &ret);
- TDM_UT_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, failed);
- TDM_UT_GOTO_IF_FAIL(layer != NULL, failed);
-
- if (ut_tdm_layer_is_cursor_layer(layer))
- continue;
- if (ut_tdm_layer_is_video_layer(layer))
- continue;
-
- displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret);
- if (displaying_buffer) {
- TDM_UT_GOTO_IF_FAIL(displaying_buffer == buffers[l], failed);
- display_buffer_count++;
- }
- }
+ 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);
}
- for (int l = 0; l < count; l++)
- tbm_surface_destroy(buffers[l]);
-
- free(buffers);
-
- TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_pipe(output, &pipe) == TDM_ERROR_NONE);
-
- TDM_INFO("preparing output(%d) done", pipe);
+ tbm_surface_internal_unref(buffer);
return true;
failed:
- for (int l = 0; l < count; l++)
- tbm_surface_destroy(buffers[l]);
- free(buffers);
+ 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)
{
return (double)1.0 / (double)mode->vrefresh;
}
-#ifdef UT_TDM_OUTPUT_ENABLE
-
TEST_P(TDMOutput, OutputGetBackendModule)
{
TDM_UT_SKIP_FLAG(has_outputs);
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_TRUE(tdm_output_get_available_modes(outputs[o], &modes_array, &count) == TDM_ERROR_NONE);
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;
{
TDM_UT_SKIP_FLAG(has_outputs);
- bool done;
-
for (int o = 0; o < output_count; o++) {
if (!ut_tdm_output_is_connected(outputs[o]))
continue;
- ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o]) == true);
+ ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o], true) == true);
ASSERT_TRUE(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF) == TDM_ERROR_NONE);
- done = false;
- ASSERT_TRUE(tdm_output_add_change_handler(outputs[o], _ut_tdm_output_change_cb, &done) == TDM_ERROR_NONE);
+ done1 = false;
+ ASSERT_TRUE(tdm_output_add_change_handler(outputs[o], _ut_tdm_output_change_cb, &done1) == TDM_ERROR_NONE);
ASSERT_TRUE(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON) == TDM_ERROR_NONE);
- ASSERT_TRUE(done == true);
+ ASSERT_TRUE(done1 == true);
}
}
TDM_UT_SKIP_FLAG(has_outputs);
for (int o = 0; o < output_count; o++) {
- for (int t = 0; t < 100; t++) {
+ for (int t = 0; t < 10; t++) {
ASSERT_TRUE(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);
}
{
TDM_UT_SKIP_FLAG(has_outputs);
- bool done;
-
for (int o = 0; o < output_count; o++) {
if (!ut_tdm_output_is_connected(outputs[o]))
continue;
ASSERT_TRUE(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF) == TDM_ERROR_NONE);
- done = false;
- ASSERT_TRUE(tdm_output_add_change_handler(outputs[o], _ut_tdm_output_change_cb, &done) == TDM_ERROR_NONE);
+ done1 = false;
+ ASSERT_TRUE(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_TRUE(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON) == TDM_ERROR_NONE);
- ASSERT_TRUE(done == true);
+ ASSERT_TRUE(done1 == true);
}
}
{
TDM_UT_SKIP_FLAG(has_outputs);
- bool done1, done2, done3;
-
for (int o = 0; o < output_count; o++) {
if (!ut_tdm_output_is_connected(outputs[o]))
continue;
}
}
-TEST_P(TDMOutput, OutputSetDPMS)
+TEST_P(TDMOutput, OutputSetDpms)
{
TDM_UT_SKIP_FLAG(has_outputs);
}
}
-TEST_P(TDMOutput, OutputSetDPMSNullObject)
+TEST_P(TDMOutput, OutputSetDpmsNullObject)
{
TDM_UT_SKIP_FLAG(has_outputs);
ASSERT_TRUE(tdm_output_set_dpms(NULL, TDM_OUTPUT_DPMS_OFF) == TDM_ERROR_INVALID_PARAMETER);
}
-TEST_P(TDMOutput, OutputSetDPMSNullOther)
+TEST_P(TDMOutput, OutputSetDpmsNullOther)
{
TDM_UT_SKIP_FLAG(has_outputs);
ASSERT_TRUE(tdm_output_set_dpms(outputs[0], (tdm_output_dpms)INT_MAX) == TDM_ERROR_BAD_REQUEST);
}
-TEST_P(TDMOutput, OutputSetDPMSAsync)
+TEST_P(TDMOutput, OutputSetDpmsAsync)
{
TDM_UT_SKIP_FLAG(has_outputs);
for (int o = 0; o < output_count; o++) {
- bool done = false;
-
if (!ut_tdm_output_is_connected(outputs[o]))
continue;
if (!ut_tdm_output_is_async_dpms_enable(outputs[o]))
continue;
+ done1 = false;
ASSERT_TRUE(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF) == TDM_ERROR_NONE);
- ASSERT_TRUE(tdm_output_add_change_handler(outputs[o], _ut_tdm_output_change_cb, &done) == TDM_ERROR_NONE);
+ ASSERT_TRUE(tdm_output_add_change_handler(outputs[o], _ut_tdm_output_change_cb, &done1) == TDM_ERROR_NONE);
ASSERT_TRUE(tdm_output_set_dpms_async(outputs[o], TDM_OUTPUT_DPMS_ON) == TDM_ERROR_NONE);
- while(!done)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
- tdm_output_remove_change_handler(outputs[o], _ut_tdm_output_change_cb, &done);
+ while (!done1)
+ ASSERT_TRUE(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)
+TEST_P(TDMOutput, OutputGetDpms)
{
TDM_UT_SKIP_FLAG(has_outputs);
}
}
-TEST_P(TDMOutput, OutputGetDPMSNullObject)
+TEST_P(TDMOutput, OutputGetDpmsNullObject)
{
TDM_UT_SKIP_FLAG(has_outputs);
ASSERT_TRUE(dpms_value == (tdm_output_dpms)TDM_UT_INVALID_VALUE);
}
-TEST_P(TDMOutput, OutputGetDPMSNullOther)
+TEST_P(TDMOutput, OutputGetDpmsNullOther)
{
TDM_UT_SKIP_FLAG(has_outputs);
if (!ut_tdm_output_is_connected(outputs[o]))
continue;
- ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o]) == true);
+ ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o], true) == true);
for (int t = 0; t < 10; t++) {
- bool done = false;
double start, end, interval;
interval = ut_tdm_output_get_vblank_interval_time(outputs[o]);
+ done1 = false;
start = tdm_helper_get_time();
- ASSERT_TRUE(tdm_output_wait_vblank(outputs[o], 1, 0, _ut_tdm_output_done_cb, &done) == TDM_ERROR_NONE);
- while(!done)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ ASSERT_TRUE(tdm_output_wait_vblank(outputs[o], 1, 0, _ut_tdm_output_done_cb, &done1) == TDM_ERROR_NONE);
+ while (!done1)
+ ASSERT_TRUE(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 */
if (!ut_tdm_output_is_connected(outputs[o]))
continue;
- ASSERT_TRUE(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON) == TDM_ERROR_NONE);
+ ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o], true) == true);
+
ASSERT_TRUE(tdm_output_wait_vblank(outputs[o], 1, 0, NULL, NULL) == TDM_ERROR_NONE);
}
}
if (!ut_tdm_output_is_connected(outputs[o]))
continue;
- ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o]) == true);
+ ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o], true) == true);
ASSERT_TRUE(tdm_output_wait_vblank(outputs[o], 1, 0, _ut_tdm_output_done_cb, NULL) == TDM_ERROR_NONE);
usleep(1100000);
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
ASSERT_TRUE(tdm_helper_output_vblank_timer_expired(outputs[o]) > 0);
}
if (!ut_tdm_output_is_connected(outputs[o]))
continue;
- ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o]) == true);
+ ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o], true) == true);
/* start from 1 */
for (int t = 1; t < 10; t++) {
- bool done = false;
double start, end, interval;
interval = ut_tdm_output_get_vblank_interval_time(outputs[o]);
+ done1 = false;
start = tdm_helper_get_time();
- ASSERT_TRUE(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_output_done_cb, &done) == TDM_ERROR_NONE);
- while(!done)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ ASSERT_TRUE(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_output_done_cb, &done1) == TDM_ERROR_NONE);
+ while (!done1)
+ ASSERT_TRUE(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 */
if (!ut_tdm_output_is_connected(outputs[o]))
continue;
- ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o]) == true);
+ ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o], true) == true);
/* start from 1 */
for (int t = 1; t < 10; t++) {
- bool done1 = false, done2 = false, done3 = false;
double start, end, interval;
interval = ut_tdm_output_get_vblank_interval_time(outputs[o]);
+ done1 = done2 = done3 = false;
ASSERT_TRUE(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_output_done_cb, &done1) == TDM_ERROR_NONE);
ASSERT_TRUE(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_output_done_cb, &done2) == TDM_ERROR_NONE);
ASSERT_TRUE(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_output_done_cb, &done3) == TDM_ERROR_NONE);
- while(!done1 || !done2 || !done3) {
- start = tdm_helper_get_time();
- ASSERT_TRUE(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_TRUE((end - start) > (interval * (t - 1)));
- ASSERT_TRUE((end - start) < (interval * t + interval));
- }
+ start = tdm_helper_get_time();
+ while (!done1 || !done2 || !done3)
+ ASSERT_TRUE(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_TRUE((end - start) > (interval * (t - 1)));
+ ASSERT_TRUE((end - start) < (interval * t + interval));
}
}
}
if (!ut_tdm_output_is_connected(outputs[o]))
continue;
- ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o]) == true);
+ ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o], false) == true);
for (int t = 0; t < 10; t++) {
bool done = false;
if (!ut_tdm_output_is_connected(outputs[o]))
continue;
- ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o]) == true);
+ ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o], true) == true);
/* start from 1 */
for (int t = 1; t < 10; t++) {
- bool done1 = false, done2 = false, done3 = false;
+ done1 = done2 = done3 = false;
ASSERT_TRUE(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_output_done_cb, &done1) == TDM_ERROR_NONE);
ASSERT_TRUE(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_output_done_cb, &done2) == TDM_ERROR_NONE);
ASSERT_TRUE(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_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ while (!done1 || done2 || !done3)
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
}
}
}
if (!ut_tdm_output_is_connected(outputs[o]))
continue;
- ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o]) == true);
+ ut_tdm_output_prepare(dpy, outputs[o], true);
/* start from 1 */
for (int t = 1; t < 10; t++) {
- bool done1 = false, done2 = false, done3 = false;
+ done1 = done2 = done3 = false;
ASSERT_TRUE(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_output_done_cb, &done1) == TDM_ERROR_NONE);
ASSERT_TRUE(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_output_done_cb, &done2) == TDM_ERROR_NONE);
ASSERT_TRUE(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_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ while (!done1 || !done2 || !done3)
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
}
}
}
if (!ut_tdm_output_is_connected(outputs[o]))
continue;
- ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o]) == true);
+ ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o], true) == true);
/* start from 1 */
for (int t = 1; t < 10; t++) {
- bool done1 = false, done2 = false, done3 = false;
+ done1 = done2 = done3 = false;
ASSERT_TRUE(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_output_done_cb, &done1) == TDM_ERROR_NONE);
ASSERT_TRUE(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_output_done_cb, &done2) == TDM_ERROR_NONE);
ASSERT_TRUE(tdm_output_wait_vblank(outputs[o], t, 0, _ut_tdm_output_done_cb, &done3) == TDM_ERROR_NONE);
- while(!done1 || !done2 || !done3)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ while (!done1 || !done2 || !done3)
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
}
}
}
if (!ut_tdm_output_is_connected(outputs[o]))
continue;
- ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o]) == true);
+ ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o], true) == true);
for (int t = 0; t < 10; t++) {
- bool done = false;
double start, end, interval;
interval = ut_tdm_output_get_vblank_interval_time(outputs[o]);
+ done1 = false;
start = tdm_helper_get_time();
- ASSERT_TRUE(tdm_output_commit(outputs[o], 0, _ut_tdm_output_done_cb, &done) == TDM_ERROR_NONE);
- while(!done)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ ASSERT_TRUE(tdm_output_commit(outputs[o], 0, _ut_tdm_output_done_cb, &done1) == TDM_ERROR_NONE);
+ while (!done1)
+ ASSERT_TRUE(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 */
if (!ut_tdm_output_is_connected(outputs[o]))
continue;
- ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o]) == true);
+ ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o], true) == true);
ASSERT_TRUE(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_SUSPEND) == TDM_ERROR_NONE);
if (!ut_tdm_output_is_connected(outputs[o]))
continue;
- ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o]) == true);
+ ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o], true) == true);
ASSERT_TRUE(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF) == TDM_ERROR_NONE);
if (!ut_tdm_output_is_aod_enable(outputs[o]))
continue;
- ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o]) == true);
+ ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o], true) == true);
ASSERT_TRUE(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_AOD) == TDM_ERROR_NONE);
for (int t = 0; t < 10; t++) {
- bool done = false;
- ASSERT_TRUE(tdm_output_commit(outputs[o], 0, _ut_tdm_output_done_cb, &done) == TDM_ERROR_NONE);
- while(!done)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ done1 = false;
+ ASSERT_TRUE(tdm_output_commit(outputs[o], 0, _ut_tdm_output_done_cb, &done1) == TDM_ERROR_NONE);
+ while (!done1)
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
}
}
}
tdm_layer *layer;
tdm_error ret;
- ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o]) == true);
+ if (!ut_tdm_output_is_connected(outputs[o]))
+ continue;
+
+ ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o], true) == true);
ASSERT_TRUE(tdm_output_get_primary_index(outputs[o], &index) == TDM_ERROR_NONE);
ASSERT_TRUE(index != TDM_UT_INVALID_VALUE);
if (!ut_tdm_output_is_connected(outputs[o]))
continue;
- ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o]) == true);
+ ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o], true) == true);
for (int t = 0; t < 10; t++) {
- bool done1 = false, done2 = false, done3 = false;
+ done1 = done2 = done3 = false;
ASSERT_TRUE(tdm_output_commit(outputs[o], 0, _ut_tdm_output_done_cb, &done1) == TDM_ERROR_NONE);
ASSERT_TRUE(tdm_output_commit(outputs[o], 0, _ut_tdm_output_done_cb, &done2) == TDM_ERROR_NONE);
ASSERT_TRUE(tdm_output_commit(outputs[o], 0, _ut_tdm_output_done_cb, &done3) == TDM_ERROR_NONE);
- while(!done1 || !done2 || !done3)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ while (!done1 || !done2 || !done3)
+ ASSERT_TRUE(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);
if (!ut_tdm_output_is_connected(outputs[o]))
continue;
- ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o]) == true);
+ ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o], true) == true);
for (int t = 0; t < 10; t++) {
- bool done1 = false, done2 = false, done3 = false;
+ done1 = done2 = done3 = false;
ASSERT_TRUE(tdm_output_commit(outputs[o], 0, _ut_tdm_output_done_cb, &done1) == TDM_ERROR_NONE);
ASSERT_TRUE(tdm_output_commit(outputs[o], 0, _ut_tdm_output_done_cb, &done2) == TDM_ERROR_NONE);
ASSERT_TRUE(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_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ while (!done1 || done2 || !done3)
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
}
}
}
if (!ut_tdm_output_is_connected(outputs[o]))
continue;
- ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o]) == true);
+ ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o], true) == true);
for (int t = 0; t < 10; t++) {
- bool done1 = false, done2 = false, done3 = false;
+ done1 = done2 = done3 = false;
ASSERT_TRUE(tdm_output_commit(outputs[o], 0, _ut_tdm_output_done_cb, &done1) == TDM_ERROR_NONE);
ASSERT_TRUE(tdm_output_commit(outputs[o], 0, _ut_tdm_output_done_cb, &done2) == TDM_ERROR_NONE);
ASSERT_TRUE(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_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ while (!done1 || !done2 || !done3)
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
}
}
}
if (!ut_tdm_output_is_connected(outputs[o]))
continue;
- ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o]) == true);
+ ASSERT_TRUE(ut_tdm_output_prepare(dpy, outputs[o], true) == true);
for (int t = 0; t < 10; t++) {
- bool done1 = false, done2 = false, done3 = false;
+ done1 = done2 = done3 = false;
ASSERT_TRUE(tdm_output_commit(outputs[o], 0, _ut_tdm_output_done_cb2, &done1) == TDM_ERROR_NONE);
ASSERT_TRUE(tdm_output_commit(outputs[o], 0, _ut_tdm_output_done_cb2, &done2) == TDM_ERROR_NONE);
ASSERT_TRUE(tdm_output_commit(outputs[o], 0, _ut_tdm_output_done_cb2, &done3) == TDM_ERROR_NONE);
- while(!done1 || !done2 || !done3)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ while (!done1 || !done2 || !done3)
+ ASSERT_TRUE(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)));
-
-#endif
+#else
+INSTANTIATE_TEST_CASE_P(TDMOutputParams,
+ TDMOutput,
+ Values(TDM_DEFAULT_MODULE));
+#endif
\ No newline at end of file
TDMOutput::TearDown();
}
-#ifdef UT_TDM_OUTPUT_HWC_ENABLE
-
/* tdm_hwc_window * tdm_output_hwc_create_window(tdm_output *output, tdm_error *error); */
TEST_P(TDMOutputHwc, CreateWindowFailNull)
{
}
}
+#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
+++ /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"
-
-class TDMPP : public TDMDisplay {
-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;
-
- TDMPP();
- void SetUp(void);
- void TearDown(void);
-
- bool TestPrepare(int sw, int sh, tbm_format sf, int dw, int dh, tbm_format df, tdm_transform t);
- void DumpBuffers(int b, char *test);
- void DestroyBuffers(void);
-};
-
-TDMPP::TDMPP()
-{
- 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);
-}
-
-void TDMPP::SetUp(void)
-{
- TDMDisplay::SetUp();
-
- if (!has_pp_cap)
- return;
-
- tdm_error ret;
- pp = tdm_display_create_pp(dpy, &ret);
- ASSERT_TRUE(ret == TDM_ERROR_NONE);
- ASSERT_TRUE(pp != NULL);
- ASSERT_TRUE(tdm_display_get_pp_capabilities(dpy, &capabilities) == TDM_ERROR_NONE);
- ASSERT_TRUE(capabilities > 0);
- ASSERT_TRUE(tdm_display_get_pp_available_formats(dpy, &formats, &format_count) == TDM_ERROR_NONE);
- ASSERT_TRUE(formats != NULL);
- ASSERT_TRUE(format_count > 0);
- ASSERT_TRUE(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);
-}
-
-void TDMPP::TearDown(void)
-{
- if (pp)
- tdm_pp_destroy(pp);
-
- DestroyBuffers();
-
- TDMDisplay::TearDown();
-}
-
-bool TDMPP::TestPrepare(int sw, int sh, tbm_format sf, int dw, int dh, tbm_format df, tdm_transform t)
-{
- int flags = 0;
-
- sw = TDM_UT_SIZE_ALIGN(sw, preferred_align);
- dw = TDM_UT_SIZE_ALIGN(dw, preferred_align);
-
- if (capabilities & TDM_PP_CAPABILITY_SCANOUT)
- flags = TBM_BO_SCANOUT;
-
- TDM_UT_RETURN_FALSE_IF_FAIL(ut_tdm_buffer_create(sw, sh, sf, flags, true, 3, srcbuf) == true);
- TDM_UT_RETURN_FALSE_IF_FAIL(ut_tdm_buffer_create(dw, dh, df, 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;
-}
-
-void TDMPP::DumpBuffers(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 TDMPP::DestroyBuffers(void)
-{
- for (int b = 0; b < 3; b++) {
- tbm_surface_destroy(srcbuf[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_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.h,
- 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.h,
- 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;
-}
-
-#ifdef UT_TDM_PP_ENABLE
-
-TEST_P(TDMPP, PPDispalyGetAvaiableFormatsNullObject)
-{
- const tbm_format *formats = (const tbm_format *)TDM_UT_INVALID_VALUE;
- int count = TDM_UT_INVALID_VALUE;
- if (has_pp_cap)
- ASSERT_TRUE(tdm_display_get_pp_available_formats(NULL, &formats, &count) == TDM_ERROR_INVALID_PARAMETER);
- else
- ASSERT_TRUE(tdm_display_get_pp_available_formats(NULL, &formats, &count) == TDM_ERROR_NO_CAPABILITY);
- ASSERT_TRUE(formats == (const tbm_format *)TDM_UT_INVALID_VALUE);
- ASSERT_TRUE(count == TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMPP, PPDispalyGetAvaiableFormatsNullOther)
-{
- if (has_pp_cap)
- ASSERT_TRUE(tdm_display_get_pp_available_formats(pp, NULL, NULL) == TDM_ERROR_INVALID_PARAMETER);
- else
- ASSERT_TRUE(tdm_display_get_pp_available_formats(pp, NULL, NULL) == TDM_ERROR_NO_CAPABILITY);
-}
-
-TEST_P(TDMPP, 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 (has_pp_cap)
- ASSERT_TRUE(tdm_display_get_pp_available_size(NULL, &min_w, &min_h, &max_w, &max_h, &preferred_align) == TDM_ERROR_INVALID_PARAMETER);
- else
- ASSERT_TRUE(tdm_display_get_pp_available_size(NULL, &min_w, &min_h, &max_w, &max_h, &preferred_align) == TDM_ERROR_NO_CAPABILITY);
- ASSERT_TRUE(min_w == TDM_UT_INVALID_VALUE);
- ASSERT_TRUE(min_h == TDM_UT_INVALID_VALUE);
- ASSERT_TRUE(max_w == TDM_UT_INVALID_VALUE);
- ASSERT_TRUE(max_h == TDM_UT_INVALID_VALUE);
- ASSERT_TRUE(preferred_align == TDM_UT_INVALID_VALUE);
-}
-
-TEST_P(TDMPP, PPDispalyGetAvaiableSizeNullOther)
-{
- if (has_pp_cap)
- ASSERT_TRUE(tdm_display_get_pp_available_size(pp, NULL, NULL, NULL, NULL, NULL) == TDM_ERROR_INVALID_PARAMETER);
- else
- ASSERT_TRUE(tdm_display_get_pp_available_size(pp, NULL, NULL, NULL, NULL, NULL) == TDM_ERROR_NO_CAPABILITY);
-}
-
-TEST_P(TDMPP, PPDestroy)
-{
- TDM_UT_SKIP_FLAG(has_pp_cap);
-
- tdm_pp_destroy(pp);
- pp = NULL;
-}
-
-TEST_P(TDMPP, PPDestroyNullObject)
-{
- TDM_UT_SKIP_FLAG(has_pp_cap);
-
- tdm_pp_destroy(NULL);
-}
-
-TEST_P(TDMPP, PPSetInfo)
-{
- /* tested in PPNoScaleNoTransformNoCSC */
-}
-
-TEST_P(TDMPP, PPSetInfoNullObject)
-{
- TDM_UT_SKIP_FLAG(has_pp_cap);
-
- tdm_info_pp info;
- memset(&info, 0, sizeof info);
- ASSERT_TRUE(tdm_pp_set_info(NULL, &info) == TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMPP, PPSetInfoNullOther)
-{
- TDM_UT_SKIP_FLAG(has_pp_cap);
-
- ASSERT_TRUE(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(TDMPP, PPSetDoneHandler)
-{
- TDM_UT_SKIP_FLAG(has_pp_cap);
-
- ASSERT_TRUE(tdm_pp_set_done_handler(pp, _ut_tdm_pp_done_cb, NULL) == TDM_ERROR_NONE);
-}
-
-TEST_P(TDMPP, PPSetDoneHandlerNullObject)
-{
- TDM_UT_SKIP_FLAG(has_pp_cap);
-
- ASSERT_TRUE(tdm_pp_set_done_handler(NULL, _ut_tdm_pp_done_cb, NULL) == TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMPP, PPSetDoneHandlerNullOther)
-{
- TDM_UT_SKIP_FLAG(has_pp_cap);
-
- ASSERT_TRUE(tdm_pp_set_done_handler(pp, NULL, NULL) == TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMPP, PPAttach)
-{
- TDM_UT_SKIP_FLAG(has_pp_cap);
-
- for (int f = 0; f < format_count; f++) {
- ASSERT_TRUE(TestPrepare(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_TRUE(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]) == TDM_ERROR_NONE);
-
- DestroyBuffers();
- }
-}
-
-TEST_P(TDMPP, PPAttachNullObject)
-{
- TDM_UT_SKIP_FLAG(has_pp_cap);
-
- tbm_surface_h srcbuf = (tbm_surface_h)TDM_UT_BUFFER_SIZE;
- tbm_surface_h dstbuf = (tbm_surface_h)TDM_UT_BUFFER_SIZE;
-
- ASSERT_TRUE(tdm_pp_attach(NULL, srcbuf, dstbuf) == TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMPP, PPAttachNullOther)
-{
- TDM_UT_SKIP_FLAG(has_pp_cap);
-
- ASSERT_TRUE(tdm_pp_attach(pp, NULL, NULL) == TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMPP, PPCommit)
-{
- TDM_UT_SKIP_FLAG(has_pp_cap);
-
- ASSERT_TRUE(tdm_pp_commit(pp) == TDM_ERROR_NONE);
-}
-
-TEST_P(TDMPP, PPCommitNullOBject)
-{
- TDM_UT_SKIP_FLAG(has_pp_cap);
-
- ASSERT_TRUE(tdm_pp_commit(NULL) == TDM_ERROR_INVALID_PARAMETER);
-}
-
-TEST_P(TDMPP, PPNoScaleNoTransformNoCSC)
-{
- TDM_UT_SKIP_FLAG(has_pp_cap);
-
- bool done;
-
- for (int f = 0; f < format_count; f++) {
- char temp[256];
- snprintf(temp, sizeof temp, "%c%c%c%c", FOURCC_STR(formats[f]));
-
- TDM_INFO("---- format(%c%c%c%c)", FOURCC_STR(formats[f]));
-
- ASSERT_TRUE(TestPrepare(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, formats[2],
- TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, formats[0],
- TDM_TRANSFORM_NORMAL) == true);
-
- ASSERT_TRUE(tdm_pp_set_done_handler(pp, _ut_tdm_pp_done_cb, &done) == TDM_ERROR_NONE);
-
- for (int b = 0; b < 3; b++) {
- done = false;
-
- ASSERT_TRUE(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]) == TDM_ERROR_NONE);
- ASSERT_TRUE(tdm_pp_commit(pp) == TDM_ERROR_NONE);
-
- while (!done)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
-
- DumpBuffers(b, temp);
- }
-
- DestroyBuffers();
- }
-}
-
-TEST_P(TDMPP, PPScaleTransformCSC)
-{
- TDM_UT_SKIP_FLAG(has_pp_cap);
-
- bool done;
- tbm_format format1, format2;
-
- format1 = formats[0];
- if (format_count > 1)
- format2 = formats[1];
- else
- format2 = formats[0];
-
- TDM_INFO("format(%c%c%c%c) ------> format(%c%c%c%c)", format1, format2);
-
- ASSERT_TRUE(TestPrepare(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, format1,
- TDM_UT_BUFFER_SIZE * 2, TDM_UT_BUFFER_SIZE * 2, format2,
- TDM_TRANSFORM_NORMAL) == true);
-
- ASSERT_TRUE(tdm_pp_set_done_handler(pp, _ut_tdm_pp_done_cb, &done) == TDM_ERROR_NONE);
-
- for (int b = 0; b < 3; b++) {
- done = false;
-
- ASSERT_TRUE(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]) == TDM_ERROR_NONE);
- ASSERT_TRUE(tdm_pp_commit(pp) == TDM_ERROR_NONE);
-
- while (!done)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
-
- DumpBuffers(b, NULL);
- }
-
- 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)++;
-}
-
-TEST_P(TDMPP, PPAttachFewTimesInOneCommit)
-{
- TDM_UT_SKIP_FLAG(has_pp_cap);
-
- int done = 0;
- int f = 0;
- char temp[256];
- snprintf(temp, sizeof temp, "%c%c%c%c", FOURCC_STR(formats[f]));
-
- ASSERT_TRUE(TestPrepare(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_TRUE(tdm_pp_set_done_handler(pp, _ut_tdm_pp_done_cb2, &done) == TDM_ERROR_NONE);
- for (int b = 0; b < 3; b++)
- ASSERT_TRUE(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]) == TDM_ERROR_NONE);
-
- ASSERT_TRUE(tdm_pp_commit(pp) == TDM_ERROR_NONE);
-
- while (done != 3)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
-
- for (int b = 0; b < 3; b++)
- DumpBuffers(b, temp);
-
- DestroyBuffers();
-}
-
-TEST_P(TDMPP, PPDestroyWithoutCommit)
-{
- TDM_UT_SKIP_FLAG(has_pp_cap);
-
- int f = 0;
-
- ASSERT_TRUE(TestPrepare(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_TRUE(tdm_pp_set_done_handler(pp, _ut_tdm_pp_done_cb2, NULL) == TDM_ERROR_NONE);
- for (int b = 0; b < 3; b++)
- ASSERT_TRUE(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]) == TDM_ERROR_NONE);
-
- tdm_pp_destroy(pp);
- pp = NULL;
-
- DestroyBuffers();
-}
-
-TEST_P(TDMPP, PPDestroyBeforeDone)
-{
- TDM_UT_SKIP_FLAG(has_pp_cap);
-
- int f = 0;
-
- ASSERT_TRUE(TestPrepare(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_TRUE(tdm_pp_set_done_handler(pp, _ut_tdm_pp_done_cb2, NULL) == TDM_ERROR_NONE);
- for (int b = 0; b < 3; b++)
- ASSERT_TRUE(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]) == TDM_ERROR_NONE);
-
- ASSERT_TRUE(tdm_pp_commit(pp) == TDM_ERROR_NONE);
-
- tdm_pp_destroy(pp);
- pp = NULL;
-
- DestroyBuffers();
-}
-
-INSTANTIATE_TEST_CASE_P(TDMPPParams,
- TDMPP,
- Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
-
-#endif
#include "ut_tdm.h"
+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:
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);
if (!ut_tdm_output_is_connected(outputs[o]))
continue;
- TDM_UT_RETURN_FALSE_IF_FAIL(ut_tdm_output_prepare(dpy, outputs[o]) == true);
+ TDM_UT_RETURN_FALSE_IF_FAIL(ut_tdm_output_prepare(dpy, outputs[o], false) == true);
}
return true;
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);
}
-#ifdef UT_TDM_VBLANK_ENABLE
-
/* tdm_vblank_set_client_vblank_fps */
TEST_P(TDMVblank, DISABLED_VblankSetClientVblankFps)
{
{
unsigned int *cur_seq = (unsigned int *)user_data;
if (cur_seq)
- *cur_seq = sequence;
+ *cur_seq = (error == TDM_ERROR_NONE) ? sequence : ((unsigned int)-1);
}
TEST_P(TDMVblank, VblankWait)
start = tdm_helper_get_time();
ASSERT_TRUE(tdm_vblank_wait(vblanks[v], 0, 0, 1, _ut_tdm_vblank_cb, &cur_seq) == TDM_ERROR_NONE);
while (cur_seq == 0)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ ASSERT_TRUE(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_TRUE(tdm_vblank_wait(vblanks[v], 0, 0, 1, _ut_tdm_vblank_cb, &seq1) == TDM_ERROR_NONE);
ASSERT_TRUE(tdm_vblank_wait(vblanks[v], 0, 0, 1, _ut_tdm_vblank_cb, &seq2) == TDM_ERROR_NONE);
while (cur_seq == 0)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
end = tdm_helper_get_time();
ASSERT_TRUE(seq1 != 0);
start = tdm_helper_get_time();
ASSERT_TRUE(tdm_vblank_wait(vblanks[v], 0, 0, t, _ut_tdm_vblank_cb, &cur_seq) == TDM_ERROR_NONE);
while (cur_seq == 0)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ ASSERT_TRUE(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_TRUE(tdm_vblank_wait(vblanks[v], 0, 0, 1, _ut_tdm_vblank_cb, &cur_seq) == TDM_ERROR_NONE);
while (cur_seq == 0)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
start = tdm_helper_get_time();
ASSERT_TRUE(tdm_vblank_wait_seq(vblanks[v], 0, 0, cur_seq + 1, _ut_tdm_vblank_cb, &temp) == TDM_ERROR_NONE);
while (temp == 0)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ ASSERT_TRUE(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_TRUE(tdm_vblank_wait(vblanks[v], 0, 0, 1, _ut_tdm_vblank_cb, &cur_seq) == TDM_ERROR_NONE);
while (cur_seq == 0)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
start = tdm_helper_get_time();
ASSERT_TRUE(tdm_vblank_wait_seq(vblanks[v], 0, 0, cur_seq + t, _ut_tdm_vblank_cb, &temp) == TDM_ERROR_NONE);
while (temp == 0)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
end = tdm_helper_get_time();
#if 0
if (!ut_tdm_output_is_connected(output))
continue;
- ASSERT_TRUE(ut_tdm_output_unset(dpy, output) == true);
-
ASSERT_TRUE(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF) == TDM_ERROR_NONE);
ASSERT_TRUE(tdm_vblank_wait(vblanks[v], 0, 0, 1, _ut_tdm_vblank_cb, NULL) == TDM_ERROR_DPMS_OFF);
if (!ut_tdm_output_is_connected(output))
continue;
- ASSERT_TRUE(ut_tdm_output_unset(dpy, output) == true);
-
ASSERT_TRUE(tdm_vblank_wait(vblanks[v], 0, 0, 1, _ut_tdm_vblank_cb, &temp) == TDM_ERROR_NONE);
ASSERT_TRUE(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF) == TDM_ERROR_NONE);
if (!ut_tdm_output_is_connected(output))
continue;
- ASSERT_TRUE(ut_tdm_output_unset(dpy, output) == true);
-
ASSERT_TRUE(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF) == TDM_ERROR_NONE);
ASSERT_TRUE(tdm_vblank_set_enable_fake(vblanks[v], 1) == TDM_ERROR_NONE);
start = tdm_helper_get_time();
ASSERT_TRUE(tdm_vblank_wait(vblanks[v], 0, 0, 1, _ut_tdm_vblank_cb, &cur_seq) == TDM_ERROR_NONE);
while (cur_seq == 0)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ ASSERT_TRUE(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 */
start = tdm_helper_get_time();
ASSERT_TRUE(tdm_vblank_wait(vblanks[v], 0, 0, 1, _ut_tdm_vblank_cb, &cur_seq) == TDM_ERROR_NONE);
while (cur_seq == 0)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ ASSERT_TRUE(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 */
start = tdm_helper_get_time();
ASSERT_TRUE(tdm_vblank_wait(vblanks[v], 0, 0, 1, _ut_tdm_vblank_cb, &cur_seq) == TDM_ERROR_NONE);
while (cur_seq == 0)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ ASSERT_TRUE(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 */
start = tdm_helper_get_time();
while (cur_seq[2] == 0)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ ASSERT_TRUE(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_TRUE(cur_seq[0] == 0);
while (cur_seq[1] == 0)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
ASSERT_TRUE(cur_seq[0] == 0);
while (cur_seq[0] == 0)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ ASSERT_TRUE(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);
}
while (cur_seq[2] == 0)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
ASSERT_TRUE(cur_seq[1] == 0);
ASSERT_TRUE(cur_seq[0] == 0);
while (cur_seq[1] == 0)
- ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+ ASSERT_TRUE(ut_tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
ASSERT_TRUE(cur_seq[0] == 0);
}
}
}
+TEST_P(TDMVblank, DISABLED_VblankWaitBeforeDpmsOff)
+{
+ /* wait vblank -> dpms off -> then? (vblank handler is called? or not?) */
+}
+
+#ifdef TDM_UT_TEST_WITH_PARAMS
INSTANTIATE_TEST_CASE_P(TDMVblankParams,
TDMVblank,
Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
-
-#endif
+#else
+INSTANTIATE_TEST_CASE_P(TDMVblankParams,
+ TDMVblank,
+ Values(TDM_DEFAULT_MODULE));
+#endif
\ No newline at end of file