#include <iostream>
#include <stdlib.h>
-#include <dali/dali.h>
+#include <cmath>
+#include <dali/public-api/dali-core.h>
#include <dali/integration-api/events/touch-event-integ.h>
#include <dali/integration-api/events/pan-gesture-event.h>
#include <dali/integration-api/system-overlay.h>
+#include <dali/integration-api/profiling.h>
+#include <dali/integration-api/input-options.h>
#include <dali-test-suite-utils.h>
+#include <test-touch-utils.h>
using namespace Dali;
///////////////////////////////////////////////////////////////////////////////
namespace
{
-typedef Dali::PanGestureDetector::AngleContainer::size_type AngleSizeType;
+const int PAN_EVENT_TIME_DELTA = 8;
+const int PAN_GESTURE_UPDATE_COUNT = 50;
-
-// Stores data that is populated in the callback and will be read by the TET cases
+// Stores data that is populated in the callback and will be read by the test cases
struct SignalData
{
SignalData()
receivedGesture.screenPosition = Vector2(0.0f, 0.0f);
receivedGesture.numberOfTouches = 0;
- pannedActor = NULL;
+ pannedActor.Reset();
}
bool functorCalled;
{
GestureReceivedFunctor(SignalData& data) : signalData(data) { }
- void operator()(Actor actor, PanGesture pan)
+ void operator()(Actor actor, const PanGesture& pan)
{
signalData.functorCalled = true;
signalData.receivedGesture = pan;
{
}
- void operator()( Actor actor, PanGesture pan )
+ void operator()( Actor actor, const PanGesture& pan )
{
GestureReceivedFunctor::operator()( actor, pan );
Vector2 screenPosition;
Vector2 screenDisplacement;
+ Vector2 screenVelocity;
Vector2 localPosition;
Vector2 localDisplacement;
+ Vector2 localVelocity;
bool called;
void Reset()
{
- screenPosition = screenDisplacement = localPosition = localDisplacement = Vector2::ZERO;
+ screenPosition = screenDisplacement = screenVelocity = localPosition = localDisplacement = localVelocity = Vector2::ZERO;
called = false;
}
};
{
PanConstraint( ConstraintData& data ) : constraintData(data) { }
- Vector3 operator()(const Vector3& current,
- const PropertyInput& screenPositionProperty,
- const PropertyInput& screenDisplacementProperty,
- const PropertyInput& localPositionProperty,
- const PropertyInput& localDisplacementProperty)
+ void operator()( Vector3& current, const PropertyInputContainer& inputs )
{
- constraintData.screenPosition = screenPositionProperty.GetVector2();
- constraintData.screenDisplacement = screenDisplacementProperty.GetVector2();
- constraintData.localPosition = localPositionProperty.GetVector2();
- constraintData.localDisplacement = localDisplacementProperty.GetVector2();
+ constraintData.screenPosition = inputs[0]->GetVector2();
+ constraintData.screenDisplacement = inputs[1]->GetVector2();
+ constraintData.screenVelocity = inputs[2]->GetVector2();
+ constraintData.localPosition = inputs[3]->GetVector2();
+ constraintData.localDisplacement = inputs[4]->GetVector2();
+ constraintData.localVelocity = inputs[5]->GetVector2();
constraintData.called = true;
- return Vector3::ZERO;
+ current = Vector3::ZERO;
}
ConstraintData& constraintData;
Vector2 localPosition,
Vector2 screenDisplacement = Vector2::ONE,
Vector2 localDisplacement = Vector2::ONE,
- Vector2 velocity = Vector2::ONE,
+ Vector2 screenVelocity = Vector2::ONE,
+ Vector2 localVelocity = Vector2::ONE,
unsigned int numberOfTouches = 1 )
{
PanGesture pan( state );
pan.screenDisplacement = screenDisplacement;
pan.displacement = localDisplacement;
- pan.screenVelocity = pan.velocity = velocity;
+ pan.screenVelocity = screenVelocity;
+ pan.velocity = localVelocity;
+
pan.numberOfTouches = numberOfTouches;
return pan;
}
+/**
+ * Helper to generate PanGestureEvent
+ *
+ * @param[in] application Application instance
+ * @param[in] state The Gesture State
+ * @param[in] pos The current position of touch.
+ */
+static void SendPan(TestApplication& application, Gesture::State state, const Vector2& pos)
+{
+ static Vector2 last;
+ static int LastTime = 0;
+
+ if( (state == Gesture::Started) ||
+ (state == Gesture::Possible) )
+ {
+ last.x = pos.x;
+ last.y = pos.y;
+ }
+
+ application.ProcessEvent(GeneratePan(state, last, pos, PAN_EVENT_TIME_DELTA));
+
+ last.x = pos.x;
+ last.y = pos.y;
+ LastTime += PAN_EVENT_TIME_DELTA;
+}
+
+static Vector2 PerformSwipeGestureSwipe(TestApplication& application, Vector2 start, Vector2 direction, int frames, bool finish = true)
+{
+ // Now do a pan starting from (start) and heading (direction)
+ Vector2 pos(start);
+ SendPan(application, Gesture::Possible, pos);
+ SendPan(application, Gesture::Started, pos);
+ application.SendNotification();
+ application.Render();
+
+ for(int i = 0;i<frames;i++)
+ {
+ pos += direction; // Move in this direction
+ SendPan(application, Gesture::Continuing, pos);
+ application.SendNotification();
+ application.Render();
+ }
+
+ if(finish)
+ {
+ SendPan(application, Gesture::Finished, pos);
+ application.SendNotification();
+ application.Render();
+ }
+
+ return pos;
+}
+
} // anon namespace
///////////////////////////////////////////////////////////////////////////////
END_TEST;
}
+int UtcDaliPanGestureDetectorCopyConstructorP(void)
+{
+ TestApplication application;
+
+ PanGestureDetector detector = PanGestureDetector::New();;
+
+ PanGestureDetector copy( detector );
+ DALI_TEST_CHECK( detector );
+ END_TEST;
+}
+
+int UtcDaliPanGestureDetectorAssignmentOperatorP(void)
+{
+ TestApplication application;
+
+ PanGestureDetector detector = PanGestureDetector::New();;
+
+ PanGestureDetector assign;
+ assign = detector;
+ DALI_TEST_CHECK( detector );
+
+ DALI_TEST_CHECK( detector == assign );
+ END_TEST;
+}
// Negative test case for a method
int UtcDaliPanGestureDetectorNew(void)
Actor actor = Actor::New();
actor.SetSize(100.0f, 100.0f);
- actor.SetRotation(Dali::Degree(90.0f), Vector3::ZAXIS);
+ actor.SetOrientation(Dali::Degree(90.0f), Vector3::ZAXIS);
Stage::GetCurrent().Add(actor);
// Render and notify
DALI_TEST_EQUALS(Vector2(8.0f, -5.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); // Actor relative
// Rotate actor again and render a couple of times
- actor.SetRotation(Dali::Degree(180.0f), Vector3::ZAXIS);
+ actor.SetOrientation(Dali::Degree(180.0f), Vector3::ZAXIS);
application.SendNotification();
application.Render();
DALI_TEST_EQUALS(Vector2(-5.0f, -8.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); // Actor relative
// Rotate actor again and render a couple of times
- actor.SetRotation(Dali::Degree(270.0f), Vector3::ZAXIS);
+ actor.SetOrientation(Dali::Degree(270.0f), Vector3::ZAXIS);
application.SendNotification();
application.Render();
child.SetSize(100.0f, 100.0f);
child.SetAnchorPoint(AnchorPoint::CENTER);
child.SetParentOrigin(ParentOrigin::CENTER);
- child.SetRotation(Dali::Degree(90.0f), Vector3::ZAXIS);
+ child.SetOrientation(Dali::Degree(90.0f), Vector3::ZAXIS);
parent.Add(child);
TouchEventFunctor touchFunctor;
application.Render();
// Delete actor as well
- actor = NULL;
+ actor.Reset();
// Render and notify
application.SendNotification();
// Start pan within the actor's area
application.ProcessEvent( GeneratePan( Gesture::Possible, screenCoordsStart, screenCoordsEnd, 10 ) );
application.ProcessEvent( GeneratePan( Gesture::Started, screenCoordsStart, screenCoordsEnd, 10 ) );
+ DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliPanGestureBehindTouchableSystemOverlay(void)
+{
+ TestApplication application;
+ Dali::Integration::Core& core = application.GetCore();
+ Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
+ systemOverlay.GetOverlayRenderTasks().CreateTask();
+
+ // SystemOverlay actor
+ Actor systemOverlayActor = Actor::New();
+ systemOverlayActor.SetSize(100.0f, 100.0f);
+ systemOverlayActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ systemOverlay.Add(systemOverlayActor);
+
+ // Stage actor
+ Actor stageActor = Actor::New();
+ stageActor.SetSize(100.0f, 100.0f);
+ stageActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ Stage::GetCurrent().Add(stageActor);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Set system-overlay actor to touchable
+ TouchEventData touchData;
+ TouchEventDataFunctor touchFunctor( touchData );
+ systemOverlayActor.TouchedSignal().Connect(&application, touchFunctor);
+
+ // Set stage actor to receive the gesture
+ SignalData data;
+ GestureReceivedFunctor functor(data);
+
+ PanGestureDetector detector = PanGestureDetector::New();
+ detector.Attach(stageActor);
+ detector.DetectedSignal().Connect(&application, functor);
+
+ Vector2 screenCoordsStart( 10.0f, 20.0f );
+ Vector2 screenCoordsEnd( 20.0f, 20.0f );
+
+ // Start pan within the two actors' area
+ application.ProcessEvent( GeneratePan( Gesture::Possible, screenCoordsStart, screenCoordsEnd, 10 ) );
+ application.ProcessEvent( GeneratePan( Gesture::Started, screenCoordsStart, screenCoordsEnd, 10 ) );
+ application.ProcessEvent( GeneratePan( Gesture::Finished, screenCoordsStart, screenCoordsEnd, 10 ) );
+ DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
+ DALI_TEST_EQUALS( false, touchData.functorCalled, TEST_LOCATION );
+
+ data.Reset();
+ touchData.Reset();
+
+ // Do touch in the same area
+ application.ProcessEvent( touchFunctor.GenerateSingleTouch( TouchPoint::Down, screenCoordsStart ) );
+ DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
+ DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliPanGestureTouchBehindGesturedSystemOverlay(void)
+{
+ TestApplication application;
+ Dali::Integration::Core& core = application.GetCore();
+ Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
+ systemOverlay.GetOverlayRenderTasks().CreateTask();
+
+ // SystemOverlay actor
+ Actor systemOverlayActor = Actor::New();
+ systemOverlayActor.SetSize(100.0f, 100.0f);
+ systemOverlayActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ systemOverlay.Add(systemOverlayActor);
+
+ // Stage actor
+ Actor stageActor = Actor::New();
+ stageActor.SetSize(100.0f, 100.0f);
+ stageActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ Stage::GetCurrent().Add(stageActor);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Set stage actor to touchable
+ TouchEventData touchData;
+ TouchEventDataFunctor touchFunctor( touchData );
+ stageActor.TouchedSignal().Connect(&application, touchFunctor);
+
+ // Set system-overlay actor to have the gesture
+ SignalData data;
+ GestureReceivedFunctor functor(data);
+
+ PanGestureDetector detector = PanGestureDetector::New();
+ detector.Attach(systemOverlayActor);
+ detector.DetectedSignal().Connect(&application, functor);
+
+ Vector2 screenCoordsStart( 10.0f, 20.0f );
+ Vector2 screenCoordsEnd( 20.0f, 20.0f );
+
+ // Start pan within the two actors' area
+ application.ProcessEvent( GeneratePan( Gesture::Possible, screenCoordsStart, screenCoordsEnd, 10 ) );
+ application.ProcessEvent( GeneratePan( Gesture::Started, screenCoordsStart, screenCoordsEnd, 10 ) );
+ application.ProcessEvent( GeneratePan( Gesture::Finished, screenCoordsStart, screenCoordsEnd, 10 ) );
+ DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
+ DALI_TEST_EQUALS( false, touchData.functorCalled, TEST_LOCATION );
+
+ data.Reset();
+ touchData.Reset();
+
+ // Do touch in the same area
+ application.ProcessEvent( touchFunctor.GenerateSingleTouch( TouchPoint::Down, screenCoordsStart ) );
DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
+ DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );
+
END_TEST;
}
TestApplication application;
PanGestureDetector detector = PanGestureDetector::New();
- const PanGestureDetector::AngleContainer& angles( detector.GetAngles() );
- DALI_TEST_EQUALS( angles.empty(), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( detector.GetAngleCount(), 0u, TEST_LOCATION );
detector.AddAngle( PanGestureDetector::DIRECTION_LEFT, Radian( Math::PI * 0.25 ) );
- DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(1), TEST_LOCATION );
- for ( PanGestureDetector::AngleContainer::const_iterator iter = angles.begin(), endIter = angles.end(); iter != endIter; ++iter )
+ DALI_TEST_EQUALS( detector.GetAngleCount(), 1u, TEST_LOCATION );
+ bool found = false;
+ for( size_t i = 0; i < detector.GetAngleCount(); i++)
{
- if ( iter->first == PanGestureDetector::DIRECTION_LEFT )
+ if( detector.GetAngle(i).first == PanGestureDetector::DIRECTION_LEFT )
{
tet_result( TET_PASS );
+ found = true;
break;
}
+ }
- if ( iter == endIter )
- {
- tet_printf("%s, angle not added\n", TEST_LOCATION );
- tet_result( TET_FAIL );
- }
+ if(!found )
+ {
+ tet_printf("%s, angle not added\n", TEST_LOCATION );
+ tet_result( TET_FAIL );
}
detector.AddAngle( PanGestureDetector::DIRECTION_RIGHT, Radian( Math::PI * 0.25 ) );
- DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(2), TEST_LOCATION );
+ DALI_TEST_EQUALS( detector.GetAngleCount(), 2u, TEST_LOCATION );
// Remove something not in the container.
detector.RemoveAngle( PanGestureDetector::DIRECTION_UP );
- DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(2), TEST_LOCATION );
+ DALI_TEST_EQUALS( detector.GetAngleCount(), 2u, TEST_LOCATION );
detector.RemoveAngle( PanGestureDetector::DIRECTION_RIGHT );
- DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(1), TEST_LOCATION );
- for ( PanGestureDetector::AngleContainer::const_iterator iter = angles.begin(), endIter = angles.end(); iter != endIter; ++iter )
+ DALI_TEST_EQUALS( detector.GetAngleCount(), 1u, TEST_LOCATION );
+ for ( size_t i = 0; i < detector.GetAngleCount(); i++)
{
- if ( iter->first == PanGestureDetector::DIRECTION_RIGHT )
+ if ( detector.GetAngle(i).first == PanGestureDetector::DIRECTION_RIGHT )
{
tet_printf("%s, angle not removed\n", TEST_LOCATION );
tet_result( TET_FAIL );
}
detector.ClearAngles();
- DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(0), TEST_LOCATION );
+ DALI_TEST_EQUALS( detector.GetAngleCount(), 0u, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliPanGestureGetAngle(void)
+{
+ TestApplication application;
+
+ PanGestureDetector detector = PanGestureDetector::New();
+ DALI_TEST_EQUALS( detector.GetAngleCount(), 0, TEST_LOCATION );
+
+ detector.AddAngle( PanGestureDetector::DIRECTION_LEFT );
+ DALI_TEST_EQUALS( detector.GetAngleCount(), 1, TEST_LOCATION );
+
+ detector.AddAngle( PanGestureDetector::DIRECTION_RIGHT );
+ DALI_TEST_EQUALS( detector.GetAngleCount(), 2, TEST_LOCATION );
+
+ detector.AddAngle( PanGestureDetector::DIRECTION_UP );
+ DALI_TEST_EQUALS( detector.GetAngleCount(), 3, TEST_LOCATION );
+
+ detector.AddAngle( PanGestureDetector::DIRECTION_DOWN );
+ DALI_TEST_EQUALS( detector.GetAngleCount(), 4, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( detector.GetAngle(0).first, PanGestureDetector::DIRECTION_LEFT, TEST_LOCATION );
+ DALI_TEST_EQUALS( detector.GetAngle(1).first, PanGestureDetector::DIRECTION_RIGHT, TEST_LOCATION );
+ DALI_TEST_EQUALS( detector.GetAngle(2).first, PanGestureDetector::DIRECTION_UP, TEST_LOCATION );
+ DALI_TEST_EQUALS( detector.GetAngle(3).first, PanGestureDetector::DIRECTION_DOWN, TEST_LOCATION );
+
END_TEST;
}
TestApplication application;
PanGestureDetector detector = PanGestureDetector::New();
- const PanGestureDetector::AngleContainer& angles( detector.GetAngles() );
- DALI_TEST_EQUALS( angles.empty(), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( detector.GetAngleCount(), 0u, TEST_LOCATION );
//
// Angle
//
detector.AddAngle( Degree(180.0f) );
- DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(-180.0f) ), 0.000001, TEST_LOCATION );
+ DALI_TEST_EQUALS( detector.GetAngle(0).first, Radian( Degree(-180.0f) ), 0.000001, TEST_LOCATION );
detector.ClearAngles();
detector.AddAngle( Degree(190.0f) );
- DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(-170.0f) ), 0.000001, TEST_LOCATION );
+ DALI_TEST_EQUALS( detector.GetAngle(0).first, Radian( Degree(-170.0f) ), 0.000001, TEST_LOCATION );
detector.ClearAngles();
detector.AddAngle( Degree(-190.0f) );
- DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(170.0f) ), 0.000001, TEST_LOCATION );
+ DALI_TEST_EQUALS( detector.GetAngle(0).first, Radian( Degree(170.0f) ), 0.000001, TEST_LOCATION );
detector.ClearAngles();
detector.AddAngle( Degree(350.0f) );
- DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(-10.0f) ), 0.000001, TEST_LOCATION );
+ DALI_TEST_EQUALS( detector.GetAngle(0).first, Radian( Degree(-10.0f) ), 0.000001, TEST_LOCATION );
detector.ClearAngles();
detector.AddAngle( Degree(-350.0f) );
- DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(10.0f) ), 0.000001, TEST_LOCATION );
+ DALI_TEST_EQUALS( detector.GetAngle(0).first, Radian( Degree(10.0f) ), 0.000001, TEST_LOCATION );
detector.ClearAngles();
detector.AddAngle( Degree(370.0f) );
- DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(10.0f) ), 0.000001, TEST_LOCATION );
+ DALI_TEST_EQUALS( detector.GetAngle(0).first, Radian( Degree(10.0f) ), 0.000001, TEST_LOCATION );
detector.ClearAngles();
detector.AddAngle( Degree(-370.0f) );
- DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(-10.0f) ), 0.000001, TEST_LOCATION );
+ DALI_TEST_EQUALS( detector.GetAngle(0).first, Radian( Degree(-10.0f) ), 0.000001, TEST_LOCATION );
detector.ClearAngles();
//
//
detector.AddAngle( PanGestureDetector::DIRECTION_RIGHT, Degree( 0.0f ) );
- DALI_TEST_EQUALS( angles.begin()->second, Radian( Degree(0.0f) ), 0.000001, TEST_LOCATION );
+ DALI_TEST_EQUALS( detector.GetAngle(0).second, Radian( Degree(0.0f) ), 0.000001, TEST_LOCATION );
detector.ClearAngles();
detector.AddAngle( PanGestureDetector::DIRECTION_RIGHT, Degree( -10.0f ) );
- DALI_TEST_EQUALS( angles.begin()->second, Radian( Degree(10.0f) ), 0.000001, TEST_LOCATION );
+ DALI_TEST_EQUALS( detector.GetAngle(0).second, Radian( Degree(10.0f) ), 0.000001, TEST_LOCATION );
detector.ClearAngles();
detector.AddAngle( PanGestureDetector::DIRECTION_RIGHT, Degree( -181.0f ) );
- DALI_TEST_EQUALS( angles.begin()->second, Radian( Degree(180.0f) ), 0.000001, TEST_LOCATION );
+ DALI_TEST_EQUALS( detector.GetAngle(0).second, Radian( Degree(180.0f) ), 0.000001, TEST_LOCATION );
detector.ClearAngles();
detector.AddAngle( PanGestureDetector::DIRECTION_RIGHT, Degree( 181.0f ) );
- DALI_TEST_EQUALS( angles.begin()->second, Radian( Degree(180.0f) ), 0.000001, TEST_LOCATION );
+ DALI_TEST_EQUALS( detector.GetAngle(0).second, Radian( Degree(180.0f) ), 0.000001, TEST_LOCATION );
detector.ClearAngles();
END_TEST;
}
TestApplication application;
PanGestureDetector detector = PanGestureDetector::New();
- const PanGestureDetector::AngleContainer& angles( detector.GetAngles() );
- DALI_TEST_EQUALS( angles.empty(), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( detector.GetAngleCount(), 0u, TEST_LOCATION );
detector.AddDirection( PanGestureDetector::DIRECTION_LEFT, Radian( Math::PI * 0.25 ) );
- DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(2), TEST_LOCATION );
- for ( PanGestureDetector::AngleContainer::const_iterator iter = angles.begin(), endIter = angles.end(); iter != endIter; ++iter )
+ DALI_TEST_EQUALS( detector.GetAngleCount(), 2u, TEST_LOCATION );
+ bool found = false;
+ for ( size_t i = 0; detector.GetAngleCount(); i++)
{
- if ( iter->first == PanGestureDetector::DIRECTION_LEFT )
+ if ( detector.GetAngle(i).first == PanGestureDetector::DIRECTION_LEFT )
{
tet_result( TET_PASS );
+ found = true;
break;
}
- if ( iter == endIter )
- {
- tet_printf("%s, angle not added\n", TEST_LOCATION );
- tet_result( TET_FAIL );
- }
}
- for ( PanGestureDetector::AngleContainer::const_iterator iter = angles.begin(), endIter = angles.end(); iter != endIter; ++iter )
+ if (!found )
+ {
+ tet_printf("%s, angle not added\n", TEST_LOCATION );
+ tet_result( TET_FAIL );
+ }
+
+ found = false;
+ for( size_t i = 0; i < detector.GetAngleCount(); i++)
{
- if ( iter->first == PanGestureDetector::DIRECTION_RIGHT )
+ if( detector.GetAngle(i).first == PanGestureDetector::DIRECTION_RIGHT )
{
tet_result( TET_PASS );
+ found = true;
break;
}
+ }
- if ( iter == endIter )
- {
- tet_printf("%s, angle not added\n", TEST_LOCATION );
- tet_result( TET_FAIL );
- }
+ if(!found )
+ {
+ tet_printf("%s, angle not added\n", TEST_LOCATION );
+ tet_result( TET_FAIL );
}
// Remove something not in the container.
detector.RemoveDirection( PanGestureDetector::DIRECTION_UP );
- DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(2), TEST_LOCATION );
+ DALI_TEST_EQUALS( detector.GetAngleCount(), 2u, TEST_LOCATION );
detector.RemoveDirection( PanGestureDetector::DIRECTION_RIGHT );
- DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(0), TEST_LOCATION );
+ DALI_TEST_EQUALS( detector.GetAngleCount(), 0u, TEST_LOCATION );
END_TEST;
}
END_TEST;
}
+int UtcDaliPanGestureNoPredictionNoSmoothing(void)
+{
+ TestApplication application;
+ Integration::SetPanGesturePredictionMode(0);
+ Integration::SetPanGestureSmoothingMode(0);
+
+ Actor actor = Actor::New();
+ actor.SetSize(100.0f, 100.0f);
+ actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ Stage::GetCurrent().Add(actor);
+
+ // Add a pan detector
+ PanGestureDetector detector = PanGestureDetector::New();
+ detector.Attach( actor );
+ SignalData data;
+ GestureReceivedFunctor functor( data );
+ detector.DetectedSignal().Connect( &application, functor );
+
+ Property::Index property = actor.RegisterProperty( "Dummy Property", Vector3::ZERO );
+
+ ConstraintData constraintData;
+ Constraint constraint = Constraint::New<Vector3>( actor, property, PanConstraint( constraintData ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::SCREEN_POSITION ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::SCREEN_DISPLACEMENT ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::SCREEN_VELOCITY ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_POSITION ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_VELOCITY ) );
+ constraint.Apply();
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ Vector2 direction(Vector2::XAXIS * -5.0f);
+ Vector2 startPosition( 1.0f, 1.0f );
+ PerformSwipeGestureSwipe(application, startPosition, direction, PAN_GESTURE_UPDATE_COUNT, true);
+ DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
+ DALI_TEST_EQUALS( constraintData.called, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( constraintData.screenPosition, startPosition + (direction * PAN_GESTURE_UPDATE_COUNT), 0.1f, TEST_LOCATION );
+ DALI_TEST_EQUALS( constraintData.localPosition, startPosition + (direction * PAN_GESTURE_UPDATE_COUNT), 0.1f, TEST_LOCATION );
+
+ constraintData.Reset();
+ END_TEST;
+}
+
+int UtcDaliPanGestureNoPredictionSmoothing(void)
+{
+ TestApplication application;
+ Integration::SetPanGesturePredictionMode(0);
+ Integration::SetPanGestureSmoothingMode(1);
+
+ Actor actor = Actor::New();
+ actor.SetSize(100.0f, 100.0f);
+ actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ Stage::GetCurrent().Add(actor);
+
+ // Add a pan detector
+ PanGestureDetector detector = PanGestureDetector::New();
+ detector.Attach( actor );
+ SignalData data;
+ GestureReceivedFunctor functor( data );
+ detector.DetectedSignal().Connect( &application, functor );
+
+ Property::Index property = actor.RegisterProperty( "Dummy Property", Vector3::ZERO );
+
+ ConstraintData constraintData;
+ Constraint constraint = Constraint::New<Vector3>( actor, property, PanConstraint( constraintData ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::SCREEN_POSITION ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::SCREEN_DISPLACEMENT ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::SCREEN_VELOCITY ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_POSITION ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_VELOCITY ) );
+ constraint.Apply();
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ Vector2 direction(Vector2::XAXIS * -5.0f);
+ Vector2 previousPosition( 20.0f, 20.0f );
+ Vector2 currentPosition( 20.0f, 10.0f );
+ PerformSwipeGestureSwipe(application, Vector2(1.0f, 1.0f), direction, PAN_GESTURE_UPDATE_COUNT, true);
+ DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
+ DALI_TEST_EQUALS( constraintData.called, true, TEST_LOCATION );
+ // Take into account resampling done when prediction is off.
+ DALI_TEST_EQUALS( constraintData.screenPosition, Vector2(1.0f, 1.0f) + (direction * (PAN_GESTURE_UPDATE_COUNT - 0.25f)), 0.15f, TEST_LOCATION );
+ DALI_TEST_EQUALS( constraintData.localPosition, Vector2(1.0f, 1.0f) + (direction * (PAN_GESTURE_UPDATE_COUNT - 0.25f)), 0.15f, TEST_LOCATION );
+
+ constraintData.Reset();
+ END_TEST;
+}
+
+int UtcDaliPanGesturePredictionNoSmoothing(void)
+{
+ TestApplication application;
+ Integration::SetPanGesturePredictionMode(1);
+ Integration::SetPanGestureSmoothingMode(0);
+
+ Actor actor = Actor::New();
+ actor.SetSize(100.0f, 100.0f);
+ actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ Stage::GetCurrent().Add(actor);
+
+ // Add a pan detector
+ PanGestureDetector detector = PanGestureDetector::New();
+ detector.Attach( actor );
+ SignalData data;
+ GestureReceivedFunctor functor( data );
+ detector.DetectedSignal().Connect( &application, functor );
+
+ Property::Index property = actor.RegisterProperty( "Dummy Property", Vector3::ZERO );
+
+ ConstraintData constraintData;
+ Constraint constraint = Constraint::New<Vector3>( actor, property, PanConstraint( constraintData ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::SCREEN_POSITION ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::SCREEN_DISPLACEMENT ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::SCREEN_VELOCITY ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_POSITION ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_VELOCITY ) );
+ constraint.Apply();
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ Vector2 direction(Vector2::XAXIS * -1.0f);
+ Vector2 previousPosition( 20.0f, 20.0f );
+ Vector2 currentPosition( 20.0f, 10.0f );
+ PerformSwipeGestureSwipe(application, Vector2(1.0f, 1.0f), direction, PAN_GESTURE_UPDATE_COUNT, true);
+ DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
+ DALI_TEST_EQUALS( constraintData.called, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( constraintData.screenPosition, Vector2(1.0f, 1.0f) + (direction * PAN_GESTURE_UPDATE_COUNT), 10.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( constraintData.localPosition, Vector2(1.0f, 1.0f) + (direction * PAN_GESTURE_UPDATE_COUNT), 10.0f, TEST_LOCATION );
+
+ constraintData.Reset();
+ END_TEST;
+}
+
+int UtcDaliPanGesturePredictionSmoothing(void)
+{
+ TestApplication application;
+ Integration::SetPanGesturePredictionMode(1);
+ Integration::SetPanGestureSmoothingMode(1);
+
+ Actor actor = Actor::New();
+ actor.SetSize(100.0f, 100.0f);
+ actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ Stage::GetCurrent().Add(actor);
+
+ // Add a pan detector
+ PanGestureDetector detector = PanGestureDetector::New();
+ detector.Attach( actor );
+ SignalData data;
+ GestureReceivedFunctor functor( data );
+ detector.DetectedSignal().Connect( &application, functor );
+
+ Property::Index property = actor.RegisterProperty( "Dummy Property", Vector3::ZERO );
+
+ ConstraintData constraintData;
+ Constraint constraint = Constraint::New<Vector3>( actor, property, PanConstraint( constraintData ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::SCREEN_POSITION ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::SCREEN_DISPLACEMENT ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::SCREEN_VELOCITY ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_POSITION ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_VELOCITY ) );
+ constraint.Apply();
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ Vector2 direction(Vector2::XAXIS * -1.0f);
+ Vector2 previousPosition( 20.0f, 20.0f );
+ Vector2 currentPosition( 20.0f, 10.0f );
+ PerformSwipeGestureSwipe(application, Vector2(1.0f, 1.0f), direction, PAN_GESTURE_UPDATE_COUNT, true);
+ DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
+ DALI_TEST_EQUALS( constraintData.called, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( constraintData.screenPosition, Vector2(1.0f, 1.0f) + (direction * PAN_GESTURE_UPDATE_COUNT), 10.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( constraintData.localPosition, Vector2(1.0f, 1.0f) + (direction * PAN_GESTURE_UPDATE_COUNT), 10.0f, TEST_LOCATION );
+
+ constraintData.Reset();
+ END_TEST;
+}
+
int UtcDaliPanGestureSetProperties(void)
{
TestApplication application;
TestRenderController& renderController( application.GetRenderController() );
+ Integration::SetPanGesturePredictionMode(0);
+ Integration::SetPanGestureSmoothingMode(0);
Actor actor = Actor::New();
actor.SetSize(100.0f, 100.0f);
Property::Index property = actor.RegisterProperty( "Dummy Property", Vector3::ZERO );
ConstraintData constraintData;
- actor.ApplyConstraint( Constraint::New<Vector3>( property, Source( detector, PanGestureDetector::SCREEN_POSITION ),
- Source( detector, PanGestureDetector::SCREEN_DISPLACEMENT ),
- Source( detector, PanGestureDetector::LOCAL_POSITION ),
- Source( detector, PanGestureDetector::LOCAL_DISPLACEMENT ),
- PanConstraint( constraintData ) ) );
+ Constraint constraint = Constraint::New<Vector3>( actor, property, PanConstraint( constraintData ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::SCREEN_POSITION ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::SCREEN_DISPLACEMENT ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::SCREEN_VELOCITY ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_POSITION ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_VELOCITY ) );
+ constraint.Apply();
// Render and notify
application.SendNotification();
Vector2 screenPosition( 20.0f, 20.0f );
Vector2 screenDisplacement( 1.0f, 1.0f );
+ Vector2 screenVelocity( 1.3f, 4.0f );
Vector2 localPosition( 21.0f, 21.0f );
Vector2 localDisplacement( 0.5f, 0.5f );
+ Vector2 localVelocity( 1.5f, 2.5f );
- PanGestureDetector::SetPanGestureProperties( GeneratePan( 1u, Gesture::Started, screenPosition, localPosition, screenDisplacement, localDisplacement ) );
+ PanGestureDetector::SetPanGestureProperties( GeneratePan( 1u, Gesture::Started, screenPosition, localPosition, screenDisplacement, localDisplacement, screenVelocity, localVelocity ) );
DALI_TEST_EQUALS( renderController.WasCalled( TestRenderController::RequestUpdateFunc ), true, TEST_LOCATION );
// Render and notify
DALI_TEST_EQUALS( constraintData.localPosition, localPosition, TEST_LOCATION );
DALI_TEST_EQUALS( constraintData.screenDisplacement, screenDisplacement, TEST_LOCATION );
DALI_TEST_EQUALS( constraintData.localDisplacement, localDisplacement, TEST_LOCATION );
+ DALI_TEST_EQUALS( constraintData.screenVelocity, screenVelocity, TEST_LOCATION );
+ DALI_TEST_EQUALS( constraintData.localVelocity, localVelocity, TEST_LOCATION );
constraintData.Reset();
END_TEST;
}
int UtcDaliPanGestureSetPropertiesAlreadyPanning(void)
{
TestApplication application;
+ Integration::SetPanGesturePredictionMode(0);
Actor actor = Actor::New();
actor.SetSize(100.0f, 100.0f);
Property::Index property = actor.RegisterProperty( "Dummy Property", Vector3::ZERO );
ConstraintData constraintData;
- actor.ApplyConstraint( Constraint::New<Vector3>( property, Source( detector, PanGestureDetector::SCREEN_POSITION ),
- Source( detector, PanGestureDetector::SCREEN_DISPLACEMENT ),
- Source( detector, PanGestureDetector::LOCAL_POSITION ),
- Source( detector, PanGestureDetector::LOCAL_DISPLACEMENT ),
- PanConstraint( constraintData ) ) );
+ Constraint constraint = Constraint::New<Vector3>( actor, property, PanConstraint( constraintData ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::SCREEN_POSITION ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::SCREEN_DISPLACEMENT ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::SCREEN_VELOCITY ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_POSITION ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT ) );
+ constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_VELOCITY ) );
+ constraint.Apply();
// Render and notify
application.SendNotification();
Property::IndexContainer indices;
detector.GetPropertyIndices( indices );
- DALI_TEST_CHECK( ! indices.empty() );
- DALI_TEST_EQUALS( indices.size(), detector.GetPropertyCount(), TEST_LOCATION );
+ DALI_TEST_CHECK( indices.Size() );
+ DALI_TEST_EQUALS( indices.Size(), detector.GetPropertyCount(), TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliPanGestureLayerConsumesTouch(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ actor.SetSize(100.0f, 100.0f);
+ actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ Stage::GetCurrent().Add(actor);
+
+ // Add a pan detector
+ PanGestureDetector detector = PanGestureDetector::New();
+ detector.Attach( actor );
+ SignalData data;
+ GestureReceivedFunctor functor( data );
+ detector.DetectedSignal().Connect( &application, functor );
+
+ // Add a layer to overlap the actor
+ Layer layer = Layer::New();
+ layer.SetSize(100.0f, 100.0f);
+ layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ Stage::GetCurrent().Add( layer );
+ layer.RaiseToTop();
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Emit signals, should receive
+ application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
+ application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
+ application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
+ DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+ data.Reset();
+
+ // Set layer to consume all touch
+ layer.SetTouchConsumed( true );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Emit the same signals again, should not receive
+ application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
+ application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
+ application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
+ DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
+ data.Reset();
+
+ END_TEST;
+}
+
+int UtcDaliPanGestureNoTimeDiff(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ actor.SetSize(100.0f, 100.0f);
+ actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ Stage::GetCurrent().Add(actor);
+
+ // Add a pan detector
+ PanGestureDetector detector = PanGestureDetector::New();
+ detector.Attach( actor );
+ SignalData data;
+ GestureReceivedFunctor functor( data );
+ detector.DetectedSignal().Connect( &application, functor );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Emit signals, should receive
+ application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 0));
+ application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 0));
+ application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 0));
+ DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+ DALI_TEST_CHECK( !std::isinf( data.receivedGesture.velocity.x ) );
+ DALI_TEST_CHECK( !std::isinf( data.receivedGesture.velocity.y ) );
+ DALI_TEST_CHECK( !std::isinf( data.receivedGesture.screenVelocity.x ) );
+ DALI_TEST_CHECK( !std::isinf( data.receivedGesture.screenVelocity.y ) );
+ data.Reset();
+
+ data.Reset();
+
END_TEST;
}