Add UTC for Stage::WheelEventSignal()
[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 #include <dali/devel-api/dynamics/dynamics.h>
28
29 #include <dali-test-suite-utils.h>
30
31 using namespace Dali;
32
33 void stage_test_startup(void)
34 {
35   test_return_value = TET_UNDEF;
36 }
37
38 void stage_test_cleanup(void)
39 {
40   test_return_value = TET_PASS;
41 }
42
43 namespace
44 {
45
46 /**
47  * Functor for EventProcessingFinished signal
48  */
49 struct EventProcessingFinishedFunctor
50 {
51   /**
52    * @param[in] eventProcessingFinished reference to a boolean variable used to check if signal has been called.
53    */
54   EventProcessingFinishedFunctor( bool& eventProcessingFinished )
55   : mEventProcessingFinished( eventProcessingFinished )
56   {}
57
58   void operator()()
59   {
60     mEventProcessingFinished = true;
61   }
62
63   bool& mEventProcessingFinished;
64 };
65
66 // Stores data that is populated in the key-event callback and will be read by the TET cases
67 struct KeyEventSignalData
68 {
69   KeyEventSignalData()
70   : functorCalled(false)
71   {}
72
73   void Reset()
74   {
75     functorCalled = false;
76
77     receivedKeyEvent.keyModifier = 0;
78     receivedKeyEvent.keyPressedName.clear();
79     receivedKeyEvent.keyPressed.clear();
80   }
81
82   bool functorCalled;
83   KeyEvent receivedKeyEvent;
84 };
85
86 // Functor that sets the data when called
87 struct KeyEventReceivedFunctor
88 {
89   KeyEventReceivedFunctor( KeyEventSignalData& data ) : signalData( data ) { }
90
91   bool operator()( const KeyEvent& keyEvent )
92   {
93     signalData.functorCalled = true;
94     signalData.receivedKeyEvent = keyEvent;
95
96     return true;
97   }
98
99   KeyEventSignalData& signalData;
100 };
101
102 // Stores data that is populated in the touched signal callback and will be read by the TET cases
103 struct TouchedSignalData
104 {
105   TouchedSignalData()
106   : functorCalled(false)
107   {}
108
109   void Reset()
110   {
111     functorCalled = false;
112
113     receivedTouchEvent.points.clear();
114     receivedTouchEvent.time = 0;
115   }
116
117   bool functorCalled;
118   TouchEvent receivedTouchEvent;
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 // Stores data that is populated in the wheel-event callback and will be read by the TET cases
136 struct WheelEventSignalData
137 {
138   WheelEventSignalData()
139   : functorCalled(false)
140   {}
141
142   void Reset()
143   {
144     functorCalled = false;
145   }
146
147   bool functorCalled;
148   WheelEvent receivedWheelEvent;
149 };
150
151 // Functor that sets the data when wheel-event signal is received
152 struct WheelEventReceivedFunctor
153 {
154   WheelEventReceivedFunctor( WheelEventSignalData& data ) : signalData( data ) { }
155
156   bool operator()( const WheelEvent& wheelEvent )
157   {
158     signalData.functorCalled = true;
159     signalData.receivedWheelEvent = wheelEvent;
160
161     return true;
162   }
163
164   WheelEventSignalData& signalData;
165 };
166
167 bool DummyTouchCallback( Actor actor, const TouchEvent& touch )
168 {
169   return true;
170 }
171
172
173 struct ContextStatusFunctor
174 {
175   ContextStatusFunctor(bool& calledFlag) : mCalledFlag( calledFlag )
176   {
177     mCalledFlag = false;
178   }
179
180   void operator()()
181   {
182     mCalledFlag = true;
183   }
184   void Reset()
185   {
186     mCalledFlag = false;
187   }
188
189   bool& mCalledFlag;
190 };
191
192 struct SceneCreatedStatusFunctor
193 {
194   SceneCreatedStatusFunctor(bool& calledFlag) : mCalledFlag( calledFlag )
195   {
196     mCalledFlag = false;
197   }
198
199   void operator()()
200   {
201     mCalledFlag = true;
202   }
203   void Reset()
204   {
205     mCalledFlag = false;
206   }
207
208   bool& mCalledFlag;
209 };
210
211 } // unnamed namespace
212
213
214 int UtcDaliStageDefaultConstructor(void)
215 {
216   TestApplication application;
217   Stage stage;
218
219   DALI_TEST_CHECK(!stage);
220   END_TEST;
221 }
222
223 int UtcDaliStageDestructor(void)
224 {
225   TestApplication application;
226   Stage* stage = new Stage();
227   delete stage;
228   stage = NULL;
229
230   DALI_TEST_CHECK( true );
231   END_TEST;
232 }
233
234 int UtcDaliStageGetCurrent(void)
235 {
236   TestApplication application;
237   Stage stage = Stage::GetCurrent();
238
239   DALI_TEST_CHECK(stage);
240   END_TEST;
241 }
242
243 int UtcDaliStageAssign(void)
244 {
245   TestApplication application;
246   Stage stage = Stage::GetCurrent();
247   Stage stage2;
248   stage2 = stage;
249
250   DALI_TEST_CHECK(stage2);
251   END_TEST;
252 }
253
254 int UtcDaliStageIsInstalled(void)
255 {
256   DALI_TEST_CHECK(!Stage::IsInstalled());
257
258   TestApplication application;
259
260   Stage::GetCurrent();
261
262   DALI_TEST_CHECK(Stage::IsInstalled());
263   END_TEST;
264 }
265
266 int UtcDaliStageAdd(void)
267 {
268   TestApplication application;
269
270   Stage stage = Stage::GetCurrent();
271
272   Actor actor = Actor::New();
273   DALI_TEST_CHECK(!actor.OnStage());
274
275   stage.Add(actor);
276   DALI_TEST_CHECK(actor.OnStage());
277   END_TEST;
278 }
279
280 int UtcDaliStageRemove(void)
281 {
282   TestApplication application;
283
284   Stage stage = Stage::GetCurrent();
285
286   Actor actor = Actor::New();
287   DALI_TEST_CHECK(!actor.OnStage());
288
289   stage.Add(actor);
290   DALI_TEST_CHECK(actor.OnStage());
291
292   stage.Remove(actor);
293   DALI_TEST_CHECK(!actor.OnStage());
294   END_TEST;
295 }
296
297 int UtcDaliStageGetSize(void)
298 {
299   TestApplication application;
300
301   Stage stage = Stage::GetCurrent();
302
303   Vector2 size = stage.GetSize();
304
305   DALI_TEST_EQUALS(size.width,  static_cast<float>(TestApplication::DEFAULT_SURFACE_WIDTH),  TEST_LOCATION);
306   DALI_TEST_EQUALS(size.height, static_cast<float>(TestApplication::DEFAULT_SURFACE_HEIGHT), TEST_LOCATION);
307   END_TEST;
308 }
309
310 int UtcDaliStageGetDpi01(void)
311 {
312   TestApplication application; // Initializes core DPI to default values
313
314   Stage stage = Stage::GetCurrent();
315
316   // Test the default DPI.
317   Vector2 dpi = stage.GetDpi();
318   DALI_TEST_EQUALS(dpi.x, static_cast<float>(TestApplication::DEFAULT_HORIZONTAL_DPI), TEST_LOCATION);
319   DALI_TEST_EQUALS(dpi.y, static_cast<float>(TestApplication::DEFAULT_VERTICAL_DPI),   TEST_LOCATION);
320   END_TEST;
321 }
322
323 int UtcDaliStageGetDpi02(void)
324 {
325   TestApplication application; // Initializes core DPI to default values
326
327   // Test that setting core DPI explicitly also sets up the Stage's DPI.
328   application.GetCore().SetDpi(200, 180);
329
330   Stage stage = Stage::GetCurrent();
331   Vector2 dpi = stage.GetDpi();
332   DALI_TEST_EQUALS(dpi.x, 200.0f, TEST_LOCATION);
333   DALI_TEST_EQUALS(dpi.y, 180.0f, TEST_LOCATION);
334   END_TEST;
335 }
336
337
338 int UtcDaliStageGetDpi03(void)
339 {
340   TestApplication application(480, 800, 72.0f, 120.0f); // Initializes core DPI with specific values
341
342   Stage stage = Stage::GetCurrent();
343
344   // Test that setting core DPI explicitly also sets up the Stage's DPI.
345   Vector2 dpi = stage.GetDpi();
346   DALI_TEST_EQUALS(dpi.x, 72.0f, TEST_LOCATION);
347   DALI_TEST_EQUALS(dpi.y, 120.0f, TEST_LOCATION);
348   END_TEST;
349 }
350
351 int UtcDaliStageInitializeDynamicsP(void)
352 {
353   TestApplication application;
354   Stage stage = Stage::GetCurrent();
355   DynamicsWorld world = stage.InitializeDynamics( DynamicsWorldConfig::New() );
356
357 #if !defined(DYNAMICS_SUPPORT)
358   DALI_TEST_CHECK(true);
359 #else
360   DALI_TEST_CHECK( world );
361 #endif
362
363   END_TEST;
364 }
365
366 int UtcDaliStageGetLayerCount(void)
367 {
368   TestApplication application;
369
370   Stage stage = Stage::GetCurrent();
371
372   // Initially we have a default layer
373   DALI_TEST_EQUALS(stage.GetLayerCount(), 1u, TEST_LOCATION);
374
375   Layer layer = Layer::New();
376   stage.Add(layer);
377
378   DALI_TEST_EQUALS(stage.GetLayerCount(), 2u, TEST_LOCATION);
379   END_TEST;
380 }
381
382 int UtcDaliStageGetLayer(void)
383 {
384   TestApplication application;
385
386   Stage stage = Stage::GetCurrent();
387
388   Layer rootLayer = stage.GetLayer(0);
389   DALI_TEST_CHECK(rootLayer);
390
391   Layer layer = Layer::New();
392   stage.Add(layer);
393
394   Layer sameLayer = stage.GetLayer(1);
395   DALI_TEST_CHECK(layer == sameLayer);
396   END_TEST;
397 }
398
399
400 int UtcDaliStageGetRootLayer(void)
401 {
402   TestApplication application;
403
404   Stage stage = Stage::GetCurrent();
405
406   Layer rootLayer = stage.GetLayer(0);
407   DALI_TEST_CHECK( rootLayer );
408
409   Layer layer = Layer::New();
410   stage.Add( layer );
411   layer.LowerToBottom();
412
413   DALI_TEST_CHECK( stage.GetRootLayer() == rootLayer );
414   END_TEST;
415 }
416
417 int UtcDaliStageSetBackgroundColor(void)
418 {
419   TestApplication application;
420
421   Stage stage = Stage::GetCurrent();
422
423   Vector4 testColor(0.1f, 0.2f, 0.3f, 1.0f);
424   stage.SetBackgroundColor(testColor);
425
426   DALI_TEST_EQUALS(testColor, stage.GetBackgroundColor(), TEST_LOCATION);
427   END_TEST;
428 }
429
430 int UtcDaliStageGetBackgroundColor(void)
431 {
432   TestApplication application;
433
434   Stage stage = Stage::GetCurrent();
435
436   DALI_TEST_EQUALS(Stage::DEFAULT_BACKGROUND_COLOR, stage.GetBackgroundColor(), TEST_LOCATION);
437   END_TEST;
438 }
439
440 int UtcDaliStageKeepRendering(void)
441 {
442   TestApplication application;
443
444   Stage stage = Stage::GetCurrent();
445
446   // Run core until it wants to sleep
447   bool keepUpdating( true );
448   while ( keepUpdating )
449   {
450     application.SendNotification();
451     keepUpdating = application.Render(1000.0f /*1 second*/);
452   }
453
454   // Force rendering for the next 5 seconds
455   stage.KeepRendering( 5.0f );
456
457   application.SendNotification();
458
459   // Test that core wants to sleep after 10 seconds
460   keepUpdating = application.Render(1000.0f /*1 second*/);
461   DALI_TEST_CHECK( keepUpdating );
462   keepUpdating = application.Render(1000.0f /*2 seconds*/);
463   DALI_TEST_CHECK( keepUpdating );
464   keepUpdating = application.Render(1000.0f /*3 seconds*/);
465   DALI_TEST_CHECK( keepUpdating );
466   keepUpdating = application.Render(1000.0f /*4 seconds*/);
467   DALI_TEST_CHECK( keepUpdating );
468   keepUpdating = application.Render(1000.0f /*5 seconds*/);
469   DALI_TEST_CHECK( !keepUpdating );
470   END_TEST;
471 }
472
473 int UtcDaliStageEventProcessingFinished(void)
474 {
475   TestApplication application;
476   Stage stage = Stage::GetCurrent();
477
478   bool eventProcessingFinished = false;
479   EventProcessingFinishedFunctor functor( eventProcessingFinished );
480   stage.EventProcessingFinishedSignal().Connect( &application, functor );
481
482   Actor actor( Actor::New() );
483   stage.Add( actor );
484
485   application.SendNotification();
486   application.Render();
487
488   DALI_TEST_CHECK( eventProcessingFinished );
489
490   END_TEST;
491 }
492
493 int UtcDaliStageSignalKeyEvent(void)
494 {
495   TestApplication application;
496   Stage stage = Stage::GetCurrent();
497
498   KeyEventSignalData data;
499   KeyEventReceivedFunctor functor( data );
500   stage.KeyEventSignal().Connect( &application, functor );
501
502   Integration::KeyEvent event( "i","i", 0, 0, 0, Integration::KeyEvent::Down );
503   application.ProcessEvent( event );
504
505   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
506   DALI_TEST_CHECK( event.keyModifier == data.receivedKeyEvent.keyModifier );
507   DALI_TEST_CHECK( event.keyName == data.receivedKeyEvent.keyPressedName );
508   DALI_TEST_CHECK( event.keyString == data.receivedKeyEvent.keyPressed );
509   DALI_TEST_CHECK( event.state == static_cast<Integration::KeyEvent::State>(data.receivedKeyEvent.state) );
510
511   data.Reset();
512
513   Integration::KeyEvent event2( "i","i", 0, 0, 0, Integration::KeyEvent::Up );
514   application.ProcessEvent( event2 );
515
516   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
517   DALI_TEST_CHECK( event2.keyModifier == data.receivedKeyEvent.keyModifier );
518   DALI_TEST_CHECK( event2.keyName == data.receivedKeyEvent.keyPressedName );
519   DALI_TEST_CHECK( event2.keyString == data.receivedKeyEvent.keyPressed );
520   DALI_TEST_CHECK( event2.state == static_cast<Integration::KeyEvent::State>(data.receivedKeyEvent.state) );
521
522   data.Reset();
523
524   Integration::KeyEvent event3( "a","a", 0, 0, 0, Integration::KeyEvent::Down );
525   application.ProcessEvent( event3 );
526
527   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
528   DALI_TEST_CHECK( event3.keyModifier == data.receivedKeyEvent.keyModifier );
529   DALI_TEST_CHECK( event3.keyName == data.receivedKeyEvent.keyPressedName );
530   DALI_TEST_CHECK( event3.keyString == data.receivedKeyEvent.keyPressed );
531   DALI_TEST_CHECK( event3.state == static_cast<Integration::KeyEvent::State>(data.receivedKeyEvent.state) );
532
533   data.Reset();
534
535   Integration::KeyEvent event4( "a","a", 0, 0, 0, Integration::KeyEvent::Up );
536   application.ProcessEvent( event4 );
537
538   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
539   DALI_TEST_CHECK( event4.keyModifier == data.receivedKeyEvent.keyModifier );
540   DALI_TEST_CHECK( event4.keyName == data.receivedKeyEvent.keyPressedName );
541   DALI_TEST_CHECK( event4.keyString == data.receivedKeyEvent.keyPressed );
542   DALI_TEST_CHECK( event4.state == static_cast<Integration::KeyEvent::State>(data.receivedKeyEvent.state) );
543   END_TEST;
544 }
545
546 int UtcDaliStageTouchedSignal(void)
547 {
548   TestApplication application;
549   Stage stage = Stage::GetCurrent();
550
551   TouchedSignalData data;
552   TouchedFunctor functor( data );
553   stage.TouchedSignal().Connect( &application, functor );
554
555   // Render and notify
556   application.SendNotification();
557   application.Render();
558
559   // NO ACTORS, SINGLE TOUCH, DOWN, MOTION THEN UP
560   {
561     Integration::TouchEvent touchEvent;
562     touchEvent.points.push_back( TouchPoint( 0, TouchPoint::Down, 10.0f, 10.0f ) );
563     application.ProcessEvent( touchEvent );
564
565     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
566     DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0 );
567     DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
568     data.Reset();
569
570     touchEvent.points[0].state = TouchPoint::Motion;
571     touchEvent.points[0].screen.x = 12.0f; // Some motion
572     application.ProcessEvent( touchEvent );
573
574     DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
575     data.Reset();
576
577     touchEvent.points[0].state = TouchPoint::Up;
578     application.ProcessEvent( touchEvent );
579
580     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
581     DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0 );
582     DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
583     data.Reset();
584   }
585
586   // Add an actor to the scene
587
588   Actor actor = Actor::New();
589   actor.SetSize( 100.0f, 100.0f );
590   actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
591   actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
592   actor.TouchedSignal().Connect( &DummyTouchCallback );
593   stage.Add( actor );
594
595   // Render and notify
596   application.SendNotification();
597   application.Render();
598
599   // ACTOR ON SCENE, SINGLE TOUCH, DOWN IN ACTOR, MOTION THEN UP OUTSIDE ACTOR
600   {
601     Integration::TouchEvent touchEvent;
602     touchEvent.points.push_back( TouchPoint( 0, TouchPoint::Down, 10.0f, 10.0f ) );
603     application.ProcessEvent( touchEvent );
604
605     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
606     DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0 );
607     DALI_TEST_CHECK( data.receivedTouchEvent.points[0].hitActor == actor );
608     data.Reset();
609
610     touchEvent.points[0].state = TouchPoint::Motion;
611     touchEvent.points[0].screen.x = 150.0f; // Some motion
612     application.ProcessEvent( touchEvent );
613
614     DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
615     data.Reset();
616
617     touchEvent.points[0].state = TouchPoint::Up;
618     application.ProcessEvent( touchEvent );
619
620     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
621     DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0 );
622     DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
623     data.Reset();
624   }
625
626   // INTERRUPTED BEFORE DOWN AND INTERRUPTED AFTER DOWN
627   {
628     Integration::TouchEvent touchEvent;
629     touchEvent.points.push_back( TouchPoint( 0, TouchPoint::Interrupted, 10.0f, 10.0f ) );
630     application.ProcessEvent( touchEvent );
631
632     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
633     DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0 );
634     DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
635     DALI_TEST_CHECK( data.receivedTouchEvent.points[0].state == TouchPoint::Interrupted );
636     data.Reset();
637
638     touchEvent.points[0].state = TouchPoint::Down;
639     application.ProcessEvent( touchEvent );
640
641     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
642     DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0 );
643     DALI_TEST_CHECK( data.receivedTouchEvent.points[0].hitActor == actor );
644     DALI_TEST_CHECK( data.receivedTouchEvent.points[0].state == TouchPoint::Down );
645     data.Reset();
646
647     touchEvent.points[0].state = TouchPoint::Interrupted;
648     application.ProcessEvent( touchEvent );
649
650     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
651     DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0 );
652     DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
653     DALI_TEST_CHECK( data.receivedTouchEvent.points[0].state == TouchPoint::Interrupted );
654     data.Reset();
655   }
656
657   // MULTIPLE TOUCH, SHOULD ONLY RECEIVE TOUCH ON FIRST DOWN AND LAST UP
658   {
659     Integration::TouchEvent touchEvent;
660
661     // 1st point
662     touchEvent.points.push_back( TouchPoint( 0, TouchPoint::Down, 10.0f, 10.0f ) );
663     application.ProcessEvent( touchEvent );
664     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
665     data.Reset();
666
667     // 2nd point
668     touchEvent.points[0].state = TouchPoint::Stationary;
669     touchEvent.points.push_back( TouchPoint( 1, TouchPoint::Down, 50.0f, 50.0f ) );
670     application.ProcessEvent( touchEvent );
671     DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
672     data.Reset();
673
674     // Primary point is up
675     touchEvent.points[0].state = TouchPoint::Up;
676     touchEvent.points[1].state = TouchPoint::Stationary;
677     application.ProcessEvent( touchEvent );
678     DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
679     data.Reset();
680
681     // Remove 1st point now, 2nd point is now in motion
682     touchEvent.points.erase( touchEvent.points.begin() );
683     touchEvent.points[0].state = TouchPoint::Motion;
684     touchEvent.points[0].screen.x = 150.0f;
685     application.ProcessEvent( touchEvent );
686     DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
687     data.Reset();
688
689     // Final point Up
690     touchEvent.points[0].state = TouchPoint::Up;
691     application.ProcessEvent( touchEvent );
692     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
693     data.Reset();
694   }
695   END_TEST;
696 }
697
698 int UtcDaliStageSignalWheelEvent(void)
699 {
700   TestApplication application;
701   Stage stage = Stage::GetCurrent();
702
703   WheelEventSignalData data;
704   WheelEventReceivedFunctor functor( data );
705   stage.WheelEventSignal().Connect( &application, functor );
706
707   Integration::WheelEvent event( Integration::WheelEvent::CUSTOM_WHEEL, 0, 0u, Vector2( 0.0f, 0.0f ), 1, 1000u );
708   application.ProcessEvent( event );
709
710   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
711   DALI_TEST_CHECK( static_cast< WheelEvent::Type >(event.type) == data.receivedWheelEvent.type );
712   DALI_TEST_CHECK( event.direction == data.receivedWheelEvent.direction );
713   DALI_TEST_CHECK( event.modifiers == data.receivedWheelEvent.modifiers );
714   DALI_TEST_CHECK( event.point == data.receivedWheelEvent.point );
715   DALI_TEST_CHECK( event.z == data.receivedWheelEvent.z );
716   DALI_TEST_CHECK( event.timeStamp == data.receivedWheelEvent.timeStamp );
717
718   data.Reset();
719
720   Integration::WheelEvent event2( Integration::WheelEvent::CUSTOM_WHEEL, 0, 0u, Vector2( 0.0f, 0.0f ), -1, 1000u );
721   application.ProcessEvent( event2 );
722
723   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
724   DALI_TEST_CHECK( static_cast< WheelEvent::Type >(event2.type) == data.receivedWheelEvent.type );
725   DALI_TEST_CHECK( event2.direction == data.receivedWheelEvent.direction );
726   DALI_TEST_CHECK( event2.modifiers == data.receivedWheelEvent.modifiers );
727   DALI_TEST_CHECK( event2.point == data.receivedWheelEvent.point );
728   DALI_TEST_CHECK( event2.z == data.receivedWheelEvent.z );
729   DALI_TEST_CHECK( event2.timeStamp == data.receivedWheelEvent.timeStamp );
730   END_TEST;
731 }
732
733 int UtcDaliStageContextLostRegainedSignals(void)
734 {
735   TestApplication app;
736   Stage stage = Stage::GetCurrent();
737
738   bool contextLost = false;
739   bool contextRegained = false;
740   ContextStatusFunctor contextLostFunctor( contextLost );
741   ContextStatusFunctor contextRegainedFunctor( contextRegained );
742   stage.ContextLostSignal().Connect(&app, contextLostFunctor );
743   stage.ContextRegainedSignal().Connect(&app, contextRegainedFunctor );
744
745   Integration::Core& core = app.GetCore();
746   Integration::ContextNotifierInterface* notifier = core.GetContextNotifier();
747   notifier->NotifyContextLost();
748   DALI_TEST_EQUALS( contextLost, true, TEST_LOCATION );
749
750   notifier->NotifyContextRegained();
751   DALI_TEST_EQUALS( contextRegained, true, TEST_LOCATION );
752
753   END_TEST;
754 }
755
756 int UtcDaliStageSceneCreatedSignal(void)
757 {
758   TestApplication app;
759   Stage stage = Stage::GetCurrent();
760
761   bool signalCalled = false;
762   SceneCreatedStatusFunctor sceneCreatedFunctor( signalCalled );
763   stage.SceneCreatedSignal().Connect(&app, sceneCreatedFunctor );
764
765   Integration::Core& core = app.GetCore();
766   core.SceneCreated();
767   DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
768
769   END_TEST;
770 }