2 * Copyright (c) 2022 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.h>
20 #include <dali/integration-api/events/key-event-integ.h>
21 #include <dali/integration-api/events/touch-event-integ.h>
22 #include <dali/integration-api/events/wheel-event-integ.h>
23 #include <dali/integration-api/scene.h>
24 #include <dali/public-api/events/key-event.h>
25 #include <mesh-builder.h>
30 // Internal headers are allowed here
34 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
36 // Functor for EventProcessingFinished signal
37 struct EventProcessingFinishedFunctor
40 * @param[in] eventProcessingFinished reference to a boolean variable used to check if signal has been called.
42 EventProcessingFinishedFunctor(bool& eventProcessingFinished)
43 : mEventProcessingFinished(eventProcessingFinished)
49 mEventProcessingFinished = true;
52 bool& mEventProcessingFinished;
55 // Stores data that is populated in the key-event callback and will be read by the TET cases
56 struct KeyEventSignalData
59 : functorCalled(false)
65 functorCalled = false;
67 receivedKeyEvent.Reset();
71 KeyEvent receivedKeyEvent;
74 // Functor that sets the data when called
75 struct KeyEventReceivedFunctor
77 KeyEventReceivedFunctor(KeyEventSignalData& data)
82 bool operator()(const KeyEvent& keyEvent)
84 signalData.functorCalled = true;
85 signalData.receivedKeyEvent = keyEvent;
90 KeyEventSignalData& signalData;
93 // Stores data that is populated in the touched signal callback and will be read by the TET cases
94 struct TouchedSignalData
97 : functorCalled(false),
98 createNewScene(false),
99 newSceneCreated(false)
105 functorCalled = false;
106 createNewScene = false;
107 newSceneCreated = false;
108 receivedTouchEvent.Reset();
113 bool newSceneCreated;
114 TouchEvent receivedTouchEvent;
117 // Functor that sets the data when touched signal is received
120 TouchFunctor(TouchedSignalData& data)
125 void operator()(const TouchEvent& touch)
127 signalData.functorCalled = true;
128 signalData.receivedTouchEvent = touch;
130 if(signalData.createNewScene)
132 Dali::Integration::Scene scene = Dali::Integration::Scene::New(Size(480.0f, 800.0f));
133 DALI_TEST_CHECK(scene);
135 signalData.newSceneCreated = true;
141 signalData.functorCalled = true;
144 TouchedSignalData& signalData;
147 // Stores data that is populated in the wheel-event callback and will be read by the TET cases
148 struct WheelEventSignalData
150 WheelEventSignalData()
151 : functorCalled(false)
157 functorCalled = false;
161 WheelEvent receivedWheelEvent;
164 // Functor that sets the data when wheel-event signal is received
165 struct WheelEventReceivedFunctor
167 WheelEventReceivedFunctor(WheelEventSignalData& data)
172 bool operator()(const WheelEvent& wheelEvent)
174 signalData.functorCalled = true;
175 signalData.receivedWheelEvent = wheelEvent;
180 WheelEventSignalData& signalData;
183 // Stores data that is populated in the KeyEventGeneratedSignal callback and will be read by the TET cases
184 struct KeyEventGeneratedSignalData
186 KeyEventGeneratedSignalData()
187 : functorCalled(false)
193 functorCalled = false;
195 receivedKeyEvent.Reset();
199 KeyEvent receivedKeyEvent;
202 // Functor that sets the data when called
203 struct KeyEventGeneratedReceivedFunctor
205 KeyEventGeneratedReceivedFunctor(KeyEventGeneratedSignalData& data)
210 bool operator()(const KeyEvent& keyEvent)
212 signalData.functorCalled = true;
213 signalData.receivedKeyEvent = keyEvent;
220 signalData.functorCalled = true;
224 KeyEventGeneratedSignalData& signalData;
227 // Stores data that is populated in the WheelEventGeneratedSignal callback and will be read by the TET cases
228 struct WheelEventGeneratedSignalData
230 WheelEventGeneratedSignalData()
231 : functorCalled(false)
237 functorCalled = false;
239 receivedWheelEvent.Reset();
243 WheelEvent receivedWheelEvent;
246 // Functor that sets the data when called
247 struct WheelEventGeneratedReceivedFunctor
249 WheelEventGeneratedReceivedFunctor(WheelEventGeneratedSignalData& data)
254 bool operator()(const WheelEvent& wheelEvent)
256 signalData.functorCalled = true;
257 signalData.receivedWheelEvent = wheelEvent;
264 signalData.functorCalled = true;
268 WheelEventGeneratedSignalData& signalData;
271 void GenerateTouch(TestApplication& application, PointState::Type state, const Vector2& screenPosition)
273 Integration::TouchEvent touchEvent;
274 Integration::Point point;
275 point.SetState(state);
276 point.SetScreenPosition(screenPosition);
277 touchEvent.points.push_back(point);
278 application.ProcessEvent(touchEvent);
281 bool DummyTouchCallback(Actor actor, const TouchEvent& touch)
286 void FrameCallback(int frameId)
290 } // unnamed namespace
292 int UtcDaliSceneAdd(void)
294 TestApplication application;
295 tet_infoline("Testing Dali::Integration::Scene::Add");
297 Dali::Integration::Scene scene = application.GetScene();
299 Actor actor = Actor::New();
300 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
303 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
308 int UtcDaliSceneRemove(void)
310 TestApplication application;
311 tet_infoline("Testing Dali::Integration::Scene::Remove");
313 Dali::Integration::Scene scene = application.GetScene();
315 Actor actor = Actor::New();
316 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
319 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
322 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
327 int UtcDaliSceneGetSize(void)
329 TestApplication application;
330 tet_infoline("Testing Dali::Integration::Scene::GetSize");
332 Dali::Integration::Scene scene = application.GetScene();
333 Size size = scene.GetSize();
334 DALI_TEST_EQUALS(TestApplication::DEFAULT_SURFACE_WIDTH, size.width, TEST_LOCATION);
335 DALI_TEST_EQUALS(TestApplication::DEFAULT_SURFACE_HEIGHT, size.height, TEST_LOCATION);
340 int UtcDaliSceneGetDpi(void)
342 TestApplication application; // Initializes core DPI to default values
344 // Test that setting core DPI explicitly also sets up the scene's DPI.
345 Dali::Integration::Scene scene = application.GetScene();
346 scene.SetDpi(Vector2(200.0f, 180.0f));
347 Vector2 dpi = scene.GetDpi();
348 DALI_TEST_EQUALS(dpi.x, 200.0f, TEST_LOCATION);
349 DALI_TEST_EQUALS(dpi.y, 180.0f, TEST_LOCATION);
353 int UtcDaliSceneGetRenderTaskList(void)
355 TestApplication application;
356 tet_infoline("Testing Dali::Integration::Scene::GetRenderTaskList");
358 Dali::Integration::Scene scene = application.GetScene();
360 // Check we get a valid instance.
361 const RenderTaskList& tasks = scene.GetRenderTaskList();
363 // There should be 1 task by default.
364 DALI_TEST_EQUALS(tasks.GetTaskCount(), 1u, TEST_LOCATION);
366 // RenderTaskList has it's own UTC tests.
367 // But we can confirm that GetRenderTaskList in Stage retrieves the same RenderTaskList each time.
368 RenderTask newTask = scene.GetRenderTaskList().CreateTask();
370 DALI_TEST_EQUALS(scene.GetRenderTaskList().GetTask(1), newTask, TEST_LOCATION);
375 int UtcDaliSceneGetRootLayer(void)
377 TestApplication application;
378 tet_infoline("Testing Dali::Integration::Scene::GetRootLayer");
380 Dali::Integration::Scene scene = application.GetScene();
381 Layer layer = scene.GetLayer(0);
382 DALI_TEST_CHECK(layer);
384 // Check that GetRootLayer() correctly retreived layer 0.
385 DALI_TEST_CHECK(scene.GetRootLayer() == layer);
390 int UtcDaliSceneGetLayerCount(void)
392 TestApplication application;
393 tet_infoline("Testing Dali::Integration::Scene::GetLayerCount");
395 Dali::Integration::Scene scene = application.GetScene();
396 // Initially we have a default layer
397 DALI_TEST_EQUALS(scene.GetLayerCount(), 1u, TEST_LOCATION);
399 Layer layer = Layer::New();
402 DALI_TEST_EQUALS(scene.GetLayerCount(), 2u, TEST_LOCATION);
406 int UtcDaliSceneGetLayer(void)
408 TestApplication application;
409 tet_infoline("Testing Dali::Integration::Scene::GetLayer");
411 Dali::Integration::Scene scene = application.GetScene();
413 Layer rootLayer = scene.GetLayer(0);
414 DALI_TEST_CHECK(rootLayer);
416 Layer layer = Layer::New();
419 Layer sameLayer = scene.GetLayer(1);
420 DALI_TEST_CHECK(layer == sameLayer);
425 int UtcDaliSceneGet(void)
427 TestApplication application;
428 tet_infoline("Testing Dali::Integration::Scene::Get");
430 Dali::Integration::Scene scene = application.GetScene();
432 Actor parent = Actor::New();
433 Actor child = Actor::New();
437 // Should be empty scene
438 DALI_TEST_CHECK(Dali::Integration::Scene() == Dali::Integration::Scene::Get(parent));
439 DALI_TEST_CHECK(Dali::Integration::Scene() == Dali::Integration::Scene::Get(child));
443 // Should return the valid scene
444 DALI_TEST_CHECK(scene == Dali::Integration::Scene::Get(parent));
445 DALI_TEST_CHECK(scene == Dali::Integration::Scene::Get(child));
449 // Should be empty scene
450 DALI_TEST_CHECK(Dali::Integration::Scene() == Dali::Integration::Scene::Get(parent));
451 DALI_TEST_CHECK(Dali::Integration::Scene() == Dali::Integration::Scene::Get(child));
456 int UtcDaliSceneDiscard(void)
458 TestApplication application;
459 tet_infoline("Testing Dali::Scene::Discard");
461 // Create a new Scene
462 Dali::Integration::Scene scene = Dali::Integration::Scene::New(Size(480.0f, 800.0f));
463 DALI_TEST_CHECK(scene);
465 // One reference of scene kept here and the other one kept in the Core
466 DALI_TEST_CHECK(scene.GetBaseObject().ReferenceCount() == 2);
468 // Render and notify.
469 application.SendNotification();
470 application.Render(0);
472 // Keep the reference of the root layer handle so it will still be alive after the scene is deleted
473 Layer rootLayer = scene.GetRootLayer();
474 DALI_TEST_CHECK(rootLayer);
475 DALI_TEST_CHECK(rootLayer.GetBaseObject().ReferenceCount() == 2);
477 // Request to discard the scene from the Core
479 DALI_TEST_CHECK(scene.GetBaseObject().ReferenceCount() == 1);
481 // Reset the scene handle
484 // Render and notify.
485 application.SendNotification();
486 application.Render(0);
488 // At this point, the scene should have been automatically deleted
489 // To prove this, the ref count of the root layer handle should be decremented to 1
490 DALI_TEST_CHECK(rootLayer.GetBaseObject().ReferenceCount() == 1);
492 // Delete the root layer handle
495 // Render and notify.
496 application.SendNotification();
497 application.Render(0);
502 int UtcDaliSceneCreateNewSceneDuringCoreEventProcessing(void)
504 TestApplication application;
506 Dali::Integration::Scene scene = application.GetScene();
508 TouchedSignalData data;
509 data.createNewScene = true;
510 TouchFunctor functor(data);
511 scene.TouchedSignal().Connect(&application, functor);
513 // Render and notify.
514 application.SendNotification();
515 application.Render();
517 GenerateTouch(application, PointState::DOWN, Vector2(10.0f, 10.0f));
519 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
520 DALI_TEST_EQUALS(true, data.createNewScene, TEST_LOCATION);
521 DALI_TEST_EQUALS(true, data.newSceneCreated, TEST_LOCATION);
527 int UtcDaliSceneRootLayerAndSceneAlignment(void)
529 TestApplication application;
532 Dali::Integration::Scene scene = Dali::Integration::Scene::New(Size(480.0f, 800.0f));
533 DALI_TEST_CHECK(scene);
535 // One reference of scene kept here and the other one kept in the Core
536 DALI_TEST_CHECK(scene.GetBaseObject().ReferenceCount() == 2);
538 // Add a renderable actor to the scene
539 auto actor = CreateRenderableActor();
542 // Render and notify.
543 application.SendNotification();
544 application.Render(0);
546 // Keep the reference of the root layer handle so it will still be alive after the scene is deleted
547 Layer rootLayer = scene.GetRootLayer();
548 DALI_TEST_CHECK(rootLayer);
549 DALI_TEST_CHECK(rootLayer.GetBaseObject().ReferenceCount() == 2);
551 // Request to discard the scene from the Core
553 DALI_TEST_CHECK(scene.GetBaseObject().ReferenceCount() == 1);
555 // Reset the scene handle
558 // Render and notify.
559 application.SendNotification();
560 application.Render(0);
562 // At this point, the scene should have been automatically deleted
563 // To prove this, the ref count of the root layer handle should be decremented to 1
564 DALI_TEST_CHECK(rootLayer.GetBaseObject().ReferenceCount() == 1);
566 // Create a new Scene while the root layer of the deleted scene is still alive
567 Dali::Integration::Scene newScene = Dali::Integration::Scene::New(Size(480.0f, 800.0f));
568 DALI_TEST_CHECK(newScene);
570 // Render and notify.
571 application.SendNotification();
572 application.Render(0);
574 // At this point, we have only one scene but two root layers
575 // The root layer of the deleted scene is still alive
576 DALI_TEST_CHECK(rootLayer.GetBaseObject().ReferenceCount() == 1);
578 // Delete the root layer of the deleted scene
581 // Render and notify.
582 application.SendNotification();
583 application.Render(0);
588 int UtcDaliSceneEventProcessingFinishedP(void)
590 TestApplication application;
591 Dali::Integration::Scene scene = application.GetScene();
593 bool eventProcessingFinished = false;
594 EventProcessingFinishedFunctor functor(eventProcessingFinished);
595 scene.EventProcessingFinishedSignal().Connect(&application, functor);
597 Actor actor(Actor::New());
600 application.SendNotification();
601 application.Render();
603 DALI_TEST_CHECK(eventProcessingFinished);
608 int UtcDaliSceneEventProcessingFinishedN(void)
610 TestApplication application;
611 Dali::Integration::Scene scene = application.GetScene();
613 bool eventProcessingFinished = false;
614 EventProcessingFinishedFunctor functor(eventProcessingFinished);
615 scene.EventProcessingFinishedSignal().Connect(&application, functor);
617 Actor actor(Actor::New());
620 // Do not complete event processing and confirm the signal has not been emitted.
621 DALI_TEST_CHECK(!eventProcessingFinished);
626 int UtcDaliSceneSignalKeyEventP(void)
628 TestApplication application;
629 Dali::Integration::Scene scene = application.GetScene();
631 KeyEventSignalData data;
632 KeyEventReceivedFunctor functor(data);
633 scene.KeyEventSignal().Connect(&application, functor);
635 Integration::KeyEvent event("i", "", "i", 0, 0, 0, Integration::KeyEvent::DOWN, "i", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE);
636 application.ProcessEvent(event);
638 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
639 DALI_TEST_CHECK(event.keyModifier == data.receivedKeyEvent.GetKeyModifier());
640 DALI_TEST_CHECK(event.keyName == data.receivedKeyEvent.GetKeyName());
641 DALI_TEST_CHECK(event.keyString == data.receivedKeyEvent.GetKeyString());
642 DALI_TEST_CHECK(event.state == static_cast<Integration::KeyEvent::State>(data.receivedKeyEvent.GetState()));
646 Integration::KeyEvent event2("i", "", "i", 0, 0, 0, Integration::KeyEvent::UP, "i", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE);
647 application.ProcessEvent(event2);
649 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
650 DALI_TEST_CHECK(event2.keyModifier == data.receivedKeyEvent.GetKeyModifier());
651 DALI_TEST_CHECK(event2.keyName == data.receivedKeyEvent.GetKeyName());
652 DALI_TEST_CHECK(event2.keyString == data.receivedKeyEvent.GetKeyString());
653 DALI_TEST_CHECK(event2.state == static_cast<Integration::KeyEvent::State>(data.receivedKeyEvent.GetState()));
657 Integration::KeyEvent event3("a", "", "a", 0, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE);
658 application.ProcessEvent(event3);
660 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
661 DALI_TEST_CHECK(event3.keyModifier == data.receivedKeyEvent.GetKeyModifier());
662 DALI_TEST_CHECK(event3.keyName == data.receivedKeyEvent.GetKeyName());
663 DALI_TEST_CHECK(event3.keyString == data.receivedKeyEvent.GetKeyString());
664 DALI_TEST_CHECK(event3.state == static_cast<Integration::KeyEvent::State>(data.receivedKeyEvent.GetState()));
668 Integration::KeyEvent event4("a", "", "a", 0, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE);
669 application.ProcessEvent(event4);
671 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
672 DALI_TEST_CHECK(event4.keyModifier == data.receivedKeyEvent.GetKeyModifier());
673 DALI_TEST_CHECK(event4.keyName == data.receivedKeyEvent.GetKeyName());
674 DALI_TEST_CHECK(event4.keyString == data.receivedKeyEvent.GetKeyString());
675 DALI_TEST_CHECK(event4.state == static_cast<Integration::KeyEvent::State>(data.receivedKeyEvent.GetState()));
679 int UtcDaliSceneSignalKeyEventN(void)
681 TestApplication application;
682 Dali::Integration::Scene scene = application.GetScene();
684 KeyEventSignalData data;
685 KeyEventReceivedFunctor functor(data);
686 scene.KeyEventSignal().Connect(&application, functor);
688 // Check that a non-pressed key events data is not modified.
689 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
694 int UtcDaliSceneTouchedSignalP(void)
696 TestApplication application;
697 Dali::Integration::Scene scene = application.GetScene();
699 TouchedSignalData data;
700 TouchFunctor functor(data);
701 scene.TouchedSignal().Connect(&application, functor);
703 // Render and notify.
704 application.SendNotification();
705 application.Render();
707 // Basic test: No actors, single touch (down then up).
709 GenerateTouch(application, PointState::DOWN, Vector2(10.0f, 10.0f));
711 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
712 DALI_TEST_CHECK(data.receivedTouchEvent.GetPointCount() != 0u);
713 DALI_TEST_CHECK(!data.receivedTouchEvent.GetHitActor(0));
716 GenerateTouch(application, PointState::UP, Vector2(10.0f, 10.0f));
718 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
719 DALI_TEST_CHECK(data.receivedTouchEvent.GetPointCount() != 0u);
720 DALI_TEST_CHECK(!data.receivedTouchEvent.GetHitActor(0));
724 // Add an actor to the scene.
725 Actor actor = Actor::New();
726 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
727 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
728 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
729 actor.TouchedSignal().Connect(&DummyTouchCallback);
732 // Render and notify.
733 application.SendNotification();
734 application.Render();
736 // Actor on scene, single touch, down in actor, motion, then up outside actor.
738 GenerateTouch(application, PointState::DOWN, Vector2(10.0f, 10.0f));
740 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
741 DALI_TEST_CHECK(data.receivedTouchEvent.GetPointCount() != 0u);
742 DALI_TEST_CHECK(data.receivedTouchEvent.GetHitActor(0) == actor);
745 GenerateTouch(application, PointState::MOTION, Vector2(150.0f, 10.0f)); // Some motion
747 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
750 GenerateTouch(application, PointState::UP, Vector2(150.0f, 10.0f)); // Some motion
752 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
753 DALI_TEST_CHECK(data.receivedTouchEvent.GetPointCount() != 0u);
754 DALI_TEST_CHECK(!data.receivedTouchEvent.GetHitActor(0));
758 // Multiple touch. Should only receive a touch on first down and last up.
760 Integration::TouchEvent touchEvent;
761 Integration::Point point;
764 point.SetState(PointState::DOWN);
765 point.SetScreenPosition(Vector2(10.0f, 10.0f));
766 touchEvent.points.push_back(point);
767 application.ProcessEvent(touchEvent);
768 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
769 DALI_TEST_EQUALS(data.receivedTouchEvent.GetPointCount(), 1u, TEST_LOCATION);
773 touchEvent.points[0].SetState(PointState::STATIONARY);
774 point.SetDeviceId(1);
775 point.SetScreenPosition(Vector2(50.0f, 50.0f));
776 touchEvent.points.push_back(point);
777 application.ProcessEvent(touchEvent);
778 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
781 // Primary point is up
782 touchEvent.points[0].SetState(PointState::UP);
783 touchEvent.points[1].SetState(PointState::STATIONARY);
784 application.ProcessEvent(touchEvent);
785 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
788 // Remove 1st point now, 2nd point is now in motion
789 touchEvent.points.erase(touchEvent.points.begin());
790 touchEvent.points[0].SetState(PointState::MOTION);
791 touchEvent.points[0].SetScreenPosition(Vector2(150.0f, 50.0f));
792 application.ProcessEvent(touchEvent);
793 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
797 touchEvent.points[0].SetState(PointState::UP);
798 application.ProcessEvent(touchEvent);
799 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
800 DALI_TEST_EQUALS(data.receivedTouchEvent.GetPointCount(), 1u, TEST_LOCATION);
806 int UtcDaliSceneTouchedSignalN(void)
808 TestApplication application;
809 Dali::Integration::Scene scene = application.GetScene();
811 TouchedSignalData data;
812 TouchFunctor functor(data);
813 scene.TouchedSignal().Connect(&application, functor);
815 // Render and notify.
816 application.SendNotification();
817 application.Render();
819 // Confirm functor not called before there has been any touch event.
820 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
822 // No actors, single touch, down, motion then up.
824 GenerateTouch(application, PointState::DOWN, Vector2(10.0f, 10.0f));
826 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
827 DALI_TEST_CHECK(data.receivedTouchEvent.GetPointCount() != 0u);
828 DALI_TEST_CHECK(!data.receivedTouchEvent.GetHitActor(0));
832 // Confirm there is no signal when the touchpoint is only moved.
833 GenerateTouch(application, PointState::MOTION, Vector2(1200.0f, 10.0f)); // Some motion
835 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
838 // Confirm a following up event generates a signal.
839 GenerateTouch(application, PointState::UP, Vector2(1200.0f, 10.0f));
841 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
842 DALI_TEST_CHECK(data.receivedTouchEvent.GetPointCount() != 0u);
843 DALI_TEST_CHECK(!data.receivedTouchEvent.GetHitActor(0));
847 // Add an actor to the scene.
848 Actor actor = Actor::New();
849 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
850 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
851 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
852 actor.TouchedSignal().Connect(&DummyTouchCallback);
855 // Render and notify.
856 application.SendNotification();
857 application.Render();
859 // Actor on scene. Interrupted before down and interrupted after down.
861 GenerateTouch(application, PointState::INTERRUPTED, Vector2(10.0f, 10.0f));
863 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
864 DALI_TEST_CHECK(data.receivedTouchEvent.GetPointCount() != 0u);
865 DALI_TEST_CHECK(!data.receivedTouchEvent.GetHitActor(0));
866 DALI_TEST_CHECK(data.receivedTouchEvent.GetState(0) == PointState::INTERRUPTED);
869 GenerateTouch(application, PointState::DOWN, Vector2(10.0f, 10.0f));
871 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
872 DALI_TEST_CHECK(data.receivedTouchEvent.GetPointCount() != 0u);
873 DALI_TEST_CHECK(data.receivedTouchEvent.GetHitActor(0) == actor);
874 DALI_TEST_CHECK(data.receivedTouchEvent.GetState(0) == PointState::DOWN);
877 GenerateTouch(application, PointState::INTERRUPTED, Vector2(10.0f, 10.0f));
879 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
880 DALI_TEST_CHECK(data.receivedTouchEvent.GetPointCount() != 0u);
881 DALI_TEST_CHECK(!data.receivedTouchEvent.GetHitActor(0));
882 DALI_TEST_CHECK(data.receivedTouchEvent.GetState(0) == PointState::INTERRUPTED);
884 DALI_TEST_EQUALS(data.receivedTouchEvent.GetPointCount(), 1u, TEST_LOCATION);
886 // Check that getting info about a non-existent point returns an empty handle
887 Actor actor = data.receivedTouchEvent.GetHitActor(1);
888 DALI_TEST_CHECK(!actor);
896 int UtcDaliSceneSignalWheelEventP(void)
898 TestApplication application;
899 Dali::Integration::Scene scene = application.GetScene();
901 WheelEventSignalData data;
902 WheelEventReceivedFunctor functor(data);
903 scene.WheelEventSignal().Connect(&application, functor);
905 Integration::WheelEvent event(Integration::WheelEvent::CUSTOM_WHEEL, 0, 0u, Vector2(0.0f, 0.0f), 1, 1000u);
906 application.ProcessEvent(event);
908 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
909 DALI_TEST_CHECK(static_cast<WheelEvent::Type>(event.type) == data.receivedWheelEvent.GetType());
910 DALI_TEST_CHECK(event.direction == data.receivedWheelEvent.GetDirection());
911 DALI_TEST_CHECK(event.modifiers == data.receivedWheelEvent.GetModifiers());
912 DALI_TEST_CHECK(event.point == data.receivedWheelEvent.GetPoint());
913 DALI_TEST_CHECK(event.delta == data.receivedWheelEvent.GetDelta());
914 DALI_TEST_CHECK(event.timeStamp == data.receivedWheelEvent.GetTime());
918 Integration::WheelEvent event2(Integration::WheelEvent::CUSTOM_WHEEL, 0, 0u, Vector2(0.0f, 0.0f), -1, 1000u);
919 application.ProcessEvent(event2);
921 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
922 DALI_TEST_CHECK(static_cast<WheelEvent::Type>(event2.type) == data.receivedWheelEvent.GetType());
923 DALI_TEST_CHECK(event2.direction == data.receivedWheelEvent.GetDirection());
924 DALI_TEST_CHECK(event2.modifiers == data.receivedWheelEvent.GetModifiers());
925 DALI_TEST_CHECK(event2.point == data.receivedWheelEvent.GetPoint());
926 DALI_TEST_CHECK(event2.delta == data.receivedWheelEvent.GetDelta());
927 DALI_TEST_CHECK(event2.timeStamp == data.receivedWheelEvent.GetTime());
931 int UtcDaliSceneSurfaceResizedDefaultScene(void)
933 tet_infoline("Ensure resizing of the surface is handled properly");
935 TestApplication application;
937 auto defaultScene = application.GetScene();
938 DALI_TEST_CHECK(defaultScene);
940 // Ensure stage size matches the scene size
941 auto stage = Stage::GetCurrent();
942 DALI_TEST_EQUALS(stage.GetSize(), defaultScene.GetSize(), TEST_LOCATION);
945 Vector2 newSize(1000.0f, 2000.0f);
946 DALI_TEST_CHECK(stage.GetSize() != newSize);
947 defaultScene.SurfaceResized(newSize.width, newSize.height);
949 DALI_TEST_EQUALS(stage.GetSize(), newSize, TEST_LOCATION);
950 DALI_TEST_EQUALS(defaultScene.GetSize(), newSize, TEST_LOCATION);
955 int UtcDaliSceneSurfaceResizedDefaultSceneViewport(void)
957 tet_infoline("Ensure resizing of the surface & viewport is handled properly");
959 TestApplication application;
960 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
961 TraceCallStack& callStack = glAbstraction.GetViewportTrace();
962 glAbstraction.EnableViewportCallTrace(true);
964 // Initial scene setup
965 Geometry geometry = CreateQuadGeometry();
966 Shader shader = CreateShader();
967 Renderer renderer = Renderer::New(geometry, shader);
969 Actor actor = Actor::New();
970 actor.AddRenderer(renderer);
971 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
972 application.GetScene().Add(actor);
974 // Render before resizing surface
975 application.SendNotification();
976 application.Render(0);
977 glAbstraction.ResetViewportCallStack();
979 auto defaultScene = application.GetScene();
980 DALI_TEST_CHECK(defaultScene);
982 // consume the resize flag by first rendering
983 defaultScene.IsSurfaceRectChanged();
985 // Ensure stage size matches the scene size
986 auto stage = Stage::GetCurrent();
987 DALI_TEST_EQUALS(stage.GetSize(), defaultScene.GetSize(), TEST_LOCATION);
989 Rect<int32_t> surfaceRect = defaultScene.GetCurrentSurfaceRect();
992 // check resized flag before surface is resized.
993 surfaceResized = defaultScene.IsSurfaceRectChanged();
994 DALI_TEST_EQUALS(surfaceResized, false, TEST_LOCATION);
997 Vector2 newSize(1000.0f, 2000.0f);
998 std::string viewportParams("0, 0, 1000, 2000"); // to match newSize
999 DALI_TEST_CHECK(stage.GetSize() != newSize);
1000 defaultScene.SurfaceResized(newSize.width, newSize.height);
1002 DALI_TEST_EQUALS(stage.GetSize(), newSize, TEST_LOCATION);
1003 DALI_TEST_EQUALS(defaultScene.GetSize(), newSize, TEST_LOCATION);
1005 // Check current surface rect
1006 Rect<int32_t> newSurfaceRect = defaultScene.GetCurrentSurfaceRect();
1008 // It should not be changed yet.
1009 DALI_TEST_CHECK(surfaceRect == newSurfaceRect);
1011 // Render after resizing surface
1012 application.SendNotification();
1013 application.Render(0);
1015 surfaceResized = defaultScene.IsSurfaceRectChanged();
1016 DALI_TEST_EQUALS(surfaceResized, true, TEST_LOCATION);
1018 // Check that the viewport is handled properly
1019 DALI_TEST_CHECK(callStack.FindIndexFromMethodAndParams("Viewport", viewportParams) >= 0);
1021 // Check current surface rect
1022 newSurfaceRect = defaultScene.GetCurrentSurfaceRect();
1024 // It should be changed
1025 DALI_TEST_EQUALS(newSurfaceRect.x, 0, TEST_LOCATION);
1026 DALI_TEST_EQUALS(newSurfaceRect.y, 0, TEST_LOCATION);
1027 DALI_TEST_EQUALS(newSurfaceRect.width, 1000, TEST_LOCATION);
1028 DALI_TEST_EQUALS(newSurfaceRect.height, 2000, TEST_LOCATION);
1033 int UtcDaliSceneSurfaceResizedMultipleRenderTasks(void)
1035 tet_infoline("Ensure resizing of the surface & viewport is handled properly");
1037 TestApplication application;
1038 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
1039 TraceCallStack& callStack = glAbstraction.GetViewportTrace();
1040 glAbstraction.EnableViewportCallTrace(true);
1042 // Initial scene setup
1043 auto scene = application.GetScene();
1045 Geometry geometry = CreateQuadGeometry();
1046 Shader shader = CreateShader();
1047 Renderer renderer = Renderer::New(geometry, shader);
1049 Actor actor = Actor::New();
1050 actor.AddRenderer(renderer);
1051 int testWidth = 400;
1052 int testHeight = 400;
1053 actor.SetProperty(Actor::Property::SIZE, Vector2(testWidth, testHeight));
1056 CameraActor offscreenCameraActor = CameraActor::New(Size(testWidth, testHeight));
1057 application.GetScene().Add(offscreenCameraActor);
1059 FrameBuffer newFrameBuffer = FrameBuffer::New(testWidth, testHeight, FrameBuffer::Attachment::NONE);
1061 RenderTask newTask = scene.GetRenderTaskList().CreateTask();
1062 newTask.SetCameraActor(offscreenCameraActor);
1063 newTask.SetSourceActor(actor);
1064 newTask.SetFrameBuffer(newFrameBuffer);
1065 newTask.SetViewportPosition(Vector2(0, 0));
1066 newTask.SetViewportSize(Vector2(testWidth, testHeight));
1068 // Render before resizing surface
1069 application.SendNotification();
1070 application.Render(0);
1071 glAbstraction.ResetViewportCallStack();
1073 Rect<int32_t> initialViewport = newTask.GetViewport();
1074 int initialWidth = initialViewport.width;
1075 int initialHeight = initialViewport.height;
1076 DALI_TEST_EQUALS(initialWidth, testWidth, TEST_LOCATION);
1077 DALI_TEST_EQUALS(initialHeight, testHeight, TEST_LOCATION);
1079 auto defaultScene = application.GetScene();
1080 DALI_TEST_CHECK(defaultScene);
1082 // Ensure stage size matches the scene size
1083 auto stage = Stage::GetCurrent();
1084 DALI_TEST_EQUALS(stage.GetSize(), defaultScene.GetSize(), TEST_LOCATION);
1087 Vector2 newSize(1000.0f, 2000.0f);
1088 std::string viewportParams("0, 0, 1000, 2000"); // to match newSize
1089 DALI_TEST_CHECK(stage.GetSize() != newSize);
1090 defaultScene.SurfaceResized(newSize.width, newSize.height);
1092 DALI_TEST_EQUALS(stage.GetSize(), newSize, TEST_LOCATION);
1093 DALI_TEST_EQUALS(defaultScene.GetSize(), newSize, TEST_LOCATION);
1095 // Render after resizing surface
1096 application.SendNotification();
1097 application.Render(0);
1099 // Check that the viewport is handled properly
1100 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("Viewport", viewportParams));
1102 // Second render-task should not be affected
1103 Rect<int32_t> viewport = newTask.GetViewport();
1104 int width = viewport.width;
1105 int height = viewport.height;
1106 DALI_TEST_EQUALS(width, testWidth, TEST_LOCATION);
1107 DALI_TEST_EQUALS(height, testHeight, TEST_LOCATION);
1112 int UtcDaliSceneSurfaceResizedAdditionalScene(void)
1114 tet_infoline("Ensure resizing of the surface is handled properly on additional scenes");
1116 TestApplication application;
1117 Vector2 originalSurfaceSize(500.0f, 1000.0f);
1119 auto scene = Integration::Scene::New(Size(originalSurfaceSize.width, originalSurfaceSize.height));
1121 // Ensure stage size does NOT match the surface size
1122 auto stage = Stage::GetCurrent();
1123 const auto stageSize = stage.GetSize();
1124 DALI_TEST_CHECK(stageSize != originalSurfaceSize);
1125 DALI_TEST_EQUALS(originalSurfaceSize, scene.GetSize(), TEST_LOCATION);
1127 // Resize the surface and inform the scene accordingly
1128 Vector2 newSize(1000.0f, 2000.0f);
1129 DALI_TEST_CHECK(stage.GetSize() != newSize);
1130 scene.SurfaceResized(newSize.width, newSize.height);
1132 // Ensure the stage hasn't been resized
1133 DALI_TEST_EQUALS(stage.GetSize(), stageSize, TEST_LOCATION);
1134 DALI_TEST_EQUALS(scene.GetSize(), newSize, TEST_LOCATION);
1139 #define CLIPPING_RECT_X (16)
1140 #define CLIPPING_RECT_Y (768)
1141 #define CLIPPING_RECT_WIDTH (32)
1142 #define CLIPPING_RECT_HEIGHT (32)
1144 int UtcDaliSceneSurfaceRotatedWithAngle0(void)
1146 tet_infoline("Ensure rotation of the surface is handled properly with Angle 0");
1148 TestApplication application(
1149 TestApplication::DEFAULT_SURFACE_WIDTH,
1150 TestApplication::DEFAULT_SURFACE_HEIGHT,
1151 TestApplication::DEFAULT_HORIZONTAL_DPI,
1152 TestApplication::DEFAULT_VERTICAL_DPI,
1156 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
1158 std::vector<Rect<int>> damagedRects;
1159 Rect<int> clippingRect;
1160 application.SendNotification();
1161 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
1163 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
1165 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
1166 application.RenderWithPartialUpdate(damagedRects, clippingRect);
1168 Actor actor = CreateRenderableActor();
1169 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1170 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
1171 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
1172 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1173 application.GetScene().Add(actor);
1175 // consume the orientating changing flag by first rendering
1176 application.SendNotification();
1178 damagedRects.clear();
1179 application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
1180 TestApplication::DEFAULT_SURFACE_HEIGHT,
1183 // Check current orientations
1184 int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
1185 int32_t screenOrientation = application.GetScene().GetCurrentScreenOrientation();
1187 // It should not be changed yet.
1188 DALI_TEST_EQUALS(orientation, 0, TEST_LOCATION);
1189 DALI_TEST_EQUALS(screenOrientation, 0, TEST_LOCATION);
1191 application.SendNotification();
1192 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
1193 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
1195 clippingRect = Rect<int>(CLIPPING_RECT_X, CLIPPING_RECT_Y, CLIPPING_RECT_WIDTH, CLIPPING_RECT_HEIGHT); // in screen coordinates, includes 3 last frames updates
1196 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
1197 application.RenderWithPartialUpdate(damagedRects, clippingRect);
1199 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
1200 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
1201 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
1202 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
1204 // Check current orientations
1205 orientation = application.GetScene().GetCurrentSurfaceOrientation();
1206 screenOrientation = application.GetScene().GetCurrentScreenOrientation();
1208 // It should be changed.
1209 DALI_TEST_EQUALS(orientation, 0, TEST_LOCATION);
1210 DALI_TEST_EQUALS(screenOrientation, 0, TEST_LOCATION);
1215 int UtcDaliSceneSurfaceRotatedWithAngle90(void)
1217 tet_infoline("Ensure rotation of the surface is handled properly with Angle 90");
1219 TestApplication application(
1220 TestApplication::DEFAULT_SURFACE_WIDTH,
1221 TestApplication::DEFAULT_SURFACE_HEIGHT,
1222 TestApplication::DEFAULT_HORIZONTAL_DPI,
1223 TestApplication::DEFAULT_VERTICAL_DPI,
1227 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
1229 std::vector<Rect<int>> damagedRects;
1230 Rect<int> clippingRect;
1231 application.SendNotification();
1232 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
1234 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
1236 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
1237 application.RenderWithPartialUpdate(damagedRects, clippingRect);
1239 Actor actor = CreateRenderableActor();
1240 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1241 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
1242 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
1243 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1244 application.GetScene().Add(actor);
1246 application.SendNotification();
1248 damagedRects.clear();
1249 application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
1250 TestApplication::DEFAULT_SURFACE_HEIGHT,
1253 // Check current surface orientation
1254 int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
1255 int32_t screenOrientation = application.GetScene().GetCurrentScreenOrientation();
1257 // It should not be changed yet.
1258 DALI_TEST_EQUALS(orientation, 0, TEST_LOCATION);
1259 DALI_TEST_EQUALS(screenOrientation, 0, TEST_LOCATION);
1261 application.SendNotification();
1262 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
1263 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
1265 clippingRect = Rect<int>(CLIPPING_RECT_X, CLIPPING_RECT_Y, CLIPPING_RECT_WIDTH, CLIPPING_RECT_HEIGHT); // in screen coordinates, includes 3 last frames updates
1266 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
1267 application.RenderWithPartialUpdate(damagedRects, clippingRect);
1269 // It is recalculation for glScissor.
1270 // Because surface is rotated and glScissor is called with recalcurated value.
1271 clippingRect.x = TestApplication::DEFAULT_SURFACE_HEIGHT - (CLIPPING_RECT_Y + CLIPPING_RECT_HEIGHT);
1272 clippingRect.y = CLIPPING_RECT_X;
1273 clippingRect.width = CLIPPING_RECT_HEIGHT;
1274 clippingRect.height = CLIPPING_RECT_WIDTH;
1276 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
1277 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
1278 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
1279 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
1281 // Check current orientations
1282 orientation = application.GetScene().GetCurrentSurfaceOrientation();
1283 screenOrientation = application.GetScene().GetCurrentScreenOrientation();
1285 // It should be changed.
1286 DALI_TEST_EQUALS(orientation, 90, TEST_LOCATION);
1287 DALI_TEST_EQUALS(screenOrientation, 90, TEST_LOCATION);
1292 int UtcDaliSceneSurfaceRotatedWithAngle180(void)
1294 tet_infoline("Ensure rotation of the surface is handled properly with Angle 180");
1296 TestApplication application(
1297 TestApplication::DEFAULT_SURFACE_WIDTH,
1298 TestApplication::DEFAULT_SURFACE_HEIGHT,
1299 TestApplication::DEFAULT_HORIZONTAL_DPI,
1300 TestApplication::DEFAULT_VERTICAL_DPI,
1304 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
1306 std::vector<Rect<int>> damagedRects;
1307 Rect<int> clippingRect;
1308 application.SendNotification();
1309 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
1311 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
1313 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
1314 application.RenderWithPartialUpdate(damagedRects, clippingRect);
1316 Actor actor = CreateRenderableActor();
1317 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1318 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
1319 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
1320 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1321 application.GetScene().Add(actor);
1323 application.SendNotification();
1325 damagedRects.clear();
1326 application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
1327 TestApplication::DEFAULT_SURFACE_HEIGHT,
1330 // Check current surface orientation
1331 int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
1332 int32_t screenOrientation = application.GetScene().GetCurrentScreenOrientation();
1334 // It should not be changed yet.
1335 DALI_TEST_EQUALS(orientation, 0, TEST_LOCATION);
1336 DALI_TEST_EQUALS(screenOrientation, 0, TEST_LOCATION);
1338 application.SendNotification();
1339 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
1340 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
1342 clippingRect = Rect<int>(CLIPPING_RECT_X, CLIPPING_RECT_Y, CLIPPING_RECT_WIDTH, CLIPPING_RECT_HEIGHT); // in screen coordinates, includes 3 last frames updates
1343 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
1344 application.RenderWithPartialUpdate(damagedRects, clippingRect);
1346 // It is recalculation for glScissor.
1347 // Because surface is rotated and glScissor is called with recalcurated value.
1348 clippingRect.x = TestApplication::DEFAULT_SURFACE_WIDTH - (CLIPPING_RECT_X + CLIPPING_RECT_WIDTH);
1349 clippingRect.y = TestApplication::DEFAULT_SURFACE_HEIGHT - (CLIPPING_RECT_Y + CLIPPING_RECT_HEIGHT);
1350 clippingRect.width = CLIPPING_RECT_WIDTH;
1351 clippingRect.height = CLIPPING_RECT_HEIGHT;
1353 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
1354 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
1355 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
1356 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
1358 // Check current orientations
1359 orientation = application.GetScene().GetCurrentSurfaceOrientation();
1360 screenOrientation = application.GetScene().GetCurrentScreenOrientation();
1362 // It should be changed.
1363 DALI_TEST_EQUALS(orientation, 180, TEST_LOCATION);
1364 DALI_TEST_EQUALS(screenOrientation, 180, TEST_LOCATION);
1369 int UtcDaliSceneSurfaceRotatedWithAngle270(void)
1371 tet_infoline("Ensure rotation of the surface is handled properly with Angle 270");
1373 TestApplication application(
1374 TestApplication::DEFAULT_SURFACE_WIDTH,
1375 TestApplication::DEFAULT_SURFACE_HEIGHT,
1376 TestApplication::DEFAULT_HORIZONTAL_DPI,
1377 TestApplication::DEFAULT_VERTICAL_DPI,
1381 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
1383 std::vector<Rect<int>> damagedRects;
1384 Rect<int> clippingRect;
1385 application.SendNotification();
1386 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
1388 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
1390 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
1391 application.RenderWithPartialUpdate(damagedRects, clippingRect);
1393 Actor actor = CreateRenderableActor();
1394 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1395 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
1396 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
1397 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1398 application.GetScene().Add(actor);
1400 application.SendNotification();
1402 damagedRects.clear();
1403 application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
1404 TestApplication::DEFAULT_SURFACE_HEIGHT,
1407 // Check current surface orientation
1408 int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
1409 int32_t screenOrientation = application.GetScene().GetCurrentScreenOrientation();
1411 // It should not be changed yet.
1412 DALI_TEST_EQUALS(orientation, 0, TEST_LOCATION);
1413 DALI_TEST_EQUALS(screenOrientation, 0, TEST_LOCATION);
1415 application.SendNotification();
1416 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
1417 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
1419 clippingRect = Rect<int>(CLIPPING_RECT_X, CLIPPING_RECT_Y, CLIPPING_RECT_WIDTH, CLIPPING_RECT_HEIGHT); // in screen coordinates, includes 3 last frames updates
1420 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
1421 application.RenderWithPartialUpdate(damagedRects, clippingRect);
1423 // It is recalculation for glScissor.
1424 // Because surface is rotated and glScissor is called with recalcurated value.
1425 clippingRect.x = CLIPPING_RECT_Y;
1426 clippingRect.y = TestApplication::DEFAULT_SURFACE_WIDTH - (CLIPPING_RECT_X + CLIPPING_RECT_WIDTH);
1427 clippingRect.width = CLIPPING_RECT_HEIGHT;
1428 clippingRect.height = CLIPPING_RECT_WIDTH;
1430 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
1431 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
1432 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
1433 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
1435 // Check current orientations
1436 orientation = application.GetScene().GetCurrentSurfaceOrientation();
1437 screenOrientation = application.GetScene().GetCurrentScreenOrientation();
1439 // It should be changed.
1440 DALI_TEST_EQUALS(orientation, 270, TEST_LOCATION);
1441 DALI_TEST_EQUALS(screenOrientation, 270, TEST_LOCATION);
1446 int UtcDaliSceneSetRotationCompletedAcknowledgementWithAngle90(void)
1448 tet_infoline("Ensure to acknowledge for completing surface 90 angle rotaiton");
1450 TestApplication application(
1451 TestApplication::DEFAULT_SURFACE_WIDTH,
1452 TestApplication::DEFAULT_SURFACE_HEIGHT,
1453 TestApplication::DEFAULT_HORIZONTAL_DPI,
1454 TestApplication::DEFAULT_VERTICAL_DPI,
1458 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
1460 std::vector<Rect<int>> damagedRects;
1461 Rect<int> clippingRect;
1462 application.SendNotification();
1463 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
1465 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
1466 application.RenderWithPartialUpdate(damagedRects, clippingRect);
1468 Actor actor = CreateRenderableActor();
1469 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1470 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
1471 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
1472 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1473 application.GetScene().Add(actor);
1475 application.SendNotification();
1477 damagedRects.clear();
1478 application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
1479 TestApplication::DEFAULT_SURFACE_HEIGHT,
1482 // Check current surface orientation
1483 int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
1484 int32_t screenOrientation = application.GetScene().GetCurrentScreenOrientation();
1486 // It should not be changed yet.
1487 DALI_TEST_EQUALS(orientation, 0, TEST_LOCATION);
1488 DALI_TEST_EQUALS(screenOrientation, 0, TEST_LOCATION);
1490 application.GetScene().SetRotationCompletedAcknowledgement();
1492 application.SendNotification();
1493 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
1494 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
1496 clippingRect = Rect<int>(CLIPPING_RECT_X, CLIPPING_RECT_Y, CLIPPING_RECT_WIDTH, CLIPPING_RECT_HEIGHT); // in screen coordinates, includes 3 last frames updates
1497 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
1498 application.RenderWithPartialUpdate(damagedRects, clippingRect);
1500 // It is recalculation for glScissor.
1501 // Because surface is rotated and glScissor is called with recalcurated value.
1502 clippingRect.x = TestApplication::DEFAULT_SURFACE_HEIGHT - (CLIPPING_RECT_Y + CLIPPING_RECT_HEIGHT);
1503 clippingRect.y = CLIPPING_RECT_X;
1504 clippingRect.width = CLIPPING_RECT_HEIGHT;
1505 clippingRect.height = CLIPPING_RECT_WIDTH;
1507 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
1508 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
1509 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
1510 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
1512 // Check current orientations
1513 orientation = application.GetScene().GetCurrentSurfaceOrientation();
1514 screenOrientation = application.GetScene().GetCurrentScreenOrientation();
1516 // It should be changed.
1517 DALI_TEST_EQUALS(orientation, 90, TEST_LOCATION);
1518 DALI_TEST_EQUALS(screenOrientation, 90, TEST_LOCATION);
1520 bool isSetRotationCompletedAcknowledgementSet = application.GetScene().IsRotationCompletedAcknowledgementSet();
1521 DALI_TEST_EQUALS(isSetRotationCompletedAcknowledgementSet, true, TEST_LOCATION);
1526 int UtcDaliSceneSurfaceRotatedPartialUpdate(void)
1528 tet_infoline("Ensure rotation of the surface and partial update are handled properly");
1530 TestApplication application(
1531 TestApplication::DEFAULT_SURFACE_WIDTH,
1532 TestApplication::DEFAULT_SURFACE_HEIGHT,
1533 TestApplication::DEFAULT_HORIZONTAL_DPI,
1534 TestApplication::DEFAULT_VERTICAL_DPI,
1538 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
1540 std::vector<Rect<int>> damagedRects;
1541 Rect<int> clippingRect;
1542 application.SendNotification();
1543 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
1545 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
1547 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
1548 application.RenderWithPartialUpdate(damagedRects, clippingRect);
1550 Actor actor = CreateRenderableActor();
1551 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1552 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1553 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
1554 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1555 application.GetScene().Add(actor);
1557 application.SendNotification();
1558 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
1560 clippingRect = Rect<int>(224, 384, 48, 48); // in screen coordinates
1561 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
1562 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
1564 application.RenderWithPartialUpdate(damagedRects, clippingRect);
1566 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
1567 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
1568 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
1569 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
1571 damagedRects.clear();
1572 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
1573 application.RenderWithPartialUpdate(damagedRects, clippingRect);
1575 damagedRects.clear();
1576 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
1577 application.RenderWithPartialUpdate(damagedRects, clippingRect);
1579 // Ensure the damaged rect is empty
1580 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
1583 application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_HEIGHT,
1584 TestApplication::DEFAULT_SURFACE_WIDTH,
1587 damagedRects.clear();
1589 application.SendNotification();
1590 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
1592 clippingRect = Rect<int>(224, 224, 208, 208); // in screen coordinates, merged value with the previous rect
1593 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
1594 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
1596 application.RenderWithPartialUpdate(damagedRects, clippingRect);
1601 int UtcDaliSceneKeyEventGeneratedSignalP(void)
1603 TestApplication application;
1604 Dali::Integration::Scene scene = application.GetScene();
1606 KeyEventGeneratedSignalData data;
1607 KeyEventGeneratedReceivedFunctor functor(data);
1608 scene.KeyEventGeneratedSignal().Connect(&application, functor);
1610 Integration::KeyEvent event("a", "", "a", 0, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE);
1611 application.ProcessEvent(event);
1613 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1614 DALI_TEST_CHECK(event.keyModifier == data.receivedKeyEvent.GetKeyModifier());
1615 DALI_TEST_CHECK(event.keyName == data.receivedKeyEvent.GetKeyName());
1616 DALI_TEST_CHECK(event.keyString == data.receivedKeyEvent.GetKeyString());
1617 DALI_TEST_CHECK(event.state == static_cast<Integration::KeyEvent::State>(data.receivedKeyEvent.GetState()));
1621 Integration::KeyEvent event2("i", "", "i", 0, 0, 0, Integration::KeyEvent::UP, "i", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE);
1622 application.ProcessEvent(event2);
1624 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1625 DALI_TEST_CHECK(event2.keyModifier == data.receivedKeyEvent.GetKeyModifier());
1626 DALI_TEST_CHECK(event2.keyName == data.receivedKeyEvent.GetKeyName());
1627 DALI_TEST_CHECK(event2.keyString == data.receivedKeyEvent.GetKeyString());
1628 DALI_TEST_CHECK(event2.state == static_cast<Integration::KeyEvent::State>(data.receivedKeyEvent.GetState()));
1632 Integration::KeyEvent event3("a", "", "a", 0, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE);
1633 application.ProcessEvent(event3);
1635 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1636 DALI_TEST_CHECK(event3.keyModifier == data.receivedKeyEvent.GetKeyModifier());
1637 DALI_TEST_CHECK(event3.keyName == data.receivedKeyEvent.GetKeyName());
1638 DALI_TEST_CHECK(event3.keyString == data.receivedKeyEvent.GetKeyString());
1639 DALI_TEST_CHECK(event3.state == static_cast<Integration::KeyEvent::State>(data.receivedKeyEvent.GetState()));
1643 Integration::KeyEvent event4("a", "", "a", 0, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE);
1644 application.ProcessEvent(event4);
1646 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1647 DALI_TEST_CHECK(event4.keyModifier == data.receivedKeyEvent.GetKeyModifier());
1648 DALI_TEST_CHECK(event4.keyName == data.receivedKeyEvent.GetKeyName());
1649 DALI_TEST_CHECK(event4.keyString == data.receivedKeyEvent.GetKeyString());
1650 DALI_TEST_CHECK(event4.state == static_cast<Integration::KeyEvent::State>(data.receivedKeyEvent.GetState()));
1654 int UtcDaliSceneEnsureReplacedSurfaceKeepsClearColor(void)
1656 tet_infoline("Ensure we keep background color when the scene surface is replaced ");
1658 TestApplication application;
1660 // Create a new scene and set the background color of the main scene
1661 auto defaultScene = application.GetScene();
1662 defaultScene.SetBackgroundColor(Color::BLUE);
1664 // Need to create a renderable as we don't start rendering until we have at least one
1665 // We don't need to add this to any scene
1666 auto actor = CreateRenderableActor();
1668 auto& glAbstraction = application.GetGlAbstraction();
1669 auto clearCountBefore = glAbstraction.GetClearCountCalled();
1671 application.SendNotification();
1672 application.Render();
1674 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
1675 DALI_TEST_EQUALS(glAbstraction.GetLastClearColor(), Color::BLUE, TEST_LOCATION);
1677 defaultScene.SurfaceReplaced();
1679 application.SendNotification();
1680 application.Render();
1682 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 2, TEST_LOCATION);
1683 DALI_TEST_EQUALS(glAbstraction.GetLastClearColor(), Color::BLUE, TEST_LOCATION);
1685 // Check when the main render task viewport is set the clear color is clipped using scissors
1686 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
1687 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
1688 scissorTrace.Enable(true);
1689 enabledDisableTrace.Enable(true);
1691 defaultScene.GetRenderTaskList().GetTask(0).SetViewport(Viewport(0.0f, 0.0f, 100.0f, 100.0f));
1693 application.SendNotification();
1694 application.Render();
1696 // Check scissor test was enabled.
1697 std::ostringstream scissor;
1698 scissor << std::hex << GL_SCISSOR_TEST;
1699 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
1701 // Check the scissor was set, and the coordinates are correct.
1702 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", "0, 700, 100, 100"));
1704 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 3, TEST_LOCATION);
1705 DALI_TEST_EQUALS(glAbstraction.GetLastClearColor(), Color::BLUE, TEST_LOCATION);
1707 scissorTrace.Enable(false);
1708 scissorTrace.Reset();
1710 enabledDisableTrace.Enable(false);
1711 enabledDisableTrace.Reset();
1716 int UtcDaliSceneEnsureRenderTargetRecreated(void)
1718 tet_infoline("Ensure render target is re-created when surface replaced ");
1720 TestApplication application;
1722 // Create a new scene and set the background color of the main scene
1723 auto defaultScene = application.GetScene();
1724 defaultScene.SetBackgroundColor(Color::BLUE);
1726 auto actor = CreateRenderableActor();
1727 defaultScene.Add(actor);
1729 auto& graphicsController = application.GetGraphicsController();
1731 application.SendNotification();
1732 application.Render();
1734 TraceCallStack& graphicsCallStack = graphicsController.mCallStack;
1735 TraceCallStack::NamedParams empty{};
1736 const TraceCallStack::NamedParams* matching = graphicsCallStack.FindLastMatch("PresentRenderTarget", empty);
1737 DALI_TEST_CHECK(matching != nullptr);
1739 graphicsCallStack.Reset();
1742 Graphics::RenderTargetCreateInfo createInfo{};
1743 createInfo.SetSurface(&fakeSurface1).SetExtent(Graphics::Extent2D{480u, 800u});
1744 defaultScene.SetSurfaceRenderTarget(createInfo);
1746 application.SendNotification();
1747 application.Render();
1749 TraceCallStack::NamedParams query1;
1750 query1["surface"] << std::hex << &fakeSurface1;
1751 const TraceCallStack::NamedParams* matching2 = graphicsCallStack.FindLastMatch("CreateRenderTarget", query1);
1752 DALI_TEST_CHECK(matching2 != nullptr);
1754 const TraceCallStack::NamedParams* matching3 = graphicsCallStack.FindLastMatch("PresentRenderTarget", empty);
1755 DALI_TEST_CHECK(matching3 != nullptr);
1756 DALI_TEST_EQUALS((*matching3)["surface"].str(), query1["surface"].str(), TEST_LOCATION);
1761 int UtcDaliSceneEmptySceneRendering(void)
1763 tet_infoline("Ensure not rendering before a Renderer is added");
1765 TestApplication application;
1766 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
1768 // Render without any renderer
1769 application.SendNotification();
1770 application.Render();
1772 // Check the clear count and the render status
1773 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), 0, TEST_LOCATION);
1774 DALI_TEST_EQUALS(application.GetRenderNeedsPostRender(), false, TEST_LOCATION);
1777 Geometry geometry = CreateQuadGeometry();
1778 Shader shader = CreateShader();
1779 Renderer renderer = Renderer::New(geometry, shader);
1781 // Render before adding renderer
1782 application.SendNotification();
1783 application.Render();
1785 // Check the clear count and the render status
1786 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), 0, TEST_LOCATION);
1787 DALI_TEST_EQUALS(application.GetRenderNeedsPostRender(), false, TEST_LOCATION);
1789 Actor actor = Actor::New();
1790 actor.AddRenderer(renderer);
1792 actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400));
1793 application.GetScene().Add(actor);
1796 application.SendNotification();
1797 application.Render();
1799 // Check the clear count and the render status
1800 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), 1, TEST_LOCATION);
1801 DALI_TEST_EQUALS(application.GetRenderNeedsPostRender(), true, TEST_LOCATION);
1803 // Remove the Renderer
1804 application.GetScene().Remove(actor);
1809 application.SendNotification();
1810 application.Render();
1812 // Check the clear count and the render status
1813 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), 2, TEST_LOCATION); // Should be cleared
1814 DALI_TEST_EQUALS(application.GetRenderNeedsPostRender(), true, TEST_LOCATION);
1819 int UtcDaliSceneFrameRenderedPresentedCallback(void)
1821 tet_infoline("UtcDaliSceneFrameRenderedCallback");
1823 TestApplication application;
1826 Geometry geometry = CreateQuadGeometry();
1827 Shader shader = CreateShader();
1828 Renderer renderer = Renderer::New(geometry, shader);
1830 Actor actor = Actor::New();
1831 actor.AddRenderer(renderer);
1832 application.GetScene().Add(actor);
1834 Dali::Integration::Scene scene = application.GetScene();
1837 scene.AddFrameRenderedCallback(std::unique_ptr<CallbackBase>(MakeCallback(&FrameCallback)), frameId);
1838 scene.AddFramePresentedCallback(std::unique_ptr<CallbackBase>(MakeCallback(&FrameCallback)), frameId);
1841 application.SendNotification();
1842 application.Render();
1844 Dali::Integration::Scene::FrameCallbackContainer callbackContainer;
1845 scene.GetFrameRenderedCallback(callbackContainer);
1847 DALI_TEST_EQUALS(callbackContainer.size(), 1, TEST_LOCATION);
1848 DALI_TEST_EQUALS(callbackContainer[0].second, frameId, TEST_LOCATION);
1850 callbackContainer.clear();
1852 scene.GetFramePresentedCallback(callbackContainer);
1854 DALI_TEST_EQUALS(callbackContainer.size(), 1, TEST_LOCATION);
1855 DALI_TEST_EQUALS(callbackContainer[0].second, frameId, TEST_LOCATION);
1860 int UtcDaliSceneWheelEventGeneratedSignalP(void)
1862 TestApplication application;
1863 Dali::Integration::Scene scene = application.GetScene();
1865 WheelEventGeneratedSignalData data;
1866 WheelEventGeneratedReceivedFunctor functor(data);
1867 scene.WheelEventGeneratedSignal().Connect(&application, functor);
1869 Integration::WheelEvent event(Integration::WheelEvent::CUSTOM_WHEEL, 0, 0u, Vector2(0.0f, 0.0f), 1, 1000u);
1870 application.ProcessEvent(event);
1872 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1873 DALI_TEST_CHECK(static_cast<WheelEvent::Type>(event.type) == data.receivedWheelEvent.GetType());
1874 DALI_TEST_CHECK(event.direction == data.receivedWheelEvent.GetDirection());
1875 DALI_TEST_CHECK(event.modifiers == data.receivedWheelEvent.GetModifiers());
1876 DALI_TEST_CHECK(event.point == data.receivedWheelEvent.GetPoint());
1877 DALI_TEST_CHECK(event.delta == data.receivedWheelEvent.GetDelta());
1878 DALI_TEST_CHECK(event.timeStamp == data.receivedWheelEvent.GetTime());
1882 Integration::WheelEvent event2(Integration::WheelEvent::CUSTOM_WHEEL, 0, 0u, Vector2(0.0f, 0.0f), -1, 1000u);
1883 application.ProcessEvent(event2);
1885 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1886 DALI_TEST_CHECK(static_cast<WheelEvent::Type>(event2.type) == data.receivedWheelEvent.GetType());
1887 DALI_TEST_CHECK(event2.direction == data.receivedWheelEvent.GetDirection());
1888 DALI_TEST_CHECK(event2.modifiers == data.receivedWheelEvent.GetModifiers());
1889 DALI_TEST_CHECK(event2.point == data.receivedWheelEvent.GetPoint());
1890 DALI_TEST_CHECK(event2.delta == data.receivedWheelEvent.GetDelta());
1891 DALI_TEST_CHECK(event2.timeStamp == data.receivedWheelEvent.GetTime());
1895 int UtcDaliSceneSignalInterceptKeyEventP(void)
1897 TestApplication application;
1898 Dali::Integration::Scene scene = application.GetScene();
1900 KeyEventSignalData data;
1901 KeyEventReceivedFunctor functor(data);
1902 scene.KeyEventSignal().Connect(&application, functor);
1904 KeyEventGeneratedSignalData interceptData;
1905 KeyEventGeneratedReceivedFunctor interceptFunctor(interceptData);
1906 scene.InterceptKeyEventSignal().Connect(&application, interceptFunctor);
1908 Integration::KeyEvent event("i", "", "i", 0, 0, 0, Integration::KeyEvent::DOWN, "i", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE);
1909 application.ProcessEvent(event);
1911 DALI_TEST_EQUALS(true, interceptData.functorCalled, TEST_LOCATION);
1912 DALI_TEST_CHECK(event.keyModifier == interceptData.receivedKeyEvent.GetKeyModifier());
1913 DALI_TEST_CHECK(event.keyName == interceptData.receivedKeyEvent.GetKeyName());
1914 DALI_TEST_CHECK(event.keyString == interceptData.receivedKeyEvent.GetKeyString());
1915 DALI_TEST_CHECK(event.state == static_cast<Integration::KeyEvent::State>(interceptData.receivedKeyEvent.GetState()));
1916 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1919 interceptData.Reset();
1921 Integration::KeyEvent event2("i", "", "i", 0, 0, 0, Integration::KeyEvent::UP, "i", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE);
1922 application.ProcessEvent(event2);
1924 DALI_TEST_EQUALS(true, interceptData.functorCalled, TEST_LOCATION);
1925 DALI_TEST_CHECK(event2.keyModifier == interceptData.receivedKeyEvent.GetKeyModifier());
1926 DALI_TEST_CHECK(event2.keyName == interceptData.receivedKeyEvent.GetKeyName());
1927 DALI_TEST_CHECK(event2.keyString == interceptData.receivedKeyEvent.GetKeyString());
1928 DALI_TEST_CHECK(event2.state == static_cast<Integration::KeyEvent::State>(interceptData.receivedKeyEvent.GetState()));
1929 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1932 interceptData.Reset();
1934 Integration::KeyEvent event3("a", "", "a", 0, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE);
1935 application.ProcessEvent(event3);
1937 DALI_TEST_EQUALS(true, interceptData.functorCalled, TEST_LOCATION);
1938 DALI_TEST_CHECK(event3.keyModifier == interceptData.receivedKeyEvent.GetKeyModifier());
1939 DALI_TEST_CHECK(event3.keyName == interceptData.receivedKeyEvent.GetKeyName());
1940 DALI_TEST_CHECK(event3.keyString == interceptData.receivedKeyEvent.GetKeyString());
1941 DALI_TEST_CHECK(event3.state == static_cast<Integration::KeyEvent::State>(interceptData.receivedKeyEvent.GetState()));
1942 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1945 interceptData.Reset();
1947 Integration::KeyEvent event4("a", "", "a", 0, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE);
1948 application.ProcessEvent(event4);
1950 DALI_TEST_EQUALS(true, interceptData.functorCalled, TEST_LOCATION);
1951 DALI_TEST_CHECK(event4.keyModifier == interceptData.receivedKeyEvent.GetKeyModifier());
1952 DALI_TEST_CHECK(event4.keyName == interceptData.receivedKeyEvent.GetKeyName());
1953 DALI_TEST_CHECK(event4.keyString == interceptData.receivedKeyEvent.GetKeyString());
1954 DALI_TEST_CHECK(event4.state == static_cast<Integration::KeyEvent::State>(interceptData.receivedKeyEvent.GetState()));
1955 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1959 int UtcDaliSceneSignalInterceptKeyEventN(void)
1961 TestApplication application;
1962 Dali::Integration::Scene scene = application.GetScene();
1964 KeyEventGeneratedSignalData data;
1965 KeyEventGeneratedReceivedFunctor functor(data);
1966 scene.InterceptKeyEventSignal().Connect(&application, functor);
1968 // Check that a non-pressed key events data is not modified.
1969 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);