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