2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/dali-core.h>
23 #include <dali/devel-api/common/stage-devel.h>
24 #include <dali/integration-api/context-notifier.h>
25 #include <dali/integration-api/events/key-event-integ.h>
26 #include <dali/public-api/events/key-event.h>
27 #include <dali/integration-api/events/touch-event-integ.h>
28 #include <dali/integration-api/events/wheel-event-integ.h>
30 #include <dali-test-suite-utils.h>
34 void stage_test_startup(void)
36 test_return_value = TET_UNDEF;
39 void stage_test_cleanup(void)
41 test_return_value = TET_PASS;
47 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
48 const DevelKeyEvent::DeviceClass::Type DEFAULT_DEVICE_CLASS( DevelKeyEvent::DeviceClass::TOUCH );
50 // Functor for EventProcessingFinished signal
51 struct EventProcessingFinishedFunctor
54 * @param[in] eventProcessingFinished reference to a boolean variable used to check if signal has been called.
56 EventProcessingFinishedFunctor( bool& eventProcessingFinished )
57 : mEventProcessingFinished( eventProcessingFinished )
62 mEventProcessingFinished = true;
65 bool& mEventProcessingFinished;
68 // Stores data that is populated in the KeyEventGeneratedSignal callback and will be read by the TET cases
69 struct KeyEventGeneratedSignalData
71 KeyEventGeneratedSignalData()
72 : functorCalled(false)
77 functorCalled = false;
79 receivedKeyEvent.keyModifier = 0;
80 receivedKeyEvent.keyPressedName.clear();
81 receivedKeyEvent.keyPressed.clear();
85 KeyEvent receivedKeyEvent;
88 // Functor that sets the data when called
89 struct KeyEventGeneratedReceivedFunctor
91 KeyEventGeneratedReceivedFunctor( KeyEventGeneratedSignalData& data )
95 bool operator()( const KeyEvent& keyEvent )
97 signalData.functorCalled = true;
98 signalData.receivedKeyEvent = keyEvent;
105 signalData.functorCalled = true;
109 KeyEventGeneratedSignalData& signalData;
112 // Stores data that is populated in the key-event callback and will be read by the TET cases
113 struct KeyEventSignalData
116 : functorCalled(false)
121 functorCalled = false;
123 receivedKeyEvent.keyModifier = 0;
124 receivedKeyEvent.keyPressedName.clear();
125 receivedKeyEvent.keyPressed.clear();
129 KeyEvent receivedKeyEvent;
132 // Functor that sets the data when called
133 struct KeyEventReceivedFunctor
135 KeyEventReceivedFunctor( KeyEventSignalData& data ) : signalData( data ) { }
137 bool operator()( const KeyEvent& keyEvent )
139 signalData.functorCalled = true;
140 signalData.receivedKeyEvent = keyEvent;
145 KeyEventSignalData& signalData;
148 // Stores data that is populated in the touched signal callback and will be read by the TET cases
149 struct TouchedSignalData
152 : functorCalled(false)
157 functorCalled = false;
159 receivedTouchEvent.points.clear();
160 receivedTouchEvent.time = 0;
162 receivedTouchData.Reset();
166 TouchEvent receivedTouchEvent;
167 TouchData receivedTouchData;
170 // Functor that sets the data when touched signal is received
171 struct TouchedFunctor
173 TouchedFunctor( TouchedSignalData& data ) : signalData( data ) { }
175 void operator()( const TouchEvent& touch )
177 signalData.functorCalled = true;
178 signalData.receivedTouchEvent = touch;
181 TouchedSignalData& signalData;
185 // Functor that sets the data when touched signal is received
188 TouchFunctor( TouchedSignalData& data ) : signalData( data ) { }
190 void operator()( const TouchData& touch )
192 signalData.functorCalled = true;
193 signalData.receivedTouchData = touch;
198 signalData.functorCalled = true;
201 TouchedSignalData& signalData;
204 // Stores data that is populated in the wheel-event callback and will be read by the TET cases
205 struct WheelEventSignalData
207 WheelEventSignalData()
208 : functorCalled(false)
213 functorCalled = false;
217 WheelEvent receivedWheelEvent;
220 // Functor that sets the data when wheel-event signal is received
221 struct WheelEventReceivedFunctor
223 WheelEventReceivedFunctor( WheelEventSignalData& data ) : signalData( data ) { }
225 bool operator()( const WheelEvent& wheelEvent )
227 signalData.functorCalled = true;
228 signalData.receivedWheelEvent = wheelEvent;
233 WheelEventSignalData& signalData;
236 bool DummyTouchCallback( Actor actor, const TouchEvent& touch )
241 struct ContextStatusFunctor
243 ContextStatusFunctor(bool& calledFlag) : mCalledFlag( calledFlag )
260 struct SceneCreatedStatusFunctor
262 SceneCreatedStatusFunctor(bool& calledFlag) : mCalledFlag( calledFlag )
279 struct ActorCreatedFunctor
281 ActorCreatedFunctor( bool& signalReceived )
282 : mSignalVerified( signalReceived )
286 void operator()( BaseHandle object )
288 tet_infoline( "Verifying TestActorCallback()" );
289 Actor actor = Actor::DownCast( object );
292 mSignalVerified = true;
296 bool& mSignalVerified;
299 void GenerateTouch( TestApplication& application, PointState::Type state, const Vector2& screenPosition )
301 Integration::TouchEvent touchEvent;
302 Integration::Point point;
303 point.SetState( state );
304 point.SetScreenPosition( screenPosition );
305 touchEvent.points.push_back( point );
306 application.ProcessEvent( touchEvent );
309 } // unnamed namespace
312 int UtcDaliStageDefaultConstructorP(void)
314 TestApplication application;
317 DALI_TEST_CHECK( !stage );
321 // Note: No negative test for default constructor.
323 int UtcDaliStageDestructorP(void)
325 TestApplication application;
326 Stage* stage = new Stage();
330 DALI_TEST_CHECK( true );
334 // Note: No negative test for default destructor.
336 int UtcDaliStageGetCurrentP(void)
338 TestApplication application;
339 Stage stage = Stage::GetCurrent();
341 DALI_TEST_CHECK( stage );
345 int UtcDaliStageGetCurrentN(void)
347 bool asserted = false;
350 Stage stage = Stage::GetCurrent();
352 catch( Dali::DaliException& e )
354 DALI_TEST_PRINT_ASSERT( e );
355 DALI_TEST_ASSERT( e, "stage && \"Stage doesn't exist\"", TEST_LOCATION );
359 DALI_TEST_CHECK( asserted );
363 int UtcDaliStageIsInstalledP(void)
365 TestApplication application;
369 DALI_TEST_CHECK( Stage::IsInstalled() );
373 int UtcDaliStageIsInstalledN(void)
375 DALI_TEST_CHECK( !Stage::IsInstalled() );
380 int UtcDaliStageCopyConstructorP(void)
382 TestApplication application;
383 Stage stage = Stage::GetCurrent();
385 Stage copyStage( stage );
387 DALI_TEST_CHECK( copyStage );
388 DALI_TEST_CHECK( copyStage.GetRootLayer() == stage.GetRootLayer() );
393 // Note: no negative test for UtcDaliStageCopyConstructor.
395 int UtcDaliStageAssignmentOperatorP(void)
397 TestApplication application;
398 const Stage stage = Stage::GetCurrent();
400 Stage copyStage = stage;
402 DALI_TEST_CHECK( copyStage );
403 DALI_TEST_CHECK( copyStage.GetRootLayer() == stage.GetRootLayer() );
408 // Note: No negative test for UtcDaliStageAssignmentOperator.
410 int UtcDaliStageAddP(void)
412 TestApplication application;
414 Stage stage = Stage::GetCurrent();
416 Actor actor = Actor::New();
417 DALI_TEST_CHECK( !actor.OnStage() );
420 DALI_TEST_CHECK( actor.OnStage() );
424 int UtcDaliStageAddN(void)
426 TestApplication application;
428 Stage stage = Stage::GetCurrent();
431 bool asserted = false;
436 catch( Dali::DaliException& e )
438 DALI_TEST_PRINT_ASSERT( e );
439 DALI_TEST_ASSERT( e, "actor && \"Actor handle is empty\"", TEST_LOCATION );
443 DALI_TEST_CHECK( asserted );
448 int UtcDaliStageRemoveP(void)
450 TestApplication application;
452 Stage stage = Stage::GetCurrent();
454 Actor actor = Actor::New();
455 DALI_TEST_CHECK( !actor.OnStage() );
458 DALI_TEST_CHECK( actor.OnStage() );
461 DALI_TEST_CHECK( !actor.OnStage() );
465 int UtcDaliStageRemoveN1(void)
467 TestApplication application;
469 Stage stage = Stage::GetCurrent();
472 bool asserted = false;
475 // Actor is not valid, confirm a removal attempt does assert.
476 stage.Remove( actor );
478 catch( Dali::DaliException& e )
480 DALI_TEST_PRINT_ASSERT( e );
481 DALI_TEST_ASSERT( e, "actor && \"Actor handle is empty\"", TEST_LOCATION );
485 DALI_TEST_CHECK( asserted );
489 int UtcDaliStageRemoveN2(void)
491 TestApplication application;
493 Stage stage = Stage::GetCurrent();
494 Actor actor = Actor::New();
495 DALI_TEST_CHECK( !actor.OnStage() );
497 bool asserted = false;
500 // Actor is not on stage, confirm a removal attempt does not assert / segfault.
501 stage.Remove( actor );
503 catch( Dali::DaliException& e )
505 DALI_TEST_PRINT_ASSERT( e );
509 DALI_TEST_CHECK( !asserted );
513 int UtcDaliStageRemoveN3(void)
515 TestApplication application;
517 Stage stage = Stage::GetCurrent();
519 // Initially we have a default layer
520 DALI_TEST_EQUALS( stage.GetLayerCount(), 1u, TEST_LOCATION );
522 // Check we cannot remove the root layer from the stage.
523 Layer layer = stage.GetRootLayer();
524 bool asserted = true;
527 stage.Remove( layer );
529 catch( Dali::DaliException& e )
531 DALI_TEST_PRINT_ASSERT( e );
532 DALI_TEST_ASSERT( e, "this != &child && \"Cannot remove actor from itself\"", TEST_LOCATION );
536 DALI_TEST_CHECK( asserted );
537 DALI_TEST_EQUALS( stage.GetLayerCount(), 1u, TEST_LOCATION );
541 int UtcDaliStageGetSizeP(void)
543 TestApplication application;
545 Stage stage = Stage::GetCurrent();
547 Vector2 size = stage.GetSize();
549 DALI_TEST_EQUALS( size.width, static_cast<float>( TestApplication::DEFAULT_SURFACE_WIDTH ), TEST_LOCATION );
550 DALI_TEST_EQUALS( size.height, static_cast<float>( TestApplication::DEFAULT_SURFACE_HEIGHT ), TEST_LOCATION );
554 int UtcDaliStageGetSizeN(void)
556 TestApplication application;
560 bool asserted = false;
564 size = stage.GetSize();
566 catch( Dali::DaliException& e )
568 DALI_TEST_PRINT_ASSERT( e );
569 DALI_TEST_ASSERT( e, "stage && \"Stage handle is empty\"", TEST_LOCATION );
573 DALI_TEST_CHECK( asserted );
577 int UtcDaliStageGetDpiP1(void)
579 TestApplication application; // Initializes core DPI to default values
581 Stage stage = Stage::GetCurrent();
583 // Test the default DPI.
584 Vector2 dpi = stage.GetDpi();
585 DALI_TEST_EQUALS( dpi.x, static_cast<float>( TestApplication::DEFAULT_HORIZONTAL_DPI ), TEST_LOCATION );
586 DALI_TEST_EQUALS( dpi.y, static_cast<float>( TestApplication::DEFAULT_VERTICAL_DPI ), TEST_LOCATION );
590 int UtcDaliStageGetDpiP2(void)
592 TestApplication application; // Initializes core DPI to default values
594 // Test that setting core DPI explicitly also sets up the Stage's DPI.
595 application.GetCore().SetDpi( 200, 180 );
597 Stage stage = Stage::GetCurrent();
598 Vector2 dpi = stage.GetDpi();
599 DALI_TEST_EQUALS( dpi.x, 200.0f, TEST_LOCATION );
600 DALI_TEST_EQUALS( dpi.y, 180.0f, TEST_LOCATION );
604 int UtcDaliStageGetDpiP3(void)
606 TestApplication application( 480, 800, 72.0f, 120.0f ); // Initializes core DPI with specific values
608 Stage stage = Stage::GetCurrent();
610 // Test that setting core DPI explicitly also sets up the Stage's DPI.
611 Vector2 dpi = stage.GetDpi();
612 DALI_TEST_EQUALS( dpi.x, 72.0f, TEST_LOCATION );
613 DALI_TEST_EQUALS( dpi.y, 120.0f, TEST_LOCATION) ;
618 * This is not a true negative test, we are checking the DPI if it has not been set.
619 * A test for setting negative DPI values would be part of the application core utc tests.
621 int UtcDaliStageGetDpiN(void)
623 TestApplication application; // Initializes core DPI to default values
625 Stage stage = Stage::GetCurrent();
626 Vector2 dpi = stage.GetDpi();
628 DALI_TEST_EQUALS( dpi.x, 220.0f, TEST_LOCATION );
629 DALI_TEST_EQUALS( dpi.y, 217.0f, TEST_LOCATION );
633 int UtcDaliStageGetLayerCountP(void)
635 TestApplication application;
637 Stage stage = Stage::GetCurrent();
639 // Initially we have a default layer
640 DALI_TEST_EQUALS( stage.GetLayerCount(), 1u, TEST_LOCATION );
642 Layer layer = Layer::New();
645 DALI_TEST_EQUALS( stage.GetLayerCount(), 2u, TEST_LOCATION );
650 * Not a true negative test, but confirms layer count is not affected by an invalid removal.
652 int UtcDaliStageGetLayerCountN(void)
654 TestApplication application;
656 Stage stage = Stage::GetCurrent();
658 // Initially we have a default layer
659 DALI_TEST_EQUALS( stage.GetLayerCount(), 1u, TEST_LOCATION );
661 Layer layer = Layer::New();
662 stage.Remove( layer );
664 // Still have 1 layer.
665 DALI_TEST_EQUALS( stage.GetLayerCount(), 1u, TEST_LOCATION );
669 int UtcDaliStageGetLayerP(void)
671 TestApplication application;
673 Stage stage = Stage::GetCurrent();
675 Layer rootLayer = stage.GetLayer( 0 );
676 DALI_TEST_CHECK( rootLayer );
678 Layer layer = Layer::New();
681 Layer sameLayer = stage.GetLayer( 1 );
682 DALI_TEST_CHECK( layer == sameLayer );
686 int UtcDaliStageGetLayerN(void)
688 TestApplication application;
690 Stage stage = Stage::GetCurrent();
692 bool asserted = false;
695 // Try to get a layer that doesn't exist (note: 0 is the root layer).
696 Layer layer = stage.GetLayer( 1 );
698 catch( Dali::DaliException& e )
700 DALI_TEST_PRINT_ASSERT( e );
701 DALI_TEST_ASSERT( e, "depth < mLayers.size()", TEST_LOCATION );
705 DALI_TEST_CHECK( asserted );
709 int UtcDaliStageGetRootLayerP(void)
711 TestApplication application;
713 Stage stage = Stage::GetCurrent();
715 Layer layer = stage.GetLayer( 0 );
716 DALI_TEST_CHECK( layer );
718 // Check that GetRootLayer() correctly retreived layer 0.
719 DALI_TEST_CHECK( stage.GetRootLayer() == layer );
724 int UtcDaliStageGetRootLayerN(void)
726 TestApplication application;
728 Stage stage = Stage::GetCurrent();
730 Layer rootLayer = stage.GetLayer( 0 );
731 DALI_TEST_CHECK( rootLayer );
732 DALI_TEST_CHECK( stage.GetRootLayer() == rootLayer );
734 // Create a new layer and attempt to lower it below the root layer.
735 Layer layer = Layer::New();
737 layer.LowerToBottom();
739 // Check that GetRootLayer still retrieves the same original layer.
740 DALI_TEST_CHECK( stage.GetRootLayer() == rootLayer );
742 // Check modifying the root layer is also blocked.
743 rootLayer.RaiseToTop();
744 DALI_TEST_CHECK( stage.GetRootLayer() == rootLayer );
749 int UtcDaliStageSetBackgroundColorP(void)
751 TestApplication application;
753 Stage stage = Stage::GetCurrent();
755 Vector4 testColor( 0.1f, 0.2f, 0.3f, 1.0f );
756 stage.SetBackgroundColor( testColor );
758 DALI_TEST_EQUALS( testColor, stage.GetBackgroundColor(), TEST_LOCATION );
762 // Note: No negative test for UtcDaliStageSetBackgroundColor as we do not wish to implement
763 // range checking for colors due to speed. Colors are clamped with glclampf within GL anyway.
765 int UtcDaliStageGetBackgroundColorP(void)
767 TestApplication application;
769 Stage stage = Stage::GetCurrent();
771 DALI_TEST_EQUALS( Stage::DEFAULT_BACKGROUND_COLOR, stage.GetBackgroundColor(), TEST_LOCATION );
775 // Note: No negative test for UtcDaliStageGetBackgroundColor as this is covered by UtcDaliStageSetBackgroundColorN.
777 int UtcDaliStageKeepRenderingP(void)
779 TestApplication application;
781 Stage stage = Stage::GetCurrent();
783 // Run core until it wants to sleep
784 bool keepUpdating( true );
785 while ( keepUpdating )
787 application.SendNotification();
788 keepUpdating = application.Render( 1000.0f /*1 second*/ );
791 // Force rendering for the next 5 seconds
792 stage.KeepRendering( 5.0f );
794 application.SendNotification();
796 // Test that core wants to sleep after 10 seconds
797 keepUpdating = application.Render( 1000.0f /*1 second*/ );
798 DALI_TEST_CHECK( keepUpdating );
799 keepUpdating = application.Render( 1000.0f /*2 seconds*/ );
800 DALI_TEST_CHECK( keepUpdating );
801 keepUpdating = application.Render( 1000.0f /*3 seconds*/ );
802 DALI_TEST_CHECK( keepUpdating );
803 keepUpdating = application.Render( 1000.0f /*4 seconds*/ );
804 DALI_TEST_CHECK( keepUpdating );
805 keepUpdating = application.Render( 1000.0f /*5 seconds*/ );
806 DALI_TEST_CHECK( !keepUpdating );
810 int UtcDaliStageKeepRenderingN(void)
812 TestApplication application;
814 Stage stage = Stage::GetCurrent();
816 // Run core until it wants to sleep
817 bool keepUpdating( true );
818 while ( keepUpdating )
820 application.SendNotification();
821 keepUpdating = application.Render( 1000.0f /*1 second*/ );
824 // Force rendering for the next 5 seconds
825 stage.KeepRendering( -1.0f );
827 application.SendNotification();
829 // Test that core wants to sleep after 10 seconds
830 keepUpdating = application.Render( 1000.0f /*1 second*/ );
831 DALI_TEST_CHECK( !keepUpdating );
836 int UtcDaliStageEventProcessingFinishedP(void)
838 TestApplication application;
839 Stage stage = Stage::GetCurrent();
841 bool eventProcessingFinished = false;
842 EventProcessingFinishedFunctor functor( eventProcessingFinished );
843 stage.EventProcessingFinishedSignal().Connect( &application, functor );
845 Actor actor( Actor::New() );
848 application.SendNotification();
849 application.Render();
851 DALI_TEST_CHECK( eventProcessingFinished );
856 int UtcDaliStageEventProcessingFinishedN(void)
858 TestApplication application;
859 Stage stage = Stage::GetCurrent();
861 bool eventProcessingFinished = false;
862 EventProcessingFinishedFunctor functor( eventProcessingFinished );
863 stage.EventProcessingFinishedSignal().Connect( &application, functor );
865 Actor actor( Actor::New() );
868 // Do not complete event processing and confirm the signal has not been emitted.
869 DALI_TEST_CHECK( !eventProcessingFinished );
874 int UtcDaliStageKeyEventGeneratedSignalP(void)
876 TestApplication application;
877 Stage stage = Stage::GetCurrent();
879 KeyEventGeneratedSignalData data;
880 KeyEventGeneratedReceivedFunctor functor( data );
881 DevelStage::KeyEventGeneratedSignal( stage ).Connect( &application, functor );
883 KeyEventGeneratedSignalData data2;
884 KeyEventGeneratedReceivedFunctor functor2( data2 );
885 GetImplementation( stage ).ConnectSignal( &application, "keyEventGenerated", functor2 );
887 Integration::KeyEvent event( "a", "a", 0, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DEFAULT_DEVICE_CLASS );
888 application.ProcessEvent( event );
890 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
891 DALI_TEST_CHECK( event.keyModifier == data.receivedKeyEvent.keyModifier );
892 DALI_TEST_CHECK( event.keyName == data.receivedKeyEvent.keyPressedName );
893 DALI_TEST_CHECK( event.keyString == data.receivedKeyEvent.keyPressed );
894 DALI_TEST_CHECK( event.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
898 Integration::KeyEvent event2( "i", "i", 0, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DEFAULT_DEVICE_CLASS );
899 application.ProcessEvent( event2 );
901 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
902 DALI_TEST_CHECK( event2.keyModifier == data.receivedKeyEvent.keyModifier );
903 DALI_TEST_CHECK( event2.keyName == data.receivedKeyEvent.keyPressedName );
904 DALI_TEST_CHECK( event2.keyString == data.receivedKeyEvent.keyPressed );
905 DALI_TEST_CHECK( event2.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
909 Integration::KeyEvent event3( "a", "a", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DEFAULT_DEVICE_CLASS );
910 application.ProcessEvent( event3 );
912 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
913 DALI_TEST_CHECK( event3.keyModifier == data.receivedKeyEvent.keyModifier );
914 DALI_TEST_CHECK( event3.keyName == data.receivedKeyEvent.keyPressedName );
915 DALI_TEST_CHECK( event3.keyString == data.receivedKeyEvent.keyPressed );
916 DALI_TEST_CHECK( event3.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
920 Integration::KeyEvent event4( "a", "a", 0, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DEFAULT_DEVICE_CLASS );
921 application.ProcessEvent( event4 );
923 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
924 DALI_TEST_CHECK( event4.keyModifier == data.receivedKeyEvent.keyModifier );
925 DALI_TEST_CHECK( event4.keyName == data.receivedKeyEvent.keyPressedName );
926 DALI_TEST_CHECK( event4.keyString == data.receivedKeyEvent.keyPressed );
927 DALI_TEST_CHECK( event4.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
931 int UtcDaliStageSignalKeyEventP(void)
933 TestApplication application;
934 Stage stage = Stage::GetCurrent();
936 KeyEventSignalData data;
937 KeyEventReceivedFunctor functor( data );
938 stage.KeyEventSignal().Connect( &application, functor );
940 Integration::KeyEvent event( "i", "i", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DEFAULT_DEVICE_CLASS );
941 application.ProcessEvent( event );
943 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
944 DALI_TEST_CHECK( event.keyModifier == data.receivedKeyEvent.keyModifier );
945 DALI_TEST_CHECK( event.keyName == data.receivedKeyEvent.keyPressedName );
946 DALI_TEST_CHECK( event.keyString == data.receivedKeyEvent.keyPressed );
947 DALI_TEST_CHECK( event.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
951 Integration::KeyEvent event2( "i", "i", 0, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DEFAULT_DEVICE_CLASS );
952 application.ProcessEvent( event2 );
954 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
955 DALI_TEST_CHECK( event2.keyModifier == data.receivedKeyEvent.keyModifier );
956 DALI_TEST_CHECK( event2.keyName == data.receivedKeyEvent.keyPressedName );
957 DALI_TEST_CHECK( event2.keyString == data.receivedKeyEvent.keyPressed );
958 DALI_TEST_CHECK( event2.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
962 Integration::KeyEvent event3( "a", "a", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DEFAULT_DEVICE_CLASS );
963 application.ProcessEvent( event3 );
965 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
966 DALI_TEST_CHECK( event3.keyModifier == data.receivedKeyEvent.keyModifier );
967 DALI_TEST_CHECK( event3.keyName == data.receivedKeyEvent.keyPressedName );
968 DALI_TEST_CHECK( event3.keyString == data.receivedKeyEvent.keyPressed );
969 DALI_TEST_CHECK( event3.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
973 Integration::KeyEvent event4( "a", "a", 0, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DEFAULT_DEVICE_CLASS );
974 application.ProcessEvent( event4 );
976 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
977 DALI_TEST_CHECK( event4.keyModifier == data.receivedKeyEvent.keyModifier );
978 DALI_TEST_CHECK( event4.keyName == data.receivedKeyEvent.keyPressedName );
979 DALI_TEST_CHECK( event4.keyString == data.receivedKeyEvent.keyPressed );
980 DALI_TEST_CHECK( event4.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
984 int UtcDaliStageSignalKeyEventN(void)
986 TestApplication application;
987 Stage stage = Stage::GetCurrent();
989 KeyEventSignalData data;
990 KeyEventReceivedFunctor functor( data );
991 stage.KeyEventSignal().Connect( &application, functor );
993 // Check that a non-pressed key events data is not modified.
994 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
999 int UtcDaliStageTouchedSignalP(void)
1001 TestApplication application;
1002 Stage stage = Stage::GetCurrent();
1004 TouchedSignalData data;
1005 TouchedFunctor functor( data );
1006 stage.TouchedSignal().Connect( &application, functor );
1008 // Render and notify.
1009 application.SendNotification();
1010 application.Render();
1012 // Basic test: No actors, single touch (down then up).
1014 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1016 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1017 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1018 DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
1021 GenerateTouch( application, PointState::UP, Vector2( 10.0f, 10.0f ) );
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 );
1029 // Add an actor to the scene.
1030 Actor actor = Actor::New();
1031 actor.SetSize( 100.0f, 100.0f );
1032 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1033 actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1034 actor.TouchedSignal().Connect( &DummyTouchCallback );
1037 // Render and notify.
1038 application.SendNotification();
1039 application.Render();
1041 // Actor on scene, single touch, down in actor, motion, then up outside actor.
1043 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1045 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1046 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1047 DALI_TEST_CHECK( data.receivedTouchEvent.points[0].hitActor == actor );
1050 GenerateTouch( application, PointState::MOTION, Vector2( 150.0f, 10.0f ) ); // Some motion
1052 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1055 GenerateTouch( application, PointState::UP, Vector2( 150.0f, 10.0f ) ); // Some motion
1057 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1058 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1059 DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
1063 // Multiple touch. Should only receive a touch on first down and last up.
1065 Integration::TouchEvent touchEvent;
1066 Integration::Point point;
1069 point.SetState( PointState::DOWN );
1070 point.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
1071 touchEvent.points.push_back( point );
1072 application.ProcessEvent( touchEvent );
1073 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1074 DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 1u, TEST_LOCATION );
1078 touchEvent.points[0].SetState( PointState::STATIONARY );
1079 point.SetDeviceId( 1 );
1080 point.SetScreenPosition( Vector2( 50.0f, 50.0f ) );
1081 touchEvent.points.push_back( point );
1082 application.ProcessEvent( touchEvent );
1083 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1084 DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 0u, TEST_LOCATION );
1087 // Primary point is up
1088 touchEvent.points[0].SetState( PointState::UP );
1089 touchEvent.points[1].SetState( PointState::STATIONARY );
1090 application.ProcessEvent( touchEvent );
1091 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1092 DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 0u, TEST_LOCATION );
1095 // Remove 1st point now, 2nd point is now in motion
1096 touchEvent.points.erase( touchEvent.points.begin() );
1097 touchEvent.points[0].SetState( PointState::MOTION );
1098 touchEvent.points[0].SetScreenPosition( Vector2( 150.0f, 50.0f ) );
1099 application.ProcessEvent( touchEvent );
1100 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1101 DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 0u, TEST_LOCATION );
1105 touchEvent.points[0].SetState( PointState::UP );
1106 application.ProcessEvent( touchEvent );
1107 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1108 DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 1u, TEST_LOCATION );
1114 int UtcDaliStageTouchedSignalN(void)
1116 TestApplication application;
1117 Stage stage = Stage::GetCurrent();
1119 TouchedSignalData data;
1120 TouchedFunctor functor( data );
1121 stage.TouchedSignal().Connect( &application, functor );
1123 // Render and notify.
1124 application.SendNotification();
1125 application.Render();
1127 // Confirm functor not called before there has been any touch event.
1128 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1130 // No actors, single touch, down, motion then up.
1132 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1134 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1135 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1136 DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
1139 // Confirm there is no signal when the touchpoint is only moved.
1140 GenerateTouch( application, PointState::MOTION, Vector2( 1200.0f, 10.0f ) ); // Some motion
1142 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1145 // Confirm a following up event generates a signal.
1146 GenerateTouch( application, PointState::UP, Vector2( 1200.0f, 10.0f ) );
1148 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1149 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1150 DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
1154 // Add an actor to the scene.
1155 Actor actor = Actor::New();
1156 actor.SetSize( 100.0f, 100.0f );
1157 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1158 actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1159 actor.TouchedSignal().Connect( &DummyTouchCallback );
1162 // Render and notify.
1163 application.SendNotification();
1164 application.Render();
1166 // Actor on scene. Interrupted before down and interrupted after down.
1168 GenerateTouch( application, PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) );
1170 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1171 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1172 DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
1173 DALI_TEST_CHECK( data.receivedTouchEvent.points[0].state == TouchPoint::Interrupted );
1176 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1178 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1179 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1180 DALI_TEST_CHECK( data.receivedTouchEvent.points[0].hitActor == actor );
1181 DALI_TEST_CHECK( data.receivedTouchEvent.points[0].state == TouchPoint::Down );
1184 GenerateTouch( application, PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) );
1186 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1187 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1188 DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
1189 DALI_TEST_CHECK( data.receivedTouchEvent.points[0].state == TouchPoint::Interrupted );
1191 DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 1u, TEST_LOCATION );
1193 // Check that getting info about a non-existent point causes an assert.
1194 bool asserted = false;
1197 data.receivedTouchEvent.GetPoint( 1 );
1199 catch( Dali::DaliException& e )
1201 DALI_TEST_PRINT_ASSERT( e );
1202 DALI_TEST_ASSERT( e, "point < points.size() && \"No point at index\"", TEST_LOCATION );
1205 DALI_TEST_CHECK( asserted );
1214 int UtcDaliStageTouchSignalP(void)
1216 TestApplication application;
1217 Stage stage = Stage::GetCurrent();
1219 TouchedSignalData data;
1220 TouchFunctor functor( data );
1221 stage.TouchSignal().Connect( &application, functor );
1223 // Render and notify.
1224 application.SendNotification();
1225 application.Render();
1227 // Basic test: No actors, single touch (down then up).
1229 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1231 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1232 DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1233 DALI_TEST_CHECK( !data.receivedTouchData.GetHitActor(0) );
1236 GenerateTouch( application, PointState::UP, Vector2( 10.0f, 10.0f ) );
1238 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1239 DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1240 DALI_TEST_CHECK( !data.receivedTouchData.GetHitActor(0) );
1244 // Add an actor to the scene.
1245 Actor actor = Actor::New();
1246 actor.SetSize( 100.0f, 100.0f );
1247 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1248 actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1249 actor.TouchedSignal().Connect( &DummyTouchCallback );
1252 // Render and notify.
1253 application.SendNotification();
1254 application.Render();
1256 // Actor on scene, single touch, down in actor, motion, then up outside actor.
1258 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1260 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1261 DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1262 DALI_TEST_CHECK( data.receivedTouchData.GetHitActor(0) == actor );
1265 GenerateTouch( application, PointState::MOTION, Vector2( 150.0f, 10.0f ) ); // Some motion
1267 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1270 GenerateTouch( application, PointState::UP, Vector2( 150.0f, 10.0f ) ); // Some motion
1272 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1273 DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1274 DALI_TEST_CHECK( !data.receivedTouchData.GetHitActor(0) );
1278 // Multiple touch. Should only receive a touch on first down and last up.
1280 Integration::TouchEvent touchEvent;
1281 Integration::Point point;
1284 point.SetState( PointState::DOWN );
1285 point.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
1286 touchEvent.points.push_back( point );
1287 application.ProcessEvent( touchEvent );
1288 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1289 DALI_TEST_EQUALS( data.receivedTouchData.GetPointCount(), 1u, TEST_LOCATION );
1293 touchEvent.points[0].SetState( PointState::STATIONARY );
1294 point.SetDeviceId( 1 );
1295 point.SetScreenPosition( Vector2( 50.0f, 50.0f ) );
1296 touchEvent.points.push_back( point );
1297 application.ProcessEvent( touchEvent );
1298 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1301 // Primary point is up
1302 touchEvent.points[0].SetState( PointState::UP );
1303 touchEvent.points[1].SetState( PointState::STATIONARY );
1304 application.ProcessEvent( touchEvent );
1305 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1308 // Remove 1st point now, 2nd point is now in motion
1309 touchEvent.points.erase( touchEvent.points.begin() );
1310 touchEvent.points[0].SetState( PointState::MOTION );
1311 touchEvent.points[0].SetScreenPosition( Vector2( 150.0f, 50.0f ) );
1312 application.ProcessEvent( touchEvent );
1313 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1317 touchEvent.points[0].SetState( PointState::UP );
1318 application.ProcessEvent( touchEvent );
1319 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1320 DALI_TEST_EQUALS( data.receivedTouchData.GetPointCount(), 1u, TEST_LOCATION );
1326 int UtcDaliStageTouchSignalN(void)
1328 TestApplication application;
1329 Stage stage = Stage::GetCurrent();
1331 TouchedSignalData data;
1332 TouchFunctor functor( data );
1333 stage.TouchSignal().Connect( &application, functor );
1335 TouchedSignalData data2;
1336 TouchFunctor functor2( data2 );
1337 GetImplementation( stage ).ConnectSignal( &application, "touch", functor2 );
1339 // Render and notify.
1340 application.SendNotification();
1341 application.Render();
1343 // Confirm functor not called before there has been any touch event.
1344 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1345 DALI_TEST_EQUALS( false, data2.functorCalled, TEST_LOCATION );
1347 // No actors, single touch, down, motion then up.
1349 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1351 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1352 DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1353 DALI_TEST_CHECK( !data.receivedTouchData.GetHitActor(0));
1355 DALI_TEST_EQUALS( true, data2.functorCalled, TEST_LOCATION );
1360 // Confirm there is no signal when the touchpoint is only moved.
1361 GenerateTouch( application, PointState::MOTION, Vector2( 1200.0f, 10.0f ) ); // Some motion
1363 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1366 // Confirm a following up event generates a signal.
1367 GenerateTouch( application, PointState::UP, Vector2( 1200.0f, 10.0f ) );
1369 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1370 DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1371 DALI_TEST_CHECK( !data.receivedTouchData.GetHitActor(0));
1375 // Add an actor to the scene.
1376 Actor actor = Actor::New();
1377 actor.SetSize( 100.0f, 100.0f );
1378 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1379 actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1380 actor.TouchedSignal().Connect( &DummyTouchCallback );
1383 // Render and notify.
1384 application.SendNotification();
1385 application.Render();
1387 // Actor on scene. Interrupted before down and interrupted after down.
1389 GenerateTouch( application, PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) );
1391 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1392 DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1393 DALI_TEST_CHECK( !data.receivedTouchData.GetHitActor(0) );
1394 DALI_TEST_CHECK( data.receivedTouchData.GetState(0) == PointState::INTERRUPTED );
1397 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1399 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1400 DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1401 DALI_TEST_CHECK( data.receivedTouchData.GetHitActor(0) == actor );
1402 DALI_TEST_CHECK( data.receivedTouchData.GetState(0) == PointState::DOWN );
1405 GenerateTouch( application, PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) );
1407 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1408 DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1409 DALI_TEST_CHECK( !data.receivedTouchData.GetHitActor(0) );
1410 DALI_TEST_CHECK( data.receivedTouchData.GetState(0) == PointState::INTERRUPTED );
1412 DALI_TEST_EQUALS( data.receivedTouchData.GetPointCount(), 1u, TEST_LOCATION );
1414 // Check that getting info about a non-existent point returns an empty handle
1415 Actor actor = data.receivedTouchData.GetHitActor( 1 );
1416 DALI_TEST_CHECK( !actor );
1424 int UtcDaliStageSignalWheelEventP(void)
1426 TestApplication application;
1427 Stage stage = Stage::GetCurrent();
1429 WheelEventSignalData data;
1430 WheelEventReceivedFunctor functor( data );
1431 stage.WheelEventSignal().Connect( &application, functor );
1433 Integration::WheelEvent event( Integration::WheelEvent::CUSTOM_WHEEL, 0, 0u, Vector2( 0.0f, 0.0f ), 1, 1000u );
1434 application.ProcessEvent( event );
1436 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1437 DALI_TEST_CHECK( static_cast< WheelEvent::Type >(event.type) == data.receivedWheelEvent.type );
1438 DALI_TEST_CHECK( event.direction == data.receivedWheelEvent.direction );
1439 DALI_TEST_CHECK( event.modifiers == data.receivedWheelEvent.modifiers );
1440 DALI_TEST_CHECK( event.point == data.receivedWheelEvent.point );
1441 DALI_TEST_CHECK( event.z == data.receivedWheelEvent.z );
1442 DALI_TEST_CHECK( event.timeStamp == data.receivedWheelEvent.timeStamp );
1446 Integration::WheelEvent event2( Integration::WheelEvent::CUSTOM_WHEEL, 0, 0u, Vector2( 0.0f, 0.0f ), -1, 1000u );
1447 application.ProcessEvent( event2 );
1449 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1450 DALI_TEST_CHECK( static_cast< WheelEvent::Type >(event2.type) == data.receivedWheelEvent.type );
1451 DALI_TEST_CHECK( event2.direction == data.receivedWheelEvent.direction );
1452 DALI_TEST_CHECK( event2.modifiers == data.receivedWheelEvent.modifiers );
1453 DALI_TEST_CHECK( event2.point == data.receivedWheelEvent.point );
1454 DALI_TEST_CHECK( event2.z == data.receivedWheelEvent.z );
1455 DALI_TEST_CHECK( event2.timeStamp == data.receivedWheelEvent.timeStamp );
1459 int UtcDaliStageContextLostSignalP(void)
1461 TestApplication app;
1462 Stage stage = Stage::GetCurrent();
1464 bool contextLost = false;
1465 ContextStatusFunctor contextLostFunctor( contextLost );
1466 stage.ContextLostSignal().Connect( &app, contextLostFunctor );
1468 Integration::ContextNotifierInterface* notifier = app.GetCore().GetContextNotifier();
1469 notifier->NotifyContextLost();
1470 DALI_TEST_EQUALS( contextLost, true, TEST_LOCATION );
1475 int UtcDaliStageContextLostSignalN(void)
1477 TestApplication app;
1480 // Check that connecting to the signal with a bad stage instance causes an assert.
1481 bool asserted = false;
1482 bool contextLost = false;
1483 ContextStatusFunctor contextLostFunctor( contextLost );
1486 stage.ContextLostSignal().Connect( &app, contextLostFunctor );
1488 catch( Dali::DaliException& e )
1490 DALI_TEST_PRINT_ASSERT( e );
1491 DALI_TEST_ASSERT( e, "stage && \"Stage handle is empty\"", TEST_LOCATION );
1494 DALI_TEST_CHECK( asserted );
1499 int UtcDaliStageContextRegainedSignalP(void)
1501 TestApplication app;
1502 Stage stage = Stage::GetCurrent();
1504 bool contextRegained = false;
1505 ContextStatusFunctor contextRegainedFunctor( contextRegained );
1506 stage.ContextRegainedSignal().Connect( &app, contextRegainedFunctor );
1508 Integration::ContextNotifierInterface* notifier = app.GetCore().GetContextNotifier();
1509 notifier->NotifyContextLost();
1510 notifier->NotifyContextRegained();
1511 DALI_TEST_EQUALS( contextRegained, true, TEST_LOCATION );
1516 int UtcDaliStageContextRegainedSignalN(void)
1518 TestApplication app;
1521 // Check that connecting to the signal with a bad stage instance causes an assert.
1522 bool asserted = false;
1523 bool contextRegained = false;
1524 ContextStatusFunctor contextRegainedFunctor( contextRegained );
1527 stage.ContextRegainedSignal().Connect( &app, contextRegainedFunctor );
1529 catch( Dali::DaliException& e )
1531 DALI_TEST_PRINT_ASSERT( e );
1532 DALI_TEST_ASSERT( e, "stage && \"Stage handle is empty\"", TEST_LOCATION );
1535 DALI_TEST_CHECK( asserted );
1540 int UtcDaliStageSceneCreatedSignalP(void)
1542 TestApplication app;
1543 Stage stage = Stage::GetCurrent();
1545 bool signalCalled = false;
1546 SceneCreatedStatusFunctor sceneCreatedFunctor( signalCalled );
1547 stage.SceneCreatedSignal().Connect( &app, sceneCreatedFunctor );
1549 Integration::Core& core = app.GetCore();
1550 core.SceneCreated();
1551 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
1556 int UtcDaliStageSceneCreatedSignalN(void)
1558 TestApplication app;
1561 // Check that connecting to the signal with a bad stage instance causes an assert.
1562 bool asserted = false;
1563 bool signalCalled = false;
1564 SceneCreatedStatusFunctor sceneCreatedFunctor( signalCalled );
1567 stage.SceneCreatedSignal().Connect( &app, sceneCreatedFunctor );
1569 catch( Dali::DaliException& e )
1571 DALI_TEST_PRINT_ASSERT( e );
1572 DALI_TEST_ASSERT( e, "stage && \"Stage handle is empty\"", TEST_LOCATION );
1575 DALI_TEST_CHECK( asserted );
1580 int UtcDaliStageGetRenderTaskListP(void)
1582 TestApplication app;
1583 Stage stage = Stage::GetCurrent();
1585 // Check we get a valid instance.
1586 const RenderTaskList& tasks = stage.GetRenderTaskList();
1588 // There should be 1 task by default.
1589 DALI_TEST_EQUALS( tasks.GetTaskCount(), 1u, TEST_LOCATION );
1591 // RenderTaskList has it's own UTC tests.
1592 // But we can confirm that GetRenderTaskList in Stage retrieves the same RenderTaskList each time.
1593 RenderTask newTask = stage.GetRenderTaskList().CreateTask();
1595 DALI_TEST_EQUALS( stage.GetRenderTaskList().GetTask( 1 ), newTask, TEST_LOCATION );
1600 int UtcDaliStageGetRenderTaskListN(void)
1602 TestApplication app;
1605 // Check that getting the render task list with a bad stage instance causes an assert.
1606 bool asserted = false;
1609 stage.GetRenderTaskList();
1611 catch( Dali::DaliException& e )
1613 DALI_TEST_PRINT_ASSERT( e );
1614 DALI_TEST_ASSERT( e, "stage && \"Stage handle is empty\"", TEST_LOCATION );
1617 DALI_TEST_CHECK( asserted );
1622 int UtcDaliStageGetObjectRegistryP(void)
1624 TestApplication app;
1625 Stage stage = Stage::GetCurrent();
1627 ObjectRegistry objectRegistry = stage.GetObjectRegistry();
1629 // Object registry tests are covered in their own module.
1630 // However we want a basic test to confirm the returned registry is valid and works.
1631 bool verified = false;
1632 ActorCreatedFunctor test( verified );
1633 objectRegistry.ObjectCreatedSignal().Connect( &app, test );
1635 Actor actor = Actor::New();
1636 DALI_TEST_CHECK( test.mSignalVerified );
1641 int UtcDaliStageGetObjectRegistryN(void)
1643 TestApplication app;
1646 // Check that getting the object registry with a bad stage instance DOES NOT cause an assert.
1647 // This is because GetCurrent() is used, always creating a stage if one does not exist.
1648 bool asserted = false;
1651 stage.GetObjectRegistry();
1653 catch( Dali::DaliException& e )
1655 DALI_TEST_PRINT_ASSERT( e );
1658 DALI_TEST_CHECK( !asserted );
1663 int UtcDaliStageOperatorAssign(void)
1665 TestApplication app;
1667 DALI_TEST_CHECK( !stage );
1669 stage = Stage::GetCurrent();
1670 DALI_TEST_CHECK( stage );