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