2 * Copyright (c) 2020 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.Reset();
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.Reset();
124 KeyEvent receivedKeyEvent;
127 // Functor that sets the data when called
128 struct KeyEventReceivedFunctor
130 KeyEventReceivedFunctor( KeyEventSignalData& data ) : signalData( data ) { }
132 bool operator()( const KeyEvent& keyEvent )
134 signalData.functorCalled = true;
135 signalData.receivedKeyEvent = keyEvent;
140 KeyEventSignalData& signalData;
143 // Stores data that is populated in the touched signal callback and will be read by the TET cases
144 struct TouchSignalData
147 : functorCalled(false)
152 functorCalled = false;
154 receivedTouchEvent.Reset();
158 TouchEvent receivedTouchEvent;
161 // Functor that sets the data when touched signal is received
164 TouchFunctor( TouchSignalData& data ) : signalData( data ) { }
166 void operator()( const TouchEvent& touch )
168 signalData.functorCalled = true;
169 TouchEvent handle(touch);
170 signalData.receivedTouchEvent = handle;
175 signalData.functorCalled = true;
178 TouchSignalData& signalData;
181 // Stores data that is populated in the wheel-event callback and will be read by the TET cases
182 struct WheelEventSignalData
184 WheelEventSignalData()
185 : functorCalled(false)
190 functorCalled = false;
194 WheelEvent receivedWheelEvent;
197 // Functor that sets the data when wheel-event signal is received
198 struct WheelEventReceivedFunctor
200 WheelEventReceivedFunctor( WheelEventSignalData& data ) : signalData( data ) { }
202 bool operator()( const WheelEvent& wheelEvent )
204 signalData.functorCalled = true;
205 signalData.receivedWheelEvent = wheelEvent;
210 WheelEventSignalData& signalData;
213 bool DummyTouchCallback( Actor actor, const TouchEvent& touch )
218 struct ContextStatusFunctor
220 ContextStatusFunctor(bool& calledFlag) : mCalledFlag( calledFlag )
237 struct SceneCreatedStatusFunctor
239 SceneCreatedStatusFunctor(bool& calledFlag) : mCalledFlag( calledFlag )
256 struct ActorCreatedFunctor
258 ActorCreatedFunctor( bool& signalReceived )
259 : mSignalVerified( signalReceived )
263 void operator()( BaseHandle object )
265 tet_infoline( "Verifying TestActorCallback()" );
266 Actor actor = Actor::DownCast( object );
269 mSignalVerified = true;
273 bool& mSignalVerified;
276 void GenerateTouch( TestApplication& application, PointState::Type state, const Vector2& screenPosition )
278 Integration::TouchEvent touchEvent;
279 Integration::Point point;
280 point.SetState( state );
281 point.SetScreenPosition( screenPosition );
282 touchEvent.points.push_back( point );
283 application.ProcessEvent( touchEvent );
286 } // unnamed namespace
289 int UtcDaliStageDefaultConstructorP(void)
291 TestApplication application;
294 DALI_TEST_CHECK( !stage );
298 // Note: No negative test for default constructor.
300 int UtcDaliStageDestructorP(void)
302 TestApplication application;
303 Stage* stage = new Stage();
307 DALI_TEST_CHECK( true );
311 // Note: No negative test for default destructor.
313 int UtcDaliStageGetCurrentP(void)
315 TestApplication application;
316 Stage stage = Stage::GetCurrent();
318 DALI_TEST_CHECK( stage );
322 int UtcDaliStageGetCurrentN(void)
324 bool asserted = false;
327 Stage stage = Stage::GetCurrent();
329 catch( Dali::DaliException& e )
331 DALI_TEST_PRINT_ASSERT( e );
332 DALI_TEST_ASSERT( e, "stage && \"Stage doesn't exist\"", TEST_LOCATION );
336 DALI_TEST_CHECK( asserted );
340 int UtcDaliStageIsInstalledP(void)
342 TestApplication application;
346 DALI_TEST_CHECK( Stage::IsInstalled() );
350 int UtcDaliStageIsInstalledN(void)
352 DALI_TEST_CHECK( !Stage::IsInstalled() );
357 int UtcDaliStageCopyConstructorP(void)
359 TestApplication application;
360 Stage stage = Stage::GetCurrent();
362 Stage copyStage( stage );
364 DALI_TEST_CHECK( copyStage );
365 DALI_TEST_CHECK( copyStage.GetRootLayer() == stage.GetRootLayer() );
370 // Note: no negative test for UtcDaliStageCopyConstructor.
372 int UtcDaliStageAssignmentOperatorP(void)
374 TestApplication application;
375 const Stage stage = Stage::GetCurrent();
377 Stage copyStage = stage;
379 DALI_TEST_CHECK( copyStage );
380 DALI_TEST_CHECK( copyStage.GetRootLayer() == stage.GetRootLayer() );
385 // Note: No negative test for UtcDaliStageAssignmentOperator.
387 int UtcDaliStageAddP(void)
389 TestApplication application;
391 Stage stage = Stage::GetCurrent();
393 Actor actor = Actor::New();
394 DALI_TEST_CHECK( !actor.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) );
397 DALI_TEST_CHECK( actor.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) );
401 int UtcDaliStageAddN(void)
403 TestApplication application;
405 Stage stage = Stage::GetCurrent();
408 bool asserted = false;
413 catch( Dali::DaliException& e )
415 DALI_TEST_PRINT_ASSERT( e );
416 DALI_TEST_ASSERT( e, "actor && \"Actor handle is empty\"", TEST_LOCATION );
420 DALI_TEST_CHECK( asserted );
425 int UtcDaliStageRemoveP(void)
427 TestApplication application;
429 Stage stage = Stage::GetCurrent();
431 Actor actor = Actor::New();
432 DALI_TEST_CHECK( !actor.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) );
435 DALI_TEST_CHECK( actor.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) );
438 DALI_TEST_CHECK( !actor.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) );
442 int UtcDaliStageRemoveN1(void)
444 TestApplication application;
446 Stage stage = Stage::GetCurrent();
449 bool asserted = false;
452 // Actor is not valid, confirm a removal attempt does assert.
453 stage.Remove( actor );
455 catch( Dali::DaliException& e )
457 DALI_TEST_PRINT_ASSERT( e );
458 DALI_TEST_ASSERT( e, "actor && \"Actor handle is empty\"", TEST_LOCATION );
462 DALI_TEST_CHECK( asserted );
466 int UtcDaliStageRemoveN2(void)
468 TestApplication application;
470 Stage stage = Stage::GetCurrent();
471 Actor actor = Actor::New();
472 DALI_TEST_CHECK( !actor.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) );
474 bool asserted = false;
477 // Actor is not on stage, confirm a removal attempt does not assert / segfault.
478 stage.Remove( actor );
480 catch( Dali::DaliException& e )
482 DALI_TEST_PRINT_ASSERT( e );
486 DALI_TEST_CHECK( !asserted );
490 int UtcDaliStageRemoveN3(void)
492 TestApplication application;
494 Stage stage = Stage::GetCurrent();
496 // Initially we have a default layer
497 DALI_TEST_EQUALS( stage.GetLayerCount(), 1u, TEST_LOCATION );
499 // Check we cannot remove the root layer from the stage.
500 Layer layer = stage.GetRootLayer();
501 bool asserted = true;
504 stage.Remove( layer );
506 catch( Dali::DaliException& e )
508 DALI_TEST_PRINT_ASSERT( e );
509 DALI_TEST_ASSERT( e, "this != &child && \"Cannot remove actor from itself\"", TEST_LOCATION );
513 DALI_TEST_CHECK( asserted );
514 DALI_TEST_EQUALS( stage.GetLayerCount(), 1u, TEST_LOCATION );
518 int UtcDaliStageGetSizeP(void)
520 TestApplication application;
522 Stage stage = Stage::GetCurrent();
524 Vector2 size = stage.GetSize();
526 DALI_TEST_EQUALS( size.width, static_cast<float>( TestApplication::DEFAULT_SURFACE_WIDTH ), TEST_LOCATION );
527 DALI_TEST_EQUALS( size.height, static_cast<float>( TestApplication::DEFAULT_SURFACE_HEIGHT ), TEST_LOCATION );
531 int UtcDaliStageGetSizeN(void)
533 TestApplication application;
537 bool asserted = false;
541 size = stage.GetSize();
543 catch( Dali::DaliException& e )
545 DALI_TEST_PRINT_ASSERT( e );
546 DALI_TEST_ASSERT( e, "stage && \"Stage handle is empty\"", TEST_LOCATION );
550 DALI_TEST_CHECK( asserted );
554 int UtcDaliStageGetDpiP1(void)
556 TestApplication application; // Initializes core DPI to default values
558 Stage stage = Stage::GetCurrent();
560 // Test the default DPI.
561 Vector2 dpi = stage.GetDpi();
562 DALI_TEST_EQUALS( dpi.x, static_cast<float>( TestApplication::DEFAULT_HORIZONTAL_DPI ), TEST_LOCATION );
563 DALI_TEST_EQUALS( dpi.y, static_cast<float>( TestApplication::DEFAULT_VERTICAL_DPI ), TEST_LOCATION );
567 int UtcDaliStageGetDpiP2(void)
569 TestApplication application; // Initializes core DPI to default values
571 // Test that setting core DPI explicitly also sets up the Stage's DPI.
572 Dali::Integration::Scene scene = application.GetScene();
573 scene.SetDpi( Vector2(200.0f, 180.0f) );
575 Stage stage = Stage::GetCurrent();
576 Vector2 dpi = stage.GetDpi();
577 DALI_TEST_EQUALS( dpi.x, 200.0f, TEST_LOCATION );
578 DALI_TEST_EQUALS( dpi.y, 180.0f, TEST_LOCATION );
582 int UtcDaliStageGetDpiP3(void)
584 TestApplication application( 480, 800, 72, 120 ); // Initializes core DPI with specific values
586 Stage stage = Stage::GetCurrent();
588 // Test that setting core DPI explicitly also sets up the Stage's DPI.
589 Vector2 dpi = stage.GetDpi();
590 DALI_TEST_EQUALS( dpi.x, 72.0f, TEST_LOCATION );
591 DALI_TEST_EQUALS( dpi.y, 120.0f, TEST_LOCATION) ;
596 * This is not a true negative test, we are checking the DPI if it has not been set.
597 * A test for setting negative DPI values would be part of the application core utc tests.
599 int UtcDaliStageGetDpiN(void)
601 TestApplication application; // Initializes core DPI to default values
603 Stage stage = Stage::GetCurrent();
604 Vector2 dpi = stage.GetDpi();
606 DALI_TEST_EQUALS( dpi.x, 220.0f, TEST_LOCATION );
607 DALI_TEST_EQUALS( dpi.y, 217.0f, TEST_LOCATION );
611 int UtcDaliStageGetLayerCountP(void)
613 TestApplication application;
615 Stage stage = Stage::GetCurrent();
617 // Initially we have a default layer
618 DALI_TEST_EQUALS( stage.GetLayerCount(), 1u, TEST_LOCATION );
620 Layer layer = Layer::New();
623 DALI_TEST_EQUALS( stage.GetLayerCount(), 2u, TEST_LOCATION );
628 * Not a true negative test, but confirms layer count is not affected by an invalid removal.
630 int UtcDaliStageGetLayerCountN(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();
640 stage.Remove( layer );
642 // Still have 1 layer.
643 DALI_TEST_EQUALS( stage.GetLayerCount(), 1u, TEST_LOCATION );
647 int UtcDaliStageGetLayerP(void)
649 TestApplication application;
651 Stage stage = Stage::GetCurrent();
653 Layer rootLayer = stage.GetLayer( 0 );
654 DALI_TEST_CHECK( rootLayer );
656 Layer layer = Layer::New();
659 Layer sameLayer = stage.GetLayer( 1 );
660 DALI_TEST_CHECK( layer == sameLayer );
664 int UtcDaliStageGetLayerN(void)
666 TestApplication application;
668 Stage stage = Stage::GetCurrent();
670 bool asserted = false;
673 // Try to get a layer that doesn't exist (note: 0 is the root layer).
674 Layer layer = stage.GetLayer( 1 );
676 catch( Dali::DaliException& e )
678 DALI_TEST_PRINT_ASSERT( e );
679 DALI_TEST_ASSERT( e, "depth < mLayers.size()", TEST_LOCATION );
683 DALI_TEST_CHECK( asserted );
687 int UtcDaliStageGetRootLayerP(void)
689 TestApplication application;
691 Stage stage = Stage::GetCurrent();
693 Layer layer = stage.GetLayer( 0 );
694 DALI_TEST_CHECK( layer );
696 // Check that GetRootLayer() correctly retreived layer 0.
697 DALI_TEST_CHECK( stage.GetRootLayer() == layer );
702 int UtcDaliStageGetRootLayerN(void)
704 TestApplication application;
706 Stage stage = Stage::GetCurrent();
708 Layer rootLayer = stage.GetLayer( 0 );
709 DALI_TEST_CHECK( rootLayer );
710 DALI_TEST_CHECK( stage.GetRootLayer() == rootLayer );
712 // Create a new layer and attempt to lower it below the root layer.
713 Layer layer = Layer::New();
715 layer.LowerToBottom();
717 // Check that GetRootLayer still retrieves the same original layer.
718 DALI_TEST_CHECK( stage.GetRootLayer() == rootLayer );
720 // Check modifying the root layer is also blocked.
721 rootLayer.RaiseToTop();
722 DALI_TEST_CHECK( stage.GetRootLayer() == rootLayer );
727 int UtcDaliStageSetBackgroundColorP(void)
729 TestApplication application;
731 Stage stage = Stage::GetCurrent();
733 Vector4 testColor( 0.1f, 0.2f, 0.3f, 1.0f );
734 stage.SetBackgroundColor( testColor );
736 DALI_TEST_EQUALS( testColor, stage.GetBackgroundColor(), TEST_LOCATION );
740 // Note: No negative test for UtcDaliStageSetBackgroundColor as we do not wish to implement
741 // range checking for colors due to speed. Colors are clamped with glclampf within GL anyway.
743 int UtcDaliStageGetBackgroundColorP(void)
745 TestApplication application;
747 Stage stage = Stage::GetCurrent();
749 DALI_TEST_EQUALS( DEFAULT_BACKGROUND_COLOR, stage.GetBackgroundColor(), TEST_LOCATION );
753 // Note: No negative test for UtcDaliStageGetBackgroundColor as this is covered by UtcDaliStageSetBackgroundColorN.
755 int UtcDaliStageKeepRenderingP(void)
757 TestApplication application;
759 Stage stage = Stage::GetCurrent();
761 // Run core until it wants to sleep
762 bool keepUpdating( true );
763 while ( keepUpdating )
765 application.SendNotification();
766 keepUpdating = application.Render( 1000.0f /*1 second*/ );
769 // Force rendering for the next 5 seconds
770 stage.KeepRendering( 5.0f );
772 application.SendNotification();
774 // Test that core wants to sleep after 10 seconds
775 keepUpdating = application.Render( 1000.0f /*1 second*/ );
776 DALI_TEST_CHECK( keepUpdating );
777 keepUpdating = application.Render( 1000.0f /*2 seconds*/ );
778 DALI_TEST_CHECK( keepUpdating );
779 keepUpdating = application.Render( 1000.0f /*3 seconds*/ );
780 DALI_TEST_CHECK( keepUpdating );
781 keepUpdating = application.Render( 1000.0f /*4 seconds*/ );
782 DALI_TEST_CHECK( keepUpdating );
783 keepUpdating = application.Render( 1000.0f /*5 seconds*/ );
784 DALI_TEST_CHECK( !keepUpdating );
788 int UtcDaliStageKeepRenderingN(void)
790 TestApplication application;
792 Stage stage = Stage::GetCurrent();
794 // Run core until it wants to sleep
795 bool keepUpdating( true );
796 while ( keepUpdating )
798 application.SendNotification();
799 keepUpdating = application.Render( 1000.0f /*1 second*/ );
802 // Force rendering for the next 5 seconds
803 stage.KeepRendering( -1.0f );
805 application.SendNotification();
807 // Test that core wants to sleep after 10 seconds
808 keepUpdating = application.Render( 1000.0f /*1 second*/ );
809 DALI_TEST_CHECK( !keepUpdating );
814 int UtcDaliStageEventProcessingFinishedP(void)
816 TestApplication application;
817 Stage stage = Stage::GetCurrent();
819 bool eventProcessingFinished = false;
820 EventProcessingFinishedFunctor functor( eventProcessingFinished );
821 stage.EventProcessingFinishedSignal().Connect( &application, functor );
823 Actor actor( Actor::New() );
826 application.SendNotification();
827 application.Render();
829 DALI_TEST_CHECK( eventProcessingFinished );
834 int UtcDaliStageEventProcessingFinishedN(void)
836 TestApplication application;
837 Stage stage = Stage::GetCurrent();
839 bool eventProcessingFinished = false;
840 EventProcessingFinishedFunctor functor( eventProcessingFinished );
841 stage.EventProcessingFinishedSignal().Connect( &application, functor );
843 Actor actor( Actor::New() );
846 // Do not complete event processing and confirm the signal has not been emitted.
847 DALI_TEST_CHECK( !eventProcessingFinished );
852 int UtcDaliStageKeyEventGeneratedSignalP(void)
854 TestApplication application;
855 Stage stage = Stage::GetCurrent();
857 KeyEventGeneratedSignalData data;
858 KeyEventGeneratedReceivedFunctor functor( data );
859 DevelStage::KeyEventGeneratedSignal( stage ).Connect( &application, functor );
861 KeyEventGeneratedSignalData data2;
862 KeyEventGeneratedReceivedFunctor functor2( data2 );
863 GetImplementation( stage ).ConnectSignal( &application, "keyEventGenerated", functor2 );
865 Integration::KeyEvent event( "a", "", "a", 0, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
866 application.ProcessEvent( event );
868 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
869 DALI_TEST_CHECK( event.keyModifier == data.receivedKeyEvent.GetKeyModifier() );
870 DALI_TEST_CHECK( event.keyName == data.receivedKeyEvent.GetKeyName() );
871 DALI_TEST_CHECK( event.keyString == data.receivedKeyEvent.GetKeyString() );
872 DALI_TEST_CHECK( event.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.GetState() ) );
876 Integration::KeyEvent event2( "i", "", "i", 0, 0, 0, Integration::KeyEvent::UP, "i", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
877 application.ProcessEvent( event2 );
879 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
880 DALI_TEST_CHECK( event2.keyModifier == data.receivedKeyEvent.GetKeyModifier() );
881 DALI_TEST_CHECK( event2.keyName == data.receivedKeyEvent.GetKeyName() );
882 DALI_TEST_CHECK( event2.keyString == data.receivedKeyEvent.GetKeyString() );
883 DALI_TEST_CHECK( event2.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.GetState() ) );
887 Integration::KeyEvent event3( "a", "", "a", 0, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
888 application.ProcessEvent( event3 );
890 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
891 DALI_TEST_CHECK( event3.keyModifier == data.receivedKeyEvent.GetKeyModifier() );
892 DALI_TEST_CHECK( event3.keyName == data.receivedKeyEvent.GetKeyName() );
893 DALI_TEST_CHECK( event3.keyString == data.receivedKeyEvent.GetKeyString() );
894 DALI_TEST_CHECK( event3.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.GetState() ) );
898 Integration::KeyEvent event4( "a", "", "a", 0, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
899 application.ProcessEvent( event4 );
901 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
902 DALI_TEST_CHECK( event4.keyModifier == data.receivedKeyEvent.GetKeyModifier() );
903 DALI_TEST_CHECK( event4.keyName == data.receivedKeyEvent.GetKeyName() );
904 DALI_TEST_CHECK( event4.keyString == data.receivedKeyEvent.GetKeyString() );
905 DALI_TEST_CHECK( event4.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.GetState() ) );
909 int UtcDaliStageSignalKeyEventP(void)
911 TestApplication application;
912 Stage stage = Stage::GetCurrent();
914 KeyEventSignalData data;
915 KeyEventReceivedFunctor functor( data );
916 stage.KeyEventSignal().Connect( &application, functor );
918 Integration::KeyEvent event( "i", "", "i", 0, 0, 0, Integration::KeyEvent::DOWN, "i", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
919 application.ProcessEvent( event );
921 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
922 DALI_TEST_CHECK( event.keyModifier == data.receivedKeyEvent.GetKeyModifier() );
923 DALI_TEST_CHECK( event.keyName == data.receivedKeyEvent.GetKeyName() );
924 DALI_TEST_CHECK( event.keyString == data.receivedKeyEvent.GetKeyString() );
925 DALI_TEST_CHECK( event.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.GetState() ) );
929 Integration::KeyEvent event2( "i", "", "i", 0, 0, 0, Integration::KeyEvent::UP, "i", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
930 application.ProcessEvent( event2 );
932 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
933 DALI_TEST_CHECK( event2.keyModifier == data.receivedKeyEvent.GetKeyModifier() );
934 DALI_TEST_CHECK( event2.keyName == data.receivedKeyEvent.GetKeyName() );
935 DALI_TEST_CHECK( event2.keyString == data.receivedKeyEvent.GetKeyString() );
936 DALI_TEST_CHECK( event2.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.GetState() ) );
940 Integration::KeyEvent event3( "a", "", "a", 0, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
941 application.ProcessEvent( event3 );
943 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
944 DALI_TEST_CHECK( event3.keyModifier == data.receivedKeyEvent.GetKeyModifier() );
945 DALI_TEST_CHECK( event3.keyName == data.receivedKeyEvent.GetKeyName() );
946 DALI_TEST_CHECK( event3.keyString == data.receivedKeyEvent.GetKeyString() );
947 DALI_TEST_CHECK( event3.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.GetState() ) );
951 Integration::KeyEvent event4( "a", "", "a", 0, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
952 application.ProcessEvent( event4 );
954 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
955 DALI_TEST_CHECK( event4.keyModifier == data.receivedKeyEvent.GetKeyModifier() );
956 DALI_TEST_CHECK( event4.keyName == data.receivedKeyEvent.GetKeyName() );
957 DALI_TEST_CHECK( event4.keyString == data.receivedKeyEvent.GetKeyString() );
958 DALI_TEST_CHECK( event4.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.GetState() ) );
962 int UtcDaliStageSignalKeyEventN(void)
964 TestApplication application;
965 Stage stage = Stage::GetCurrent();
967 KeyEventSignalData data;
968 KeyEventReceivedFunctor functor( data );
969 stage.KeyEventSignal().Connect( &application, functor );
971 // Check that a non-pressed key events data is not modified.
972 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
977 int UtcDaliStageTouchedSignalP(void)
979 TestApplication application;
980 Stage stage = Stage::GetCurrent();
982 TouchSignalData data;
983 TouchFunctor functor( data );
984 stage.TouchSignal().Connect( &application, functor );
986 // Render and notify.
987 application.SendNotification();
988 application.Render();
990 // Basic test: No actors, single touch (down then up).
992 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
994 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
995 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
996 DALI_TEST_CHECK( !data.receivedTouchEvent.GetHitActor(0) );
999 GenerateTouch( application, PointState::UP, Vector2( 10.0f, 10.0f ) );
1001 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1002 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1003 DALI_TEST_CHECK( !data.receivedTouchEvent.GetHitActor(0) );
1008 // Add an actor to the scene.
1009 Actor actor = Actor::New();
1010 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1011 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1012 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1013 actor.TouchSignal().Connect( &DummyTouchCallback );
1016 // Render and notify.
1017 application.SendNotification();
1018 application.Render();
1020 // Actor on scene, single touch, down in actor, motion, then up outside actor.
1022 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1024 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1025 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1026 DALI_TEST_CHECK( data.receivedTouchEvent.GetHitActor(0) );
1029 GenerateTouch( application, PointState::MOTION, Vector2( 150.0f, 10.0f ) ); // Some motion
1031 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1034 GenerateTouch( application, PointState::UP, Vector2( 150.0f, 10.0f ) ); // Some motion
1036 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1037 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1038 DALI_TEST_CHECK( !data.receivedTouchEvent.GetHitActor(0) );
1042 // Multiple touch. Should only receive a touch on first down and last up.
1044 Integration::TouchEvent touchEvent;
1045 Integration::Point point;
1048 point.SetState( PointState::DOWN );
1049 point.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
1050 touchEvent.points.push_back( point );
1051 application.ProcessEvent( touchEvent );
1052 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1053 DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 1u, TEST_LOCATION );
1057 touchEvent.points[0].SetState( PointState::STATIONARY );
1058 point.SetDeviceId( 1 );
1059 point.SetScreenPosition( Vector2( 50.0f, 50.0f ) );
1060 touchEvent.points.push_back( point );
1061 application.ProcessEvent( touchEvent );
1062 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1063 DALI_TEST_EQUALS( (bool)data.receivedTouchEvent, false, TEST_LOCATION );
1066 // Primary point is up
1067 touchEvent.points[0].SetState( PointState::UP );
1068 touchEvent.points[1].SetState( PointState::STATIONARY );
1069 application.ProcessEvent( touchEvent );
1070 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1071 DALI_TEST_EQUALS( (bool)data.receivedTouchEvent, false, TEST_LOCATION );
1074 // Remove 1st point now, 2nd point is now in motion
1075 touchEvent.points.erase( touchEvent.points.begin() );
1076 touchEvent.points[0].SetState( PointState::MOTION );
1077 touchEvent.points[0].SetScreenPosition( Vector2( 150.0f, 50.0f ) );
1078 application.ProcessEvent( touchEvent );
1079 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1080 DALI_TEST_EQUALS( (bool)data.receivedTouchEvent, false, TEST_LOCATION );
1084 touchEvent.points[0].SetState( PointState::UP );
1085 application.ProcessEvent( touchEvent );
1086 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1087 DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 1u, TEST_LOCATION );
1093 int UtcDaliStageTouchedSignalN(void)
1095 TestApplication application;
1096 Stage stage = Stage::GetCurrent();
1098 TouchSignalData data;
1099 TouchFunctor functor( data );
1100 stage.TouchSignal().Connect( &application, functor );
1102 // Render and notify.
1103 application.SendNotification();
1104 application.Render();
1106 // Confirm functor not called before there has been any touch event.
1107 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1109 // No actors, single touch, down, motion then up.
1111 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1113 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1114 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1115 DALI_TEST_CHECK( !data.receivedTouchEvent.GetHitActor(0) );
1118 // Confirm there is no signal when the touchpoint is only moved.
1119 GenerateTouch( application, PointState::MOTION, Vector2( 1200.0f, 10.0f ) ); // Some motion
1121 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1124 // Confirm a following up event generates a signal.
1125 GenerateTouch( application, PointState::UP, Vector2( 1200.0f, 10.0f ) );
1127 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1128 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1129 DALI_TEST_CHECK( !data.receivedTouchEvent.GetHitActor(0) );
1133 // Add an actor to the scene.
1134 Actor actor = Actor::New();
1135 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1136 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1137 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1138 actor.TouchSignal().Connect( &DummyTouchCallback );
1141 // Render and notify.
1142 application.SendNotification();
1143 application.Render();
1145 // Actor on scene. Interrupted before down and interrupted after down.
1147 GenerateTouch( application, PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) );
1149 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1150 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1151 DALI_TEST_CHECK( !data.receivedTouchEvent.GetHitActor(0) );
1152 DALI_TEST_CHECK( data.receivedTouchEvent.GetState(0) == PointState::INTERRUPTED );
1155 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1157 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1158 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1159 DALI_TEST_CHECK( data.receivedTouchEvent.GetHitActor(0) == actor );
1160 DALI_TEST_CHECK( data.receivedTouchEvent.GetState(0) == PointState::DOWN );
1163 GenerateTouch( application, PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) );
1165 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1166 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1167 DALI_TEST_CHECK( !data.receivedTouchEvent.GetHitActor(0) );
1168 DALI_TEST_CHECK( data.receivedTouchEvent.GetState(0) == PointState::INTERRUPTED );
1170 DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 1u, TEST_LOCATION );
1172 // Check that getting info about a non-existent point causes an assert.
1173 DALI_TEST_EQUALS( data.receivedTouchEvent.GetState( 1 ), PointState::FINISHED, TEST_LOCATION );
1182 int UtcDaliStageTouchSignalP(void)
1184 TestApplication application;
1185 Stage stage = Stage::GetCurrent();
1187 TouchSignalData data;
1188 TouchFunctor functor( data );
1189 stage.TouchSignal().Connect( &application, functor );
1191 // Render and notify.
1192 application.SendNotification();
1193 application.Render();
1195 // Basic test: No actors, single touch (down then up).
1197 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1199 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1200 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1201 DALI_TEST_CHECK( !data.receivedTouchEvent.GetHitActor(0) );
1204 GenerateTouch( application, PointState::UP, Vector2( 10.0f, 10.0f ) );
1206 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1207 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1208 DALI_TEST_CHECK( !data.receivedTouchEvent.GetHitActor(0) );
1212 // Add an actor to the scene.
1213 Actor actor = Actor::New();
1214 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1215 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1216 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1217 actor.TouchSignal().Connect( &DummyTouchCallback );
1220 // Render and notify.
1221 application.SendNotification();
1222 application.Render();
1224 // Actor on scene, single touch, down in actor, motion, then up outside actor.
1226 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1228 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1229 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1230 DALI_TEST_CHECK( data.receivedTouchEvent.GetHitActor(0) == actor );
1233 GenerateTouch( application, PointState::MOTION, Vector2( 150.0f, 10.0f ) ); // Some motion
1235 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1238 GenerateTouch( application, PointState::UP, Vector2( 150.0f, 10.0f ) ); // Some motion
1240 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1241 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1242 DALI_TEST_CHECK( !data.receivedTouchEvent.GetHitActor(0) );
1246 // Multiple touch. Should only receive a touch on first down and last up.
1248 Integration::TouchEvent touchEvent;
1249 Integration::Point point;
1252 point.SetState( PointState::DOWN );
1253 point.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
1254 touchEvent.points.push_back( point );
1255 application.ProcessEvent( touchEvent );
1256 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1257 DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 1u, TEST_LOCATION );
1261 touchEvent.points[0].SetState( PointState::STATIONARY );
1262 point.SetDeviceId( 1 );
1263 point.SetScreenPosition( Vector2( 50.0f, 50.0f ) );
1264 touchEvent.points.push_back( point );
1265 application.ProcessEvent( touchEvent );
1266 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1269 // Primary point is up
1270 touchEvent.points[0].SetState( PointState::UP );
1271 touchEvent.points[1].SetState( PointState::STATIONARY );
1272 application.ProcessEvent( touchEvent );
1273 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1276 // Remove 1st point now, 2nd point is now in motion
1277 touchEvent.points.erase( touchEvent.points.begin() );
1278 touchEvent.points[0].SetState( PointState::MOTION );
1279 touchEvent.points[0].SetScreenPosition( Vector2( 150.0f, 50.0f ) );
1280 application.ProcessEvent( touchEvent );
1281 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1285 touchEvent.points[0].SetState( PointState::UP );
1286 application.ProcessEvent( touchEvent );
1287 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1288 DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 1u, TEST_LOCATION );
1294 int UtcDaliStageTouchSignalN(void)
1296 TestApplication application;
1297 Stage stage = Stage::GetCurrent();
1299 TouchSignalData data;
1300 TouchFunctor functor( data );
1301 stage.TouchSignal().Connect( &application, functor );
1303 TouchSignalData data2;
1304 TouchFunctor functor2( data2 );
1305 GetImplementation( stage ).ConnectSignal( &application, "touch", functor2 );
1307 // Render and notify.
1308 application.SendNotification();
1309 application.Render();
1311 // Confirm functor not called before there has been any touch event.
1312 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1313 DALI_TEST_EQUALS( false, data2.functorCalled, TEST_LOCATION );
1315 // No actors, single touch, down, motion then up.
1317 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1319 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1320 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1321 DALI_TEST_CHECK( !data.receivedTouchEvent.GetHitActor(0));
1323 DALI_TEST_EQUALS( true, data2.functorCalled, TEST_LOCATION );
1328 // Confirm there is no signal when the touchpoint is only moved.
1329 GenerateTouch( application, PointState::MOTION, Vector2( 1200.0f, 10.0f ) ); // Some motion
1331 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1334 // Confirm a following up event generates a signal.
1335 GenerateTouch( application, PointState::UP, Vector2( 1200.0f, 10.0f ) );
1337 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1338 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1339 DALI_TEST_CHECK( !data.receivedTouchEvent.GetHitActor(0));
1343 // Add an actor to the scene.
1344 Actor actor = Actor::New();
1345 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1346 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1347 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1348 actor.TouchSignal().Connect( &DummyTouchCallback );
1351 // Render and notify.
1352 application.SendNotification();
1353 application.Render();
1355 // Actor on scene. Interrupted before down and interrupted after down.
1357 GenerateTouch( application, PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) );
1359 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1360 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1361 DALI_TEST_CHECK( !data.receivedTouchEvent.GetHitActor(0) );
1362 DALI_TEST_CHECK( data.receivedTouchEvent.GetState(0) == PointState::INTERRUPTED );
1365 GenerateTouch( application, PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1367 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1368 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1369 DALI_TEST_CHECK( data.receivedTouchEvent.GetHitActor(0) == actor );
1370 DALI_TEST_CHECK( data.receivedTouchEvent.GetState(0) == PointState::DOWN );
1373 GenerateTouch( application, PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) );
1375 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1376 DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0u );
1377 DALI_TEST_CHECK( !data.receivedTouchEvent.GetHitActor(0) );
1378 DALI_TEST_CHECK( data.receivedTouchEvent.GetState(0) == PointState::INTERRUPTED );
1380 DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 1u, TEST_LOCATION );
1382 // Check that getting info about a non-existent point returns an empty handle
1383 Actor actor = data.receivedTouchEvent.GetHitActor( 1 );
1384 DALI_TEST_CHECK( !actor );
1392 int UtcDaliStageSignalWheelEventP(void)
1394 TestApplication application;
1395 Stage stage = Stage::GetCurrent();
1397 WheelEventSignalData data;
1398 WheelEventReceivedFunctor functor( data );
1399 stage.WheelEventSignal().Connect( &application, functor );
1401 Integration::WheelEvent event( Integration::WheelEvent::CUSTOM_WHEEL, 0, 0u, Vector2( 0.0f, 0.0f ), 1, 1000u );
1402 application.ProcessEvent( event );
1404 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1405 DALI_TEST_CHECK( static_cast< WheelEvent::Type >(event.type) == data.receivedWheelEvent.GetType() );
1406 DALI_TEST_CHECK( event.direction == data.receivedWheelEvent.GetDirection() );
1407 DALI_TEST_CHECK( event.modifiers == data.receivedWheelEvent.GetModifiers() );
1408 DALI_TEST_CHECK( event.point == data.receivedWheelEvent.GetPoint() );
1409 DALI_TEST_CHECK( event.delta == data.receivedWheelEvent.GetDelta() );
1410 DALI_TEST_CHECK( event.timeStamp == data.receivedWheelEvent.GetTime() );
1414 Integration::WheelEvent event2( Integration::WheelEvent::CUSTOM_WHEEL, 0, 0u, Vector2( 0.0f, 0.0f ), -1, 1000u );
1415 application.ProcessEvent( event2 );
1417 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1418 DALI_TEST_CHECK( static_cast< WheelEvent::Type >(event2.type) == data.receivedWheelEvent.GetType() );
1419 DALI_TEST_CHECK( event2.direction == data.receivedWheelEvent.GetDirection() );
1420 DALI_TEST_CHECK( event2.modifiers == data.receivedWheelEvent.GetModifiers() );
1421 DALI_TEST_CHECK( event2.point == data.receivedWheelEvent.GetPoint() );
1422 DALI_TEST_CHECK( event2.delta == data.receivedWheelEvent.GetDelta() );
1423 DALI_TEST_CHECK( event2.timeStamp == data.receivedWheelEvent.GetTime() );
1427 int UtcDaliStageContextLostSignalP(void)
1429 TestApplication application;
1430 Stage stage = Stage::GetCurrent();
1432 bool contextLost = false;
1433 ContextStatusFunctor contextLostFunctor( contextLost );
1434 stage.ContextLostSignal().Connect( &application, contextLostFunctor );
1436 Integration::ContextNotifierInterface* notifier = application.GetCore().GetContextNotifier();
1437 notifier->NotifyContextLost();
1438 DALI_TEST_EQUALS( contextLost, true, TEST_LOCATION );
1443 int UtcDaliStageContextLostSignalN(void)
1445 TestApplication application;
1448 // Check that connecting to the signal with a bad stage instance causes an assert.
1449 bool asserted = false;
1450 bool contextLost = false;
1451 ContextStatusFunctor contextLostFunctor( contextLost );
1454 stage.ContextLostSignal().Connect( &application, contextLostFunctor );
1456 catch( Dali::DaliException& e )
1458 DALI_TEST_PRINT_ASSERT( e );
1459 DALI_TEST_ASSERT( e, "stage && \"Stage handle is empty\"", TEST_LOCATION );
1462 DALI_TEST_CHECK( asserted );
1467 int UtcDaliStageContextRegainedSignalP(void)
1469 TestApplication application;
1470 Stage stage = Stage::GetCurrent();
1472 bool contextRegained = false;
1473 ContextStatusFunctor contextRegainedFunctor( contextRegained );
1474 stage.ContextRegainedSignal().Connect( &application, contextRegainedFunctor );
1476 Integration::ContextNotifierInterface* notifier = application.GetCore().GetContextNotifier();
1477 notifier->NotifyContextLost();
1478 notifier->NotifyContextRegained();
1479 DALI_TEST_EQUALS( contextRegained, true, TEST_LOCATION );
1484 int UtcDaliStageContextRegainedSignalN(void)
1486 TestApplication application;
1489 // Check that connecting to the signal with a bad stage instance causes an assert.
1490 bool asserted = false;
1491 bool contextRegained = false;
1492 ContextStatusFunctor contextRegainedFunctor( contextRegained );
1495 stage.ContextRegainedSignal().Connect( &application, contextRegainedFunctor );
1497 catch( Dali::DaliException& e )
1499 DALI_TEST_PRINT_ASSERT( e );
1500 DALI_TEST_ASSERT( e, "stage && \"Stage handle is empty\"", TEST_LOCATION );
1503 DALI_TEST_CHECK( asserted );
1508 int UtcDaliStageSceneCreatedSignalP(void)
1510 TestApplication application;
1511 Stage stage = Stage::GetCurrent();
1513 bool signalCalled = false;
1514 SceneCreatedStatusFunctor sceneCreatedFunctor( signalCalled );
1515 stage.SceneCreatedSignal().Connect( &application, sceneCreatedFunctor );
1517 Integration::Core& core = application.GetCore();
1518 core.SceneCreated();
1519 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
1524 int UtcDaliStageSceneCreatedSignalN(void)
1526 TestApplication application;
1529 // Check that connecting to the signal with a bad stage instance causes an assert.
1530 bool asserted = false;
1531 bool signalCalled = false;
1532 SceneCreatedStatusFunctor sceneCreatedFunctor( signalCalled );
1535 stage.SceneCreatedSignal().Connect( &application, sceneCreatedFunctor );
1537 catch( Dali::DaliException& e )
1539 DALI_TEST_PRINT_ASSERT( e );
1540 DALI_TEST_ASSERT( e, "stage && \"Stage handle is empty\"", TEST_LOCATION );
1543 DALI_TEST_CHECK( asserted );
1548 int UtcDaliStageGetRenderTaskListP(void)
1550 TestApplication application;
1551 Stage stage = Stage::GetCurrent();
1553 // Check we get a valid instance.
1554 const RenderTaskList& tasks = stage.GetRenderTaskList();
1556 // There should be 1 task by default.
1557 DALI_TEST_EQUALS( tasks.GetTaskCount(), 1u, TEST_LOCATION );
1559 // RenderTaskList has it's own UTC tests.
1560 // But we can confirm that GetRenderTaskList in Stage retrieves the same RenderTaskList each time.
1561 RenderTask newTask = stage.GetRenderTaskList().CreateTask();
1563 DALI_TEST_EQUALS( stage.GetRenderTaskList().GetTask( 1 ), newTask, TEST_LOCATION );
1568 int UtcDaliStageGetRenderTaskListN(void)
1570 TestApplication application;
1573 // Check that getting the render task list with a bad stage instance causes an assert.
1574 bool asserted = false;
1577 stage.GetRenderTaskList();
1579 catch( Dali::DaliException& e )
1581 DALI_TEST_PRINT_ASSERT( e );
1582 DALI_TEST_ASSERT( e, "stage && \"Stage handle is empty\"", TEST_LOCATION );
1585 DALI_TEST_CHECK( asserted );
1590 int UtcDaliStageGetObjectRegistryP(void)
1592 TestApplication application;
1593 Stage stage = Stage::GetCurrent();
1595 ObjectRegistry objectRegistry = stage.GetObjectRegistry();
1597 // Object registry tests are covered in their own module.
1598 // However we want a basic test to confirm the returned registry is valid and works.
1599 bool verified = false;
1600 ActorCreatedFunctor test( verified );
1601 objectRegistry.ObjectCreatedSignal().Connect( &application, test );
1603 Actor actor = Actor::New();
1604 DALI_TEST_CHECK( test.mSignalVerified );
1609 int UtcDaliStageGetObjectRegistryN(void)
1611 TestApplication application;
1614 // Check that getting the object registry with a bad stage instance DOES NOT cause an assert.
1615 // This is because GetCurrent() is used, always creating a stage if one does not exist.
1616 bool asserted = false;
1619 stage.GetObjectRegistry();
1621 catch( Dali::DaliException& e )
1623 DALI_TEST_PRINT_ASSERT( e );
1626 DALI_TEST_CHECK( !asserted );
1631 int UtcDaliStageOperatorAssign(void)
1633 TestApplication application;
1635 DALI_TEST_CHECK( !stage );
1637 stage = Stage::GetCurrent();
1638 DALI_TEST_CHECK( stage );
1643 int UtcDaliStageRenderingBehavior(void)
1645 TestApplication application;
1646 Stage stage = Stage::GetCurrent();
1648 tet_infoline( "Check default rendering behavior is only if required" );
1649 DALI_TEST_CHECK( DevelStage::GetRenderingBehavior( stage ) == DevelStage::Rendering::IF_REQUIRED );
1651 tet_infoline( "No update required with an empty application" );
1652 application.SendNotification();
1653 DALI_TEST_CHECK( application.UpdateOnly() == false );
1654 application.RenderOnly();
1656 tet_infoline( "Change to continuous rendering, further updates should be required" );
1657 DevelStage::SetRenderingBehavior( stage, DevelStage::Rendering::CONTINUOUSLY );
1659 DALI_TEST_CHECK( DevelStage::GetRenderingBehavior( stage ) == DevelStage::Rendering::CONTINUOUSLY );
1661 application.SendNotification();
1662 DALI_TEST_CHECK( application.UpdateOnly() == true );
1663 application.RenderOnly();
1665 application.SendNotification();
1666 DALI_TEST_CHECK( application.UpdateOnly() == true );
1667 application.RenderOnly();
1669 tet_infoline( "Change to rendering only if required, further updates should NOT be required" );
1670 DevelStage::SetRenderingBehavior( stage, DevelStage::Rendering::IF_REQUIRED );
1672 DALI_TEST_CHECK( DevelStage::GetRenderingBehavior( stage ) == DevelStage::Rendering::IF_REQUIRED );
1674 application.SendNotification();
1675 DALI_TEST_CHECK( application.UpdateOnly() == false );
1676 application.RenderOnly();
1678 tet_infoline( "The next update is not required so TestApplication should print a warning" );
1679 application.SendNotification();
1680 DALI_TEST_CHECK( application.UpdateOnly() == false );
1681 application.RenderOnly();