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