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