X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-ScrollView.cpp;h=4e050f3ae26ef7f977847e7a4640c2d2ff0e6e70;hp=c1fee4767c7e9d9a7e313727bf76407de7219a04;hb=be93fd772a1b1b09425ac0aaec1ea1b64e9a9e60;hpb=946461ac1b49e996d9155c95130ec5aa1b08f77d diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp index c1fee47..4e050f3 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp @@ -20,6 +20,7 @@ #include #include #include +#include using namespace Dali; using namespace Toolkit; @@ -113,6 +114,7 @@ static bool gOnScrollStartCalled; ///< Whether the OnScrol 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. @@ -158,6 +160,19 @@ static void OnSnapStart( const ScrollView::SnapEvent& event ) } /** + * 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. @@ -289,6 +304,24 @@ int UtcDaliToolkitScrollViewCopyConstructorP(void) 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( 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( ScrollView::Property::SCROLL_POSITION ), Vector2(10.0f, 10.0f), TEST_LOCATION ); + DALI_TEST_CHECK( !scrollView ); + + END_TEST; +} + int UtcDaliToolkitScrollViewAssignmentOperatorP(void) { ToolkitTestApplication application; @@ -296,12 +329,32 @@ int UtcDaliToolkitScrollViewAssignmentOperatorP(void) 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( ScrollView::Property::SCROLL_POSITION ) == scrollView.GetProperty( 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( 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( ScrollView::Property::SCROLL_POSITION ), Vector2(10.0f, 10.0f), TEST_LOCATION ); + DALI_TEST_CHECK( !scrollView ); + + END_TEST; +} + int UtcDaliScrollViewDestructorP(void) { ToolkitTestApplication application; @@ -2955,3 +3008,81 @@ int UtcDaliScrollViewSetGetProperty(void) 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; +}