#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/integration-api/events/wheel-event-integ.h>
using namespace Dali;
using namespace Toolkit;
static bool gOnScrollUpdateCalled; ///< Whether the OnScrollUpdate signal was invoked.
static bool gOnScrollCompleteCalled; ///< Whether the OnScrollComplete signal was invoked.
static bool gOnSnapStartCalled; ///< Whether the OnSnapStart signal was invoked.
+static bool gOnWheelEventCalled; ///< Whether the WheelEventSignal signal was invoked.
static SnapType gLastSnapType; ///< Snaping information from SnapEvent.
static Vector3 gConstraintResult; ///< Result from constraint.
}
/**
+ * Invoked after a wheel-event is received
+ *
+ * @param[in] actor The owing actor
+ * @param[in] event The wheel event
+ * @return True if the event should be consumed
+ */
+static bool OnWheelEvent( Actor actor, const Dali::WheelEvent& wheelEvent )
+{
+ gOnWheelEventCalled = true;
+ return false;
+}
+
+/**
* TestSumConstraint
*
* Summation of current value, property, and offset.
END_TEST;
}
+int UtcDaliScrollViewMoveConstructor(void)
+{
+ ToolkitTestApplication application;
+
+ ScrollView scrollView = ScrollView::New();
+ DALI_TEST_EQUALS( 1, scrollView.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+ scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f) );
+ DALI_TEST_EQUALS( scrollView.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ), Vector2(10.0f, 10.0f), TEST_LOCATION );
+
+ ScrollView moved = std::move( scrollView );
+ DALI_TEST_CHECK( moved );
+ DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+ DALI_TEST_EQUALS( moved.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ), Vector2(10.0f, 10.0f), TEST_LOCATION );
+ DALI_TEST_CHECK( !scrollView );
+
+ END_TEST;
+}
+
int UtcDaliToolkitScrollViewAssignmentOperatorP(void)
{
ToolkitTestApplication application;
ScrollView scrollView = ScrollView::New();
scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f) );
- ScrollView copy = scrollView;
+ ScrollView copy;
+ copy = scrollView;
DALI_TEST_CHECK( copy );
DALI_TEST_CHECK( copy.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) == scrollView.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) );
END_TEST;
}
+int UtcDaliScrollViewMoveAssignment(void)
+{
+ ToolkitTestApplication application;
+
+ ScrollView scrollView = ScrollView::New();
+ DALI_TEST_EQUALS( 1, scrollView.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+ scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f) );
+ DALI_TEST_EQUALS( scrollView.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ), Vector2(10.0f, 10.0f), TEST_LOCATION );
+
+ ScrollView moved;
+ moved = std::move( scrollView );
+ DALI_TEST_CHECK( moved );
+ DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+ DALI_TEST_EQUALS( moved.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ), Vector2(10.0f, 10.0f), TEST_LOCATION );
+ DALI_TEST_CHECK( !scrollView );
+
+ END_TEST;
+}
+
int UtcDaliScrollViewDestructorP(void)
{
ToolkitTestApplication application;
DALI_TEST_CHECK( scrollView2 == scrollView );
//Additional check to ensure object is created by checking if it's registered
- ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
+ ObjectRegistry registry = application.GetCore().GetObjectRegistry();
DALI_TEST_CHECK( registry );
gObjectCreatedCallBackCalled = false;
Wait(application, RENDER_DELAY_SCROLL);
DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
- scrollView.ScrollTo( target2, 0.25f, Dali::Toolkit::DirectionBiasLeft, Dali::Toolkit::DirectionBiasLeft );
+ scrollView.ScrollTo( target2, 0.25f, Dali::Toolkit::DIRECTION_BIAS_LEFT, Dali::Toolkit::DIRECTION_BIAS_LEFT );
Wait(application, RENDER_DELAY_SCROLL);
DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
Wait(application, RENDER_DELAY_SCROLL);
DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
- scrollView.ScrollTo( target2, 0.25f, Dali::Toolkit::DirectionBiasRight, Dali::Toolkit::DirectionBiasRight );
+ scrollView.ScrollTo( target2, 0.25f, Dali::Toolkit::DIRECTION_BIAS_RIGHT, Dali::Toolkit::DIRECTION_BIAS_RIGHT );
Wait(application, RENDER_DELAY_SCROLL);
DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
Wait(application, RENDER_DELAY_SCROLL);
DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
- scrollView.ScrollTo( target2, 0.25f, AlphaFunction::LINEAR, Dali::Toolkit::DirectionBiasLeft, Dali::Toolkit::DirectionBiasLeft );
+ scrollView.ScrollTo( target2, 0.25f, AlphaFunction::LINEAR, Dali::Toolkit::DIRECTION_BIAS_LEFT, Dali::Toolkit::DIRECTION_BIAS_LEFT );
Wait(application, RENDER_DELAY_SCROLL);
DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
Wait(application, RENDER_DELAY_SCROLL);
DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
- scrollView.ScrollTo( target2, 0.25f, AlphaFunction::LINEAR, Dali::Toolkit::DirectionBiasRight, Dali::Toolkit::DirectionBiasRight );
+ scrollView.ScrollTo( target2, 0.25f, AlphaFunction::LINEAR, Dali::Toolkit::DIRECTION_BIAS_RIGHT, Dali::Toolkit::DIRECTION_BIAS_RIGHT );
Wait(application, RENDER_DELAY_SCROLL);
DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
Wait(application, RENDER_DELAY_SCROLL);
DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
- scrollView.ScrollTo( target2, 0.25f, TestAlphaFunction, Dali::Toolkit::DirectionBiasRight, Dali::Toolkit::DirectionBiasRight );
+ scrollView.ScrollTo( target2, 0.25f, TestAlphaFunction, Dali::Toolkit::DIRECTION_BIAS_RIGHT, Dali::Toolkit::DIRECTION_BIAS_RIGHT );
Wait(application, 125);
// Check that the scroll animation should finish within just half of the specified duration with the above alpha function
DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
// Confirm the final X coord has snapped to exactly one page ahead of the start page.
DALI_TEST_EQUALS( viewPageSize.width, scrollView.GetCurrentScrollPosition().x, Math::MACHINE_EPSILON_0, TEST_LOCATION );
+ // Change scroll mode during pan, should not crash
+ PerformGestureSwipe( application, startPos, direction, frames - 1, time, false );
+ try
+ {
+ scrollView.SetScrollSensitive(false);
+ DALI_TEST_CHECK(true);
+ }
+ catch(...)
+ {
+ DALI_TEST_CHECK(false);
+ }
+
END_TEST;
}
scrollView.SetWrapMode(true);
- scrollView.ScrollTo( 0, 0.25, Dali::Toolkit::DirectionBiasLeft );
+ scrollView.ScrollTo( 0, 0.25, Dali::Toolkit::DIRECTION_BIAS_LEFT );
Wait(application, RENDER_FRAME_INTERVAL); // Wait for one frame
// Check that the scroll position remains the same
DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
- scrollView.ScrollTo( 0, 0.25, Dali::Toolkit::DirectionBiasRight );
+ scrollView.ScrollTo( 0, 0.25, Dali::Toolkit::DIRECTION_BIAS_RIGHT );
Wait(application, RENDER_FRAME_INTERVAL); // Wait for one frame
// Check that it scrolls towards the right
Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
- constraint.SetRemoveAction(Constraint::Discard);
+ constraint.SetRemoveAction(Constraint::DISCARD);
scrollView.ApplyConstraintToChildren(constraint);
Wait(application);
// apply this constraint to scrollview
Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
- constraint.SetRemoveAction(Constraint::Discard);
+ constraint.SetRemoveAction(Constraint::DISCARD);
scrollView.ApplyConstraintToChildren(constraint);
Wait(application);
PerformGestureSwipe(application, CLAMP_TOUCH_START, Vector2(0.5f, 0.0f), 60, time, true);
DALI_TEST_CHECK( gOnSnapStartCalled );
- DALI_TEST_CHECK( gLastSnapType == Toolkit::Snap );
+ DALI_TEST_CHECK( gLastSnapType == Toolkit::SNAP );
// Second try a swipe.
PerformGestureSwipe(application, CLAMP_TOUCH_START, Vector2(20.0f, 0.0f), 60, time, true);
DALI_TEST_CHECK( gOnSnapStartCalled );
- DALI_TEST_CHECK( gLastSnapType == Toolkit::Flick );
+ DALI_TEST_CHECK( gLastSnapType == Toolkit::FLICK );
END_TEST;
}
ClampState clamped;
float value = domainX.Clamp(50.0f, 100.0f, 1.0f, clamped);
DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION);
- DALI_TEST_EQUALS( clamped, Dali::Toolkit::NotClamped, TEST_LOCATION);
+ DALI_TEST_EQUALS( clamped, Dali::Toolkit::NOT_CLAMPED, TEST_LOCATION);
value = domainX.Clamp(-100.0f, 200.0f, 1.0f, clamped);
DALI_TEST_EQUALS( value, 0.0f, TEST_LOCATION);
- DALI_TEST_EQUALS( clamped, Dali::Toolkit::ClampedToMin, TEST_LOCATION);
+ DALI_TEST_EQUALS( clamped, Dali::Toolkit::CLAMPED_TO_MIN, TEST_LOCATION);
value = domainX.Clamp(300.0f, 20.0f, 1.0f, clamped);
DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION);
- DALI_TEST_EQUALS( clamped, Dali::Toolkit::ClampedToMax, TEST_LOCATION);
+ DALI_TEST_EQUALS( clamped, Dali::Toolkit::CLAMPED_TO_MAX, TEST_LOCATION);
END_TEST;
}
RulerPtr defaultRuler = new DefaultRuler();
DALI_TEST_CHECK( defaultRuler );
- DALI_TEST_EQUALS( defaultRuler->GetType(), Dali::Toolkit::Ruler::Free, TEST_LOCATION);
+ DALI_TEST_EQUALS( defaultRuler->GetType(), Dali::Toolkit::Ruler::FREE, TEST_LOCATION);
RulerPtr fixedRuler = new FixedRuler( 100.0f );
DALI_TEST_CHECK( fixedRuler );
- DALI_TEST_EQUALS( fixedRuler->GetType(), Dali::Toolkit::Ruler::Fixed, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->GetType(), Dali::Toolkit::Ruler::FIXED, TEST_LOCATION);
END_TEST;
}
// clamp state testing.
ClampState clamped;
DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
- DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
+ DALI_TEST_EQUALS( clamped, NOT_CLAMPED, TEST_LOCATION );
DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
- DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
+ DALI_TEST_EQUALS( clamped, NOT_CLAMPED, TEST_LOCATION );
DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
- DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
+ DALI_TEST_EQUALS( clamped, NOT_CLAMPED, TEST_LOCATION );
DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
- DALI_TEST_EQUALS( clamped, ClampedToMin, TEST_LOCATION );
+ DALI_TEST_EQUALS( clamped, CLAMPED_TO_MIN, TEST_LOCATION );
DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
- DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
+ DALI_TEST_EQUALS( clamped, NOT_CLAMPED, TEST_LOCATION );
DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
- DALI_TEST_EQUALS( clamped, ClampedToMax, TEST_LOCATION );
+ DALI_TEST_EQUALS( clamped, CLAMPED_TO_MAX, TEST_LOCATION );
END_TEST;
}
Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, MoveActorConstraint );
constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
- constraint.SetRemoveAction(Constraint::Discard);
+ constraint.SetRemoveAction(Constraint::DISCARD);
scrollView.ApplyConstraintToChildren(constraint);
scrollView.ScrollTo( target, 0.0f );
constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
constraint.AddSource( Source( scrollView, Toolkit::ScrollView::Property::WRAP ) );
- constraint.SetRemoveAction(Constraint::Discard);
+ constraint.SetRemoveAction(Constraint::DISCARD);
scrollView.ApplyConstraintToChildren(constraint);
scrollView.ScrollTo( target, 0.0f );
END_TEST;
}
+
+int UtcDaliToolkitScrollViewWheelEvent(void)
+{
+ ToolkitTestApplication application;
+
+ // Set up a scrollView.
+ ScrollView scrollView = ScrollView::New();
+
+ // Do not rely on stage size for UTC tests.
+ Vector2 viewPageSize( 720.0f, 1280.0f );
+ scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
+ scrollView.SetProperty( Actor::Property::SIZE, viewPageSize );
+ scrollView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+ scrollView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
+ scrollView.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
+
+ // Position rulers.
+ // We set the X ruler to fixed to give us pages to snap to.
+ Dali::Toolkit::FixedRuler* rulerX = new Dali::Toolkit::FixedRuler( viewPageSize.width );
+ // Note: The 3x page width is arbitary, but we need enough to show that we are
+ // capping page movement by the page limiter, and not the domain.
+ rulerX->SetDomain( Dali::Toolkit::RulerDomain( 0.0f, viewPageSize.width * 3.0f, false ) );
+ Dali::Toolkit::RulerPtr rulerY = new Dali::Toolkit::DefaultRuler();
+ rulerY->Disable();
+ scrollView.SetRulerX( rulerX );
+ scrollView.SetRulerY( rulerY );
+
+ scrollView.SetWrapMode( false );
+
+ application.GetScene().Add( scrollView );
+
+ //Connect to wheel event signal
+ scrollView.WheelEventSignal().Connect( &OnWheelEvent );
+
+ DALI_TEST_CHECK( !gOnWheelEventCalled );
+
+ // Render and notify
+ application.Render();
+ application.SendNotification();
+ application.Render();
+ application.SendNotification();
+
+ // Perform a wheel event
+ Dali::Integration::WheelEvent wheelEvent( Dali::Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, Vector2( 10.0f, 10.0f ), 1, 1000u );
+ application.ProcessEvent( wheelEvent );
+ DALI_TEST_CHECK( gOnWheelEventCalled );
+
+ // Set X ruler to free
+ Dali::Toolkit::DefaultRuler* defaultRuler = new Dali::Toolkit::DefaultRuler();
+ scrollView.SetRulerX( defaultRuler );
+
+ // Perform a wheel event
+ gOnWheelEventCalled = false;
+ application.ProcessEvent( wheelEvent );
+ DALI_TEST_CHECK( gOnWheelEventCalled );
+
+ // Enable Y ruler
+ rulerY->Enable();
+
+ // Perform a wheel event
+ gOnWheelEventCalled = false;
+ application.ProcessEvent( wheelEvent );
+ DALI_TEST_CHECK( gOnWheelEventCalled );
+
+ // Wait until it finishes scrolling
+ Wait(application, RENDER_DELAY_SCROLL);
+
+ // Set Y ruler to fixed
+ Dali::Toolkit::FixedRuler* fixedRulerY = new Dali::Toolkit::FixedRuler( viewPageSize.height );
+ scrollView.SetRulerY( fixedRulerY );
+
+ // Perform a wheel event
+ gOnWheelEventCalled = false;
+ application.ProcessEvent( wheelEvent );
+ DALI_TEST_CHECK( gOnWheelEventCalled );
+
+ END_TEST;
+}