Merge branch 'devel/master (1.2.0)' into tizen
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Stage.cpp
1 /*
2  * Copyright (c) 2014 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
22 #include <dali/public-api/dali-core.h>
23 #include <dali/integration-api/context-notifier.h>
24 #include <dali/integration-api/events/key-event-integ.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
30 using namespace Dali;
31
32 void stage_test_startup(void)
33 {
34   test_return_value = TET_UNDEF;
35 }
36
37 void stage_test_cleanup(void)
38 {
39   test_return_value = TET_PASS;
40 }
41
42 namespace
43 {
44
45 // Functor for EventProcessingFinished signal
46 struct EventProcessingFinishedFunctor
47 {
48   /**
49    * @param[in] eventProcessingFinished reference to a boolean variable used to check if signal has been called.
50    */
51   EventProcessingFinishedFunctor( bool& eventProcessingFinished )
52   : mEventProcessingFinished( eventProcessingFinished )
53   {}
54
55   void operator()()
56   {
57     mEventProcessingFinished = true;
58   }
59
60   bool& mEventProcessingFinished;
61 };
62
63 // Stores data that is populated in the key-event callback and will be read by the TET cases
64 struct KeyEventSignalData
65 {
66   KeyEventSignalData()
67   : functorCalled(false)
68   {}
69
70   void Reset()
71   {
72     functorCalled = false;
73
74     receivedKeyEvent.keyModifier = 0;
75     receivedKeyEvent.keyPressedName.clear();
76     receivedKeyEvent.keyPressed.clear();
77   }
78
79   bool functorCalled;
80   KeyEvent receivedKeyEvent;
81 };
82
83 // Functor that sets the data when called
84 struct KeyEventReceivedFunctor
85 {
86   KeyEventReceivedFunctor( KeyEventSignalData& data ) : signalData( data ) { }
87
88   bool operator()( const KeyEvent& keyEvent )
89   {
90     signalData.functorCalled = true;
91     signalData.receivedKeyEvent = keyEvent;
92
93     return true;
94   }
95
96   KeyEventSignalData& signalData;
97 };
98
99 // Stores data that is populated in the touched signal callback and will be read by the TET cases
100 struct TouchedSignalData
101 {
102   TouchedSignalData()
103   : functorCalled(false)
104   {}
105
106   void Reset()
107   {
108     functorCalled = false;
109
110     receivedTouchEvent.points.clear();
111     receivedTouchEvent.time = 0;
112
113     receivedTouchData.Reset();
114   }
115
116   bool functorCalled;
117   TouchEvent receivedTouchEvent;
118   TouchData receivedTouchData;
119 };
120
121 // Functor that sets the data when touched signal is received
122 struct TouchedFunctor
123 {
124   TouchedFunctor( TouchedSignalData& data ) : signalData( data ) { }
125
126   void operator()( const TouchEvent& touch )
127   {
128     signalData.functorCalled = true;
129     signalData.receivedTouchEvent = touch;
130   }
131
132   TouchedSignalData& signalData;
133 };
134
135
136 // Functor that sets the data when touched signal is received
137 struct TouchFunctor
138 {
139   TouchFunctor( TouchedSignalData& data ) : signalData( data ) { }
140
141   void operator()( const TouchData& touch )
142   {
143     signalData.functorCalled = true;
144     signalData.receivedTouchData = touch;
145   }
146
147   TouchedSignalData& signalData;
148 };
149
150 // Stores data that is populated in the wheel-event callback and will be read by the TET cases
151 struct WheelEventSignalData
152 {
153   WheelEventSignalData()
154   : functorCalled(false)
155   {}
156
157   void Reset()
158   {
159     functorCalled = false;
160   }
161
162   bool functorCalled;
163   WheelEvent receivedWheelEvent;
164 };
165
166 // Functor that sets the data when wheel-event signal is received
167 struct WheelEventReceivedFunctor
168 {
169   WheelEventReceivedFunctor( WheelEventSignalData& data ) : signalData( data ) { }
170
171   bool operator()( const WheelEvent& wheelEvent )
172   {
173     signalData.functorCalled = true;
174     signalData.receivedWheelEvent = wheelEvent;
175
176     return true;
177   }
178
179   WheelEventSignalData& signalData;
180 };
181
182 bool DummyTouchCallback( Actor actor, const TouchEvent& touch )
183 {
184   return true;
185 }
186
187 struct ContextStatusFunctor
188 {
189   ContextStatusFunctor(bool& calledFlag) : mCalledFlag( calledFlag )
190   {
191     mCalledFlag = false;
192   }
193
194   void operator()()
195   {
196     mCalledFlag = true;
197   }
198   void Reset()
199   {
200     mCalledFlag = false;
201   }
202
203   bool& mCalledFlag;
204 };
205
206 struct SceneCreatedStatusFunctor
207 {
208   SceneCreatedStatusFunctor(bool& calledFlag) : mCalledFlag( calledFlag )
209   {
210     mCalledFlag = false;
211   }
212
213   void operator()()
214   {
215     mCalledFlag = true;
216   }
217   void Reset()
218   {
219     mCalledFlag = false;
220   }
221
222   bool& mCalledFlag;
223 };
224
225 struct ActorCreatedFunctor
226 {
227   ActorCreatedFunctor( bool& signalReceived )
228   : mSignalVerified( signalReceived )
229   {
230   }
231
232   void operator()( BaseHandle object )
233   {
234     tet_infoline( "Verifying TestActorCallback()" );
235     Actor actor = Actor::DownCast( object );
236     if( actor )
237     {
238       mSignalVerified = true;
239     }
240   }
241
242   bool& mSignalVerified;
243 };
244
245 void GenerateTouch( TestApplication& application, PointState::Type state, const Vector2& screenPosition )
246 {
247   Integration::TouchEvent touchEvent;
248   Integration::Point point;
249   point.SetState( state );
250   point.SetScreenPosition( screenPosition );
251   touchEvent.points.push_back( point );
252   application.ProcessEvent( touchEvent );
253 }
254
255 } // unnamed namespace
256
257
258 int UtcDaliStageDefaultConstructorP(void)
259 {
260   TestApplication application;
261   Stage stage;
262
263   DALI_TEST_CHECK( !stage );
264   END_TEST;
265 }
266
267 // Note: No negative test for default constructor.
268
269 int UtcDaliStageDestructorP(void)
270 {
271   TestApplication application;
272   Stage* stage = new Stage();
273   delete stage;
274   stage = NULL;
275
276   DALI_TEST_CHECK( true );
277   END_TEST;
278 }
279
280 // Note: No negative test for default destructor.
281
282 int UtcDaliStageGetCurrentP(void)
283 {
284   TestApplication application;
285   Stage stage = Stage::GetCurrent();
286
287   DALI_TEST_CHECK( stage );
288   END_TEST;
289 }
290
291 int UtcDaliStageGetCurrentN(void)
292 {
293   bool asserted = false;
294   try
295   {
296     Stage stage = Stage::GetCurrent();
297   }
298   catch( Dali::DaliException& e )
299   {
300     DALI_TEST_PRINT_ASSERT( e );
301     DALI_TEST_ASSERT( e, "stage && \"Stage doesn't exist\"", TEST_LOCATION );
302     asserted = true;
303   }
304
305   DALI_TEST_CHECK( asserted );
306   END_TEST;
307 }
308
309 int UtcDaliStageIsInstalledP(void)
310 {
311   TestApplication application;
312
313   Stage::GetCurrent();
314
315   DALI_TEST_CHECK( Stage::IsInstalled() );
316   END_TEST;
317 }
318
319 int UtcDaliStageIsInstalledN(void)
320 {
321   DALI_TEST_CHECK( !Stage::IsInstalled() );
322
323   END_TEST;
324 }
325
326 int UtcDaliStageCopyConstructorP(void)
327 {
328   TestApplication application;
329   Stage stage = Stage::GetCurrent();
330
331   Stage copyStage( stage );
332
333   DALI_TEST_CHECK( copyStage );
334   DALI_TEST_CHECK( copyStage.GetRootLayer() == stage.GetRootLayer() );
335
336   END_TEST;
337 }
338
339 // Note: no negative test for UtcDaliStageCopyConstructor.
340
341 int UtcDaliStageAssignmentOperatorP(void)
342 {
343   TestApplication application;
344   const Stage stage = Stage::GetCurrent();
345
346   Stage copyStage = stage;
347
348   DALI_TEST_CHECK( copyStage );
349   DALI_TEST_CHECK( copyStage.GetRootLayer() == stage.GetRootLayer() );
350
351   END_TEST;
352 }
353
354 // Note: No negative test for UtcDaliStageAssignmentOperator.
355
356 int UtcDaliStageAddP(void)
357 {
358   TestApplication application;
359
360   Stage stage = Stage::GetCurrent();
361
362   Actor actor = Actor::New();
363   DALI_TEST_CHECK( !actor.OnStage() );
364
365   stage.Add( actor );
366   DALI_TEST_CHECK( actor.OnStage() );
367   END_TEST;
368 }
369
370 int UtcDaliStageAddN(void)
371 {
372   TestApplication application;
373
374   Stage stage = Stage::GetCurrent();
375   Actor actor;
376
377   bool asserted = false;
378   try
379   {
380     stage.Add( actor );
381   }
382   catch( Dali::DaliException& e )
383   {
384     DALI_TEST_PRINT_ASSERT( e );
385     DALI_TEST_ASSERT( e, "actor && \"Actor handle is empty\"", TEST_LOCATION );
386     asserted = true;
387   }
388
389   DALI_TEST_CHECK( asserted );
390
391   END_TEST;
392 }
393
394 int UtcDaliStageRemoveP(void)
395 {
396   TestApplication application;
397
398   Stage stage = Stage::GetCurrent();
399
400   Actor actor = Actor::New();
401   DALI_TEST_CHECK( !actor.OnStage() );
402
403   stage.Add( actor );
404   DALI_TEST_CHECK( actor.OnStage() );
405
406   stage.Remove(actor);
407   DALI_TEST_CHECK( !actor.OnStage() );
408   END_TEST;
409 }
410
411 int UtcDaliStageRemoveN1(void)
412 {
413   TestApplication application;
414
415   Stage stage = Stage::GetCurrent();
416   Actor actor;
417
418   bool asserted = false;
419   try
420   {
421     // Actor is not valid, confirm a removal attempt does assert.
422     stage.Remove( actor );
423   }
424   catch( Dali::DaliException& e )
425   {
426     DALI_TEST_PRINT_ASSERT( e );
427     DALI_TEST_ASSERT( e, "actor && \"Actor handle is empty\"", TEST_LOCATION );
428     asserted = true;
429   }
430
431   DALI_TEST_CHECK( asserted );
432   END_TEST;
433 }
434
435 int UtcDaliStageRemoveN2(void)
436 {
437   TestApplication application;
438
439   Stage stage = Stage::GetCurrent();
440   Actor actor = Actor::New();
441   DALI_TEST_CHECK( !actor.OnStage() );
442
443   bool asserted = false;
444   try
445   {
446     // Actor is not on stage, confirm a removal attempt does not assert / segfault.
447     stage.Remove( actor );
448   }
449   catch( Dali::DaliException& e )
450   {
451     DALI_TEST_PRINT_ASSERT( e );
452     asserted = true;
453   }
454
455   DALI_TEST_CHECK( !asserted );
456   END_TEST;
457 }
458
459 int UtcDaliStageRemoveN3(void)
460 {
461   TestApplication application;
462
463   Stage stage = Stage::GetCurrent();
464
465   // Initially we have a default layer
466   DALI_TEST_EQUALS( stage.GetLayerCount(), 1u, TEST_LOCATION );
467
468   // Check we cannot remove the root layer from the stage.
469   Layer layer = stage.GetRootLayer();
470   bool asserted = true;
471   try
472   {
473     stage.Remove( layer );
474   }
475   catch( Dali::DaliException& e )
476   {
477     DALI_TEST_PRINT_ASSERT( e );
478     DALI_TEST_ASSERT( e, "this != &child && \"Cannot remove actor from itself\"", TEST_LOCATION );
479     asserted = true;
480   }
481
482   DALI_TEST_CHECK( asserted );
483   DALI_TEST_EQUALS( stage.GetLayerCount(), 1u, TEST_LOCATION );
484   END_TEST;
485 }
486
487 int UtcDaliStageGetSizeP(void)
488 {
489   TestApplication application;
490
491   Stage stage = Stage::GetCurrent();
492
493   Vector2 size = stage.GetSize();
494
495   DALI_TEST_EQUALS( size.width,  static_cast<float>( TestApplication::DEFAULT_SURFACE_WIDTH ),  TEST_LOCATION );
496   DALI_TEST_EQUALS( size.height, static_cast<float>( TestApplication::DEFAULT_SURFACE_HEIGHT ), TEST_LOCATION );
497   END_TEST;
498 }
499
500 int UtcDaliStageGetSizeN(void)
501 {
502   TestApplication application;
503
504   Stage stage;
505
506   bool asserted = false;
507   Vector2 size;
508   try
509   {
510     size = stage.GetSize();
511   }
512   catch( Dali::DaliException& e )
513   {
514     DALI_TEST_PRINT_ASSERT( e );
515     DALI_TEST_ASSERT( e, "stage && \"Stage handle is empty\"", TEST_LOCATION );
516     asserted = true;
517   }
518
519   DALI_TEST_CHECK( asserted );
520   END_TEST;
521 }
522
523 int UtcDaliStageGetDpiP1(void)
524 {
525   TestApplication application; // Initializes core DPI to default values
526
527   Stage stage = Stage::GetCurrent();
528
529   // Test the default DPI.
530   Vector2 dpi = stage.GetDpi();
531   DALI_TEST_EQUALS( dpi.x, static_cast<float>( TestApplication::DEFAULT_HORIZONTAL_DPI ), TEST_LOCATION );
532   DALI_TEST_EQUALS( dpi.y, static_cast<float>( TestApplication::DEFAULT_VERTICAL_DPI ),   TEST_LOCATION );
533   END_TEST;
534 }
535
536 int UtcDaliStageGetDpiP2(void)
537 {
538   TestApplication application; // Initializes core DPI to default values
539
540   // Test that setting core DPI explicitly also sets up the Stage's DPI.
541   application.GetCore().SetDpi( 200, 180 );
542
543   Stage stage = Stage::GetCurrent();
544   Vector2 dpi = stage.GetDpi();
545   DALI_TEST_EQUALS( dpi.x, 200.0f, TEST_LOCATION );
546   DALI_TEST_EQUALS( dpi.y, 180.0f, TEST_LOCATION );
547   END_TEST;
548 }
549
550 int UtcDaliStageGetDpiP3(void)
551 {
552   TestApplication application( 480, 800, 72.0f, 120.0f ); // Initializes core DPI with specific values
553
554   Stage stage = Stage::GetCurrent();
555
556   // Test that setting core DPI explicitly also sets up the Stage's DPI.
557   Vector2 dpi = stage.GetDpi();
558   DALI_TEST_EQUALS( dpi.x, 72.0f, TEST_LOCATION );
559   DALI_TEST_EQUALS( dpi.y, 120.0f, TEST_LOCATION) ;
560   END_TEST;
561 }
562
563 /*
564  * This is not a true negative test, we are checking the DPI if it has not been set.
565  * A test for setting negative DPI values would be part of the application core utc tests.
566  */
567 int UtcDaliStageGetDpiN(void)
568 {
569   TestApplication application; // Initializes core DPI to default values
570
571   Stage stage = Stage::GetCurrent();
572   Vector2 dpi = stage.GetDpi();
573
574   DALI_TEST_EQUALS( dpi.x, 220.0f, TEST_LOCATION );
575   DALI_TEST_EQUALS( dpi.y, 217.0f, TEST_LOCATION );
576   END_TEST;
577 }
578
579 int UtcDaliStageGetLayerCountP(void)
580 {
581   TestApplication application;
582
583   Stage stage = Stage::GetCurrent();
584
585   // Initially we have a default layer
586   DALI_TEST_EQUALS( stage.GetLayerCount(), 1u, TEST_LOCATION );
587
588   Layer layer = Layer::New();
589   stage.Add( layer );
590
591   DALI_TEST_EQUALS( stage.GetLayerCount(), 2u, TEST_LOCATION );
592   END_TEST;
593 }
594
595 /*
596  * Not a true negative test, but confirms layer count is not affected by an invalid removal.
597  */
598 int UtcDaliStageGetLayerCountN(void)
599 {
600   TestApplication application;
601
602   Stage stage = Stage::GetCurrent();
603
604   // Initially we have a default layer
605   DALI_TEST_EQUALS( stage.GetLayerCount(), 1u, TEST_LOCATION );
606
607   Layer layer = Layer::New();
608   stage.Remove( layer );
609
610   // Still have 1 layer.
611   DALI_TEST_EQUALS( stage.GetLayerCount(), 1u, TEST_LOCATION );
612   END_TEST;
613 }
614
615 int UtcDaliStageGetLayerP(void)
616 {
617   TestApplication application;
618
619   Stage stage = Stage::GetCurrent();
620
621   Layer rootLayer = stage.GetLayer( 0 );
622   DALI_TEST_CHECK( rootLayer );
623
624   Layer layer = Layer::New();
625   stage.Add( layer );
626
627   Layer sameLayer = stage.GetLayer( 1 );
628   DALI_TEST_CHECK( layer == sameLayer );
629   END_TEST;
630 }
631
632 int UtcDaliStageGetLayerN(void)
633 {
634   TestApplication application;
635
636   Stage stage = Stage::GetCurrent();
637
638   bool asserted = false;
639   try
640   {
641     // Try to get a layer that doesn't exist (note: 0 is the root layer).
642     Layer layer = stage.GetLayer( 1 );
643   }
644   catch( Dali::DaliException& e )
645   {
646     DALI_TEST_PRINT_ASSERT( e );
647     DALI_TEST_ASSERT( e, "depth < mLayers.size()", TEST_LOCATION );
648     asserted = true;
649   }
650
651   DALI_TEST_CHECK( asserted );
652   END_TEST;
653 }
654
655 int UtcDaliStageGetRootLayerP(void)
656 {
657   TestApplication application;
658
659   Stage stage = Stage::GetCurrent();
660
661   Layer layer = stage.GetLayer( 0 );
662   DALI_TEST_CHECK( layer );
663
664   // Check that GetRootLayer() correctly retreived layer 0.
665   DALI_TEST_CHECK( stage.GetRootLayer() == layer );
666
667   END_TEST;
668 }
669
670 int UtcDaliStageGetRootLayerN(void)
671 {
672   TestApplication application;
673
674   Stage stage = Stage::GetCurrent();
675
676   Layer rootLayer = stage.GetLayer( 0 );
677   DALI_TEST_CHECK( rootLayer );
678   DALI_TEST_CHECK( stage.GetRootLayer() == rootLayer );
679
680   // Create a new layer and attempt to lower it below the root layer.
681   Layer layer = Layer::New();
682   stage.Add( layer );
683   layer.LowerToBottom();
684
685   // Check that GetRootLayer still retrieves the same original layer.
686   DALI_TEST_CHECK( stage.GetRootLayer() == rootLayer );
687
688   // Check modifying the root layer is also blocked.
689   rootLayer.RaiseToTop();
690   DALI_TEST_CHECK( stage.GetRootLayer() == rootLayer );
691
692   END_TEST;
693 }
694
695 int UtcDaliStageSetBackgroundColorP(void)
696 {
697   TestApplication application;
698
699   Stage stage = Stage::GetCurrent();
700
701   Vector4 testColor( 0.1f, 0.2f, 0.3f, 1.0f );
702   stage.SetBackgroundColor( testColor );
703
704   DALI_TEST_EQUALS( testColor, stage.GetBackgroundColor(), TEST_LOCATION );
705   END_TEST;
706 }
707
708 // Note: No negative test for UtcDaliStageSetBackgroundColor as we do not wish to implement
709 // range checking for colors due to speed. Colors are clamped with glclampf within GL anyway.
710
711 int UtcDaliStageGetBackgroundColorP(void)
712 {
713   TestApplication application;
714
715   Stage stage = Stage::GetCurrent();
716
717   DALI_TEST_EQUALS( Stage::DEFAULT_BACKGROUND_COLOR, stage.GetBackgroundColor(), TEST_LOCATION );
718   END_TEST;
719 }
720
721 // Note: No negative test for UtcDaliStageGetBackgroundColor as this is covered by UtcDaliStageSetBackgroundColorN.
722
723 int UtcDaliStageKeepRenderingP(void)
724 {
725   TestApplication application;
726
727   Stage stage = Stage::GetCurrent();
728
729   // Run core until it wants to sleep
730   bool keepUpdating( true );
731   while ( keepUpdating )
732   {
733     application.SendNotification();
734     keepUpdating = application.Render( 1000.0f /*1 second*/ );
735   }
736
737   // Force rendering for the next 5 seconds
738   stage.KeepRendering( 5.0f );
739
740   application.SendNotification();
741
742   // Test that core wants to sleep after 10 seconds
743   keepUpdating = application.Render( 1000.0f /*1 second*/ );
744   DALI_TEST_CHECK( keepUpdating );
745   keepUpdating = application.Render( 1000.0f /*2 seconds*/ );
746   DALI_TEST_CHECK( keepUpdating );
747   keepUpdating = application.Render( 1000.0f /*3 seconds*/ );
748   DALI_TEST_CHECK( keepUpdating );
749   keepUpdating = application.Render( 1000.0f /*4 seconds*/ );
750   DALI_TEST_CHECK( keepUpdating );
751   keepUpdating = application.Render( 1000.0f /*5 seconds*/ );
752   DALI_TEST_CHECK( !keepUpdating );
753   END_TEST;
754 }
755
756 int UtcDaliStageKeepRenderingN(void)
757 {
758   TestApplication application;
759
760   Stage stage = Stage::GetCurrent();
761
762   // Run core until it wants to sleep
763   bool keepUpdating( true );
764   while ( keepUpdating )
765   {
766     application.SendNotification();
767     keepUpdating = application.Render( 1000.0f /*1 second*/ );
768   }
769
770   // Force rendering for the next 5 seconds
771   stage.KeepRendering( -1.0f );
772
773   application.SendNotification();
774
775   // Test that core wants to sleep after 10 seconds
776   keepUpdating = application.Render( 1000.0f /*1 second*/ );
777   DALI_TEST_CHECK( !keepUpdating );
778
779   END_TEST;
780 }
781
782 int UtcDaliStageEventProcessingFinishedP(void)
783 {
784   TestApplication application;
785   Stage stage = Stage::GetCurrent();
786
787   bool eventProcessingFinished = false;
788   EventProcessingFinishedFunctor functor( eventProcessingFinished );
789   stage.EventProcessingFinishedSignal().Connect( &application, functor );
790
791   Actor actor( Actor::New() );
792   stage.Add( actor );
793
794   application.SendNotification();
795   application.Render();
796
797   DALI_TEST_CHECK( eventProcessingFinished );
798
799   END_TEST;
800 }
801
802 int UtcDaliStageEventProcessingFinishedN(void)
803 {
804   TestApplication application;
805   Stage stage = Stage::GetCurrent();
806
807   bool eventProcessingFinished = false;
808   EventProcessingFinishedFunctor functor( eventProcessingFinished );
809   stage.EventProcessingFinishedSignal().Connect( &application, functor );
810
811   Actor actor( Actor::New() );
812   stage.Add( actor );
813
814   // Do not complete event processing and confirm the signal has not been emitted.
815   DALI_TEST_CHECK( !eventProcessingFinished );
816
817   END_TEST;
818 }
819
820 int UtcDaliStageSignalKeyEventP(void)
821 {
822   TestApplication application;
823   Stage stage = Stage::GetCurrent();
824
825   KeyEventSignalData data;
826   KeyEventReceivedFunctor functor( data );
827   stage.KeyEventSignal().Connect( &application, functor );
828
829   Integration::KeyEvent event( "i", "i", 0, 0, 0, Integration::KeyEvent::Down );
830   application.ProcessEvent( event );
831
832   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
833   DALI_TEST_CHECK( event.keyModifier == data.receivedKeyEvent.keyModifier );
834   DALI_TEST_CHECK( event.keyName == data.receivedKeyEvent.keyPressedName );
835   DALI_TEST_CHECK( event.keyString == data.receivedKeyEvent.keyPressed );
836   DALI_TEST_CHECK( event.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
837
838   data.Reset();
839
840   Integration::KeyEvent event2( "i", "i", 0, 0, 0, Integration::KeyEvent::Up );
841   application.ProcessEvent( event2 );
842
843   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
844   DALI_TEST_CHECK( event2.keyModifier == data.receivedKeyEvent.keyModifier );
845   DALI_TEST_CHECK( event2.keyName == data.receivedKeyEvent.keyPressedName );
846   DALI_TEST_CHECK( event2.keyString == data.receivedKeyEvent.keyPressed );
847   DALI_TEST_CHECK( event2.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
848
849   data.Reset();
850
851   Integration::KeyEvent event3( "a", "a", 0, 0, 0, Integration::KeyEvent::Down );
852   application.ProcessEvent( event3 );
853
854   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
855   DALI_TEST_CHECK( event3.keyModifier == data.receivedKeyEvent.keyModifier );
856   DALI_TEST_CHECK( event3.keyName == data.receivedKeyEvent.keyPressedName );
857   DALI_TEST_CHECK( event3.keyString == data.receivedKeyEvent.keyPressed );
858   DALI_TEST_CHECK( event3.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
859
860   data.Reset();
861
862   Integration::KeyEvent event4( "a", "a", 0, 0, 0, Integration::KeyEvent::Up );
863   application.ProcessEvent( event4 );
864
865   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
866   DALI_TEST_CHECK( event4.keyModifier == data.receivedKeyEvent.keyModifier );
867   DALI_TEST_CHECK( event4.keyName == data.receivedKeyEvent.keyPressedName );
868   DALI_TEST_CHECK( event4.keyString == data.receivedKeyEvent.keyPressed );
869   DALI_TEST_CHECK( event4.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
870   END_TEST;
871 }
872
873 int UtcDaliStageSignalKeyEventN(void)
874 {
875   TestApplication application;
876   Stage stage = Stage::GetCurrent();
877
878   KeyEventSignalData data;
879   KeyEventReceivedFunctor functor( data );
880   stage.KeyEventSignal().Connect( &application, functor );
881
882   // Check that a non-pressed key events data is not modified.
883   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
884
885   END_TEST;
886 }
887
888 int UtcDaliStageTouchedSignalP(void)
889 {
890   TestApplication application;
891   Stage stage = Stage::GetCurrent();
892
893   TouchedSignalData data;
894   TouchedFunctor functor( data );
895   stage.TouchedSignal().Connect( &application, functor );
896
897   // Render and notify.
898   application.SendNotification();
899   application.Render();
900
901   // Basic test: No actors, single touch (down then up).
902   {
903     GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
904
905     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
906     DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
907     DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
908     data.Reset();
909
910     GenerateTouch( application, PointState::UP, Vector2( 10.0f, 10.0f ) );
911
912     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
913     DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
914     DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
915     data.Reset();
916   }
917
918   // Add an actor to the scene.
919   Actor actor = Actor::New();
920   actor.SetSize( 100.0f, 100.0f );
921   actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
922   actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
923   actor.TouchedSignal().Connect( &DummyTouchCallback );
924   stage.Add( actor );
925
926   // Render and notify.
927   application.SendNotification();
928   application.Render();
929
930   // Actor on scene, single touch, down in actor, motion, then up outside actor.
931   {
932     GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
933
934     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
935     DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
936     DALI_TEST_CHECK( data.receivedTouchEvent.points[0].hitActor == actor );
937     data.Reset();
938
939     GenerateTouch( application, PointState::MOTION, Vector2( 150.0f, 10.0f ) ); // Some motion
940
941     DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
942     data.Reset();
943
944     GenerateTouch( application, PointState::UP, Vector2( 150.0f, 10.0f ) ); // Some motion
945
946     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
947     DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
948     DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
949     data.Reset();
950   }
951
952   // Multiple touch. Should only receive a touch on first down and last up.
953   {
954     Integration::TouchEvent touchEvent;
955     Integration::Point point;
956
957     // 1st point
958     point.SetState( PointState::DOWN );
959     point.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
960     touchEvent.points.push_back( point );
961     application.ProcessEvent( touchEvent );
962     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
963     DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 1u, TEST_LOCATION );
964     data.Reset();
965
966     // 2nd point
967     touchEvent.points[0].SetState( PointState::STATIONARY );
968     point.SetDeviceId( 1 );
969     point.SetScreenPosition( Vector2( 50.0f, 50.0f ) );
970     touchEvent.points.push_back( point );
971     application.ProcessEvent( touchEvent );
972     DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
973     DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 0u, TEST_LOCATION );
974     data.Reset();
975
976     // Primary point is up
977     touchEvent.points[0].SetState( PointState::UP );
978     touchEvent.points[1].SetState( PointState::STATIONARY );
979     application.ProcessEvent( touchEvent );
980     DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
981     DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 0u, TEST_LOCATION );
982     data.Reset();
983
984     // Remove 1st point now, 2nd point is now in motion
985     touchEvent.points.erase( touchEvent.points.begin() );
986     touchEvent.points[0].SetState( PointState::MOTION );
987     touchEvent.points[0].SetScreenPosition( Vector2( 150.0f, 50.0f ) );
988     application.ProcessEvent( touchEvent );
989     DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
990     DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 0u, TEST_LOCATION );
991     data.Reset();
992
993     // Final point Up
994     touchEvent.points[0].SetState( PointState::UP );
995     application.ProcessEvent( touchEvent );
996     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
997     DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 1u, TEST_LOCATION );
998     data.Reset();
999   }
1000   END_TEST;
1001 }
1002
1003 int UtcDaliStageTouchedSignalN(void)
1004 {
1005   TestApplication application;
1006   Stage stage = Stage::GetCurrent();
1007
1008   TouchedSignalData data;
1009   TouchedFunctor functor( data );
1010   stage.TouchedSignal().Connect( &application, functor );
1011
1012   // Render and notify.
1013   application.SendNotification();
1014   application.Render();
1015
1016   // Confirm functor not called before there has been any touch event.
1017   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1018
1019   // No actors, single touch, down, motion then up.
1020   {
1021     GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1022
1023     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1024     DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1025     DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
1026     data.Reset();
1027
1028     // Confirm there is no signal when the touchpoint is only moved.
1029     GenerateTouch( application, PointState::MOTION, Vector2( 1200.0f, 10.0f ) ); // Some motion
1030
1031     DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1032     data.Reset();
1033
1034     // Confirm a following up event generates a signal.
1035     GenerateTouch( application, PointState::UP, Vector2( 1200.0f, 10.0f ) );
1036
1037     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1038     DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1039     DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
1040     data.Reset();
1041   }
1042
1043   // Add an actor to the scene.
1044   Actor actor = Actor::New();
1045   actor.SetSize( 100.0f, 100.0f );
1046   actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1047   actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1048   actor.TouchedSignal().Connect( &DummyTouchCallback );
1049   stage.Add( actor );
1050
1051   // Render and notify.
1052   application.SendNotification();
1053   application.Render();
1054
1055   // Actor on scene. Interrupted before down and interrupted after down.
1056   {
1057     GenerateTouch( application, PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) );
1058
1059     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1060     DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1061     DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
1062     DALI_TEST_CHECK( data.receivedTouchEvent.points[0].state == TouchPoint::Interrupted );
1063     data.Reset();
1064
1065     GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1066
1067     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1068     DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1069     DALI_TEST_CHECK( data.receivedTouchEvent.points[0].hitActor == actor );
1070     DALI_TEST_CHECK( data.receivedTouchEvent.points[0].state == TouchPoint::Down );
1071     data.Reset();
1072
1073     GenerateTouch( application, PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) );
1074
1075     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1076     DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1077     DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
1078     DALI_TEST_CHECK( data.receivedTouchEvent.points[0].state == TouchPoint::Interrupted );
1079
1080     DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 1u, TEST_LOCATION );
1081
1082     // Check that getting info about a non-existent point causes an assert.
1083     bool asserted = false;
1084     try
1085     {
1086       data.receivedTouchEvent.GetPoint( 1 );
1087     }
1088     catch( Dali::DaliException& e )
1089     {
1090       DALI_TEST_PRINT_ASSERT( e );
1091       DALI_TEST_ASSERT( e, "point < points.size() && \"No point at index\"", TEST_LOCATION );
1092       asserted = true;
1093     }
1094     DALI_TEST_CHECK( asserted );
1095
1096     data.Reset();
1097   }
1098
1099   END_TEST;
1100 }
1101
1102
1103 int UtcDaliStageTouchSignalP(void)
1104 {
1105   TestApplication application;
1106   Stage stage = Stage::GetCurrent();
1107
1108   TouchedSignalData data;
1109   TouchFunctor functor( data );
1110   stage.TouchSignal().Connect( &application, functor );
1111
1112   // Render and notify.
1113   application.SendNotification();
1114   application.Render();
1115
1116   // Basic test: No actors, single touch (down then up).
1117   {
1118     GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1119
1120     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1121     DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1122     DALI_TEST_CHECK( !data.receivedTouchData.GetHitActor(0) );
1123     data.Reset();
1124
1125     GenerateTouch( application, PointState::UP, Vector2( 10.0f, 10.0f ) );
1126
1127     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1128     DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1129     DALI_TEST_CHECK( !data.receivedTouchData.GetHitActor(0) );
1130     data.Reset();
1131   }
1132
1133   // Add an actor to the scene.
1134   Actor actor = Actor::New();
1135   actor.SetSize( 100.0f, 100.0f );
1136   actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1137   actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1138   actor.TouchedSignal().Connect( &DummyTouchCallback );
1139   stage.Add( actor );
1140
1141   // Render and notify.
1142   application.SendNotification();
1143   application.Render();
1144
1145   // Actor on scene, single touch, down in actor, motion, then up outside actor.
1146   {
1147     GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1148
1149     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1150     DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1151     DALI_TEST_CHECK( data.receivedTouchData.GetHitActor(0) == actor );
1152     data.Reset();
1153
1154     GenerateTouch( application, PointState::MOTION, Vector2( 150.0f, 10.0f ) ); // Some motion
1155
1156     DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1157     data.Reset();
1158
1159     GenerateTouch( application, PointState::UP, Vector2( 150.0f, 10.0f ) ); // Some motion
1160
1161     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1162     DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1163     DALI_TEST_CHECK( !data.receivedTouchData.GetHitActor(0) );
1164     data.Reset();
1165   }
1166
1167   // Multiple touch. Should only receive a touch on first down and last up.
1168   {
1169     Integration::TouchEvent touchEvent;
1170     Integration::Point point;
1171
1172     // 1st point
1173     point.SetState( PointState::DOWN );
1174     point.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
1175     touchEvent.points.push_back( point );
1176     application.ProcessEvent( touchEvent );
1177     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1178     DALI_TEST_EQUALS( data.receivedTouchData.GetPointCount(), 1u, TEST_LOCATION );
1179     data.Reset();
1180
1181     // 2nd point
1182     touchEvent.points[0].SetState( PointState::STATIONARY );
1183     point.SetDeviceId( 1 );
1184     point.SetScreenPosition( Vector2( 50.0f, 50.0f ) );
1185     touchEvent.points.push_back( point );
1186     application.ProcessEvent( touchEvent );
1187     DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1188     data.Reset();
1189
1190     // Primary point is up
1191     touchEvent.points[0].SetState( PointState::UP );
1192     touchEvent.points[1].SetState( PointState::STATIONARY );
1193     application.ProcessEvent( touchEvent );
1194     DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1195     data.Reset();
1196
1197     // Remove 1st point now, 2nd point is now in motion
1198     touchEvent.points.erase( touchEvent.points.begin() );
1199     touchEvent.points[0].SetState( PointState::MOTION );
1200     touchEvent.points[0].SetScreenPosition( Vector2( 150.0f, 50.0f ) );
1201     application.ProcessEvent( touchEvent );
1202     DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1203     data.Reset();
1204
1205     // Final point Up
1206     touchEvent.points[0].SetState( PointState::UP );
1207     application.ProcessEvent( touchEvent );
1208     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1209     DALI_TEST_EQUALS( data.receivedTouchData.GetPointCount(), 1u, TEST_LOCATION );
1210     data.Reset();
1211   }
1212   END_TEST;
1213 }
1214
1215 int UtcDaliStageTouchSignalN(void)
1216 {
1217   TestApplication application;
1218   Stage stage = Stage::GetCurrent();
1219
1220   TouchedSignalData data;
1221   TouchFunctor functor( data );
1222   stage.TouchSignal().Connect( &application, functor );
1223
1224   // Render and notify.
1225   application.SendNotification();
1226   application.Render();
1227
1228   // Confirm functor not called before there has been any touch event.
1229   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1230
1231   // No actors, single touch, down, motion then up.
1232   {
1233     GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1234
1235     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1236     DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1237     DALI_TEST_CHECK( !data.receivedTouchData.GetHitActor(0));
1238     data.Reset();
1239
1240     // Confirm there is no signal when the touchpoint is only moved.
1241     GenerateTouch( application, PointState::MOTION, Vector2( 1200.0f, 10.0f ) ); // Some motion
1242
1243     DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1244     data.Reset();
1245
1246     // Confirm a following up event generates a signal.
1247     GenerateTouch( application, PointState::UP, Vector2( 1200.0f, 10.0f ) );
1248
1249     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1250     DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1251     DALI_TEST_CHECK( !data.receivedTouchData.GetHitActor(0));
1252     data.Reset();
1253   }
1254
1255   // Add an actor to the scene.
1256   Actor actor = Actor::New();
1257   actor.SetSize( 100.0f, 100.0f );
1258   actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1259   actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1260   actor.TouchedSignal().Connect( &DummyTouchCallback );
1261   stage.Add( actor );
1262
1263   // Render and notify.
1264   application.SendNotification();
1265   application.Render();
1266
1267   // Actor on scene. Interrupted before down and interrupted after down.
1268   {
1269     GenerateTouch( application, PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) );
1270
1271     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1272     DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1273     DALI_TEST_CHECK( !data.receivedTouchData.GetHitActor(0) );
1274     DALI_TEST_CHECK( data.receivedTouchData.GetState(0) == PointState::INTERRUPTED );
1275     data.Reset();
1276
1277     GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1278
1279     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1280     DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1281     DALI_TEST_CHECK( data.receivedTouchData.GetHitActor(0) == actor );
1282     DALI_TEST_CHECK( data.receivedTouchData.GetState(0) == PointState::DOWN );
1283     data.Reset();
1284
1285     GenerateTouch( application, PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) );
1286
1287     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1288     DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1289     DALI_TEST_CHECK( !data.receivedTouchData.GetHitActor(0) );
1290     DALI_TEST_CHECK( data.receivedTouchData.GetState(0) == PointState::INTERRUPTED );
1291
1292     DALI_TEST_EQUALS( data.receivedTouchData.GetPointCount(), 1u, TEST_LOCATION );
1293
1294     // Check that getting info about a non-existent point returns an empty handle
1295     Actor actor = data.receivedTouchData.GetHitActor( 1 );
1296     DALI_TEST_CHECK( !actor );
1297
1298     data.Reset();
1299   }
1300
1301   END_TEST;
1302 }
1303
1304 int UtcDaliStageSignalWheelEventP(void)
1305 {
1306   TestApplication application;
1307   Stage stage = Stage::GetCurrent();
1308
1309   WheelEventSignalData data;
1310   WheelEventReceivedFunctor functor( data );
1311   stage.WheelEventSignal().Connect( &application, functor );
1312
1313   Integration::WheelEvent event( Integration::WheelEvent::CUSTOM_WHEEL, 0, 0u, Vector2( 0.0f, 0.0f ), 1, 1000u );
1314   application.ProcessEvent( event );
1315
1316   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1317   DALI_TEST_CHECK( static_cast< WheelEvent::Type >(event.type) == data.receivedWheelEvent.type );
1318   DALI_TEST_CHECK( event.direction == data.receivedWheelEvent.direction );
1319   DALI_TEST_CHECK( event.modifiers == data.receivedWheelEvent.modifiers );
1320   DALI_TEST_CHECK( event.point == data.receivedWheelEvent.point );
1321   DALI_TEST_CHECK( event.z == data.receivedWheelEvent.z );
1322   DALI_TEST_CHECK( event.timeStamp == data.receivedWheelEvent.timeStamp );
1323
1324   data.Reset();
1325
1326   Integration::WheelEvent event2( Integration::WheelEvent::CUSTOM_WHEEL, 0, 0u, Vector2( 0.0f, 0.0f ), -1, 1000u );
1327   application.ProcessEvent( event2 );
1328
1329   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1330   DALI_TEST_CHECK( static_cast< WheelEvent::Type >(event2.type) == data.receivedWheelEvent.type );
1331   DALI_TEST_CHECK( event2.direction == data.receivedWheelEvent.direction );
1332   DALI_TEST_CHECK( event2.modifiers == data.receivedWheelEvent.modifiers );
1333   DALI_TEST_CHECK( event2.point == data.receivedWheelEvent.point );
1334   DALI_TEST_CHECK( event2.z == data.receivedWheelEvent.z );
1335   DALI_TEST_CHECK( event2.timeStamp == data.receivedWheelEvent.timeStamp );
1336   END_TEST;
1337 }
1338
1339 int UtcDaliStageContextLostSignalP(void)
1340 {
1341   TestApplication app;
1342   Stage stage = Stage::GetCurrent();
1343
1344   bool contextLost = false;
1345   ContextStatusFunctor contextLostFunctor( contextLost );
1346   stage.ContextLostSignal().Connect( &app, contextLostFunctor );
1347
1348   Integration::ContextNotifierInterface* notifier = app.GetCore().GetContextNotifier();
1349   notifier->NotifyContextLost();
1350   DALI_TEST_EQUALS( contextLost, true, TEST_LOCATION );
1351
1352   END_TEST;
1353 }
1354
1355 int UtcDaliStageContextLostSignalN(void)
1356 {
1357   TestApplication app;
1358   Stage stage;
1359
1360   // Check that connecting to the signal with a bad stage instance causes an assert.
1361   bool asserted = false;
1362   bool contextLost = false;
1363   ContextStatusFunctor contextLostFunctor( contextLost );
1364   try
1365   {
1366     stage.ContextLostSignal().Connect( &app, contextLostFunctor );
1367   }
1368   catch( Dali::DaliException& e )
1369   {
1370     DALI_TEST_PRINT_ASSERT( e );
1371     DALI_TEST_ASSERT( e, "stage && \"Stage handle is empty\"", TEST_LOCATION );
1372     asserted = true;
1373   }
1374   DALI_TEST_CHECK( asserted );
1375
1376   END_TEST;
1377 }
1378
1379 int UtcDaliStageContextRegainedSignalP(void)
1380 {
1381   TestApplication app;
1382   Stage stage = Stage::GetCurrent();
1383
1384   bool contextRegained = false;
1385   ContextStatusFunctor contextRegainedFunctor( contextRegained );
1386   stage.ContextRegainedSignal().Connect( &app, contextRegainedFunctor );
1387
1388   Integration::ContextNotifierInterface* notifier = app.GetCore().GetContextNotifier();
1389   notifier->NotifyContextLost();
1390   notifier->NotifyContextRegained();
1391   DALI_TEST_EQUALS( contextRegained, true, TEST_LOCATION );
1392
1393   END_TEST;
1394 }
1395
1396 int UtcDaliStageContextRegainedSignalN(void)
1397 {
1398   TestApplication app;
1399   Stage stage;
1400
1401   // Check that connecting to the signal with a bad stage instance causes an assert.
1402   bool asserted = false;
1403   bool contextRegained = false;
1404   ContextStatusFunctor contextRegainedFunctor( contextRegained );
1405   try
1406   {
1407     stage.ContextRegainedSignal().Connect( &app, contextRegainedFunctor );
1408   }
1409   catch( Dali::DaliException& e )
1410   {
1411     DALI_TEST_PRINT_ASSERT( e );
1412     DALI_TEST_ASSERT( e, "stage && \"Stage handle is empty\"", TEST_LOCATION );
1413     asserted = true;
1414   }
1415   DALI_TEST_CHECK( asserted );
1416
1417   END_TEST;
1418 }
1419
1420 int UtcDaliStageSceneCreatedSignalP(void)
1421 {
1422   TestApplication app;
1423   Stage stage = Stage::GetCurrent();
1424
1425   bool signalCalled = false;
1426   SceneCreatedStatusFunctor sceneCreatedFunctor( signalCalled );
1427   stage.SceneCreatedSignal().Connect( &app, sceneCreatedFunctor );
1428
1429   Integration::Core& core = app.GetCore();
1430   core.SceneCreated();
1431   DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
1432
1433   END_TEST;
1434 }
1435
1436 int UtcDaliStageSceneCreatedSignalN(void)
1437 {
1438   TestApplication app;
1439   Stage stage;
1440
1441   // Check that connecting to the signal with a bad stage instance causes an assert.
1442   bool asserted = false;
1443   bool signalCalled = false;
1444   SceneCreatedStatusFunctor sceneCreatedFunctor( signalCalled );
1445   try
1446   {
1447     stage.SceneCreatedSignal().Connect( &app, sceneCreatedFunctor );
1448   }
1449   catch( Dali::DaliException& e )
1450   {
1451     DALI_TEST_PRINT_ASSERT( e );
1452     DALI_TEST_ASSERT( e, "stage && \"Stage handle is empty\"", TEST_LOCATION );
1453     asserted = true;
1454   }
1455   DALI_TEST_CHECK( asserted );
1456
1457   END_TEST;
1458 }
1459
1460 int UtcDaliStageGetRenderTaskListP(void)
1461 {
1462   TestApplication app;
1463   Stage stage = Stage::GetCurrent();
1464
1465   // Check we get a valid instance.
1466   const RenderTaskList& tasks = stage.GetRenderTaskList();
1467
1468   // There should be 1 task by default.
1469   DALI_TEST_EQUALS( tasks.GetTaskCount(), 1u, TEST_LOCATION );
1470
1471   // RenderTaskList has it's own UTC tests.
1472   // But we can confirm that GetRenderTaskList in Stage retrieves the same RenderTaskList each time.
1473   RenderTask newTask = stage.GetRenderTaskList().CreateTask();
1474
1475   DALI_TEST_EQUALS( stage.GetRenderTaskList().GetTask( 1 ), newTask, TEST_LOCATION );
1476
1477   END_TEST;
1478 }
1479
1480 int UtcDaliStageGetRenderTaskListN(void)
1481 {
1482   TestApplication app;
1483   Stage stage;
1484
1485   // Check that getting the render task list with a bad stage instance causes an assert.
1486   bool asserted = false;
1487   try
1488   {
1489     stage.GetRenderTaskList();
1490   }
1491   catch( Dali::DaliException& e )
1492   {
1493     DALI_TEST_PRINT_ASSERT( e );
1494     DALI_TEST_ASSERT( e, "stage && \"Stage handle is empty\"", TEST_LOCATION );
1495     asserted = true;
1496   }
1497   DALI_TEST_CHECK( asserted );
1498
1499   END_TEST;
1500 }
1501
1502 int UtcDaliStageGetObjectRegistryP(void)
1503 {
1504   TestApplication app;
1505   Stage stage = Stage::GetCurrent();
1506
1507   ObjectRegistry objectRegistry = stage.GetObjectRegistry();
1508
1509   // Object registry tests are covered in their own module.
1510   // However we want a basic test to confirm the returned registry is valid and works.
1511   bool verified = false;
1512   ActorCreatedFunctor test( verified );
1513   objectRegistry.ObjectCreatedSignal().Connect( &app, test );
1514
1515   Actor actor = Actor::New();
1516   DALI_TEST_CHECK( test.mSignalVerified );
1517
1518   END_TEST;
1519 }
1520
1521 int UtcDaliStageGetObjectRegistryN(void)
1522 {
1523   TestApplication app;
1524   Stage stage;
1525
1526   // Check that getting the object registry with a bad stage instance DOES NOT cause an assert.
1527   // This is because GetCurrent() is used, always creating a stage if one does not exist.
1528   bool asserted = false;
1529   try
1530   {
1531     stage.GetObjectRegistry();
1532   }
1533   catch( Dali::DaliException& e )
1534   {
1535     DALI_TEST_PRINT_ASSERT( e );
1536     asserted = true;
1537   }
1538   DALI_TEST_CHECK( !asserted );
1539
1540   END_TEST;
1541 }
1542
1543 int UtcDaliStageOperatorAssign(void)
1544 {
1545   TestApplication app;
1546   Stage stage;
1547   DALI_TEST_CHECK( !stage );
1548
1549   stage = Stage::GetCurrent();
1550   DALI_TEST_CHECK( stage );
1551
1552   END_TEST;
1553 }