2 * Copyright (c) 2018 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");
49 // Functor for EventProcessingFinished signal
50 struct EventProcessingFinishedFunctor
53 * @param[in] eventProcessingFinished reference to a boolean variable used to check if signal has been called.
55 EventProcessingFinishedFunctor( bool& eventProcessingFinished )
56 : mEventProcessingFinished( eventProcessingFinished )
61 mEventProcessingFinished = true;
64 bool& mEventProcessingFinished;
67 // Stores data that is populated in the KeyEventGeneratedSignal callback and will be read by the TET cases
68 struct KeyEventGeneratedSignalData
70 KeyEventGeneratedSignalData()
71 : functorCalled(false)
76 functorCalled = false;
78 receivedKeyEvent.keyModifier = 0;
79 receivedKeyEvent.keyPressedName.clear();
80 receivedKeyEvent.keyPressed.clear();
84 KeyEvent receivedKeyEvent;
87 // Functor that sets the data when called
88 struct KeyEventGeneratedReceivedFunctor
90 KeyEventGeneratedReceivedFunctor( KeyEventGeneratedSignalData& data )
94 bool operator()( const KeyEvent& keyEvent )
96 signalData.functorCalled = true;
97 signalData.receivedKeyEvent = keyEvent;
104 signalData.functorCalled = true;
108 KeyEventGeneratedSignalData& signalData;
111 // Stores data that is populated in the key-event callback and will be read by the TET cases
112 struct KeyEventSignalData
115 : functorCalled(false)
120 functorCalled = false;
122 receivedKeyEvent.keyModifier = 0;
123 receivedKeyEvent.keyPressedName.clear();
124 receivedKeyEvent.keyPressed.clear();
128 KeyEvent receivedKeyEvent;
131 // Functor that sets the data when called
132 struct KeyEventReceivedFunctor
134 KeyEventReceivedFunctor( KeyEventSignalData& data ) : signalData( data ) { }
136 bool operator()( const KeyEvent& keyEvent )
138 signalData.functorCalled = true;
139 signalData.receivedKeyEvent = keyEvent;
144 KeyEventSignalData& signalData;
147 // Stores data that is populated in the touched signal callback and will be read by the TET cases
148 struct TouchedSignalData
151 : functorCalled(false)
156 functorCalled = false;
158 receivedTouchEvent.points.clear();
159 receivedTouchEvent.time = 0;
161 receivedTouchData.Reset();
165 TouchEvent receivedTouchEvent;
166 TouchData receivedTouchData;
169 // Functor that sets the data when touched signal is received
170 struct TouchedFunctor
172 TouchedFunctor( TouchedSignalData& data ) : signalData( data ) { }
174 void operator()( const TouchEvent& touch )
176 signalData.functorCalled = true;
177 signalData.receivedTouchEvent = touch;
180 TouchedSignalData& signalData;
184 // Functor that sets the data when touched signal is received
187 TouchFunctor( TouchedSignalData& data ) : signalData( data ) { }
189 void operator()( const TouchData& touch )
191 signalData.functorCalled = true;
192 signalData.receivedTouchData = touch;
197 signalData.functorCalled = true;
200 TouchedSignalData& signalData;
203 // Stores data that is populated in the wheel-event callback and will be read by the TET cases
204 struct WheelEventSignalData
206 WheelEventSignalData()
207 : functorCalled(false)
212 functorCalled = false;
216 WheelEvent receivedWheelEvent;
219 // Functor that sets the data when wheel-event signal is received
220 struct WheelEventReceivedFunctor
222 WheelEventReceivedFunctor( WheelEventSignalData& data ) : signalData( data ) { }
224 bool operator()( const WheelEvent& wheelEvent )
226 signalData.functorCalled = true;
227 signalData.receivedWheelEvent = wheelEvent;
232 WheelEventSignalData& signalData;
235 bool DummyTouchCallback( Actor actor, const TouchEvent& touch )
240 struct ContextStatusFunctor
242 ContextStatusFunctor(bool& calledFlag) : mCalledFlag( calledFlag )
259 struct SceneCreatedStatusFunctor
261 SceneCreatedStatusFunctor(bool& calledFlag) : mCalledFlag( calledFlag )
278 struct ActorCreatedFunctor
280 ActorCreatedFunctor( bool& signalReceived )
281 : mSignalVerified( signalReceived )
285 void operator()( BaseHandle object )
287 tet_infoline( "Verifying TestActorCallback()" );
288 Actor actor = Actor::DownCast( object );
291 mSignalVerified = true;
295 bool& mSignalVerified;
298 void GenerateTouch( TestApplication& application, PointState::Type state, const Vector2& screenPosition )
300 Integration::TouchEvent touchEvent;
301 Integration::Point point;
302 point.SetState( state );
303 point.SetScreenPosition( screenPosition );
304 touchEvent.points.push_back( point );
305 application.ProcessEvent( touchEvent );
308 } // unnamed namespace
311 int UtcDaliStageDefaultConstructorP(void)
313 TestApplication application;
316 DALI_TEST_CHECK( !stage );
320 // Note: No negative test for default constructor.
322 int UtcDaliStageDestructorP(void)
324 TestApplication application;
325 Stage* stage = new Stage();
329 DALI_TEST_CHECK( true );
333 // Note: No negative test for default destructor.
335 int UtcDaliStageGetCurrentP(void)
337 TestApplication application;
338 Stage stage = Stage::GetCurrent();
340 DALI_TEST_CHECK( stage );
344 int UtcDaliStageGetCurrentN(void)
346 bool asserted = false;
349 Stage stage = Stage::GetCurrent();
351 catch( Dali::DaliException& e )
353 DALI_TEST_PRINT_ASSERT( e );
354 DALI_TEST_ASSERT( e, "stage && \"Stage doesn't exist\"", TEST_LOCATION );
358 DALI_TEST_CHECK( asserted );
362 int UtcDaliStageIsInstalledP(void)
364 TestApplication application;
368 DALI_TEST_CHECK( Stage::IsInstalled() );
372 int UtcDaliStageIsInstalledN(void)
374 DALI_TEST_CHECK( !Stage::IsInstalled() );
379 int UtcDaliStageCopyConstructorP(void)
381 TestApplication application;
382 Stage stage = Stage::GetCurrent();
384 Stage copyStage( stage );
386 DALI_TEST_CHECK( copyStage );
387 DALI_TEST_CHECK( copyStage.GetRootLayer() == stage.GetRootLayer() );
392 // Note: no negative test for UtcDaliStageCopyConstructor.
394 int UtcDaliStageAssignmentOperatorP(void)
396 TestApplication application;
397 const Stage stage = Stage::GetCurrent();
399 Stage copyStage = stage;
401 DALI_TEST_CHECK( copyStage );
402 DALI_TEST_CHECK( copyStage.GetRootLayer() == stage.GetRootLayer() );
407 // Note: No negative test for UtcDaliStageAssignmentOperator.
409 int UtcDaliStageAddP(void)
411 TestApplication application;
413 Stage stage = Stage::GetCurrent();
415 Actor actor = Actor::New();
416 DALI_TEST_CHECK( !actor.OnStage() );
419 DALI_TEST_CHECK( actor.OnStage() );
423 int UtcDaliStageAddN(void)
425 TestApplication application;
427 Stage stage = Stage::GetCurrent();
430 bool asserted = false;
435 catch( Dali::DaliException& e )
437 DALI_TEST_PRINT_ASSERT( e );
438 DALI_TEST_ASSERT( e, "actor && \"Actor handle is empty\"", TEST_LOCATION );
442 DALI_TEST_CHECK( asserted );
447 int UtcDaliStageRemoveP(void)
449 TestApplication application;
451 Stage stage = Stage::GetCurrent();
453 Actor actor = Actor::New();
454 DALI_TEST_CHECK( !actor.OnStage() );
457 DALI_TEST_CHECK( actor.OnStage() );
460 DALI_TEST_CHECK( !actor.OnStage() );
464 int UtcDaliStageRemoveN1(void)
466 TestApplication application;
468 Stage stage = Stage::GetCurrent();
471 bool asserted = false;
474 // Actor is not valid, confirm a removal attempt does assert.
475 stage.Remove( actor );
477 catch( Dali::DaliException& e )
479 DALI_TEST_PRINT_ASSERT( e );
480 DALI_TEST_ASSERT( e, "actor && \"Actor handle is empty\"", TEST_LOCATION );
484 DALI_TEST_CHECK( asserted );
488 int UtcDaliStageRemoveN2(void)
490 TestApplication application;
492 Stage stage = Stage::GetCurrent();
493 Actor actor = Actor::New();
494 DALI_TEST_CHECK( !actor.OnStage() );
496 bool asserted = false;
499 // Actor is not on stage, confirm a removal attempt does not assert / segfault.
500 stage.Remove( actor );
502 catch( Dali::DaliException& e )
504 DALI_TEST_PRINT_ASSERT( e );
508 DALI_TEST_CHECK( !asserted );
512 int UtcDaliStageRemoveN3(void)
514 TestApplication application;
516 Stage stage = Stage::GetCurrent();
518 // Initially we have a default layer
519 DALI_TEST_EQUALS( stage.GetLayerCount(), 1u, TEST_LOCATION );
521 // Check we cannot remove the root layer from the stage.
522 Layer layer = stage.GetRootLayer();
523 bool asserted = true;
526 stage.Remove( layer );
528 catch( Dali::DaliException& e )
530 DALI_TEST_PRINT_ASSERT( e );
531 DALI_TEST_ASSERT( e, "this != &child && \"Cannot remove actor from itself\"", TEST_LOCATION );
535 DALI_TEST_CHECK( asserted );
536 DALI_TEST_EQUALS( stage.GetLayerCount(), 1u, TEST_LOCATION );
540 int UtcDaliStageGetSizeP(void)
542 TestApplication application;
544 Stage stage = Stage::GetCurrent();
546 Vector2 size = stage.GetSize();
548 DALI_TEST_EQUALS( size.width, static_cast<float>( TestApplication::DEFAULT_SURFACE_WIDTH ), TEST_LOCATION );
549 DALI_TEST_EQUALS( size.height, static_cast<float>( TestApplication::DEFAULT_SURFACE_HEIGHT ), TEST_LOCATION );
553 int UtcDaliStageGetSizeN(void)
555 TestApplication application;
559 bool asserted = false;
563 size = stage.GetSize();
565 catch( Dali::DaliException& e )
567 DALI_TEST_PRINT_ASSERT( e );
568 DALI_TEST_ASSERT( e, "stage && \"Stage handle is empty\"", TEST_LOCATION );
572 DALI_TEST_CHECK( asserted );
576 int UtcDaliStageGetDpiP1(void)
578 TestApplication application; // Initializes core DPI to default values
580 Stage stage = Stage::GetCurrent();
582 // Test the default DPI.
583 Vector2 dpi = stage.GetDpi();
584 DALI_TEST_EQUALS( dpi.x, static_cast<float>( TestApplication::DEFAULT_HORIZONTAL_DPI ), TEST_LOCATION );
585 DALI_TEST_EQUALS( dpi.y, static_cast<float>( TestApplication::DEFAULT_VERTICAL_DPI ), TEST_LOCATION );
589 int UtcDaliStageGetDpiP2(void)
591 TestApplication application; // Initializes core DPI to default values
593 // Test that setting core DPI explicitly also sets up the Stage's DPI.
594 Dali::Integration::Scene scene = application.GetScene();
595 scene.SetDpi( Vector2(200.0f, 180.0f) );
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, 120 ); // 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, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
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, "i", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
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, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
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, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
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, "i", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
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, "i", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
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, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
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, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
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 );
1675 int UtcDaliStageRenderingBehavior(void)
1677 TestApplication application;
1678 Stage stage = Stage::GetCurrent();
1680 tet_infoline( "Check default rendering behavior is only if required" );
1681 DALI_TEST_CHECK( DevelStage::GetRenderingBehavior( stage ) == DevelStage::Rendering::IF_REQUIRED );
1683 tet_infoline( "No update required with an empty application" );
1684 application.SendNotification();
1685 DALI_TEST_CHECK( application.UpdateOnly() == false );
1686 application.RenderOnly();
1688 tet_infoline( "Change to continuous rendering, further updates should be required" );
1689 DevelStage::SetRenderingBehavior( stage, DevelStage::Rendering::CONTINUOUSLY );
1691 DALI_TEST_CHECK( DevelStage::GetRenderingBehavior( stage ) == DevelStage::Rendering::CONTINUOUSLY );
1693 application.SendNotification();
1694 DALI_TEST_CHECK( application.UpdateOnly() == true );
1695 application.RenderOnly();
1697 application.SendNotification();
1698 DALI_TEST_CHECK( application.UpdateOnly() == true );
1699 application.RenderOnly();
1701 tet_infoline( "Change to rendering only if required, further updates should NOT be required" );
1702 DevelStage::SetRenderingBehavior( stage, DevelStage::Rendering::IF_REQUIRED );
1704 DALI_TEST_CHECK( DevelStage::GetRenderingBehavior( stage ) == DevelStage::Rendering::IF_REQUIRED );
1706 application.SendNotification();
1707 DALI_TEST_CHECK( application.UpdateOnly() == false );
1708 application.RenderOnly();
1710 tet_infoline( "The next update is not required so TestApplication should print a warning" );
1711 application.SendNotification();
1712 DALI_TEST_CHECK( application.UpdateOnly() == false );
1713 application.RenderOnly();