Renamed TouchSignal to TouchedSignal
[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   defaultScene.SurfaceResized( newSize.width, newSize.height );
877
878   DALI_TEST_EQUALS( stage.GetSize(), newSize, TEST_LOCATION );
879   DALI_TEST_EQUALS( defaultScene.GetSize(), newSize, TEST_LOCATION );
880
881   END_TEST;
882 }
883
884 int UtcDaliSceneSurfaceResizedDefaultSceneViewport(void)
885 {
886   tet_infoline( "Ensure resizing of the surface & viewport is handled properly" );
887
888   TestApplication application;
889   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
890   TraceCallStack& callStack = glAbstraction.GetViewportTrace();
891   glAbstraction.EnableViewportCallTrace( true );
892
893   // Initial scene setup
894   Geometry geometry = CreateQuadGeometry();
895   Shader shader = CreateShader();
896   Renderer renderer = Renderer::New( geometry, shader );
897
898   Actor actor = Actor::New();
899   actor.AddRenderer(renderer);
900   actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
901   application.GetScene().Add(actor);
902
903   // Render before resizing surface
904   application.SendNotification();
905   application.Render(0);
906   glAbstraction.ResetViewportCallStack();
907
908   auto defaultScene = application.GetScene();
909   DALI_TEST_CHECK( defaultScene );
910
911   // Ensure stage size matches the scene size
912   auto stage = Stage::GetCurrent();
913   DALI_TEST_EQUALS( stage.GetSize(), defaultScene.GetSize(), TEST_LOCATION );
914
915   // Resize the scene
916   Vector2 newSize( 1000.0f, 2000.0f );
917   std::string viewportParams( "0, 0, 1000, 2000" ); // to match newSize
918   DALI_TEST_CHECK( stage.GetSize() != newSize );
919   defaultScene.SurfaceResized( newSize.width, newSize.height );
920
921   DALI_TEST_EQUALS( stage.GetSize(), newSize, TEST_LOCATION );
922   DALI_TEST_EQUALS( defaultScene.GetSize(), newSize, TEST_LOCATION );
923
924   // Render after resizing surface
925   application.SendNotification();
926   application.Render(0);
927
928   // Check that the viewport is handled properly
929   DALI_TEST_CHECK( callStack.FindMethodAndGetParameters("Viewport", viewportParams ) );
930
931   END_TEST;
932 }
933
934 int UtcDaliSceneSurfaceResizedMultipleRenderTasks(void)
935 {
936   tet_infoline( "Ensure resizing of the surface & viewport is handled properly" );
937
938   TestApplication application;
939   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
940   TraceCallStack& callStack = glAbstraction.GetViewportTrace();
941   glAbstraction.EnableViewportCallTrace( true );
942
943   // Initial scene setup
944   auto scene = application.GetScene();
945
946   Geometry geometry = CreateQuadGeometry();
947   Shader shader = CreateShader();
948   Renderer renderer = Renderer::New( geometry, shader );
949
950   Actor actor = Actor::New();
951   actor.AddRenderer(renderer);
952   int testWidth = 400;
953   int testHeight = 400;
954   actor.SetProperty( Actor::Property::SIZE, Vector2( testWidth, testHeight) );
955   scene.Add(actor);
956
957   CameraActor offscreenCameraActor = CameraActor::New( Size( testWidth, testHeight ) );
958   application.GetScene().Add( offscreenCameraActor );
959
960   FrameBuffer newFrameBuffer = FrameBuffer::New( testWidth, testHeight, FrameBuffer::Attachment::NONE );
961
962   RenderTask newTask = scene.GetRenderTaskList().CreateTask();
963   newTask.SetCameraActor( offscreenCameraActor );
964   newTask.SetSourceActor( actor );
965   newTask.SetFrameBuffer( newFrameBuffer );
966   newTask.SetViewportPosition( Vector2(0, 0) );
967   newTask.SetViewportSize( Vector2(testWidth, testHeight) );
968
969   // Render before resizing surface
970   application.SendNotification();
971   application.Render(0);
972   glAbstraction.ResetViewportCallStack();
973
974   Rect<int32_t> initialViewport = newTask.GetViewport();
975   int initialWidth = initialViewport.width;
976   int initialHeight = initialViewport.height;
977   DALI_TEST_EQUALS( initialWidth, testWidth, TEST_LOCATION );
978   DALI_TEST_EQUALS( initialHeight, testHeight, TEST_LOCATION );
979
980   auto defaultScene = application.GetScene();
981   DALI_TEST_CHECK( defaultScene );
982
983   // Ensure stage size matches the scene size
984   auto stage = Stage::GetCurrent();
985   DALI_TEST_EQUALS( stage.GetSize(), defaultScene.GetSize(), TEST_LOCATION );
986
987   // Resize the scene
988   Vector2 newSize( 1000.0f, 2000.0f );
989   std::string viewportParams( "0, 0, 1000, 2000" ); // to match newSize
990   DALI_TEST_CHECK( stage.GetSize() != newSize );
991   defaultScene.SurfaceResized( newSize.width, newSize.height );
992
993   DALI_TEST_EQUALS( stage.GetSize(), newSize, TEST_LOCATION );
994   DALI_TEST_EQUALS( defaultScene.GetSize(), newSize, TEST_LOCATION );
995
996   // Render after resizing surface
997   application.SendNotification();
998   application.Render(0);
999
1000   // Check that the viewport is handled properly
1001   DALI_TEST_CHECK( callStack.FindMethodAndGetParameters("Viewport", viewportParams ) );
1002
1003   // Second render-task should not be affected
1004   Rect<int32_t> viewport = newTask.GetViewport();
1005   int width = viewport.width;
1006   int height = viewport.height;
1007   DALI_TEST_EQUALS( width, testWidth, TEST_LOCATION );
1008   DALI_TEST_EQUALS( height, testHeight, TEST_LOCATION );
1009
1010   END_TEST;
1011 }
1012
1013 int UtcDaliSceneSurfaceResizedAdditionalScene(void)
1014 {
1015   tet_infoline( "Ensure resizing of the surface is handled properly on additional scenes" );
1016
1017   TestApplication application;
1018   Vector2 originalSurfaceSize( 500.0f, 1000.0f );
1019
1020   auto scene = Integration::Scene::New( Size( originalSurfaceSize.width, originalSurfaceSize.height ) );
1021
1022   // Ensure stage size does NOT match the surface size
1023   auto stage = Stage::GetCurrent();
1024   const auto stageSize = stage.GetSize();
1025   DALI_TEST_CHECK( stageSize != originalSurfaceSize );
1026   DALI_TEST_EQUALS( originalSurfaceSize, scene.GetSize(), TEST_LOCATION );
1027
1028   // Resize the surface and inform the scene accordingly
1029   Vector2 newSize( 1000.0f, 2000.0f );
1030   DALI_TEST_CHECK( stage.GetSize() != newSize );
1031   scene.SurfaceResized( newSize.width, newSize.height );
1032
1033   // Ensure the stage hasn't been resized
1034   DALI_TEST_EQUALS( stage.GetSize(), stageSize, TEST_LOCATION );
1035   DALI_TEST_EQUALS( scene.GetSize(), newSize, TEST_LOCATION );
1036
1037   END_TEST;
1038 }
1039
1040 int UtcDaliSceneKeyEventGeneratedSignalP(void)
1041 {
1042   TestApplication application;
1043   Dali::Integration::Scene scene = application.GetScene();
1044
1045   KeyEventGeneratedSignalData data;
1046   KeyEventGeneratedReceivedFunctor functor( data );
1047   scene.KeyEventGeneratedSignal().Connect( &application, functor );
1048
1049   Integration::KeyEvent event( "a", "", "a", 0, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
1050   application.ProcessEvent( event );
1051
1052   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1053   DALI_TEST_CHECK( event.keyModifier == data.receivedKeyEvent.GetKeyModifier() );
1054   DALI_TEST_CHECK( event.keyName == data.receivedKeyEvent.GetKeyName() );
1055   DALI_TEST_CHECK( event.keyString == data.receivedKeyEvent.GetKeyString() );
1056   DALI_TEST_CHECK( event.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.GetState() ) );
1057
1058   data.Reset();
1059
1060   Integration::KeyEvent event2( "i", "", "i", 0, 0, 0, Integration::KeyEvent::UP, "i", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
1061   application.ProcessEvent( event2 );
1062
1063   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1064   DALI_TEST_CHECK( event2.keyModifier == data.receivedKeyEvent.GetKeyModifier() );
1065   DALI_TEST_CHECK( event2.keyName == data.receivedKeyEvent.GetKeyName() );
1066   DALI_TEST_CHECK( event2.keyString == data.receivedKeyEvent.GetKeyString() );
1067   DALI_TEST_CHECK( event2.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.GetState() ) );
1068
1069   data.Reset();
1070
1071   Integration::KeyEvent event3( "a", "", "a", 0, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
1072   application.ProcessEvent( event3 );
1073
1074   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1075   DALI_TEST_CHECK( event3.keyModifier == data.receivedKeyEvent.GetKeyModifier() );
1076   DALI_TEST_CHECK( event3.keyName == data.receivedKeyEvent.GetKeyName() );
1077   DALI_TEST_CHECK( event3.keyString == data.receivedKeyEvent.GetKeyString() );
1078   DALI_TEST_CHECK( event3.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.GetState() ) );
1079
1080   data.Reset();
1081
1082   Integration::KeyEvent event4( "a", "", "a", 0, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
1083   application.ProcessEvent( event4 );
1084
1085   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1086   DALI_TEST_CHECK( event4.keyModifier == data.receivedKeyEvent.GetKeyModifier() );
1087   DALI_TEST_CHECK( event4.keyName == data.receivedKeyEvent.GetKeyName() );
1088   DALI_TEST_CHECK( event4.keyString == data.receivedKeyEvent.GetKeyString() );
1089   DALI_TEST_CHECK( event4.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.GetState() ) );
1090   END_TEST;
1091 }
1092
1093 int UtcDaliSceneEnsureReplacedSurfaceKeepsClearColor(void)
1094 {
1095   tet_infoline( "Ensure we keep background color when the scene surface is replaced " );
1096
1097   TestApplication application;
1098
1099   // Create a new scene and set the background color of the main scene
1100   auto defaultScene = application.GetScene();
1101   defaultScene.SetBackgroundColor( Color::BLUE );
1102
1103   // Need to create a renderable as we don't start rendering until we have at least one
1104   // We don't need to add this to any scene
1105   auto actor = CreateRenderableActor();
1106
1107   auto& glAbstraction = application.GetGlAbstraction();
1108   auto clearCountBefore = glAbstraction.GetClearCountCalled();
1109
1110   application.SendNotification();
1111   application.Render();
1112
1113   DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION );
1114   DALI_TEST_EQUALS( glAbstraction.GetLastClearColor(), Color::BLUE, TEST_LOCATION );
1115
1116   defaultScene.SurfaceReplaced();
1117
1118   application.SendNotification();
1119   application.Render();
1120
1121   DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), clearCountBefore + 2, TEST_LOCATION );
1122   DALI_TEST_EQUALS( glAbstraction.GetLastClearColor(), Color::BLUE, TEST_LOCATION );
1123
1124   // Check when the main render task viewport is set the clear color is clipped using scissors
1125   TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
1126   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
1127   scissorTrace.Enable( true );
1128   enabledDisableTrace.Enable( true );
1129
1130   defaultScene.GetRenderTaskList().GetTask( 0 ).SetViewport( Viewport( 0.0f, 0.0f, 100.0f, 100.0f ) );
1131
1132   application.SendNotification();
1133   application.Render();
1134
1135   // Check scissor test was enabled.
1136   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
1137
1138   // Check the scissor was set, and the coordinates are correct.
1139   DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", "0, 700, 100, 100" ) );
1140
1141   DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), clearCountBefore + 3, TEST_LOCATION );
1142   DALI_TEST_EQUALS( glAbstraction.GetLastClearColor(), Color::BLUE, TEST_LOCATION );
1143
1144   scissorTrace.Enable( false );
1145   scissorTrace.Reset();
1146
1147   enabledDisableTrace.Enable( false );
1148   enabledDisableTrace.Reset();
1149
1150   END_TEST;
1151 }
1152
1153 int UtcDaliSceneEmptySceneRendering(void)
1154 {
1155   tet_infoline( "Ensure not rendering before a Renderer is added" );
1156
1157   TestApplication application;
1158   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
1159
1160   // Render without any renderer
1161   application.SendNotification();
1162   application.Render();
1163
1164   // Check the clear count and the render status
1165   DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), 0, TEST_LOCATION );
1166   DALI_TEST_EQUALS( application.GetRenderNeedsPostRender(), false, TEST_LOCATION );
1167
1168   // Add a Renderer
1169   Geometry geometry = CreateQuadGeometry();
1170   Shader shader = CreateShader();
1171   Renderer renderer = Renderer::New( geometry, shader );
1172
1173   Actor actor = Actor::New();
1174   actor.AddRenderer( renderer );
1175
1176   actor.SetProperty( Actor::Property::SIZE, Vector2( 400, 400 ) );
1177   application.GetScene().Add( actor );
1178
1179   // Render
1180   application.SendNotification();
1181   application.Render();
1182
1183   // Check the clear count and the render status
1184   DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), 1, TEST_LOCATION );
1185   DALI_TEST_EQUALS( application.GetRenderNeedsPostRender(), true, TEST_LOCATION );
1186
1187   // Remove the Renderer
1188   application.GetScene().Remove( actor );
1189   actor.Reset();
1190   renderer.Reset();
1191
1192   // Render
1193   application.SendNotification();
1194   application.Render();
1195
1196   // Check the clear count and the render status
1197   DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), 2, TEST_LOCATION );  // Should be cleared
1198   DALI_TEST_EQUALS( application.GetRenderNeedsPostRender(), true, TEST_LOCATION );
1199
1200   END_TEST;
1201 }
1202
1203 int UtcDaliSceneFrameRenderedPresentedCallback(void)
1204 {
1205   tet_infoline( "UtcDaliSceneFrameRenderedCallback" );
1206
1207   TestApplication application;
1208
1209   // Add a Renderer
1210   Geometry geometry = CreateQuadGeometry();
1211   Shader shader = CreateShader();
1212   Renderer renderer = Renderer::New( geometry, shader );
1213
1214   Actor actor = Actor::New();
1215   actor.AddRenderer( renderer );
1216   application.GetScene().Add( actor );
1217
1218   Dali::Integration::Scene scene = application.GetScene();
1219
1220   int frameId = 1;
1221   scene.AddFrameRenderedCallback( std::unique_ptr< CallbackBase >( MakeCallback( &FrameCallback ) ), frameId );
1222   scene.AddFramePresentedCallback( std::unique_ptr< CallbackBase >( MakeCallback( &FrameCallback ) ), frameId );
1223
1224   // Render
1225   application.SendNotification();
1226   application.Render();
1227
1228   Dali::Integration::Scene::FrameCallbackContainer callbackContainer;
1229   scene.GetFrameRenderedCallback( callbackContainer );
1230
1231   DALI_TEST_EQUALS( callbackContainer.size(), 1, TEST_LOCATION );
1232   DALI_TEST_EQUALS( callbackContainer[0].second, frameId, TEST_LOCATION );
1233
1234   callbackContainer.clear();
1235
1236   scene.GetFramePresentedCallback( callbackContainer );
1237
1238   DALI_TEST_EQUALS( callbackContainer.size(), 1, TEST_LOCATION );
1239   DALI_TEST_EQUALS( callbackContainer[0].second, frameId, TEST_LOCATION );
1240
1241   END_TEST;
1242 }