2 * Copyright (c) 2023 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.
18 #include <dali-test-suite-utils.h>
19 #include <dali/devel-api/common/stage-devel.h>
20 #include <dali/devel-api/threading/thread.h>
21 #include <dali/integration-api/context-notifier.h>
22 #include <dali/integration-api/events/key-event-integ.h>
23 #include <dali/integration-api/events/touch-event-integ.h>
24 #include <dali/integration-api/events/wheel-event-integ.h>
25 #include <dali/public-api/dali-core.h>
26 #include <dali/public-api/events/key-event.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;
46 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
48 // Functor for EventProcessingFinished signal
49 struct EventProcessingFinishedFunctor
52 * @param[in] eventProcessingFinished reference to a boolean variable used to check if signal has been called.
54 EventProcessingFinishedFunctor(bool& eventProcessingFinished)
55 : 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)
77 functorCalled = false;
79 receivedKeyEvent.Reset();
83 KeyEvent receivedKeyEvent;
86 // Functor that sets the data when called
87 struct KeyEventGeneratedReceivedFunctor
89 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)
121 functorCalled = false;
123 receivedKeyEvent.Reset();
127 KeyEvent receivedKeyEvent;
130 // Functor that sets the data when called
131 struct KeyEventReceivedFunctor
133 KeyEventReceivedFunctor(KeyEventSignalData& data)
138 bool operator()(const KeyEvent& keyEvent)
140 signalData.functorCalled = true;
141 signalData.receivedKeyEvent = keyEvent;
146 KeyEventSignalData& signalData;
149 // Stores data that is populated in the touched signal callback and will be read by the TET cases
150 struct TouchedSignalData
153 : functorCalled(false)
159 functorCalled = false;
161 receivedTouchEvent.Reset();
165 TouchEvent receivedTouchEvent;
168 // Functor that sets the data when touched signal is received
171 TouchFunctor(TouchedSignalData& data)
176 void operator()(const TouchEvent& touch)
178 signalData.functorCalled = true;
179 TouchEvent handle(touch);
180 signalData.receivedTouchEvent = handle;
183 // Allows functor to be used for signal connection by string.
184 // No data stored, though, so quite useless.
187 signalData.functorCalled = true;
190 TouchedSignalData& signalData;
193 // Stores data that is populated in the wheel-event callback and will be read by the TET cases
194 struct WheelEventSignalData
196 WheelEventSignalData()
197 : functorCalled(false)
203 functorCalled = false;
207 WheelEvent receivedWheelEvent;
210 // Functor that sets the data when wheel-event signal is received
211 struct WheelEventReceivedFunctor
213 WheelEventReceivedFunctor(WheelEventSignalData& data)
218 bool operator()(const WheelEvent& wheelEvent)
220 signalData.functorCalled = true;
221 signalData.receivedWheelEvent = wheelEvent;
226 WheelEventSignalData& signalData;
229 // Functor that sets the data when wheel-event signal is received
230 struct WheelEventReceivedVoidFunctor
232 WheelEventReceivedVoidFunctor(WheelEventSignalData& data)
237 // Signals connected through BaseObject::DoConnectSignal can only take void() methods
238 bool operator()(void)
240 signalData.functorCalled = true;
244 WheelEventSignalData& signalData;
247 bool DummyTouchCallback(Actor actor, const TouchEvent& touch)
252 struct ContextStatusFunctor
254 ContextStatusFunctor(bool& calledFlag)
255 : mCalledFlag(calledFlag)
272 struct SceneCreatedStatusFunctor
274 SceneCreatedStatusFunctor(bool& calledFlag)
275 : mCalledFlag(calledFlag)
292 struct ActorCreatedFunctor
294 ActorCreatedFunctor(bool& signalReceived)
295 : mSignalVerified(signalReceived)
299 void operator()(BaseHandle object)
301 tet_infoline("Verifying TestActorCallback()");
302 Actor actor = Actor::DownCast(object);
305 mSignalVerified = true;
309 bool& mSignalVerified;
312 void GenerateTouch(TestApplication& application, PointState::Type state, const Vector2& screenPosition)
314 Integration::TouchEvent touchEvent;
315 Integration::Point point;
316 point.SetState(state);
317 point.SetScreenPosition(screenPosition);
318 touchEvent.points.push_back(point);
319 application.ProcessEvent(touchEvent);
322 volatile bool gRunThreadEntryFunc = false;
324 class TestThread : public Dali::Thread
331 TestThread(Dali::CallbackBase* callback)
332 : mCallback(callback)
345 Dali::CallbackBase::Execute(*mCallback);
348 gRunThreadEntryFunc = true;
352 Dali::CallbackBase* mCallback{nullptr};
355 void CoreThreadCheck()
357 DALI_TEST_CHECK(!Stage::IsCoreThread());
360 } // unnamed namespace
362 int UtcDaliStageDefaultConstructorP(void)
364 TestApplication application;
367 DALI_TEST_CHECK(!stage);
371 // Note: No negative test for default constructor.
373 int UtcDaliStageDestructorP(void)
375 TestApplication application;
376 Stage* stage = new Stage();
380 DALI_TEST_CHECK(true);
384 // Note: No negative test for default destructor.
386 int UtcDaliStageGetCurrentP(void)
388 TestApplication application;
389 Stage stage = Stage::GetCurrent();
391 DALI_TEST_CHECK(stage);
395 int UtcDaliStageGetCurrentN(void)
397 bool asserted = false;
400 Stage stage = Stage::GetCurrent();
402 catch(Dali::DaliException& e)
404 DALI_TEST_PRINT_ASSERT(e);
405 DALI_TEST_ASSERT(e, "stage && \"Stage doesn't exist\"", TEST_LOCATION);
409 DALI_TEST_CHECK(asserted);
413 int UtcDaliStageIsInstalledP(void)
415 TestApplication application;
419 DALI_TEST_CHECK(Stage::IsInstalled());
423 int UtcDaliStageIsInstalledN(void)
425 DALI_TEST_CHECK(!Stage::IsInstalled());
430 int UtcDaliStageIsShuttingDown(void)
432 DALI_TEST_CHECK(!Stage::IsShuttingDown());
435 TestApplication application;
437 DALI_TEST_CHECK(!Stage::IsShuttingDown());
441 DALI_TEST_CHECK(!Stage::IsShuttingDown());
445 DALI_TEST_CHECK(Stage::IsShuttingDown());
449 int UtcDaliStageIsCoreThread(void)
451 DALI_TEST_CHECK(!Stage::IsCoreThread());
454 TestApplication application;
456 DALI_TEST_CHECK(Stage::IsCoreThread());
460 DALI_TEST_CHECK(Stage::IsCoreThread());
462 TestThread thread(Dali::MakeCallback(&CoreThreadCheck));
464 gRunThreadEntryFunc = false;
467 // wait till the thread is terminated
468 while(!gRunThreadEntryFunc)
470 usleep(1); // 1 microsecond
472 DALI_TEST_EQUALS(true, gRunThreadEntryFunc, TEST_LOCATION);
478 DALI_TEST_CHECK(Stage::IsCoreThread());
483 int UtcDaliStageCopyConstructorP(void)
485 TestApplication application;
486 Stage stage = Stage::GetCurrent();
488 Stage copyStage(stage);
490 DALI_TEST_CHECK(copyStage);
491 DALI_TEST_CHECK(copyStage.GetRootLayer() == stage.GetRootLayer());
496 // Note: no negative test for UtcDaliStageCopyConstructor.
498 int UtcDaliStageAssignmentOperatorP(void)
500 TestApplication application;
501 const Stage stage = Stage::GetCurrent();
503 Stage copyStage = stage;
505 DALI_TEST_CHECK(copyStage);
506 DALI_TEST_CHECK(copyStage.GetRootLayer() == stage.GetRootLayer());
511 // Note: No negative test for UtcDaliStageAssignmentOperator.
513 int UtcDaliStageAddP(void)
515 TestApplication application;
517 Stage stage = Stage::GetCurrent();
519 Actor actor = Actor::New();
520 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
523 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
527 int UtcDaliStageAddN(void)
529 TestApplication application;
531 Stage stage = Stage::GetCurrent();
534 bool asserted = false;
539 catch(Dali::DaliException& e)
541 DALI_TEST_PRINT_ASSERT(e);
542 DALI_TEST_ASSERT(e, "actor && \"Actor handle is empty\"", TEST_LOCATION);
546 DALI_TEST_CHECK(asserted);
551 int UtcDaliStageRemoveP(void)
553 TestApplication application;
555 Stage stage = Stage::GetCurrent();
557 Actor actor = Actor::New();
558 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
561 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
564 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
568 int UtcDaliStageRemoveN1(void)
570 TestApplication application;
572 Stage stage = Stage::GetCurrent();
575 bool asserted = false;
578 // Actor is not valid, confirm a removal attempt does assert.
581 catch(Dali::DaliException& e)
583 DALI_TEST_PRINT_ASSERT(e);
584 DALI_TEST_ASSERT(e, "actor && \"Actor handle is empty\"", TEST_LOCATION);
588 DALI_TEST_CHECK(asserted);
592 int UtcDaliStageRemoveN2(void)
594 TestApplication application;
596 Stage stage = Stage::GetCurrent();
597 Actor actor = Actor::New();
598 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
600 bool asserted = false;
603 // Actor is not on stage, confirm a removal attempt does not assert / segfault.
606 catch(Dali::DaliException& e)
608 DALI_TEST_PRINT_ASSERT(e);
612 DALI_TEST_CHECK(!asserted);
616 int UtcDaliStageRemoveN3(void)
618 TestApplication application;
620 Stage stage = Stage::GetCurrent();
622 // Initially we have a default layer
623 DALI_TEST_EQUALS(stage.GetLayerCount(), 1u, TEST_LOCATION);
625 // Check we cannot remove the root layer from the stage.
626 Layer layer = stage.GetRootLayer();
627 bool asserted = true;
632 catch(Dali::DaliException& e)
634 DALI_TEST_PRINT_ASSERT(e);
635 DALI_TEST_ASSERT(e, "this != &child && \"Cannot remove actor from itself\"", TEST_LOCATION);
639 DALI_TEST_CHECK(asserted);
640 DALI_TEST_EQUALS(stage.GetLayerCount(), 1u, TEST_LOCATION);
644 int UtcDaliStageGetSizeP(void)
646 TestApplication application;
648 Stage stage = Stage::GetCurrent();
650 Vector2 size = stage.GetSize();
652 DALI_TEST_EQUALS(size.width, static_cast<float>(TestApplication::DEFAULT_SURFACE_WIDTH), TEST_LOCATION);
653 DALI_TEST_EQUALS(size.height, static_cast<float>(TestApplication::DEFAULT_SURFACE_HEIGHT), TEST_LOCATION);
657 int UtcDaliStageGetSizeN(void)
659 TestApplication application;
663 bool asserted = false;
667 size = stage.GetSize();
669 catch(Dali::DaliException& e)
671 DALI_TEST_PRINT_ASSERT(e);
672 DALI_TEST_ASSERT(e, "stage && \"Stage handle is empty\"", TEST_LOCATION);
676 DALI_TEST_CHECK(asserted);
680 int UtcDaliStageGetDpiP1(void)
682 TestApplication application; // Initializes core DPI to default values
684 Stage stage = Stage::GetCurrent();
686 // Test the default DPI.
687 Vector2 dpi = stage.GetDpi();
688 DALI_TEST_EQUALS(dpi.x, static_cast<float>(TestApplication::DEFAULT_HORIZONTAL_DPI), TEST_LOCATION);
689 DALI_TEST_EQUALS(dpi.y, static_cast<float>(TestApplication::DEFAULT_VERTICAL_DPI), TEST_LOCATION);
693 int UtcDaliStageGetDpiP2(void)
695 TestApplication application; // Initializes core DPI to default values
697 // Test that setting core DPI explicitly also sets up the Stage's DPI.
698 Dali::Integration::Scene scene = application.GetScene();
699 scene.SetDpi(Vector2(200.0f, 180.0f));
701 Stage stage = Stage::GetCurrent();
702 Vector2 dpi = stage.GetDpi();
703 DALI_TEST_EQUALS(dpi.x, 200.0f, TEST_LOCATION);
704 DALI_TEST_EQUALS(dpi.y, 180.0f, TEST_LOCATION);
708 int UtcDaliStageGetDpiP3(void)
710 TestApplication application(480, 800, 72, 120); // Initializes core DPI with specific values
712 Stage stage = Stage::GetCurrent();
714 // Test that setting core DPI explicitly also sets up the Stage's DPI.
715 Vector2 dpi = stage.GetDpi();
716 DALI_TEST_EQUALS(dpi.x, 72.0f, TEST_LOCATION);
717 DALI_TEST_EQUALS(dpi.y, 120.0f, TEST_LOCATION);
722 * This is not a true negative test, we are checking the DPI if it has not been set.
723 * A test for setting negative DPI values would be part of the application core utc tests.
725 int UtcDaliStageGetDpiN(void)
727 TestApplication application; // Initializes core DPI to default values
729 Stage stage = Stage::GetCurrent();
730 Vector2 dpi = stage.GetDpi();
732 DALI_TEST_EQUALS(dpi.x, 220.0f, TEST_LOCATION);
733 DALI_TEST_EQUALS(dpi.y, 217.0f, TEST_LOCATION);
737 int UtcDaliStageGetLayerCountP(void)
739 TestApplication application;
741 Stage stage = Stage::GetCurrent();
743 // Initially we have a default layer
744 DALI_TEST_EQUALS(stage.GetLayerCount(), 1u, TEST_LOCATION);
746 Layer layer = Layer::New();
749 DALI_TEST_EQUALS(stage.GetLayerCount(), 2u, TEST_LOCATION);
754 * Not a true negative test, but confirms layer count is not affected by an invalid removal.
756 int UtcDaliStageGetLayerCountN(void)
758 TestApplication application;
760 Stage stage = Stage::GetCurrent();
762 // Initially we have a default layer
763 DALI_TEST_EQUALS(stage.GetLayerCount(), 1u, TEST_LOCATION);
765 Layer layer = Layer::New();
768 // Still have 1 layer.
769 DALI_TEST_EQUALS(stage.GetLayerCount(), 1u, TEST_LOCATION);
773 int UtcDaliStageGetLayerP(void)
775 TestApplication application;
777 Stage stage = Stage::GetCurrent();
779 Layer rootLayer = stage.GetLayer(0);
780 DALI_TEST_CHECK(rootLayer);
782 Layer layer = Layer::New();
785 Layer sameLayer = stage.GetLayer(1);
786 DALI_TEST_CHECK(layer == sameLayer);
790 int UtcDaliStageGetLayerN(void)
792 TestApplication application;
794 Stage stage = Stage::GetCurrent();
796 bool asserted = false;
799 // Try to get a layer that doesn't exist (note: 0 is the root layer).
800 Layer layer = stage.GetLayer(1);
802 catch(Dali::DaliException& e)
804 DALI_TEST_PRINT_ASSERT(e);
805 DALI_TEST_ASSERT(e, "depth < mLayers.size()", TEST_LOCATION);
809 DALI_TEST_CHECK(asserted);
813 int UtcDaliStageGetRootLayerP(void)
815 TestApplication application;
817 Stage stage = Stage::GetCurrent();
819 Layer layer = stage.GetLayer(0);
820 DALI_TEST_CHECK(layer);
822 // Check that GetRootLayer() correctly retreived layer 0.
823 DALI_TEST_CHECK(stage.GetRootLayer() == layer);
828 int UtcDaliStageGetRootLayerN(void)
830 TestApplication application;
832 Stage stage = Stage::GetCurrent();
834 Layer rootLayer = stage.GetLayer(0);
835 DALI_TEST_CHECK(rootLayer);
836 DALI_TEST_CHECK(stage.GetRootLayer() == rootLayer);
838 // Create a new layer and attempt to lower it below the root layer.
839 Layer layer = Layer::New();
841 layer.LowerToBottom();
843 // Check that GetRootLayer still retrieves the same original layer.
844 DALI_TEST_CHECK(stage.GetRootLayer() == rootLayer);
846 // Check modifying the root layer is also blocked.
847 rootLayer.RaiseToTop();
848 DALI_TEST_CHECK(stage.GetRootLayer() == rootLayer);
853 int UtcDaliStageSetBackgroundColorP(void)
855 TestApplication application;
857 Stage stage = Stage::GetCurrent();
859 Vector4 testColor(0.1f, 0.2f, 0.3f, 1.0f);
860 stage.SetBackgroundColor(testColor);
862 DALI_TEST_EQUALS(testColor, stage.GetBackgroundColor(), TEST_LOCATION);
866 // Note: No negative test for UtcDaliStageSetBackgroundColor as we do not wish to implement
867 // range checking for colors due to speed. Colors are clamped with glclampf within GL anyway.
869 int UtcDaliStageGetBackgroundColorP(void)
871 TestApplication application;
873 Stage stage = Stage::GetCurrent();
875 DALI_TEST_EQUALS(DEFAULT_BACKGROUND_COLOR, stage.GetBackgroundColor(), TEST_LOCATION);
879 // Note: No negative test for UtcDaliStageGetBackgroundColor as this is covered by UtcDaliStageSetBackgroundColorN.
881 int UtcDaliStageKeepRenderingP(void)
883 TestApplication application;
885 Stage stage = Stage::GetCurrent();
887 Actor actor = CreateRenderableActor();
890 // Run core until it wants to sleep
891 bool keepUpdating(true);
894 application.SendNotification();
895 keepUpdating = application.Render(1000.0f /*1 second*/);
898 // Force rendering for the next 5 seconds
899 stage.KeepRendering(5.0f);
901 application.SendNotification();
903 // Test that core wants to sleep after 5 seconds
904 keepUpdating = application.Render(1000.0f /*1 second*/);
905 DALI_TEST_CHECK(keepUpdating);
906 keepUpdating = application.Render(1000.0f /*2 seconds*/);
907 DALI_TEST_CHECK(keepUpdating);
908 keepUpdating = application.Render(1000.0f /*3 seconds*/);
909 DALI_TEST_CHECK(keepUpdating);
910 keepUpdating = application.Render(1000.0f /*4 seconds*/);
911 DALI_TEST_CHECK(keepUpdating);
912 keepUpdating = application.Render(1000.0f /*5 seconds*/);
913 DALI_TEST_CHECK(keepUpdating);
914 keepUpdating = application.Render(1000.0f /*6 seconds*/); // After 5 sec
915 DALI_TEST_CHECK(!keepUpdating);
919 int UtcDaliStageKeepRenderingN(void)
921 TestApplication application;
923 Stage stage = Stage::GetCurrent();
925 // Run core until it wants to sleep
926 bool keepUpdating(true);
929 application.SendNotification();
930 keepUpdating = application.Render(1000.0f /*1 second*/);
933 // Force rendering for the next 5 seconds
934 stage.KeepRendering(-1.0f);
936 application.SendNotification();
938 // Test that core wants to sleep after 10 seconds
939 keepUpdating = application.Render(1000.0f /*1 second*/);
940 DALI_TEST_CHECK(!keepUpdating);
945 int UtcDaliStageEventProcessingFinishedP(void)
947 TestApplication application;
948 Stage stage = Stage::GetCurrent();
950 bool eventProcessingFinished = false;
951 EventProcessingFinishedFunctor functor(eventProcessingFinished);
952 stage.EventProcessingFinishedSignal().Connect(&application, functor);
954 Actor actor(Actor::New());
957 application.SendNotification();
958 application.Render();
960 DALI_TEST_CHECK(eventProcessingFinished);
965 int UtcDaliStageEventProcessingFinishedP2(void)
967 TestApplication application;
968 Stage stage = Stage::GetCurrent();
969 tet_printf("UtcDaliStageEventProcessingFinishedSignalP2 - check event processing finished signal connection by name\n");
971 bool eventProcessingFinished = false;
972 EventProcessingFinishedFunctor functor(eventProcessingFinished);
973 GetImplementation(stage).ConnectSignal(&application, "eventProcessingFinished", functor);
975 Actor actor(Actor::New());
978 application.SendNotification();
979 application.Render();
981 DALI_TEST_CHECK(eventProcessingFinished);
986 int UtcDaliStageEventProcessingFinishedN(void)
988 TestApplication application;
989 Stage stage = Stage::GetCurrent();
991 bool eventProcessingFinished = false;
992 EventProcessingFinishedFunctor functor(eventProcessingFinished);
993 stage.EventProcessingFinishedSignal().Connect(&application, functor);
995 Actor actor(Actor::New());
998 // Do not complete event processing and confirm the signal has not been emitted.
999 DALI_TEST_CHECK(!eventProcessingFinished);
1004 int UtcDaliStageKeyEventGeneratedSignalP(void)
1006 TestApplication application;
1007 Stage stage = Stage::GetCurrent();
1009 KeyEventGeneratedSignalData data;
1010 KeyEventGeneratedReceivedFunctor functor(data);
1011 DevelStage::KeyEventGeneratedSignal(stage).Connect(&application, functor);
1013 KeyEventGeneratedSignalData data2;
1014 KeyEventGeneratedReceivedFunctor functor2(data2);
1015 GetImplementation(stage).ConnectSignal(&application, "keyEventGenerated", functor2);
1017 Integration::KeyEvent event("a", "", "a", 0, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE);
1018 application.ProcessEvent(event);
1020 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1021 DALI_TEST_CHECK(event.keyModifier == data.receivedKeyEvent.GetKeyModifier());
1022 DALI_TEST_CHECK(event.keyName == data.receivedKeyEvent.GetKeyName());
1023 DALI_TEST_CHECK(event.keyString == data.receivedKeyEvent.GetKeyString());
1024 DALI_TEST_CHECK(event.state == static_cast<Integration::KeyEvent::State>(data.receivedKeyEvent.GetState()));
1028 Integration::KeyEvent event2("i", "", "i", 0, 0, 0, Integration::KeyEvent::UP, "i", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE);
1029 application.ProcessEvent(event2);
1031 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1032 DALI_TEST_CHECK(event2.keyModifier == data.receivedKeyEvent.GetKeyModifier());
1033 DALI_TEST_CHECK(event2.keyName == data.receivedKeyEvent.GetKeyName());
1034 DALI_TEST_CHECK(event2.keyString == data.receivedKeyEvent.GetKeyString());
1035 DALI_TEST_CHECK(event2.state == static_cast<Integration::KeyEvent::State>(data.receivedKeyEvent.GetState()));
1039 Integration::KeyEvent event3("a", "", "a", 0, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE);
1040 application.ProcessEvent(event3);
1042 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1043 DALI_TEST_CHECK(event3.keyModifier == data.receivedKeyEvent.GetKeyModifier());
1044 DALI_TEST_CHECK(event3.keyName == data.receivedKeyEvent.GetKeyName());
1045 DALI_TEST_CHECK(event3.keyString == data.receivedKeyEvent.GetKeyString());
1046 DALI_TEST_CHECK(event3.state == static_cast<Integration::KeyEvent::State>(data.receivedKeyEvent.GetState()));
1050 Integration::KeyEvent event4("a", "", "a", 0, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE);
1051 application.ProcessEvent(event4);
1053 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1054 DALI_TEST_CHECK(event4.keyModifier == data.receivedKeyEvent.GetKeyModifier());
1055 DALI_TEST_CHECK(event4.keyName == data.receivedKeyEvent.GetKeyName());
1056 DALI_TEST_CHECK(event4.keyString == data.receivedKeyEvent.GetKeyString());
1057 DALI_TEST_CHECK(event4.state == static_cast<Integration::KeyEvent::State>(data.receivedKeyEvent.GetState()));
1061 int UtcDaliStageSignalKeyEventP(void)
1063 TestApplication application;
1064 Stage stage = Stage::GetCurrent();
1066 KeyEventSignalData data;
1067 KeyEventReceivedFunctor functor(data);
1068 stage.KeyEventSignal().Connect(&application, functor);
1070 Integration::KeyEvent event("i", "", "i", 0, 0, 0, Integration::KeyEvent::DOWN, "i", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE);
1071 application.ProcessEvent(event);
1073 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1074 DALI_TEST_CHECK(event.keyModifier == data.receivedKeyEvent.GetKeyModifier());
1075 DALI_TEST_CHECK(event.keyName == data.receivedKeyEvent.GetKeyName());
1076 DALI_TEST_CHECK(event.keyString == data.receivedKeyEvent.GetKeyString());
1077 DALI_TEST_CHECK(event.state == static_cast<Integration::KeyEvent::State>(data.receivedKeyEvent.GetState()));
1081 Integration::KeyEvent event2("i", "", "i", 0, 0, 0, Integration::KeyEvent::UP, "i", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE);
1082 application.ProcessEvent(event2);
1084 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1085 DALI_TEST_CHECK(event2.keyModifier == data.receivedKeyEvent.GetKeyModifier());
1086 DALI_TEST_CHECK(event2.keyName == data.receivedKeyEvent.GetKeyName());
1087 DALI_TEST_CHECK(event2.keyString == data.receivedKeyEvent.GetKeyString());
1088 DALI_TEST_CHECK(event2.state == static_cast<Integration::KeyEvent::State>(data.receivedKeyEvent.GetState()));
1092 Integration::KeyEvent event3("a", "", "a", 0, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE);
1093 application.ProcessEvent(event3);
1095 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1096 DALI_TEST_CHECK(event3.keyModifier == data.receivedKeyEvent.GetKeyModifier());
1097 DALI_TEST_CHECK(event3.keyName == data.receivedKeyEvent.GetKeyName());
1098 DALI_TEST_CHECK(event3.keyString == data.receivedKeyEvent.GetKeyString());
1099 DALI_TEST_CHECK(event3.state == static_cast<Integration::KeyEvent::State>(data.receivedKeyEvent.GetState()));
1103 Integration::KeyEvent event4("a", "", "a", 0, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE);
1104 application.ProcessEvent(event4);
1106 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1107 DALI_TEST_CHECK(event4.keyModifier == data.receivedKeyEvent.GetKeyModifier());
1108 DALI_TEST_CHECK(event4.keyName == data.receivedKeyEvent.GetKeyName());
1109 DALI_TEST_CHECK(event4.keyString == data.receivedKeyEvent.GetKeyString());
1110 DALI_TEST_CHECK(event4.state == static_cast<Integration::KeyEvent::State>(data.receivedKeyEvent.GetState()));
1114 int UtcDaliStageSignalKeyEventN(void)
1116 TestApplication application;
1117 Stage stage = Stage::GetCurrent();
1119 KeyEventSignalData data;
1120 KeyEventReceivedFunctor functor(data);
1121 stage.KeyEventSignal().Connect(&application, functor);
1123 // Check that a non-pressed key events data is not modified.
1124 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1129 int UtcDaliStageTouchedSignalP(void)
1131 TestApplication application;
1132 Stage stage = Stage::GetCurrent();
1134 TouchedSignalData data;
1135 TouchFunctor functor(data);
1136 stage.TouchedSignal().Connect(&application, functor);
1138 // Render and notify.
1139 application.SendNotification();
1140 application.Render();
1142 // Basic test: No actors, single touch (down then up).
1144 GenerateTouch(application, PointState::DOWN, Vector2(10.0f, 10.0f));
1146 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1147 DALI_TEST_CHECK(data.receivedTouchEvent.GetPointCount() != 0u);
1148 DALI_TEST_CHECK(!data.receivedTouchEvent.GetHitActor(0));
1151 GenerateTouch(application, PointState::UP, Vector2(10.0f, 10.0f));
1153 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1154 DALI_TEST_CHECK(data.receivedTouchEvent.GetPointCount() != 0u);
1155 DALI_TEST_CHECK(!data.receivedTouchEvent.GetHitActor(0));
1160 // Add an actor to the scene.
1161 Actor actor = Actor::New();
1162 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1163 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1164 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1165 actor.TouchedSignal().Connect(&DummyTouchCallback);
1168 // Render and notify.
1169 application.SendNotification();
1170 application.Render();
1172 // Actor on scene, single touch, down in actor, motion, then up outside actor.
1174 GenerateTouch(application, PointState::DOWN, Vector2(10.0f, 10.0f));
1176 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1177 DALI_TEST_CHECK(data.receivedTouchEvent.GetPointCount() != 0u);
1178 DALI_TEST_CHECK(data.receivedTouchEvent.GetHitActor(0));
1181 GenerateTouch(application, PointState::MOTION, Vector2(150.0f, 10.0f)); // Some motion
1183 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1186 GenerateTouch(application, PointState::UP, Vector2(150.0f, 10.0f)); // Some motion
1188 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1189 DALI_TEST_CHECK(data.receivedTouchEvent.GetPointCount() != 0u);
1190 DALI_TEST_CHECK(!data.receivedTouchEvent.GetHitActor(0));
1194 // Multiple touch. Should only receive a touch on first down and last up.
1196 Integration::TouchEvent touchEvent;
1197 Integration::Point point;
1200 point.SetState(PointState::DOWN);
1201 point.SetScreenPosition(Vector2(10.0f, 10.0f));
1202 touchEvent.points.push_back(point);
1203 application.ProcessEvent(touchEvent);
1204 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1205 DALI_TEST_EQUALS(data.receivedTouchEvent.GetPointCount(), 1u, TEST_LOCATION);
1209 touchEvent.points[0].SetState(PointState::STATIONARY);
1210 point.SetDeviceId(1);
1211 point.SetScreenPosition(Vector2(50.0f, 50.0f));
1212 touchEvent.points.push_back(point);
1213 application.ProcessEvent(touchEvent);
1214 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1215 DALI_TEST_EQUALS((bool)data.receivedTouchEvent, false, TEST_LOCATION);
1218 // Primary point is up
1219 touchEvent.points[0].SetState(PointState::UP);
1220 touchEvent.points[1].SetState(PointState::STATIONARY);
1221 application.ProcessEvent(touchEvent);
1222 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1223 DALI_TEST_EQUALS((bool)data.receivedTouchEvent, false, TEST_LOCATION);
1226 // Remove 1st point now, 2nd point is now in motion
1227 touchEvent.points.erase(touchEvent.points.begin());
1228 touchEvent.points[0].SetState(PointState::MOTION);
1229 touchEvent.points[0].SetScreenPosition(Vector2(150.0f, 50.0f));
1230 application.ProcessEvent(touchEvent);
1231 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1232 DALI_TEST_EQUALS((bool)data.receivedTouchEvent, false, TEST_LOCATION);
1236 touchEvent.points[0].SetState(PointState::UP);
1237 application.ProcessEvent(touchEvent);
1238 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1239 DALI_TEST_EQUALS(data.receivedTouchEvent.GetPointCount(), 1u, TEST_LOCATION);
1245 int UtcDaliStageTouchedSignalP2(void)
1247 TestApplication application;
1248 Stage stage = Stage::GetCurrent();
1249 tet_printf("UtcDaliStageTouchedSignalP2 - check touched signal connection by name\n");
1251 TouchedSignalData data;
1252 TouchFunctor functor(data);
1253 GetImplementation(stage).ConnectSignal(&application, "touched", functor);
1255 // Render and notify.
1256 application.SendNotification();
1257 application.Render();
1259 // Basic test: No actors, single touch (down then up).
1261 GenerateTouch(application, PointState::DOWN, Vector2(10.0f, 10.0f));
1263 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1266 GenerateTouch(application, PointState::UP, Vector2(10.0f, 10.0f));
1267 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1273 int UtcDaliStageTouchedSignalN(void)
1275 TestApplication application;
1276 Stage stage = Stage::GetCurrent();
1278 TouchedSignalData data;
1279 TouchFunctor functor(data);
1280 stage.TouchedSignal().Connect(&application, functor);
1282 // Render and notify.
1283 application.SendNotification();
1284 application.Render();
1286 // Confirm functor not called before there has been any touch event.
1287 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1289 // No actors, single touch, down, motion then up.
1291 GenerateTouch(application, PointState::DOWN, Vector2(10.0f, 10.0f));
1293 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1294 DALI_TEST_CHECK(data.receivedTouchEvent.GetPointCount() != 0u);
1295 DALI_TEST_CHECK(!data.receivedTouchEvent.GetHitActor(0));
1298 // Confirm there is no signal when the touchpoint is only moved.
1299 GenerateTouch(application, PointState::MOTION, Vector2(1200.0f, 10.0f)); // Some motion
1301 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1304 // Confirm a following up event generates a signal.
1305 GenerateTouch(application, PointState::UP, Vector2(1200.0f, 10.0f));
1307 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1308 DALI_TEST_CHECK(data.receivedTouchEvent.GetPointCount() != 0u);
1309 DALI_TEST_CHECK(!data.receivedTouchEvent.GetHitActor(0));
1313 // Add an actor to the scene.
1314 Actor actor = Actor::New();
1315 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1316 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1317 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1318 actor.TouchedSignal().Connect(&DummyTouchCallback);
1321 // Render and notify.
1322 application.SendNotification();
1323 application.Render();
1325 // Actor on scene. Interrupted before down and interrupted after down.
1327 GenerateTouch(application, PointState::INTERRUPTED, Vector2(10.0f, 10.0f));
1329 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1330 DALI_TEST_CHECK(data.receivedTouchEvent.GetPointCount() != 0u);
1331 DALI_TEST_CHECK(!data.receivedTouchEvent.GetHitActor(0));
1332 DALI_TEST_CHECK(data.receivedTouchEvent.GetState(0) == PointState::INTERRUPTED);
1335 GenerateTouch(application, PointState::DOWN, Vector2(10.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) == actor);
1340 DALI_TEST_CHECK(data.receivedTouchEvent.GetState(0) == PointState::DOWN);
1343 GenerateTouch(application, PointState::INTERRUPTED, Vector2(10.0f, 10.0f));
1345 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1346 DALI_TEST_CHECK(data.receivedTouchEvent.GetPointCount() != 0u);
1347 DALI_TEST_CHECK(!data.receivedTouchEvent.GetHitActor(0));
1348 DALI_TEST_CHECK(data.receivedTouchEvent.GetState(0) == PointState::INTERRUPTED);
1350 DALI_TEST_EQUALS(data.receivedTouchEvent.GetPointCount(), 1u, TEST_LOCATION);
1352 // Check that getting info about a non-existent point causes an assert.
1353 DALI_TEST_EQUALS(data.receivedTouchEvent.GetState(1), PointState::FINISHED, TEST_LOCATION);
1361 int UtcDaliStageSignalWheelEventP(void)
1363 TestApplication application;
1364 Stage stage = Stage::GetCurrent();
1366 WheelEventSignalData data;
1367 WheelEventReceivedFunctor functor(data);
1368 stage.WheelEventSignal().Connect(&application, functor);
1370 Integration::WheelEvent event(Integration::WheelEvent::CUSTOM_WHEEL, 0, 0u, Vector2(0.0f, 0.0f), 1, 1000u);
1371 application.ProcessEvent(event);
1373 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1374 DALI_TEST_CHECK(static_cast<WheelEvent::Type>(event.type) == data.receivedWheelEvent.GetType());
1375 DALI_TEST_CHECK(event.direction == data.receivedWheelEvent.GetDirection());
1376 DALI_TEST_CHECK(event.modifiers == data.receivedWheelEvent.GetModifiers());
1377 DALI_TEST_CHECK(event.point == data.receivedWheelEvent.GetPoint());
1378 DALI_TEST_CHECK(event.delta == data.receivedWheelEvent.GetDelta());
1379 DALI_TEST_CHECK(event.timeStamp == data.receivedWheelEvent.GetTime());
1383 Integration::WheelEvent event2(Integration::WheelEvent::CUSTOM_WHEEL, 0, 0u, Vector2(0.0f, 0.0f), -1, 1000u);
1384 application.ProcessEvent(event2);
1386 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1387 DALI_TEST_CHECK(static_cast<WheelEvent::Type>(event2.type) == data.receivedWheelEvent.GetType());
1388 DALI_TEST_CHECK(event2.direction == data.receivedWheelEvent.GetDirection());
1389 DALI_TEST_CHECK(event2.modifiers == data.receivedWheelEvent.GetModifiers());
1390 DALI_TEST_CHECK(event2.point == data.receivedWheelEvent.GetPoint());
1391 DALI_TEST_CHECK(event2.delta == data.receivedWheelEvent.GetDelta());
1392 DALI_TEST_CHECK(event2.timeStamp == data.receivedWheelEvent.GetTime());
1396 int UtcDaliStageSignalWheelEventP2(void)
1398 TestApplication application;
1399 Stage stage = Stage::GetCurrent();
1400 tet_printf("UtcDaliStageSignalWheelEventP2 - check wheel signal connection by name\n");
1402 WheelEventSignalData data;
1403 WheelEventReceivedVoidFunctor functor(data);
1404 GetImplementation(stage).ConnectSignal(&application, "wheelEvent", functor);
1406 Integration::WheelEvent event(Integration::WheelEvent::CUSTOM_WHEEL, 0, 0u, Vector2(0.0f, 0.0f), 1, 1000u);
1407 application.ProcessEvent(event);
1409 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1410 // It's meaningless, since there's no data passed to the functor :/
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);
1421 int UtcDaliStageContextLostSignalP(void)
1423 TestApplication application;
1424 Stage stage = Stage::GetCurrent();
1426 bool contextLost = false;
1427 ContextStatusFunctor contextLostFunctor(contextLost);
1428 stage.ContextLostSignal().Connect(&application, contextLostFunctor);
1430 Integration::ContextNotifierInterface* notifier = application.GetCore().GetContextNotifier();
1431 notifier->NotifyContextLost();
1432 DALI_TEST_EQUALS(contextLost, true, TEST_LOCATION);
1437 int UtcDaliStageContextLostSignalP2(void)
1439 TestApplication application;
1440 Stage stage = Stage::GetCurrent();
1441 tet_printf("UtcDaliStageContextLostSignalP2 - check context loss signal connection by name\n");
1443 bool contextLost = false;
1444 ContextStatusFunctor contextLostFunctor(contextLost);
1445 GetImplementation(stage).ConnectSignal(&application, "contextLost", contextLostFunctor);
1447 Integration::ContextNotifierInterface* notifier = application.GetCore().GetContextNotifier();
1448 notifier->NotifyContextLost();
1449 DALI_TEST_EQUALS(contextLost, true, TEST_LOCATION);
1454 int UtcDaliStageContextLostSignalN(void)
1456 TestApplication application;
1459 // Check that connecting to the signal with a bad stage instance causes an assert.
1460 bool asserted = false;
1461 bool contextLost = false;
1462 ContextStatusFunctor contextLostFunctor(contextLost);
1465 stage.ContextLostSignal().Connect(&application, contextLostFunctor);
1467 catch(Dali::DaliException& e)
1469 DALI_TEST_PRINT_ASSERT(e);
1470 DALI_TEST_ASSERT(e, "stage && \"Stage handle is empty\"", TEST_LOCATION);
1473 DALI_TEST_CHECK(asserted);
1478 int UtcDaliStageContextRegainedSignalP(void)
1480 TestApplication application;
1481 Stage stage = Stage::GetCurrent();
1483 bool contextRegained = false;
1484 ContextStatusFunctor contextRegainedFunctor(contextRegained);
1485 stage.ContextRegainedSignal().Connect(&application, contextRegainedFunctor);
1487 Integration::ContextNotifierInterface* notifier = application.GetCore().GetContextNotifier();
1488 notifier->NotifyContextLost();
1489 notifier->NotifyContextRegained();
1490 DALI_TEST_EQUALS(contextRegained, true, TEST_LOCATION);
1495 int UtcDaliStageContextRegainedSignalP2(void)
1497 TestApplication application;
1498 Stage stage = Stage::GetCurrent();
1499 tet_printf("UtcDaliStageContextRegainedSignalP2 - check context regained signal connection by name\n");
1501 bool contextRegained = false;
1502 ContextStatusFunctor contextRegainedFunctor(contextRegained);
1503 GetImplementation(stage).ConnectSignal(&application, "contextRegained", contextRegainedFunctor);
1505 Integration::ContextNotifierInterface* notifier = application.GetCore().GetContextNotifier();
1506 notifier->NotifyContextLost();
1507 notifier->NotifyContextRegained();
1508 DALI_TEST_EQUALS(contextRegained, true, TEST_LOCATION);
1513 int UtcDaliStageContextRegainedSignalN(void)
1515 TestApplication application;
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(&application, 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 application;
1540 Stage stage = Stage::GetCurrent();
1542 bool signalCalled = false;
1543 SceneCreatedStatusFunctor sceneCreatedFunctor(signalCalled);
1544 stage.SceneCreatedSignal().Connect(&application, sceneCreatedFunctor);
1546 Integration::Core& core = application.GetCore();
1547 core.SceneCreated();
1548 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
1553 int UtcDaliStageSceneCreatedSignalP2(void)
1555 TestApplication application;
1556 Stage stage = Stage::GetCurrent();
1558 bool signalCalled = false;
1559 SceneCreatedStatusFunctor sceneCreatedFunctor(signalCalled);
1560 GetImplementation(stage).ConnectSignal(&application, "sceneCreated", sceneCreatedFunctor);
1562 Integration::Core& core = application.GetCore();
1563 core.SceneCreated();
1564 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
1569 int UtcDaliStageSceneCreatedSignalN(void)
1571 TestApplication application;
1574 // Check that connecting to the signal with a bad stage instance causes an assert.
1575 bool asserted = false;
1576 bool signalCalled = false;
1577 SceneCreatedStatusFunctor sceneCreatedFunctor(signalCalled);
1580 stage.SceneCreatedSignal().Connect(&application, sceneCreatedFunctor);
1582 catch(Dali::DaliException& e)
1584 DALI_TEST_PRINT_ASSERT(e);
1585 DALI_TEST_ASSERT(e, "stage && \"Stage handle is empty\"", TEST_LOCATION);
1588 DALI_TEST_CHECK(asserted);
1593 int UtcDaliStageGetRenderTaskListP(void)
1595 TestApplication application;
1596 Stage stage = Stage::GetCurrent();
1598 // Check we get a valid instance.
1599 const RenderTaskList& tasks = stage.GetRenderTaskList();
1601 // There should be 1 task by default.
1602 DALI_TEST_EQUALS(tasks.GetTaskCount(), 1u, TEST_LOCATION);
1604 // RenderTaskList has it's own UTC tests.
1605 // But we can confirm that GetRenderTaskList in Stage retrieves the same RenderTaskList each time.
1606 RenderTask newTask = stage.GetRenderTaskList().CreateTask();
1608 DALI_TEST_EQUALS(stage.GetRenderTaskList().GetTask(1), newTask, TEST_LOCATION);
1613 int UtcDaliStageGetRenderTaskListN(void)
1615 TestApplication application;
1618 // Check that getting the render task list with a bad stage instance causes an assert.
1619 bool asserted = false;
1622 stage.GetRenderTaskList();
1624 catch(Dali::DaliException& e)
1626 DALI_TEST_PRINT_ASSERT(e);
1627 DALI_TEST_ASSERT(e, "stage && \"Stage handle is empty\"", TEST_LOCATION);
1630 DALI_TEST_CHECK(asserted);
1635 int UtcDaliStageGetObjectRegistryP(void)
1637 TestApplication application;
1638 Stage stage = Stage::GetCurrent();
1640 ObjectRegistry objectRegistry = stage.GetObjectRegistry();
1642 // Object registry tests are covered in their own module.
1643 // However we want a basic test to confirm the returned registry is valid and works.
1644 bool verified = false;
1645 ActorCreatedFunctor test(verified);
1646 objectRegistry.ObjectCreatedSignal().Connect(&application, test);
1648 Actor actor = Actor::New();
1649 DALI_TEST_CHECK(test.mSignalVerified);
1654 int UtcDaliStageGetObjectRegistryN(void)
1656 TestApplication application;
1659 // Check that getting the object registry with a bad stage instance DOES NOT cause an assert.
1660 // This is because GetCurrent() is used, always creating a stage if one does not exist.
1661 bool asserted = false;
1664 stage.GetObjectRegistry();
1666 catch(Dali::DaliException& e)
1668 DALI_TEST_PRINT_ASSERT(e);
1671 DALI_TEST_CHECK(!asserted);
1676 int UtcDaliStageOperatorAssign(void)
1678 TestApplication application;
1680 DALI_TEST_CHECK(!stage);
1682 stage = Stage::GetCurrent();
1683 DALI_TEST_CHECK(stage);
1688 int UtcDaliStageRenderingBehavior(void)
1690 TestApplication application;
1691 Stage stage = Stage::GetCurrent();
1693 tet_infoline("Check default rendering behavior is only if required");
1694 DALI_TEST_CHECK(DevelStage::GetRenderingBehavior(stage) == DevelStage::Rendering::IF_REQUIRED);
1696 tet_infoline("No update required with an empty application");
1697 application.SendNotification();
1698 DALI_TEST_CHECK(application.UpdateOnly() == false);
1699 application.RenderOnly();
1701 tet_infoline("Change to continuous rendering, further updates should be required");
1702 DevelStage::SetRenderingBehavior(stage, DevelStage::Rendering::CONTINUOUSLY);
1704 DALI_TEST_CHECK(DevelStage::GetRenderingBehavior(stage) == DevelStage::Rendering::CONTINUOUSLY);
1706 application.SendNotification();
1707 DALI_TEST_CHECK(application.UpdateOnly() == true);
1708 application.RenderOnly();
1710 application.SendNotification();
1711 DALI_TEST_CHECK(application.UpdateOnly() == true);
1712 application.RenderOnly();
1714 tet_infoline("Change to rendering only if required, further updates should NOT be required");
1715 DevelStage::SetRenderingBehavior(stage, DevelStage::Rendering::IF_REQUIRED);
1717 DALI_TEST_CHECK(DevelStage::GetRenderingBehavior(stage) == DevelStage::Rendering::IF_REQUIRED);
1719 application.SendNotification();
1720 DALI_TEST_CHECK(application.UpdateOnly() == false);
1721 application.RenderOnly();
1723 tet_infoline("The next update is not required so TestApplication should print a warning");
1724 application.SendNotification();
1725 DALI_TEST_CHECK(application.UpdateOnly() == false);
1726 application.RenderOnly();