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