/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
*/
#include <dali-test-suite-utils.h>
+#include <dali/devel-api/actors/actor-devel.h>
#include <dali/devel-api/events/long-press-gesture-detector-devel.h>
#include <dali/integration-api/events/touch-event-integ.h>
#include <dali/integration-api/input-options.h>
TestApplication application;
LongPressGestureDetector detector = LongPressGestureDetector::New();
- ;
LongPressGestureDetector copy(detector);
DALI_TEST_CHECK(detector);
LongPressGestureDetector detector;
detector = LongPressGestureDetector::New();
- ;
LongPressGestureDetector copy;
copy = detector;
END_TEST;
}
+int UtcDaliLongPressGestureDetectorMoveConstructorP(void)
+{
+ TestApplication application;
+
+ LongPressGestureDetector detector = LongPressGestureDetector::New();
+ DALI_TEST_CHECK(detector);
+
+ LongPressGestureDetector moved = std::move(detector);
+ DALI_TEST_CHECK(moved);
+ DALI_TEST_CHECK(!detector);
+ END_TEST;
+}
+
+int UtcDaliLongPressGestureDetectorMoveAssignmentOperatorP(void)
+{
+ TestApplication application;
+
+ LongPressGestureDetector detector;
+ detector = LongPressGestureDetector::New();
+ DALI_TEST_CHECK(detector);
+
+ LongPressGestureDetector moved;
+ moved = std::move(detector);
+ DALI_TEST_CHECK(moved);
+ DALI_TEST_CHECK(!detector);
+ END_TEST;
+}
+
int UtcDaliLongPressGestureDetectorNew(void)
{
TestApplication application;
END_TEST;
}
-int UtcDaliLongPressGestureInterruptedWhenTouchConsumed(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);
-
- bool consume = false;
- TouchEventFunctorConsumeSetter touchFunctor(consume);
- actor.TouchedSignal().Connect(&application, touchFunctor);
-
- // Render and notify
- application.SendNotification();
- application.Render();
-
- SignalData data;
- GestureReceivedFunctor functor(data);
-
- LongPressGestureDetector detector = LongPressGestureDetector::New();
- detector.Attach(actor);
- detector.DetectedSignal().Connect(&application, functor);
-
- // Start gesture within the actor's area, we should receive the gesture as the touch is NOT being consumed
- TestGenerateLongPress(application, 50.0f, 50.0f);
- DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
- data.Reset();
- TestEndLongPress(application, 50.0f, 50.0f);
- DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
- data.Reset();
-
- // Another gesture in the same location, this time we will not receive it as touch is being consumed
- consume = true;
- TestGenerateLongPress(application, 50.0f, 50.0f);
- DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
- data.Reset();
- TestEndLongPress(application, 50.0f, 50.0f);
- DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
-
- END_TEST;
-}
-
int UtcDaliLongPressGestureDisableDetectionDuringLongPressN(void)
{
// Crash occurred when gesture-recognizer was deleted internally during a signal when the attached actor was detached
END_TEST;
}
+
+int UtcDaliLongPressGestureWhenGesturePropargation(void)
+{
+ TestApplication application;
+
+ Actor parentActor = Actor::New();
+ parentActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
+ parentActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+
+ Actor childActor = Actor::New();
+ childActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
+ childActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+
+ parentActor.Add(childActor);
+ application.GetScene().Add(parentActor);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ SignalData pData;
+ GestureReceivedFunctor pFunctor(pData);
+
+ LongPressGestureDetector parentDetector = LongPressGestureDetector::New();
+ parentDetector.Attach(parentActor);
+ parentDetector.DetectedSignal().Connect(&application, pFunctor);
+
+ SignalData cData;
+ GestureReceivedFunctor cFunctor(cData);
+
+ LongPressGestureDetector childDetector = LongPressGestureDetector::New();
+ childDetector.Attach(childActor);
+ childDetector.DetectedSignal().Connect(&application, cFunctor);
+
+ // Start gesture within the actor's area, we receive the gesture not parent actor but child actor.
+ TestGenerateLongPress(application, 50.0f, 50.0f);
+ TestEndLongPress(application, 50.0f, 50.0f);
+
+ DALI_TEST_EQUALS(true, cData.functorCalled, TEST_LOCATION);
+ DALI_TEST_EQUALS(false, pData.functorCalled, TEST_LOCATION);
+ cData.Reset();
+ pData.Reset();
+
+ // If GesturePropargation is set, a gesture event is to pass over to the parent.
+ Dali::DevelActor::SetNeedGesturePropagation(childActor, true);
+
+ // So now the parent got the gesture event.
+ TestGenerateLongPress(application, 50.0f, 50.0f);
+ TestEndLongPress(application, 50.0f, 50.0f);
+ DALI_TEST_EQUALS(true, cData.functorCalled, TEST_LOCATION);
+ DALI_TEST_EQUALS(true, pData.functorCalled, TEST_LOCATION);
+ cData.Reset();
+ pData.Reset();
+
+ END_TEST;
+}