Merge branch 'devel/master' into tizen
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-RenderTask.cpp
1 /*
2  * Copyright (c) 2020 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-test-suite-utils.h>
19 #include <dali/devel-api/events/hit-test-algorithm.h>
20 #include <dali/integration-api/debug.h>
21 #include <dali/public-api/dali-core.h>
22 #include <mesh-builder.h>
23 #include <stdlib.h>
24 #include <test-native-image.h>
25
26 #include <iostream>
27
28 #define BOOLSTR(x) ((x) ? "T" : "F")
29
30 //& set: DaliRenderTask
31
32 using namespace Dali;
33
34 void utc_dali_render_task_startup(void)
35 {
36   test_return_value = TET_UNDEF;
37 }
38
39 void utc_dali_render_task_cleanup(void)
40 {
41   test_return_value = TET_PASS;
42 }
43
44 /**
45  * APIs:
46  *
47  * Constructor, Destructor, DownCast, New, copy constructor, assignment operator
48  *
49  * SetSourceActor                      2+ve, 1-ve
50  * GetSourceActor                      1+ve, 1-ve
51  * SetExclusive                        2+ve, 0-ve
52  * IsExclusive                         2+ve, 0-ve
53  * SetInputEnabled                     1+ve, 0-ve
54  * GetInputEnabled                     1+ve, 0-ve
55  * SetCameraActor                      1+ve, 1-ve
56  * GetCameraActor                      1+ve, 1-ve
57  * SetTargetFrameBuffer                1+ve, 1-ve
58  * GetTargetFrameBuffer                1+ve, 1-ve
59  * SetScreenToFrameBufferFunction      1+ve, 1-ve
60  * GetScreenToFrameBufferFunction      1+ve, 1-ve
61  * SetScreenToFrameBufferMappingActor  1+ve, 1-ve
62  * GetScreenToFrameBufferMappingActor  1+ve, 1-ve
63  * SetViewportPosition                 1+ve
64  * GetCurrentViewportPosition          1+ve
65  * SetViewportSize                     1+ve
66  * GetCurrentViewportSize              1+ve
67  * SetViewport                         2+ve, 1-ve
68  * GetViewport                         2+ve, 1-ve
69  * SetClearColor                       1+ve, 1-ve
70  * GetClearColor                       1+ve, 1-ve
71  * SetClearEnabled                     1+ve, 1-ve
72  * GetClearEnabled                     1+ve, 1-ve
73  * SetCullMode
74  * GetCullMode
75  * SetRefreshRate                      Many
76  * GetRefreshRate                      1+ve
77  * FinishedSignal                      1+ve
78  */
79
80 namespace // unnamed namespace
81 {
82 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
83
84 /*
85  * Simulate time passed by.
86  *
87  * @note this will always process at least 1 frame (1/60 sec)
88  *
89  * @param application Test application instance
90  * @param duration Time to pass in milliseconds.
91  * @return The actual time passed in milliseconds
92  */
93 int Wait(TestApplication& application, int duration = 0)
94 {
95   int time = 0;
96
97   for(int i = 0; i <= (duration / RENDER_FRAME_INTERVAL); i++)
98   {
99     application.SendNotification();
100     application.Render(RENDER_FRAME_INTERVAL);
101     time += RENDER_FRAME_INTERVAL;
102   }
103
104   return time;
105 }
106
107 struct RenderTaskFinished
108 {
109   RenderTaskFinished(bool& finished)
110   : finished(finished)
111   {
112   }
113
114   void operator()(RenderTask& renderTask)
115   {
116     finished = true;
117   }
118
119   bool& finished;
120 };
121
122 struct RenderTaskFinishedRemoveSource
123 {
124   RenderTaskFinishedRemoveSource(bool& finished)
125   : finished(finished),
126     finishedOnce(false)
127   {
128   }
129
130   void operator()(RenderTask& renderTask)
131   {
132     DALI_TEST_CHECK(finishedOnce == false);
133     finished       = true;
134     finishedOnce   = true;
135     Actor srcActor = renderTask.GetSourceActor();
136     UnparentAndReset(srcActor);
137   }
138
139   bool& finished;
140   bool  finishedOnce;
141 };
142
143 struct RenderTaskFinishedRenderAgain
144 {
145   RenderTaskFinishedRenderAgain(bool& finished)
146   : finished(finished),
147     finishedOnce(false)
148   {
149   }
150
151   void operator()(RenderTask& renderTask)
152   {
153     DALI_TEST_CHECK(finishedOnce == false);
154     finished     = true;
155     finishedOnce = true;
156     renderTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
157   }
158
159   bool& finished;
160   bool  finishedOnce;
161 };
162
163 bool TestScreenToFrameBufferFunction(Vector2& coordinates)
164 {
165   coordinates = coordinates + Vector2(1, 2);
166
167   return true;
168 }
169
170 Actor CreateRenderableActorSuccess(TestApplication& application, std::string filename)
171 {
172   Actor actor = CreateRenderableActor();
173   actor.SetProperty(Actor::Property::SIZE, Vector2(80.0f, 80.0f));
174   return actor;
175 }
176
177 Texture CreateTexture()
178 {
179   return Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 80u, 80u);
180 }
181
182 RenderTask CreateRenderTask(TestApplication& application,
183                             CameraActor      offscreenCamera,
184                             Actor            rootActor,       // Reset default render task to point at this actor
185                             Actor            secondRootActor, // Source actor
186                             unsigned int     refreshRate,
187                             bool             glSync,
188                             uint32_t         frameBufferWidth  = 10,
189                             uint32_t         frameBufferHeight = 10)
190 {
191   // Change main render task to use a different root
192   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
193   taskList.GetTask(0u).SetSourceActor(rootActor);
194
195   FrameBuffer frameBuffer = FrameBuffer::New(frameBufferWidth, frameBufferHeight);
196   if(glSync)
197   {
198     NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(frameBufferWidth, frameBufferHeight);
199     Texture                 texture            = Texture::New(*testNativeImagePtr);
200     frameBuffer.AttachColorTexture(texture);
201   }
202
203   // Don't draw output framebuffer // '
204
205   RenderTask newTask = taskList.CreateTask();
206   newTask.SetCameraActor(offscreenCamera);
207   newTask.SetSourceActor(secondRootActor);
208   newTask.SetInputEnabled(false);
209   newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
210   newTask.SetClearEnabled(true);
211   newTask.SetExclusive(true);
212   newTask.SetRefreshRate(refreshRate);
213   newTask.SetFrameBuffer(frameBuffer);
214   newTask.SetProperty(RenderTask::Property::REQUIRES_SYNC, glSync);
215   return newTask;
216 }
217
218 bool UpdateRender(TestApplication& application, TraceCallStack& callStack, bool testDrawn, bool& finishedSig, bool testFinished, bool testKeepUpdating, int lineNumber)
219 {
220   finishedSig = false;
221   callStack.Reset();
222
223   tet_printf("TestApplication::UpdateRender().\n");
224
225   application.Render(16);
226   application.SendNotification();
227
228   bool sigPassed = false;
229   if(testFinished)
230   {
231     sigPassed = finishedSig;
232   }
233   else
234   {
235     sigPassed = !finishedSig;
236   }
237
238   bool drawResult = callStack.FindMethod("DrawElements") || callStack.FindMethod("DrawArrays");
239
240   bool drawPassed = false;
241   if(testDrawn)
242   {
243     drawPassed = drawResult;
244   }
245   else
246   {
247     drawPassed = !drawResult;
248   }
249
250   bool keepUpdating       = (application.GetUpdateStatus() != 0);
251   bool keepUpdatingPassed = false;
252   if(testKeepUpdating)
253   {
254     keepUpdatingPassed = keepUpdating;
255   }
256   else
257   {
258     keepUpdatingPassed = !keepUpdating;
259   }
260
261   bool result = (sigPassed && drawPassed && keepUpdatingPassed);
262
263   tet_printf("UpdateRender: Expected: Draw:%s Signal:%s KeepUpdating: %s  Actual: Draw:%s  Signal:%s KeepUpdating: %s  %s, line %d\n",
264              BOOLSTR(testDrawn),
265              BOOLSTR(testFinished),
266              BOOLSTR(testKeepUpdating),
267              BOOLSTR(drawResult),
268              BOOLSTR(finishedSig),
269              BOOLSTR(keepUpdating),
270              result ? "Passed" : "Failed",
271              lineNumber);
272
273   return result;
274 }
275
276 } // unnamed namespace
277
278 /****************************************************************************************************/
279 /****************************************************************************************************/
280 /********************************   TEST CASES BELOW   **********************************************/
281 /****************************************************************************************************/
282 /****************************************************************************************************/
283
284 int UtcDaliRenderTaskDownCast01(void)
285 {
286   TestApplication application;
287
288   tet_infoline("Testing RenderTask::DownCast()");
289
290   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
291
292   BaseHandle base = taskList.GetTask(0u);
293   DALI_TEST_CHECK(base);
294
295   RenderTask task = RenderTask::DownCast(base);
296   DALI_TEST_CHECK(task);
297
298   // Try calling a method
299   DALI_TEST_CHECK(task.GetSourceActor());
300   END_TEST;
301 }
302
303 int UtcDaliRenderTaskDownCast02(void)
304 {
305   TestApplication application;
306
307   tet_infoline("Testing RenderTask::DownCast()");
308
309   Actor actor = Actor::New();
310
311   RenderTask task = RenderTask::DownCast(actor);
312   DALI_TEST_CHECK(!task);
313
314   END_TEST;
315 }
316
317 int UtcDaliRenderTaskSetSourceActorN(void)
318 {
319   TestApplication application;
320   tet_infoline("Testing RenderTask::SetSourceActor() Negative - try with empty actor handle");
321   Integration::Scene stage = application.GetScene();
322
323   Actor srcActor;
324
325   RenderTaskList taskList   = stage.GetRenderTaskList();
326   RenderTask     renderTask = taskList.CreateTask();
327   renderTask.SetSourceActor(srcActor);
328
329   application.SendNotification();
330   application.Render();
331
332   DALI_TEST_CHECK(!renderTask.GetSourceActor());
333   END_TEST;
334 }
335
336 int UtcDaliRenderTaskSetSourceActorP01(void)
337 {
338   TestApplication application;
339
340   tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that setting a non-renderable actor stops existing source actor being rendered ");
341
342   Integration::Scene stage    = application.GetScene();
343   RenderTaskList     taskList = stage.GetRenderTaskList();
344   RenderTask         task     = taskList.GetTask(0u);
345
346   Actor actor = task.GetSourceActor();
347   DALI_TEST_CHECK(actor);
348
349   Texture img      = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
350   Actor   newActor = CreateRenderableActor(img);
351   newActor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
352   stage.Add(newActor);
353
354   Actor nonRenderableActor = Actor::New();
355   stage.Add(nonRenderableActor);
356
357   // Stop the newActor from being rendered by changing the source actor
358   DALI_TEST_CHECK(nonRenderableActor);
359   task.SetSourceActor(nonRenderableActor);
360   DALI_TEST_CHECK(task.GetSourceActor() != actor);
361   DALI_TEST_CHECK(task.GetSourceActor() == nonRenderableActor);
362
363   TestGlAbstraction& gl        = application.GetGlAbstraction();
364   TraceCallStack&    drawTrace = gl.GetDrawTrace();
365   drawTrace.Enable(true);
366
367   // Update & Render nothing!
368   application.GetGlAbstraction().ClearBoundTextures();
369   application.SendNotification();
370   application.Render();
371
372   // Check that nothing was rendered
373   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
374
375   END_TEST;
376 }
377
378 int UtcDaliRenderTaskSetSourceActorP02(void)
379 {
380   TestApplication application;
381
382   tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that switching source from a non-renderable to a renderable actor causes the texture to be drawn");
383
384   Integration::Scene stage = application.GetScene();
385
386   RenderTaskList taskList = stage.GetRenderTaskList();
387
388   RenderTask task = taskList.GetTask(0u);
389
390   Actor actor = task.GetSourceActor();
391   DALI_TEST_CHECK(actor);
392
393   Texture img      = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
394   Actor   newActor = CreateRenderableActor(img);
395   newActor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
396   stage.Add(newActor);
397
398   Actor nonRenderableActor = Actor::New();
399   stage.Add(nonRenderableActor);
400
401   TestGlAbstraction& gl        = application.GetGlAbstraction();
402   TraceCallStack&    drawTrace = gl.GetDrawTrace();
403   drawTrace.Enable(true);
404
405   // Stop the newActor from being rendered by changing the source actor
406   DALI_TEST_CHECK(nonRenderableActor);
407   task.SetSourceActor(nonRenderableActor);
408   DALI_TEST_CHECK(task.GetSourceActor() != actor);
409   DALI_TEST_CHECK(task.GetSourceActor() == nonRenderableActor);
410
411   // Update & Render nothing!
412   application.GetGlAbstraction().ClearBoundTextures();
413   application.SendNotification();
414   application.Render();
415
416   // Check that nothing was rendered
417   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
418   drawTrace.Reset();
419
420   // Set newActor as the new source Actor
421   task.SetSourceActor(newActor);
422   DALI_TEST_CHECK(task.GetSourceActor() != actor);
423   DALI_TEST_CHECK(task.GetSourceActor() == newActor);
424
425   // Update & Render the newActor
426   application.GetGlAbstraction().ClearBoundTextures();
427   application.SendNotification();
428   application.Render();
429
430   // Check that the newActor was rendered
431   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
432   END_TEST;
433 }
434
435 int UtcDaliRenderTaskSetSourceActorOffScene(void)
436 {
437   TestApplication application;
438
439   tet_infoline("Testing RenderTask::SetSourceActor (on/off stage testing)");
440
441   Integration::Scene stage    = application.GetScene();
442   RenderTaskList     taskList = stage.GetRenderTaskList();
443   RenderTask         task     = taskList.GetTask(0u);
444
445   Actor actor = task.GetSourceActor();
446   DALI_TEST_CHECK(actor);
447
448   TestGlAbstraction& gl        = application.GetGlAbstraction();
449   TraceCallStack&    drawTrace = gl.GetDrawTrace();
450   drawTrace.Enable(true);
451
452   Texture img      = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
453   Actor   newActor = CreateRenderableActor(img);
454   newActor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
455   task.SetSourceActor(newActor);
456   // Don't add newActor to stage yet   //'
457
458   // Update & Render with the actor initially off-stage
459   application.SendNotification();
460   application.Render();
461
462   // Check that nothing was rendered
463   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
464
465   // Now add to stage
466   stage.Add(newActor);
467
468   // Update & Render with the actor on-stage
469   application.GetGlAbstraction().ClearBoundTextures();
470   application.SendNotification();
471   application.Render();
472
473   // Check that the newActor was rendered
474   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
475   drawTrace.Reset();
476
477   // Now remove from stage
478   stage.Remove(newActor);
479
480   // Update & Render with the actor off-stage
481   application.SendNotification();
482   application.Render();
483   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
484
485   END_TEST;
486 }
487
488 int UtcDaliRenderTaskSetSourceActorEmpty(void)
489 {
490   TestApplication application;
491
492   tet_infoline("Testing RenderTask::SetSourceActor (empty handle case)");
493
494   Integration::Scene stage    = application.GetScene();
495   RenderTaskList     taskList = stage.GetRenderTaskList();
496   RenderTask         task     = taskList.GetTask(0u);
497
498   Actor actor = task.GetSourceActor();
499   DALI_TEST_CHECK(actor);
500
501   Texture img      = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
502   Actor   newActor = CreateRenderableActor(img);
503   newActor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
504   stage.Add(newActor);
505
506   Actor nonRenderableActor = Actor::New();
507   stage.Add(nonRenderableActor);
508
509   // Set with empty handle
510   task.SetSourceActor(Actor());
511   DALI_TEST_CHECK(!task.GetSourceActor());
512
513   TestGlAbstraction& gl        = application.GetGlAbstraction();
514   TraceCallStack&    drawTrace = gl.GetDrawTrace();
515   drawTrace.Enable(true);
516
517   // Update & Render nothing!
518   application.SendNotification();
519   application.Render();
520
521   // Check that nothing was rendered
522   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
523
524   // Set with non-empty handle
525   task.SetSourceActor(newActor);
526   DALI_TEST_CHECK(task.GetSourceActor() == newActor);
527
528   // Update & Render the newActor
529   application.GetGlAbstraction().ClearBoundTextures();
530   application.SendNotification();
531   application.Render();
532
533   // Check that the newActor was rendered
534   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
535   END_TEST;
536 }
537
538 int UtcDaliRenderTaskSetSourceActorDestroyed(void)
539 {
540   TestApplication application;
541
542   tet_infoline("Testing RenderTask::SetSourceActor - Set a source actor and destroy the source actor");
543
544   Integration::Scene stage    = application.GetScene();
545   RenderTaskList     taskList = stage.GetRenderTaskList();
546   RenderTask         task     = taskList.GetTask(0u);
547
548   Actor actor = task.GetSourceActor();
549   DALI_TEST_CHECK(actor);
550
551   Texture img = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
552
553   Actor newActor = CreateRenderableActor(img);
554   newActor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
555   stage.Add(newActor);
556
557   task.SetSourceActor(newActor);
558
559   DALI_TEST_CHECK(task.GetSourceActor() != actor);
560   DALI_TEST_CHECK(task.GetSourceActor() == newActor);
561
562   application.SendNotification();
563   application.Render();
564
565   // Destroy the source actor
566   stage.Remove(newActor);
567   newActor.Reset();
568
569   DALI_TEST_CHECK(!task.GetSourceActor()); // The source actor should be an empty handle.
570
571   END_TEST;
572 }
573
574 int UtcDaliRenderTaskGetSourceActorP01(void)
575 {
576   TestApplication application;
577
578   tet_infoline("Testing RenderTask::GetSourceActor() Check the default render task has a valid source actor");
579
580   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
581
582   RenderTask task = taskList.GetTask(0u);
583
584   Actor actor = task.GetSourceActor();
585   DALI_TEST_CHECK(actor);
586
587   // By default the entire scene should be rendered
588   Actor root = application.GetScene().GetLayer(0);
589   DALI_TEST_CHECK(root == actor);
590   END_TEST;
591 }
592
593 int UtcDaliRenderTaskGetSourceActorP02(void)
594 {
595   TestApplication application;
596
597   tet_infoline("Testing RenderTask::GetSourceActor() Create a new render task, Add a new actor to the stage and set it as the source of the new render task. Get its source actor and check that it is equivalent to what was set.");
598
599   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
600   RenderTask     task     = taskList.CreateTask();
601   Actor          actor    = Actor::New();
602   application.GetScene().Add(actor);
603   task.SetSourceActor(actor);
604
605   DALI_TEST_EQUALS(actor, task.GetSourceActor(), TEST_LOCATION);
606
607   END_TEST;
608 }
609
610 int UtcDaliRenderTaskGetSourceActorN(void)
611 {
612   TestApplication application;
613
614   tet_infoline("Testing RenderTask::GetSourceActor() Try with empty handle");
615
616   RenderTask task;
617   try
618   {
619     Actor actor = task.GetSourceActor();
620   }
621   catch(Dali::DaliException& e)
622   {
623     DALI_TEST_PRINT_ASSERT(e);
624     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
625   }
626
627   END_TEST;
628 }
629
630 int UtcDaliRenderTaskSetExclusive(void)
631 {
632   TestApplication application;
633
634   tet_infoline("Testing RenderTask::SetExclusive() Check that exclusion works");
635
636   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
637
638   // Manipulate the GenTextures behaviour, to identify different actors
639
640   std::vector<GLuint> ids;
641   ids.push_back(8);  // 8 = actor1
642   ids.push_back(9);  // 9 = actor2
643   ids.push_back(10); // 10 = actor3
644   application.GetGlAbstraction().SetNextTextureIds(ids);
645
646   Texture img1   = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
647   Actor   actor1 = CreateRenderableActor(img1);
648   actor1.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
649   application.GetScene().Add(actor1);
650
651   // Update & Render actor1
652   application.SendNotification();
653   application.Render();
654
655   // Check that the actor1 was rendered
656   const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures(GL_TEXTURE0);
657   DALI_TEST_GREATER(boundTextures.size(), static_cast<std::vector<GLuint>::size_type>(0), TEST_LOCATION);
658
659   if(boundTextures.size())
660   {
661     int c = 0;
662     DALI_TEST_EQUALS(boundTextures[c++], 8u /*unique to actor1*/, TEST_LOCATION);
663     if(boundTextures.size() > 1)
664     {
665       DALI_TEST_EQUALS(boundTextures[c++], 8u /*unique to actor1*/, TEST_LOCATION);
666     }
667   }
668
669   Texture img2 = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
670
671   Actor actor2 = CreateRenderableActor(img2);
672   actor2.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
673
674   // Force actor2 to be rendered before actor1
675   Layer layer = Layer::New();
676   application.GetScene().Add(layer);
677   layer.Add(actor2);
678   layer.LowerToBottom();
679
680   // Update & Render
681   application.GetGlAbstraction().ClearBoundTextures();
682   application.SendNotification();
683   application.Render();
684
685   // Check that the actors were rendered
686   DALI_TEST_GREATER(boundTextures.size(), static_cast<std::vector<GLuint>::size_type>(1), TEST_LOCATION);
687
688   if(boundTextures.size())
689   {
690     int c = 0;
691     DALI_TEST_EQUALS(boundTextures[c++], 9u /*unique to actor2*/, TEST_LOCATION);
692     if(boundTextures.size() > 2)
693     {
694       DALI_TEST_EQUALS(boundTextures[c++], 9u /*unique to actor1*/, TEST_LOCATION);
695     }
696     DALI_TEST_EQUALS(boundTextures[c++], 8u /*unique to actor1*/, TEST_LOCATION);
697   }
698
699   Texture img3   = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
700   Actor   actor3 = CreateRenderableActor(img3);
701   actor3.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
702
703   // Force actor3 to be rendered before actor2
704   layer = Layer::New();
705   application.GetScene().Add(layer);
706   layer.Add(actor3);
707   layer.LowerToBottom();
708
709   // Update & Render all actors
710   application.GetGlAbstraction().ClearBoundTextures();
711   application.SendNotification();
712   application.Render();
713
714   // Check that the actors were rendered
715   DALI_TEST_GREATER(boundTextures.size(), static_cast<std::vector<GLuint>::size_type>(2), TEST_LOCATION);
716
717   if(boundTextures.size())
718   {
719     int c = 0;
720     DALI_TEST_EQUALS(boundTextures[c++], 10u /*unique to actor3*/, TEST_LOCATION);
721     if(boundTextures.size() > 3)
722     {
723       DALI_TEST_EQUALS(boundTextures[c++], 10u /*unique to actor2*/, TEST_LOCATION);
724     }
725     DALI_TEST_EQUALS(boundTextures[c++], 9u /*unique to actor2*/, TEST_LOCATION);
726     DALI_TEST_EQUALS(boundTextures[c++], 8u /*unique to actor1*/, TEST_LOCATION);
727   }
728
729   // Both actors are now connected to the root node
730   // Setup 2 render-tasks - the first will render from the root-node, and the second from actor2
731
732   // Not exclusive is the default
733   RenderTask task1 = taskList.GetTask(0u);
734   DALI_TEST_CHECK(false == task1.IsExclusive());
735
736   RenderTask task2 = taskList.CreateTask();
737   DALI_TEST_CHECK(false == task2.IsExclusive());
738   task2.SetSourceActor(actor2);
739
740   // Task1 should render all actors, and task 2 should render only actor2
741
742   application.GetGlAbstraction().ClearBoundTextures();
743   application.SendNotification();
744   application.Render();
745
746   DALI_TEST_EQUALS(boundTextures.size(), 4u, TEST_LOCATION);
747
748   if(boundTextures.size() == 4)
749   {
750     // Test that task 1 renders actor3, then actor2 & then actor1
751     DALI_TEST_CHECK(boundTextures[0] == 10u);
752     DALI_TEST_CHECK(boundTextures[1] == 9u);
753     DALI_TEST_CHECK(boundTextures[2] == 8u);
754
755     // Test that task 2 renders actor2
756     DALI_TEST_EQUALS(boundTextures[3], 9u, TEST_LOCATION);
757   }
758
759   // Make actor2 exclusive to task2
760
761   task2.SetExclusive(true);
762   DALI_TEST_CHECK(true == task2.IsExclusive());
763
764   // Task1 should render only actor1, and task 2 should render only actor2
765
766   application.GetGlAbstraction().ClearBoundTextures();
767   application.SendNotification();
768   application.Render();
769
770   DALI_TEST_EQUALS(boundTextures.size(), 3u, TEST_LOCATION);
771   if(boundTextures.size() == 3)
772   {
773     // Test that task 1 renders actor3 & actor1
774     DALI_TEST_CHECK(boundTextures[0] == 10u);
775     DALI_TEST_CHECK(boundTextures[1] == 8u);
776
777     // Test that task 2 renders actor2
778     DALI_TEST_CHECK(boundTextures[2] == 9u);
779   }
780
781   // Create a renderable actor and replace the source actor in task2
782   auto actor4 = CreateRenderableActor();
783   task2.SetSourceActor(actor3);
784   DALI_TEST_EQUALS(actor3, task2.GetSourceActor(), TEST_LOCATION);
785
786   END_TEST;
787 }
788
789 int UtcDaliRenderTaskSetExclusive02(void)
790 {
791   TestApplication application;
792
793   tet_infoline("Testing RenderTask::SetExclusive() Check that changing from exclusive to not-exclusive works");
794
795   std::vector<GLuint> ids;
796   ids.push_back(8); // 8 = actor1
797   application.GetGlAbstraction().SetNextTextureIds(ids);
798
799   Texture img1   = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
800   Actor   actor1 = CreateRenderableActor(img1);
801   actor1.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
802   application.GetScene().Add(actor1);
803
804   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
805   RenderTask     task     = taskList.CreateTask();
806
807   task.SetSourceActor(actor1);
808   task.SetExclusive(true); // Actor should only render once
809
810   TestGlAbstraction& gl        = application.GetGlAbstraction();
811   TraceCallStack&    drawTrace = gl.GetDrawTrace();
812   drawTrace.Enable(true);
813
814   // Update & Render actor1
815   application.SendNotification();
816   application.Render();
817
818   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
819
820   // Set task to non-exclusive - actor1 should render twice:
821   drawTrace.Reset();
822   task.SetExclusive(false);
823   application.SendNotification();
824   application.Render();
825
826   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 2, TEST_LOCATION);
827
828   END_TEST;
829 }
830
831 int UtcDaliRenderTaskSetExclusiveN(void)
832 {
833   TestApplication application;
834
835   tet_infoline("Testing RenderTask::SetExclusive() on empty handle");
836
837   RenderTask task;
838   try
839   {
840     task.SetExclusive(true);
841   }
842   catch(Dali::DaliException& e)
843   {
844     DALI_TEST_PRINT_ASSERT(e);
845     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
846   }
847   END_TEST;
848 }
849
850 int UtcDaliRenderTaskIsExclusive01(void)
851 {
852   TestApplication application;
853
854   tet_infoline("Testing RenderTask::IsExclusive() Check default values are non-exclusive");
855
856   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
857
858   // Not exclusive is the default
859   RenderTask task = taskList.GetTask(0u);
860   DALI_TEST_CHECK(false == task.IsExclusive());
861
862   RenderTask newTask = taskList.CreateTask();
863   DALI_TEST_CHECK(false == newTask.IsExclusive());
864
865   END_TEST;
866 }
867
868 int UtcDaliRenderTaskIsExclusive02(void)
869 {
870   TestApplication application;
871
872   tet_infoline("Testing RenderTask::IsExclusive() Check the getter returns set values");
873
874   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
875
876   // Not exclusive is the default
877   RenderTask newTask = taskList.CreateTask();
878   DALI_TEST_EQUALS(newTask.IsExclusive(), false, TEST_LOCATION);
879
880   newTask.SetExclusive(true);
881   DALI_TEST_EQUALS(newTask.IsExclusive(), true, TEST_LOCATION);
882   END_TEST;
883 }
884
885 int UtcDaliRenderTaskIsExclusiveN(void)
886 {
887   TestApplication application;
888
889   tet_infoline("Testing RenderTask::IsExclusive() on empty handle");
890
891   RenderTask task;
892   try
893   {
894     bool x = task.IsExclusive();
895     (void)x;
896   }
897   catch(Dali::DaliException& e)
898   {
899     DALI_TEST_PRINT_ASSERT(e);
900     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
901   }
902   END_TEST;
903 }
904
905 int UtcDaliRenderTaskSetInputEnabled(void)
906 {
907   TestApplication application;
908
909   tet_infoline("Testing RenderTask::SetInputEnabled()");
910
911   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
912
913   // Input is enabled by default
914   RenderTask task = taskList.GetTask(0u);
915   DALI_TEST_CHECK(true == task.GetInputEnabled());
916
917   task.SetInputEnabled(false);
918   DALI_TEST_CHECK(false == task.GetInputEnabled());
919
920   task.SetInputEnabled(true);
921   DALI_TEST_CHECK(true == task.GetInputEnabled());
922   END_TEST;
923 }
924
925 int UtcDaliRenderTaskGetInputEnabled(void)
926 {
927   TestApplication application;
928
929   tet_infoline("Testing RenderTask::GetInputEnabled()");
930
931   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
932
933   // Input is enabled by default
934   RenderTask task = taskList.GetTask(0u);
935   DALI_TEST_EQUALS(true, task.GetInputEnabled(), TEST_LOCATION);
936
937   RenderTask newTask = taskList.CreateTask();
938   DALI_TEST_EQUALS(true, newTask.GetInputEnabled(), TEST_LOCATION);
939
940   newTask.SetInputEnabled(false);
941   DALI_TEST_EQUALS(false, newTask.GetInputEnabled(), TEST_LOCATION);
942
943   END_TEST;
944 }
945
946 int UtcDaliRenderTaskSetCameraActorP(void)
947 {
948   TestApplication application;
949
950   tet_infoline("Testing RenderTask::SetCameraActor()");
951
952   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
953
954   RenderTask task = taskList.GetTask(0u);
955
956   Actor defaultCameraActor = task.GetCameraActor();
957   DALI_TEST_CHECK(defaultCameraActor);
958
959   CameraActor newCameraActor = CameraActor::New();
960   DALI_TEST_CHECK(newCameraActor);
961
962   task.SetCameraActor(newCameraActor);
963   DALI_TEST_CHECK(task.GetCameraActor() != defaultCameraActor);
964   DALI_TEST_EQUALS(task.GetCameraActor(), newCameraActor, TEST_LOCATION);
965   END_TEST;
966 }
967
968 int UtcDaliRenderTaskSetCameraActorN(void)
969 {
970   TestApplication application;
971
972   tet_infoline("Testing RenderTask::SetCameraActor() with empty actor handle");
973
974   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
975
976   RenderTask task = taskList.GetTask(0u);
977
978   Actor actor = task.GetCameraActor();
979   DALI_TEST_CHECK(actor);
980
981   CameraActor cameraActor;
982
983   task.SetCameraActor(cameraActor);
984   DALI_TEST_EQUALS((bool)task.GetCameraActor(), false, TEST_LOCATION);
985   DALI_TEST_EQUALS(task.GetCameraActor(), cameraActor, TEST_LOCATION);
986   END_TEST;
987 }
988
989 int UtcDaliRenderTaskSetCameraActorDestroyed(void)
990 {
991   TestApplication application;
992
993   tet_infoline("Testing RenderTask::SetCameraActor - Set a camera actor and destroy the camera actor");
994
995   Integration::Scene stage    = application.GetScene();
996   RenderTaskList     taskList = stage.GetRenderTaskList();
997   RenderTask         task     = taskList.GetTask(0u);
998
999   CameraActor newCameraActor = CameraActor::New();
1000   task.SetCameraActor(newCameraActor);
1001
1002   DALI_TEST_EQUALS(task.GetCameraActor(), newCameraActor, TEST_LOCATION);
1003
1004   // Destroy the camera actor
1005   newCameraActor.Reset();
1006
1007   CameraActor camera = task.GetCameraActor();
1008   DALI_TEST_CHECK(!camera); // The camera actor should be an empty handle.
1009
1010   END_TEST;
1011 }
1012
1013 int UtcDaliRenderTaskGetCameraActorP(void)
1014 {
1015   TestApplication application;
1016
1017   tet_infoline("Testing RenderTask::GetCameraActor()");
1018
1019   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1020
1021   RenderTask task = taskList.GetTask(0u);
1022
1023   CameraActor actor = task.GetCameraActor();
1024   DALI_TEST_CHECK(actor);
1025   DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION);
1026   DALI_TEST_GREATER(actor.GetFieldOfView(), 0.0f, TEST_LOCATION);
1027   END_TEST;
1028 }
1029
1030 int UtcDaliRenderTaskGetCameraActorN(void)
1031 {
1032   TestApplication application;
1033
1034   tet_infoline("Testing RenderTask::GetCameraActor() with empty handle");
1035   RenderTask task;
1036
1037   try
1038   {
1039     Actor actor = task.GetCameraActor();
1040   }
1041   catch(Dali::DaliException& e)
1042   {
1043     DALI_TEST_PRINT_ASSERT(e);
1044     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1045   }
1046
1047   END_TEST;
1048 }
1049
1050 int UtcDaliRenderTaskSetFrameBufferP(void)
1051 {
1052   TestApplication application;
1053
1054   tet_infoline("Testing RenderTask::SetFrameBuffer()");
1055
1056   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1057
1058   RenderTask task = taskList.GetTask(0u);
1059
1060   FrameBuffer newFrameBuffer = FrameBuffer::New(128u, 128u, FrameBuffer::Attachment::NONE);
1061   task.SetFrameBuffer(newFrameBuffer);
1062   DALI_TEST_CHECK(task.GetFrameBuffer() == newFrameBuffer);
1063   END_TEST;
1064 }
1065
1066 int UtcDaliRenderTaskSetFrameBufferN(void)
1067 {
1068   TestApplication application;
1069
1070   tet_infoline("Testing RenderTask::SetFrameBuffer()");
1071
1072   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1073
1074   RenderTask  task = taskList.GetTask(0u);
1075   FrameBuffer newFrameBuffer; // Empty handle
1076   task.SetFrameBuffer(newFrameBuffer);
1077   DALI_TEST_EQUALS((bool)task.GetFrameBuffer(), false, TEST_LOCATION);
1078   END_TEST;
1079 }
1080
1081 int UtcDaliRenderTaskGetFrameBufferP(void)
1082 {
1083   TestApplication application;
1084
1085   tet_infoline("Testing RenderTask::GetFrameBuffer()");
1086
1087   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1088
1089   RenderTask task = taskList.GetTask(0u);
1090
1091   FrameBuffer newFrameBuffer = FrameBuffer::New(1u, 1u, FrameBuffer::Attachment::NONE);
1092   task.SetFrameBuffer(newFrameBuffer);
1093   DALI_TEST_CHECK(task.GetFrameBuffer() == newFrameBuffer);
1094   END_TEST;
1095 }
1096
1097 int UtcDaliRenderTaskGetFrameBufferN(void)
1098 {
1099   TestApplication application;
1100
1101   tet_infoline("Testing RenderTask::GetFrameBuffer()");
1102
1103   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1104
1105   RenderTask task = taskList.GetTask(0u);
1106
1107   // By default render-tasks do not render off-screen
1108   FrameBuffer frameBuffer = task.GetFrameBuffer();
1109   DALI_TEST_CHECK(!frameBuffer);
1110
1111   END_TEST;
1112 }
1113
1114 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionP(void)
1115 {
1116   TestApplication application;
1117
1118   tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1119
1120   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1121
1122   RenderTask task = taskList.GetTask(0u);
1123
1124   task.SetScreenToFrameBufferFunction(TestScreenToFrameBufferFunction);
1125
1126   Vector2 coordinates(5, 10);
1127   Vector2 convertedCoordinates(6, 12); // + Vector(1, 2)
1128
1129   RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1130   DALI_TEST_CHECK(func(coordinates));
1131   DALI_TEST_CHECK(coordinates == convertedCoordinates);
1132
1133   task.SetScreenToFrameBufferFunction(RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION);
1134   func = task.GetScreenToFrameBufferFunction();
1135   DALI_TEST_CHECK(func(coordinates));
1136
1137   task.SetScreenToFrameBufferFunction(RenderTask::DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION);
1138   func = task.GetScreenToFrameBufferFunction();
1139   DALI_TEST_CHECK(!func(coordinates));
1140   END_TEST;
1141 }
1142
1143 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionN(void)
1144 {
1145   TestApplication application;
1146
1147   tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1148
1149   RenderTask task; // Empty handle
1150   try
1151   {
1152     task.SetScreenToFrameBufferFunction(TestScreenToFrameBufferFunction);
1153   }
1154   catch(Dali::DaliException& e)
1155   {
1156     DALI_TEST_PRINT_ASSERT(e);
1157     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1158   }
1159   END_TEST;
1160 }
1161
1162 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionP(void)
1163 {
1164   TestApplication application;
1165
1166   tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction()");
1167
1168   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1169
1170   RenderTask task = taskList.GetTask(0u);
1171
1172   Vector2 originalCoordinates(5, 10);
1173   Vector2 coordinates(5, 10);
1174
1175   RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1176   DALI_TEST_CHECK(!func(coordinates));                 // conversion should fail by default
1177   DALI_TEST_CHECK(coordinates == originalCoordinates); // coordinates should not be modified
1178   END_TEST;
1179 }
1180
1181 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionN(void)
1182 {
1183   TestApplication application;
1184
1185   tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction() on empty handle");
1186
1187   RenderTask task;
1188   try
1189   {
1190     RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1191     (void)func;
1192   }
1193   catch(Dali::DaliException& e)
1194   {
1195     DALI_TEST_PRINT_ASSERT(e);
1196     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1197   }
1198   END_TEST;
1199 }
1200
1201 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorP(void)
1202 {
1203   TestApplication application;
1204   tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor ");
1205
1206   RenderTaskList taskList     = application.GetScene().GetRenderTaskList();
1207   RenderTask     renderTask   = taskList.CreateTask();
1208   Actor          mappingActor = Actor::New();
1209   renderTask.SetScreenToFrameBufferMappingActor(mappingActor);
1210
1211   DALI_TEST_EQUALS(mappingActor, renderTask.GetScreenToFrameBufferMappingActor(), TEST_LOCATION);
1212   END_TEST;
1213 }
1214
1215 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorN(void)
1216 {
1217   TestApplication application;
1218   tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1219
1220   RenderTask task;
1221   try
1222   {
1223     Actor mappingActor;
1224     task.SetScreenToFrameBufferMappingActor(mappingActor);
1225   }
1226   catch(Dali::DaliException& e)
1227   {
1228     DALI_TEST_PRINT_ASSERT(e);
1229     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1230   }
1231   END_TEST;
1232 }
1233
1234 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActor02N(void)
1235 {
1236   TestApplication application;
1237   tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1238
1239   RenderTaskList taskList   = application.GetScene().GetRenderTaskList();
1240   RenderTask     renderTask = taskList.CreateTask();
1241   Actor          actor;
1242   renderTask.SetScreenToFrameBufferMappingActor(actor);
1243
1244   DALI_TEST_EQUALS((bool)renderTask.GetScreenToFrameBufferMappingActor(), false, TEST_LOCATION);
1245   END_TEST;
1246 }
1247
1248 int UtcDaliRenderTaskGetViewportP01(void)
1249 {
1250   TestApplication application;
1251
1252   tet_infoline("Testing RenderTask::GetViewport() on default task");
1253
1254   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1255   RenderTask     task     = taskList.GetTask(0u);
1256   Viewport       viewport = task.GetViewport();
1257
1258   // By default the viewport should match the stage width/height
1259   Vector2  stageSize = application.GetScene().GetSize();
1260   Viewport expectedViewport(0, 0, stageSize.width, stageSize.height);
1261   DALI_TEST_CHECK(viewport == expectedViewport);
1262   END_TEST;
1263 }
1264
1265 int UtcDaliRenderTaskGetViewportP02(void)
1266 {
1267   TestApplication application;
1268
1269   tet_infoline("Testing RenderTask::GetViewport() on new task");
1270
1271   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1272   RenderTask     task     = taskList.CreateTask();
1273   Viewport       viewport = task.GetViewport();
1274
1275   // By default the viewport should match the stage width/height
1276   Vector2  stageSize = application.GetScene().GetSize();
1277   Viewport expectedViewport(0, 0, stageSize.width, stageSize.height);
1278   DALI_TEST_CHECK(viewport == expectedViewport);
1279   END_TEST;
1280 }
1281
1282 int UtcDaliRenderTaskGetViewportN(void)
1283 {
1284   TestApplication application;
1285
1286   tet_infoline("Testing RenderTask::GetViewport() on empty handle");
1287
1288   RenderTask task;
1289   try
1290   {
1291     Viewport viewport = task.GetViewport();
1292     (void)viewport;
1293   }
1294   catch(Dali::DaliException& e)
1295   {
1296     DALI_TEST_PRINT_ASSERT(e);
1297     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1298   }
1299   END_TEST;
1300 }
1301
1302 int UtcDaliRenderTaskSetViewportP(void)
1303 {
1304   TestApplication application;
1305
1306   tet_infoline("Testing RenderTask::SetViewport()");
1307
1308   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1309
1310   RenderTask task      = taskList.GetTask(0u);
1311   Vector2    stageSize = application.GetScene().GetSize();
1312   Viewport   newViewport(0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f);
1313   task.SetViewport(newViewport);
1314
1315   // Update (viewport is a property)
1316   application.SendNotification();
1317   application.Render();
1318
1319   DALI_TEST_CHECK(task.GetViewport() == newViewport);
1320   END_TEST;
1321 }
1322
1323 int UtcDaliRenderTaskSetViewportN(void)
1324 {
1325   TestApplication application;
1326
1327   tet_infoline("Testing RenderTask::SetViewport()");
1328
1329   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1330
1331   RenderTask task;
1332   try
1333   {
1334     Vector2  stageSize = application.GetScene().GetSize();
1335     Viewport newViewport(0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f);
1336     task.SetViewport(newViewport);
1337   }
1338   catch(Dali::DaliException& e)
1339   {
1340     DALI_TEST_PRINT_ASSERT(e);
1341     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1342   }
1343
1344   END_TEST;
1345 }
1346
1347 int UtcDaliRenderTaskSetViewportPosition(void)
1348 {
1349   TestApplication application;
1350
1351   tet_infoline("Testing RenderTask::SetViewportPosition()");
1352
1353   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1354
1355   RenderTask task = taskList.GetTask(0u);
1356
1357   Viewport viewport = task.GetViewport();
1358
1359   // By default the viewport should match the stage width/height
1360
1361   Vector2  stageSize = application.GetScene().GetSize();
1362   Viewport expectedViewport(0, 0, stageSize.width, stageSize.height);
1363   DALI_TEST_CHECK(viewport == expectedViewport);
1364
1365   // 'Setter' test
1366   Vector2 newPosition(25.0f, 50.0f);
1367   task.SetViewportPosition(newPosition);
1368
1369   // Update (viewport is a property)
1370   application.SendNotification();
1371   application.Render();
1372
1373   DALI_TEST_EQUALS(task.GetCurrentViewportPosition(), newPosition, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1374
1375   // Set by Property test
1376   Vector2 newPosition2(32.0f, 32.0f);
1377   task.SetProperty(RenderTask::Property::VIEWPORT_POSITION, newPosition2);
1378   DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition2, TEST_LOCATION);
1379   DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition, TEST_LOCATION); // still the old position
1380
1381   // Update
1382   application.SendNotification();
1383   application.Render();
1384
1385   DALI_TEST_EQUALS(task.GetCurrentViewportPosition(), newPosition2, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1386   DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition2, TEST_LOCATION);
1387   DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition2, TEST_LOCATION);
1388
1389   Vector2   newPosition3(64.0f, 0.0f);
1390   Animation animation = Animation::New(1.0f);
1391   animation.AnimateTo(Property(task, RenderTask::Property::VIEWPORT_POSITION), newPosition3, AlphaFunction::LINEAR);
1392   animation.Play();
1393
1394   DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1395   DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition2, TEST_LOCATION);
1396
1397   // Perform 1000ms worth of updates at which point animation should have completed.
1398   Wait(application, 1000);
1399   DALI_TEST_EQUALS(task.GetCurrentViewportPosition(), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1400   DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1401   DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1402
1403   // Create another animation which animates by a certain value
1404   const Vector2 newPosition4(75.0f, 45.0f);
1405   const Vector2 relativePosition(newPosition4 - newPosition3);
1406   animation = Animation::New(1.0f);
1407   animation.AnimateBy(Property(task, RenderTask::Property::VIEWPORT_POSITION), relativePosition);
1408   animation.Play();
1409
1410   DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1411   DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition3, TEST_LOCATION);
1412
1413   // Perform 1000ms worth of updates at which point animation should have completed.
1414   Wait(application, 1000);
1415   DALI_TEST_EQUALS(task.GetCurrentViewportPosition(), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1416   DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1417   DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1418
1419   END_TEST;
1420 }
1421
1422 int UtcDaliRenderTaskSetViewportSize(void)
1423 {
1424   TestApplication application;
1425
1426   tet_infoline("Testing RenderTask::SetViewportSize()");
1427
1428   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1429
1430   RenderTask task = taskList.GetTask(0u);
1431
1432   Viewport viewport = task.GetViewport();
1433
1434   // By default the viewport should match the stage width/height
1435
1436   Vector2  stageSize = application.GetScene().GetSize();
1437   Viewport expectedViewport(0, 0, stageSize.width, stageSize.height);
1438   DALI_TEST_CHECK(viewport == expectedViewport);
1439
1440   Vector2 newSize(128.0f, 64.0f);
1441   task.SetViewportSize(newSize);
1442
1443   // Update (viewport is a property)
1444   application.SendNotification();
1445   application.Render();
1446
1447   DALI_TEST_EQUALS(task.GetCurrentViewportSize(), newSize, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1448
1449   // Set by Property test
1450   Vector2 newSize2(50.0f, 50.0f);
1451   task.SetProperty(RenderTask::Property::VIEWPORT_SIZE, newSize2);
1452   DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize2, TEST_LOCATION);
1453   DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize, TEST_LOCATION); // still the old position
1454
1455   // Update
1456   application.SendNotification();
1457   application.Render();
1458
1459   DALI_TEST_EQUALS(task.GetCurrentViewportSize(), newSize2, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1460   DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize2, TEST_LOCATION);
1461   DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize2, TEST_LOCATION);
1462
1463   Vector2   newSize3(10.0f, 10.0f);
1464   Animation animation = Animation::New(1.0f);
1465   animation.AnimateTo(Property(task, RenderTask::Property::VIEWPORT_SIZE), newSize3, AlphaFunction::LINEAR);
1466   animation.Play();
1467
1468   DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1469   DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize2, TEST_LOCATION);
1470
1471   // Perform 1000ms worth of updates at which point animation should have completed.
1472   Wait(application, 1000);
1473   DALI_TEST_EQUALS(task.GetCurrentViewportSize(), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1474   DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1475   DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1476
1477   // Create another animation which animates by a certain value
1478   const Vector2 newSize4(75.0f, 45.0f);
1479   const Vector2 relativeSize(newSize4 - newSize3);
1480   animation = Animation::New(1.0f);
1481   animation.AnimateBy(Property(task, RenderTask::Property::VIEWPORT_SIZE), relativeSize);
1482   animation.Play();
1483
1484   DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1485   DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize3, TEST_LOCATION);
1486
1487   // Perform 1000ms worth of updates at which point animation should have completed.
1488   Wait(application, 1000);
1489   DALI_TEST_EQUALS(task.GetCurrentViewportSize(), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1490   DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1491   DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1492
1493   END_TEST;
1494 }
1495
1496 int UtcDaliRenderTaskSetClearColorP(void)
1497 {
1498   TestApplication application;
1499
1500   tet_infoline("Testing RenderTask::SetClearColor()");
1501
1502   Vector4 testColor(1.0f, 2.0f, 3.0f, 4.0f);
1503   Vector4 testColor2(5.0f, 6.0f, 7.0f, 8.0f);
1504
1505   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1506
1507   RenderTask task = taskList.GetTask(0u);
1508   DALI_TEST_CHECK(task.GetClearColor() != testColor);
1509
1510   task.SetClearColor(testColor);
1511
1512   // Wait a frame.
1513   Wait(application);
1514
1515   DALI_TEST_EQUALS(task.GetClearColor(), testColor, TEST_LOCATION);
1516
1517   task.SetProperty(RenderTask::Property::CLEAR_COLOR, testColor2);
1518   DALI_TEST_EQUALS(task.GetProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), testColor2, TEST_LOCATION);
1519   DALI_TEST_EQUALS(task.GetCurrentProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), testColor, TEST_LOCATION); // still the old color
1520
1521   // Wait a frame.
1522   Wait(application);
1523
1524   DALI_TEST_EQUALS(task.GetClearColor(), testColor2, TEST_LOCATION);
1525   DALI_TEST_EQUALS(task.GetProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), testColor2, TEST_LOCATION);
1526   DALI_TEST_EQUALS(task.GetCurrentProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), testColor2, TEST_LOCATION);
1527
1528   Vector4   newColor3(10.0f, 10.0f, 20.0f, 30.0f);
1529   Animation animation = Animation::New(1.0f);
1530   animation.AnimateTo(Property(task, RenderTask::Property::CLEAR_COLOR), newColor3, AlphaFunction::LINEAR);
1531   animation.Play();
1532
1533   DALI_TEST_EQUALS(task.GetProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1534   DALI_TEST_EQUALS(task.GetCurrentProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), testColor2, TEST_LOCATION);
1535
1536   // Perform 1000ms worth of updates at which point animation should have completed.
1537   Wait(application, 1000);
1538   DALI_TEST_EQUALS(task.GetCurrentProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1539   DALI_TEST_EQUALS(task.GetProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1540
1541   // Create another animation which animates by a certain value
1542   const Vector4 newColor4(0.45f, 0.35f, 0.25f, 0.1f);
1543   const Vector4 relativeColor(newColor4 - newColor3);
1544   animation = Animation::New(1.0f);
1545   animation.AnimateBy(Property(task, RenderTask::Property::CLEAR_COLOR), relativeColor);
1546   animation.Play();
1547
1548   DALI_TEST_EQUALS(task.GetProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor4, Math::MACHINE_EPSILON_10, TEST_LOCATION);
1549   DALI_TEST_EQUALS(task.GetCurrentProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor3, Math::MACHINE_EPSILON_10, TEST_LOCATION);
1550
1551   // Perform 1000ms worth of updates at which point animation should have completed.
1552   Wait(application, 1000);
1553   DALI_TEST_EQUALS(task.GetCurrentProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor4, Math::MACHINE_EPSILON_10, TEST_LOCATION);
1554   DALI_TEST_EQUALS(task.GetProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor4, Math::MACHINE_EPSILON_10, TEST_LOCATION);
1555
1556   END_TEST;
1557 }
1558
1559 int UtcDaliRenderTaskSetClearColorN(void)
1560 {
1561   TestApplication application;
1562
1563   tet_infoline("Testing RenderTask::SetClearColor() on empty handle");
1564
1565   RenderTask task;
1566   try
1567   {
1568     task.SetClearColor(Vector4::ZERO);
1569   }
1570   catch(Dali::DaliException& e)
1571   {
1572     DALI_TEST_PRINT_ASSERT(e);
1573     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1574   }
1575   END_TEST;
1576 }
1577
1578 int UtcDaliRenderTaskGetClearColorP(void)
1579 {
1580   TestApplication application;
1581
1582   tet_infoline("Testing RenderTask::GetClearColor()");
1583
1584   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1585   RenderTask     task     = taskList.GetTask(0u);
1586   DALI_TEST_EQUALS(task.GetClearColor(), RenderTask::DEFAULT_CLEAR_COLOR, TEST_LOCATION);
1587   END_TEST;
1588 }
1589
1590 int UtcDaliRenderTaskGetClearColorN(void)
1591 {
1592   TestApplication application;
1593
1594   tet_infoline("Testing RenderTask::GetClearColor()");
1595
1596   RenderTask task;
1597   try
1598   {
1599     Vector4 color = task.GetClearColor();
1600     (void)color;
1601   }
1602   catch(Dali::DaliException& e)
1603   {
1604     DALI_TEST_PRINT_ASSERT(e);
1605     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1606   }
1607   END_TEST;
1608 }
1609
1610 int UtcDaliRenderTaskSetClearEnabledP(void)
1611 {
1612   TestApplication application;
1613
1614   tet_infoline("Testing RenderTask::SetClearEnabled()");
1615
1616   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1617
1618   RenderTask task = taskList.GetTask(0u);
1619   DALI_TEST_CHECK(task.GetClearEnabled()); // defaults to true
1620
1621   task.SetClearEnabled(false);
1622   DALI_TEST_EQUALS(task.GetClearEnabled(), false, TEST_LOCATION);
1623
1624   task.SetClearEnabled(true);
1625   DALI_TEST_EQUALS(task.GetClearEnabled(), true, TEST_LOCATION);
1626   END_TEST;
1627 }
1628
1629 int UtcDaliRenderTaskSetClearEnabledN(void)
1630 {
1631   TestApplication application;
1632
1633   tet_infoline("Testing RenderTask::SetClearEnabled() with empty handle");
1634
1635   RenderTask task;
1636   try
1637   {
1638     task.SetClearEnabled(true);
1639   }
1640   catch(Dali::DaliException& e)
1641   {
1642     DALI_TEST_PRINT_ASSERT(e);
1643     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1644   }
1645   END_TEST;
1646 }
1647
1648 int UtcDaliRenderTaskGetClearEnabledP(void)
1649 {
1650   TestApplication application;
1651
1652   tet_infoline("Testing RenderTask::GetClearEnabled()");
1653
1654   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1655
1656   RenderTask task = taskList.GetTask(0u);
1657   DALI_TEST_CHECK(task.GetClearEnabled()); // defaults to true
1658   END_TEST;
1659 }
1660
1661 int UtcDaliRenderTaskGetClearEnabledN(void)
1662 {
1663   TestApplication application;
1664
1665   tet_infoline("Testing RenderTask::GetClearEnabled() with empty handle");
1666
1667   RenderTask task;
1668   try
1669   {
1670     bool x = task.GetClearEnabled();
1671     (void)x;
1672   }
1673   catch(Dali::DaliException& e)
1674   {
1675     DALI_TEST_PRINT_ASSERT(e);
1676     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1677   }
1678   END_TEST;
1679 }
1680
1681 int UtcDaliRenderTaskSetCullModeP(void)
1682 {
1683   TestApplication application;
1684
1685   tet_infoline("Testing RenderTask::SetCullMode()");
1686
1687   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1688   RenderTask     task     = taskList.GetTask(0u);
1689   DALI_TEST_EQUALS(task.GetCullMode(), true, TEST_LOCATION);
1690
1691   task.SetCullMode(false);
1692
1693   DALI_TEST_EQUALS(task.GetCullMode(), false, TEST_LOCATION);
1694
1695   END_TEST;
1696 }
1697
1698 int UtcDaliRenderTaskSetCullModeN(void)
1699 {
1700   TestApplication application;
1701
1702   tet_infoline("Testing RenderTask::SetCullMode() on empty handle");
1703
1704   RenderTask task;
1705   try
1706   {
1707     task.SetCullMode(false);
1708   }
1709   catch(Dali::DaliException& e)
1710   {
1711     DALI_TEST_PRINT_ASSERT(e);
1712     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1713   }
1714   END_TEST;
1715 }
1716
1717 int UtcDaliRenderTaskGetCullModeP(void)
1718 {
1719   TestApplication application;
1720
1721   tet_infoline("Testing RenderTask::GetCullMode()");
1722
1723   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1724   RenderTask     task     = taskList.GetTask(0u);
1725   DALI_TEST_EQUALS(task.GetCullMode(), true, TEST_LOCATION);
1726   END_TEST;
1727 }
1728
1729 int UtcDaliRenderTaskGetCullModeN(void)
1730 {
1731   TestApplication application;
1732
1733   tet_infoline("Testing RenderTask::GetCullMode() with empty handle");
1734
1735   RenderTask task;
1736   try
1737   {
1738     bool x = task.GetCullMode();
1739     (void)x;
1740   }
1741   catch(Dali::DaliException& e)
1742   {
1743     DALI_TEST_PRINT_ASSERT(e);
1744     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1745   }
1746   END_TEST;
1747 }
1748
1749 int UtcDaliRenderTaskSetRefreshRate(void)
1750 {
1751   TestApplication application;
1752
1753   tet_infoline("Testing RenderTask::SetRefreshRate()");
1754
1755   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1756
1757   // By default tasks will be processed every frame
1758   RenderTask task = taskList.GetTask(0u);
1759   DALI_TEST_CHECK(RenderTask::REFRESH_ALWAYS == task.GetRefreshRate());
1760
1761   task.SetRefreshRate(2u); // every-other frame
1762   DALI_TEST_CHECK(2u == task.GetRefreshRate());
1763
1764   task.SetRefreshRate(RenderTask::REFRESH_ALWAYS);
1765   DALI_TEST_CHECK(RenderTask::REFRESH_ALWAYS == task.GetRefreshRate());
1766   END_TEST;
1767 }
1768
1769 int UtcDaliRenderTaskGetRefreshRate(void)
1770 {
1771   TestApplication application;
1772
1773   tet_infoline("Testing RenderTask::GetRefreshRate()");
1774
1775   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1776
1777   // By default tasks will be processed every frame
1778   RenderTask task = taskList.GetTask(0u);
1779   DALI_TEST_CHECK(RenderTask::REFRESH_ALWAYS == task.GetRefreshRate());
1780
1781   RenderTask newTask = taskList.CreateTask();
1782   DALI_TEST_CHECK(RenderTask::REFRESH_ALWAYS == newTask.GetRefreshRate());
1783   END_TEST;
1784 }
1785
1786 int UtcDaliRenderTaskSignalFinished(void)
1787 {
1788   TestApplication application;
1789
1790   tet_infoline("Testing RenderTask::SignalFinished()");
1791
1792   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1793   TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
1794
1795   CameraActor offscreenCameraActor = CameraActor::New();
1796
1797   application.GetScene().Add(offscreenCameraActor);
1798
1799   Texture image     = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 10, 10);
1800   Actor   rootActor = CreateRenderableActor(image);
1801   rootActor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1802   application.GetScene().Add(rootActor);
1803
1804   RenderTaskList          taskList           = application.GetScene().GetRenderTaskList();
1805   NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
1806   Texture                 frameBufferTexture = Texture::New(*testNativeImagePtr);
1807   FrameBuffer             frameBuffer        = FrameBuffer::New(frameBufferTexture.GetWidth(), frameBufferTexture.GetHeight());
1808   frameBuffer.AttachColorTexture(frameBufferTexture);
1809
1810   RenderTask newTask = taskList.CreateTask();
1811   newTask.SetCameraActor(offscreenCameraActor);
1812   newTask.SetSourceActor(rootActor);
1813   newTask.SetInputEnabled(false);
1814   newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
1815   newTask.SetClearEnabled(true);
1816   newTask.SetExclusive(true);
1817   newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
1818   newTask.SetFrameBuffer(frameBuffer);
1819   newTask.SetProperty(RenderTask::Property::REQUIRES_SYNC, true);
1820
1821   bool               finished = false;
1822   RenderTaskFinished renderTaskFinished(finished);
1823   newTask.FinishedSignal().Connect(&application, renderTaskFinished);
1824
1825   // Flush the queue and render.
1826   application.SendNotification();
1827
1828   // 1 render to process render task, then wait for sync before finished msg is sent
1829   // from update to the event thread.
1830
1831   application.Render();
1832   application.SendNotification();
1833   DALI_TEST_CHECK(!finished);
1834
1835   Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
1836   DALI_TEST_CHECK(lastSyncObj != NULL);
1837
1838   application.Render();
1839   DALI_TEST_EQUALS((Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION);
1840   application.SendNotification();
1841   DALI_TEST_CHECK(!finished);
1842
1843   application.Render();
1844   DALI_TEST_EQUALS((Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION);
1845   application.SendNotification();
1846   DALI_TEST_CHECK(!finished);
1847
1848   sync.SetObjectSynced(lastSyncObj, true);
1849
1850   application.Render();
1851   application.SendNotification();
1852   DALI_TEST_CHECK(!finished);
1853
1854   application.Render();
1855   application.SendNotification();
1856   DALI_TEST_CHECK(finished);
1857
1858   DALI_TEST_EQUALS(application.GetUpdateStatus(), 0, TEST_LOCATION);
1859   END_TEST;
1860 }
1861
1862 int UtcDaliRenderTaskContinuous01(void)
1863 {
1864   TestApplication application;
1865
1866   tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not staged)\nPOST:continuous renders, no Finished signal");
1867
1868   // SETUP AN OFFSCREEN RENDER TASK
1869   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1870   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1871   drawTrace.Enable(true);
1872
1873   Actor rootActor = Actor::New();
1874   application.GetScene().Add(rootActor);
1875
1876   CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
1877   application.GetScene().Add(offscreenCameraActor);
1878
1879   Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
1880
1881   RenderTask         newTask  = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1882   bool               finished = false;
1883   RenderTaskFinished renderTaskFinished(finished);
1884   application.SendNotification();
1885
1886   // START PROCESS/RENDER                     Input,    Expected  Input, Expected, KeepUpdating
1887   DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, false, __LINE__));
1888   application.GetPlatform().ClearReadyResources();
1889
1890   // ADD SOURCE ACTOR TO STAGE - expect continuous renders to start, no finished signal
1891   application.GetScene().Add(secondRootActor);
1892   application.SendNotification();
1893
1894   // CONTINUE PROCESS/RENDER                  Input,    Expected  Input,    Expected
1895   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
1896   END_TEST;
1897 }
1898
1899 int UtcDaliRenderTaskContinuous02(void)
1900 {
1901   TestApplication application;
1902
1903   tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not visible)\nPOST:continuous renders, no Finished signal");
1904
1905   // SETUP AN OFFSCREEN RENDER TASK
1906   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1907   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1908   drawTrace.Enable(true);
1909
1910   Actor rootActor = Actor::New();
1911   application.GetScene().Add(rootActor);
1912
1913   CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
1914   application.GetScene().Add(offscreenCameraActor);
1915
1916   Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
1917   application.GetScene().Add(secondRootActor);
1918   secondRootActor.SetProperty(Actor::Property::VISIBLE, false);
1919
1920   RenderTask         newTask  = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1921   bool               finished = false;
1922   RenderTaskFinished renderTaskFinished(finished);
1923   newTask.FinishedSignal().Connect(&application, renderTaskFinished);
1924   application.SendNotification();
1925
1926   // START PROCESS/RENDER                    Input,    Expected  Input,    Expected, KeepUpdating
1927   DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, false, __LINE__));
1928   application.GetPlatform().ClearReadyResources();
1929
1930   // MAKE SOURCE ACTOR VISIBLE - expect continuous renders to start, no finished signal
1931   secondRootActor.SetProperty(Actor::Property::VISIBLE, true);
1932   application.SendNotification();
1933
1934   // CONTINUE PROCESS/RENDER                 Input,    Expected  Input,    Expected
1935   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
1936   END_TEST;
1937 }
1938
1939 int UtcDaliRenderTaskContinuous03(void)
1940 {
1941   TestApplication application;
1942
1943   tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (camera actor not staged)\nPOST:continuous renders, no Finished signal");
1944
1945   // SETUP AN OFFSCREEN RENDER TASK
1946   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1947   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1948   drawTrace.Enable(true);
1949
1950   Actor rootActor = Actor::New();
1951   application.GetScene().Add(rootActor);
1952
1953   CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
1954   Actor       secondRootActor      = CreateRenderableActorSuccess(application, "aFile.jpg");
1955   application.GetScene().Add(secondRootActor);
1956
1957   RenderTask         newTask  = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1958   bool               finished = false;
1959   RenderTaskFinished renderTaskFinished(finished);
1960   newTask.FinishedSignal().Connect(&application, renderTaskFinished);
1961   application.SendNotification();
1962
1963   // START PROCESS/RENDER                    Input,    Expected  Input,    Expected
1964   DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, false, __LINE__));
1965   application.GetPlatform().ClearReadyResources();
1966
1967   // ADD CAMERA ACTOR TO STAGE - expect continuous renders to start, no finished signal
1968   application.GetScene().Add(offscreenCameraActor);
1969   application.SendNotification();
1970
1971   // CONTINUE PROCESS/RENDER                 Input,    Expected  Input,    Expected
1972   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
1973   END_TEST;
1974 }
1975
1976 int UtcDaliRenderTaskContinuous04(void)
1977 {
1978   TestApplication application;
1979
1980   tet_infoline("Testing RenderTask Render Continuous using loaded image");
1981
1982   // SETUP AN OFFSCREEN RENDER TASK
1983   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1984   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1985   drawTrace.Enable(true);
1986
1987   Actor rootActor = Actor::New();
1988   application.GetScene().Add(rootActor);
1989
1990   CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
1991   application.GetScene().Add(offscreenCameraActor);
1992   Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
1993   application.GetScene().Add(secondRootActor);
1994
1995   RenderTask         newTask  = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1996   bool               finished = false;
1997   RenderTaskFinished renderTaskFinished(finished);
1998   newTask.FinishedSignal().Connect(&application, renderTaskFinished);
1999   application.SendNotification();
2000
2001   // START PROCESS/RENDER                    Input,    Expected  Input,    Expected
2002   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2003   END_TEST;
2004 }
2005
2006 int UtcDaliRenderTaskOnce01(void)
2007 {
2008   TestApplication application;
2009
2010   tet_infoline("Testing RenderTask Render Once GlSync, using loaded image");
2011
2012   // SETUP AN OFFSCREEN RENDER TASK
2013   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2014   TestGlSyncAbstraction& sync      = application.GetGlSyncAbstraction();
2015   TraceCallStack&        drawTrace = application.GetGlAbstraction().GetDrawTrace();
2016   drawTrace.Enable(true);
2017
2018   Actor rootActor = Actor::New();
2019   application.GetScene().Add(rootActor);
2020
2021   CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2022   application.GetScene().Add(offscreenCameraActor);
2023   Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2024
2025   application.GetScene().Add(secondRootActor);
2026
2027   RenderTask         newTask  = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
2028   bool               finished = false;
2029   RenderTaskFinished renderTaskFinished(finished);
2030   newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2031   application.SendNotification();
2032
2033   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2034
2035   Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2036   DALI_TEST_CHECK(lastSyncObj != NULL);
2037   sync.SetObjectSynced(lastSyncObj, true);
2038
2039   DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, true, __LINE__));
2040   DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2041   END_TEST;
2042 }
2043
2044 int UtcDaliRenderTaskOnce02(void)
2045 {
2046   TestApplication application;
2047
2048   tet_infoline("Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loaded image.\n");
2049
2050   // SETUP AN OFFSCREEN RENDER TASK
2051   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2052   TestGlSyncAbstraction& sync      = application.GetGlSyncAbstraction();
2053   TraceCallStack&        drawTrace = application.GetGlAbstraction().GetDrawTrace();
2054   drawTrace.Enable(true);
2055
2056   Actor rootActor = Actor::New();
2057   application.GetScene().Add(rootActor);
2058
2059   CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2060   application.GetScene().Add(offscreenCameraActor);
2061
2062   Shader     shader     = CreateShader();
2063   Texture    image      = CreateTexture();
2064   TextureSet textureSet = CreateTextureSet(image);
2065
2066   Geometry geometry = CreateQuadGeometry();
2067   Renderer renderer = Renderer::New(geometry, shader);
2068   renderer.SetTextures(textureSet);
2069   Actor secondRootActor = Actor::New();
2070   secondRootActor.AddRenderer(renderer);
2071   secondRootActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2072   application.GetScene().Add(secondRootActor);
2073
2074   RenderTask         newTask  = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
2075   bool               finished = false;
2076   RenderTaskFinished renderTaskFinished(finished);
2077   newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2078   application.SendNotification();
2079
2080   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2081
2082   Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2083   DALI_TEST_CHECK(lastSyncObj != NULL);
2084   sync.SetObjectSynced(lastSyncObj, true);
2085
2086   DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, true, __LINE__));
2087   DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2088
2089   END_TEST;
2090 }
2091
2092 int UtcDaliRenderTaskOnce03(void)
2093 {
2094   TestApplication application;
2095
2096   tet_infoline("Testing RenderTask Render Once GlSync, using loaded image. Switch from render always after ready to render once\n");
2097
2098   // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2099   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2100   TestGlSyncAbstraction& sync      = application.GetGlSyncAbstraction();
2101   TraceCallStack&        drawTrace = application.GetGlAbstraction().GetDrawTrace();
2102   drawTrace.Enable(true);
2103
2104   Actor rootActor = Actor::New();
2105   application.GetScene().Add(rootActor);
2106
2107   CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2108   application.GetScene().Add(offscreenCameraActor);
2109   Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2110   application.GetScene().Add(secondRootActor);
2111
2112   RenderTask         newTask  = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2113   bool               finished = false;
2114   RenderTaskFinished renderTaskFinished(finished);
2115   newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2116   application.SendNotification();
2117
2118   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2119
2120   newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2121   application.SendNotification();
2122
2123   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2124
2125   Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2126   DALI_TEST_CHECK(lastSyncObj != NULL);
2127   sync.SetObjectSynced(lastSyncObj, true);
2128
2129   DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, true, __LINE__));
2130   DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2131
2132   END_TEST;
2133 }
2134
2135 int UtcDaliRenderTaskOnce04(void)
2136 {
2137   TestApplication application;
2138   tet_infoline(
2139     "Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loaded image.\n"
2140     "Switch from render always after ready to render once\n");
2141
2142   // SETUP AN OFFSCREEN RENDER TASK
2143   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2144   TestGlSyncAbstraction& sync      = application.GetGlSyncAbstraction();
2145   TraceCallStack&        drawTrace = application.GetGlAbstraction().GetDrawTrace();
2146   drawTrace.Enable(true);
2147
2148   Actor rootActor = Actor::New();
2149   application.GetScene().Add(rootActor);
2150
2151   CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2152   application.GetScene().Add(offscreenCameraActor);
2153
2154   Shader     shader     = CreateShader();
2155   Texture    image      = CreateTexture();
2156   TextureSet textureSet = CreateTextureSet(image);
2157
2158   Geometry geometry = CreateQuadGeometry();
2159   Renderer renderer = Renderer::New(geometry, shader);
2160   renderer.SetTextures(textureSet);
2161   Actor secondRootActor = Actor::New();
2162   secondRootActor.AddRenderer(renderer);
2163   secondRootActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2164   application.GetScene().Add(secondRootActor);
2165
2166   RenderTask         newTask  = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2167   bool               finished = false;
2168   RenderTaskFinished renderTaskFinished(finished);
2169   newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2170   application.SendNotification();
2171
2172   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2173
2174   newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2175   application.SendNotification();
2176
2177   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2178
2179   Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2180   DALI_TEST_CHECK(lastSyncObj != NULL);
2181   sync.SetObjectSynced(lastSyncObj, true);
2182
2183   DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, true, __LINE__));
2184   DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2185
2186   END_TEST;
2187 }
2188
2189 int UtcDaliRenderTaskOnceNoSync01(void)
2190 {
2191   TestApplication application;
2192
2193   tet_infoline("Testing RenderTask Render Once, \nPRE: Resources ready\nPOST: Finished signal sent once only");
2194
2195   // SETUP AN OFFSCREEN RENDER TASK
2196   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2197   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2198   drawTrace.Enable(true);
2199
2200   Actor rootActor = Actor::New();
2201   application.GetScene().Add(rootActor);
2202
2203   CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2204   application.GetScene().Add(offscreenCameraActor);
2205   Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2206   application.GetScene().Add(secondRootActor);
2207
2208   RenderTask         newTask  = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2209   bool               finished = false;
2210   RenderTaskFinished renderTaskFinished(finished);
2211   newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2212   application.SendNotification();
2213
2214   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2215   DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2216   END_TEST;
2217 }
2218
2219 int UtcDaliRenderTaskOnceNoSync02(void)
2220 {
2221   TestApplication application;
2222
2223   tet_infoline(
2224     "Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loaded image.\n"
2225     "PRE: Resources ready\nPOST: Finished signal sent once only");
2226   // SETUP AN OFFSCREEN RENDER TASK
2227   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2228   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2229   drawTrace.Enable(true);
2230
2231   Actor rootActor = Actor::New();
2232   application.GetScene().Add(rootActor);
2233
2234   CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2235   application.GetScene().Add(offscreenCameraActor);
2236
2237   Shader     shader     = CreateShader();
2238   Texture    image      = CreateTexture();
2239   TextureSet textureSet = CreateTextureSet(image);
2240
2241   Geometry geometry = CreateQuadGeometry();
2242   Renderer renderer = Renderer::New(geometry, shader);
2243   renderer.SetTextures(textureSet);
2244   Actor secondRootActor = Actor::New();
2245   secondRootActor.AddRenderer(renderer);
2246   secondRootActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2247   application.GetScene().Add(secondRootActor);
2248
2249   RenderTask         newTask  = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2250   bool               finished = false;
2251   RenderTaskFinished renderTaskFinished(finished);
2252   newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2253   application.SendNotification();
2254
2255   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2256   application.GetPlatform().ClearReadyResources();
2257   DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2258
2259   END_TEST;
2260 }
2261
2262 int UtcDaliRenderTaskOnceNoSync03(void)
2263 {
2264   TestApplication application;
2265
2266   tet_infoline(
2267     "Testing RenderTask Render Once, using loaded image. Switch from render always after ready to render once\n"
2268     "PRE: Render task ready, Image loaded\n"
2269     "POST: Finished signal sent only once");
2270
2271   // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2272   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2273   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2274   drawTrace.Enable(true);
2275
2276   Actor rootActor = Actor::New();
2277   application.GetScene().Add(rootActor);
2278
2279   CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2280   application.GetScene().Add(offscreenCameraActor);
2281   Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2282   application.GetScene().Add(secondRootActor);
2283
2284   RenderTask         newTask  = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2285   bool               finished = false;
2286   RenderTaskFinished renderTaskFinished(finished);
2287   newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2288   application.SendNotification();
2289
2290   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2291
2292   newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2293   application.SendNotification(); //         Input,    Expected  Input,    Expected
2294   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2295   DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2296   END_TEST;
2297 }
2298
2299 int UtcDaliRenderTaskOnceNoSync04(void)
2300 {
2301   TestApplication application;
2302
2303   tet_infoline(
2304     "Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loading image.\n"
2305     "Switch from render always after ready to render once\n"
2306     "PRE: Render task ready, Image not loaded\n"
2307     "POST: Finished signal sent only once");
2308
2309   // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2310   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2311   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2312   drawTrace.Enable(true);
2313
2314   Actor rootActor = Actor::New();
2315   application.GetScene().Add(rootActor);
2316
2317   CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2318   application.GetScene().Add(offscreenCameraActor);
2319
2320   Shader     shader     = CreateShader();
2321   Texture    image      = CreateTexture();
2322   TextureSet textureSet = CreateTextureSet(image);
2323
2324   Geometry geometry = CreateQuadGeometry();
2325   Renderer renderer = Renderer::New(geometry, shader);
2326   renderer.SetTextures(textureSet);
2327   Actor secondRootActor = Actor::New();
2328   secondRootActor.AddRenderer(renderer);
2329   secondRootActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2330   application.GetScene().Add(secondRootActor);
2331
2332   RenderTask         newTask  = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2333   bool               finished = false;
2334   RenderTaskFinished renderTaskFinished(finished);
2335   newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2336   application.SendNotification();
2337
2338   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2339   TestGlSyncAbstraction&                      sync        = application.GetGlSyncAbstraction();
2340   Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2341   DALI_TEST_CHECK(lastSyncObj == NULL);
2342
2343   newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2344   application.SendNotification(); //         Input,    Expected  Input,    Expected
2345   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2346   DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2347
2348   lastSyncObj = sync.GetLastSyncObject();
2349   DALI_TEST_CHECK(lastSyncObj == NULL);
2350
2351   END_TEST;
2352 }
2353
2354 int UtcDaliRenderTaskOnceNoSync05(void)
2355 {
2356   TestApplication application;
2357
2358   tet_infoline(
2359     "Testing RenderTask Render Once\n"
2360     "SetRefreshRate(ONCE), resource load failed, completes render task.\n"
2361     "PRE: resources failed to load\n"
2362     "POST: No finished signal sent.");
2363
2364   // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2365   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2366   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2367   drawTrace.Enable(true);
2368
2369   Actor rootActor = Actor::New();
2370   application.GetScene().Add(rootActor);
2371
2372   CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2373   application.GetScene().Add(offscreenCameraActor);
2374   Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2375   application.GetScene().Add(secondRootActor);
2376
2377   RenderTask         newTask  = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2378   bool               finished = false;
2379   RenderTaskFinished renderTaskFinished(finished);
2380   newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2381   application.SendNotification();
2382
2383   // START PROCESS/RENDER                    Input,     Expected  Input,    Expected
2384   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2385
2386   // CHANGE TO RENDER ONCE,
2387   newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2388   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2389
2390   END_TEST;
2391 }
2392
2393 int UtcDaliRenderTaskOnceChain01(void)
2394 {
2395   TestApplication application;
2396
2397   tet_infoline(
2398     "Testing RenderTask Render Once Chained render tasks\n"
2399     "SetRefreshRate(ONCE), resource load completes, both render tasks render.\n"
2400     "PRE: resources ready\n"
2401     "POST: 2 finished signals sent.");
2402
2403   // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2404   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2405   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2406   drawTrace.Enable(true);
2407
2408   Actor defaultRootActor = Actor::New(); // Root for default RT
2409   application.GetScene().Add(defaultRootActor);
2410
2411   CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2412   application.GetScene().Add(offscreenCameraActor);
2413   Actor firstRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2414   application.GetScene().Add(firstRootActor);
2415
2416   // first render task
2417   RenderTask         firstTask     = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, firstRootActor, RenderTask::REFRESH_ONCE, false);
2418   bool               firstFinished = false;
2419   RenderTaskFinished renderTask1Finished(firstFinished);
2420   firstTask.FinishedSignal().Connect(&application, renderTask1Finished);
2421
2422   // Second render task
2423   FrameBuffer fbo             = firstTask.GetFrameBuffer();
2424   Actor       secondRootActor = CreateRenderableActor(fbo.GetColorTexture());
2425   application.GetScene().Add(secondRootActor);
2426   RenderTask         secondTask     = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2427   bool               secondFinished = false;
2428   RenderTaskFinished renderTask2Finished(secondFinished);
2429   secondTask.FinishedSignal().Connect(&application, renderTask2Finished);
2430
2431   application.SendNotification();
2432
2433   //Both render tasks are executed.
2434   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__));
2435   DALI_TEST_CHECK(firstFinished == false);
2436   DALI_TEST_CHECK(secondFinished == false);
2437
2438   //Nothing else to render and both render task should have finished now
2439   DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, firstFinished, true, false, __LINE__));
2440   DALI_TEST_CHECK(firstFinished == true);
2441   DALI_TEST_CHECK(secondFinished == true);
2442
2443   END_TEST;
2444 }
2445
2446 int UtcDaliRenderTaskProperties(void)
2447 {
2448   TestApplication application;
2449
2450   RenderTask task = application.GetScene().GetRenderTaskList().CreateTask();
2451
2452   Property::IndexContainer indices;
2453   task.GetPropertyIndices(indices);
2454   DALI_TEST_CHECK(indices.Size());
2455   DALI_TEST_EQUALS(indices.Size(), task.GetPropertyCount(), TEST_LOCATION);
2456   END_TEST;
2457 }
2458
2459 int UtcDaliRenderTaskFinishInvisibleSourceActor(void)
2460 {
2461   TestApplication application;
2462
2463   tet_infoline("Testing RenderTask::FinishInvisibleSourceActor()");
2464
2465   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2466   TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2467
2468   CameraActor offscreenCameraActor = CameraActor::New();
2469
2470   application.GetScene().Add(offscreenCameraActor);
2471
2472   Texture image     = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 10, 10);
2473   Actor   rootActor = CreateRenderableActor(image);
2474   rootActor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
2475   rootActor.SetProperty(Actor::Property::VISIBLE, false);
2476   application.GetScene().Add(rootActor);
2477
2478   RenderTaskList          taskList           = application.GetScene().GetRenderTaskList();
2479   NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
2480   Texture                 frameBufferTexture = Texture::New(*testNativeImagePtr);
2481   FrameBuffer             frameBuffer        = FrameBuffer::New(frameBufferTexture.GetWidth(), frameBufferTexture.GetHeight());
2482   frameBuffer.AttachColorTexture(frameBufferTexture);
2483
2484   // Flush all outstanding messages
2485   application.SendNotification();
2486   application.Render();
2487
2488   RenderTask newTask = taskList.CreateTask();
2489   newTask.SetCameraActor(offscreenCameraActor);
2490   newTask.SetSourceActor(rootActor);
2491   newTask.SetInputEnabled(false);
2492   newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
2493   newTask.SetClearEnabled(true);
2494   newTask.SetExclusive(true);
2495   newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2496   newTask.SetFrameBuffer(frameBuffer);
2497   newTask.SetProperty(RenderTask::Property::REQUIRES_SYNC, true);
2498
2499   // Framebuffer doesn't actually get created until Connected, i.e. by previous line
2500
2501   bool               finished = false;
2502   RenderTaskFinished renderTaskFinished(finished);
2503   newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2504
2505   // Flush the queue and render.
2506   application.SendNotification();
2507
2508   // 1 render to process render task, then wait for sync before finished msg is sent
2509   // from update to the event thread.
2510
2511   application.Render();
2512   application.SendNotification();
2513   DALI_TEST_CHECK(!finished);
2514
2515   Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2516   DALI_TEST_CHECK(lastSyncObj != NULL);
2517
2518   application.Render();
2519   DALI_TEST_EQUALS((Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION);
2520   application.SendNotification();
2521   DALI_TEST_CHECK(!finished);
2522
2523   application.Render();
2524   DALI_TEST_EQUALS((Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION);
2525   application.SendNotification();
2526   DALI_TEST_CHECK(!finished);
2527
2528   sync.SetObjectSynced(lastSyncObj, true);
2529
2530   application.Render();
2531   application.SendNotification();
2532   DALI_TEST_CHECK(!finished);
2533
2534   application.Render();
2535   application.SendNotification();
2536   DALI_TEST_CHECK(finished);
2537   finished = false;
2538
2539   application.Render(); // Double check no more finished signal
2540   application.SendNotification();
2541   DALI_TEST_CHECK(!finished);
2542
2543   END_TEST;
2544 }
2545
2546 int UtcDaliRenderTaskFinishMissingImage(void)
2547 {
2548   TestApplication application;
2549
2550   // Previously we had bugs where not having a resource ID would cause render-tasks to wait forever
2551   tet_infoline("Testing RenderTask::SignalFinished() when an Actor has no Image set");
2552
2553   Integration::Scene stage = application.GetScene();
2554
2555   Texture image     = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 10, 10);
2556   Actor   rootActor = CreateRenderableActor(image);
2557   rootActor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
2558   stage.Add(rootActor);
2559
2560   Actor actorWithMissingImage = CreateRenderableActor(Texture());
2561   actorWithMissingImage.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
2562   stage.Add(actorWithMissingImage);
2563
2564   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2565   RenderTask     newTask  = taskList.CreateTask();
2566   newTask.SetInputEnabled(false);
2567   newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
2568   newTask.SetClearEnabled(true);
2569   newTask.SetExclusive(true);
2570   newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2571
2572   bool               finished = false;
2573   RenderTaskFinished renderTaskFinished(finished);
2574   newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2575
2576   // 1 render to process render task, then 1 before finished msg is sent from update to the event thread.
2577   application.SendNotification();
2578   application.Render();
2579   application.Render();
2580
2581   application.SendNotification();
2582   DALI_TEST_CHECK(finished);
2583
2584   END_TEST;
2585 }
2586
2587 int UtcDaliRenderTaskWorldToViewport(void)
2588 {
2589   TestApplication application(400u, 400u); // square surface
2590
2591   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2592
2593   Actor actor = Actor::New();
2594   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2595   actor.SetProperty(Actor::Property::POSITION, Vector3(0.0, 0.0, 0.0));
2596
2597   actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5, 0.5, 0.5));
2598   actor.SetProperty(Actor::Property::ANCHOR_POINT, Vector3(0.5, 0.5, 0.5));
2599
2600   application.GetScene().Add(actor);
2601
2602   application.SendNotification();
2603   application.Render();
2604   application.SendNotification();
2605
2606   RenderTask task = taskList.GetTask(0u);
2607
2608   CameraActor camera = task.GetCameraActor();
2609
2610   Vector2 screenSize = task.GetCurrentViewportSize();
2611
2612   float screenX = 0.0;
2613   float screenY = 0.0;
2614
2615   bool ok = task.WorldToViewport(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), screenX, screenY);
2616   DALI_TEST_CHECK(ok == true);
2617
2618   DALI_TEST_EQUALS(screenX, screenSize.x / 2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2619   DALI_TEST_EQUALS(screenY, screenSize.y / 2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2620
2621   Actor actor2     = Actor::New();
2622   float actor2Size = 100.f;
2623   actor2.SetProperty(Actor::Property::SIZE, Vector2(actor2Size, actor2Size));
2624   actor2.SetProperty(Actor::Property::POSITION, Vector3(0.0, 0.0, 0.0));
2625   actor2.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5, 0.5, 0.0));
2626   actor2.SetProperty(Actor::Property::ANCHOR_POINT, Vector3(0.5, 0.5, 0.0));
2627   application.GetScene().Add(actor2);
2628   actor2.Add(actor);
2629   actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0, 0, 0));
2630
2631   application.SendNotification();
2632   application.Render();
2633   application.SendNotification();
2634
2635   ok = task.WorldToViewport(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), screenX, screenY);
2636   DALI_TEST_CHECK(ok == true);
2637
2638   DALI_TEST_EQUALS(screenX, screenSize.x / 2 - actor2Size / 2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2639   DALI_TEST_EQUALS(screenY, screenSize.y / 2 - actor2Size / 2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2640
2641   END_TEST;
2642 }
2643
2644 int UtcDaliRenderTaskViewportToLocal(void)
2645 {
2646   TestApplication application;
2647   Actor           actor = Actor::New();
2648   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2649   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2650   actor.SetProperty(Actor::Property::POSITION, Vector2(10.0f, 10.0f));
2651   application.GetScene().Add(actor);
2652
2653   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2654   RenderTask     task     = taskList.GetTask(0u);
2655
2656   // flush the queue and render once
2657   application.SendNotification();
2658   application.Render();
2659   application.SendNotification();
2660   application.Render();
2661
2662   float localX;
2663   float localY;
2664
2665   float rtLocalX;
2666   float rtLocalY;
2667
2668   float screenX = 50.0f;
2669   float screenY = 50.0f;
2670
2671   DALI_TEST_CHECK(actor.ScreenToLocal(localX, localY, screenX, screenY));
2672
2673   DALI_TEST_CHECK(task.ViewportToLocal(actor, screenX, screenY, rtLocalX, rtLocalY));
2674
2675   DALI_TEST_EQUALS(localX, rtLocalX, 0.01f, TEST_LOCATION);
2676   DALI_TEST_EQUALS(localY, rtLocalY, 0.01f, TEST_LOCATION);
2677
2678   END_TEST;
2679 }
2680
2681 int UtcDaliRenderTaskOffscreenViewportToLocal(void)
2682 {
2683   TestApplication application;
2684   Actor           actor = Actor::New();
2685   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2686   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2687   actor.SetProperty(Actor::Property::POSITION, Vector2(10.0f, 10.0f));
2688   application.GetScene().Add(actor);
2689
2690   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2691   RenderTask     task     = taskList.CreateTask();
2692
2693   FrameBuffer newFrameBuffer = FrameBuffer::New(10, 10);
2694   task.SetFrameBuffer(newFrameBuffer);
2695   task.SetSourceActor(actor);
2696   task.SetScreenToFrameBufferMappingActor(actor);
2697
2698   CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2699   application.GetScene().Add(offscreenCameraActor);
2700   task.SetCameraActor(offscreenCameraActor);
2701
2702   // flush the queue and render once
2703   application.SendNotification();
2704   application.Render();
2705   application.SendNotification();
2706   application.Render();
2707
2708   float localX;
2709   float localY;
2710
2711   float rtLocalX;
2712   float rtLocalY;
2713
2714   float screenX = 50.0f;
2715   float screenY = 50.0f;
2716
2717   DALI_TEST_CHECK(actor.ScreenToLocal(localX, localY, screenX, screenY));
2718
2719   DALI_TEST_CHECK(task.ViewportToLocal(actor, screenX, screenY, rtLocalX, rtLocalY));
2720
2721   DALI_TEST_EQUALS(localX, rtLocalX, 0.01f, TEST_LOCATION);
2722   DALI_TEST_EQUALS(localY, rtLocalY, 0.01f, TEST_LOCATION);
2723
2724   END_TEST;
2725 }
2726
2727 int UtcDaliRenderTaskRequiresSync(void)
2728 {
2729   TestApplication application;
2730   RenderTaskList  taskList = application.GetScene().GetRenderTaskList();
2731
2732   RenderTask newTask = taskList.CreateTask();
2733   newTask.SetProperty(RenderTask::Property::REQUIRES_SYNC, false);
2734
2735   DALI_TEST_EQUALS(newTask.GetProperty<bool>(RenderTask::Property::REQUIRES_SYNC), false, TEST_LOCATION);
2736   DALI_TEST_EQUALS(newTask.GetCurrentProperty<bool>(RenderTask::Property::REQUIRES_SYNC), false, TEST_LOCATION);
2737
2738   newTask.SetProperty(RenderTask::Property::REQUIRES_SYNC, true);
2739
2740   DALI_TEST_EQUALS(newTask.GetProperty<bool>(RenderTask::Property::REQUIRES_SYNC), true, TEST_LOCATION);
2741   DALI_TEST_EQUALS(newTask.GetCurrentProperty<bool>(RenderTask::Property::REQUIRES_SYNC), true, TEST_LOCATION);
2742
2743   END_TEST;
2744 }
2745
2746 int UtcDaliRenderTaskSetClearEnabled(void)
2747 {
2748   TestApplication application;
2749
2750   tet_infoline("UtcDaliRenderTaskSetClearEnabled");
2751
2752   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2753   TestGlAbstraction& gl = application.GetGlAbstraction();
2754
2755   Actor renderableActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2756   application.GetScene().Add(renderableActor);
2757
2758   Actor rootActor = Actor::New();
2759   application.GetScene().Add(rootActor);
2760
2761   CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2762   application.GetScene().Add(offscreenCameraActor);
2763
2764   Actor sourceActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2765   application.GetScene().Add(sourceActor);
2766
2767   RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, sourceActor, RenderTask::REFRESH_ALWAYS, false);
2768
2769   DALI_TEST_EQUALS(gl.GetClearCountCalled(), 0, TEST_LOCATION);
2770
2771   application.SendNotification();
2772   application.Render();
2773
2774   // glClear should be called twice - default task and the new task.
2775   DALI_TEST_EQUALS(gl.GetClearCountCalled(), 2, TEST_LOCATION);
2776
2777   newTask.SetClearEnabled(false);
2778
2779   application.SendNotification();
2780   application.Render();
2781
2782   // The count should increase by 1 - default task only.
2783   DALI_TEST_EQUALS(gl.GetClearCountCalled(), 3, TEST_LOCATION);
2784
2785   END_TEST;
2786 }
2787
2788 int UtcDaliRenderTaskMoveConstrctor(void)
2789 {
2790   TestApplication application;
2791
2792   Vector4 testColor(1.0f, 2.0f, 3.0f, 4.0f);
2793
2794   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2795   RenderTask     task     = taskList.GetTask(0u);
2796   DALI_TEST_CHECK(task);
2797   DALI_TEST_EQUALS(2, task.GetBaseObject().ReferenceCount(), TEST_LOCATION);
2798   DALI_TEST_CHECK(task.GetClearColor() != testColor);
2799
2800   task.SetClearColor(testColor);
2801
2802   // Wait a frame.
2803   Wait(application);
2804
2805   DALI_TEST_EQUALS(task.GetClearColor(), testColor, TEST_LOCATION);
2806
2807   RenderTask move = std::move(task);
2808   DALI_TEST_CHECK(move);
2809   DALI_TEST_EQUALS(2, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
2810   DALI_TEST_EQUALS(move.GetClearColor(), testColor, TEST_LOCATION);
2811   DALI_TEST_CHECK(!task);
2812
2813   END_TEST;
2814 }
2815
2816 int UtcDaliRenderTaskMoveAssignment(void)
2817 {
2818   TestApplication application;
2819
2820   Vector4 testColor(1.0f, 2.0f, 3.0f, 4.0f);
2821
2822   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2823   RenderTask     task     = taskList.GetTask(0u);
2824   DALI_TEST_CHECK(task);
2825   DALI_TEST_EQUALS(2, task.GetBaseObject().ReferenceCount(), TEST_LOCATION);
2826   DALI_TEST_CHECK(task.GetClearColor() != testColor);
2827
2828   task.SetClearColor(testColor);
2829
2830   // Wait a frame.
2831   Wait(application);
2832
2833   DALI_TEST_EQUALS(task.GetClearColor(), testColor, TEST_LOCATION);
2834
2835   RenderTask move;
2836   move = std::move(task);
2837   DALI_TEST_CHECK(move);
2838   DALI_TEST_EQUALS(2, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
2839   DALI_TEST_EQUALS(move.GetClearColor(), testColor, TEST_LOCATION);
2840   DALI_TEST_CHECK(!task);
2841
2842   END_TEST;
2843 }
2844
2845 int UtcDaliRenderTaskSetCullModeNegative(void)
2846 {
2847   TestApplication  application;
2848   Dali::RenderTask instance;
2849   try
2850   {
2851     bool arg1(false);
2852     instance.SetCullMode(arg1);
2853     DALI_TEST_CHECK(false); // Should not get here
2854   }
2855   catch(...)
2856   {
2857     DALI_TEST_CHECK(true); // We expect an assert
2858   }
2859   END_TEST;
2860 }
2861
2862 int UtcDaliRenderTaskSetViewportNegative(void)
2863 {
2864   TestApplication  application;
2865   Dali::RenderTask instance;
2866   try
2867   {
2868     Dali::Rect<int> arg1;
2869     instance.SetViewport(arg1);
2870     DALI_TEST_CHECK(false); // Should not get here
2871   }
2872   catch(...)
2873   {
2874     DALI_TEST_CHECK(true); // We expect an assert
2875   }
2876   END_TEST;
2877 }
2878
2879 int UtcDaliRenderTaskSetExclusiveNegative(void)
2880 {
2881   TestApplication  application;
2882   Dali::RenderTask instance;
2883   try
2884   {
2885     bool arg1(false);
2886     instance.SetExclusive(arg1);
2887     DALI_TEST_CHECK(false); // Should not get here
2888   }
2889   catch(...)
2890   {
2891     DALI_TEST_CHECK(true); // We expect an assert
2892   }
2893   END_TEST;
2894 }
2895
2896 int UtcDaliRenderTaskSetClearColorNegative(void)
2897 {
2898   TestApplication  application;
2899   Dali::RenderTask instance;
2900   try
2901   {
2902     Dali::Vector4 arg1;
2903     instance.SetClearColor(arg1);
2904     DALI_TEST_CHECK(false); // Should not get here
2905   }
2906   catch(...)
2907   {
2908     DALI_TEST_CHECK(true); // We expect an assert
2909   }
2910   END_TEST;
2911 }
2912
2913 int UtcDaliRenderTaskFinishedSignalNegative(void)
2914 {
2915   TestApplication  application;
2916   Dali::RenderTask instance;
2917   try
2918   {
2919     instance.FinishedSignal();
2920     DALI_TEST_CHECK(false); // Should not get here
2921   }
2922   catch(...)
2923   {
2924     DALI_TEST_CHECK(true); // We expect an assert
2925   }
2926   END_TEST;
2927 }
2928
2929 int UtcDaliRenderTaskSetCameraActorNegative(void)
2930 {
2931   TestApplication  application;
2932   Dali::RenderTask instance;
2933   try
2934   {
2935     Dali::CameraActor arg1;
2936     instance.SetCameraActor(arg1);
2937     DALI_TEST_CHECK(false); // Should not get here
2938   }
2939   catch(...)
2940   {
2941     DALI_TEST_CHECK(true); // We expect an assert
2942   }
2943   END_TEST;
2944 }
2945
2946 int UtcDaliRenderTaskSetFrameBufferNegative(void)
2947 {
2948   TestApplication  application;
2949   Dali::RenderTask instance;
2950   try
2951   {
2952     Dali::FrameBuffer arg1;
2953     instance.SetFrameBuffer(arg1);
2954     DALI_TEST_CHECK(false); // Should not get here
2955   }
2956   catch(...)
2957   {
2958     DALI_TEST_CHECK(true); // We expect an assert
2959   }
2960   END_TEST;
2961 }
2962
2963 int UtcDaliRenderTaskSetRefreshRateNegative(void)
2964 {
2965   TestApplication  application;
2966   Dali::RenderTask instance;
2967   try
2968   {
2969     unsigned int arg1(0u);
2970     instance.SetRefreshRate(arg1);
2971     DALI_TEST_CHECK(false); // Should not get here
2972   }
2973   catch(...)
2974   {
2975     DALI_TEST_CHECK(true); // We expect an assert
2976   }
2977   END_TEST;
2978 }
2979
2980 int UtcDaliRenderTaskSetSourceActorNegative(void)
2981 {
2982   TestApplication  application;
2983   Dali::RenderTask instance;
2984   try
2985   {
2986     Dali::Actor arg1;
2987     instance.SetSourceActor(arg1);
2988     DALI_TEST_CHECK(false); // Should not get here
2989   }
2990   catch(...)
2991   {
2992     DALI_TEST_CHECK(true); // We expect an assert
2993   }
2994   END_TEST;
2995 }
2996
2997 int UtcDaliRenderTaskSetClearEnabledNegative(void)
2998 {
2999   TestApplication  application;
3000   Dali::RenderTask instance;
3001   try
3002   {
3003     bool arg1(false);
3004     instance.SetClearEnabled(arg1);
3005     DALI_TEST_CHECK(false); // Should not get here
3006   }
3007   catch(...)
3008   {
3009     DALI_TEST_CHECK(true); // We expect an assert
3010   }
3011   END_TEST;
3012 }
3013
3014 int UtcDaliRenderTaskSetInputEnabledNegative(void)
3015 {
3016   TestApplication  application;
3017   Dali::RenderTask instance;
3018   try
3019   {
3020     bool arg1(false);
3021     instance.SetInputEnabled(arg1);
3022     DALI_TEST_CHECK(false); // Should not get here
3023   }
3024   catch(...)
3025   {
3026     DALI_TEST_CHECK(true); // We expect an assert
3027   }
3028   END_TEST;
3029 }
3030
3031 int UtcDaliRenderTaskSetViewportSizeNegative(void)
3032 {
3033   TestApplication  application;
3034   Dali::RenderTask instance;
3035   try
3036   {
3037     Dali::Vector2 arg1;
3038     instance.SetViewportSize(arg1);
3039     DALI_TEST_CHECK(false); // Should not get here
3040   }
3041   catch(...)
3042   {
3043     DALI_TEST_CHECK(true); // We expect an assert
3044   }
3045   END_TEST;
3046 }
3047
3048 int UtcDaliRenderTaskSetViewportPositionNegative(void)
3049 {
3050   TestApplication  application;
3051   Dali::RenderTask instance;
3052   try
3053   {
3054     Dali::Vector2 arg1;
3055     instance.SetViewportPosition(arg1);
3056     DALI_TEST_CHECK(false); // Should not get here
3057   }
3058   catch(...)
3059   {
3060     DALI_TEST_CHECK(true); // We expect an assert
3061   }
3062   END_TEST;
3063 }
3064
3065 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionNegative(void)
3066 {
3067   TestApplication  application;
3068   Dali::RenderTask instance;
3069   try
3070   {
3071     RenderTask::ScreenToFrameBufferFunction arg1(nullptr);
3072     instance.SetScreenToFrameBufferFunction(arg1);
3073     DALI_TEST_CHECK(false); // Should not get here
3074   }
3075   catch(...)
3076   {
3077     DALI_TEST_CHECK(true); // We expect an assert
3078   }
3079   END_TEST;
3080 }
3081
3082 int UtcDaliRenderTaskSetScreenToFrameBufferMappingActorNegative(void)
3083 {
3084   TestApplication  application;
3085   Dali::RenderTask instance;
3086   try
3087   {
3088     Dali::Actor arg1;
3089     instance.SetScreenToFrameBufferMappingActor(arg1);
3090     DALI_TEST_CHECK(false); // Should not get here
3091   }
3092   catch(...)
3093   {
3094     DALI_TEST_CHECK(true); // We expect an assert
3095   }
3096   END_TEST;
3097 }
3098
3099 int UtcDaliRenderTaskGetCullModeNegative(void)
3100 {
3101   TestApplication  application;
3102   Dali::RenderTask instance;
3103   try
3104   {
3105     instance.GetCullMode();
3106     DALI_TEST_CHECK(false); // Should not get here
3107   }
3108   catch(...)
3109   {
3110     DALI_TEST_CHECK(true); // We expect an assert
3111   }
3112   END_TEST;
3113 }
3114
3115 int UtcDaliRenderTaskGetViewportNegative(void)
3116 {
3117   TestApplication  application;
3118   Dali::RenderTask instance;
3119   try
3120   {
3121     instance.GetViewport();
3122     DALI_TEST_CHECK(false); // Should not get here
3123   }
3124   catch(...)
3125   {
3126     DALI_TEST_CHECK(true); // We expect an assert
3127   }
3128   END_TEST;
3129 }
3130
3131 int UtcDaliRenderTaskIsExclusiveNegative(void)
3132 {
3133   TestApplication  application;
3134   Dali::RenderTask instance;
3135   try
3136   {
3137     instance.IsExclusive();
3138     DALI_TEST_CHECK(false); // Should not get here
3139   }
3140   catch(...)
3141   {
3142     DALI_TEST_CHECK(true); // We expect an assert
3143   }
3144   END_TEST;
3145 }
3146
3147 int UtcDaliRenderTaskGetClearColorNegative(void)
3148 {
3149   TestApplication  application;
3150   Dali::RenderTask instance;
3151   try
3152   {
3153     instance.GetClearColor();
3154     DALI_TEST_CHECK(false); // Should not get here
3155   }
3156   catch(...)
3157   {
3158     DALI_TEST_CHECK(true); // We expect an assert
3159   }
3160   END_TEST;
3161 }
3162
3163 int UtcDaliRenderTaskGetCameraActorNegative(void)
3164 {
3165   TestApplication  application;
3166   Dali::RenderTask instance;
3167   try
3168   {
3169     instance.GetCameraActor();
3170     DALI_TEST_CHECK(false); // Should not get here
3171   }
3172   catch(...)
3173   {
3174     DALI_TEST_CHECK(true); // We expect an assert
3175   }
3176   END_TEST;
3177 }
3178
3179 int UtcDaliRenderTaskGetFrameBufferNegative(void)
3180 {
3181   TestApplication  application;
3182   Dali::RenderTask instance;
3183   try
3184   {
3185     instance.GetFrameBuffer();
3186     DALI_TEST_CHECK(false); // Should not get here
3187   }
3188   catch(...)
3189   {
3190     DALI_TEST_CHECK(true); // We expect an assert
3191   }
3192   END_TEST;
3193 }
3194
3195 int UtcDaliRenderTaskGetRefreshRateNegative(void)
3196 {
3197   TestApplication  application;
3198   Dali::RenderTask instance;
3199   try
3200   {
3201     instance.GetRefreshRate();
3202     DALI_TEST_CHECK(false); // Should not get here
3203   }
3204   catch(...)
3205   {
3206     DALI_TEST_CHECK(true); // We expect an assert
3207   }
3208   END_TEST;
3209 }
3210
3211 int UtcDaliRenderTaskGetSourceActorNegative(void)
3212 {
3213   TestApplication  application;
3214   Dali::RenderTask instance;
3215   try
3216   {
3217     instance.GetSourceActor();
3218     DALI_TEST_CHECK(false); // Should not get here
3219   }
3220   catch(...)
3221   {
3222     DALI_TEST_CHECK(true); // We expect an assert
3223   }
3224   END_TEST;
3225 }
3226
3227 int UtcDaliRenderTaskGetClearEnabledNegative(void)
3228 {
3229   TestApplication  application;
3230   Dali::RenderTask instance;
3231   try
3232   {
3233     instance.GetClearEnabled();
3234     DALI_TEST_CHECK(false); // Should not get here
3235   }
3236   catch(...)
3237   {
3238     DALI_TEST_CHECK(true); // We expect an assert
3239   }
3240   END_TEST;
3241 }
3242
3243 int UtcDaliRenderTaskGetInputEnabledNegative(void)
3244 {
3245   TestApplication  application;
3246   Dali::RenderTask instance;
3247   try
3248   {
3249     instance.GetInputEnabled();
3250     DALI_TEST_CHECK(false); // Should not get here
3251   }
3252   catch(...)
3253   {
3254     DALI_TEST_CHECK(true); // We expect an assert
3255   }
3256   END_TEST;
3257 }
3258
3259 int UtcDaliRenderTaskViewportToLocalNegative(void)
3260 {
3261   TestApplication  application;
3262   Dali::RenderTask instance;
3263   try
3264   {
3265     Dali::Actor arg1(Actor::New());
3266     float       arg2(0.0f);
3267     float       arg3(0.0f);
3268     float       arg4(0.0f);
3269     float       arg5(0.0f);
3270     instance.ViewportToLocal(arg1, arg2, arg3, arg4, arg5);
3271     DALI_TEST_CHECK(false); // Should not get here
3272   }
3273   catch(...)
3274   {
3275     DALI_TEST_CHECK(true); // We expect an assert
3276   }
3277   END_TEST;
3278 }
3279
3280 int UtcDaliRenderTaskWorldToViewportNegative(void)
3281 {
3282   TestApplication  application;
3283   Dali::RenderTask instance;
3284   try
3285   {
3286     Dali::Vector3 arg1;
3287     float         arg2(0.0f);
3288     float         arg3(0.0f);
3289     instance.WorldToViewport(arg1, arg2, arg3);
3290     DALI_TEST_CHECK(false); // Should not get here
3291   }
3292   catch(...)
3293   {
3294     DALI_TEST_CHECK(true); // We expect an assert
3295   }
3296   END_TEST;
3297 }
3298
3299 int UtcDaliRenderTaskGetCurrentViewportSizeNegative(void)
3300 {
3301   TestApplication  application;
3302   Dali::RenderTask instance;
3303   try
3304   {
3305     instance.GetCurrentViewportSize();
3306     DALI_TEST_CHECK(false); // Should not get here
3307   }
3308   catch(...)
3309   {
3310     DALI_TEST_CHECK(true); // We expect an assert
3311   }
3312   END_TEST;
3313 }
3314
3315 int UtcDaliRenderTaskGetCurrentViewportPositionNegative(void)
3316 {
3317   TestApplication  application;
3318   Dali::RenderTask instance;
3319   try
3320   {
3321     instance.GetCurrentViewportPosition();
3322     DALI_TEST_CHECK(false); // Should not get here
3323   }
3324   catch(...)
3325   {
3326     DALI_TEST_CHECK(true); // We expect an assert
3327   }
3328   END_TEST;
3329 }
3330
3331 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionNegative(void)
3332 {
3333   TestApplication  application;
3334   Dali::RenderTask instance;
3335   try
3336   {
3337     instance.GetScreenToFrameBufferFunction();
3338     DALI_TEST_CHECK(false); // Should not get here
3339   }
3340   catch(...)
3341   {
3342     DALI_TEST_CHECK(true); // We expect an assert
3343   }
3344   END_TEST;
3345 }
3346
3347 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorNegative(void)
3348 {
3349   TestApplication  application;
3350   Dali::RenderTask instance;
3351   try
3352   {
3353     instance.GetScreenToFrameBufferMappingActor();
3354     DALI_TEST_CHECK(false); // Should not get here
3355   }
3356   catch(...)
3357   {
3358     DALI_TEST_CHECK(true); // We expect an assert
3359   }
3360   END_TEST;
3361 }
3362
3363 int UtcDaliRenderTaskClippingMode01(void)
3364 {
3365   TestApplication application;
3366
3367   tet_infoline("Testing clipping mode: CLIP_TO_BOUNDING_BOX.\n");
3368
3369   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
3370   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3371   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
3372
3373   enabledDisableTrace.Enable(true);
3374   scissorTrace.Enable(true);
3375
3376   // SETUP AN OFFSCREEN RENDER TASK
3377   Actor rootActor = Actor::New();
3378   application.GetScene().Add(rootActor);
3379
3380   CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
3381   offscreenCameraActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3382   offscreenCameraActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3383   application.GetScene().Add(offscreenCameraActor);
3384
3385   Shader     shader     = CreateShader();
3386   Texture    image      = CreateTexture();
3387   TextureSet textureSet = CreateTextureSet(image);
3388
3389   Geometry geometry = CreateQuadGeometry();
3390   Renderer renderer = Renderer::New(geometry, shader);
3391   renderer.SetTextures(textureSet);
3392
3393   Vector2 position(100.0f, 100.0f);
3394   Vector2 size(200.0f, 200.0f);
3395   Actor   secondRootActor = Actor::New();
3396   secondRootActor.AddRenderer(renderer);
3397   secondRootActor.SetProperty(Actor::Property::POSITION, position);
3398   secondRootActor.SetProperty(Actor::Property::SIZE, size);
3399   secondRootActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3400   secondRootActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3401   secondRootActor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
3402   application.GetScene().Add(secondRootActor);
3403
3404   RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
3405
3406   application.SendNotification();
3407   application.Render();
3408
3409   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
3410
3411   // Check the scissor was set, and the coordinates are correct.
3412   Vector4           expectResults(position.x, TestApplication::DEFAULT_SURFACE_HEIGHT - size.height - position.y, size.width, size.height); // (100, 500, 200, 200)
3413   std::stringstream compareParametersString;
3414   compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
3415   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with the expected result
3416
3417   END_TEST;
3418 }
3419
3420 int UtcDaliRenderTaskClippingMode02(void)
3421 {
3422   TestApplication application;
3423
3424   tet_infoline("Testing clipping mode with the inverted camera: CLIP_TO_BOUNDING_BOX.\n");
3425
3426   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
3427   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3428   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
3429
3430   enabledDisableTrace.Enable(true);
3431   scissorTrace.Enable(true);
3432
3433   // SETUP AN OFFSCREEN RENDER TASK
3434   Actor rootActor = Actor::New();
3435   application.GetScene().Add(rootActor);
3436
3437   CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
3438   offscreenCameraActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3439   offscreenCameraActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3440   offscreenCameraActor.SetInvertYAxis(true);
3441   application.GetScene().Add(offscreenCameraActor);
3442
3443   Shader     shader     = CreateShader();
3444   Texture    image      = CreateTexture();
3445   TextureSet textureSet = CreateTextureSet(image);
3446
3447   Geometry geometry = CreateQuadGeometry();
3448   Renderer renderer = Renderer::New(geometry, shader);
3449   renderer.SetTextures(textureSet);
3450
3451   Vector2 position(100.0f, 100.0f);
3452   Vector2 size(200.0f, 200.0f);
3453   Actor   secondRootActor = Actor::New();
3454   secondRootActor.AddRenderer(renderer);
3455   secondRootActor.SetProperty(Actor::Property::POSITION, position);
3456   secondRootActor.SetProperty(Actor::Property::SIZE, size);
3457   secondRootActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3458   secondRootActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3459   secondRootActor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
3460   application.GetScene().Add(secondRootActor);
3461
3462   RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
3463
3464   application.SendNotification();
3465   application.Render();
3466
3467   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
3468
3469   // Check the scissor was set, and the coordinates are correct.
3470   Vector4           expectResults(position.x, position.y, size.width, size.height); // (100, 100, 200, 200)
3471   std::stringstream compareParametersString;
3472   compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
3473   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with the expected result
3474
3475   END_TEST;
3476 }