package version up to 1.16.10
[platform/core/uifw/libtdm.git] / utests / src / ut_tdm_backend_capture.cpp
1 /**************************************************************************
2  *
3  * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
4  *
5  * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
6  * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
7  * Contact: Roman Marchenko <r.marchenko@samsung.com>
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a
10  * copy of this software and associated documentation files (the
11  * "Software"), to deal in the Software without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sub license, and/or sell copies of the Software, and to
14  * permit persons to whom the Software is furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice and this permission notice (including the
18  * next paragraph) shall be included in all copies or substantial portions
19  * of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
24  * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
25  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
26  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28  *
29 **************************************************************************/
30
31 #include "ut_tdm.h"
32
33 class TDMBackendCapture : public TDMBackendDisplay
34 {
35 public:
36         bool has_capture_cap;
37
38         tdm_capture *capture;
39         tdm_capture_capability capabilities;
40         const tbm_format *formats;
41         int format_count;
42         int min_w;
43         int min_h;
44         int max_w;
45         int max_h;
46         int preferred_align;
47
48         tbm_surface_h buffers[3];
49
50         tdm_info_capture info;
51
52         tdm_output *output;
53         unsigned int pipe;
54         const tdm_output_mode *mode;
55
56         tdm_layer *dst_layer;
57         int dst_zpos;
58         int dst_layer_index;
59         tdm_pos dst_pos;
60
61         bool stream_exit;
62         int stream_count;
63
64         TDMBackendCapture();
65         void SetUp(void);
66         void TearDown(void);
67
68         bool FindLayer(int output_idx, tbm_format fmt, tdm_pos *punch);
69         bool TestPrepareDefault(void);
70         bool TestPrepare(int output_idx, int w, int h, tbm_format fmt, tdm_transform t, tdm_capture_type c, int frequency, bool stretch);
71         void TestDone(void);
72         void ShowBuffer(int b, tdm_pos *pos);
73         void HideLayer(void);
74         void DumpBuffer(int b, char *test);
75         void DestroyBuffers(void);
76 };
77
78 TDMBackendCapture::TDMBackendCapture()
79 {
80         has_capture_cap = false;
81         capture = NULL;
82         capabilities = (tdm_capture_capability)0;
83         formats = NULL;
84         format_count = 0;
85         min_w = min_h = max_w = max_h = preferred_align = -1;
86
87         for (int b = 0; b < 3; b++)
88                 buffers[b] = NULL;
89         memset(&info, 0, sizeof info);
90
91         output = NULL;
92         pipe = 0;
93         mode = NULL;
94
95         dst_layer = NULL;
96         dst_zpos = 0;
97         dst_layer_index = 0;
98         memset(&dst_pos, 0, sizeof dst_pos);
99
100         stream_exit = false;
101         stream_count = 0;
102 }
103
104 void TDMBackendCapture::SetUp(void)
105 {
106         tdm_display_capability dpy_capabilities;
107
108         TDMBackendDisplay::SetUp();
109
110         ASSERT_EQ(tdm_display_get_capabilities(dpy, &dpy_capabilities), TDM_ERROR_NONE);
111         has_capture_cap = dpy_capabilities & TDM_DISPLAY_CAPABILITY_CAPTURE;
112
113         if (!has_capture_cap)
114                 return;
115
116         ASSERT_EQ(tdm_display_get_capture_capabilities(dpy, &capabilities), TDM_ERROR_NONE);
117         ASSERT_GT(capabilities, 0);
118         ASSERT_EQ(tdm_display_get_capture_available_formats(dpy, &formats, &format_count), TDM_ERROR_NONE);
119         ASSERT_NE(formats, NULL);
120         ASSERT_GT(format_count, 0);
121         ASSERT_EQ(tdm_display_get_capture_available_size(dpy, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_NONE);
122         ASSERT_TRUE(min_w == -1 || min_w > 0);
123         ASSERT_TRUE(min_h == -1 || min_h > 0);
124         ASSERT_TRUE(max_w == -1 || max_w > 0);
125         ASSERT_TRUE(max_h == -1 || max_h > 0);
126         ASSERT_TRUE(preferred_align == -1 || preferred_align > 0);
127
128         for (int o = 0; o < output_count; o++) {
129                 if (!ut_tdm_output_is_connected(outputs[o]))
130                         continue;
131
132                 ASSERT_EQ(ut_tdm_output_prepare(dpy, outputs[o], true), true);
133         }
134 }
135
136 void TDMBackendCapture::TearDown(void)
137 {
138         if (capture)
139                 tdm_capture_destroy(capture);
140
141         for (int o = 0; o < output_count; o++) {
142                 if (!ut_tdm_output_is_connected(outputs[o]))
143                         continue;
144
145                 ASSERT_EQ(ut_tdm_output_unset(dpy, outputs[o]), true);
146         }
147
148         DestroyBuffers();
149
150         TDMBackendDisplay::TearDown();
151 }
152
153 bool TDMBackendCapture::FindLayer(int output_idx, tbm_format fmt, tdm_pos *punch)
154 {
155         tdm_error ret;
156         int count;
157         int primary_zpos, zpos;
158         tdm_layer *primary = ut_tdm_output_get_primary_layer(outputs[output_idx]);
159         TDM_UT_RETURN_FALSE_IF_FAIL(primary != NULL);
160         TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_layer_count(outputs[output_idx], &count) == TDM_ERROR_NONE);
161         TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_zpos(primary, &primary_zpos) == TDM_ERROR_NONE);
162
163         dst_layer = NULL;
164
165         for (int l = 0; l < count; l++) {
166                 unsigned int usable;
167                 const tbm_format *dst_formats;
168                 int dst_format_count;
169
170                 tdm_layer *temp = tdm_output_get_layer(outputs[output_idx], l, &ret);
171                 TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
172                 TDM_UT_RETURN_FALSE_IF_FAIL(temp != NULL);
173                 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_is_usable(temp, &usable) == TDM_ERROR_NONE);
174                 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_zpos(temp, &zpos) == TDM_ERROR_NONE);
175                 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_available_formats(temp, &dst_formats, &dst_format_count) == TDM_ERROR_NONE);
176                 TDM_UT_RETURN_FALSE_IF_FAIL(dst_formats != NULL);
177                 TDM_UT_RETURN_FALSE_IF_FAIL(dst_format_count > 0);
178
179                 if (usable) {
180                         bool found = false;
181                         for (int f = 0; f < dst_format_count; f++) {
182                                 if (dst_formats[f] == fmt) {
183                                         found = true;
184                                         break;
185                                 }
186                         }
187                         if (!found)
188                                 continue;
189                         dst_layer = temp;
190                         dst_zpos = zpos;
191                         TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_index(dst_layer, &dst_layer_index) == TDM_ERROR_NONE);
192                         break;
193                 }
194         }
195
196         if (dst_layer && (dst_zpos < primary_zpos)) {
197                 tbm_surface_h displaying_buffer = tdm_layer_get_displaying_buffer(primary, &ret);
198                 TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
199                 TDM_UT_RETURN_FALSE_IF_FAIL(displaying_buffer != NULL);
200                 tdm_helper_clear_buffer_pos(displaying_buffer, punch);
201         }
202
203         return true;
204 }
205
206 bool TDMBackendCapture::TestPrepareDefault(void)
207 {
208         tdm_error ret;
209
210         for (int o = 0; o < output_count; o++) {
211                 if (!ut_tdm_output_is_connected(outputs[o]))
212                         continue;
213
214                 capture = tdm_output_create_capture(outputs[o], &ret);
215                 TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
216                 TDM_UT_RETURN_FALSE_IF_FAIL(capture != NULL);
217
218                 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);
219                 TDM_UT_RETURN_FALSE_IF_FAIL(ut_tdm_capture_fill_info(outputs[o], buffers[0], TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1, false, &info) == true);
220                 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_capture_set_info(capture, &info) == TDM_ERROR_NONE);
221
222                 output = outputs[o];
223
224                 if (capture)
225                         break;
226         }
227
228         return (capture) ? true : false;
229 }
230
231 bool TDMBackendCapture::TestPrepare(int output_idx, int w, int h, tbm_format fmt, tdm_transform t, tdm_capture_type c, int frequency, bool stretch)
232 {
233         tdm_error ret;
234         int flags = 0;
235
236         TDM_UT_RETURN_FALSE_IF_FAIL(outputs != NULL);
237         TDM_UT_RETURN_FALSE_IF_FAIL(output_count > 0);
238         TDM_UT_RETURN_FALSE_IF_FAIL(output_count >= output_idx);
239
240         TDM_UT_RETURN_FALSE_IF_FAIL(tdm_display_get_capture_capabilities(dpy, &capabilities) == TDM_ERROR_NONE);
241         TDM_UT_RETURN_FALSE_IF_FAIL(capabilities > 0);
242
243         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);
244         TDM_UT_RETURN_FALSE_IF_FAIL(min_w == -1 || min_w > 0);
245         TDM_UT_RETURN_FALSE_IF_FAIL(min_h == -1 || min_h > 0);
246         TDM_UT_RETURN_FALSE_IF_FAIL(max_w == -1 || max_w > 0);
247         TDM_UT_RETURN_FALSE_IF_FAIL(max_h == -1 || max_h > 0);
248         TDM_UT_RETURN_FALSE_IF_FAIL(preferred_align == -1 || preferred_align > 0);
249
250         capture = tdm_output_create_capture(outputs[output_idx], &ret);
251         TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
252         TDM_UT_RETURN_FALSE_IF_FAIL(capture != NULL);
253
254         if (dst_layer) {
255                 tdm_layer_capability capabilities;
256                 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_capabilities(dst_layer, &capabilities) == TDM_ERROR_NONE);
257                 if (capabilities & TDM_LAYER_CAPABILITY_SCANOUT)
258                         flags |= TBM_BO_SCANOUT;
259         }
260
261         TDM_UT_RETURN_FALSE_IF_FAIL(ut_tdm_buffer_create(w, h, fmt, flags, false, 3, buffers) == true);
262         TDM_UT_RETURN_FALSE_IF_FAIL(ut_tdm_capture_fill_info(outputs[output_idx], buffers[0], t, c, frequency, stretch, &info) == true);
263         TDM_UT_RETURN_FALSE_IF_FAIL(tdm_capture_set_info(capture, &info) == TDM_ERROR_NONE);
264
265         output = outputs[output_idx];
266
267         return true;
268 }
269
270 void TDMBackendCapture::TestDone(void)
271 {
272         if (capture) {
273                 tdm_capture_destroy(capture);
274                 capture = NULL;
275         }
276
277         DestroyBuffers();
278 }
279
280 void TDMBackendCapture::DumpBuffer(int b, char *test)
281 {
282         char filename[256];
283         if (test)
284                 snprintf(filename, sizeof filename, "%s_%s_%d", typeid(*this).name(), test, b);
285         else
286                 snprintf(filename, sizeof filename, "%s_%d", typeid(*this).name(), b);
287         tdm_helper_dump_buffer_str(buffers[b], NULL, filename);
288 }
289
290 void TDMBackendCapture::ShowBuffer(int b, tdm_pos *pos)
291 {
292         ASSERT_NE(output, NULL);
293         ASSERT_NE(dst_layer, NULL);
294
295         ASSERT_EQ(ut_tdm_layer_set_buffer_with_pos(dst_layer, buffers[b], pos), true);
296         ASSERT_EQ(tdm_output_commit(output, 0, NULL, NULL), TDM_ERROR_NONE);
297 }
298
299 void TDMBackendCapture::HideLayer(void)
300 {
301         ASSERT_NE(output, NULL);
302         ASSERT_NE(dst_layer, NULL);
303
304         tdm_layer_unset_buffer(dst_layer);
305         tdm_output_commit(output, 0, NULL, NULL);
306
307         dst_layer = NULL;
308 }
309
310 void TDMBackendCapture::DestroyBuffers(void)
311 {
312         for (int b = 0; b < 3; b++) {
313                 tbm_surface_destroy(buffers[b]);
314                 buffers[b] = NULL;
315         }
316 }
317
318 static void
319 _ut_tdm_capture_fit_rect(int src_w, int src_h, int dst_w, int dst_h, tdm_pos *fit)
320 {
321         float rw, rh;
322
323         if (src_w <= 0 || src_h <= 0 || dst_w <= 0 || dst_h <= 0 || !fit)
324                 return;
325
326         rw = (float)src_w / dst_w;
327         rh = (float)src_h / dst_h;
328
329         if (rw > rh) {
330                 fit->w = dst_w;
331                 fit->h = src_h / rw;
332                 fit->x = 0;
333                 fit->y = (dst_h - fit->h) / 2;
334         } else if (rw < rh) {
335                 fit->w = src_w / rh;
336                 fit->h = dst_h;
337                 fit->x = (dst_w - fit->w) / 2;
338                 fit->y = 0;
339         } else {
340                 fit->w = dst_w;
341                 fit->h = dst_h;
342                 fit->x = 0;
343                 fit->y = 0;
344         }
345
346         if (fit->x % 2)
347                 fit->x = fit->x - 1;
348 }
349
350 bool
351 ut_tdm_capture_fill_info(tdm_output *output, tbm_surface_h buffer, tdm_transform transform,
352                                                  tdm_capture_type type, int frequency, bool stretch, tdm_info_capture *info)
353 {
354         int bw, bh;
355         const tdm_output_mode *mode = NULL;
356
357         TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_mode(output, &mode) == TDM_ERROR_NONE);
358         TDM_UT_RETURN_FALSE_IF_FAIL(mode != NULL);
359
360         memset(info, 0, sizeof *info);
361
362         bw = bh = TDM_UT_INVALID_VALUE;
363         tdm_helper_get_buffer_full_size(buffer, &bw, &bh);
364
365         TDM_UT_RETURN_FALSE_IF_FAIL(bw != TDM_UT_INVALID_VALUE);
366         TDM_UT_RETURN_FALSE_IF_FAIL(bw >= tbm_surface_get_width(buffer));
367         TDM_UT_RETURN_FALSE_IF_FAIL(bh != TDM_UT_INVALID_VALUE);
368         TDM_UT_RETURN_FALSE_IF_FAIL(bh >= tbm_surface_get_height(buffer));
369         info->dst_config.size.h = bw;
370         info->dst_config.size.v = bh;
371
372         if (stretch) {
373                 info->dst_config.pos.x = 0;
374                 info->dst_config.pos.y = 0;
375                 info->dst_config.pos.w = tbm_surface_get_width(buffer);
376                 info->dst_config.pos.h = tbm_surface_get_height(buffer);
377         } else {
378                 _ut_tdm_capture_fit_rect(mode->hdisplay, mode->vdisplay,
379                                                                  tbm_surface_get_width(buffer), tbm_surface_get_height(buffer),
380                                                                  &info->dst_config.pos);
381         }
382
383         info->dst_config.format = tbm_surface_get_format(buffer);
384
385         info->transform = transform;
386         info->type = type;
387         info->flags = 0;
388
389         if (frequency <= 0)
390                 frequency = mode->vrefresh;
391
392         info->frequency = frequency;
393
394         TDM_UT_INFO("filling capture info done: dst_config(%dx%d: %d,%d %dx%d: %c%c%c%c) transform(%s) type(%s) freq(%d)",
395                                 info->dst_config.size.h, info->dst_config.size.v,
396                                 info->dst_config.pos.x, info->dst_config.pos.y, info->dst_config.pos.w, info->dst_config.pos.h,
397                                 FOURCC_STR(info->dst_config.format),
398                                 tdm_transform_str(info->transform), tdm_capture_type_str(info->type), info->frequency);
399
400         return true;
401 }
402
403 TEST_P(TDMBackendCapture, CaptureDispalyGetAvaiableFormats)
404 {
405         const tbm_format *formats = (const tbm_format *)TDM_UT_INVALID_VALUE;
406         int count = TDM_UT_INVALID_VALUE;
407         if (has_capture_cap) {
408                 ASSERT_EQ(tdm_display_get_capture_available_formats(dpy, &formats, &count), TDM_ERROR_NONE);
409                 ASSERT_TRUE(formats != NULL && formats != (const tbm_format *)TDM_UT_INVALID_VALUE);
410                 ASSERT_TRUE(count > 0 && count != TDM_UT_INVALID_VALUE);
411         } else {
412                 ASSERT_EQ(tdm_display_get_capture_available_formats(dpy, &formats, &count), TDM_ERROR_NO_CAPABILITY);
413                 ASSERT_EQ(formats, (const tbm_format *)TDM_UT_INVALID_VALUE);
414                 ASSERT_EQ(count, TDM_UT_INVALID_VALUE);
415         }
416 }
417
418 TEST_P(TDMBackendCapture, CaptureDispalyGetAvaiableFormatsNullObject)
419 {
420         const tbm_format *formats = (const tbm_format *)TDM_UT_INVALID_VALUE;
421         int count = TDM_UT_INVALID_VALUE;
422         ASSERT_EQ(tdm_display_get_capture_available_formats(NULL, &formats, &count), TDM_ERROR_INVALID_PARAMETER);
423         ASSERT_EQ(formats, (const tbm_format *)TDM_UT_INVALID_VALUE);
424         ASSERT_EQ(count, TDM_UT_INVALID_VALUE);
425 }
426
427 TEST_P(TDMBackendCapture, CaptureDispalyGetAvaiableFormatsNullOther)
428 {
429         ASSERT_EQ(tdm_display_get_capture_available_formats(dpy, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
430 }
431
432 TEST_P(TDMBackendCapture, CaptureDispalyGetAvaiableSize)
433 {
434         int min_w = TDM_UT_INVALID_VALUE;
435         int min_h = TDM_UT_INVALID_VALUE;
436         int max_w = TDM_UT_INVALID_VALUE;
437         int max_h = TDM_UT_INVALID_VALUE;
438         int preferred_align = TDM_UT_INVALID_VALUE;
439         if (has_capture_cap) {
440                 ASSERT_EQ(tdm_display_get_capture_available_size(dpy, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_NONE);
441                 ASSERT_NE(min_w, TDM_UT_INVALID_VALUE);
442                 ASSERT_NE(min_h, TDM_UT_INVALID_VALUE);
443                 ASSERT_NE(max_w, TDM_UT_INVALID_VALUE);
444                 ASSERT_NE(max_h, TDM_UT_INVALID_VALUE);
445                 ASSERT_NE(preferred_align, TDM_UT_INVALID_VALUE);
446         } else {
447                 ASSERT_EQ(tdm_display_get_capture_available_size(dpy, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_NO_CAPABILITY);
448                 ASSERT_EQ(min_w, TDM_UT_INVALID_VALUE);
449                 ASSERT_EQ(min_h, TDM_UT_INVALID_VALUE);
450                 ASSERT_EQ(max_w, TDM_UT_INVALID_VALUE);
451                 ASSERT_EQ(max_h, TDM_UT_INVALID_VALUE);
452                 ASSERT_EQ(preferred_align, TDM_UT_INVALID_VALUE);
453         }
454 }
455
456 TEST_P(TDMBackendCapture, CaptureDispalyGetAvaiableSizeNullObject)
457 {
458         int min_w = TDM_UT_INVALID_VALUE;
459         int min_h = TDM_UT_INVALID_VALUE;
460         int max_w = TDM_UT_INVALID_VALUE;
461         int max_h = TDM_UT_INVALID_VALUE;
462         int preferred_align = TDM_UT_INVALID_VALUE;
463         ASSERT_EQ(tdm_display_get_capture_available_size(NULL, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_INVALID_PARAMETER);
464         ASSERT_EQ(min_w, TDM_UT_INVALID_VALUE);
465         ASSERT_EQ(min_h, TDM_UT_INVALID_VALUE);
466         ASSERT_EQ(max_w, TDM_UT_INVALID_VALUE);
467         ASSERT_EQ(max_h, TDM_UT_INVALID_VALUE);
468         ASSERT_EQ(preferred_align, TDM_UT_INVALID_VALUE);
469 }
470
471 TEST_P(TDMBackendCapture, CaptureDispalyGetAvaiableSizeNullOther)
472 {
473         if (has_capture_cap)
474                 ASSERT_EQ(tdm_display_get_capture_available_size(dpy, NULL, NULL, NULL, NULL, NULL), TDM_ERROR_NONE);
475         else
476                 ASSERT_EQ(tdm_display_get_capture_available_size(dpy, NULL, NULL, NULL, NULL, NULL), TDM_ERROR_NO_CAPABILITY);
477 }
478
479 TEST_P(TDMBackendCapture, CaptureDestroy)
480 {
481         TDM_UT_SKIP_FLAG(has_capture_cap);
482         TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
483
484         ASSERT_EQ(TestPrepareDefault(), true);
485
486         TestDone();
487 }
488
489 TEST_P(TDMBackendCapture, CaptureDestroyNullObject)
490 {
491         TDM_UT_SKIP_FLAG(has_capture_cap);
492         TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
493
494         tdm_capture_destroy(NULL);
495 }
496
497 TEST_P(TDMBackendCapture, CaptureSetInfo)
498 {
499         /* tested in CaptureNoScaleNoTransformNoCSC */
500 }
501
502 TEST_P(TDMBackendCapture, CaptureSetInfoNullObject)
503 {
504         TDM_UT_SKIP_FLAG(has_capture_cap);
505         TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
506
507         tdm_info_capture info;
508         memset(&info, 0, sizeof info);
509         ASSERT_EQ(tdm_capture_set_info(NULL, &info), TDM_ERROR_INVALID_PARAMETER);
510 }
511
512 TEST_P(TDMBackendCapture, CaptureSetInfoNullOther)
513 {
514         TDM_UT_SKIP_FLAG(has_capture_cap);
515         TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
516
517         ASSERT_EQ(TestPrepareDefault(), true);
518
519         ASSERT_EQ(tdm_capture_set_info(capture, NULL), TDM_ERROR_INVALID_PARAMETER);
520
521         TestDone();
522 }
523
524 static void
525 _ut_tdm_capture_done_cb(tdm_capture *capture, tbm_surface_h buffer, void *user_data)
526 {
527         bool *done = (bool*)user_data;
528         if (done)
529                 *done = true;
530 }
531
532 TEST_P(TDMBackendCapture, CaptureSetDoneHandler)
533 {
534         TDM_UT_SKIP_FLAG(has_capture_cap);
535         TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
536
537         ASSERT_EQ(TestPrepareDefault(), true);
538
539         ASSERT_EQ(tdm_capture_set_done_handler(capture, _ut_tdm_capture_done_cb, NULL), TDM_ERROR_NONE);
540
541         TestDone();
542 }
543
544 TEST_P(TDMBackendCapture, CaptureSetDoneHandlerNullObject)
545 {
546         TDM_UT_SKIP_FLAG(has_capture_cap);
547         TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
548
549         ASSERT_EQ(tdm_capture_set_done_handler(NULL, _ut_tdm_capture_done_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
550 }
551
552 TEST_P(TDMBackendCapture, CaptureSetDoneHandlerNullOther)
553 {
554         TDM_UT_SKIP_FLAG(has_capture_cap);
555         TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
556
557         ASSERT_EQ(TestPrepareDefault(), true);
558
559         ASSERT_EQ(tdm_capture_set_done_handler(capture, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
560
561         TestDone();
562 }
563
564 TEST_P(TDMBackendCapture, CaptureAttach)
565 {
566         TDM_UT_SKIP_FLAG(has_capture_cap);
567         TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
568
569         for (int o = 0; o < output_count; o++) {
570
571                 if (!ut_tdm_output_is_connected(outputs[o]))
572                         continue;
573
574                 for (int f = 0; f < format_count; f++) {
575                         FindLayer(o, formats[f], &dst_pos);
576
577                         ASSERT_EQ(TestPrepare(o, TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
578                                                                   TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1, false), true);
579
580                         for (int b = 0; b < 3; b++)
581                                 ASSERT_EQ(tdm_capture_attach(capture, buffers[b]), TDM_ERROR_NONE);
582
583                         TestDone();
584                 }
585         }
586 }
587
588 TEST_P(TDMBackendCapture, CaptureAttachNullObject)
589 {
590         TDM_UT_SKIP_FLAG(has_capture_cap);
591         TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
592
593         tbm_surface_h buffer = (tbm_surface_h)TDM_UT_BUFFER_SIZE;
594
595         ASSERT_EQ(tdm_capture_attach(NULL, buffer), TDM_ERROR_INVALID_PARAMETER);
596 }
597
598 TEST_P(TDMBackendCapture, CaptureAttachNullOther)
599 {
600         TDM_UT_SKIP_FLAG(has_capture_cap);
601         TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
602
603         ASSERT_EQ(TestPrepareDefault(), true);
604
605         ASSERT_EQ(tdm_capture_attach(capture, NULL), TDM_ERROR_INVALID_PARAMETER);
606
607         TestDone();
608 }
609
610 TEST_P(TDMBackendCapture, CaptureCommit)
611 {
612         TDM_UT_SKIP_FLAG(has_capture_cap);
613         TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
614
615         ASSERT_EQ(TestPrepareDefault(), true);
616
617         ASSERT_EQ(tdm_capture_commit(capture), TDM_ERROR_NONE);
618
619         TestDone();
620 }
621
622 TEST_P(TDMBackendCapture, CaptureCommitNullOBject)
623 {
624         TDM_UT_SKIP_FLAG(has_capture_cap);
625         TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
626
627         ASSERT_EQ(tdm_capture_commit(NULL), TDM_ERROR_INVALID_PARAMETER);
628 }
629
630 TEST_P(TDMBackendCapture, CaptureCommitDpmsOff)
631 {
632         TDM_UT_SKIP_FLAG(has_capture_cap);
633         TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
634
635         ASSERT_EQ(TestPrepareDefault(), true);
636
637         ASSERT_EQ(ut_tdm_output_unset(dpy, output), true);
638
639         ASSERT_EQ(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
640
641         ASSERT_EQ(tdm_capture_commit(capture), TDM_ERROR_BAD_REQUEST);
642
643         TestDone();
644 }
645
646 static void
647 _ut_tdm_capture_done_cb2(tdm_capture *capture, tbm_surface_h buffer, void *user_data)
648 {
649         int *done = (int*)user_data;
650         if (done)
651                 (*done)++;
652 }
653
654 TEST_P(TDMBackendCapture, CaptureDestroyWithoutCommit)
655 {
656         TDM_UT_SKIP_FLAG(has_capture_cap);
657         TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
658
659         for (int o = 0; o < output_count; o++) {
660                 const tdm_output_mode *mode = NULL;
661                 int f = 0;
662
663                 if (!ut_tdm_output_is_connected(outputs[o]))
664                         continue;
665
666                 ASSERT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE);
667
668                 FindLayer(o, formats[f], &dst_pos);
669
670                 ASSERT_EQ(TestPrepare(o, TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
671                                                           TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1, false), true);
672
673                 ASSERT_EQ(tdm_capture_set_done_handler(capture, _ut_tdm_capture_done_cb2, NULL), TDM_ERROR_NONE);
674
675                 for (int b = 0; b < 3; b++)
676                         ASSERT_EQ(tdm_capture_attach(capture, buffers[b]), TDM_ERROR_NONE);
677
678                 tdm_capture_destroy(capture);
679                 capture = NULL;
680
681                 TestDone();
682         }
683 }
684
685 TEST_P(TDMBackendCapture, CaptureDestroyBeforeDone)
686 {
687         TDM_UT_SKIP_FLAG(has_capture_cap);
688         TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
689
690         for (int o = 0; o < output_count; o++) {
691                 const tdm_output_mode *mode = NULL;
692                 int f = 0;
693
694                 if (!ut_tdm_output_is_connected(outputs[o]))
695                         continue;
696
697                 ASSERT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE);
698
699                 FindLayer(o, formats[f], &dst_pos);
700
701                 ASSERT_EQ(TestPrepare(o, TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
702                                                           TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1, false), true);
703
704                 ASSERT_EQ(tdm_capture_set_done_handler(capture, _ut_tdm_capture_done_cb2, NULL), TDM_ERROR_NONE);
705
706                 for (int b = 0; b < 3; b++)
707                         ASSERT_EQ(tdm_capture_attach(capture, buffers[b]), TDM_ERROR_NONE);
708
709                 ASSERT_EQ(tdm_capture_commit(capture), TDM_ERROR_NONE);
710
711                 tdm_capture_destroy(capture);
712                 capture = NULL;
713
714                 TestDone();
715         }
716 }
717
718 TEST_P(TDMBackendCapture, CaptureOneshotLetterboxSize)
719 {
720         TDM_UT_SKIP_FLAG(has_capture_cap);
721         TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
722         TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_ONESHOT);
723
724         bool done;
725
726         for (int o = 0; o < output_count; o++) {
727                 const tdm_output_mode *mode = NULL;
728
729                 if (!ut_tdm_output_is_connected(outputs[o]))
730                         continue;
731
732                 ASSERT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE);
733
734                 for (int f = 0; f < format_count; f++) {
735                         int half_size = ((mode->hdisplay <= mode->vdisplay) ? mode->hdisplay : mode->vdisplay) / 2;
736
737                         dst_pos.x = (mode->hdisplay - half_size) / 2;
738                         dst_pos.y = (mode->vdisplay - half_size) / 2;
739                         dst_pos.w = half_size;
740                         dst_pos.h = half_size;
741
742                         TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(formats[f]));
743
744                         FindLayer(o, formats[f], &dst_pos);
745
746                         if (!dst_layer) {
747                                 TDM_UT_INFO("no proper layer for %c%c%c%c", FOURCC_STR(formats[f]));
748                                 continue;
749                         }
750
751                         ASSERT_EQ(TestPrepare(o, half_size, half_size, formats[f],
752                                                                   TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1, false), true);
753
754                         ASSERT_EQ(tdm_capture_set_done_handler(capture, _ut_tdm_capture_done_cb, &done), TDM_ERROR_NONE);
755
756 retry:
757                         for (int b = 0; b < 3; b++) {
758                                 done = false;
759                                 ASSERT_EQ(tdm_capture_attach(capture, buffers[b]), TDM_ERROR_NONE);
760                                 ASSERT_EQ(tdm_capture_commit(capture), TDM_ERROR_NONE);
761
762                                 while (!done)
763                                         ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
764
765 #if 0
766                                 char temp[256];
767                                 snprintf(temp, sizeof temp, "f%d_b%d", f, b);
768                                 DumpBuffer(b, temp);
769 #endif
770                                 ShowBuffer(b, &dst_pos);
771                         }
772
773                         TDM_UT_ASK_YNR("* Successed to capture a output to a '%c%c%c%c' buffer as letterbox size and show? (output: %d, layer: %d)",
774                                                    FOURCC_STR(formats[f]), pipe, dst_layer_index);
775
776
777                         HideLayer();
778
779                         TestDone();
780                 }
781         }
782 }
783
784 TEST_P(TDMBackendCapture, CaptureOneshotFullSize)
785 {
786         TDM_UT_SKIP_FLAG(has_capture_cap);
787         TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
788         TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_ONESHOT);
789
790         bool done;
791
792         for (int o = 0; o < output_count; o++) {
793                 const tdm_output_mode *mode = NULL;
794
795                 if (!ut_tdm_output_is_connected(outputs[o]))
796                         continue;
797
798                 ASSERT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE);
799
800                 for (int f = 0; f < format_count; f++) {
801                         int half_size = ((mode->hdisplay <= mode->vdisplay) ? mode->hdisplay : mode->vdisplay) / 2;
802
803                         dst_pos.x = (mode->hdisplay - half_size) / 2;
804                         dst_pos.y = (mode->vdisplay - half_size) / 2;
805                         dst_pos.w = half_size;
806                         dst_pos.h = half_size;
807
808                         TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(formats[f]));
809
810                         FindLayer(o, formats[f], &dst_pos);
811
812                         if (!dst_layer) {
813                                 TDM_UT_INFO("no proper layer for %c%c%c%c", FOURCC_STR(formats[f]));
814                                 continue;
815                         }
816
817                         ASSERT_EQ(TestPrepare(o, half_size, half_size, formats[f],
818                                                                   TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1, true), true);
819
820                         ASSERT_EQ(tdm_capture_set_done_handler(capture, _ut_tdm_capture_done_cb, &done), TDM_ERROR_NONE);
821
822 retry:
823                         for (int b = 0; b < 3; b++) {
824                                 done = false;
825                                 ASSERT_EQ(tdm_capture_attach(capture, buffers[b]), TDM_ERROR_NONE);
826                                 ASSERT_EQ(tdm_capture_commit(capture), TDM_ERROR_NONE);
827
828                                 while (!done)
829                                         ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
830
831 #if 0
832                                 char temp[256];
833                                 snprintf(temp, sizeof temp, "f%d_b%d", f, b);
834                                 DumpBuffer(b, temp);
835 #endif
836                                 ShowBuffer(b, &dst_pos);
837                         }
838
839                         TDM_UT_ASK_YNR("* Successed to capture a output to a '%c%c%c%c' buffer as full size and show? (output: %d, layer: %d)",
840                                                    FOURCC_STR(formats[f]), pipe, dst_layer_index);
841
842
843                         HideLayer();
844
845                         TestDone();
846                 }
847         }
848 }
849
850 TEST_P(TDMBackendCapture, CaptureOneshotAttachFewTimesInOneCommit)
851 {
852         TDM_UT_SKIP_FLAG(has_capture_cap);
853         TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
854         TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_ONESHOT);
855
856         int done;
857
858         for (int o = 0; o < output_count; o++) {
859                 const tdm_output_mode *mode = NULL;
860
861                 if (!ut_tdm_output_is_connected(outputs[o]))
862                         continue;
863
864                 ASSERT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE);
865
866                 for (int f = 0; f < format_count; f++) {
867                         int half_size = ((mode->hdisplay <= mode->vdisplay) ? mode->hdisplay : mode->vdisplay) / 2;
868
869                         dst_pos.x = (mode->hdisplay - half_size) / 2;
870                         dst_pos.y = (mode->vdisplay - half_size) / 2;
871                         dst_pos.w = half_size;
872                         dst_pos.h = half_size;
873
874                         TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(formats[f]));
875
876                         FindLayer(o, formats[f], &dst_pos);
877
878                         if (!dst_layer) {
879                                 TDM_UT_INFO("no proper layer for %c%c%c%c", FOURCC_STR(formats[f]));
880                                 continue;
881                         }
882
883                         ASSERT_EQ(TestPrepare(o, half_size, half_size, formats[f],
884                                                                   TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1, false), true);
885
886                         done = 0;
887                         ASSERT_EQ(tdm_capture_set_done_handler(capture, _ut_tdm_capture_done_cb2, &done), TDM_ERROR_NONE);
888
889 retry:
890                         for (int b = 0; b < 3; b++)
891                                 ASSERT_EQ(tdm_capture_attach(capture, buffers[b]), TDM_ERROR_NONE);
892
893                         ASSERT_EQ(tdm_capture_commit(capture), TDM_ERROR_NONE);
894
895                         while (done != 3)
896                                 ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
897
898                         for (int b = 0; b < 3; b++) {
899 #if 0
900                                 char temp[256];
901                                 snprintf(temp, sizeof temp, "f%d_b%d", f, b);
902                                 DumpBuffer(b, temp);
903 #endif
904                                 ShowBuffer(b, &dst_pos);
905                         }
906
907                         TDM_UT_ASK_YNR("* Successed to capture a output to a '%c%c%c%c' buffer as letterbox size and show? (output: %d, layer: %d)",
908                                                    FOURCC_STR(formats[f]), pipe, dst_layer_index);
909
910
911                         HideLayer();
912
913                         TestDone();
914                 }
915         }
916 }
917
918 static void
919 _ut_tdm_backend_capture_buffer_release_cb(tbm_surface_h buffer, void *user_data)
920 {
921         TDMBackendCapture *backend_capture = (TDMBackendCapture*)user_data;
922
923         tdm_buffer_remove_release_handler(buffer, _ut_tdm_backend_capture_buffer_release_cb, backend_capture);
924
925         ASSERT_EQ(tdm_capture_attach(backend_capture->capture, buffer), TDM_ERROR_NONE);
926         ASSERT_EQ(tdm_capture_commit(backend_capture->capture), TDM_ERROR_NONE);
927 }
928
929 static void
930 _ut_tdm_capture_stream_done_cb(tdm_capture *capture, tbm_surface_h buffer, void *user_data)
931 {
932         TDMBackendCapture *backend_capture = (TDMBackendCapture*)user_data;
933
934         for (int b = 0; b < 3; b++) {
935                 if (backend_capture->buffers[b] == buffer) {
936 #if 0
937                         char temp[256];
938                         snprintf(temp, sizeof temp, "f%d_b%d", f, b);
939                         DumpBuffer(b, temp);
940 #endif
941                         tdm_buffer_add_release_handler(buffer, _ut_tdm_backend_capture_buffer_release_cb, (void*)backend_capture);
942                         backend_capture->ShowBuffer(b, &backend_capture->dst_pos);
943                         break;
944                 }
945         }
946
947         if (--backend_capture->stream_count == 0) {
948                 backend_capture->stream_exit = 1;
949         }
950 }
951
952 TEST_P(TDMBackendCapture, CaptureStreamLetterboxSize)
953 {
954         TDM_UT_SKIP_FLAG(has_capture_cap);
955         TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
956         TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_STREAM);
957
958         for (int o = 0; o < output_count; o++) {
959                 const tdm_output_mode *mode = NULL;
960
961                 if (!ut_tdm_output_is_connected(outputs[o]))
962                         continue;
963
964                 ASSERT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE);
965
966                 for (int f = 0; f < format_count; f++) {
967                         int half_size = ((mode->hdisplay <= mode->vdisplay) ? mode->hdisplay : mode->vdisplay) / 2;
968
969                         dst_pos.x = (mode->hdisplay - half_size) / 2;
970                         dst_pos.y = (mode->vdisplay - half_size) / 2;
971                         dst_pos.w = half_size;
972                         dst_pos.h = half_size;
973
974                         TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(formats[f]));
975
976                         FindLayer(o, formats[f], &dst_pos);
977
978                         if (!dst_layer) {
979                                 TDM_UT_INFO("no proper layer for %c%c%c%c", FOURCC_STR(formats[f]));
980                                 continue;
981                         }
982
983                         ASSERT_EQ(TestPrepare(o, half_size, half_size, formats[f],
984                                                                   TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_STREAM, -1, false), true);
985
986                         ASSERT_EQ(tdm_capture_set_done_handler(capture, _ut_tdm_capture_stream_done_cb, (void*)this), TDM_ERROR_NONE);
987
988                         for (int b = 0; b < 3; b++)
989                                 ASSERT_EQ(tdm_capture_attach(capture, buffers[b]), TDM_ERROR_NONE);
990
991 retry:
992
993                         stream_exit = false;
994                         stream_count = 30;
995
996                         ASSERT_EQ(tdm_capture_commit(capture), TDM_ERROR_NONE);
997
998                         while (!stream_exit)
999                                 ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
1000
1001                         TDM_UT_ASK_YNR("* Successed to capture a output to a '%c%c%c%c' buffer as letterbox size and show? (output: %d, layer: %d)",
1002                                                    FOURCC_STR(formats[f]), pipe, dst_layer_index);
1003
1004
1005                         HideLayer();
1006
1007                         TestDone();
1008                 }
1009         }
1010 }
1011
1012 TEST_P(TDMBackendCapture, CaptureStreamFullSize)
1013 {
1014         TDM_UT_SKIP_FLAG(has_capture_cap);
1015         TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT);
1016         TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_STREAM);
1017
1018         for (int o = 0; o < output_count; o++) {
1019                 const tdm_output_mode *mode = NULL;
1020
1021                 if (!ut_tdm_output_is_connected(outputs[o]))
1022                         continue;
1023
1024                 ASSERT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE);
1025
1026                 for (int f = 0; f < format_count; f++) {
1027                         int half_size = ((mode->hdisplay <= mode->vdisplay) ? mode->hdisplay : mode->vdisplay) / 2;
1028
1029                         dst_pos.x = (mode->hdisplay - half_size) / 2;
1030                         dst_pos.y = (mode->vdisplay - half_size) / 2;
1031                         dst_pos.w = half_size;
1032                         dst_pos.h = half_size;
1033
1034                         TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(formats[f]));
1035
1036                         FindLayer(o, formats[f], &dst_pos);
1037
1038                         if (!dst_layer) {
1039                                 TDM_UT_INFO("no proper layer for %c%c%c%c", FOURCC_STR(formats[f]));
1040                                 continue;
1041                         }
1042
1043                         ASSERT_EQ(TestPrepare(o, half_size, half_size, formats[f],
1044                                                                   TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_STREAM, -1, true), true);
1045
1046                         ASSERT_EQ(tdm_capture_set_done_handler(capture, _ut_tdm_capture_stream_done_cb, (void*)this), TDM_ERROR_NONE);
1047
1048                         for (int b = 0; b < 3; b++)
1049                                 ASSERT_EQ(tdm_capture_attach(capture, buffers[b]), TDM_ERROR_NONE);
1050
1051 retry:
1052
1053                         stream_exit = false;
1054                         stream_count = 30;
1055
1056                         ASSERT_EQ(tdm_capture_commit(capture), TDM_ERROR_NONE);
1057
1058                         while (!stream_exit)
1059                                 ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
1060
1061                         TDM_UT_ASK_YNR("* Successed to capture a output to a '%c%c%c%c' buffer as full size and show? (output: %d, layer: %d)",
1062                                                    FOURCC_STR(formats[f]), pipe, dst_layer_index);
1063
1064
1065                         HideLayer();
1066
1067                         TestDone();
1068                 }
1069         }
1070 }
1071
1072 #ifdef TDM_UT_TEST_WITH_PARAMS
1073 INSTANTIATE_TEST_CASE_P(TDMBackendCaptureParams,
1074                                                 TDMBackendCapture,
1075                                                 Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
1076 #else
1077 INSTANTIATE_TEST_CASE_P(TDMBackendCaptureParams,
1078                                                 TDMBackendCapture,
1079                                                 Values(TDM_DEFAULT_MODULE));
1080 #endif