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");
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 application.GetCore().SetDpi( 200, 180 );
596 Stage stage = Stage::GetCurrent();
597 Vector2 dpi = stage.GetDpi();
598 DALI_TEST_EQUALS( dpi.x, 200.0f, TEST_LOCATION );
599 DALI_TEST_EQUALS( dpi.y, 180.0f, TEST_LOCATION );
603 int UtcDaliStageGetDpiP3(void)
605 TestApplication application( 480, 800, 72.0f, 120.0f ); // Initializes core DPI with specific values
607 Stage stage = Stage::GetCurrent();
609 // Test that setting core DPI explicitly also sets up the Stage's DPI.
610 Vector2 dpi = stage.GetDpi();
611 DALI_TEST_EQUALS( dpi.x, 72.0f, TEST_LOCATION );
612 DALI_TEST_EQUALS( dpi.y, 120.0f, TEST_LOCATION) ;
617 * This is not a true negative test, we are checking the DPI if it has not been set.
618 * A test for setting negative DPI values would be part of the application core utc tests.
620 int UtcDaliStageGetDpiN(void)
622 TestApplication application; // Initializes core DPI to default values
624 Stage stage = Stage::GetCurrent();
625 Vector2 dpi = stage.GetDpi();
627 DALI_TEST_EQUALS( dpi.x, 220.0f, TEST_LOCATION );
628 DALI_TEST_EQUALS( dpi.y, 217.0f, TEST_LOCATION );
632 int UtcDaliStageGetLayerCountP(void)
634 TestApplication application;
636 Stage stage = Stage::GetCurrent();
638 // Initially we have a default layer
639 DALI_TEST_EQUALS( stage.GetLayerCount(), 1u, TEST_LOCATION );
641 Layer layer = Layer::New();
644 DALI_TEST_EQUALS( stage.GetLayerCount(), 2u, TEST_LOCATION );
649 * Not a true negative test, but confirms layer count is not affected by an invalid removal.
651 int UtcDaliStageGetLayerCountN(void)
653 TestApplication application;
655 Stage stage = Stage::GetCurrent();
657 // Initially we have a default layer
658 DALI_TEST_EQUALS( stage.GetLayerCount(), 1u, TEST_LOCATION );
660 Layer layer = Layer::New();
661 stage.Remove( layer );
663 // Still have 1 layer.
664 DALI_TEST_EQUALS( stage.GetLayerCount(), 1u, TEST_LOCATION );
668 int UtcDaliStageGetLayerP(void)
670 TestApplication application;
672 Stage stage = Stage::GetCurrent();
674 Layer rootLayer = stage.GetLayer( 0 );
675 DALI_TEST_CHECK( rootLayer );
677 Layer layer = Layer::New();
680 Layer sameLayer = stage.GetLayer( 1 );
681 DALI_TEST_CHECK( layer == sameLayer );
685 int UtcDaliStageGetLayerN(void)
687 TestApplication application;
689 Stage stage = Stage::GetCurrent();
691 bool asserted = false;
694 // Try to get a layer that doesn't exist (note: 0 is the root layer).
695 Layer layer = stage.GetLayer( 1 );
697 catch( Dali::DaliException& e )
699 DALI_TEST_PRINT_ASSERT( e );
700 DALI_TEST_ASSERT( e, "depth < mLayers.size()", TEST_LOCATION );
704 DALI_TEST_CHECK( asserted );
708 int UtcDaliStageGetRootLayerP(void)
710 TestApplication application;
712 Stage stage = Stage::GetCurrent();
714 Layer layer = stage.GetLayer( 0 );
715 DALI_TEST_CHECK( layer );
717 // Check that GetRootLayer() correctly retreived layer 0.
718 DALI_TEST_CHECK( stage.GetRootLayer() == layer );
723 int UtcDaliStageGetRootLayerN(void)
725 TestApplication application;
727 Stage stage = Stage::GetCurrent();
729 Layer rootLayer = stage.GetLayer( 0 );
730 DALI_TEST_CHECK( rootLayer );
731 DALI_TEST_CHECK( stage.GetRootLayer() == rootLayer );
733 // Create a new layer and attempt to lower it below the root layer.
734 Layer layer = Layer::New();
736 layer.LowerToBottom();
738 // Check that GetRootLayer still retrieves the same original layer.
739 DALI_TEST_CHECK( stage.GetRootLayer() == rootLayer );
741 // Check modifying the root layer is also blocked.
742 rootLayer.RaiseToTop();
743 DALI_TEST_CHECK( stage.GetRootLayer() == rootLayer );
748 int UtcDaliStageSetBackgroundColorP(void)
750 TestApplication application;
752 Stage stage = Stage::GetCurrent();
754 Vector4 testColor( 0.1f, 0.2f, 0.3f, 1.0f );
755 stage.SetBackgroundColor( testColor );
757 DALI_TEST_EQUALS( testColor, stage.GetBackgroundColor(), TEST_LOCATION );
761 // Note: No negative test for UtcDaliStageSetBackgroundColor as we do not wish to implement
762 // range checking for colors due to speed. Colors are clamped with glclampf within GL anyway.
764 int UtcDaliStageGetBackgroundColorP(void)
766 TestApplication application;
768 Stage stage = Stage::GetCurrent();
770 DALI_TEST_EQUALS( Stage::DEFAULT_BACKGROUND_COLOR, stage.GetBackgroundColor(), TEST_LOCATION );
774 // Note: No negative test for UtcDaliStageGetBackgroundColor as this is covered by UtcDaliStageSetBackgroundColorN.
776 int UtcDaliStageKeepRenderingP(void)
778 TestApplication application;
780 Stage stage = Stage::GetCurrent();
782 // Run core until it wants to sleep
783 bool keepUpdating( true );
784 while ( keepUpdating )
786 application.SendNotification();
787 keepUpdating = application.Render( 1000.0f /*1 second*/ );
790 // Force rendering for the next 5 seconds
791 stage.KeepRendering( 5.0f );
793 application.SendNotification();
795 // Test that core wants to sleep after 10 seconds
796 keepUpdating = application.Render( 1000.0f /*1 second*/ );
797 DALI_TEST_CHECK( keepUpdating );
798 keepUpdating = application.Render( 1000.0f /*2 seconds*/ );
799 DALI_TEST_CHECK( keepUpdating );
800 keepUpdating = application.Render( 1000.0f /*3 seconds*/ );
801 DALI_TEST_CHECK( keepUpdating );
802 keepUpdating = application.Render( 1000.0f /*4 seconds*/ );
803 DALI_TEST_CHECK( keepUpdating );
804 keepUpdating = application.Render( 1000.0f /*5 seconds*/ );
805 DALI_TEST_CHECK( !keepUpdating );
809 int UtcDaliStageKeepRenderingN(void)
811 TestApplication application;
813 Stage stage = Stage::GetCurrent();
815 // Run core until it wants to sleep
816 bool keepUpdating( true );
817 while ( keepUpdating )
819 application.SendNotification();
820 keepUpdating = application.Render( 1000.0f /*1 second*/ );
823 // Force rendering for the next 5 seconds
824 stage.KeepRendering( -1.0f );
826 application.SendNotification();
828 // Test that core wants to sleep after 10 seconds
829 keepUpdating = application.Render( 1000.0f /*1 second*/ );
830 DALI_TEST_CHECK( !keepUpdating );
835 int UtcDaliStageEventProcessingFinishedP(void)
837 TestApplication application;
838 Stage stage = Stage::GetCurrent();
840 bool eventProcessingFinished = false;
841 EventProcessingFinishedFunctor functor( eventProcessingFinished );
842 stage.EventProcessingFinishedSignal().Connect( &application, functor );
844 Actor actor( Actor::New() );
847 application.SendNotification();
848 application.Render();
850 DALI_TEST_CHECK( eventProcessingFinished );
855 int UtcDaliStageEventProcessingFinishedN(void)
857 TestApplication application;
858 Stage stage = Stage::GetCurrent();
860 bool eventProcessingFinished = false;
861 EventProcessingFinishedFunctor functor( eventProcessingFinished );
862 stage.EventProcessingFinishedSignal().Connect( &application, functor );
864 Actor actor( Actor::New() );
867 // Do not complete event processing and confirm the signal has not been emitted.
868 DALI_TEST_CHECK( !eventProcessingFinished );
873 int UtcDaliStageKeyEventGeneratedSignalP(void)
875 TestApplication application;
876 Stage stage = Stage::GetCurrent();
878 KeyEventGeneratedSignalData data;
879 KeyEventGeneratedReceivedFunctor functor( data );
880 DevelStage::KeyEventGeneratedSignal( stage ).Connect( &application, functor );
882 KeyEventGeneratedSignalData data2;
883 KeyEventGeneratedReceivedFunctor functor2( data2 );
884 GetImplementation( stage ).ConnectSignal( &application, "keyEventGenerated", functor2 );
886 Integration::KeyEvent event( "a", "a", 0, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME );
887 application.ProcessEvent( event );
889 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
890 DALI_TEST_CHECK( event.keyModifier == data.receivedKeyEvent.keyModifier );
891 DALI_TEST_CHECK( event.keyName == data.receivedKeyEvent.keyPressedName );
892 DALI_TEST_CHECK( event.keyString == data.receivedKeyEvent.keyPressed );
893 DALI_TEST_CHECK( event.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
897 Integration::KeyEvent event2( "i", "i", 0, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME );
898 application.ProcessEvent( event2 );
900 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
901 DALI_TEST_CHECK( event2.keyModifier == data.receivedKeyEvent.keyModifier );
902 DALI_TEST_CHECK( event2.keyName == data.receivedKeyEvent.keyPressedName );
903 DALI_TEST_CHECK( event2.keyString == data.receivedKeyEvent.keyPressed );
904 DALI_TEST_CHECK( event2.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
908 Integration::KeyEvent event3( "a", "a", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME );
909 application.ProcessEvent( event3 );
911 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
912 DALI_TEST_CHECK( event3.keyModifier == data.receivedKeyEvent.keyModifier );
913 DALI_TEST_CHECK( event3.keyName == data.receivedKeyEvent.keyPressedName );
914 DALI_TEST_CHECK( event3.keyString == data.receivedKeyEvent.keyPressed );
915 DALI_TEST_CHECK( event3.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
919 Integration::KeyEvent event4( "a", "a", 0, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME );
920 application.ProcessEvent( event4 );
922 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
923 DALI_TEST_CHECK( event4.keyModifier == data.receivedKeyEvent.keyModifier );
924 DALI_TEST_CHECK( event4.keyName == data.receivedKeyEvent.keyPressedName );
925 DALI_TEST_CHECK( event4.keyString == data.receivedKeyEvent.keyPressed );
926 DALI_TEST_CHECK( event4.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
930 int UtcDaliStageSignalKeyEventP(void)
932 TestApplication application;
933 Stage stage = Stage::GetCurrent();
935 KeyEventSignalData data;
936 KeyEventReceivedFunctor functor( data );
937 stage.KeyEventSignal().Connect( &application, functor );
939 Integration::KeyEvent event( "i", "i", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME );
940 application.ProcessEvent( event );
942 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
943 DALI_TEST_CHECK( event.keyModifier == data.receivedKeyEvent.keyModifier );
944 DALI_TEST_CHECK( event.keyName == data.receivedKeyEvent.keyPressedName );
945 DALI_TEST_CHECK( event.keyString == data.receivedKeyEvent.keyPressed );
946 DALI_TEST_CHECK( event.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
950 Integration::KeyEvent event2( "i", "i", 0, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME );
951 application.ProcessEvent( event2 );
953 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
954 DALI_TEST_CHECK( event2.keyModifier == data.receivedKeyEvent.keyModifier );
955 DALI_TEST_CHECK( event2.keyName == data.receivedKeyEvent.keyPressedName );
956 DALI_TEST_CHECK( event2.keyString == data.receivedKeyEvent.keyPressed );
957 DALI_TEST_CHECK( event2.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
961 Integration::KeyEvent event3( "a", "a", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME );
962 application.ProcessEvent( event3 );
964 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
965 DALI_TEST_CHECK( event3.keyModifier == data.receivedKeyEvent.keyModifier );
966 DALI_TEST_CHECK( event3.keyName == data.receivedKeyEvent.keyPressedName );
967 DALI_TEST_CHECK( event3.keyString == data.receivedKeyEvent.keyPressed );
968 DALI_TEST_CHECK( event3.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
972 Integration::KeyEvent event4( "a", "a", 0, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME );
973 application.ProcessEvent( event4 );
975 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
976 DALI_TEST_CHECK( event4.keyModifier == data.receivedKeyEvent.keyModifier );
977 DALI_TEST_CHECK( event4.keyName == data.receivedKeyEvent.keyPressedName );
978 DALI_TEST_CHECK( event4.keyString == data.receivedKeyEvent.keyPressed );
979 DALI_TEST_CHECK( event4.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
983 int UtcDaliStageSignalKeyEventN(void)
985 TestApplication application;
986 Stage stage = Stage::GetCurrent();
988 KeyEventSignalData data;
989 KeyEventReceivedFunctor functor( data );
990 stage.KeyEventSignal().Connect( &application, functor );
992 // Check that a non-pressed key events data is not modified.
993 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
998 int UtcDaliStageTouchedSignalP(void)
1000 TestApplication application;
1001 Stage stage = Stage::GetCurrent();
1003 TouchedSignalData data;
1004 TouchedFunctor functor( data );
1005 stage.TouchedSignal().Connect( &application, functor );
1007 // Render and notify.
1008 application.SendNotification();
1009 application.Render();
1011 // Basic test: No actors, single touch (down then up).
1013 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1015 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1016 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1017 DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
1020 GenerateTouch( application, PointState::UP, Vector2( 10.0f, 10.0f ) );
1022 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1023 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1024 DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
1028 // Add an actor to the scene.
1029 Actor actor = Actor::New();
1030 actor.SetSize( 100.0f, 100.0f );
1031 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1032 actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1033 actor.TouchedSignal().Connect( &DummyTouchCallback );
1036 // Render and notify.
1037 application.SendNotification();
1038 application.Render();
1040 // Actor on scene, single touch, down in actor, motion, then up outside actor.
1042 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1044 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1045 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1046 DALI_TEST_CHECK( data.receivedTouchEvent.points[0].hitActor == actor );
1049 GenerateTouch( application, PointState::MOTION, Vector2( 150.0f, 10.0f ) ); // Some motion
1051 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1054 GenerateTouch( application, PointState::UP, Vector2( 150.0f, 10.0f ) ); // Some motion
1056 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1057 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1058 DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
1062 // Multiple touch. Should only receive a touch on first down and last up.
1064 Integration::TouchEvent touchEvent;
1065 Integration::Point point;
1068 point.SetState( PointState::DOWN );
1069 point.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
1070 touchEvent.points.push_back( point );
1071 application.ProcessEvent( touchEvent );
1072 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1073 DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 1u, TEST_LOCATION );
1077 touchEvent.points[0].SetState( PointState::STATIONARY );
1078 point.SetDeviceId( 1 );
1079 point.SetScreenPosition( Vector2( 50.0f, 50.0f ) );
1080 touchEvent.points.push_back( point );
1081 application.ProcessEvent( touchEvent );
1082 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1083 DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 0u, TEST_LOCATION );
1086 // Primary point is up
1087 touchEvent.points[0].SetState( PointState::UP );
1088 touchEvent.points[1].SetState( PointState::STATIONARY );
1089 application.ProcessEvent( touchEvent );
1090 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1091 DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 0u, TEST_LOCATION );
1094 // Remove 1st point now, 2nd point is now in motion
1095 touchEvent.points.erase( touchEvent.points.begin() );
1096 touchEvent.points[0].SetState( PointState::MOTION );
1097 touchEvent.points[0].SetScreenPosition( Vector2( 150.0f, 50.0f ) );
1098 application.ProcessEvent( touchEvent );
1099 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1100 DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 0u, TEST_LOCATION );
1104 touchEvent.points[0].SetState( PointState::UP );
1105 application.ProcessEvent( touchEvent );
1106 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1107 DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 1u, TEST_LOCATION );
1113 int UtcDaliStageTouchedSignalN(void)
1115 TestApplication application;
1116 Stage stage = Stage::GetCurrent();
1118 TouchedSignalData data;
1119 TouchedFunctor functor( data );
1120 stage.TouchedSignal().Connect( &application, functor );
1122 // Render and notify.
1123 application.SendNotification();
1124 application.Render();
1126 // Confirm functor not called before there has been any touch event.
1127 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1129 // No actors, single touch, down, motion then up.
1131 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1133 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1134 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1135 DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
1138 // Confirm there is no signal when the touchpoint is only moved.
1139 GenerateTouch( application, PointState::MOTION, Vector2( 1200.0f, 10.0f ) ); // Some motion
1141 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1144 // Confirm a following up event generates a signal.
1145 GenerateTouch( application, PointState::UP, Vector2( 1200.0f, 10.0f ) );
1147 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1148 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1149 DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
1153 // Add an actor to the scene.
1154 Actor actor = Actor::New();
1155 actor.SetSize( 100.0f, 100.0f );
1156 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1157 actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1158 actor.TouchedSignal().Connect( &DummyTouchCallback );
1161 // Render and notify.
1162 application.SendNotification();
1163 application.Render();
1165 // Actor on scene. Interrupted before down and interrupted after down.
1167 GenerateTouch( application, PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) );
1169 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1170 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1171 DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
1172 DALI_TEST_CHECK( data.receivedTouchEvent.points[0].state == TouchPoint::Interrupted );
1175 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1177 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1178 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1179 DALI_TEST_CHECK( data.receivedTouchEvent.points[0].hitActor == actor );
1180 DALI_TEST_CHECK( data.receivedTouchEvent.points[0].state == TouchPoint::Down );
1183 GenerateTouch( application, PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) );
1185 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1186 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1187 DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
1188 DALI_TEST_CHECK( data.receivedTouchEvent.points[0].state == TouchPoint::Interrupted );
1190 DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 1u, TEST_LOCATION );
1192 // Check that getting info about a non-existent point causes an assert.
1193 bool asserted = false;
1196 data.receivedTouchEvent.GetPoint( 1 );
1198 catch( Dali::DaliException& e )
1200 DALI_TEST_PRINT_ASSERT( e );
1201 DALI_TEST_ASSERT( e, "point < points.size() && \"No point at index\"", TEST_LOCATION );
1204 DALI_TEST_CHECK( asserted );
1213 int UtcDaliStageTouchSignalP(void)
1215 TestApplication application;
1216 Stage stage = Stage::GetCurrent();
1218 TouchedSignalData data;
1219 TouchFunctor functor( data );
1220 stage.TouchSignal().Connect( &application, functor );
1222 // Render and notify.
1223 application.SendNotification();
1224 application.Render();
1226 // Basic test: No actors, single touch (down then up).
1228 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1230 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1231 DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1232 DALI_TEST_CHECK( !data.receivedTouchData.GetHitActor(0) );
1235 GenerateTouch( application, PointState::UP, Vector2( 10.0f, 10.0f ) );
1237 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1238 DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1239 DALI_TEST_CHECK( !data.receivedTouchData.GetHitActor(0) );
1243 // Add an actor to the scene.
1244 Actor actor = Actor::New();
1245 actor.SetSize( 100.0f, 100.0f );
1246 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1247 actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1248 actor.TouchedSignal().Connect( &DummyTouchCallback );
1251 // Render and notify.
1252 application.SendNotification();
1253 application.Render();
1255 // Actor on scene, single touch, down in actor, motion, then up outside actor.
1257 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1259 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1260 DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1261 DALI_TEST_CHECK( data.receivedTouchData.GetHitActor(0) == actor );
1264 GenerateTouch( application, PointState::MOTION, Vector2( 150.0f, 10.0f ) ); // Some motion
1266 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1269 GenerateTouch( application, PointState::UP, Vector2( 150.0f, 10.0f ) ); // Some motion
1271 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1272 DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1273 DALI_TEST_CHECK( !data.receivedTouchData.GetHitActor(0) );
1277 // Multiple touch. Should only receive a touch on first down and last up.
1279 Integration::TouchEvent touchEvent;
1280 Integration::Point point;
1283 point.SetState( PointState::DOWN );
1284 point.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
1285 touchEvent.points.push_back( point );
1286 application.ProcessEvent( touchEvent );
1287 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1288 DALI_TEST_EQUALS( data.receivedTouchData.GetPointCount(), 1u, TEST_LOCATION );
1292 touchEvent.points[0].SetState( PointState::STATIONARY );
1293 point.SetDeviceId( 1 );
1294 point.SetScreenPosition( Vector2( 50.0f, 50.0f ) );
1295 touchEvent.points.push_back( point );
1296 application.ProcessEvent( touchEvent );
1297 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1300 // Primary point is up
1301 touchEvent.points[0].SetState( PointState::UP );
1302 touchEvent.points[1].SetState( PointState::STATIONARY );
1303 application.ProcessEvent( touchEvent );
1304 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1307 // Remove 1st point now, 2nd point is now in motion
1308 touchEvent.points.erase( touchEvent.points.begin() );
1309 touchEvent.points[0].SetState( PointState::MOTION );
1310 touchEvent.points[0].SetScreenPosition( Vector2( 150.0f, 50.0f ) );
1311 application.ProcessEvent( touchEvent );
1312 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1316 touchEvent.points[0].SetState( PointState::UP );
1317 application.ProcessEvent( touchEvent );
1318 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1319 DALI_TEST_EQUALS( data.receivedTouchData.GetPointCount(), 1u, TEST_LOCATION );
1325 int UtcDaliStageTouchSignalN(void)
1327 TestApplication application;
1328 Stage stage = Stage::GetCurrent();
1330 TouchedSignalData data;
1331 TouchFunctor functor( data );
1332 stage.TouchSignal().Connect( &application, functor );
1334 TouchedSignalData data2;
1335 TouchFunctor functor2( data2 );
1336 GetImplementation( stage ).ConnectSignal( &application, "touch", functor2 );
1338 // Render and notify.
1339 application.SendNotification();
1340 application.Render();
1342 // Confirm functor not called before there has been any touch event.
1343 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1344 DALI_TEST_EQUALS( false, data2.functorCalled, TEST_LOCATION );
1346 // No actors, single touch, down, motion then up.
1348 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1350 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1351 DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1352 DALI_TEST_CHECK( !data.receivedTouchData.GetHitActor(0));
1354 DALI_TEST_EQUALS( true, data2.functorCalled, TEST_LOCATION );
1359 // Confirm there is no signal when the touchpoint is only moved.
1360 GenerateTouch( application, PointState::MOTION, Vector2( 1200.0f, 10.0f ) ); // Some motion
1362 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1365 // Confirm a following up event generates a signal.
1366 GenerateTouch( application, PointState::UP, Vector2( 1200.0f, 10.0f ) );
1368 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1369 DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1370 DALI_TEST_CHECK( !data.receivedTouchData.GetHitActor(0));
1374 // Add an actor to the scene.
1375 Actor actor = Actor::New();
1376 actor.SetSize( 100.0f, 100.0f );
1377 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1378 actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1379 actor.TouchedSignal().Connect( &DummyTouchCallback );
1382 // Render and notify.
1383 application.SendNotification();
1384 application.Render();
1386 // Actor on scene. Interrupted before down and interrupted after down.
1388 GenerateTouch( application, PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) );
1390 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1391 DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1392 DALI_TEST_CHECK( !data.receivedTouchData.GetHitActor(0) );
1393 DALI_TEST_CHECK( data.receivedTouchData.GetState(0) == PointState::INTERRUPTED );
1396 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1398 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1399 DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1400 DALI_TEST_CHECK( data.receivedTouchData.GetHitActor(0) == actor );
1401 DALI_TEST_CHECK( data.receivedTouchData.GetState(0) == PointState::DOWN );
1404 GenerateTouch( application, PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) );
1406 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1407 DALI_TEST_CHECK( data.receivedTouchData.GetPointCount() != 0u );
1408 DALI_TEST_CHECK( !data.receivedTouchData.GetHitActor(0) );
1409 DALI_TEST_CHECK( data.receivedTouchData.GetState(0) == PointState::INTERRUPTED );
1411 DALI_TEST_EQUALS( data.receivedTouchData.GetPointCount(), 1u, TEST_LOCATION );
1413 // Check that getting info about a non-existent point returns an empty handle
1414 Actor actor = data.receivedTouchData.GetHitActor( 1 );
1415 DALI_TEST_CHECK( !actor );
1423 int UtcDaliStageSignalWheelEventP(void)
1425 TestApplication application;
1426 Stage stage = Stage::GetCurrent();
1428 WheelEventSignalData data;
1429 WheelEventReceivedFunctor functor( data );
1430 stage.WheelEventSignal().Connect( &application, functor );
1432 Integration::WheelEvent event( Integration::WheelEvent::CUSTOM_WHEEL, 0, 0u, Vector2( 0.0f, 0.0f ), 1, 1000u );
1433 application.ProcessEvent( event );
1435 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1436 DALI_TEST_CHECK( static_cast< WheelEvent::Type >(event.type) == data.receivedWheelEvent.type );
1437 DALI_TEST_CHECK( event.direction == data.receivedWheelEvent.direction );
1438 DALI_TEST_CHECK( event.modifiers == data.receivedWheelEvent.modifiers );
1439 DALI_TEST_CHECK( event.point == data.receivedWheelEvent.point );
1440 DALI_TEST_CHECK( event.z == data.receivedWheelEvent.z );
1441 DALI_TEST_CHECK( event.timeStamp == data.receivedWheelEvent.timeStamp );
1445 Integration::WheelEvent event2( Integration::WheelEvent::CUSTOM_WHEEL, 0, 0u, Vector2( 0.0f, 0.0f ), -1, 1000u );
1446 application.ProcessEvent( event2 );
1448 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1449 DALI_TEST_CHECK( static_cast< WheelEvent::Type >(event2.type) == data.receivedWheelEvent.type );
1450 DALI_TEST_CHECK( event2.direction == data.receivedWheelEvent.direction );
1451 DALI_TEST_CHECK( event2.modifiers == data.receivedWheelEvent.modifiers );
1452 DALI_TEST_CHECK( event2.point == data.receivedWheelEvent.point );
1453 DALI_TEST_CHECK( event2.z == data.receivedWheelEvent.z );
1454 DALI_TEST_CHECK( event2.timeStamp == data.receivedWheelEvent.timeStamp );
1458 int UtcDaliStageContextLostSignalP(void)
1460 TestApplication app;
1461 Stage stage = Stage::GetCurrent();
1463 bool contextLost = false;
1464 ContextStatusFunctor contextLostFunctor( contextLost );
1465 stage.ContextLostSignal().Connect( &app, contextLostFunctor );
1467 Integration::ContextNotifierInterface* notifier = app.GetCore().GetContextNotifier();
1468 notifier->NotifyContextLost();
1469 DALI_TEST_EQUALS( contextLost, true, TEST_LOCATION );
1474 int UtcDaliStageContextLostSignalN(void)
1476 TestApplication app;
1479 // Check that connecting to the signal with a bad stage instance causes an assert.
1480 bool asserted = false;
1481 bool contextLost = false;
1482 ContextStatusFunctor contextLostFunctor( contextLost );
1485 stage.ContextLostSignal().Connect( &app, contextLostFunctor );
1487 catch( Dali::DaliException& e )
1489 DALI_TEST_PRINT_ASSERT( e );
1490 DALI_TEST_ASSERT( e, "stage && \"Stage handle is empty\"", TEST_LOCATION );
1493 DALI_TEST_CHECK( asserted );
1498 int UtcDaliStageContextRegainedSignalP(void)
1500 TestApplication app;
1501 Stage stage = Stage::GetCurrent();
1503 bool contextRegained = false;
1504 ContextStatusFunctor contextRegainedFunctor( contextRegained );
1505 stage.ContextRegainedSignal().Connect( &app, contextRegainedFunctor );
1507 Integration::ContextNotifierInterface* notifier = app.GetCore().GetContextNotifier();
1508 notifier->NotifyContextLost();
1509 notifier->NotifyContextRegained();
1510 DALI_TEST_EQUALS( contextRegained, true, TEST_LOCATION );
1515 int UtcDaliStageContextRegainedSignalN(void)
1517 TestApplication app;
1520 // Check that connecting to the signal with a bad stage instance causes an assert.
1521 bool asserted = false;
1522 bool contextRegained = false;
1523 ContextStatusFunctor contextRegainedFunctor( contextRegained );
1526 stage.ContextRegainedSignal().Connect( &app, contextRegainedFunctor );
1528 catch( Dali::DaliException& e )
1530 DALI_TEST_PRINT_ASSERT( e );
1531 DALI_TEST_ASSERT( e, "stage && \"Stage handle is empty\"", TEST_LOCATION );
1534 DALI_TEST_CHECK( asserted );
1539 int UtcDaliStageSceneCreatedSignalP(void)
1541 TestApplication app;
1542 Stage stage = Stage::GetCurrent();
1544 bool signalCalled = false;
1545 SceneCreatedStatusFunctor sceneCreatedFunctor( signalCalled );
1546 stage.SceneCreatedSignal().Connect( &app, sceneCreatedFunctor );
1548 Integration::Core& core = app.GetCore();
1549 core.SceneCreated();
1550 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
1555 int UtcDaliStageSceneCreatedSignalN(void)
1557 TestApplication app;
1560 // Check that connecting to the signal with a bad stage instance causes an assert.
1561 bool asserted = false;
1562 bool signalCalled = false;
1563 SceneCreatedStatusFunctor sceneCreatedFunctor( signalCalled );
1566 stage.SceneCreatedSignal().Connect( &app, sceneCreatedFunctor );
1568 catch( Dali::DaliException& e )
1570 DALI_TEST_PRINT_ASSERT( e );
1571 DALI_TEST_ASSERT( e, "stage && \"Stage handle is empty\"", TEST_LOCATION );
1574 DALI_TEST_CHECK( asserted );
1579 int UtcDaliStageGetRenderTaskListP(void)
1581 TestApplication app;
1582 Stage stage = Stage::GetCurrent();
1584 // Check we get a valid instance.
1585 const RenderTaskList& tasks = stage.GetRenderTaskList();
1587 // There should be 1 task by default.
1588 DALI_TEST_EQUALS( tasks.GetTaskCount(), 1u, TEST_LOCATION );
1590 // RenderTaskList has it's own UTC tests.
1591 // But we can confirm that GetRenderTaskList in Stage retrieves the same RenderTaskList each time.
1592 RenderTask newTask = stage.GetRenderTaskList().CreateTask();
1594 DALI_TEST_EQUALS( stage.GetRenderTaskList().GetTask( 1 ), newTask, TEST_LOCATION );
1599 int UtcDaliStageGetRenderTaskListN(void)
1601 TestApplication app;
1604 // Check that getting the render task list with a bad stage instance causes an assert.
1605 bool asserted = false;
1608 stage.GetRenderTaskList();
1610 catch( Dali::DaliException& e )
1612 DALI_TEST_PRINT_ASSERT( e );
1613 DALI_TEST_ASSERT( e, "stage && \"Stage handle is empty\"", TEST_LOCATION );
1616 DALI_TEST_CHECK( asserted );
1621 int UtcDaliStageGetObjectRegistryP(void)
1623 TestApplication app;
1624 Stage stage = Stage::GetCurrent();
1626 ObjectRegistry objectRegistry = stage.GetObjectRegistry();
1628 // Object registry tests are covered in their own module.
1629 // However we want a basic test to confirm the returned registry is valid and works.
1630 bool verified = false;
1631 ActorCreatedFunctor test( verified );
1632 objectRegistry.ObjectCreatedSignal().Connect( &app, test );
1634 Actor actor = Actor::New();
1635 DALI_TEST_CHECK( test.mSignalVerified );
1640 int UtcDaliStageGetObjectRegistryN(void)
1642 TestApplication app;
1645 // Check that getting the object registry with a bad stage instance DOES NOT cause an assert.
1646 // This is because GetCurrent() is used, always creating a stage if one does not exist.
1647 bool asserted = false;
1650 stage.GetObjectRegistry();
1652 catch( Dali::DaliException& e )
1654 DALI_TEST_PRINT_ASSERT( e );
1657 DALI_TEST_CHECK( !asserted );
1662 int UtcDaliStageOperatorAssign(void)
1664 TestApplication app;
1666 DALI_TEST_CHECK( !stage );
1668 stage = Stage::GetCurrent();
1669 DALI_TEST_CHECK( stage );