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