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 // Functor for EventProcessingFinished signal
48 struct EventProcessingFinishedFunctor
51 * @param[in] eventProcessingFinished reference to a boolean variable used to check if signal has been called.
53 EventProcessingFinishedFunctor( bool& eventProcessingFinished )
54 : mEventProcessingFinished( eventProcessingFinished )
59 mEventProcessingFinished = true;
62 bool& mEventProcessingFinished;
65 // Stores data that is populated in the KeyEventGeneratedSignal callback and will be read by the TET cases
66 struct KeyEventGeneratedSignalData
68 KeyEventGeneratedSignalData()
69 : functorCalled(false)
74 functorCalled = false;
76 receivedKeyEvent.keyModifier = 0;
77 receivedKeyEvent.keyPressedName.clear();
78 receivedKeyEvent.keyPressed.clear();
82 KeyEvent receivedKeyEvent;
85 // Functor that sets the data when called
86 struct KeyEventGeneratedReceivedFunctor
88 KeyEventGeneratedReceivedFunctor( KeyEventGeneratedSignalData& data )
92 bool operator()( const KeyEvent& keyEvent )
94 signalData.functorCalled = true;
95 signalData.receivedKeyEvent = keyEvent;
102 signalData.functorCalled = true;
106 KeyEventGeneratedSignalData& signalData;
109 // Stores data that is populated in the key-event callback and will be read by the TET cases
110 struct KeyEventSignalData
113 : functorCalled(false)
118 functorCalled = false;
120 receivedKeyEvent.keyModifier = 0;
121 receivedKeyEvent.keyPressedName.clear();
122 receivedKeyEvent.keyPressed.clear();
126 KeyEvent receivedKeyEvent;
129 // Functor that sets the data when called
130 struct KeyEventReceivedFunctor
132 KeyEventReceivedFunctor( KeyEventSignalData& data ) : signalData( data ) { }
134 bool operator()( const KeyEvent& keyEvent )
136 signalData.functorCalled = true;
137 signalData.receivedKeyEvent = keyEvent;
142 KeyEventSignalData& signalData;
145 // Stores data that is populated in the touched signal callback and will be read by the TET cases
146 struct TouchedSignalData
149 : functorCalled(false)
154 functorCalled = false;
156 receivedTouchEvent.points.clear();
157 receivedTouchEvent.time = 0;
159 receivedTouchData.Reset();
163 TouchEvent receivedTouchEvent;
164 TouchData receivedTouchData;
167 // Functor that sets the data when touched signal is received
168 struct TouchedFunctor
170 TouchedFunctor( TouchedSignalData& data ) : signalData( data ) { }
172 void operator()( const TouchEvent& touch )
174 signalData.functorCalled = true;
175 signalData.receivedTouchEvent = touch;
178 TouchedSignalData& signalData;
182 // Functor that sets the data when touched signal is received
185 TouchFunctor( TouchedSignalData& data ) : signalData( data ) { }
187 void operator()( const TouchData& touch )
189 signalData.functorCalled = true;
190 signalData.receivedTouchData = touch;
195 signalData.functorCalled = true;
198 TouchedSignalData& signalData;
201 // Stores data that is populated in the wheel-event callback and will be read by the TET cases
202 struct WheelEventSignalData
204 WheelEventSignalData()
205 : functorCalled(false)
210 functorCalled = false;
214 WheelEvent receivedWheelEvent;
217 // Functor that sets the data when wheel-event signal is received
218 struct WheelEventReceivedFunctor
220 WheelEventReceivedFunctor( WheelEventSignalData& data ) : signalData( data ) { }
222 bool operator()( const WheelEvent& wheelEvent )
224 signalData.functorCalled = true;
225 signalData.receivedWheelEvent = wheelEvent;
230 WheelEventSignalData& signalData;
233 bool DummyTouchCallback( Actor actor, const TouchEvent& touch )
238 struct ContextStatusFunctor
240 ContextStatusFunctor(bool& calledFlag) : mCalledFlag( calledFlag )
257 struct SceneCreatedStatusFunctor
259 SceneCreatedStatusFunctor(bool& calledFlag) : mCalledFlag( calledFlag )
276 struct ActorCreatedFunctor
278 ActorCreatedFunctor( bool& signalReceived )
279 : mSignalVerified( signalReceived )
283 void operator()( BaseHandle object )
285 tet_infoline( "Verifying TestActorCallback()" );
286 Actor actor = Actor::DownCast( object );
289 mSignalVerified = true;
293 bool& mSignalVerified;
296 void GenerateTouch( TestApplication& application, PointState::Type state, const Vector2& screenPosition )
298 Integration::TouchEvent touchEvent;
299 Integration::Point point;
300 point.SetState( state );
301 point.SetScreenPosition( screenPosition );
302 touchEvent.points.push_back( point );
303 application.ProcessEvent( touchEvent );
306 } // unnamed namespace
309 int UtcDaliStageDefaultConstructorP(void)
311 TestApplication application;
314 DALI_TEST_CHECK( !stage );
318 // Note: No negative test for default constructor.
320 int UtcDaliStageDestructorP(void)
322 TestApplication application;
323 Stage* stage = new Stage();
327 DALI_TEST_CHECK( true );
331 // Note: No negative test for default destructor.
333 int UtcDaliStageGetCurrentP(void)
335 TestApplication application;
336 Stage stage = Stage::GetCurrent();
338 DALI_TEST_CHECK( stage );
342 int UtcDaliStageGetCurrentN(void)
344 bool asserted = false;
347 Stage stage = Stage::GetCurrent();
349 catch( Dali::DaliException& e )
351 DALI_TEST_PRINT_ASSERT( e );
352 DALI_TEST_ASSERT( e, "stage && \"Stage doesn't exist\"", TEST_LOCATION );
356 DALI_TEST_CHECK( asserted );
360 int UtcDaliStageIsInstalledP(void)
362 TestApplication application;
366 DALI_TEST_CHECK( Stage::IsInstalled() );
370 int UtcDaliStageIsInstalledN(void)
372 DALI_TEST_CHECK( !Stage::IsInstalled() );
377 int UtcDaliStageCopyConstructorP(void)
379 TestApplication application;
380 Stage stage = Stage::GetCurrent();
382 Stage copyStage( stage );
384 DALI_TEST_CHECK( copyStage );
385 DALI_TEST_CHECK( copyStage.GetRootLayer() == stage.GetRootLayer() );
390 // Note: no negative test for UtcDaliStageCopyConstructor.
392 int UtcDaliStageAssignmentOperatorP(void)
394 TestApplication application;
395 const Stage stage = Stage::GetCurrent();
397 Stage copyStage = stage;
399 DALI_TEST_CHECK( copyStage );
400 DALI_TEST_CHECK( copyStage.GetRootLayer() == stage.GetRootLayer() );
405 // Note: No negative test for UtcDaliStageAssignmentOperator.
407 int UtcDaliStageAddP(void)
409 TestApplication application;
411 Stage stage = Stage::GetCurrent();
413 Actor actor = Actor::New();
414 DALI_TEST_CHECK( !actor.OnStage() );
417 DALI_TEST_CHECK( actor.OnStage() );
421 int UtcDaliStageAddN(void)
423 TestApplication application;
425 Stage stage = Stage::GetCurrent();
428 bool asserted = false;
433 catch( Dali::DaliException& e )
435 DALI_TEST_PRINT_ASSERT( e );
436 DALI_TEST_ASSERT( e, "actor && \"Actor handle is empty\"", TEST_LOCATION );
440 DALI_TEST_CHECK( asserted );
445 int UtcDaliStageRemoveP(void)
447 TestApplication application;
449 Stage stage = Stage::GetCurrent();
451 Actor actor = Actor::New();
452 DALI_TEST_CHECK( !actor.OnStage() );
455 DALI_TEST_CHECK( actor.OnStage() );
458 DALI_TEST_CHECK( !actor.OnStage() );
462 int UtcDaliStageRemoveN1(void)
464 TestApplication application;
466 Stage stage = Stage::GetCurrent();
469 bool asserted = false;
472 // Actor is not valid, confirm a removal attempt does assert.
473 stage.Remove( actor );
475 catch( Dali::DaliException& e )
477 DALI_TEST_PRINT_ASSERT( e );
478 DALI_TEST_ASSERT( e, "actor && \"Actor handle is empty\"", TEST_LOCATION );
482 DALI_TEST_CHECK( asserted );
486 int UtcDaliStageRemoveN2(void)
488 TestApplication application;
490 Stage stage = Stage::GetCurrent();
491 Actor actor = Actor::New();
492 DALI_TEST_CHECK( !actor.OnStage() );
494 bool asserted = false;
497 // Actor is not on stage, confirm a removal attempt does not assert / segfault.
498 stage.Remove( actor );
500 catch( Dali::DaliException& e )
502 DALI_TEST_PRINT_ASSERT( e );
506 DALI_TEST_CHECK( !asserted );
510 int UtcDaliStageRemoveN3(void)
512 TestApplication application;
514 Stage stage = Stage::GetCurrent();
516 // Initially we have a default layer
517 DALI_TEST_EQUALS( stage.GetLayerCount(), 1u, TEST_LOCATION );
519 // Check we cannot remove the root layer from the stage.
520 Layer layer = stage.GetRootLayer();
521 bool asserted = true;
524 stage.Remove( layer );
526 catch( Dali::DaliException& e )
528 DALI_TEST_PRINT_ASSERT( e );
529 DALI_TEST_ASSERT( e, "this != &child && \"Cannot remove actor from itself\"", TEST_LOCATION );
533 DALI_TEST_CHECK( asserted );
534 DALI_TEST_EQUALS( stage.GetLayerCount(), 1u, TEST_LOCATION );
538 int UtcDaliStageGetSizeP(void)
540 TestApplication application;
542 Stage stage = Stage::GetCurrent();
544 Vector2 size = stage.GetSize();
546 DALI_TEST_EQUALS( size.width, static_cast<float>( TestApplication::DEFAULT_SURFACE_WIDTH ), TEST_LOCATION );
547 DALI_TEST_EQUALS( size.height, static_cast<float>( TestApplication::DEFAULT_SURFACE_HEIGHT ), TEST_LOCATION );
551 int UtcDaliStageGetSizeN(void)
553 TestApplication application;
557 bool asserted = false;
561 size = stage.GetSize();
563 catch( Dali::DaliException& e )
565 DALI_TEST_PRINT_ASSERT( e );
566 DALI_TEST_ASSERT( e, "stage && \"Stage handle is empty\"", TEST_LOCATION );
570 DALI_TEST_CHECK( asserted );
574 int UtcDaliStageGetDpiP1(void)
576 TestApplication application; // Initializes core DPI to default values
578 Stage stage = Stage::GetCurrent();
580 // Test the default DPI.
581 Vector2 dpi = stage.GetDpi();
582 DALI_TEST_EQUALS( dpi.x, static_cast<float>( TestApplication::DEFAULT_HORIZONTAL_DPI ), TEST_LOCATION );
583 DALI_TEST_EQUALS( dpi.y, static_cast<float>( TestApplication::DEFAULT_VERTICAL_DPI ), TEST_LOCATION );
587 int UtcDaliStageGetDpiP2(void)
589 TestApplication application; // Initializes core DPI to default values
591 // Test that setting core DPI explicitly also sets up the Stage's DPI.
592 application.GetCore().SetDpi( 200, 180 );
594 Stage stage = Stage::GetCurrent();
595 Vector2 dpi = stage.GetDpi();
596 DALI_TEST_EQUALS( dpi.x, 200.0f, TEST_LOCATION );
597 DALI_TEST_EQUALS( dpi.y, 180.0f, TEST_LOCATION );
601 int UtcDaliStageGetDpiP3(void)
603 TestApplication application( 480, 800, 72.0f, 120.0f ); // Initializes core DPI with specific values
605 Stage stage = Stage::GetCurrent();
607 // Test that setting core DPI explicitly also sets up the Stage's DPI.
608 Vector2 dpi = stage.GetDpi();
609 DALI_TEST_EQUALS( dpi.x, 72.0f, TEST_LOCATION );
610 DALI_TEST_EQUALS( dpi.y, 120.0f, TEST_LOCATION) ;
615 * This is not a true negative test, we are checking the DPI if it has not been set.
616 * A test for setting negative DPI values would be part of the application core utc tests.
618 int UtcDaliStageGetDpiN(void)
620 TestApplication application; // Initializes core DPI to default values
622 Stage stage = Stage::GetCurrent();
623 Vector2 dpi = stage.GetDpi();
625 DALI_TEST_EQUALS( dpi.x, 220.0f, TEST_LOCATION );
626 DALI_TEST_EQUALS( dpi.y, 217.0f, TEST_LOCATION );
630 int UtcDaliStageGetLayerCountP(void)
632 TestApplication application;
634 Stage stage = Stage::GetCurrent();
636 // Initially we have a default layer
637 DALI_TEST_EQUALS( stage.GetLayerCount(), 1u, TEST_LOCATION );
639 Layer layer = Layer::New();
642 DALI_TEST_EQUALS( stage.GetLayerCount(), 2u, TEST_LOCATION );
647 * Not a true negative test, but confirms layer count is not affected by an invalid removal.
649 int UtcDaliStageGetLayerCountN(void)
651 TestApplication application;
653 Stage stage = Stage::GetCurrent();
655 // Initially we have a default layer
656 DALI_TEST_EQUALS( stage.GetLayerCount(), 1u, TEST_LOCATION );
658 Layer layer = Layer::New();
659 stage.Remove( layer );
661 // Still have 1 layer.
662 DALI_TEST_EQUALS( stage.GetLayerCount(), 1u, TEST_LOCATION );
666 int UtcDaliStageGetLayerP(void)
668 TestApplication application;
670 Stage stage = Stage::GetCurrent();
672 Layer rootLayer = stage.GetLayer( 0 );
673 DALI_TEST_CHECK( rootLayer );
675 Layer layer = Layer::New();
678 Layer sameLayer = stage.GetLayer( 1 );
679 DALI_TEST_CHECK( layer == sameLayer );
683 int UtcDaliStageGetLayerN(void)
685 TestApplication application;
687 Stage stage = Stage::GetCurrent();
689 bool asserted = false;
692 // Try to get a layer that doesn't exist (note: 0 is the root layer).
693 Layer layer = stage.GetLayer( 1 );
695 catch( Dali::DaliException& e )
697 DALI_TEST_PRINT_ASSERT( e );
698 DALI_TEST_ASSERT( e, "depth < mLayers.size()", TEST_LOCATION );
702 DALI_TEST_CHECK( asserted );
706 int UtcDaliStageGetRootLayerP(void)
708 TestApplication application;
710 Stage stage = Stage::GetCurrent();
712 Layer layer = stage.GetLayer( 0 );
713 DALI_TEST_CHECK( layer );
715 // Check that GetRootLayer() correctly retreived layer 0.
716 DALI_TEST_CHECK( stage.GetRootLayer() == layer );
721 int UtcDaliStageGetRootLayerN(void)
723 TestApplication application;
725 Stage stage = Stage::GetCurrent();
727 Layer rootLayer = stage.GetLayer( 0 );
728 DALI_TEST_CHECK( rootLayer );
729 DALI_TEST_CHECK( stage.GetRootLayer() == rootLayer );
731 // Create a new layer and attempt to lower it below the root layer.
732 Layer layer = Layer::New();
734 layer.LowerToBottom();
736 // Check that GetRootLayer still retrieves the same original layer.
737 DALI_TEST_CHECK( stage.GetRootLayer() == rootLayer );
739 // Check modifying the root layer is also blocked.
740 rootLayer.RaiseToTop();
741 DALI_TEST_CHECK( stage.GetRootLayer() == rootLayer );
746 int UtcDaliStageSetBackgroundColorP(void)
748 TestApplication application;
750 Stage stage = Stage::GetCurrent();
752 Vector4 testColor( 0.1f, 0.2f, 0.3f, 1.0f );
753 stage.SetBackgroundColor( testColor );
755 DALI_TEST_EQUALS( testColor, stage.GetBackgroundColor(), TEST_LOCATION );
759 // Note: No negative test for UtcDaliStageSetBackgroundColor as we do not wish to implement
760 // range checking for colors due to speed. Colors are clamped with glclampf within GL anyway.
762 int UtcDaliStageGetBackgroundColorP(void)
764 TestApplication application;
766 Stage stage = Stage::GetCurrent();
768 DALI_TEST_EQUALS( Stage::DEFAULT_BACKGROUND_COLOR, stage.GetBackgroundColor(), TEST_LOCATION );
772 // Note: No negative test for UtcDaliStageGetBackgroundColor as this is covered by UtcDaliStageSetBackgroundColorN.
774 int UtcDaliStageKeepRenderingP(void)
776 TestApplication application;
778 Stage stage = Stage::GetCurrent();
780 // Run core until it wants to sleep
781 bool keepUpdating( true );
782 while ( keepUpdating )
784 application.SendNotification();
785 keepUpdating = application.Render( 1000.0f /*1 second*/ );
788 // Force rendering for the next 5 seconds
789 stage.KeepRendering( 5.0f );
791 application.SendNotification();
793 // Test that core wants to sleep after 10 seconds
794 keepUpdating = application.Render( 1000.0f /*1 second*/ );
795 DALI_TEST_CHECK( keepUpdating );
796 keepUpdating = application.Render( 1000.0f /*2 seconds*/ );
797 DALI_TEST_CHECK( keepUpdating );
798 keepUpdating = application.Render( 1000.0f /*3 seconds*/ );
799 DALI_TEST_CHECK( keepUpdating );
800 keepUpdating = application.Render( 1000.0f /*4 seconds*/ );
801 DALI_TEST_CHECK( keepUpdating );
802 keepUpdating = application.Render( 1000.0f /*5 seconds*/ );
803 DALI_TEST_CHECK( !keepUpdating );
807 int UtcDaliStageKeepRenderingN(void)
809 TestApplication application;
811 Stage stage = Stage::GetCurrent();
813 // Run core until it wants to sleep
814 bool keepUpdating( true );
815 while ( keepUpdating )
817 application.SendNotification();
818 keepUpdating = application.Render( 1000.0f /*1 second*/ );
821 // Force rendering for the next 5 seconds
822 stage.KeepRendering( -1.0f );
824 application.SendNotification();
826 // Test that core wants to sleep after 10 seconds
827 keepUpdating = application.Render( 1000.0f /*1 second*/ );
828 DALI_TEST_CHECK( !keepUpdating );
833 int UtcDaliStageEventProcessingFinishedP(void)
835 TestApplication application;
836 Stage stage = Stage::GetCurrent();
838 bool eventProcessingFinished = false;
839 EventProcessingFinishedFunctor functor( eventProcessingFinished );
840 stage.EventProcessingFinishedSignal().Connect( &application, functor );
842 Actor actor( Actor::New() );
845 application.SendNotification();
846 application.Render();
848 DALI_TEST_CHECK( eventProcessingFinished );
853 int UtcDaliStageEventProcessingFinishedN(void)
855 TestApplication application;
856 Stage stage = Stage::GetCurrent();
858 bool eventProcessingFinished = false;
859 EventProcessingFinishedFunctor functor( eventProcessingFinished );
860 stage.EventProcessingFinishedSignal().Connect( &application, functor );
862 Actor actor( Actor::New() );
865 // Do not complete event processing and confirm the signal has not been emitted.
866 DALI_TEST_CHECK( !eventProcessingFinished );
871 int UtcDaliStageKeyEventGeneratedSignalP(void)
873 TestApplication application;
874 Stage stage = Stage::GetCurrent();
876 KeyEventGeneratedSignalData data;
877 KeyEventGeneratedReceivedFunctor functor( data );
878 DevelStage::KeyEventGeneratedSignal( stage ).Connect( &application, functor );
880 KeyEventGeneratedSignalData data2;
881 KeyEventGeneratedReceivedFunctor functor2( data2 );
882 GetImplementation( stage ).ConnectSignal( &application, "keyEventGenerated", functor2 );
884 Integration::KeyEvent event( "a", "a", 0, 0, 0, Integration::KeyEvent::Up );
885 application.ProcessEvent( event );
887 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
888 DALI_TEST_CHECK( event.keyModifier == data.receivedKeyEvent.keyModifier );
889 DALI_TEST_CHECK( event.keyName == data.receivedKeyEvent.keyPressedName );
890 DALI_TEST_CHECK( event.keyString == data.receivedKeyEvent.keyPressed );
891 DALI_TEST_CHECK( event.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
895 Integration::KeyEvent event2( "i", "i", 0, 0, 0, Integration::KeyEvent::Up );
896 application.ProcessEvent( event2 );
898 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
899 DALI_TEST_CHECK( event2.keyModifier == data.receivedKeyEvent.keyModifier );
900 DALI_TEST_CHECK( event2.keyName == data.receivedKeyEvent.keyPressedName );
901 DALI_TEST_CHECK( event2.keyString == data.receivedKeyEvent.keyPressed );
902 DALI_TEST_CHECK( event2.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
906 Integration::KeyEvent event3( "a", "a", 0, 0, 0, Integration::KeyEvent::Down );
907 application.ProcessEvent( event3 );
909 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
910 DALI_TEST_CHECK( event3.keyModifier == data.receivedKeyEvent.keyModifier );
911 DALI_TEST_CHECK( event3.keyName == data.receivedKeyEvent.keyPressedName );
912 DALI_TEST_CHECK( event3.keyString == data.receivedKeyEvent.keyPressed );
913 DALI_TEST_CHECK( event3.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
917 Integration::KeyEvent event4( "a", "a", 0, 0, 0, Integration::KeyEvent::Up );
918 application.ProcessEvent( event4 );
920 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
921 DALI_TEST_CHECK( event4.keyModifier == data.receivedKeyEvent.keyModifier );
922 DALI_TEST_CHECK( event4.keyName == data.receivedKeyEvent.keyPressedName );
923 DALI_TEST_CHECK( event4.keyString == data.receivedKeyEvent.keyPressed );
924 DALI_TEST_CHECK( event4.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
928 int UtcDaliStageSignalKeyEventP(void)
930 TestApplication application;
931 Stage stage = Stage::GetCurrent();
933 KeyEventSignalData data;
934 KeyEventReceivedFunctor functor( data );
935 stage.KeyEventSignal().Connect( &application, functor );
937 Integration::KeyEvent event( "i", "i", 0, 0, 0, Integration::KeyEvent::Down );
938 application.ProcessEvent( event );
940 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
941 DALI_TEST_CHECK( event.keyModifier == data.receivedKeyEvent.keyModifier );
942 DALI_TEST_CHECK( event.keyName == data.receivedKeyEvent.keyPressedName );
943 DALI_TEST_CHECK( event.keyString == data.receivedKeyEvent.keyPressed );
944 DALI_TEST_CHECK( event.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
948 Integration::KeyEvent event2( "i", "i", 0, 0, 0, Integration::KeyEvent::Up );
949 application.ProcessEvent( event2 );
951 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
952 DALI_TEST_CHECK( event2.keyModifier == data.receivedKeyEvent.keyModifier );
953 DALI_TEST_CHECK( event2.keyName == data.receivedKeyEvent.keyPressedName );
954 DALI_TEST_CHECK( event2.keyString == data.receivedKeyEvent.keyPressed );
955 DALI_TEST_CHECK( event2.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
959 Integration::KeyEvent event3( "a", "a", 0, 0, 0, Integration::KeyEvent::Down );
960 application.ProcessEvent( event3 );
962 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
963 DALI_TEST_CHECK( event3.keyModifier == data.receivedKeyEvent.keyModifier );
964 DALI_TEST_CHECK( event3.keyName == data.receivedKeyEvent.keyPressedName );
965 DALI_TEST_CHECK( event3.keyString == data.receivedKeyEvent.keyPressed );
966 DALI_TEST_CHECK( event3.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
970 Integration::KeyEvent event4( "a", "a", 0, 0, 0, Integration::KeyEvent::Up );
971 application.ProcessEvent( event4 );
973 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
974 DALI_TEST_CHECK( event4.keyModifier == data.receivedKeyEvent.keyModifier );
975 DALI_TEST_CHECK( event4.keyName == data.receivedKeyEvent.keyPressedName );
976 DALI_TEST_CHECK( event4.keyString == data.receivedKeyEvent.keyPressed );
977 DALI_TEST_CHECK( event4.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
981 int UtcDaliStageSignalKeyEventN(void)
983 TestApplication application;
984 Stage stage = Stage::GetCurrent();
986 KeyEventSignalData data;
987 KeyEventReceivedFunctor functor( data );
988 stage.KeyEventSignal().Connect( &application, functor );
990 // Check that a non-pressed key events data is not modified.
991 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
996 int UtcDaliStageTouchedSignalP(void)
998 TestApplication application;
999 Stage stage = Stage::GetCurrent();
1001 TouchedSignalData data;
1002 TouchedFunctor functor( data );
1003 stage.TouchedSignal().Connect( &application, functor );
1005 // Render and notify.
1006 application.SendNotification();
1007 application.Render();
1009 // Basic test: No actors, single touch (down then up).
1011 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1013 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1014 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1015 DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
1018 GenerateTouch( application, PointState::UP, Vector2( 10.0f, 10.0f ) );
1020 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1021 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1022 DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
1026 // Add an actor to the scene.
1027 Actor actor = Actor::New();
1028 actor.SetSize( 100.0f, 100.0f );
1029 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1030 actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1031 actor.TouchedSignal().Connect( &DummyTouchCallback );
1034 // Render and notify.
1035 application.SendNotification();
1036 application.Render();
1038 // Actor on scene, single touch, down in actor, motion, then up outside actor.
1040 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1042 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1043 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1044 DALI_TEST_CHECK( data.receivedTouchEvent.points[0].hitActor == actor );
1047 GenerateTouch( application, PointState::MOTION, Vector2( 150.0f, 10.0f ) ); // Some motion
1049 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1052 GenerateTouch( application, PointState::UP, Vector2( 150.0f, 10.0f ) ); // Some motion
1054 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1055 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1056 DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
1060 // Multiple touch. Should only receive a touch on first down and last up.
1062 Integration::TouchEvent touchEvent;
1063 Integration::Point point;
1066 point.SetState( PointState::DOWN );
1067 point.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
1068 touchEvent.points.push_back( point );
1069 application.ProcessEvent( touchEvent );
1070 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1071 DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 1u, TEST_LOCATION );
1075 touchEvent.points[0].SetState( PointState::STATIONARY );
1076 point.SetDeviceId( 1 );
1077 point.SetScreenPosition( Vector2( 50.0f, 50.0f ) );
1078 touchEvent.points.push_back( point );
1079 application.ProcessEvent( touchEvent );
1080 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1081 DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 0u, TEST_LOCATION );
1084 // Primary point is up
1085 touchEvent.points[0].SetState( PointState::UP );
1086 touchEvent.points[1].SetState( PointState::STATIONARY );
1087 application.ProcessEvent( touchEvent );
1088 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1089 DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 0u, TEST_LOCATION );
1092 // Remove 1st point now, 2nd point is now in motion
1093 touchEvent.points.erase( touchEvent.points.begin() );
1094 touchEvent.points[0].SetState( PointState::MOTION );
1095 touchEvent.points[0].SetScreenPosition( Vector2( 150.0f, 50.0f ) );
1096 application.ProcessEvent( touchEvent );
1097 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1098 DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 0u, TEST_LOCATION );
1102 touchEvent.points[0].SetState( PointState::UP );
1103 application.ProcessEvent( touchEvent );
1104 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1105 DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 1u, TEST_LOCATION );
1111 int UtcDaliStageTouchedSignalN(void)
1113 TestApplication application;
1114 Stage stage = Stage::GetCurrent();
1116 TouchedSignalData data;
1117 TouchedFunctor functor( data );
1118 stage.TouchedSignal().Connect( &application, functor );
1120 // Render and notify.
1121 application.SendNotification();
1122 application.Render();
1124 // Confirm functor not called before there has been any touch event.
1125 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1127 // No actors, single touch, down, motion then up.
1129 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1131 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1132 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1133 DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
1136 // Confirm there is no signal when the touchpoint is only moved.
1137 GenerateTouch( application, PointState::MOTION, Vector2( 1200.0f, 10.0f ) ); // Some motion
1139 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1142 // Confirm a following up event generates a signal.
1143 GenerateTouch( application, PointState::UP, Vector2( 1200.0f, 10.0f ) );
1145 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1146 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1147 DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
1151 // Add an actor to the scene.
1152 Actor actor = Actor::New();
1153 actor.SetSize( 100.0f, 100.0f );
1154 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1155 actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1156 actor.TouchedSignal().Connect( &DummyTouchCallback );
1159 // Render and notify.
1160 application.SendNotification();
1161 application.Render();
1163 // Actor on scene. Interrupted before down and interrupted after down.
1165 GenerateTouch( application, PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) );
1167 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1168 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1169 DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
1170 DALI_TEST_CHECK( data.receivedTouchEvent.points[0].state == TouchPoint::Interrupted );
1173 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1175 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1176 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1177 DALI_TEST_CHECK( data.receivedTouchEvent.points[0].hitActor == actor );
1178 DALI_TEST_CHECK( data.receivedTouchEvent.points[0].state == TouchPoint::Down );
1181 GenerateTouch( application, PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) );
1183 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1184 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1185 DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
1186 DALI_TEST_CHECK( data.receivedTouchEvent.points[0].state == TouchPoint::Interrupted );
1188 DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 1u, TEST_LOCATION );
1190 // Check that getting info about a non-existent point causes an assert.
1191 bool asserted = false;
1194 data.receivedTouchEvent.GetPoint( 1 );
1196 catch( Dali::DaliException& e )
1198 DALI_TEST_PRINT_ASSERT( e );
1199 DALI_TEST_ASSERT( e, "point < points.size() && \"No point at index\"", TEST_LOCATION );
1202 DALI_TEST_CHECK( asserted );
1211 int UtcDaliStageTouchSignalP(void)
1213 TestApplication application;
1214 Stage stage = Stage::GetCurrent();
1216 TouchedSignalData data;
1217 TouchFunctor functor( data );
1218 stage.TouchSignal().Connect( &application, functor );
1220 // Render and notify.
1221 application.SendNotification();
1222 application.Render();
1224 // Basic test: No actors, single touch (down then up).
1226 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1228 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1229 DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1230 DALI_TEST_CHECK( !data.receivedTouchData.GetHitActor(0) );
1233 GenerateTouch( application, PointState::UP, Vector2( 10.0f, 10.0f ) );
1235 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1236 DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1237 DALI_TEST_CHECK( !data.receivedTouchData.GetHitActor(0) );
1241 // Add an actor to the scene.
1242 Actor actor = Actor::New();
1243 actor.SetSize( 100.0f, 100.0f );
1244 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1245 actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1246 actor.TouchedSignal().Connect( &DummyTouchCallback );
1249 // Render and notify.
1250 application.SendNotification();
1251 application.Render();
1253 // Actor on scene, single touch, down in actor, motion, then up outside actor.
1255 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1257 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1258 DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1259 DALI_TEST_CHECK( data.receivedTouchData.GetHitActor(0) == actor );
1262 GenerateTouch( application, PointState::MOTION, Vector2( 150.0f, 10.0f ) ); // Some motion
1264 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1267 GenerateTouch( application, PointState::UP, Vector2( 150.0f, 10.0f ) ); // Some motion
1269 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1270 DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1271 DALI_TEST_CHECK( !data.receivedTouchData.GetHitActor(0) );
1275 // Multiple touch. Should only receive a touch on first down and last up.
1277 Integration::TouchEvent touchEvent;
1278 Integration::Point point;
1281 point.SetState( PointState::DOWN );
1282 point.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
1283 touchEvent.points.push_back( point );
1284 application.ProcessEvent( touchEvent );
1285 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1286 DALI_TEST_EQUALS( data.receivedTouchData.GetPointCount(), 1u, TEST_LOCATION );
1290 touchEvent.points[0].SetState( PointState::STATIONARY );
1291 point.SetDeviceId( 1 );
1292 point.SetScreenPosition( Vector2( 50.0f, 50.0f ) );
1293 touchEvent.points.push_back( point );
1294 application.ProcessEvent( touchEvent );
1295 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1298 // Primary point is up
1299 touchEvent.points[0].SetState( PointState::UP );
1300 touchEvent.points[1].SetState( PointState::STATIONARY );
1301 application.ProcessEvent( touchEvent );
1302 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1305 // Remove 1st point now, 2nd point is now in motion
1306 touchEvent.points.erase( touchEvent.points.begin() );
1307 touchEvent.points[0].SetState( PointState::MOTION );
1308 touchEvent.points[0].SetScreenPosition( Vector2( 150.0f, 50.0f ) );
1309 application.ProcessEvent( touchEvent );
1310 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1314 touchEvent.points[0].SetState( PointState::UP );
1315 application.ProcessEvent( touchEvent );
1316 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1317 DALI_TEST_EQUALS( data.receivedTouchData.GetPointCount(), 1u, TEST_LOCATION );
1323 int UtcDaliStageTouchSignalN(void)
1325 TestApplication application;
1326 Stage stage = Stage::GetCurrent();
1328 TouchedSignalData data;
1329 TouchFunctor functor( data );
1330 stage.TouchSignal().Connect( &application, functor );
1332 TouchedSignalData data2;
1333 TouchFunctor functor2( data2 );
1334 GetImplementation( stage ).ConnectSignal( &application, "touch", functor2 );
1336 // Render and notify.
1337 application.SendNotification();
1338 application.Render();
1340 // Confirm functor not called before there has been any touch event.
1341 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1342 DALI_TEST_EQUALS( false, data2.functorCalled, TEST_LOCATION );
1344 // No actors, single touch, down, motion then up.
1346 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1348 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1349 DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1350 DALI_TEST_CHECK( !data.receivedTouchData.GetHitActor(0));
1352 DALI_TEST_EQUALS( true, data2.functorCalled, TEST_LOCATION );
1357 // Confirm there is no signal when the touchpoint is only moved.
1358 GenerateTouch( application, PointState::MOTION, Vector2( 1200.0f, 10.0f ) ); // Some motion
1360 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1363 // Confirm a following up event generates a signal.
1364 GenerateTouch( application, PointState::UP, Vector2( 1200.0f, 10.0f ) );
1366 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1367 DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1368 DALI_TEST_CHECK( !data.receivedTouchData.GetHitActor(0));
1372 // Add an actor to the scene.
1373 Actor actor = Actor::New();
1374 actor.SetSize( 100.0f, 100.0f );
1375 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1376 actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1377 actor.TouchedSignal().Connect( &DummyTouchCallback );
1380 // Render and notify.
1381 application.SendNotification();
1382 application.Render();
1384 // Actor on scene. Interrupted before down and interrupted after down.
1386 GenerateTouch( application, PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) );
1388 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1389 DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1390 DALI_TEST_CHECK( !data.receivedTouchData.GetHitActor(0) );
1391 DALI_TEST_CHECK( data.receivedTouchData.GetState(0) == PointState::INTERRUPTED );
1394 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1396 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1397 DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1398 DALI_TEST_CHECK( data.receivedTouchData.GetHitActor(0) == actor );
1399 DALI_TEST_CHECK( data.receivedTouchData.GetState(0) == PointState::DOWN );
1402 GenerateTouch( application, PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) );
1404 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1405 DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1406 DALI_TEST_CHECK( !data.receivedTouchData.GetHitActor(0) );
1407 DALI_TEST_CHECK( data.receivedTouchData.GetState(0) == PointState::INTERRUPTED );
1409 DALI_TEST_EQUALS( data.receivedTouchData.GetPointCount(), 1u, TEST_LOCATION );
1411 // Check that getting info about a non-existent point returns an empty handle
1412 Actor actor = data.receivedTouchData.GetHitActor( 1 );
1413 DALI_TEST_CHECK( !actor );
1421 int UtcDaliStageSignalWheelEventP(void)
1423 TestApplication application;
1424 Stage stage = Stage::GetCurrent();
1426 WheelEventSignalData data;
1427 WheelEventReceivedFunctor functor( data );
1428 stage.WheelEventSignal().Connect( &application, functor );
1430 Integration::WheelEvent event( Integration::WheelEvent::CUSTOM_WHEEL, 0, 0u, Vector2( 0.0f, 0.0f ), 1, 1000u );
1431 application.ProcessEvent( event );
1433 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1434 DALI_TEST_CHECK( static_cast< WheelEvent::Type >(event.type) == data.receivedWheelEvent.type );
1435 DALI_TEST_CHECK( event.direction == data.receivedWheelEvent.direction );
1436 DALI_TEST_CHECK( event.modifiers == data.receivedWheelEvent.modifiers );
1437 DALI_TEST_CHECK( event.point == data.receivedWheelEvent.point );
1438 DALI_TEST_CHECK( event.z == data.receivedWheelEvent.z );
1439 DALI_TEST_CHECK( event.timeStamp == data.receivedWheelEvent.timeStamp );
1443 Integration::WheelEvent event2( Integration::WheelEvent::CUSTOM_WHEEL, 0, 0u, Vector2( 0.0f, 0.0f ), -1, 1000u );
1444 application.ProcessEvent( event2 );
1446 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1447 DALI_TEST_CHECK( static_cast< WheelEvent::Type >(event2.type) == data.receivedWheelEvent.type );
1448 DALI_TEST_CHECK( event2.direction == data.receivedWheelEvent.direction );
1449 DALI_TEST_CHECK( event2.modifiers == data.receivedWheelEvent.modifiers );
1450 DALI_TEST_CHECK( event2.point == data.receivedWheelEvent.point );
1451 DALI_TEST_CHECK( event2.z == data.receivedWheelEvent.z );
1452 DALI_TEST_CHECK( event2.timeStamp == data.receivedWheelEvent.timeStamp );
1456 int UtcDaliStageContextLostSignalP(void)
1458 TestApplication app;
1459 Stage stage = Stage::GetCurrent();
1461 bool contextLost = false;
1462 ContextStatusFunctor contextLostFunctor( contextLost );
1463 stage.ContextLostSignal().Connect( &app, contextLostFunctor );
1465 Integration::ContextNotifierInterface* notifier = app.GetCore().GetContextNotifier();
1466 notifier->NotifyContextLost();
1467 DALI_TEST_EQUALS( contextLost, true, TEST_LOCATION );
1472 int UtcDaliStageContextLostSignalN(void)
1474 TestApplication app;
1477 // Check that connecting to the signal with a bad stage instance causes an assert.
1478 bool asserted = false;
1479 bool contextLost = false;
1480 ContextStatusFunctor contextLostFunctor( contextLost );
1483 stage.ContextLostSignal().Connect( &app, contextLostFunctor );
1485 catch( Dali::DaliException& e )
1487 DALI_TEST_PRINT_ASSERT( e );
1488 DALI_TEST_ASSERT( e, "stage && \"Stage handle is empty\"", TEST_LOCATION );
1491 DALI_TEST_CHECK( asserted );
1496 int UtcDaliStageContextRegainedSignalP(void)
1498 TestApplication app;
1499 Stage stage = Stage::GetCurrent();
1501 bool contextRegained = false;
1502 ContextStatusFunctor contextRegainedFunctor( contextRegained );
1503 stage.ContextRegainedSignal().Connect( &app, contextRegainedFunctor );
1505 Integration::ContextNotifierInterface* notifier = app.GetCore().GetContextNotifier();
1506 notifier->NotifyContextLost();
1507 notifier->NotifyContextRegained();
1508 DALI_TEST_EQUALS( contextRegained, true, TEST_LOCATION );
1513 int UtcDaliStageContextRegainedSignalN(void)
1515 TestApplication app;
1518 // Check that connecting to the signal with a bad stage instance causes an assert.
1519 bool asserted = false;
1520 bool contextRegained = false;
1521 ContextStatusFunctor contextRegainedFunctor( contextRegained );
1524 stage.ContextRegainedSignal().Connect( &app, contextRegainedFunctor );
1526 catch( Dali::DaliException& e )
1528 DALI_TEST_PRINT_ASSERT( e );
1529 DALI_TEST_ASSERT( e, "stage && \"Stage handle is empty\"", TEST_LOCATION );
1532 DALI_TEST_CHECK( asserted );
1537 int UtcDaliStageSceneCreatedSignalP(void)
1539 TestApplication app;
1540 Stage stage = Stage::GetCurrent();
1542 bool signalCalled = false;
1543 SceneCreatedStatusFunctor sceneCreatedFunctor( signalCalled );
1544 stage.SceneCreatedSignal().Connect( &app, sceneCreatedFunctor );
1546 Integration::Core& core = app.GetCore();
1547 core.SceneCreated();
1548 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
1553 int UtcDaliStageSceneCreatedSignalN(void)
1555 TestApplication app;
1558 // Check that connecting to the signal with a bad stage instance causes an assert.
1559 bool asserted = false;
1560 bool signalCalled = false;
1561 SceneCreatedStatusFunctor sceneCreatedFunctor( signalCalled );
1564 stage.SceneCreatedSignal().Connect( &app, sceneCreatedFunctor );
1566 catch( Dali::DaliException& e )
1568 DALI_TEST_PRINT_ASSERT( e );
1569 DALI_TEST_ASSERT( e, "stage && \"Stage handle is empty\"", TEST_LOCATION );
1572 DALI_TEST_CHECK( asserted );
1577 int UtcDaliStageGetRenderTaskListP(void)
1579 TestApplication app;
1580 Stage stage = Stage::GetCurrent();
1582 // Check we get a valid instance.
1583 const RenderTaskList& tasks = stage.GetRenderTaskList();
1585 // There should be 1 task by default.
1586 DALI_TEST_EQUALS( tasks.GetTaskCount(), 1u, TEST_LOCATION );
1588 // RenderTaskList has it's own UTC tests.
1589 // But we can confirm that GetRenderTaskList in Stage retrieves the same RenderTaskList each time.
1590 RenderTask newTask = stage.GetRenderTaskList().CreateTask();
1592 DALI_TEST_EQUALS( stage.GetRenderTaskList().GetTask( 1 ), newTask, TEST_LOCATION );
1597 int UtcDaliStageGetRenderTaskListN(void)
1599 TestApplication app;
1602 // Check that getting the render task list with a bad stage instance causes an assert.
1603 bool asserted = false;
1606 stage.GetRenderTaskList();
1608 catch( Dali::DaliException& e )
1610 DALI_TEST_PRINT_ASSERT( e );
1611 DALI_TEST_ASSERT( e, "stage && \"Stage handle is empty\"", TEST_LOCATION );
1614 DALI_TEST_CHECK( asserted );
1619 int UtcDaliStageGetObjectRegistryP(void)
1621 TestApplication app;
1622 Stage stage = Stage::GetCurrent();
1624 ObjectRegistry objectRegistry = stage.GetObjectRegistry();
1626 // Object registry tests are covered in their own module.
1627 // However we want a basic test to confirm the returned registry is valid and works.
1628 bool verified = false;
1629 ActorCreatedFunctor test( verified );
1630 objectRegistry.ObjectCreatedSignal().Connect( &app, test );
1632 Actor actor = Actor::New();
1633 DALI_TEST_CHECK( test.mSignalVerified );
1638 int UtcDaliStageGetObjectRegistryN(void)
1640 TestApplication app;
1643 // Check that getting the object registry with a bad stage instance DOES NOT cause an assert.
1644 // This is because GetCurrent() is used, always creating a stage if one does not exist.
1645 bool asserted = false;
1648 stage.GetObjectRegistry();
1650 catch( Dali::DaliException& e )
1652 DALI_TEST_PRINT_ASSERT( e );
1655 DALI_TEST_CHECK( !asserted );
1660 int UtcDaliStageOperatorAssign(void)
1662 TestApplication app;
1664 DALI_TEST_CHECK( !stage );
1666 stage = Stage::GetCurrent();
1667 DALI_TEST_CHECK( stage );