5 #include <sys/timerfd.h>
11 #include <gtest/gtest.h>
17 #include <tbm_bufmgr.h>
18 #include <tbm_drm_helper.h>
22 #include "tdm_helper.h"
23 #include "tdm_config.h"
25 #include "tdm_macro.h"
28 //#define TDM_UT_TEST_WITH_PARAMS
30 extern bool enable_porting_debug;
36 #define TDM_DBG(fmt, args...) tdm_log_print(TDM_LOG_LEVEL_DBG, fmt, ##args)
37 #define TDM_INFO(fmt, args...) tdm_log_print(TDM_LOG_LEVEL_INFO, fmt, ##args)
38 #define TDM_WRN(fmt, args...) tdm_log_print(TDM_LOG_LEVEL_WRN, fmt, ##args)
39 #define TDM_ERR(fmt, args...) tdm_log_print(TDM_LOG_LEVEL_ERR, fmt, ##args)
41 #define TDM_UT_INFO(fmt, args...) tdm_log_print_stdout(TDM_LOG_LEVEL_INFO, fmt, ##args)
42 #define TDM_UT_ERR(fmt, args...) tdm_log_print_stdout(TDM_LOG_LEVEL_ERR, fmt, ##args)
44 #define TDM_UT_ENTRY() \
45 TDM_ERR("--------------------------------------------- %s", typeid(*this).name())
47 #define TDM_UT_CHECK_FLAG(FLAG) \
50 TDM_UT_INFO("[ ] not supported");\
53 #define TDM_UT_SKIP_FLAG(FLAG) \
56 TDM_UT_INFO("[ SKIPPED ] not supported");\
61 #define TDM_UT_RETURN_IF_FAIL(cond) \
64 TDM_UT_ERR("[%s,%d] '%s' failed", __FUNCTION__, __LINE__, #cond); \
68 #define TDM_UT_RETURN_FALSE_IF_FAIL(cond) \
71 TDM_UT_ERR("[%s,%d] '%s' failed", __FUNCTION__, __LINE__, #cond); \
75 #define TDM_UT_RETURN_VAL_IF_FAIL(cond, val) \
78 TDM_UT_ERR("[%s,%d] '%s' failed", __FUNCTION__, __LINE__, #cond); \
82 #define TDM_UT_GOTO_IF_FAIL(cond, dst) \
85 TDM_UT_ERR("[%s,%d] '%s' failed", __FUNCTION__, __LINE__, #cond); \
90 #define TDM_UT_ASSERT_TRUE(cond, fmt, args...) \
93 if (enable_porting_debug) \
94 TDM_UT_ERR(fmt, ##args); \
95 GTEST_TEST_BOOLEAN_((cond), #cond, false, true, GTEST_FATAL_FAILURE_); \
98 #define TDM_UT_EXPECT_TRUE(cond, fmt, args...) \
101 if (enable_porting_debug) \
102 TDM_UT_ERR(fmt, ##args); \
103 GTEST_TEST_BOOLEAN_((cond), #cond, false, true, GTEST_NONFATAL_FAILURE_); \
107 #define TDM_UT_ASK_YNR(fmt, ...) \
109 if (enable_porting_debug) { \
111 printf(fmt" [Y]es, [n]o, [r]etry: ", ##__VA_ARGS__); \
118 while ((tch = getchar()) != '\n' && tch != EOF); \
120 } while (ch != 'y' && ch != 'Y' && ch != 'n' && ch != 'N' && ch != 'r' && ch != 'R'); \
121 if (ch == 'n' || ch == 'N') \
122 GTEST_FATAL_FAILURE_("tc failed"); \
123 if (ch == 'r' || ch == 'R') \
128 #define TDM_UT_ASK_YN(fmt, ...) \
130 if (enable_porting_debug) { \
132 printf(fmt" [Y]es, [n]o: ", ##__VA_ARGS__); \
139 while ((tch = getchar()) != '\n' && tch != EOF); \
141 } while (ch != 'y' && ch != 'Y' && ch != 'n' && ch != 'N'); \
142 if (ch == 'n' || ch == 'N') \
143 GTEST_FATAL_FAILURE_("tc failed"); \
147 #define TDM_UT_SIZE_ALIGN(value, base) (((value) + ((base) - 1)) & ~((base) - 1))
149 #define TDM_UT_DUMP_DIR "/tmp/tdm_dump"
150 #define TDM_UT_INVALID_VALUE -42
151 #define TDM_UT_BUFFER_SIZE 256
152 #define TDM_UT_VBLANK_NAME "ut_tdm_vblank"
154 using ::testing::TestWithParam;
155 using ::testing::Bool;
156 using ::testing::Values;
157 using ::testing::Combine;
159 #ifdef TDM_UT_TEST_WITH_PARAMS
160 class TDMEnv : public TestWithParam< ::testing::tuple<bool, bool, const char*> >
167 class TDMEnv : public TestWithParam< ::testing::tuple<const char*> >
175 class TDMDisplay : public TDMEnv
182 bool has_capture_cap;
189 class TDMOutput : public TDMDisplay
193 tdm_output **outputs;
196 bool done1, done2, done3;
203 #ifdef TIZEN_TEST_GCOV
204 extern "C" void __gcov_flush(void);
207 tdm_error ut_tdm_display_handle_events(tdm_display *dpy);
208 bool ut_tdm_display_has_pp_capability(tdm_display *dpy);
209 bool ut_tdm_display_has_capture_capability(tdm_display *dpy);
211 bool ut_tdm_buffer_create(int width, int height, tbm_format format, int flags, bool fill,
212 int count, tbm_surface_h *buffers);
214 bool ut_tdm_output_is_async_dpms_enable(tdm_output *output);
215 bool ut_tdm_output_is_hwc_enable(tdm_output *output);
216 bool ut_tdm_output_is_aod_enable(tdm_output *output);
217 bool ut_tdm_output_is_connected(tdm_output *output);
218 bool ut_tdm_output_mode_setting(tdm_output *output);
219 bool ut_tdm_output_prepare(tdm_display *dpy, tdm_output *output, bool fill);
220 bool ut_tdm_output_prepare_all_output(tdm_display *dpy, tdm_output **outputs, int output_count, bool fill);
221 bool ut_tdm_output_unset(tdm_display *dpy, tdm_output *output);
222 double ut_tdm_output_get_vblank_interval_time(tdm_output *output);
223 tdm_layer *ut_tdm_output_get_primary_layer(tdm_output *output);
225 bool ut_tdm_layer_is_cursor_layer(tdm_layer *layer);
226 bool ut_tdm_layer_is_primary_layer(tdm_layer *layer);
227 bool ut_tdm_layer_is_video_layer(tdm_layer *layer);
228 bool ut_tdm_layer_support_scale(tdm_layer *layer);
229 bool ut_tdm_layer_support_no_crop(tdm_layer *layer);
230 bool ut_tdm_layer_prepare_buffer(tdm_layer *layer, tbm_surface_h *buffers, int buffer_count, bool fill);
231 bool ut_tdm_layer_prepare_buffer_queue(tdm_layer *layer, tbm_surface_queue_h *buffer_queue);
232 bool ut_tdm_layer_fill_info(tdm_layer *layer, tbm_surface_h buffer, tbm_surface_queue_h buffer_queue, tdm_info_layer *info);
233 bool ut_tdm_layer_set_buffer(tdm_layer *layer, tbm_surface_h buffer);
234 bool ut_tdm_layer_set_buffer_with_pos(tdm_layer *layer, tbm_surface_h buffer, tdm_pos *pos);
235 unsigned int ut_tdm_layer_get_output_pipe(tdm_layer *layer);
236 tbm_format ut_tdm_layer_find_best_format(tdm_layer *layer);
237 bool ut_tdm_layer_is_avaiable(tdm_layer *layer);
239 bool ut_tdm_pp_fill_info(tbm_surface_h srcbuf, tbm_surface_h dstbuf, tdm_transform transform, tdm_info_pp *info);
240 bool ut_tdm_capture_fill_info(tdm_output *output, tbm_surface_h buffer, tdm_transform transform,
241 tdm_capture_type type, int frequency, bool stretch, tdm_info_capture *info);
243 /******************************************************************************/
244 /** testing for checking backend's basic implementation **/
245 /******************************************************************************/
246 class TDMBackendEnv : public TDMEnv
253 class TDMBackendBasic : public TDMBackendEnv
258 tdm_output **outputs;
264 tbm_surface_h buffers[3];
269 void UnsetOutput(void);
270 void DestroyBuffers(void);
273 class TDMBackendDisplay : public TDMBackendBasic
276 void SetUp(void) { TDMBackendBasic::SetUp(); }
277 void TearDown(void) { TDMBackendBasic::TearDown(); }