[dali_2.3.20] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-VideoView.cpp
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <dali-toolkit-test-suite-utils.h>
19 #include <dali-toolkit/dali-toolkit.h>
20 #include <dali-toolkit/devel-api/controls/video-view/video-view-devel.h>
21 #include <dali-toolkit/public-api/controls/video-view/video-view.h>
22 #include <dali/devel-api/adaptor-framework/video-sync-mode.h>
23 #include <dali/devel-api/adaptor-framework/window-devel.h>
24 #include <stdlib.h>
25 #include <iostream>
26
27 using namespace Dali;
28 using namespace Dali::Toolkit;
29
30 namespace
31 {
32 const char* const TEST_FILE("test.mp4");
33 const char* const VOLUME_LEFT("volumeLeft");
34 const char* const VOLUME_RIGHT("volumeRight");
35 const char* const RENDERING_TYPE("renderingTarget");
36 const char* const DUMMY_STRING("dummy string");
37
38 // clang-format off
39 const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
40   attribute mediump vec2     aPosition;\n
41   varying mediump vec2     vTexCoord;\n
42   uniform mediump mat4   uMvpMatrix;\n
43   uniform mediump vec3 uSize;\n
44   \n
45   void main()\n
46   {\n
47     mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n
48     vertexPosition.xyz *= uSize;\n
49     vertexPosition = uMvpMatrix * vertexPosition;\n
50     vTexCoord = aPosition + vec2(0.5);\n
51     gl_Position = vertexPosition;\n
52   }\n);
53
54 const char* fragmentShaderPrefix("#extension GL_OES_EGL_image_external:require\n");
55 const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
56   varying mediump vec2 vTexCoord;\n
57   uniform samplerExternalOES sTexture;\n
58   uniform lowp vec4 uColor;\n
59   \n
60   void main()\n
61   {\n
62     gl_FragColor = texture2D(sTexture, vTexCoord) * uColor;\n
63   }\n);
64
65 // clang-format on
66
67 } // namespace
68
69 void video_view_startup(void)
70 {
71   test_return_value = TET_UNDEF;
72 }
73
74 void video_view_cleanup(void)
75 {
76   test_return_value = TET_PASS;
77 }
78
79 // Negative test case for a method
80 int UtcDaliVideoViewUninitialized(void)
81 {
82   ToolkitTestApplication application;
83   tet_infoline(" UtcDaliVideoViewUninitialized");
84
85   Toolkit::VideoView view;
86
87   try
88   {
89     // New() must be called to create a VideoView or it wont be valid.
90     Actor a = Actor::New();
91     view.Add(a);
92     DALI_TEST_CHECK(false);
93   }
94   catch(Dali::DaliException& e)
95   {
96     // Tests that a negative test of an assertion succeeds
97     DALI_TEST_PRINT_ASSERT(e);
98     DALI_TEST_CHECK(!view);
99   }
100   END_TEST;
101 }
102
103 // Positive test case for a method
104 int UtcDaliVideoViewNew(void)
105 {
106   ToolkitTestApplication application;
107   tet_infoline(" UtcDaliVideoViewNew");
108
109   Toolkit::VideoView view = Toolkit::VideoView::New();
110   DALI_TEST_CHECK(view);
111
112   const std::string  url(DUMMY_STRING);
113   Toolkit::VideoView view2 = Toolkit::VideoView::New(url);
114   DALI_TEST_CHECK(view2);
115   END_TEST;
116 }
117
118 // Positive test case for a method
119 int UtcDaliVideoViewDownCast(void)
120 {
121   ToolkitTestApplication application;
122   tet_infoline(" UtcDaliVideoViewDownCast");
123
124   Toolkit::VideoView view = Toolkit::VideoView::New();
125   BaseHandle         handle(view);
126
127   Toolkit::VideoView view2 = Toolkit::VideoView::DownCast(handle);
128   DALI_TEST_CHECK(view);
129   DALI_TEST_CHECK(view2);
130   DALI_TEST_CHECK(view == view2);
131   END_TEST;
132 }
133
134 // Positive test case for a method
135 int UtcDaliVideoViewProperty1(void)
136 {
137   ToolkitTestApplication application;
138   tet_infoline(" UtcDaliVideoViewProperty1");
139
140   Toolkit::VideoView view = Toolkit::VideoView::New();
141   DALI_TEST_CHECK(view);
142
143   std::string file;
144   view.SetProperty(VideoView::Property::VIDEO, TEST_FILE);
145   Property::Value val = view.GetProperty(VideoView::Property::VIDEO);
146   DALI_TEST_CHECK(val.Get(file));
147   DALI_TEST_CHECK(file == TEST_FILE);
148   END_TEST;
149 }
150
151 // Positive test case for a method
152 int UtcDaliVideoViewProperty1b(void)
153 {
154   ToolkitTestApplication application;
155   tet_infoline(" UtcDaliVideoViewProperty1");
156
157   Toolkit::VideoView view = Toolkit::VideoView::New();
158   DALI_TEST_CHECK(view);
159   Integration::Scene stage = application.GetScene();
160
161   std::string   file;
162   Property::Map map;
163
164   view.SetProperty(VideoView::Property::VIDEO,
165                    Property::Map()
166                      .Add("rendererType", "IMAGE")
167                      .Add("url", "video.mpg") // Note, videoView doesn't use this url
168                      .Add("RENDERING_TARGET", "windowSurfaceTarget")
169                      .Add("width", 100)
170                      .Add("height", 100));
171
172   stage.Add(view);
173
174   Property::Value val       = view.GetProperty(VideoView::Property::VIDEO);
175   Property::Map*  resultMap = val.GetMap();
176
177   DALI_TEST_CHECK(resultMap);
178   Property::Value* value = resultMap->Find("url");
179   DALI_TEST_CHECK(value);
180   DALI_TEST_EQUALS(value->Get<std::string>(), "video.mpg", TEST_LOCATION);
181
182   stage.Remove(view);
183
184   END_TEST;
185 }
186
187 int UtcDaliVideoViewProperty2(void)
188 {
189   ToolkitTestApplication application;
190   tet_infoline(" UtcDaliVideoViewProperty2");
191
192   Toolkit::VideoView view = Toolkit::VideoView::New();
193   DALI_TEST_CHECK(view);
194
195   bool            looping;
196   Property::Value val = view.GetProperty(VideoView::Property::LOOPING);
197   DALI_TEST_CHECK(val.Get(looping));
198   DALI_TEST_CHECK(!looping);
199
200   view.SetProperty(VideoView::Property::LOOPING, true);
201   val = view.GetProperty(VideoView::Property::LOOPING);
202   DALI_TEST_CHECK(val.Get(looping));
203   DALI_TEST_CHECK(looping);
204   END_TEST;
205 }
206
207 int UtcDaliVideoViewProperty3(void)
208 {
209   ToolkitTestApplication application;
210   tet_infoline(" UtcDaliVideoViewProperty3");
211
212   Toolkit::VideoView view = Toolkit::VideoView::New();
213   DALI_TEST_CHECK(view);
214
215   bool            muted;
216   Property::Value val = view.GetProperty(VideoView::Property::MUTED);
217   DALI_TEST_CHECK(val.Get(muted));
218   DALI_TEST_CHECK(!muted);
219
220   view.SetProperty(VideoView::Property::MUTED, true);
221   val = view.GetProperty(VideoView::Property::MUTED);
222   DALI_TEST_CHECK(val.Get(muted));
223   DALI_TEST_CHECK(muted);
224
225   END_TEST;
226 }
227
228 int UtcDaliVideoViewProperty4(void)
229 {
230   ToolkitTestApplication application;
231   tet_infoline(" UtcDaliVideoViewProperty4");
232
233   Toolkit::VideoView view = Toolkit::VideoView::New();
234   DALI_TEST_CHECK(view);
235
236   float left, right;
237   left = right = 0.f;
238
239   Property::Map map;
240   map.Insert(VOLUME_LEFT, 0.5f);
241   map.Insert(VOLUME_RIGHT, 0.5f);
242
243   view.SetProperty(VideoView::Property::VOLUME, map);
244   Property::Value val = view.GetProperty(VideoView::Property::VOLUME);
245
246   Property::Map map2;
247   DALI_TEST_CHECK(val.Get(map2));
248
249   Property::Value* volumeLeft  = map2.Find(VOLUME_LEFT);
250   Property::Value* volumeRight = map2.Find(VOLUME_RIGHT);
251
252   DALI_TEST_CHECK(volumeLeft && volumeLeft->Get(left));
253   DALI_TEST_CHECK(volumeRight && volumeRight->Get(right));
254   DALI_TEST_CHECK(left == 0.5f);
255   DALI_TEST_CHECK(right == 0.5f);
256
257   END_TEST;
258 }
259
260 int UtcDaliVideoViewCopyAndAssignment(void)
261 {
262   ToolkitTestApplication application;
263
264   VideoView view = Toolkit::VideoView::New();
265   DALI_TEST_CHECK(view);
266
267   VideoView copy(view);
268   DALI_TEST_CHECK(view == copy);
269
270   VideoView assign;
271   DALI_TEST_CHECK(!assign);
272
273   assign = copy;
274   DALI_TEST_CHECK(assign == view);
275
276   END_TEST;
277 }
278
279 int UtcDaliVideoViewMoveConstructor(void)
280 {
281   ToolkitTestApplication application;
282
283   VideoView view = Toolkit::VideoView::New();
284   DALI_TEST_EQUALS(1, view.GetBaseObject().ReferenceCount(), TEST_LOCATION);
285   view.SetProperty(VideoView::Property::LOOPING, true);
286   DALI_TEST_CHECK(view.GetProperty<bool>(VideoView::Property::LOOPING));
287
288   VideoView moved = std::move(view);
289   DALI_TEST_CHECK(moved);
290   DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
291   DALI_TEST_CHECK(moved.GetProperty<bool>(VideoView::Property::LOOPING));
292   DALI_TEST_CHECK(!view);
293
294   END_TEST;
295 }
296
297 int UtcDaliVideoViewMoveAssignment(void)
298 {
299   ToolkitTestApplication application;
300
301   VideoView view = Toolkit::VideoView::New();
302   DALI_TEST_EQUALS(1, view.GetBaseObject().ReferenceCount(), TEST_LOCATION);
303   view.SetProperty(VideoView::Property::LOOPING, true);
304   DALI_TEST_CHECK(view.GetProperty<bool>(VideoView::Property::LOOPING));
305
306   VideoView moved;
307   moved = std::move(view);
308   DALI_TEST_CHECK(moved);
309   DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
310   DALI_TEST_CHECK(moved.GetProperty<bool>(VideoView::Property::LOOPING));
311   DALI_TEST_CHECK(!view);
312
313   END_TEST;
314 }
315
316 int UtcDaliVideoViewTypeRegistry(void)
317 {
318   ToolkitTestApplication application;
319
320   TypeRegistry typeRegistry = TypeRegistry::Get();
321   DALI_TEST_CHECK(typeRegistry);
322
323   TypeInfo typeInfo = typeRegistry.GetTypeInfo("VideoView");
324   DALI_TEST_CHECK(typeInfo);
325
326   BaseHandle handle = typeInfo.CreateInstance();
327   DALI_TEST_CHECK(handle);
328
329   VideoView view = VideoView::DownCast(handle);
330   DALI_TEST_CHECK(view);
331
332   END_TEST;
333 }
334
335 int UtcDaliVideoViewMethodsForCoverage(void)
336 {
337   ToolkitTestApplication application;
338
339   VideoView videoView = VideoView::New();
340   DALI_TEST_CHECK(videoView);
341
342   videoView.Play();
343   videoView.Pause();
344   videoView.Stop();
345   videoView.Forward(10);
346   videoView.Backward(10);
347
348   Toolkit::DevelVideoView::GetMediaPlayer(videoView);
349
350   VideoView::VideoViewSignalType& signal = videoView.FinishedSignal();
351   DALI_TEST_EQUALS(0, signal.GetConnectionCount(), TEST_LOCATION);
352
353   END_TEST;
354 }
355
356 int UtcDaliVideoViewMethodsForRenderType(void)
357 {
358   ToolkitTestApplication application;
359   VideoView              videoView = VideoView::New();
360   DALI_TEST_CHECK(videoView);
361
362   Property::Map windowSurfaceTarget;
363   Property::Map nativeImageTarget;
364
365   windowSurfaceTarget.Insert(RENDERING_TYPE, "windowSurfaceTarget");
366   nativeImageTarget.Insert(RENDERING_TYPE, "nativeImageTarget");
367
368   Property::Map   map;
369   Property::Value value;
370   videoView.SetProperty(VideoView::Property::VIDEO, windowSurfaceTarget);
371
372   value = videoView.GetProperty(VideoView::Property::VIDEO);
373   DALI_TEST_CHECK(value.Get(map));
374
375   Property::Value* type = map.Find(RENDERING_TYPE);
376   DALI_TEST_CHECK(type);
377   DALI_TEST_EQUALS("windowSurfaceTarget", type->Get<std::string>(), TEST_LOCATION);
378
379   videoView.SetProperty(VideoView::Property::VIDEO, nativeImageTarget);
380
381   value = videoView.GetProperty(VideoView::Property::VIDEO);
382   DALI_TEST_CHECK(value.Get(map));
383   type = map.Find(RENDERING_TYPE);
384
385   DALI_TEST_CHECK(type);
386   DALI_TEST_EQUALS("nativeImageTarget", type->Get<std::string>(), TEST_LOCATION);
387
388   END_TEST;
389 }
390
391 int UtcDaliVideoViewCustomShaderForCoverage(void)
392 {
393   ToolkitTestApplication application;
394   VideoView              videoView = VideoView::New();
395   DALI_TEST_CHECK(videoView);
396
397   ToolkitApplication::DECODED_IMAGES_SUPPORTED = true;
398
399   videoView.SetProperty(Toolkit::VideoView::Property::UNDERLAY, false);
400   bool isUnderlay = videoView.GetProperty(Toolkit::VideoView::Property::UNDERLAY).Get<bool>();
401   DALI_TEST_CHECK(!isUnderlay);
402
403   application.GetScene().Add(videoView);
404   videoView.SetProperty(VideoView::Property::VIDEO, "testvideo");
405
406   Property::Map customShader;
407   customShader.Insert("vertexShader", VERTEX_SHADER);
408   customShader.Insert("fragmentShader", FRAGMENT_SHADER);
409
410   Property::Map map;
411   map.Insert("shader", customShader);
412
413   videoView.SetProperty(VideoView::Property::VIDEO, map);
414
415   Property::Map   map2;
416   Property::Value value = videoView.GetProperty(VideoView::Property::VIDEO);
417
418   DALI_TEST_CHECK(!value.Get(map2));
419   END_TEST;
420 }
421
422 int UtcDaliVideoViewMethodsForCoverage2(void)
423 {
424   ToolkitTestApplication application;
425   VideoView              videoView = VideoView::New();
426   DALI_TEST_CHECK(videoView);
427
428   Property::Map windowSurfaceTarget;
429
430   windowSurfaceTarget.Insert(RENDERING_TYPE, "windowSurfaceTarget");
431
432   application.GetScene().Add(videoView);
433
434   application.SendNotification();
435   application.Render();
436
437   Property::Map   map;
438   Property::Value value;
439   videoView.SetProperty(VideoView::Property::VIDEO, windowSurfaceTarget);
440
441   value = videoView.GetProperty(VideoView::Property::VIDEO);
442   DALI_TEST_CHECK(value.Get(map));
443
444   Property::Value* type = map.Find(RENDERING_TYPE);
445   DALI_TEST_CHECK(type);
446   DALI_TEST_EQUALS("windowSurfaceTarget", type->Get<std::string>(), TEST_LOCATION);
447
448   Vector3 vector(100.0f, 100.0f, 0.0f);
449
450   DALI_TEST_CHECK(vector != videoView.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
451   videoView.SetProperty(Actor::Property::SIZE, vector);
452
453   application.SendNotification();
454   application.Render();
455
456   // Check the size in the new frame
457   DALI_TEST_CHECK(vector == videoView.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
458
459   END_TEST;
460 }
461
462 int UtcDaliVideoViewCustomShaderForCoverage3(void)
463 {
464   ToolkitTestApplication application;
465   VideoView              videoView = VideoView::New();
466   DALI_TEST_CHECK(videoView);
467
468   ToolkitApplication::DECODED_IMAGES_SUPPORTED = true;
469
470   videoView.SetProperty(Toolkit::VideoView::Property::UNDERLAY, false);
471   bool isUnderlay = videoView.GetProperty(Toolkit::VideoView::Property::UNDERLAY).Get<bool>();
472   DALI_TEST_CHECK(!isUnderlay);
473
474   application.GetScene().Add(videoView);
475   videoView.SetProperty(VideoView::Property::VIDEO, "testvideo");
476
477   Property::Map customShader;
478   customShader.Insert("vertexShader", VERTEX_SHADER);
479
480   Property::Map map;
481   map.Insert("shader", customShader);
482
483   videoView.SetProperty(VideoView::Property::VIDEO, map);
484
485   Property::Map   map2;
486   Property::Value value = videoView.GetProperty(VideoView::Property::VIDEO);
487
488   DALI_TEST_CHECK(!value.Get(map2));
489   END_TEST;
490 }
491
492 int UtcDaliVideoViewPropertyUnderlay(void)
493 {
494   ToolkitTestApplication application;
495   tet_infoline("UtcDaliVideoViewPropertyUnderlay");
496   ToolkitApplication::DECODED_IMAGES_SUPPORTED = true;
497
498   VideoView view = VideoView::New();
499   DALI_TEST_CHECK(view);
500
501   application.GetScene().Add(view);
502   view.Play();
503
504   application.SendNotification();
505   application.Render();
506
507   bool isUnderlay = view.GetProperty(Toolkit::VideoView::Property::UNDERLAY).Get<bool>();
508   DALI_TEST_CHECK(isUnderlay);
509
510   view.Play();
511   view.SetProperty(Toolkit::VideoView::Property::UNDERLAY, false);
512   isUnderlay = view.GetProperty(Toolkit::VideoView::Property::UNDERLAY).Get<bool>();
513   DALI_TEST_CHECK(!isUnderlay);
514
515   view.Play();
516   view.SetProperty(Toolkit::VideoView::Property::UNDERLAY, true);
517   isUnderlay = view.GetProperty(Toolkit::VideoView::Property::UNDERLAY).Get<bool>();
518   DALI_TEST_CHECK(isUnderlay);
519
520   // If platform api doesn't provide any API or feature for decoded images of video,
521   // UNDERLAY should be true
522   ToolkitApplication::DECODED_IMAGES_SUPPORTED = false;
523
524   view.SetProperty(Toolkit::VideoView::Property::UNDERLAY, false);
525   isUnderlay = view.GetProperty(Toolkit::VideoView::Property::UNDERLAY).Get<bool>();
526   DALI_TEST_CHECK(isUnderlay);
527
528   // For coverage
529   ToolkitApplication::DECODED_IMAGES_SUPPORTED = true;
530
531   view.SetProperty(Toolkit::VideoView::Property::UNDERLAY, true);
532   view.SetProperty(Toolkit::VideoView::Property::UNDERLAY, false);
533   isUnderlay = view.GetProperty(Toolkit::VideoView::Property::UNDERLAY).Get<bool>();
534   DALI_TEST_CHECK(!isUnderlay);
535
536   view.Stop();
537
538   END_TEST;
539 }
540
541 int UtcDaliVideoViewPropertyPlayPosition(void)
542 {
543   ToolkitTestApplication application;
544   tet_infoline("UtcDaliVideoViewPropertyPlayPosition");
545
546   VideoView view = VideoView::New();
547   DALI_TEST_CHECK(view);
548
549   application.GetScene().Add(view);
550   view.Play();
551
552   application.SendNotification();
553   application.Render();
554
555   int playPos = view.GetProperty(Toolkit::VideoView::Property::PLAY_POSITION).Get<int>();
556   DALI_TEST_CHECK(playPos == 0);
557
558   view.SetProperty(Toolkit::VideoView::Property::PLAY_POSITION, 10);
559   playPos = view.GetProperty(Toolkit::VideoView::Property::PLAY_POSITION).Get<int>();
560   // Actually setting play position will be async
561   // Actual platform result may be different.
562   DALI_TEST_CHECK(playPos == 10);
563
564   END_TEST;
565 }
566
567 // For coverage.
568 int UtcDaliVideoViewNew2(void)
569 {
570   ToolkitTestApplication application;
571   tet_infoline("UtcDaliVideoViewNew2");
572
573   VideoView view = VideoView::New(true);
574   DALI_TEST_CHECK(view);
575
576   application.GetScene().Add(view);
577   view.Play();
578
579   application.SendNotification();
580   application.Render();
581
582   VideoView view2 = VideoView::New("", false);
583   DALI_TEST_CHECK(view2);
584
585   application.GetScene().Add(view2);
586   view2.Play();
587
588   application.SendNotification();
589   application.Render();
590
591   END_TEST;
592 }
593
594 int UtcDaliVideoViewRaiseAboveLowerBelow(void)
595 {
596   ToolkitTestApplication application;
597   tet_infoline("UtcDaliVideoViewRaiseAboveLowerBelow");
598
599   VideoView view = VideoView::New(true);
600   DALI_TEST_CHECK(view);
601
602   application.GetScene().Add(view);
603   view.Play();
604
605   application.SendNotification();
606   application.Render();
607
608   VideoView view2 = VideoView::New("", false);
609   DALI_TEST_CHECK(view2);
610
611   application.GetScene().Add(view2);
612   view2.Play();
613
614   application.SendNotification();
615   application.Render();
616
617   view.RaiseAbove(view2);
618   view.LowerBelow(view2);
619
620   END_TEST;
621 }
622
623 int UtcDaliVideoViewRaiseTopLowerBottom(void)
624 {
625   ToolkitTestApplication application;
626   tet_infoline("UtcDaliVideoViewRaiseTopLowerBottom");
627
628   VideoView view = VideoView::New(true);
629   DALI_TEST_CHECK(view);
630
631   application.GetScene().Add(view);
632   view.Play();
633
634   application.SendNotification();
635   application.Render();
636
637   VideoView view2 = VideoView::New("", false);
638   DALI_TEST_CHECK(view2);
639
640   application.GetScene().Add(view2);
641   view2.Play();
642
643   application.SendNotification();
644   application.Render();
645
646   view.RaiseToTop();
647   view.LowerToBottom();
648
649   END_TEST;
650 }
651
652 int UtcDaliVideoViewPropertyDisplayMode(void)
653 {
654   ToolkitTestApplication application;
655   tet_infoline("UtcDaliVideoViewPropertyDisplayMode");
656
657   VideoView view = VideoView::New();
658   DALI_TEST_CHECK(view);
659
660   application.GetScene().Add(view);
661   view.Play();
662
663   application.SendNotification();
664   application.Render();
665
666   view.SetProperty(Toolkit::VideoView::Property::DISPLAY_MODE, Toolkit::VideoView::DisplayMode::DST_ROI);
667   int displayMode = view.GetProperty(Toolkit::VideoView::Property::DISPLAY_MODE).Get<int>();
668   DALI_TEST_CHECK(displayMode == Toolkit::VideoView::DisplayMode::DST_ROI);
669
670   END_TEST;
671 }
672
673 int UtcDaliVideoViewCustomShader(void)
674 {
675   ToolkitTestApplication application;
676   tet_infoline("VideoView with custom shader");
677
678   VideoView view = VideoView::New(false);
679   DALI_TEST_CHECK(view);
680
681   ToolkitApplication::DECODED_IMAGES_SUPPORTED = true;
682
683   view.SetProperty(Toolkit::VideoView::Property::UNDERLAY, false);
684   bool isUnderlay = view.GetProperty(Toolkit::VideoView::Property::UNDERLAY).Get<bool>();
685   DALI_TEST_CHECK(!isUnderlay);
686
687   application.GetScene().Add(view);
688   view.SetProperty(VideoView::Property::VIDEO, "testvideo");
689
690   /* insert custom shader */
691   Property::Map customShader;
692   std::string   fragmentShaderString;
693   fragmentShaderString.reserve(strlen(fragmentShaderPrefix) + strlen(FRAGMENT_SHADER));
694   fragmentShaderString.append(fragmentShaderPrefix);
695   fragmentShaderString.append(FRAGMENT_SHADER);
696   customShader.Insert("vertexShader", VERTEX_SHADER);
697   customShader.Insert("fragmentShader", fragmentShaderString);
698
699   Property::Map map;
700   map.Insert("shader", customShader);
701
702   view.SetProperty(VideoView::Property::VIDEO, map);
703
704   /* do render for check custom shader */
705   application.GetScene().Add(view);
706   view.Play();
707
708   application.SendNotification();
709   application.Render();
710
711   /* get renderer */
712   DALI_TEST_CHECK(view.GetRendererCount() == 1u);
713   Renderer renderer = view.GetRendererAt(0);
714   Shader   shader   = renderer.GetShader();
715   DALI_TEST_CHECK(shader);
716
717   Property::Value value     = shader.GetProperty(Shader::Property::PROGRAM);
718   Property::Map*  shaderMap = value.GetMap();
719   DALI_TEST_CHECK(shaderMap);
720
721   Property::Value* fragment = shaderMap->Find("fragment"); // fragment key name from shader-impl.cpp
722   DALI_TEST_EQUALS(fragmentShaderString, fragment->Get<std::string>(), TEST_LOCATION);
723
724   Property::Value* vertex = shaderMap->Find("vertex"); // vertex key name from shader-impl.cpp
725   DALI_TEST_EQUALS(VERTEX_SHADER, vertex->Get<std::string>(), TEST_LOCATION);
726
727   END_TEST;
728 }
729
730 // Functor to test whether a Finish signal is emitted
731 struct AnimationFinishCheck
732 {
733   AnimationFinishCheck(bool& signalReceived)
734   : mSignalReceived(signalReceived)
735   {
736   }
737
738   void operator()(Animation& animation)
739   {
740     mSignalReceived = true;
741   }
742
743   void Reset()
744   {
745     mSignalReceived = false;
746   }
747
748   void CheckSignalReceived()
749   {
750     if(!mSignalReceived)
751     {
752       tet_printf("Expected Finish signal was not received\n");
753       tet_result(TET_FAIL);
754     }
755     else
756     {
757       tet_result(TET_PASS);
758     }
759   }
760
761   void CheckSignalNotReceived()
762   {
763     if(mSignalReceived)
764     {
765       tet_printf("Unexpected Finish signal was received\n");
766       tet_result(TET_FAIL);
767     }
768     else
769     {
770       tet_result(TET_PASS);
771     }
772   }
773
774   bool& mSignalReceived; // owned by individual tests
775 };
776
777 int UtcDaliVideoViewSyncAniamtionForCoverage(void)
778 {
779   ToolkitTestApplication application;
780
781   VideoView videoView = DevelVideoView::New(Dali::VideoSyncMode::ENABLED);
782   DALI_TEST_CHECK(videoView);
783
784   application.GetScene().Add(videoView);
785
786   // Build the animation
787   float     durationSeconds(1.0f);
788   Animation animation = Animation::New(durationSeconds);
789
790   // Start the animation
791   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
792   animation.AnimateTo(Property(videoView, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
793   DevelVideoView::PlayAnimation(videoView, animation);
794
795   bool                 signalReceived(false);
796   AnimationFinishCheck finishCheck(signalReceived);
797   animation.FinishedSignal().Connect(&application, finishCheck);
798
799   application.SendNotification();
800   application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f) - 1u /*just less than the animation duration*/);
801
802   // We didn't expect the animation to finish yet
803   application.SendNotification();
804   finishCheck.CheckSignalNotReceived();
805
806   application.Render(2u /*just beyond the animation duration*/);
807
808   // We did expect the animation to finish
809   application.SendNotification();
810   finishCheck.CheckSignalReceived();
811   DALI_TEST_EQUALS(targetPosition, videoView.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
812
813   // Restart the animation, with a different duration
814   finishCheck.Reset();
815
816   END_TEST;
817 }
818
819 int UtcDaliVideoViewASyncAniamtionForCoverage(void)
820 {
821   ToolkitTestApplication application;
822
823   VideoView videoView = DevelVideoView::New(Dali::VideoSyncMode::DISABLED);
824   DALI_TEST_CHECK(videoView);
825
826   application.GetScene().Add(videoView);
827
828   // Build the animation
829   float     durationSeconds(1.0f);
830   Animation animation = Animation::New(durationSeconds);
831
832   // Start the animation
833   Vector3 targetPosition(10.0f, 10.0f, 10.0f);
834   animation.AnimateTo(Property(videoView, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
835   DevelVideoView::PlayAnimation(videoView, animation);
836
837   bool                 signalReceived(false);
838   AnimationFinishCheck finishCheck(signalReceived);
839   animation.FinishedSignal().Connect(&application, finishCheck);
840
841   application.SendNotification();
842   application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f) - 1u /*just less than the animation duration*/);
843
844   // We didn't expect the animation to finish yet
845   application.SendNotification();
846   finishCheck.CheckSignalNotReceived();
847
848   application.Render(2u /*just beyond the animation duration*/);
849
850   // We did expect the animation to finish
851   application.SendNotification();
852   finishCheck.CheckSignalReceived();
853   DALI_TEST_EQUALS(targetPosition, videoView.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
854
855   // Restart the animation, with a different duration
856   finishCheck.Reset();
857
858   END_TEST;
859 }
860
861 int UtcDaliVideoViewResizeWithSynchronization(void)
862 {
863   ToolkitTestApplication application;
864   VideoView              videoView = DevelVideoView::New(Dali::VideoSyncMode::ENABLED);
865   DALI_TEST_CHECK(videoView);
866
867   application.GetScene().Add(videoView);
868
869   Vector3 vector(50.0f, 200.0f, 0.0f);
870   videoView.SetProperty(Actor::Property::SIZE, vector);
871
872   application.SendNotification();
873   application.Render();
874
875   DALI_TEST_CHECK(vector == videoView.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
876
877   END_TEST;
878 }
879
880 // For coverage.
881 int UtcDaliVideoViewSynchronizationForWindowRotation(void)
882 {
883   ToolkitTestApplication application;
884   tet_infoline("UtcDaliVideoViewSynchronizationForWindowRotation");
885
886   Window window = Window::New(PositionSize(0, 0, 100, 100), "", false);
887   DALI_TEST_CHECK(window);
888
889   VideoView view = VideoView::New(true);
890   DALI_TEST_CHECK(view);
891
892   window.Add(view);
893
894   view.Play();
895
896   DevelWindow::SetPositionSize(window, PositionSize(0, 0, 480, 240));
897
898   application.SendNotification();
899   application.Render();
900
901   END_TEST;
902 }