#include <dali/integration-api/events/touch-event-integ.h>
#include <dali/integration-api/render-task-list-integ.h>
#include <dali-test-suite-utils.h>
-#include <test-touch-utils.h>
+#include <test-touch-event-utils.h>
using namespace Dali;
functorCalled = false;
voidFunctorCalled = false;
- receivedGesture.numberOfTaps = 0u;
- receivedGesture.numberOfTouches = 0u;
- receivedGesture.screenPoint = Vector2(0.0f, 0.0f);
- receivedGesture.localPoint = Vector2(0.0f, 0.0f);
+ receivedGesture.Reset();
tappedActor.Reset();
}
unsigned int points = touch.GetPointCount();
if( points > 0)
{
- const TouchPoint& touchPoint = touch.GetPoint(0);
- tet_printf("Touch Point state = %d\n", touchPoint.state);
+ tet_printf("Touch Point state = %d\n", touch.GetState(0));
}
return false;
}
application.SendNotification();
application.Render();
- // For line coverage, Initialise default constructor
- TouchEvent touchEvent2;
END_TEST;
}
// Do a tap inside actor's area
TestGenerateTap( application, 50.0f, 50.0f, 100 );
DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
- DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
- DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
- DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION);
+ DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTaps(), TEST_LOCATION);
+ DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION);
+ DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.GetLocalPoint(), 0.1, TEST_LOCATION);
END_TEST;
}
// Start tap within the actor's area
TestGenerateTap( application, 20.0f, 20.0f, 100 );
DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
- DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
- DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
- DALI_TEST_EQUALS( Vector2(20.0f, 20.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION);
+ DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTaps(), TEST_LOCATION);
+ DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION);
+ DALI_TEST_EQUALS( Vector2(20.0f, 20.0f), data.receivedGesture.GetLocalPoint(), 0.1, TEST_LOCATION);
// repeat the tap within the actor's area - we should still receive the signal
data.Reset();
TestGenerateTap( application, 50.0f, 50.0f, 700 );
DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
- DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
- DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
- DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION);
+ DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTaps(), TEST_LOCATION);
+ DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION);
+ DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.GetLocalPoint(), 0.1, TEST_LOCATION);
// Detach actor
detector.DetachAll();
// Do tap, only check finished value
TestGenerateTap( application, 5.0f, 5.0f, 100 );
DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
- DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
- DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
- DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.screenPoint, 0.1, TEST_LOCATION);
+ DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTaps(), TEST_LOCATION);
+ DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION);
+ DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.GetScreenPoint(), 0.1, TEST_LOCATION);
// Rotate actor again and render
actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(180.0f), Vector3::ZAXIS) );
data.Reset();
TestGenerateTap( application, 5.0f, 5.0f, 700 );
DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
- DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
- DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
- DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.screenPoint, 0.1, TEST_LOCATION);
+ DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTaps(), TEST_LOCATION);
+ DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION);
+ DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.GetScreenPoint(), 0.1, TEST_LOCATION);
// Rotate actor again and render
actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(90.0f), Vector3::YAXIS) );
TestGenerateTap( application, 50.0f, 50.0f, 100 );
DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
DALI_TEST_EQUALS(true, parent == data.tappedActor, TEST_LOCATION);
- DALI_TEST_EQUALS(Vector2(50.0f, 50.0f), data.receivedGesture.screenPoint, 0.01f, TEST_LOCATION);
+ DALI_TEST_EQUALS(Vector2(50.0f, 50.0f), data.receivedGesture.GetScreenPoint(), 0.01f, TEST_LOCATION);
// Attach child and generate same touch points
// (Also proves that you can detach and then re-attach another actor)
TestGenerateTap( application, 51.0f, 51.0f, 700 );
DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
DALI_TEST_EQUALS(true, child == data.tappedActor, TEST_LOCATION);
- DALI_TEST_EQUALS(Vector2(51.0f, 51.0f), data.receivedGesture.screenPoint, 0.01f, TEST_LOCATION);
+ DALI_TEST_EQUALS(Vector2(51.0f, 51.0f), data.receivedGesture.GetScreenPoint(), 0.01f, TEST_LOCATION);
END_TEST;
}
END_TEST;
}
+
+int UtcDaliTapGestureInterruptedWhenTouchConsumed(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);
+
+ TapGestureDetector detector = TapGestureDetector::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
+ TestGenerateTap( 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;
+ TestGenerateTap( application, 50.0f, 50.0f );
+ DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
+ data.Reset();
+
+ END_TEST;
+}
+
+int UtcDaliTapGestureDisableDetectionDuringTapN(void)
+{
+ // Crash sometimes occurred when gesture-recognizer was deleted internally during a signal when the attached actor was detached
+
+ 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);
+
+ // Add a detector
+ TapGestureDetector detector = TapGestureDetector::New();
+ bool functorCalled = false;
+ detector.Attach( actor );
+ detector.DetectedSignal().Connect(
+ &application,
+ [&detector, &functorCalled](Actor actor, const TapGesture& gesture)
+ {
+ detector.Detach(actor);
+ functorCalled = true;
+ });
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Try the gesture, should not crash
+ try
+ {
+ TestGenerateTap( application, 50.0f, 10.0f );
+
+ DALI_TEST_CHECK( true ); // No crash, test has passed
+ DALI_TEST_EQUALS(functorCalled, true, TEST_LOCATION);
+ }
+ catch(...)
+ {
+ DALI_TEST_CHECK( false ); // If we crash, the test has failed
+ }
+
+ END_TEST;
+}
+