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=cf3e1633b12403e579196936afa57bc91e90502f;hb=be93fd772a1b1b09425ac0aaec1ea1b64e9a9e60;hpb=2047844bb3b4a84231905c8c540d34d4c468e5ad diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp index cf3e163..4e050f3 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -20,7 +20,7 @@ #include #include #include -#include +#include using namespace Dali; using namespace Toolkit; @@ -44,26 +44,33 @@ static void TestCallback(BaseHandle handle) gObjectCreatedCallBackCalled = true; } +struct CallbackFunctor +{ + CallbackFunctor(bool* callbackFlag) + : mCallbackFlag( callbackFlag ) + { + } + + void operator()() + { + *mCallbackFlag = true; + } + bool* mCallbackFlag; +}; -const int MILLISECONDS_PER_SECOND = 1000; const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS) -const int RENDER_ANIMATION_TEST_DURATION_MS = 1000; ///< 1000ms to test animation + const int RENDER_DELAY_SCROLL = 1000; ///< duration to wait for any scroll to complete. // For Clamp Signal testing... const float CLAMP_EXCESS_WIDTH = 200.0f; ///< Amount of width that can be panned outside scrollview const float CLAMP_EXCESS_HEIGHT = 200.0f; ///< Amount of height that can be panned outside scrollview -const int CLAMP_STEP_0_CHECK_NOTCLAMPED = 0; ///< FSM: "First check that scrollview isn't clamped" -const int CLAMP_STEP_1_CHECK_CLAMPED_WEST = 1; ///< FSM: "Next check that scrollview clamps against left side" -const int CLAMP_STEP_2_CHECK_CLAMPED_SOUTH_WEST = 2; ///< FSM: "Then check that scrollview clamps against bottom-left side" -const int CLAMP_STEP_3_SUCCESS = 3; ///< FSM: "Finished (Success)" const Vector2 CLAMP_START_SCROLL_POSITION(30.0f, 100.0f); ///< Scroll start position for the Clamping tests. const Vector2 CLAMP_TOUCH_START( 100.0f, 100.0f ); ///< Start point to touch from for the Clamping tests. const Vector2 CLAMP_TOUCH_MOVEMENT( 5.0f, -5.0f ); ///< Amount to move touch for each frame for the Clamping tests. const int CLAMP_GESTURE_FRAMES = 100; ///< Number of Frames to synthesize a gesture for the Clamping tests. const Vector3 TEST_ACTOR_POSITION(100.0f, 100.0f, 0.0f); ///< A Test actor position offset (arbitrary value) const Vector3 TEST_CONSTRAINT_OFFSET(1.0f, 2.0f, 0.0f); ///< A Test constraint offset (arbitrary value to test effects) -const float TEST_RATIO_TOLERANCE = 0.05; ///< +/-5% tolerance for ratio comparisons. const float DEFAULT_SNAP_OVERSHOOT_DURATION(0.5f); ///< Default overshoot snapping animation time. const float DEFAULT_MAX_OVERSHOOT(100.0f); ///< Default maximum allowed overshoot in pixels @@ -78,48 +85,6 @@ const float TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION = TEST_CUSTOM2_SNAP_OVERSHOOT_D const float TIME_TOLERANCE = 0.05f; ///< Allow testing tolerance between a 10th of second (+/- 3 frames) -// Generate a PanGestureEvent to send to Core -Integration::PanGestureEvent GeneratePan( - Gesture::State state, - const Vector2& previousPosition, - const Vector2& currentPosition, - unsigned long timeDelta, - unsigned int numberOfTouches = 1) -{ - Integration::PanGestureEvent pan(state); - - pan.previousPosition = previousPosition; - pan.currentPosition = currentPosition; - pan.timeDelta = timeDelta; - 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(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos) -{ - static Vector2 last; - - if( (state == Gesture::Started) || - (state == Gesture::Possible) ) - { - last.x = pos.x; - last.y = pos.y; - } - - application.ProcessEvent(GeneratePan(state, last, pos, RENDER_FRAME_INTERVAL)); - - last.x = pos.x; - last.y = pos.y; -} - /* * Simulate time passed by. * @@ -149,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. @@ -194,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. @@ -235,8 +214,8 @@ static float TestOvershootSnapDuration(ToolkitTestApplication &application, Scro int timeToReachOrigin = -1; for(int i = 0;i(ScrollView::Property::OVERSHOOT_X); - float overshootYValue = scrollView.GetProperty(ScrollView::Property::OVERSHOOT_Y); + float overshootXValue = scrollView.GetCurrentProperty( ScrollView::Property::OVERSHOOT_X ); + float overshootYValue = scrollView.GetCurrentProperty( ScrollView::Property::OVERSHOOT_Y ); if(overshootXValue == 0.0f && overshootYValue == 0.0f) { break; @@ -262,6 +241,44 @@ float TestAlphaFunction(float progress) return std::min( progress * 2.0f, 1.0f ); } +/** + * Generate a complete pan gesture + * Note: To initiate the gesture it will go from start, diagonally SE on the screen, then continue in the direction for frames touches + */ +static Vector2 PerformGestureSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, uint32_t& time, bool finish = true) +{ + gOnScrollStartCalled = false; + gOnScrollUpdateCalled = false; + gOnScrollCompleteCalled = false; + gOnSnapStartCalled = false; + + Vector2 pos( start ); + + // This is created to ensure a pan is started + Vector2 pos_start_jump( start + Vector2(11.0f, 11.0f) ); + TestStartPan( application, start, pos_start_jump, time ); + pos = pos_start_jump; + + Wait(application); + + for(int i = 0;i( 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; @@ -294,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; @@ -311,10 +366,10 @@ int UtcDaliScrollViewDestructorP(void) END_TEST; } -int UtcDaliToolkitScrollViewNewP(void) +int UtcDaliToolkitScrollViewNewP1(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliToolkitScrollViewNewP"); + tet_infoline(" UtcDaliToolkitScrollViewNewP1"); ScrollView scrollView; @@ -329,7 +384,7 @@ int UtcDaliToolkitScrollViewNewP(void) 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; @@ -341,6 +396,25 @@ int UtcDaliToolkitScrollViewNewP(void) END_TEST; } +int UtcDaliToolkitScrollViewNewP2(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewNewP2 - create thru type registry"); + + ScrollView scrollView; + DALI_TEST_CHECK( !scrollView ); + + TypeRegistry typeRegistry = TypeRegistry::Get(); + TypeInfo scrollViewType = typeRegistry.GetTypeInfo("ScrollView"); + BaseHandle handle = scrollViewType.CreateInstance(); + DALI_TEST_CHECK( handle ); + + scrollView = ScrollView::DownCast(handle); + DALI_TEST_CHECK( scrollView ); + + END_TEST; +} + int UtcDaliToolkitScrollViewDownCastP(void) { ToolkitTestApplication application; @@ -362,7 +436,7 @@ int UtcDaliToolkitScrollViewScrollToPositionP(void) // Create the ScrollView actor ScrollView scrollView = ScrollView::New(); - Stage::GetCurrent().Add( scrollView ); + application.GetScene().Add( scrollView ); const Vector2 target = Vector2(100.0f, 200.0f); const Vector2 target2 = Vector2(300.0f, 100.0f); @@ -383,7 +457,7 @@ int UtcDaliToolkitScrollViewScrollToPositionWithDirectionBiasP(void) tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithDirectionBiasP"); ScrollView scrollView = ScrollView::New(); - Stage::GetCurrent().Add( scrollView ); + application.GetScene().Add( scrollView ); RulerPtr rulerX = new FixedRuler( 100.0f ); rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) ); RulerPtr rulerY = new FixedRuler( 100.0f ); @@ -394,6 +468,9 @@ int UtcDaliToolkitScrollViewScrollToPositionWithDirectionBiasP(void) scrollView.SetWrapMode(true); + Property::Value wrapMode = scrollView.GetProperty( Toolkit::ScrollView::Property::WRAP_ENABLED ); + DALI_TEST_EQUALS( wrapMode.Get(), true, TEST_LOCATION ); + const Vector2 target = Vector2(50.0f, 50.0f); const Vector2 target2 = Vector2(150.0f, 150.0f); @@ -403,7 +480,7 @@ int UtcDaliToolkitScrollViewScrollToPositionWithDirectionBiasP(void) scrollView.ScrollTo( target2, 0.25f, Dali::Toolkit::DirectionBiasLeft, Dali::Toolkit::DirectionBiasLeft ); Wait(application, RENDER_DELAY_SCROLL); - DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION ); scrollView.ScrollTo( target, 0.0f ); Wait(application, RENDER_DELAY_SCROLL); @@ -423,7 +500,7 @@ int UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionP(void) // Create the ScrollView actor ScrollView scrollView = ScrollView::New(); - Stage::GetCurrent().Add( scrollView ); + application.GetScene().Add( scrollView ); const Vector2 target = Vector2(100.0f, 200.0f); const Vector2 target2 = Vector2(300.0f, 100.0f); @@ -452,7 +529,7 @@ int UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionAndDirectionBiasP(v tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionAndDirectionBiasP"); ScrollView scrollView = ScrollView::New(); - Stage::GetCurrent().Add( scrollView ); + application.GetScene().Add( scrollView ); RulerPtr rulerX = new FixedRuler( 100.0f ); rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) ); RulerPtr rulerY = new FixedRuler( 100.0f ); @@ -472,7 +549,7 @@ int UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionAndDirectionBiasP(v scrollView.ScrollTo( target2, 0.25f, AlphaFunction::LINEAR, Dali::Toolkit::DirectionBiasLeft, Dali::Toolkit::DirectionBiasLeft ); Wait(application, RENDER_DELAY_SCROLL); - DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION ); scrollView.ScrollTo( target, 0.0f ); Wait(application, RENDER_DELAY_SCROLL); @@ -500,7 +577,7 @@ int UtcDaliToolkitScrollViewScrollToPageP(void) tet_infoline(" UtcDaliToolkitScrollViewScrollToPageP"); ScrollView scrollView = ScrollView::New(); - Stage::GetCurrent().Add( scrollView ); + application.GetScene().Add( scrollView ); RulerPtr rulerX = new FixedRuler( 100.0f ); rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) ); RulerPtr rulerY = new FixedRuler( 100.0f ); @@ -554,13 +631,246 @@ int UtcDaliToolkitScrollViewScrollToPageP(void) END_TEST; } + +int UtcDaliToolkitScrollModeP1(void) +{ + ToolkitTestApplication application; + tet_infoline( " UtcDaliToolkitScrollView ScrollMode property" ); + + // 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. + Property::Map rulerMap; + rulerMap.Add( ScrollMode::X_AXIS_SCROLL_ENABLED, true ); + rulerMap.Add( ScrollMode::X_AXIS_SNAP_TO_INTERVAL, viewPageSize.width ); + rulerMap.Add( ScrollMode::X_AXIS_SCROLL_BOUNDARY, viewPageSize.width*3 ); + rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, false ); + scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap); + + scrollView.SetWrapMode( false ); + scrollView.SetScrollSensitive( true ); + + application.GetScene().Add( scrollView ); + + // Set up a gesture to perform. + Vector2 startPos( 50.0f, 0.0f ); + Vector2 direction( -5.0f, 0.0f ); + int frames = 200; + uint32_t time = 0; + + // Force starting position. + scrollView.ScrollTo( startPos, 0.0f ); + time += Wait( application ); + + // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins. + Vector2 currentPos( PerformGestureSwipe( application, startPos, direction, frames - 1, time, false ) ); + + // Confirm the final X coord has not moved more than one page from the start X position. + DALI_TEST_GREATER( ( startPos.x + viewPageSize.width ), scrollView.GetCurrentScrollPosition().x, TEST_LOCATION ); + + // Finish the gesture and wait for the snap. + currentPos += direction; + TestEndPan( application, currentPos, time ); + // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first. + time += Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL ); + + // 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 ); + + END_TEST; +} + +int UtcDaliToolkitScrollModeP2(void) +{ + ToolkitTestApplication application; + tet_infoline( " UtcDaliToolkitScrollView ScrollMode property" ); + + // 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. + Property::Map rulerMap; + rulerMap.Add( ScrollMode::X_AXIS_SCROLL_ENABLED, false ); + rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, true ); + rulerMap.Add( ScrollMode::Y_AXIS_SNAP_TO_INTERVAL, viewPageSize.height ); + rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_BOUNDARY, viewPageSize.height*3 ); + scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap); + + scrollView.SetWrapMode( false ); + scrollView.SetScrollSensitive( true ); + + application.GetScene().Add( scrollView ); + + // Set up a gesture to perform. + Vector2 startPos( 0.0f, 50.0f ); + Vector2 direction( 0.0f, -6.0f ); + int frames = 200; + uint32_t time = 0; + + // Force starting position. + scrollView.ScrollTo( startPos, 0.0f ); + time += Wait( application ); + + // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins. + Vector2 currentPos( PerformGestureSwipe( application, startPos, direction, frames - 1, time, false ) ); + + // Confirm the final X coord has not moved more than one page from the start X position. + DALI_TEST_GREATER( ( startPos.y + viewPageSize.height ), scrollView.GetCurrentScrollPosition().y, TEST_LOCATION ); + + // Finish the gesture and wait for the snap. + currentPos += direction; + time += Wait( application ); + TestEndPan( application, currentPos, time ); + // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first. + Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL ); + + // Confirm the final Y coord has snapped to exactly one page ahead of the start page. + DALI_TEST_EQUALS( viewPageSize.height, scrollView.GetCurrentScrollPosition().y, Math::MACHINE_EPSILON_0, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliToolkitScrollModeP3(void) +{ + ToolkitTestApplication application; + tet_infoline( " UtcDaliToolkitScrollView ScrollMode property" ); + + // 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. + Property::Map rulerMap; + rulerMap.Add( ScrollMode::X_AXIS_SCROLL_ENABLED, false ); + rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, true ); + rulerMap.Add( ScrollMode::Y_AXIS_SNAP_TO_INTERVAL, viewPageSize.height ); + rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_BOUNDARY, viewPageSize.height*3 ); + scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap); + + scrollView.SetWrapMode( false ); + scrollView.SetScrollSensitive( true ); + + application.GetScene().Add( scrollView ); + + // Set up a gesture to perform. + Vector2 startPos( 0.0f, 50.0f ); + Vector2 direction( 0.0f, -6.0f ); + int frames = 200; + uint32_t time = 0; + + // Force starting position. + scrollView.ScrollTo( startPos, 0.0f ); + time += Wait( application ); + + // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins. + Vector2 currentPos( PerformGestureSwipe( application, startPos, direction, frames - 1, time, false ) ); + + // Confirm the final X coord has not moved more than one page from the start X position. + DALI_TEST_GREATER( ( startPos.y + viewPageSize.height ), scrollView.GetCurrentScrollPosition().y, TEST_LOCATION ); + + // Finish the gesture and wait for the snap. + currentPos += direction; + TestEndPan( application, currentPos, time ); + // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first. + Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL ); + + // Confirm the final Y coord has snapped to exactly one page ahead of the start page. + DALI_TEST_EQUALS( viewPageSize.height, scrollView.GetCurrentScrollPosition().y, Math::MACHINE_EPSILON_0, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliToolkitScrollModeP4(void) +{ + ToolkitTestApplication application; + tet_infoline( " UtcDaliToolkitScrollView ScrollMode property, DefaultRulers" ); + + // 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::TOP_LEFT ); + scrollView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); + scrollView.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f )); + + // Position rulers - expect Default rulers to be used which don't snap + Property::Map rulerMap; + rulerMap.Add( ScrollMode::X_AXIS_SCROLL_ENABLED, true ); + rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, true ); + scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap); + + scrollView.SetWrapMode( false ); + scrollView.SetScrollSensitive( true ); + + application.GetScene().Add( scrollView ); + + Vector2 START_POSITION = Vector2(10.0f, 10.0f); + + uint32_t time = 0; + scrollView.ScrollTo(START_POSITION, 0.0f); + time += Wait(application); + + // Try a vertical swipe. + // PerformGestureSwipe not used as a different initial direction was required + Vector2 pos( START_POSITION + Vector2(0.0f, 15.0f) ); + Vector2 dir( 0.0f, 1.0f ); + + TestStartPan( application, START_POSITION, pos, time ); + + Wait(application); + + for( int i = 0; i<45; i++ ) + { + pos += dir; + TestMovePan( application, pos, time ); + time += Wait( application ); + } + + pos += dir; + + TestEndPan( application, pos, time ); + Wait( application, RENDER_DELAY_SCROLL ); + + // Take into account resampling done when prediction is off. + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION ); + + END_TEST; +} + int UtcDaliToolkitScrollViewScrollToPageWithDirectionBiasP(void) { ToolkitTestApplication application; tet_infoline(" UtcDaliToolkitScrollViewScrollToPageWithDirectionBiasP"); ScrollView scrollView = ScrollView::New(); - Stage::GetCurrent().Add( scrollView ); + application.GetScene().Add( scrollView ); RulerPtr rulerX = new FixedRuler( 100.0f ); rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) ); RulerPtr rulerY = new FixedRuler( 100.0f ); @@ -602,16 +912,16 @@ int UtcDaliToolkitScrollViewScrollToActorP(void) tet_infoline(" UtcDaliToolkitScrollViewScrollToActorP"); ScrollView scrollView = ScrollView::New(); - Stage::GetCurrent().Add( scrollView ); + application.GetScene().Add( scrollView ); Actor actorA = Actor::New(); const Vector3 positionA = Vector3(100.0f, 400.0f, 0.0f); - actorA.SetPosition(positionA); + actorA.SetProperty( Actor::Property::POSITION, positionA ); scrollView.Add(actorA); Actor actorB = Actor::New(); const Vector3 positionB = Vector3(500.0f, 200.0f, 0.0f); - actorB.SetPosition(positionB); + actorB.SetProperty( Actor::Property::POSITION, positionB ); scrollView.Add(actorB); Wait(application); @@ -641,7 +951,7 @@ int UtcDaliToolkitScrollViewScrollToSnapPointP(void) tet_infoline(" UtcDaliToolkitScrollViewScrollToSnapPointP"); ScrollView scrollView = ScrollView::New(); - Stage::GetCurrent().Add( scrollView ); + application.GetScene().Add( scrollView ); RulerPtr rulerX = new FixedRuler( 100.0f ); rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) ); RulerPtr rulerY = new FixedRuler( 100.0f ); @@ -683,7 +993,7 @@ int UtcDaliToolkitScrollViewSetWrapModeP(void) tet_infoline(" UtcDaliToolkitScrollViewSetWrapModeP"); ScrollView scrollView = ScrollView::New(); - Stage::GetCurrent().Add( scrollView ); + application.GetScene().Add( scrollView ); Actor actor = Actor::New(); scrollView.Add( actor ); @@ -714,7 +1024,7 @@ int UtcDaliToolkitScrollViewActorAutoSnap(void) tet_infoline(" UtcDaliToolkitScrollViewActorAutoSnap"); ScrollView scrollView = ScrollView::New(); - Stage::GetCurrent().Add( scrollView ); + application.GetScene().Add( scrollView ); // Position rulers. RulerPtr rulerX = new DefaultRuler(); @@ -727,12 +1037,12 @@ int UtcDaliToolkitScrollViewActorAutoSnap(void) const Vector3 aPosition = Vector3(200.0f, 50.0f, 0.0f); Actor a = Actor::New(); scrollView.Add(a); - a.SetPosition(aPosition); + a.SetProperty( Actor::Property::POSITION, aPosition ); const Vector3 bPosition = Vector3(600.0f, 600.0f, 0.0f); Actor b = Actor::New(); scrollView.Add(b); - b.SetPosition(bPosition); + b.SetProperty( Actor::Property::POSITION, bPosition ); // Goto a random position, and execute snap (should not move) Vector2 targetScroll = Vector2(500.0f, 500.0f); @@ -765,7 +1075,7 @@ int UtcDaliToolkitScrollViewSignalsStartComplete(void) gOnScrollCompleteCalled = false; ScrollView scrollView = ScrollView::New(); - Stage::GetCurrent().Add( scrollView ); + application.GetScene().Add( scrollView ); // Position rulers. RulerPtr rulerX = new DefaultRuler(); @@ -785,7 +1095,7 @@ int UtcDaliToolkitScrollViewSignalsStartComplete(void) END_TEST; } -int UtcDaliToolkitScrollViewSignalsUpdate(void) +int UtcDaliToolkitScrollViewSignalsUpdate01(void) { ToolkitTestApplication application; tet_infoline(" UtcDaliToolkitScrollViewSignalsUpdate"); @@ -795,11 +1105,11 @@ int UtcDaliToolkitScrollViewSignalsUpdate(void) gOnScrollCompleteCalled = false; ScrollView scrollView = ScrollView::New(); - Stage::GetCurrent().Add( scrollView ); - Vector2 stageSize = Stage::GetCurrent().GetSize(); - scrollView.SetSize(stageSize); - scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT); - scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT); + application.GetScene().Add( scrollView ); + Vector2 stageSize = application.GetScene().GetSize(); + scrollView.SetProperty( Actor::Property::SIZE, stageSize); + scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT); + scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); // Position rulers. RulerPtr rulerX = new DefaultRuler(); @@ -812,31 +1122,33 @@ int UtcDaliToolkitScrollViewSignalsUpdate(void) scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate ); scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete ); - ImageActor image = CreateSolidColorActor( Color::RED ); - image.SetSize(stageSize); - image.SetParentOrigin(ParentOrigin::TOP_LEFT); - image.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Actor image = Actor::New(); + image.SetProperty( Actor::Property::SIZE, stageSize); + image.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT); + image.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); scrollView.Add(image); Wait(application); // Do a pan starting from 100,100 and moving down diagonally. Vector2 pos(100.0f, 100.0f); - SendPan(application, Gesture::Possible, pos); - SendPan(application, Gesture::Started, pos); + uint32_t time = 100; + TestStartPan( application, pos, pos, time ); pos.x += 5.0f; pos.y += 5.0f; Wait(application, 100); for(int i = 0;i<20;i++) { - SendPan(application, Gesture::Continuing, pos); + time += RENDER_FRAME_INTERVAL; + TestMovePan( application, pos, time); pos.x += 5.0f; pos.y += 5.0f; Wait(application); } - SendPan(application, Gesture::Finished, pos); + time += RENDER_FRAME_INTERVAL; + TestEndPan(application, pos, time ); Wait(application, RENDER_DELAY_SCROLL); DALI_TEST_CHECK(gOnScrollStartCalled); @@ -845,34 +1157,73 @@ int UtcDaliToolkitScrollViewSignalsUpdate(void) END_TEST; } -static Vector2 PerformGestureDiagonalSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, bool finish = true) +int UtcDaliToolkitScrollViewSignalsUpdate02(void) { + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewSignalsUpdate"); + gOnScrollStartCalled = false; gOnScrollUpdateCalled = false; gOnScrollCompleteCalled = false; - gOnSnapStartCalled = false; - // Now do a pan starting from (start) and heading (direction) - Vector2 pos(start); - SendPan(application, Gesture::Possible, pos); - SendPan(application, Gesture::Started, pos); + ScrollView scrollView = ScrollView::New(); + application.GetScene().Add( scrollView ); + Vector2 stageSize = application.GetScene().GetSize(); + scrollView.SetProperty( Actor::Property::SIZE, stageSize); + scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT); + scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); + + // Position rulers. + RulerPtr rulerX = new DefaultRuler(); + RulerPtr rulerY = new DefaultRuler(); + rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) ); + rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) ); + scrollView.SetRulerX(rulerX); + scrollView.SetRulerY(rulerY); + Dali::ConnectionTracker tracker; + bool scrollStarted=false; + bool scrollUpdated=false; + bool scrollCompleted=false; + DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollStarted", CallbackFunctor(&scrollStarted) )); + DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollUpdated", CallbackFunctor(&scrollUpdated) )); + DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollCompleted", CallbackFunctor(&scrollCompleted) )); + + Actor image = Actor::New(); + image.SetProperty( Actor::Property::SIZE, stageSize); + image.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT); + image.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); + scrollView.Add(image); + Wait(application); - for(int i = 0;i( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) ); @@ -1039,11 +1431,11 @@ int UtcDaliToolkitScrollViewBind(void) // Set up a scrollView... ScrollView scrollView = ScrollView::New(); - Stage::GetCurrent().Add( scrollView ); - Vector2 stageSize = Stage::GetCurrent().GetSize(); - scrollView.SetSize(stageSize); - scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT); - scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT); + application.GetScene().Add( scrollView ); + Vector2 stageSize = application.GetScene().GetSize(); + scrollView.SetProperty( Actor::Property::SIZE, stageSize); + scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT); + scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); // Position rulers. RulerPtr rulerX = new DefaultRuler(); @@ -1059,7 +1451,7 @@ int UtcDaliToolkitScrollViewBind(void) gConstraintResult = Vector3::ZERO; Actor a = Actor::New(); scrollView.Add(a); - a.SetPosition( TEST_ACTOR_POSITION ); + a.SetProperty( Actor::Property::POSITION, TEST_ACTOR_POSITION); Wait(application); // apply this constraint to scrollview @@ -1093,11 +1485,18 @@ int UtcDaliToolkitScrollViewOvershoot(void) // Set up a scrollView... ScrollView scrollView = ScrollView::New(); - Stage::GetCurrent().Add( scrollView ); - Vector2 stageSize = Stage::GetCurrent().GetSize(); - scrollView.SetSize(stageSize); - scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT); - scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT); + scrollView.SetOvershootEnabled(true); + + uint32_t time = 0; + Vector2 overshootSize = Vector2(100.0f,100.0f); + scrollView.SetProperty( Scrollable::Property::OVERSHOOT_SIZE, overshootSize ); + DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_SIZE).Get(), overshootSize, TEST_LOCATION ); + + application.GetScene().Add( scrollView ); + Vector2 stageSize = application.GetScene().GetSize(); + scrollView.SetProperty( Actor::Property::SIZE, stageSize); + scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT); + scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); // Position rulers. RulerPtr rulerX = new DefaultRuler(); @@ -1111,14 +1510,14 @@ int UtcDaliToolkitScrollViewOvershoot(void) scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete ); scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little. - Wait(application); + time += Wait(application); // 1. Scroll page in NW (-500,-500 pixels), then inspect overshoot. (don't release touch) Vector2 currentPos = Vector2(100.0f, 100.0f); - currentPos = PerformGestureDiagonalSwipe(application, currentPos, Vector2(5.0f, 5.0f), 100, false); - float overshootXValue = scrollView.GetProperty(ScrollView::Property::OVERSHOOT_X); - float overshootYValue = scrollView.GetProperty(ScrollView::Property::OVERSHOOT_Y); - Vector2 positionValue = scrollView.GetProperty(ScrollView::Property::SCROLL_POSITION); + currentPos = PerformGestureSwipe(application, currentPos, Vector2(5.0f, 5.0f), 100, time, false); + float overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X ); + float overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y ); + Vector2 positionValue = scrollView.GetCurrentProperty< Vector2 >( ScrollView::Property::SCROLL_POSITION ); DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION); DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION); DALI_TEST_EQUALS(positionValue, Vector2::ZERO, TEST_LOCATION); @@ -1126,7 +1525,8 @@ int UtcDaliToolkitScrollViewOvershoot(void) float timeToReachOrigin; // Now release touch. Overshoot should snap back to zero. - SendPan(application, Gesture::Finished, currentPos); + TestEndPan(application, currentPos, time); + timeToReachOrigin = TestOvershootSnapDuration(application, scrollView); float minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE; @@ -1138,9 +1538,9 @@ int UtcDaliToolkitScrollViewOvershoot(void) // 2. Repeat Scroll, but this time change overshoot snap duration to shorter time scrollView.SetSnapOvershootDuration(TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION); - currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false); + currentPos = PerformGestureSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, time, false); // Now release touch. Overshoot should snap back to zero. - SendPan(application, Gesture::Finished, currentPos); + TestEndPan(application, currentPos, time); timeToReachOrigin = TestOvershootSnapDuration(application, scrollView); minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE; @@ -1152,9 +1552,9 @@ int UtcDaliToolkitScrollViewOvershoot(void) // 3. Repeat Scroll, but this time change overshoot snap duration to longer time. scrollView.SetSnapOvershootDuration(TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION); - currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false); + currentPos = PerformGestureSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, time, false); // Now release touch. Overshoot should snap back to zero. - SendPan(application, Gesture::Finished, currentPos); + TestEndPan(application, currentPos, time); timeToReachOrigin = TestOvershootSnapDuration(application, scrollView); minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE; @@ -1167,9 +1567,9 @@ int UtcDaliToolkitScrollViewOvershoot(void) scrollView.SetSnapOvershootDuration(TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION); scrollView.SetSnapOvershootAlphaFunction(TestAlphaFunction); - currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false); + currentPos = PerformGestureSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, time, false); // Now release touch. Overshoot should snap back to zero. - SendPan(application, Gesture::Finished, currentPos); + TestEndPan(application, currentPos, time); timeToReachOrigin = TestOvershootSnapDuration(application, scrollView); minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE; @@ -1224,11 +1624,11 @@ int UtcDaliToolkitScrollViewSnapStartedSignalP(void) // Set up a scrollView... ScrollView scrollView = ScrollView::New(); - Stage::GetCurrent().Add( scrollView ); - Vector2 stageSize = Stage::GetCurrent().GetSize(); - scrollView.SetSize(stageSize); - scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT); - scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT); + application.GetScene().Add( scrollView ); + Vector2 stageSize = application.GetScene().GetSize(); + scrollView.SetProperty( Actor::Property::SIZE, stageSize); + scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT); + scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); // Position rulers. RulerPtr rulerX = new DefaultRuler(); @@ -1240,16 +1640,17 @@ int UtcDaliToolkitScrollViewSnapStartedSignalP(void) scrollView.SnapStartedSignal().Connect( &OnSnapStart ); scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little. - Wait(application); + uint32_t time = 0; + time += Wait(application); // First try a snap. - PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(0.5f, 0.0f), 60, true); + PerformGestureSwipe(application, CLAMP_TOUCH_START, Vector2(0.5f, 0.0f), 60, time, true); DALI_TEST_CHECK( gOnSnapStartCalled ); DALI_TEST_CHECK( gLastSnapType == Toolkit::Snap ); // Second try a swipe. - PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(20.0f, 0.0f), 60, true); + PerformGestureSwipe(application, CLAMP_TOUCH_START, Vector2(20.0f, 0.0f), 60, time, true); DALI_TEST_CHECK( gOnSnapStartCalled ); DALI_TEST_CHECK( gLastSnapType == Toolkit::Flick ); @@ -1262,7 +1663,7 @@ int UtcDaliToolkitScrollViewGetCurrentPageP(void) tet_infoline(" UtcDaliToolkitScrollViewGetCurrentPageP"); ScrollView scrollView = ScrollView::New(); - Stage::GetCurrent().Add( scrollView ); + application.GetScene().Add( scrollView ); RulerPtr rulerX = new FixedRuler( 100.0f ); rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) ); RulerPtr rulerY = new FixedRuler( 100.0f ); @@ -1293,11 +1694,11 @@ int UtcDaliToolkitScrollViewSetMaxOvershootP(void) // Set up a scrollView... ScrollView scrollView = ScrollView::New(); - Stage::GetCurrent().Add( scrollView ); - Vector2 stageSize = Stage::GetCurrent().GetSize(); - scrollView.SetSize(stageSize); - scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT); - scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT); + application.GetScene().Add( scrollView ); + Vector2 stageSize = application.GetScene().GetSize(); + scrollView.SetProperty( Actor::Property::SIZE, stageSize); + scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT); + scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); // Position rulers. RulerPtr rulerX = new DefaultRuler(); @@ -1311,46 +1712,66 @@ int UtcDaliToolkitScrollViewSetMaxOvershootP(void) scrollView.SetMaxOvershoot(50.0f, 50.0f); scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little. - Wait(application); + uint32_t time = 0; + time += Wait(application); // Scroll page in NW (-20,-20 pixels), then check that overshoot should be 0. (don't release touch) - Vector2 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 20, false); - float overshootXValue = scrollView.GetProperty(ScrollView::Property::OVERSHOOT_X); - float overshootYValue = scrollView.GetProperty(ScrollView::Property::OVERSHOOT_Y); + Vector2 currentPos = PerformGestureSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 10, time, false); + float overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X ); + float overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y ); DALI_TEST_EQUALS(overshootXValue, 0.0f, TEST_LOCATION); DALI_TEST_EQUALS(overshootYValue, 0.0f, TEST_LOCATION); + time += Wait(application); // Scroll page further in NW (-105,-105 pixels), then check that overshoot should be around 0.5. (don't release touch) - currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 105, false); - overshootXValue = scrollView.GetProperty(ScrollView::Property::OVERSHOOT_X); - overshootYValue = scrollView.GetProperty(ScrollView::Property::OVERSHOOT_Y); + for(int i = 0; i<106; i++) + { + TestMovePan(application, currentPos, time ); + currentPos += Vector2(1.0f, 1.0f); + time += Wait(application); + } + + overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X ); + overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y ); // The overshoot value is a 0.0f - 1.0f ranged value of the amount overshot related to the maximum overshoot. // EG. If we move 105, max overshoot is 50, then we overshot 50 / 105. - float correctOvershootValue = 50.0f / 105.f; + float correctOvershootValue = 0.508f; // This was measured and then set as the limit DALI_TEST_EQUALS( overshootXValue, correctOvershootValue, 0.001f, TEST_LOCATION ); DALI_TEST_EQUALS( overshootYValue, correctOvershootValue, 0.001f, TEST_LOCATION ); - // Scroll page further in NW (-30,-30 pixels), then check that overshoot should be now 1.0. (don't release touch) - currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 30, false); - overshootXValue = scrollView.GetProperty(ScrollView::Property::OVERSHOOT_X); - overshootYValue = scrollView.GetProperty(ScrollView::Property::OVERSHOOT_Y); + // Scroll page further in NW (-25,-25 pixels), then check that overshoot should be now 1.0. (don't release touch) + for(int i = 0;i<25;i++) + { + TestMovePan(application, currentPos, time ); + currentPos += Vector2(1.0f, 1.0f); // Move in this direction + time += Wait(application); + } + + overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X ); + overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y ); DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION); DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION); - // Change the max overshoot to be 100 pixels in both X axis and Y axis - scrollView.SetMaxOvershoot(100.0f, 100.0f); - Wait(application); + // Change the max overshoot to be 250 pixels in both X axis and Y axis + scrollView.SetMaxOvershoot(250.0f, 250.0f); + time += Wait(application); // Check that overshoot should be now around 0.8. - overshootXValue = scrollView.GetProperty(ScrollView::Property::OVERSHOOT_X); - overshootYValue = scrollView.GetProperty(ScrollView::Property::OVERSHOOT_Y); + overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X ); + overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y ); DALI_TEST_CHECK(overshootXValue > 0.79f && overshootXValue < 0.81f); DALI_TEST_CHECK(overshootYValue > 0.79f && overshootYValue < 0.81f); - // Scroll page further in NW (-30,-30 pixels), then check that overshoot should be now 1.0. (don't release touch) - currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 30, false); - overshootXValue = scrollView.GetProperty(ScrollView::Property::OVERSHOOT_X); - overshootYValue = scrollView.GetProperty(ScrollView::Property::OVERSHOOT_Y); + // Scroll page further in NW (-50,-50 pixels), then check that overshoot should be now 1.0. (don't release touch) + for(int i = 0;i<50;i++) + { + TestMovePan(application, currentPos, time ); + currentPos += Vector2(1.0f, 1.0f); // Move in this direction + time += Wait(application); + } + + overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X ); + overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y ); DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION); DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION); @@ -1364,35 +1785,80 @@ int UtcDaliToolkitScrollViewSetScrollingDirectionP(void) // Set up a scrollView... ScrollView scrollView = ScrollView::New(); - Stage::GetCurrent().Add( scrollView ); - Vector2 stageSize = Stage::GetCurrent().GetSize(); - scrollView.SetSize(stageSize); - scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT); - scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT); + application.GetScene().Add( scrollView ); + Vector2 stageSize = application.GetScene().GetSize(); + scrollView.SetProperty( Actor::Property::SIZE, stageSize); + scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT); + scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); Vector2 START_POSITION = Vector2(10.0f, 10.0f); scrollView.ScrollTo(START_POSITION, 0.0f); - Wait(application); + uint32_t time = 0; + time += Wait(application); + // Try a vertical swipe. - PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true); + // PerformGestureSwipe not used as a different initial direction was required + + Vector2 pos( START_POSITION + Vector2(0.0f, 15.0f) ); + TestStartPan( application, START_POSITION, pos, time ); + time += Wait(application); + for( int i = 0; i<45; i++ ) + { + pos += Vector2(0.0f, 1.0f); + TestMovePan( application, pos, time ); + time += Wait( application ); + } + pos += Vector2(0.0f, 1.0f); + TestEndPan( application, pos, time ); + time += Wait( application ); + // Take into account resampling done when prediction is off. DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION ); scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL); scrollView.ScrollTo(START_POSITION, 0.0f); - Wait(application); + time += Wait(application); + // Try a vertical swipe. - PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true); - DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), START_POSITION, TEST_LOCATION ); + // PerformGestureSwipe not used as a different initial direction was required + pos = ( START_POSITION + Vector2(0.0f, 15.0f) ); + TestStartPan( application, START_POSITION, pos, time ); + time += Wait(application); + for( int i = 0; i<45; i++ ) + { + pos += Vector2(0.0f, 1.0f); + TestMovePan( application, pos, time ); + time += Wait( application ); + } + pos += Vector2(0.0f, 1.0f); + TestEndPan( application, pos, time ); + time += Wait( application ); + + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION ); scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL); - scrollView.ScrollTo(Vector2(10.0f, 10.0f), 0.0f); - Wait(application); + scrollView.ScrollTo(START_POSITION, 0.0f); + + time += Wait(application); + // Try a vertical swipe. - PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true); + // PerformGestureSwipe not used as a different initial direction was required + pos = ( START_POSITION + Vector2(0.0f, 15.0f) ); + TestStartPan( application, START_POSITION, pos, time ); + time += Wait(application); + for( int i = 0; i<45; i++ ) + { + pos += Vector2(0.0f, 1.0f); + TestMovePan( application, pos, time ); + time += Wait( application ); + } + pos += Vector2(0.0f, 1.0f); + TestEndPan( application, pos, time ); + time += Wait( application ); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION ); END_TEST; @@ -1405,29 +1871,59 @@ int UtcDaliToolkitScrollViewRemoveScrollingDirectionP(void) // Set up a scrollView... ScrollView scrollView = ScrollView::New(); - Stage::GetCurrent().Add( scrollView ); - Vector2 stageSize = Stage::GetCurrent().GetSize(); - scrollView.SetSize(stageSize); - scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT); - scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT); + application.GetScene().Add( scrollView ); + Vector2 stageSize = application.GetScene().GetSize(); + scrollView.SetProperty( Actor::Property::SIZE, stageSize); + scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT); + scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); Vector2 START_POSITION = Vector2(10.0f, 10.0f); + uint32_t time = 0; scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL); scrollView.ScrollTo(START_POSITION, 0.0f); - Wait(application); - // Try a vertical swipe. - PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true); + + time += Wait(application); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), START_POSITION, TEST_LOCATION ); + // Try a vertical swipe. + // PerformGestureSwipe not used as a different initial direction was required + Vector2 pos( START_POSITION + Vector2(0.0f, 15.0f) ); + TestStartPan( application, START_POSITION, pos, time ); + time += Wait(application); + for( int i = 0; i<45; i++ ) + { + pos += Vector2(0.0f, 1.0f); + TestMovePan( application, pos, time ); + time += Wait( application ); + } + pos += Vector2(0.0f, 1.0f); + TestEndPan( application, pos, time ); + time += Wait( application ); + + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION ); + scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL); + // When the horizontal direction is removed, there are no directions set and therefore all will work + scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_HORIZONTAL); - scrollView.ScrollTo(Vector2(10.0f, 10.0f), 0.0f); - Wait(application); + time += Wait(application); // Try a vertical swipe. - PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true); - // Take into account resampling done when prediction is off. + Vector2 pos2( pos + Vector2(0.0f, 15.0f) ); + TestStartPan( application, pos, pos2, time ); + time += Wait(application); + for( int i = 0; i<45; i++ ) + { + pos2 += Vector2(0.0f, 1.0f); + TestMovePan( application, pos2, time ); + time += Wait( application ); + } + pos2 += Vector2(0.0f, 1.0f); + TestEndPan( application, pos2, time ); + + // The previous scroll should not have had any effect DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION ); END_TEST; @@ -1439,7 +1935,7 @@ int UtcDaliToolkitScrollViewSetRulerXP(void) tet_infoline(" UtcDaliToolkitScrollViewSetRulerXP"); ScrollView scrollView = ScrollView::New(); - Stage::GetCurrent().Add( scrollView ); + application.GetScene().Add( scrollView ); RulerPtr rulerX = new FixedRuler( 100.0f ); rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) ); @@ -1467,7 +1963,7 @@ int UtcDaliToolkitScrollViewSetRulerYP(void) tet_infoline(" UtcDaliToolkitScrollViewSetRulerYP"); ScrollView scrollView = ScrollView::New(); - Stage::GetCurrent().Add( scrollView ); + application.GetScene().Add( scrollView ); RulerPtr rulerY = new FixedRuler( 200.0f ); rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) ); @@ -2198,11 +2694,11 @@ int UtcDaliToolkitScrollViewConstraintsMove(void) // Set up a scrollView... ScrollView scrollView = ScrollView::New(); - Stage::GetCurrent().Add( scrollView ); - Vector2 stageSize = Stage::GetCurrent().GetSize(); - scrollView.SetSize(stageSize); - scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT); - scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT); + application.GetScene().Add( scrollView ); + Vector2 stageSize = application.GetScene().GetSize(); + scrollView.SetProperty( Actor::Property::SIZE, stageSize); + scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT); + scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); // Position rulers. RulerPtr rulerX = new DefaultRuler(); @@ -2215,7 +2711,7 @@ int UtcDaliToolkitScrollViewConstraintsMove(void) // Add an Actor to ScrollView, Actor a = Actor::New(); scrollView.Add(a); - a.SetPosition( TEST_ACTOR_POSITION ); + a.SetProperty( Actor::Property::POSITION, TEST_ACTOR_POSITION); Wait(application); const Vector2 target = Vector2(100.0f, 100.0f); @@ -2243,11 +2739,11 @@ int UtcDaliToolkitScrollViewConstraintsWrap(void) // Set up a scrollView... ScrollView scrollView = ScrollView::New(); - Stage::GetCurrent().Add( scrollView ); - Vector2 stageSize = Stage::GetCurrent().GetSize(); - scrollView.SetSize(stageSize); - scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT); - scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT); + application.GetScene().Add( scrollView ); + Vector2 stageSize = application.GetScene().GetSize(); + scrollView.SetProperty( Actor::Property::SIZE, stageSize); + scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT); + scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); // Position rulers. RulerPtr rulerX = new DefaultRuler(); @@ -2260,7 +2756,7 @@ int UtcDaliToolkitScrollViewConstraintsWrap(void) // Add an Actor to ScrollView, Actor a = Actor::New(); scrollView.Add(a); - a.SetPosition( TEST_ACTOR_POSITION ); + a.SetProperty( Actor::Property::POSITION, TEST_ACTOR_POSITION); Wait(application); const Vector2 target = Vector2(100.0f, 100.0f); @@ -2283,5 +2779,310 @@ int UtcDaliToolkitScrollViewConstraintsWrap(void) Wait(application, RENDER_DELAY_SCROLL); DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION ); + scrollView.Remove(a); + Wait(application); + + END_TEST; +} + +// Non-API test (so no P or N variant). +int UtcDaliToolkitScrollViewGesturePageLimit(void) +{ + ToolkitTestApplication application; + tet_infoline( " UtcDaliToolkitScrollViewGesturePageLimit" ); + + // 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 ); + scrollView.SetScrollSensitive( true ); + + application.GetScene().Add( scrollView ); + + // Set up a gesture to perform. + Vector2 startPos( 50.0f, 0.0f ); + Vector2 direction( -5.0f, 0.0f ); + int frames = 200; + + // Force starting position. + scrollView.ScrollTo( startPos, 0.0f ); + uint32_t time = 0; + time += Wait( application ); + + // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins. + Vector2 currentPos( PerformGestureSwipe( application, startPos, direction, frames - 1, time, false ) ); + + // Confirm the final X coord has not moved more than one page from the start X position. + DALI_TEST_GREATER( ( startPos.x + viewPageSize.width ), scrollView.GetCurrentScrollPosition().x, TEST_LOCATION ); + + // Finish the gesture and wait for the snap. + currentPos += direction; + TestEndPan(application, currentPos, time); + // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first. + time += Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL ); + + // 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 ); + + END_TEST; +} + +int UtcDaliScrollViewSetGetProperty(void) +{ + ToolkitTestApplication application; + + // Create the ScrollView actor + ScrollView scrollView = ScrollView::New(); + DALI_TEST_CHECK(scrollView); + + // Event side properties + + // Test "wrapEnabled" property + DALI_TEST_CHECK( scrollView.GetPropertyIndex("wrapEnabled") == ScrollView::Property::WRAP_ENABLED ); + scrollView.SetProperty( ScrollView::Property::WRAP_ENABLED, true ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WRAP_ENABLED).Get(), true, TEST_LOCATION ); + + // Test "panningEnabled" property + DALI_TEST_CHECK( scrollView.GetPropertyIndex("panningEnabled") == ScrollView::Property::PANNING_ENABLED ); + scrollView.SetProperty( ScrollView::Property::PANNING_ENABLED, false ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::PANNING_ENABLED).Get(), false, TEST_LOCATION ); + + // Test "axisAutoLockEnabled" property + DALI_TEST_CHECK( scrollView.GetPropertyIndex("axisAutoLockEnabled") == ScrollView::Property::AXIS_AUTO_LOCK_ENABLED ); + scrollView.SetProperty( ScrollView::Property::AXIS_AUTO_LOCK_ENABLED, false ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::AXIS_AUTO_LOCK_ENABLED).Get(), false, TEST_LOCATION ); + + // Test "wheelScrollDistanceStep" property + DALI_TEST_CHECK( scrollView.GetPropertyIndex("wheelScrollDistanceStep") == ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP ); + scrollView.SetProperty( ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP, Vector2(100.0f, 50.0f) ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP).Get(), Vector2(100.0f, 50.0f), TEST_LOCATION ); + + // Test "overshootEnabled" property + DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootEnabled") == Scrollable::Property::OVERSHOOT_ENABLED ); + DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get(), scrollView.IsOvershootEnabled(), TEST_LOCATION ); + scrollView.SetProperty( Scrollable::Property::OVERSHOOT_ENABLED, false ); + DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get(), false, TEST_LOCATION ); + + // Animatable properties + + // Test "scrollPosition" property + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPosition") == ScrollView::Property::SCROLL_POSITION ); + scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(320.0f, 550.0f) ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_POSITION).Get(), Vector2(320.0f, 550.0f), TEST_LOCATION ); + + // Test "scrollPrePosition", "scrollPrePositionX" and "scrollPrePositionY" properties + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePosition") == ScrollView::Property::SCROLL_PRE_POSITION ); + scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION, Vector2(300.0f, 500.0f) ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION).Get(), Vector2(300.0f, 500.0f), TEST_LOCATION ); + + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionX") == ScrollView::Property::SCROLL_PRE_POSITION_X ); + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionY") == ScrollView::Property::SCROLL_PRE_POSITION_Y ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_X).Get(), 300.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_Y).Get(), 500.0f, TEST_LOCATION ); + scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_X, 400.0f ); + scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_Y, 600.0f ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_X).Get(), 400.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_Y).Get(), 600.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION).Get(), Vector2(400.0f, 600.0f), TEST_LOCATION ); + + // Test "scrollPrePositionMax", "scrollPrePositionMaxX" and "scrollPrePositionMaxY" properties + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMax") == ScrollView::Property::SCROLL_PRE_POSITION_MAX ); + scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX, Vector2(100.0f, 200.0f) ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX).Get(), Vector2(100.0f, 200.0f), TEST_LOCATION ); + + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMaxX") == ScrollView::Property::SCROLL_PRE_POSITION_MAX_X ); + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMaxY") == ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_X).Get(), 100.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y).Get(), 200.0f, TEST_LOCATION ); + scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX_X, 300.0f ); + scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y, 400.0f ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_X).Get(), 300.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y).Get(), 400.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX).Get(), Vector2(300.0f, 400.0f), TEST_LOCATION ); + + // Test "overshootX" property + DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootX") == ScrollView::Property::OVERSHOOT_X ); + scrollView.SetProperty( ScrollView::Property::OVERSHOOT_X, 0.8f ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::OVERSHOOT_X).Get(), 0.8f, TEST_LOCATION ); + + // Test "overshootY" property + DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootY") == ScrollView::Property::OVERSHOOT_Y ); + scrollView.SetProperty( ScrollView::Property::OVERSHOOT_Y, 0.8f ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::OVERSHOOT_Y).Get(), 0.8f, TEST_LOCATION ); + + // Test "scrollFinal", "scrollFinalX" and "scrollFinalY" properties + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinal") == ScrollView::Property::SCROLL_FINAL ); + scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL, Vector2(200.0f, 300.0f) ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL).Get(), Vector2(200.0f, 300.0f), TEST_LOCATION ); + + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinalX") == ScrollView::Property::SCROLL_FINAL_X ); + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinalY") == ScrollView::Property::SCROLL_FINAL_Y ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_X).Get(), 200.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_Y).Get(), 300.0f, TEST_LOCATION ); + scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL_X, 500.0f ); + scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL_Y, 600.0f ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_X).Get(), 500.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_Y).Get(), 600.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL).Get(), Vector2(500.0f, 600.0f), TEST_LOCATION ); + + // Test "wrap" property + DALI_TEST_CHECK( scrollView.GetPropertyIndex("wrap") == ScrollView::Property::WRAP ); + scrollView.SetProperty( ScrollView::Property::WRAP, false ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WRAP).Get(), false, TEST_LOCATION ); + + // Test "panning" property + DALI_TEST_CHECK( scrollView.GetPropertyIndex("panning") == ScrollView::Property::PANNING ); + scrollView.SetProperty( ScrollView::Property::PANNING, true ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::PANNING).Get(), true, TEST_LOCATION ); + + // Test "scrolling" property + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrolling") == ScrollView::Property::SCROLLING ); + scrollView.SetProperty( ScrollView::Property::SCROLLING, false ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLLING).Get(), false, TEST_LOCATION ); + + // Test "scrollDomainSize", "scrollDomainSizeX" and "scrollDomainSizeY" properties + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSize") == ScrollView::Property::SCROLL_DOMAIN_SIZE ); + scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE, Vector2(1200.0f, 1300.0f) ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE).Get(), Vector2(1200.0f, 1300.0f), TEST_LOCATION ); + + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSizeX") == ScrollView::Property::SCROLL_DOMAIN_SIZE_X ); + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSizeY") == ScrollView::Property::SCROLL_DOMAIN_SIZE_Y ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_X).Get(), 1200.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_Y).Get(), 1300.0f, TEST_LOCATION ); + scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE_X, 1500.0f ); + scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE_Y, 1600.0f ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_X).Get(), 1500.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_Y).Get(), 1600.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE).Get(), Vector2(1500.0f, 1600.0f), TEST_LOCATION ); + + // Test "scrollDomainOffset" property + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainOffset") == ScrollView::Property::SCROLL_DOMAIN_OFFSET ); + scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_OFFSET, Vector2(500.0f, 200.0f) ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_OFFSET).Get(), Vector2(500.0f, 200.0f), TEST_LOCATION ); + + // Test "scrollPositionDelta" property + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPositionDelta") == ScrollView::Property::SCROLL_POSITION_DELTA ); + scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION_DELTA, Vector2(10.0f, 30.0f) ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_POSITION_DELTA).Get(), Vector2(10.0f, 30.0f), TEST_LOCATION ); + + // Test "startPagePosition" property + DALI_TEST_CHECK( scrollView.GetPropertyIndex("startPagePosition") == ScrollView::Property::START_PAGE_POSITION ); + scrollView.SetProperty( ScrollView::Property::START_PAGE_POSITION, Vector3(50.0f, 100.0f, 20.0f) ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::START_PAGE_POSITION).Get(), Vector3(50.0f, 100.0f, 20.0f), TEST_LOCATION ); + + 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; }