/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
END_TEST;
}
+int UtcDaliGeoTouchEventNotConsumedInterrupted(void)
+{
+ TestApplication application;
+
+ application.GetScene().SetGeometryHittestEnabled(true);
+
+ Actor actor = Actor::New();
+ actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
+ actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ application.GetScene().Add(actor);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Connect to actor's touched signal
+ SignalData data;
+ TouchEventFunctor functor(data, false);
+ actor.TouchedSignal().Connect(&application, functor);
+
+ // Emit a down signal
+ application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
+ DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+ DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);
+ data.Reset();
+
+ // Emit an interrupted signal, we should be signalled regardless of whether there is a hit or not even though we didn't consume
+ // as we still were the hit-actor in the last event.
+ application.ProcessEvent(GenerateSingleTouch(PointState::INTERRUPTED, Vector2(200.0f, 200.0f /* Outside actor */)));
+ DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+ DALI_TEST_EQUALS(PointState::INTERRUPTED, data.receivedTouch.points[0].state, TEST_LOCATION);
+ data.Reset();
+
+ // Emit another interrupted signal, our signal handler should not be called.
+ application.ProcessEvent(GenerateSingleTouch(PointState::INTERRUPTED, Vector2(200.0f, 200.0f)));
+ DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
+ END_TEST;
+}
+
int UtcDaliGeoTouchEventParentConsumer(void)
{
TestApplication application;
application.GetScene().SetGeometryHittestEnabled(true);
- Actor rootActor(application.GetScene().GetRootLayer());
+ Actor rootActor(application.GetScene().GetRootLayer());
Actor actor = Actor::New();
actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
application.GetScene().SetGeometryHittestEnabled(true);
- Actor rootActor(application.GetScene().GetRootLayer());
+ Actor rootActor(application.GetScene().GetRootLayer());
Actor actor = Actor::New();
actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
application.GetScene().SetGeometryHittestEnabled(true);
- Actor rootActor(application.GetScene().GetRootLayer());
+ Actor rootActor(application.GetScene().GetRootLayer());
Actor actor = Actor::New();
actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
application.GetScene().SetGeometryHittestEnabled(true);
- Actor rootActor(application.GetScene().GetRootLayer());
+ Actor rootActor(application.GetScene().GetRootLayer());
// Connect to actor's touched signal
SignalData data;
int UtcDaliGeoTouchEventMultipleRenderTasks(void)
{
- TestApplication application;
+ TestApplication application;
application.GetScene().SetGeometryHittestEnabled(true);
-
Integration::Scene scene(application.GetScene());
Vector2 sceneSize(scene.GetSize());
int UtcDaliGeoTouchEventMultipleRenderTasksWithChildLayer(void)
{
- TestApplication application;
+ TestApplication application;
application.GetScene().SetGeometryHittestEnabled(true);
int UtcDaliGeoTouchEventOffscreenRenderTasks(void)
{
- TestApplication application;
+ TestApplication application;
application.GetScene().SetGeometryHittestEnabled(true);
int UtcDaliGeoTouchEventMultipleRenderableActors(void)
{
- TestApplication application;
+ TestApplication application;
application.GetScene().SetGeometryHittestEnabled(true);
application.GetScene().SetGeometryHittestEnabled(true);
- Actor rootActor(application.GetScene().GetRootLayer());
+ Actor rootActor(application.GetScene().GetRootLayer());
Actor parent = Actor::New();
parent.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
interceptData.Reset();
parentData.Reset();
-
END_TEST;
}
application.SendNotification();
application.Render();
- Actor rootActor(application.GetScene().GetRootLayer());
+ Actor rootActor(application.GetScene().GetRootLayer());
// Connect to root actor's intercept touched signal
SignalData sceneData;
DALI_TEST_EQUALS(true, sceneData.functorCalled, TEST_LOCATION);
sceneData.Reset();
+ END_TEST;
+}
+
+int UtcDaliGeoTouchEventIntercept04(void)
+{
+ TestApplication application;
+
+ application.GetScene().SetGeometryHittestEnabled(true);
+
+ Actor parent = Actor::New();
+ parent.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
+ parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ application.GetScene().Add(parent);
+
+ Actor actor = Actor::New();
+ actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
+ actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ parent.Add(actor);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Connect to actor's touched signal
+ SignalData data;
+ TouchEventFunctor functor(data); // consume
+ actor.TouchedSignal().Connect(&application, functor);
+
+ // Connect to parent's touched signal
+ SignalData parentData;
+ TouchEventFunctor parentFunctor(parentData); // consume
+ parent.TouchedSignal().Connect(&application, parentFunctor);
+
+ // Emit a down signal
+ application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
+ DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+ DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);
+
+ data.Reset();
+ parentData.Reset();
+
+ // Connect to parent's intercept touched signal
+ SignalData interceptData;
+ TouchEventFunctor interceptFunctor(interceptData, true /* Do intercept */);
+ Dali::DevelActor::InterceptTouchedSignal(parent).Connect(&application, interceptFunctor);
+
+ // Emit a down signal
+ application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
+
+ // The actor gets interrupted. Because touch is intercepted by parent.
+ DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+ DALI_TEST_EQUALS(PointState::INTERRUPTED, data.receivedTouch.points[0].state, TEST_LOCATION);
+ DALI_TEST_EQUALS(true, interceptData.functorCalled, TEST_LOCATION);
+ DALI_TEST_EQUALS(PointState::DOWN, interceptData.receivedTouch.points[0].state, TEST_LOCATION);
+ DALI_TEST_CHECK(actor == interceptData.receivedTouch.points[0].hitActor);
+ DALI_TEST_CHECK(parent == interceptData.touchedActor);
+ DALI_TEST_EQUALS(true, parentData.functorCalled, TEST_LOCATION);
+ DALI_TEST_EQUALS(PointState::DOWN, parentData.receivedTouch.points[0].state, TEST_LOCATION);
+ DALI_TEST_CHECK(actor == parentData.receivedTouch.points[0].hitActor);
+ DALI_TEST_CHECK(parent == parentData.touchedActor);
+ data.Reset();
+ interceptData.Reset();
+ parentData.Reset();
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Emit a move signal
+ application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 20.0f)));
+
+ // Since InterceptTouchEvent is not called because it has already been intercepted by the parent, only the parent will receive the touchEvent.
+ DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
+ DALI_TEST_EQUALS(false, interceptData.functorCalled, TEST_LOCATION);
+ DALI_TEST_EQUALS(true, parentData.functorCalled, TEST_LOCATION);
+ DALI_TEST_EQUALS(PointState::MOTION, parentData.receivedTouch.points[0].state, TEST_LOCATION);
+ DALI_TEST_CHECK(parent == parentData.receivedTouch.points[0].hitActor);
+ DALI_TEST_CHECK(parent == parentData.touchedActor);
+ data.Reset();
+ interceptData.Reset();
+ parentData.Reset();
END_TEST;
}
END_TEST;
}
+
+int UtcDaliGeoTouchDownDifferentUp(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
+ actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ application.GetScene().Add(actor);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Connect to actor's touched signal
+ SignalData data;
+ TouchEventFunctor functor(data);
+ actor.TouchedSignal().Connect(&application, functor);
+
+ // Emit a down signal
+ application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
+ DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+ DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);
+ data.Reset();
+
+ // Emit a signal outside the actor, we should NOT be signalled.
+ application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(200.0f, 200.0f /* Outside actor */)));
+ application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(210.0f, 200.0f /* Outside actor */)));
+ application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(220.0f, 200.0f /* Outside actor */)));
+ DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
+ data.Reset();
+
+ // Set the geometry hit test on
+ application.GetScene().SetGeometryHittestEnabled(true);
+
+ // ...and emit an up event outside of the actor's bounds, we should get an interrupted signal
+ application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(200.0f, 200.0f)));
+ DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+ DALI_TEST_EQUALS(PointState::INTERRUPTED, data.receivedTouch.points[0].state, TEST_LOCATION);
+ END_TEST;
+}
\ No newline at end of file