[Tizen] Add screen and client rotation itself function
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Scene.cpp
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <iostream>
19
20 #include <stdlib.h>
21 #include <dali/integration-api/scene.h>
22 #include <dali/integration-api/events/key-event-integ.h>
23 #include <dali/public-api/events/key-event.h>
24 #include <dali/devel-api/common/stage.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/integration-api/events/wheel-event-integ.h>
27
28 #include <dali-test-suite-utils.h>
29 #include <mesh-builder.h>
30
31 // Internal headers are allowed here
32
33 namespace
34 {
35
36 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
37
38 // Functor for EventProcessingFinished signal
39 struct EventProcessingFinishedFunctor
40 {
41   /**
42    * @param[in] eventProcessingFinished reference to a boolean variable used to check if signal has been called.
43    */
44   EventProcessingFinishedFunctor( bool& eventProcessingFinished )
45   : mEventProcessingFinished( eventProcessingFinished )
46   {}
47
48   void operator()()
49   {
50     mEventProcessingFinished = true;
51   }
52
53   bool& mEventProcessingFinished;
54 };
55
56 // Stores data that is populated in the key-event callback and will be read by the TET cases
57 struct KeyEventSignalData
58 {
59   KeyEventSignalData()
60   : functorCalled(false)
61   {}
62
63   void Reset()
64   {
65     functorCalled = false;
66
67     receivedKeyEvent.Reset();
68   }
69
70   bool functorCalled;
71   KeyEvent receivedKeyEvent;
72 };
73
74 // Functor that sets the data when called
75 struct KeyEventReceivedFunctor
76 {
77   KeyEventReceivedFunctor( KeyEventSignalData& data ) : signalData( data ) { }
78
79   bool operator()( const KeyEvent& keyEvent )
80   {
81     signalData.functorCalled = true;
82     signalData.receivedKeyEvent = keyEvent;
83
84     return true;
85   }
86
87   KeyEventSignalData& signalData;
88 };
89
90 // Stores data that is populated in the touched signal callback and will be read by the TET cases
91 struct TouchedSignalData
92 {
93   TouchedSignalData()
94   : functorCalled(false),
95     createNewScene(false),
96     newSceneCreated(false)
97   {}
98
99   void Reset()
100   {
101     functorCalled = false;
102     createNewScene = false;
103     newSceneCreated = false;
104     receivedTouchEvent.Reset();
105   }
106
107   bool functorCalled;
108   bool createNewScene;
109   bool newSceneCreated;
110   TouchEvent receivedTouchEvent;
111 };
112
113 // Functor that sets the data when touched signal is received
114 struct TouchFunctor
115 {
116   TouchFunctor( TouchedSignalData& data ) : signalData( data ) { }
117
118   void operator()( const TouchEvent& touch )
119   {
120     signalData.functorCalled = true;
121     signalData.receivedTouchEvent = touch;
122
123     if ( signalData.createNewScene )
124     {
125       Dali::Integration::Scene scene = Dali::Integration::Scene::New( Size( 480.0f, 800.0f  ) );
126       DALI_TEST_CHECK( scene );
127
128       signalData.newSceneCreated = true;
129     }
130   }
131
132   void operator()()
133   {
134     signalData.functorCalled = true;
135   }
136
137   TouchedSignalData& signalData;
138 };
139
140 // Stores data that is populated in the wheel-event callback and will be read by the TET cases
141 struct WheelEventSignalData
142 {
143   WheelEventSignalData()
144   : functorCalled(false)
145   {}
146
147   void Reset()
148   {
149     functorCalled = false;
150   }
151
152   bool functorCalled;
153   WheelEvent receivedWheelEvent;
154 };
155
156 // Functor that sets the data when wheel-event signal is received
157 struct WheelEventReceivedFunctor
158 {
159   WheelEventReceivedFunctor( WheelEventSignalData& data ) : signalData( data ) { }
160
161   bool operator()( const WheelEvent& wheelEvent )
162   {
163     signalData.functorCalled = true;
164     signalData.receivedWheelEvent = wheelEvent;
165
166     return true;
167   }
168
169   WheelEventSignalData& signalData;
170 };
171
172 // Stores data that is populated in the KeyEventGeneratedSignal callback and will be read by the TET cases
173 struct KeyEventGeneratedSignalData
174 {
175   KeyEventGeneratedSignalData()
176   : functorCalled(false)
177   {}
178
179   void Reset()
180   {
181     functorCalled = false;
182
183     receivedKeyEvent.Reset();
184   }
185
186   bool functorCalled;
187   KeyEvent receivedKeyEvent;
188 };
189
190 // Functor that sets the data when called
191 struct KeyEventGeneratedReceivedFunctor
192 {
193   KeyEventGeneratedReceivedFunctor( KeyEventGeneratedSignalData& data )
194   : signalData( data )
195   {}
196
197   bool operator()( const KeyEvent& keyEvent )
198   {
199     signalData.functorCalled = true;
200     signalData.receivedKeyEvent = keyEvent;
201
202     return true;
203   }
204
205   bool operator()()
206   {
207     signalData.functorCalled = true;
208     return true;
209   }
210
211   KeyEventGeneratedSignalData& signalData;
212 };
213
214 void GenerateTouch( TestApplication& application, PointState::Type state, const Vector2& screenPosition )
215 {
216   Integration::TouchEvent touchEvent;
217   Integration::Point point;
218   point.SetState( state );
219   point.SetScreenPosition( screenPosition );
220   touchEvent.points.push_back( point );
221   application.ProcessEvent( touchEvent );
222 }
223
224 bool DummyTouchCallback( Actor actor, const TouchEvent& touch )
225 {
226   return true;
227 }
228
229 void FrameCallback( int frameId )
230 {
231 }
232
233 } // unnamed namespace
234
235 int UtcDaliSceneAdd(void)
236 {
237   TestApplication application;
238   tet_infoline("Testing Dali::Integration::Scene::Add");
239
240   Dali::Integration::Scene scene = application.GetScene();
241
242   Actor actor = Actor::New();
243   DALI_TEST_CHECK( !actor.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) );
244
245   scene.Add( actor );
246   DALI_TEST_CHECK( actor.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) );
247
248   END_TEST;
249 }
250
251 int UtcDaliSceneRemove(void)
252 {
253   TestApplication application;
254   tet_infoline("Testing Dali::Integration::Scene::Remove");
255
256   Dali::Integration::Scene scene = application.GetScene();
257
258   Actor actor = Actor::New();
259   DALI_TEST_CHECK( !actor.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) );
260
261   scene.Add( actor );
262   DALI_TEST_CHECK( actor.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) );
263
264   scene.Remove(actor);
265   DALI_TEST_CHECK( !actor.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) );
266
267   END_TEST;
268 }
269
270 int UtcDaliSceneGetSize(void)
271 {
272   TestApplication application;
273   tet_infoline("Testing Dali::Integration::Scene::GetSize");
274
275   Dali::Integration::Scene scene = application.GetScene();
276   Size size = scene.GetSize();
277   DALI_TEST_EQUALS( TestApplication::DEFAULT_SURFACE_WIDTH, size.width, TEST_LOCATION );
278   DALI_TEST_EQUALS( TestApplication::DEFAULT_SURFACE_HEIGHT, size.height, TEST_LOCATION );
279
280   END_TEST;
281 }
282
283 int UtcDaliSceneGetDpi(void)
284 {
285   TestApplication application; // Initializes core DPI to default values
286
287   // Test that setting core DPI explicitly also sets up the scene's DPI.
288   Dali::Integration::Scene scene = application.GetScene();
289   scene.SetDpi( Vector2(200.0f, 180.0f) );
290   Vector2 dpi = scene.GetDpi();
291   DALI_TEST_EQUALS( dpi.x, 200.0f, TEST_LOCATION );
292   DALI_TEST_EQUALS( dpi.y, 180.0f, TEST_LOCATION );
293   END_TEST;
294 }
295
296 int UtcDaliSceneGetRenderTaskList(void)
297 {
298   TestApplication application;
299   tet_infoline("Testing Dali::Integration::Scene::GetRenderTaskList");
300
301   Dali::Integration::Scene scene = application.GetScene();
302
303   // Check we get a valid instance.
304   const RenderTaskList& tasks = scene.GetRenderTaskList();
305
306   // There should be 1 task by default.
307   DALI_TEST_EQUALS( tasks.GetTaskCount(), 1u, TEST_LOCATION );
308
309   // RenderTaskList has it's own UTC tests.
310   // But we can confirm that GetRenderTaskList in Stage retrieves the same RenderTaskList each time.
311   RenderTask newTask = scene.GetRenderTaskList().CreateTask();
312
313   DALI_TEST_EQUALS( scene.GetRenderTaskList().GetTask( 1 ), newTask, TEST_LOCATION );
314
315   END_TEST;
316 }
317
318 int UtcDaliSceneGetRootLayer(void)
319 {
320   TestApplication application;
321   tet_infoline("Testing Dali::Integration::Scene::GetRootLayer");
322
323   Dali::Integration::Scene scene = application.GetScene();
324   Layer layer = scene.GetLayer( 0 );
325   DALI_TEST_CHECK( layer );
326
327   // Check that GetRootLayer() correctly retreived layer 0.
328   DALI_TEST_CHECK( scene.GetRootLayer() == layer );
329
330   END_TEST;
331 }
332
333 int UtcDaliSceneGetLayerCount(void)
334 {
335   TestApplication application;
336   tet_infoline("Testing Dali::Integration::Scene::GetLayerCount");
337
338   Dali::Integration::Scene scene = application.GetScene();
339   // Initially we have a default layer
340   DALI_TEST_EQUALS( scene.GetLayerCount(), 1u, TEST_LOCATION );
341
342   Layer layer = Layer::New();
343   scene.Add( layer );
344
345   DALI_TEST_EQUALS( scene.GetLayerCount(), 2u, TEST_LOCATION );
346   END_TEST;
347 }
348
349 int UtcDaliSceneGetLayer(void)
350 {
351   TestApplication application;
352   tet_infoline("Testing Dali::Integration::Scene::GetLayer");
353
354   Dali::Integration::Scene scene = application.GetScene();
355
356   Layer rootLayer = scene.GetLayer( 0 );
357   DALI_TEST_CHECK( rootLayer );
358
359   Layer layer = Layer::New();
360   scene.Add( layer );
361
362   Layer sameLayer = scene.GetLayer( 1 );
363   DALI_TEST_CHECK( layer == sameLayer );
364
365   END_TEST;
366 }
367
368 int UtcDaliSceneGet(void)
369 {
370   TestApplication application;
371   tet_infoline("Testing Dali::Integration::Scene::Get");
372
373   Dali::Integration::Scene scene = application.GetScene();
374
375   Actor actor = Actor::New();
376   DALI_TEST_CHECK( Dali::Integration::Scene() == Dali::Integration::Scene::Get( actor ) );
377
378   scene.Add( actor );
379
380   DALI_TEST_CHECK( scene == Dali::Integration::Scene::Get( actor ) );
381
382   END_TEST;
383 }
384
385 int UtcDaliSceneDiscard(void)
386 {
387   TestApplication application;
388   tet_infoline("Testing Dali::Scene::Discard");
389
390   // Create a new Scene
391   Dali::Integration::Scene scene = Dali::Integration::Scene::New( Size( 480.0f, 800.0f ) );
392   DALI_TEST_CHECK( scene );
393
394   // One reference of scene kept here and the other one kept in the Core
395   DALI_TEST_CHECK( scene.GetBaseObject().ReferenceCount() == 2 );
396
397   // Render and notify.
398   application.SendNotification();
399   application.Render(0);
400
401   // Keep the reference of the root layer handle so it will still be alive after the scene is deleted
402   Layer rootLayer = scene.GetRootLayer();
403   DALI_TEST_CHECK( rootLayer );
404   DALI_TEST_CHECK( rootLayer.GetBaseObject().ReferenceCount() == 2 );
405
406   // Request to discard the scene from the Core
407   scene.Discard();
408   DALI_TEST_CHECK( scene.GetBaseObject().ReferenceCount() == 1 );
409
410   // Reset the scene handle
411   scene.Reset();
412
413   // Render and notify.
414   application.SendNotification();
415   application.Render(0);
416
417   // At this point, the scene should have been automatically deleted
418   // To prove this, the ref count of the root layer handle should be decremented to 1
419   DALI_TEST_CHECK( rootLayer.GetBaseObject().ReferenceCount() == 1 );
420
421   // Delete the root layer handle
422   rootLayer.Reset();
423
424   // Render and notify.
425   application.SendNotification();
426   application.Render(0);
427
428   END_TEST;
429 }
430
431 int UtcDaliSceneCreateNewSceneDuringCoreEventProcessing(void)
432 {
433   TestApplication application;
434
435   Dali::Integration::Scene scene = application.GetScene();
436
437   TouchedSignalData data;
438   data.createNewScene = true;
439   TouchFunctor functor( data );
440   scene.TouchedSignal().Connect( &application, functor );
441
442   // Render and notify.
443   application.SendNotification();
444   application.Render();
445
446   GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
447
448   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
449   DALI_TEST_EQUALS( true, data.createNewScene, TEST_LOCATION );
450   DALI_TEST_EQUALS( true, data.newSceneCreated, TEST_LOCATION );
451   data.Reset();
452
453   END_TEST;
454 }
455
456 int UtcDaliSceneRootLayerAndSceneAlignment(void)
457 {
458   TestApplication application;
459
460   // Create a Scene
461   Dali::Integration::Scene scene = Dali::Integration::Scene::New( Size( 480.0f, 800.0f ) );
462   DALI_TEST_CHECK( scene );
463
464   // One reference of scene kept here and the other one kept in the Core
465   DALI_TEST_CHECK( scene.GetBaseObject().ReferenceCount() == 2 );
466
467   // Add a renderable actor to the scene
468   auto actor = CreateRenderableActor();
469   scene.Add( actor );
470
471   // Render and notify.
472   application.SendNotification();
473   application.Render(0);
474
475   // Keep the reference of the root layer handle so it will still be alive after the scene is deleted
476   Layer rootLayer = scene.GetRootLayer();
477   DALI_TEST_CHECK( rootLayer );
478   DALI_TEST_CHECK( rootLayer.GetBaseObject().ReferenceCount() == 2 );
479
480   // Request to discard the scene from the Core
481   scene.Discard();
482   DALI_TEST_CHECK( scene.GetBaseObject().ReferenceCount() == 1 );
483
484   // Reset the scene handle
485   scene.Reset();
486
487   // Render and notify.
488   application.SendNotification();
489   application.Render(0);
490
491   // At this point, the scene should have been automatically deleted
492   // To prove this, the ref count of the root layer handle should be decremented to 1
493   DALI_TEST_CHECK( rootLayer.GetBaseObject().ReferenceCount() == 1 );
494
495   // Create a new Scene while the root layer of the deleted scene is still alive
496   Dali::Integration::Scene newScene = Dali::Integration::Scene::New( Size( 480.0f, 800.0f ) );
497   DALI_TEST_CHECK( newScene );
498
499   // Render and notify.
500   application.SendNotification();
501   application.Render(0);
502
503   // At this point, we have only one scene but two root layers
504   // The root layer of the deleted scene is still alive
505   DALI_TEST_CHECK( rootLayer.GetBaseObject().ReferenceCount() == 1 );
506
507   // Delete the root layer of the deleted scene
508   rootLayer.Reset();
509
510   // Render and notify.
511   application.SendNotification();
512   application.Render(0);
513
514   END_TEST;
515 }
516
517 int UtcDaliSceneEventProcessingFinishedP(void)
518 {
519   TestApplication application;
520   Dali::Integration::Scene scene = application.GetScene();
521
522   bool eventProcessingFinished = false;
523   EventProcessingFinishedFunctor functor( eventProcessingFinished );
524   scene.EventProcessingFinishedSignal().Connect( &application, functor );
525
526   Actor actor( Actor::New() );
527   scene.Add( actor );
528
529   application.SendNotification();
530   application.Render();
531
532   DALI_TEST_CHECK( eventProcessingFinished );
533
534   END_TEST;
535 }
536
537 int UtcDaliSceneEventProcessingFinishedN(void)
538 {
539   TestApplication application;
540   Dali::Integration::Scene scene = application.GetScene();
541
542   bool eventProcessingFinished = false;
543   EventProcessingFinishedFunctor functor( eventProcessingFinished );
544   scene.EventProcessingFinishedSignal().Connect( &application, functor );
545
546   Actor actor( Actor::New() );
547   scene.Add( actor );
548
549   // Do not complete event processing and confirm the signal has not been emitted.
550   DALI_TEST_CHECK( !eventProcessingFinished );
551
552   END_TEST;
553 }
554
555 int UtcDaliSceneSignalKeyEventP(void)
556 {
557   TestApplication application;
558   Dali::Integration::Scene scene = application.GetScene();
559
560   KeyEventSignalData data;
561   KeyEventReceivedFunctor functor( data );
562   scene.KeyEventSignal().Connect( &application, functor );
563
564   Integration::KeyEvent event( "i", "", "i", 0, 0, 0, Integration::KeyEvent::DOWN, "i", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
565   application.ProcessEvent( event );
566
567   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
568   DALI_TEST_CHECK( event.keyModifier == data.receivedKeyEvent.GetKeyModifier() );
569   DALI_TEST_CHECK( event.keyName == data.receivedKeyEvent.GetKeyName() );
570   DALI_TEST_CHECK( event.keyString == data.receivedKeyEvent.GetKeyString() );
571   DALI_TEST_CHECK( event.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.GetState() ) );
572
573   data.Reset();
574
575   Integration::KeyEvent event2( "i", "", "i", 0, 0, 0, Integration::KeyEvent::UP, "i", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
576   application.ProcessEvent( event2 );
577
578   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
579   DALI_TEST_CHECK( event2.keyModifier == data.receivedKeyEvent.GetKeyModifier() );
580   DALI_TEST_CHECK( event2.keyName == data.receivedKeyEvent.GetKeyName() );
581   DALI_TEST_CHECK( event2.keyString == data.receivedKeyEvent.GetKeyString() );
582   DALI_TEST_CHECK( event2.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.GetState() ) );
583
584   data.Reset();
585
586   Integration::KeyEvent event3( "a", "", "a", 0, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
587   application.ProcessEvent( event3 );
588
589   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
590   DALI_TEST_CHECK( event3.keyModifier == data.receivedKeyEvent.GetKeyModifier() );
591   DALI_TEST_CHECK( event3.keyName == data.receivedKeyEvent.GetKeyName() );
592   DALI_TEST_CHECK( event3.keyString == data.receivedKeyEvent.GetKeyString() );
593   DALI_TEST_CHECK( event3.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.GetState() ) );
594
595   data.Reset();
596
597   Integration::KeyEvent event4( "a", "", "a", 0, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
598   application.ProcessEvent( event4 );
599
600   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
601   DALI_TEST_CHECK( event4.keyModifier == data.receivedKeyEvent.GetKeyModifier() );
602   DALI_TEST_CHECK( event4.keyName == data.receivedKeyEvent.GetKeyName() );
603   DALI_TEST_CHECK( event4.keyString == data.receivedKeyEvent.GetKeyString() );
604   DALI_TEST_CHECK( event4.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.GetState() ) );
605   END_TEST;
606 }
607
608 int UtcDaliSceneSignalKeyEventN(void)
609 {
610   TestApplication application;
611   Dali::Integration::Scene scene = application.GetScene();
612
613   KeyEventSignalData data;
614   KeyEventReceivedFunctor functor( data );
615   scene.KeyEventSignal().Connect( &application, functor );
616
617   // Check that a non-pressed key events data is not modified.
618   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
619
620   END_TEST;
621 }
622
623 int UtcDaliSceneTouchedSignalP(void)
624 {
625   TestApplication application;
626   Dali::Integration::Scene scene = application.GetScene();
627
628   TouchedSignalData data;
629   TouchFunctor functor( data );
630   scene.TouchedSignal().Connect( &application, functor );
631
632   // Render and notify.
633   application.SendNotification();
634   application.Render();
635
636   // Basic test: No actors, single touch (down then up).
637   {
638     GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
639
640     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
641     DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
642     DALI_TEST_CHECK( !data.receivedTouchEvent.GetHitActor(0) );
643     data.Reset();
644
645     GenerateTouch( application, PointState::UP, Vector2( 10.0f, 10.0f ) );
646
647     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
648     DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
649     DALI_TEST_CHECK( !data.receivedTouchEvent.GetHitActor(0) );
650     data.Reset();
651   }
652
653   // Add an actor to the scene.
654   Actor actor = Actor::New();
655   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
656   actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
657   actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
658   actor.TouchedSignal().Connect( &DummyTouchCallback );
659   scene.Add( actor );
660
661   // Render and notify.
662   application.SendNotification();
663   application.Render();
664
665   // Actor on scene, single touch, down in actor, motion, then up outside actor.
666   {
667     GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
668
669     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
670     DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
671     DALI_TEST_CHECK( data.receivedTouchEvent.GetHitActor(0) == actor );
672     data.Reset();
673
674     GenerateTouch( application, PointState::MOTION, Vector2( 150.0f, 10.0f ) ); // Some motion
675
676     DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
677     data.Reset();
678
679     GenerateTouch( application, PointState::UP, Vector2( 150.0f, 10.0f ) ); // Some motion
680
681     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
682     DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
683     DALI_TEST_CHECK( !data.receivedTouchEvent.GetHitActor(0) );
684     data.Reset();
685   }
686
687   // Multiple touch. Should only receive a touch on first down and last up.
688   {
689     Integration::TouchEvent touchEvent;
690     Integration::Point point;
691
692     // 1st point
693     point.SetState( PointState::DOWN );
694     point.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
695     touchEvent.points.push_back( point );
696     application.ProcessEvent( touchEvent );
697     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
698     DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 1u, TEST_LOCATION );
699     data.Reset();
700
701     // 2nd point
702     touchEvent.points[0].SetState( PointState::STATIONARY );
703     point.SetDeviceId( 1 );
704     point.SetScreenPosition( Vector2( 50.0f, 50.0f ) );
705     touchEvent.points.push_back( point );
706     application.ProcessEvent( touchEvent );
707     DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
708     data.Reset();
709
710     // Primary point is up
711     touchEvent.points[0].SetState( PointState::UP );
712     touchEvent.points[1].SetState( PointState::STATIONARY );
713     application.ProcessEvent( touchEvent );
714     DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
715     data.Reset();
716
717     // Remove 1st point now, 2nd point is now in motion
718     touchEvent.points.erase( touchEvent.points.begin() );
719     touchEvent.points[0].SetState( PointState::MOTION );
720     touchEvent.points[0].SetScreenPosition( Vector2( 150.0f, 50.0f ) );
721     application.ProcessEvent( touchEvent );
722     DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
723     data.Reset();
724
725     // Final point Up
726     touchEvent.points[0].SetState( PointState::UP );
727     application.ProcessEvent( touchEvent );
728     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
729     DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 1u, TEST_LOCATION );
730     data.Reset();
731   }
732   END_TEST;
733 }
734
735 int UtcDaliSceneTouchedSignalN(void)
736 {
737   TestApplication application;
738   Dali::Integration::Scene scene = application.GetScene();
739
740   TouchedSignalData data;
741   TouchFunctor functor( data );
742   scene.TouchedSignal().Connect( &application, functor );
743
744   // Render and notify.
745   application.SendNotification();
746   application.Render();
747
748   // Confirm functor not called before there has been any touch event.
749   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
750
751   // No actors, single touch, down, motion then up.
752   {
753     GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
754
755     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
756     DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
757     DALI_TEST_CHECK( !data.receivedTouchEvent.GetHitActor(0));
758
759     data.Reset();
760
761     // Confirm there is no signal when the touchpoint is only moved.
762     GenerateTouch( application, PointState::MOTION, Vector2( 1200.0f, 10.0f ) ); // Some motion
763
764     DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
765     data.Reset();
766
767     // Confirm a following up event generates a signal.
768     GenerateTouch( application, PointState::UP, Vector2( 1200.0f, 10.0f ) );
769
770     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
771     DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
772     DALI_TEST_CHECK( !data.receivedTouchEvent.GetHitActor(0));
773     data.Reset();
774   }
775
776   // Add an actor to the scene.
777   Actor actor = Actor::New();
778   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
779   actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
780   actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
781   actor.TouchedSignal().Connect( &DummyTouchCallback );
782   scene.Add( actor );
783
784   // Render and notify.
785   application.SendNotification();
786   application.Render();
787
788   // Actor on scene. Interrupted before down and interrupted after down.
789   {
790     GenerateTouch( application, PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) );
791
792     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
793     DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
794     DALI_TEST_CHECK( !data.receivedTouchEvent.GetHitActor(0) );
795     DALI_TEST_CHECK( data.receivedTouchEvent.GetState(0) == PointState::INTERRUPTED );
796     data.Reset();
797
798     GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
799
800     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
801     DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
802     DALI_TEST_CHECK( data.receivedTouchEvent.GetHitActor(0) == actor );
803     DALI_TEST_CHECK( data.receivedTouchEvent.GetState(0) == PointState::DOWN );
804     data.Reset();
805
806     GenerateTouch( application, PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) );
807
808     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
809     DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
810     DALI_TEST_CHECK( !data.receivedTouchEvent.GetHitActor(0) );
811     DALI_TEST_CHECK( data.receivedTouchEvent.GetState(0) == PointState::INTERRUPTED );
812
813     DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 1u, TEST_LOCATION );
814
815     // Check that getting info about a non-existent point returns an empty handle
816     Actor actor = data.receivedTouchEvent.GetHitActor( 1 );
817     DALI_TEST_CHECK( !actor );
818
819     data.Reset();
820   }
821
822   END_TEST;
823 }
824
825 int UtcDaliSceneSignalWheelEventP(void)
826 {
827   TestApplication application;
828   Dali::Integration::Scene scene = application.GetScene();
829
830   WheelEventSignalData data;
831   WheelEventReceivedFunctor functor( data );
832   scene.WheelEventSignal().Connect( &application, functor );
833
834   Integration::WheelEvent event( Integration::WheelEvent::CUSTOM_WHEEL, 0, 0u, Vector2( 0.0f, 0.0f ), 1, 1000u );
835   application.ProcessEvent( event );
836
837   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
838   DALI_TEST_CHECK( static_cast< WheelEvent::Type >(event.type) == data.receivedWheelEvent.GetType() );
839   DALI_TEST_CHECK( event.direction == data.receivedWheelEvent.GetDirection() );
840   DALI_TEST_CHECK( event.modifiers == data.receivedWheelEvent.GetModifiers() );
841   DALI_TEST_CHECK( event.point == data.receivedWheelEvent.GetPoint() );
842   DALI_TEST_CHECK( event.delta == data.receivedWheelEvent.GetDelta() );
843   DALI_TEST_CHECK( event.timeStamp == data.receivedWheelEvent.GetTime() );
844
845   data.Reset();
846
847   Integration::WheelEvent event2( Integration::WheelEvent::CUSTOM_WHEEL, 0, 0u, Vector2( 0.0f, 0.0f ), -1, 1000u );
848   application.ProcessEvent( event2 );
849
850   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
851   DALI_TEST_CHECK( static_cast< WheelEvent::Type >(event2.type) == data.receivedWheelEvent.GetType() );
852   DALI_TEST_CHECK( event2.direction == data.receivedWheelEvent.GetDirection() );
853   DALI_TEST_CHECK( event2.modifiers == data.receivedWheelEvent.GetModifiers() );
854   DALI_TEST_CHECK( event2.point == data.receivedWheelEvent.GetPoint() );
855   DALI_TEST_CHECK( event2.delta == data.receivedWheelEvent.GetDelta() );
856   DALI_TEST_CHECK( event2.timeStamp == data.receivedWheelEvent.GetTime() );
857   END_TEST;
858 }
859
860 int UtcDaliSceneSurfaceResizedDefaultScene(void)
861 {
862   tet_infoline( "Ensure resizing of the surface is handled properly" );
863
864   TestApplication application;
865
866   auto defaultScene = application.GetScene();
867   DALI_TEST_CHECK( defaultScene );
868
869   // Ensure stage size matches the scene size
870   auto stage = Stage::GetCurrent();
871   DALI_TEST_EQUALS( stage.GetSize(), defaultScene.GetSize(), TEST_LOCATION );
872
873   // Resize the scene
874   Vector2 newSize( 1000.0f, 2000.0f );
875   DALI_TEST_CHECK( stage.GetSize() != newSize );
876
877   defaultScene.SurfaceResized( newSize.width, newSize.height, 0, false );
878
879   DALI_TEST_EQUALS( stage.GetSize(), newSize, TEST_LOCATION );
880   DALI_TEST_EQUALS( defaultScene.GetSize(), newSize, TEST_LOCATION );
881
882   END_TEST;
883 }
884
885 int UtcDaliSceneSurfaceResizedDefaultSceneViewport(void)
886 {
887   tet_infoline( "Ensure resizing of the surface & viewport is handled properly" );
888
889   TestApplication application;
890   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
891   TraceCallStack& callStack = glAbstraction.GetViewportTrace();
892   glAbstraction.EnableViewportCallTrace( true );
893
894   // Initial scene setup
895   Geometry geometry = CreateQuadGeometry();
896   Shader shader = CreateShader();
897   Renderer renderer = Renderer::New( geometry, shader );
898
899   Actor actor = Actor::New();
900   actor.AddRenderer(renderer);
901   actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
902   application.GetScene().Add(actor);
903
904   // Render before resizing surface
905   application.SendNotification();
906   application.Render(0);
907   glAbstraction.ResetViewportCallStack();
908
909   auto defaultScene = application.GetScene();
910   DALI_TEST_CHECK( defaultScene );
911
912   // Ensure stage size matches the scene size
913   auto stage = Stage::GetCurrent();
914   DALI_TEST_EQUALS( stage.GetSize(), defaultScene.GetSize(), TEST_LOCATION );
915
916   // Resize the scene
917   Vector2 newSize( 1000.0f, 2000.0f );
918   std::string viewportParams( "0, 0, 1000, 2000" ); // to match newSize
919   DALI_TEST_CHECK( stage.GetSize() != newSize );
920   defaultScene.SurfaceResized( newSize.width, newSize.height, 0, false );
921
922   DALI_TEST_EQUALS( stage.GetSize(), newSize, TEST_LOCATION );
923   DALI_TEST_EQUALS( defaultScene.GetSize(), newSize, TEST_LOCATION );
924
925   // Render after resizing surface
926   application.SendNotification();
927   application.Render(0);
928
929   // Check that the viewport is handled properly
930   DALI_TEST_CHECK( callStack.FindMethodAndGetParameters("Viewport", viewportParams ) );
931
932   END_TEST;
933 }
934
935 int UtcDaliSceneSurfaceResizedMultipleRenderTasks(void)
936 {
937   tet_infoline( "Ensure resizing of the surface & viewport is handled properly" );
938
939   TestApplication application;
940   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
941   TraceCallStack& callStack = glAbstraction.GetViewportTrace();
942   glAbstraction.EnableViewportCallTrace( true );
943
944   // Initial scene setup
945   auto scene = application.GetScene();
946
947   Geometry geometry = CreateQuadGeometry();
948   Shader shader = CreateShader();
949   Renderer renderer = Renderer::New( geometry, shader );
950
951   Actor actor = Actor::New();
952   actor.AddRenderer(renderer);
953   int testWidth = 400;
954   int testHeight = 400;
955   actor.SetProperty( Actor::Property::SIZE, Vector2( testWidth, testHeight) );
956   scene.Add(actor);
957
958   CameraActor offscreenCameraActor = CameraActor::New( Size( testWidth, testHeight ) );
959   application.GetScene().Add( offscreenCameraActor );
960
961   FrameBuffer newFrameBuffer = FrameBuffer::New( testWidth, testHeight, FrameBuffer::Attachment::NONE );
962
963   RenderTask newTask = scene.GetRenderTaskList().CreateTask();
964   newTask.SetCameraActor( offscreenCameraActor );
965   newTask.SetSourceActor( actor );
966   newTask.SetFrameBuffer( newFrameBuffer );
967   newTask.SetViewportPosition( Vector2(0, 0) );
968   newTask.SetViewportSize( Vector2(testWidth, testHeight) );
969
970   // Render before resizing surface
971   application.SendNotification();
972   application.Render(0);
973   glAbstraction.ResetViewportCallStack();
974
975   Rect<int32_t> initialViewport = newTask.GetViewport();
976   int initialWidth = initialViewport.width;
977   int initialHeight = initialViewport.height;
978   DALI_TEST_EQUALS( initialWidth, testWidth, TEST_LOCATION );
979   DALI_TEST_EQUALS( initialHeight, testHeight, TEST_LOCATION );
980
981   auto defaultScene = application.GetScene();
982   DALI_TEST_CHECK( defaultScene );
983
984   // Ensure stage size matches the scene size
985   auto stage = Stage::GetCurrent();
986   DALI_TEST_EQUALS( stage.GetSize(), defaultScene.GetSize(), TEST_LOCATION );
987
988   // Resize the scene
989   Vector2 newSize( 1000.0f, 2000.0f );
990   std::string viewportParams( "0, 0, 1000, 2000" ); // to match newSize
991   DALI_TEST_CHECK( stage.GetSize() != newSize );
992   defaultScene.SurfaceResized( newSize.width, newSize.height, 0, false );
993
994   DALI_TEST_EQUALS( stage.GetSize(), newSize, TEST_LOCATION );
995   DALI_TEST_EQUALS( defaultScene.GetSize(), newSize, TEST_LOCATION );
996
997   // Render after resizing surface
998   application.SendNotification();
999   application.Render(0);
1000
1001   // Check that the viewport is handled properly
1002   DALI_TEST_CHECK( callStack.FindMethodAndGetParameters("Viewport", viewportParams ) );
1003
1004   // Second render-task should not be affected
1005   Rect<int32_t> viewport = newTask.GetViewport();
1006   int width = viewport.width;
1007   int height = viewport.height;
1008   DALI_TEST_EQUALS( width, testWidth, TEST_LOCATION );
1009   DALI_TEST_EQUALS( height, testHeight, TEST_LOCATION );
1010
1011   END_TEST;
1012 }
1013
1014 int UtcDaliSceneSurfaceResizedAdditionalScene(void)
1015 {
1016   tet_infoline( "Ensure resizing of the surface is handled properly on additional scenes" );
1017
1018   TestApplication application;
1019   Vector2 originalSurfaceSize( 500.0f, 1000.0f );
1020
1021   auto scene = Integration::Scene::New( Size( originalSurfaceSize.width, originalSurfaceSize.height ) );
1022
1023   // Ensure stage size does NOT match the surface size
1024   auto stage = Stage::GetCurrent();
1025   const auto stageSize = stage.GetSize();
1026   DALI_TEST_CHECK( stageSize != originalSurfaceSize );
1027   DALI_TEST_EQUALS( originalSurfaceSize, scene.GetSize(), TEST_LOCATION );
1028
1029   // Resize the surface and inform the scene accordingly
1030   Vector2 newSize( 1000.0f, 2000.0f );
1031   DALI_TEST_CHECK( stage.GetSize() != newSize );
1032
1033   scene.SurfaceResized( newSize.width, newSize.height, 0, false );
1034
1035   // Ensure the stage hasn't been resized
1036   DALI_TEST_EQUALS( stage.GetSize(), stageSize, TEST_LOCATION );
1037   DALI_TEST_EQUALS( scene.GetSize(), newSize, TEST_LOCATION );
1038
1039   END_TEST;
1040 }
1041
1042 int UtcDaliSceneKeyEventGeneratedSignalP(void)
1043 {
1044   TestApplication application;
1045   Dali::Integration::Scene scene = application.GetScene();
1046
1047   KeyEventGeneratedSignalData data;
1048   KeyEventGeneratedReceivedFunctor functor( data );
1049   scene.KeyEventGeneratedSignal().Connect( &application, functor );
1050
1051   Integration::KeyEvent event( "a", "", "a", 0, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
1052   application.ProcessEvent( event );
1053
1054   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1055   DALI_TEST_CHECK( event.keyModifier == data.receivedKeyEvent.GetKeyModifier() );
1056   DALI_TEST_CHECK( event.keyName == data.receivedKeyEvent.GetKeyName() );
1057   DALI_TEST_CHECK( event.keyString == data.receivedKeyEvent.GetKeyString() );
1058   DALI_TEST_CHECK( event.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.GetState() ) );
1059
1060   data.Reset();
1061
1062   Integration::KeyEvent event2( "i", "", "i", 0, 0, 0, Integration::KeyEvent::UP, "i", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
1063   application.ProcessEvent( event2 );
1064
1065   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1066   DALI_TEST_CHECK( event2.keyModifier == data.receivedKeyEvent.GetKeyModifier() );
1067   DALI_TEST_CHECK( event2.keyName == data.receivedKeyEvent.GetKeyName() );
1068   DALI_TEST_CHECK( event2.keyString == data.receivedKeyEvent.GetKeyString() );
1069   DALI_TEST_CHECK( event2.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.GetState() ) );
1070
1071   data.Reset();
1072
1073   Integration::KeyEvent event3( "a", "", "a", 0, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
1074   application.ProcessEvent( event3 );
1075
1076   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1077   DALI_TEST_CHECK( event3.keyModifier == data.receivedKeyEvent.GetKeyModifier() );
1078   DALI_TEST_CHECK( event3.keyName == data.receivedKeyEvent.GetKeyName() );
1079   DALI_TEST_CHECK( event3.keyString == data.receivedKeyEvent.GetKeyString() );
1080   DALI_TEST_CHECK( event3.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.GetState() ) );
1081
1082   data.Reset();
1083
1084   Integration::KeyEvent event4( "a", "", "a", 0, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
1085   application.ProcessEvent( event4 );
1086
1087   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1088   DALI_TEST_CHECK( event4.keyModifier == data.receivedKeyEvent.GetKeyModifier() );
1089   DALI_TEST_CHECK( event4.keyName == data.receivedKeyEvent.GetKeyName() );
1090   DALI_TEST_CHECK( event4.keyString == data.receivedKeyEvent.GetKeyString() );
1091   DALI_TEST_CHECK( event4.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.GetState() ) );
1092   END_TEST;
1093 }
1094
1095 int UtcDaliSceneEnsureReplacedSurfaceKeepsClearColor(void)
1096 {
1097   tet_infoline( "Ensure we keep background color when the scene surface is replaced " );
1098
1099   TestApplication application;
1100
1101   // Create a new scene and set the background color of the main scene
1102   auto defaultScene = application.GetScene();
1103   defaultScene.SetBackgroundColor( Color::BLUE );
1104
1105   // Need to create a renderable as we don't start rendering until we have at least one
1106   // We don't need to add this to any scene
1107   auto actor = CreateRenderableActor();
1108
1109   auto& glAbstraction = application.GetGlAbstraction();
1110   auto clearCountBefore = glAbstraction.GetClearCountCalled();
1111
1112   application.SendNotification();
1113   application.Render();
1114
1115   DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION );
1116   DALI_TEST_EQUALS( glAbstraction.GetLastClearColor(), Color::BLUE, TEST_LOCATION );
1117
1118   defaultScene.SurfaceReplaced();
1119
1120   application.SendNotification();
1121   application.Render();
1122
1123   DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), clearCountBefore + 2, TEST_LOCATION );
1124   DALI_TEST_EQUALS( glAbstraction.GetLastClearColor(), Color::BLUE, TEST_LOCATION );
1125
1126   // Check when the main render task viewport is set the clear color is clipped using scissors
1127   TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
1128   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
1129   scissorTrace.Enable( true );
1130   enabledDisableTrace.Enable( true );
1131
1132   defaultScene.GetRenderTaskList().GetTask( 0 ).SetViewport( Viewport( 0.0f, 0.0f, 100.0f, 100.0f ) );
1133
1134   application.SendNotification();
1135   application.Render();
1136
1137   // Check scissor test was enabled.
1138   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
1139
1140   // Check the scissor was set, and the coordinates are correct.
1141   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", "0, 700, 100, 100" ) );
1142
1143   DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), clearCountBefore + 3, TEST_LOCATION );
1144   DALI_TEST_EQUALS( glAbstraction.GetLastClearColor(), Color::BLUE, TEST_LOCATION );
1145
1146   scissorTrace.Enable( false );
1147   scissorTrace.Reset();
1148
1149   enabledDisableTrace.Enable( false );
1150   enabledDisableTrace.Reset();
1151
1152   END_TEST;
1153 }
1154
1155 int UtcDaliSceneEmptySceneRendering(void)
1156 {
1157   tet_infoline( "Ensure not rendering before a Renderer is added" );
1158
1159   TestApplication application;
1160   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
1161
1162   // Render without any renderer
1163   application.SendNotification();
1164   application.Render();
1165
1166   // Check the clear count and the render status
1167   DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), 0, TEST_LOCATION );
1168   DALI_TEST_EQUALS( application.GetRenderNeedsPostRender(), false, TEST_LOCATION );
1169
1170   // Add a Renderer
1171   Geometry geometry = CreateQuadGeometry();
1172   Shader shader = CreateShader();
1173   Renderer renderer = Renderer::New( geometry, shader );
1174
1175   Actor actor = Actor::New();
1176   actor.AddRenderer( renderer );
1177
1178   actor.SetProperty( Actor::Property::SIZE, Vector2( 400, 400 ) );
1179   application.GetScene().Add( actor );
1180
1181   // Render
1182   application.SendNotification();
1183   application.Render();
1184
1185   // Check the clear count and the render status
1186   DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), 1, TEST_LOCATION );
1187   DALI_TEST_EQUALS( application.GetRenderNeedsPostRender(), true, TEST_LOCATION );
1188
1189   // Remove the Renderer
1190   application.GetScene().Remove( actor );
1191   actor.Reset();
1192   renderer.Reset();
1193
1194   // Render
1195   application.SendNotification();
1196   application.Render();
1197
1198   // Check the clear count and the render status
1199   DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), 2, TEST_LOCATION );  // Should be cleared
1200   DALI_TEST_EQUALS( application.GetRenderNeedsPostRender(), true, TEST_LOCATION );
1201
1202   END_TEST;
1203 }
1204
1205 int UtcDaliSceneFrameRenderedPresentedCallback(void)
1206 {
1207   tet_infoline( "UtcDaliSceneFrameRenderedCallback" );
1208
1209   TestApplication application;
1210
1211   // Add a Renderer
1212   Geometry geometry = CreateQuadGeometry();
1213   Shader shader = CreateShader();
1214   Renderer renderer = Renderer::New( geometry, shader );
1215
1216   Actor actor = Actor::New();
1217   actor.AddRenderer( renderer );
1218   application.GetScene().Add( actor );
1219
1220   Dali::Integration::Scene scene = application.GetScene();
1221
1222   int frameId = 1;
1223   scene.AddFrameRenderedCallback( std::unique_ptr< CallbackBase >( MakeCallback( &FrameCallback ) ), frameId );
1224   scene.AddFramePresentedCallback( std::unique_ptr< CallbackBase >( MakeCallback( &FrameCallback ) ), frameId );
1225
1226   // Render
1227   application.SendNotification();
1228   application.Render();
1229
1230   Dali::Integration::Scene::FrameCallbackContainer callbackContainer;
1231   scene.GetFrameRenderedCallback( callbackContainer );
1232
1233   DALI_TEST_EQUALS( callbackContainer.size(), 1, TEST_LOCATION );
1234   DALI_TEST_EQUALS( callbackContainer[0].second, frameId, TEST_LOCATION );
1235
1236   callbackContainer.clear();
1237
1238   scene.GetFramePresentedCallback( callbackContainer );
1239
1240   DALI_TEST_EQUALS( callbackContainer.size(), 1, TEST_LOCATION );
1241   DALI_TEST_EQUALS( callbackContainer[0].second, frameId, TEST_LOCATION );
1242
1243   END_TEST;
1244 }