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