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=cf3e1633b12403e579196936afa57bc91e90502f;hp=587d875e6d88ee5755c98dadbdc6882ed18ff959;hb=2147319a00c4214f7ade93f393b96e691f511464;hpb=e217915091790637a8b4ea7e34480e852d242efd diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp index 587d875..cf3e163 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) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2015 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. @@ -57,7 +57,7 @@ const int CLAMP_STEP_0_CHECK_NOTCLAMPED = 0; ///< FSM: "First 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 Vector3 CLAMP_START_SCROLL_POSITION(30.0f, 100.0f, 0.0f); ///< Scroll start position for the Clamping tests. +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. @@ -65,12 +65,17 @@ const Vector3 TEST_ACTOR_POSITION(100.0f, 100.0f, 0.0f); ///< A Test acto 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 int MAX_FRAMES_TO_TEST_OVERSHOOT = 600; ///< 10 seconds (at 60 frames per second). -const Vector3 OVERSHOOT_START_SCROLL_POSITION(100.0f, 100.0f, 0.0f); ///< Scroll start position for the Overshoot tests. -const float TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION = 0.05f; ///< a Test duration -const float TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION = 1.5f; ///< another Test duration +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 + +const int MAX_FRAMES_TO_TEST_OVERSHOOT = 600; ///< 10 seconds (at 60 frames per second). +const Vector2 OVERSHOOT_START_SCROLL_POSITION(100.0f, 100.0f); ///< Scroll start position for the Overshoot tests. +const float SCROLL_ANIMATION_DURATION(0.33f); ///< Duration of scroll animation in Overshoot tests (i.e. 100 pixels of overshoot in the speed of 500 pixels per 100 frames, 100/(500/(100/60)) = 0.33) +const Vector2 SNAP_POSITION_WITH_DECELERATED_VELOCITY(74.0f, 74.0f); ///< the snap position for Overshoot tests with the decelerated velocity (i.e. Decelerated from 500 pixels per 100 frames). +const float TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION = 0.05f; ///< a Test duration +const float TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION = 1.5f; ///< another Test duration const float TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION = TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * 0.5f; // Same as above, but different alpha function. -const float TIME_TOLERANCE = 0.05f; ///< Allow testing tolerance between a 10th of second (+/- 3 frames) +const float TIME_TOLERANCE = 0.05f; ///< Allow testing tolerance between a 10th of second (+/- 3 frames) // Generate a PanGestureEvent to send to Core @@ -152,7 +157,7 @@ static Vector3 gConstraintResult; ///< Result from constra * * @param[in] position The current scroll position. */ -static void OnScrollStart( const Vector3& position ) +static void OnScrollStart( const Vector2& position ) { gOnScrollStartCalled = true; } @@ -162,7 +167,7 @@ static void OnScrollStart( const Vector3& position ) * * @param[in] position The current scroll position. */ -static void OnScrollUpdate( const Vector3& position ) +static void OnScrollUpdate( const Vector2& position ) { gOnScrollUpdateCalled = true; } @@ -172,7 +177,7 @@ static void OnScrollUpdate( const Vector3& position ) * * @param[in] position The current scroll position. */ -static void OnScrollComplete( const Vector3& position ) +static void OnScrollComplete( const Vector2& position ) { gOnScrollCompleteCalled = true; } @@ -207,25 +212,13 @@ struct TestSumConstraint /** * @param[in] current The current base value - * @param[in] property The property to be added to current. - * @return The new current Vector. - */ - Vector3 operator()(const Vector3& current) - { - gConstraintResult = current + mOffset; - return gConstraintResult; - } - - /** - * @param[in] current The current base value - * @param[in] property The property to be added to current. + * @param[in] inputs Contains the property to be added to current. * @return The new current Vector. */ - Vector3 operator()(const Vector3& current, - const PropertyInput& property) + void operator()( Vector3& current, const PropertyInputContainer& inputs ) { - gConstraintResult = current + property.GetVector3() + mOffset; - return gConstraintResult; + gConstraintResult = current + Vector3(inputs[0]->GetVector2()) + mOffset; + current = gConstraintResult; } Vector3 mOffset; @@ -239,14 +232,11 @@ struct TestSumConstraint */ static float TestOvershootSnapDuration(ToolkitTestApplication &application, ScrollView scrollView) { - Property::Index overshootPropertyX = scrollView.GetPropertyIndex(ScrollView::SCROLL_OVERSHOOT_X_PROPERTY_NAME); - Property::Index overshootPropertyY = scrollView.GetPropertyIndex(ScrollView::SCROLL_OVERSHOOT_Y_PROPERTY_NAME); - int timeToReachOrigin = -1; for(int i = 0;i(overshootPropertyX); - float overshootYValue = scrollView.GetProperty(overshootPropertyY); + float overshootXValue = scrollView.GetProperty(ScrollView::Property::OVERSHOOT_X); + float overshootYValue = scrollView.GetProperty(ScrollView::Property::OVERSHOOT_Y); if(overshootXValue == 0.0f && overshootYValue == 0.0f) { break; @@ -275,10 +265,56 @@ float TestAlphaFunction(float progress) } // unnamed namespace -int UtcDaliScrollViewNew(void) +int UtcDaliToolkitScrollViewConstructorP(void) +{ + ToolkitTestApplication application; + + ScrollView scrollView; + DALI_TEST_CHECK( !scrollView ); + END_TEST; +} + +int UtcDaliToolkitScrollViewCopyConstructorP(void) +{ + ToolkitTestApplication application; + + ScrollView scrollView = ScrollView::New(); + scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f) ); + + ScrollView copy( scrollView ); + DALI_TEST_CHECK( copy ); + DALI_TEST_CHECK( copy.GetProperty( ScrollView::Property::SCROLL_POSITION ) == scrollView.GetProperty( ScrollView::Property::SCROLL_POSITION ) ); + 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; + DALI_TEST_CHECK( copy ); + DALI_TEST_CHECK( copy.GetProperty( ScrollView::Property::SCROLL_POSITION ) == scrollView.GetProperty( ScrollView::Property::SCROLL_POSITION ) ); + END_TEST; +} + +int UtcDaliScrollViewDestructorP(void) +{ + ToolkitTestApplication application; + + ScrollView* scrollView = new ScrollView(); + delete scrollView; + + DALI_TEST_CHECK( true ); + END_TEST; +} + +int UtcDaliToolkitScrollViewNewP(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliScrollViewNew"); + tet_infoline(" UtcDaliToolkitScrollViewNewP"); ScrollView scrollView; @@ -305,10 +341,10 @@ int UtcDaliScrollViewNew(void) END_TEST; } -int UtcDaliScrollViewDownCast(void) +int UtcDaliToolkitScrollViewDownCastP(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliScrollViewDownCast"); + tet_infoline(" UtcDaliToolkitScrollViewDownCastP"); ScrollView scrollView = ScrollView::New(); BaseHandle handle(scrollView); @@ -319,17 +355,17 @@ int UtcDaliScrollViewDownCast(void) END_TEST; } -int UtcDaliScrollViewScrollToPosition(void) +int UtcDaliToolkitScrollViewScrollToPositionP(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliScrollViewScrollToPosition"); + tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionP"); // Create the ScrollView actor ScrollView scrollView = ScrollView::New(); Stage::GetCurrent().Add( scrollView ); - const Vector3 target = Vector3(100.0f, 200.0f, 0.0f); - const Vector3 target2 = Vector3(300.0f, 100.0f, 0.0f); + const Vector2 target = Vector2(100.0f, 200.0f); + const Vector2 target2 = Vector2(300.0f, 100.0f); scrollView.ScrollTo( target, 0.0f ); Wait(application); @@ -338,14 +374,130 @@ int UtcDaliScrollViewScrollToPosition(void) Wait(application, RENDER_DELAY_SCROLL); DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION ); - Wait(application); END_TEST; } -int UtcDaliScrollViewScrollToPage(void) +int UtcDaliToolkitScrollViewScrollToPositionWithDirectionBiasP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithDirectionBiasP"); + + ScrollView scrollView = ScrollView::New(); + Stage::GetCurrent().Add( scrollView ); + RulerPtr rulerX = new FixedRuler( 100.0f ); + rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) ); + RulerPtr rulerY = new FixedRuler( 100.0f ); + rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) ); + + scrollView.SetRulerX( rulerX ); + scrollView.SetRulerY( rulerY ); + + scrollView.SetWrapMode(true); + + const Vector2 target = Vector2(50.0f, 50.0f); + const Vector2 target2 = Vector2(150.0f, 150.0f); + + scrollView.ScrollTo( target, 0.0f ); + Wait(application, RENDER_DELAY_SCROLL); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION ); + + 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 ); + + scrollView.ScrollTo( target, 0.0f ); + Wait(application, RENDER_DELAY_SCROLL); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION ); + + scrollView.ScrollTo( target2, 0.25f, Dali::Toolkit::DirectionBiasRight, Dali::Toolkit::DirectionBiasRight ); + Wait(application, RENDER_DELAY_SCROLL); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionP"); + + // Create the ScrollView actor + ScrollView scrollView = ScrollView::New(); + Stage::GetCurrent().Add( scrollView ); + + const Vector2 target = Vector2(100.0f, 200.0f); + const Vector2 target2 = Vector2(300.0f, 100.0f); + + scrollView.ScrollTo( target, 0.5f, TestAlphaFunction ); + Wait(application, 250); + // Check that the scroll animation should finish within just half of the specified duration with the above alpha function + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION ); + + scrollView.ScrollTo( target2, 0.5f, AlphaFunction::LINEAR ); + Wait(application, 250); + // Check that the scroll animation has not finished within half of the specified duration with the linear alpha function + DALI_TEST_CHECK( scrollView.GetCurrentScrollPosition() != target2 ); + + // Wait till the end of the specified duration + Wait(application, 250); + // Check that the scroll animation has finished + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionAndDirectionBiasP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionAndDirectionBiasP"); + + ScrollView scrollView = ScrollView::New(); + Stage::GetCurrent().Add( scrollView ); + RulerPtr rulerX = new FixedRuler( 100.0f ); + rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) ); + RulerPtr rulerY = new FixedRuler( 100.0f ); + rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) ); + + scrollView.SetRulerX( rulerX ); + scrollView.SetRulerY( rulerY ); + + scrollView.SetWrapMode(true); + + const Vector2 target = Vector2(50.0f, 50.0f); + const Vector2 target2 = Vector2(150.0f, 150.0f); + + scrollView.ScrollTo( target, 0.0f ); + 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 ); + Wait(application, RENDER_DELAY_SCROLL); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2::ZERO, TEST_LOCATION ); + + scrollView.ScrollTo( target, 0.0f ); + 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 ); + Wait(application, RENDER_DELAY_SCROLL); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION ); + + scrollView.ScrollTo( target, 0.0f ); + 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 ); + 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 ); + + END_TEST; +} + +int UtcDaliToolkitScrollViewScrollToPageP(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliScrollViewScrollToPage"); + tet_infoline(" UtcDaliToolkitScrollViewScrollToPageP"); ScrollView scrollView = ScrollView::New(); Stage::GetCurrent().Add( scrollView ); @@ -359,29 +511,29 @@ int UtcDaliScrollViewScrollToPage(void) scrollView.ScrollTo( 1, 0.0f ); Wait(application); - DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(100.0f, 0.0f, 0.0f), TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 0.0f), TEST_LOCATION ); scrollView.ScrollTo( 5, 0.0f ); Wait(application); - DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(500.0f, 0.0f, 0.0f), TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(500.0f, 0.0f), TEST_LOCATION ); scrollView.ScrollTo( 10, 0.0f ); Wait(application); - DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(200.0f, 100.0f, 0.0f), TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(200.0f, 100.0f), TEST_LOCATION ); scrollView.ScrollTo( 15, 0.0f ); Wait(application); - DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(700.0f, 100.0f, 0.0f), TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(700.0f, 100.0f), TEST_LOCATION ); DALI_TEST_EQUALS( static_cast(scrollView.GetCurrentPage()), 15, TEST_LOCATION ); scrollView.ScrollTo( 3 ); Wait(application, RENDER_DELAY_SCROLL); - DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(300.0f, 0.0f, 0.0f), TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(300.0f, 0.0f), TEST_LOCATION ); DALI_TEST_EQUALS( static_cast(scrollView.GetCurrentPage()), 3, TEST_LOCATION ); scrollView.ScrollTo( 9 ); Wait(application, RENDER_DELAY_SCROLL); - DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(100.0f, 100.0f, 0.0f), TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 100.0f), TEST_LOCATION ); DALI_TEST_EQUALS( static_cast(scrollView.GetCurrentPage()), 9, TEST_LOCATION ); // Apply DefaultRulers instead and see what happens. @@ -396,17 +548,58 @@ int UtcDaliScrollViewScrollToPage(void) // This time should always scroll to origin (0.0f, 0.0f) scrollView.ScrollTo( 1, 0.0f ); Wait(application); - DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION ); DALI_TEST_EQUALS( static_cast(scrollView.GetCurrentPage()), 0, TEST_LOCATION ); - Wait(application); END_TEST; } -int UtcDaliScrollViewScrollToActor(void) +int UtcDaliToolkitScrollViewScrollToPageWithDirectionBiasP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewScrollToPageWithDirectionBiasP"); + + ScrollView scrollView = ScrollView::New(); + Stage::GetCurrent().Add( scrollView ); + RulerPtr rulerX = new FixedRuler( 100.0f ); + rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) ); + RulerPtr rulerY = new FixedRuler( 100.0f ); + rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) ); + + scrollView.SetRulerX( rulerX ); + scrollView.SetRulerY( rulerY ); + + scrollView.SetWrapMode(true); + + scrollView.ScrollTo( 0, 0.25, Dali::Toolkit::DirectionBiasLeft ); + + Wait(application, RENDER_FRAME_INTERVAL); // Wait for one frame + // Check that the scroll position remains the same + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION ); + + Wait(application, RENDER_DELAY_SCROLL); // Wait for one second + // Check that it stays at the same page (i.e. the same scroll position) + DALI_TEST_EQUALS( static_cast(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 ); + + Wait(application, RENDER_FRAME_INTERVAL); // Wait for one frame + // Check that it scrolls towards the right + DALI_TEST_CHECK( scrollView.GetCurrentScrollPosition().x > 0.0f ); + + Wait(application, RENDER_DELAY_SCROLL); // Wait for one second + // Check that it scrolls back to the same page (i.e. the same scroll position) + DALI_TEST_EQUALS( static_cast(scrollView.GetCurrentPage()), 0, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliToolkitScrollViewScrollToActorP(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliScrollViewScrollToActor"); + tet_infoline(" UtcDaliToolkitScrollViewScrollToActorP"); ScrollView scrollView = ScrollView::New(); Stage::GetCurrent().Add( scrollView ); @@ -425,27 +618,27 @@ int UtcDaliScrollViewScrollToActor(void) scrollView.ScrollTo(actorA, 0.0f); Wait(application); - DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA.GetVectorXY(), TEST_LOCATION ); Wait(application); scrollView.ScrollTo(actorB, 0.0f); Wait(application); - DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB.GetVectorXY(), TEST_LOCATION ); scrollView.ScrollTo(actorA); Wait(application, RENDER_DELAY_SCROLL); - DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA.GetVectorXY(), TEST_LOCATION ); scrollView.ScrollTo(actorB); Wait(application, RENDER_DELAY_SCROLL); - DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB.GetVectorXY(), TEST_LOCATION ); END_TEST; } -int UtcDaliScrollViewScrollToSnapPoint(void) +int UtcDaliToolkitScrollViewScrollToSnapPointP(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliScrollViewScrollToSnapPoint"); + tet_infoline(" UtcDaliToolkitScrollViewScrollToSnapPointP"); ScrollView scrollView = ScrollView::New(); Stage::GetCurrent().Add( scrollView ); @@ -457,21 +650,21 @@ int UtcDaliScrollViewScrollToSnapPoint(void) scrollView.SetRulerX( rulerX ); scrollView.SetRulerY( rulerY ); - scrollView.ScrollTo( Vector3(120.0f, 190.0f, 0.0f), 0.0f ); + scrollView.ScrollTo( Vector2(120.0f, 190.0f), 0.0f ); Wait(application); - DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(120.0f, 190.0f, 0.0f), TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(120.0f, 190.0f), TEST_LOCATION ); scrollView.ScrollToSnapPoint(); Wait(application, RENDER_DELAY_SCROLL); - DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(100.0f, 200.0f, 0.0f), TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 200.0f), TEST_LOCATION ); END_TEST; } -int UtcDaliScrollViewSetScrollUpdateDistance(void) +int UtcDaliToolkitScrollViewSetScrollUpdateDistanceP(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliScrollViewRefreshInterval"); + tet_infoline(" UtcDaliToolkitScrollViewSetScrollUpdateDistanceP"); ScrollView scrollView = ScrollView::New(); @@ -484,14 +677,17 @@ int UtcDaliScrollViewSetScrollUpdateDistance(void) END_TEST; } -int UtcDaliScrollViewWrapMode(void) +int UtcDaliToolkitScrollViewSetWrapModeP(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliScrollViewWrapMode"); + tet_infoline(" UtcDaliToolkitScrollViewSetWrapModeP"); ScrollView scrollView = ScrollView::New(); Stage::GetCurrent().Add( scrollView ); + Actor actor = Actor::New(); + scrollView.Add( actor ); + // Position rulers. 4x4 grid. RulerPtr rulerX = new FixedRuler(50.0f); RulerPtr rulerY = new FixedRuler(50.0f); @@ -501,18 +697,21 @@ int UtcDaliScrollViewWrapMode(void) scrollView.SetRulerY(rulerY); scrollView.SetWrapMode(false); - scrollView.ScrollTo(Vector3(225.0f, 125.0f, 0.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped) + scrollView.ScrollTo(Vector2(225.0f, 125.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped) Wait(application); DALI_TEST_EQUALS( static_cast(scrollView.GetCurrentPage()), 17, TEST_LOCATION ); + scrollView.SetWrapMode(true); + scrollView.ScrollTo(Vector2(230.0f, 130.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped) + Wait(application); DALI_TEST_EQUALS( static_cast(scrollView.GetCurrentPage()), 13, TEST_LOCATION ); END_TEST; } -int UtcDaliScrollViewActorAutoSnap(void) +int UtcDaliToolkitScrollViewActorAutoSnap(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliScrollViewActorAutoSnap"); + tet_infoline(" UtcDaliToolkitScrollViewActorAutoSnap"); ScrollView scrollView = ScrollView::New(); Stage::GetCurrent().Add( scrollView ); @@ -536,7 +735,7 @@ int UtcDaliScrollViewActorAutoSnap(void) b.SetPosition(bPosition); // Goto a random position, and execute snap (should not move) - Vector3 targetScroll = Vector3(500.0f, 500.0f, 0.0f); + Vector2 targetScroll = Vector2(500.0f, 500.0f); scrollView.ScrollTo(targetScroll, 0.0f); Wait(application); scrollView.ScrollToSnapPoint(); @@ -547,20 +746,20 @@ int UtcDaliScrollViewActorAutoSnap(void) scrollView.SetActorAutoSnap(true); scrollView.ScrollToSnapPoint(); Wait(application, RENDER_DELAY_SCROLL); - DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), bPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), bPosition.GetVectorXY(), TEST_LOCATION ); - scrollView.ScrollTo(Vector3(0.0f, 0.0f, 0.0f), 0.0f); + scrollView.ScrollTo(Vector2(0.0f, 0.0f), 0.0f); Wait(application); scrollView.ScrollToSnapPoint(); Wait(application, RENDER_DELAY_SCROLL); - DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), aPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), aPosition.GetVectorXY(), TEST_LOCATION ); END_TEST; } -int UtcDaliScrollViewSignalsStartComplete(void) +int UtcDaliToolkitScrollViewSignalsStartComplete(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliScrollViewSignalsStartComplete"); + tet_infoline(" UtcDaliToolkitScrollViewSignalsStartComplete"); gOnScrollStartCalled = false; gOnScrollCompleteCalled = false; @@ -578,7 +777,7 @@ int UtcDaliScrollViewSignalsStartComplete(void) scrollView.ScrollStartedSignal().Connect( &OnScrollStart ); scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate ); scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete ); - scrollView.ScrollTo( Vector3(100.0f, 100.0f, 0.0f) ); + scrollView.ScrollTo( Vector2(100.0f, 100.0f) ); Wait(application, RENDER_DELAY_SCROLL); DALI_TEST_CHECK(gOnScrollStartCalled); @@ -586,10 +785,10 @@ int UtcDaliScrollViewSignalsStartComplete(void) END_TEST; } -int UtcDaliScrollViewSignalsUpdate(void) +int UtcDaliToolkitScrollViewSignalsUpdate(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliScrollViewSignalsUpdate"); + tet_infoline(" UtcDaliToolkitScrollViewSignalsUpdate"); gOnScrollStartCalled = false; gOnScrollUpdateCalled = false; @@ -676,10 +875,10 @@ static Vector2 PerformGestureDiagonalSwipe(ToolkitTestApplication& application, return pos; } -int UtcDaliScrollViewScrollSensitive(void) +int UtcDaliToolkitScrollViewScrollSensitive(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliScrollViewScrollSensitive"); + tet_infoline(" UtcDaliToolkitScrollViewScrollSensitive"); // Set up a scrollView... ScrollView scrollView = ScrollView::New(); @@ -722,10 +921,10 @@ int UtcDaliScrollViewScrollSensitive(void) END_TEST; } -int UtcDaliScrollViewAxisAutoLock(void) +int UtcDaliToolkitScrollViewAxisAutoLock(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliScrollViewAxisAutoLock"); + tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLock"); // Set up a scrollView... ScrollView scrollView = ScrollView::New(); @@ -747,20 +946,20 @@ int UtcDaliScrollViewAxisAutoLock(void) scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete ); // Normal - scrollView.ScrollTo(Vector3(100.0f, 100.0f, 0.0f), 0.0f); // move in a little. + scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little. Wait(application); - Vector3 startPosition = scrollView.GetCurrentScrollPosition(); + Vector2 startPosition = scrollView.GetCurrentScrollPosition(); PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(5.0f, 1.0f), 50, true); // mostly horizontal - const Vector3 positionAfterNormal = scrollView.GetCurrentScrollPosition(); + const Vector2 positionAfterNormal = scrollView.GetCurrentScrollPosition(); // Autolock scrollView.SetAxisAutoLock(true); DALI_TEST_CHECK(scrollView.GetAxisAutoLock()); - scrollView.ScrollTo(Vector3(100.0f, 100.0f, 0.0f), 0.0f); // move in a little. + scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little. Wait(application); PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(5.0f, 1.0f), 50, true); // mostly horizontal - const Vector3 positionAfterAutoLock = scrollView.GetCurrentScrollPosition(); + const Vector2 positionAfterAutoLock = scrollView.GetCurrentScrollPosition(); // compare how much the Y position has deviated for normal and autolock. const float devianceNormal = fabsf(startPosition.y - positionAfterNormal.y); @@ -774,10 +973,10 @@ int UtcDaliScrollViewAxisAutoLock(void) END_TEST; } -int UtcDaliScrollViewAxisAutoLockGradient(void) +int UtcDaliToolkitScrollViewAxisAutoLockGradient(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliScrollViewAxisAutoLockGradient"); + tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLockGradient"); // Set up a scrollView... ScrollView scrollView = ScrollView::New(); @@ -788,10 +987,10 @@ int UtcDaliScrollViewAxisAutoLockGradient(void) END_TEST; } -int UtcDaliScrollViewConstraints(void) +int UtcDaliToolkitScrollViewConstraints(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliScrollViewConstraints"); + tet_infoline(" UtcDaliToolkitScrollViewConstraints"); // Set up a scrollView... ScrollView scrollView = ScrollView::New(); @@ -817,10 +1016,8 @@ int UtcDaliScrollViewConstraints(void) a.SetPosition( TEST_ACTOR_POSITION ); Wait(application); - Property::Index scrollPositionProperty = scrollView.GetPropertyIndex(ScrollView::SCROLL_POSITION_PROPERTY_NAME); - Constraint constraint = Constraint::New( Actor::POSITION, - Source(scrollView, scrollPositionProperty), - TestSumConstraint( TEST_CONSTRAINT_OFFSET ) ); + Constraint constraint = Constraint::New( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) ); + constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) ); constraint.SetRemoveAction(Constraint::Discard); scrollView.ApplyConstraintToChildren(constraint); Wait(application); @@ -835,10 +1032,10 @@ int UtcDaliScrollViewConstraints(void) END_TEST; } -int UtcDaliScrollViewBind(void) +int UtcDaliToolkitScrollViewBind(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliScrollViewBind"); + tet_infoline(" UtcDaliToolkitScrollViewBind"); // Set up a scrollView... ScrollView scrollView = ScrollView::New(); @@ -865,12 +1062,9 @@ int UtcDaliScrollViewBind(void) a.SetPosition( TEST_ACTOR_POSITION ); Wait(application); - Property::Index scrollPositionProperty = scrollView.GetPropertyIndex(ScrollView::SCROLL_POSITION_PROPERTY_NAME); // apply this constraint to scrollview - Constraint constraint = Constraint::New( Actor::POSITION, - Source(scrollView, scrollPositionProperty), - TestSumConstraint( TEST_CONSTRAINT_OFFSET ) ); - + Constraint constraint = Constraint::New( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) ); + constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) ); constraint.SetRemoveAction(Constraint::Discard); scrollView.ApplyConstraintToChildren(constraint); @@ -892,122 +1086,10 @@ int UtcDaliScrollViewBind(void) END_TEST; } -int UtcDaliRulerEnableDisable(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliRulerEnableDisable"); - - RulerPtr ruler = new DefaultRuler(); - - DALI_TEST_CHECK( ruler->IsEnabled() ); - ruler->Disable(); - DALI_TEST_CHECK( !ruler->IsEnabled() ); - ruler->Enable(); - DALI_TEST_CHECK( ruler->IsEnabled() ); - END_TEST; -} - -int UtcDaliRulerDomainEnableDisable(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliRulerDomainEnableDisable"); - - RulerPtr ruler = new DefaultRuler(); - DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION ); - - - ruler->SetDomain( RulerDomain(0.0f, 100.0f, true) ); - DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 100.0f, TEST_LOCATION ); - DALI_TEST_EQUALS( ruler->Clamp(-200.0f), 0.0f, TEST_LOCATION ); - DALI_TEST_EQUALS( ruler->Clamp(200.0f), 100.0f, TEST_LOCATION ); - - ruler->DisableDomain(); - DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION ); - DALI_TEST_EQUALS( ruler->Clamp(-200.0f), -200.0f, TEST_LOCATION ); - DALI_TEST_EQUALS( ruler->Clamp(200.0f), 200.0f, TEST_LOCATION ); - END_TEST; -} - -int UtcDaliRulerSnapAndClamp(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliRulerSnapAndClamp"); - - RulerPtr ruler = new FixedRuler( 50.0f ); - ruler->SetDomain( RulerDomain(0.0f, 400.0f, true) ); - - // default testing. (snap and clamp) - DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f), 50.0f, TEST_LOCATION); - DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f), 50.0f, TEST_LOCATION); - DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f), 0.0f, TEST_LOCATION); - DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f), 0.0f, TEST_LOCATION); - DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f), 400.0f, TEST_LOCATION); - DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f), 400.0f, TEST_LOCATION); - - // bias testing. - DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left - DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.5f), 50.0f, TEST_LOCATION); // No Flick - DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right - - DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left - DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.5f), 0.0f, TEST_LOCATION); // No Flick - DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right - - // length testing. - DALI_TEST_EQUALS( ruler->SnapAndClamp(-10.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (over left boundary) - DALI_TEST_EQUALS( ruler->SnapAndClamp(-5.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (slightly ovr left boundary) - DALI_TEST_EQUALS( ruler->SnapAndClamp(300.0f, 0.5f, 10.0f), 300.0f, TEST_LOCATION); // 10 units long (not over a boundary) - DALI_TEST_EQUALS( ruler->SnapAndClamp(395.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (slightly over right boundary) - DALI_TEST_EQUALS( ruler->SnapAndClamp(500.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (over right boundary) - - // scale testing. - DALI_TEST_EQUALS( ruler->SnapAndClamp(-100.0f, 0.5f, 0.0f, 2.0f), 0.0f, TEST_LOCATION); - DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 2.0f), 50.0f, TEST_LOCATION); - DALI_TEST_EQUALS( ruler->SnapAndClamp(700.0f, 0.5f, 0.0f, 2.0f), 700.0f, TEST_LOCATION); - DALI_TEST_EQUALS( ruler->SnapAndClamp(850.0f, 0.5f, 0.0f, 2.0f), 800.0f, TEST_LOCATION); - - // 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( 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( 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( 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( 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( ruler->SnapAndClamp(430.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION); - DALI_TEST_EQUALS( clamped, ClampedToMax, TEST_LOCATION ); - END_TEST; -} - -int UtcDaliRulerFixedRulerSpacing(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliRulerFixedRulerSpacing"); - - RulerPtr rulerNormal = new FixedRuler( 25.0f ); - rulerNormal->SetDomain( RulerDomain(10.0f, 90.0f, true) ); - - unsigned int volume; - float position; - - position = rulerNormal->GetPositionFromPage(1, volume, true); - DALI_TEST_EQUALS( position, 35.0f, TEST_LOCATION ); - DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION ); - - position = rulerNormal->GetPositionFromPage(2, volume, true); - DALI_TEST_EQUALS( position, 60.0f, TEST_LOCATION ); - DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION ); - END_TEST; -} - -int UtcDaliScrollViewOvershoot(void) +int UtcDaliToolkitScrollViewOvershoot(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliScrollViewOvershoot"); + tet_infoline(" UtcDaliToolkitScrollViewOvershoot"); // Set up a scrollView... ScrollView scrollView = ScrollView::New(); @@ -1034,15 +1116,12 @@ int UtcDaliScrollViewOvershoot(void) // 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); - Property::Index overshootXProperty = scrollView.GetPropertyIndex(ScrollView::SCROLL_OVERSHOOT_X_PROPERTY_NAME); - Property::Index overshootYProperty = scrollView.GetPropertyIndex(ScrollView::SCROLL_OVERSHOOT_Y_PROPERTY_NAME); - Property::Index scrollPositionProperty = scrollView.GetPropertyIndex(ScrollView::SCROLL_POSITION_PROPERTY_NAME); - float overshootXValue = scrollView.GetProperty(overshootXProperty); - float overshootYValue = scrollView.GetProperty(overshootYProperty); - Vector3 positionValue = scrollView.GetProperty(scrollPositionProperty); + float overshootXValue = scrollView.GetProperty(ScrollView::Property::OVERSHOOT_X); + float overshootYValue = scrollView.GetProperty(ScrollView::Property::OVERSHOOT_Y); + Vector2 positionValue = scrollView.GetProperty(ScrollView::Property::SCROLL_POSITION); DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION); DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION); - DALI_TEST_EQUALS(positionValue, Vector3::ZERO, TEST_LOCATION); + DALI_TEST_EQUALS(positionValue, Vector2::ZERO, TEST_LOCATION); float timeToReachOrigin; @@ -1050,8 +1129,11 @@ int UtcDaliScrollViewOvershoot(void) SendPan(application, Gesture::Finished, currentPos); timeToReachOrigin = TestOvershootSnapDuration(application, scrollView); - DALI_TEST_CHECK( (timeToReachOrigin > Toolkit::ScrollView::DEFAULT_SNAP_OVERSHOOT_DURATION - TIME_TOLERANCE) && - (timeToReachOrigin < Toolkit::ScrollView::DEFAULT_SNAP_OVERSHOOT_DURATION + TIME_TOLERANCE) ); + float minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE; + float maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE; + + DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) && + (timeToReachOrigin < maxTimeToReachOrigin) ); // 2. Repeat Scroll, but this time change overshoot snap duration to shorter time scrollView.SetSnapOvershootDuration(TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION); @@ -1061,8 +1143,11 @@ int UtcDaliScrollViewOvershoot(void) SendPan(application, Gesture::Finished, currentPos); timeToReachOrigin = TestOvershootSnapDuration(application, scrollView); - DALI_TEST_CHECK( (timeToReachOrigin > TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION - TIME_TOLERANCE) && - (timeToReachOrigin < TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION + TIME_TOLERANCE) ); + minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE; + maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE; + + DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) && + (timeToReachOrigin < maxTimeToReachOrigin) ); // 3. Repeat Scroll, but this time change overshoot snap duration to longer time. scrollView.SetSnapOvershootDuration(TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION); @@ -1072,8 +1157,11 @@ int UtcDaliScrollViewOvershoot(void) SendPan(application, Gesture::Finished, currentPos); timeToReachOrigin = TestOvershootSnapDuration(application, scrollView); - DALI_TEST_CHECK( (timeToReachOrigin > TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION - TIME_TOLERANCE) && - (timeToReachOrigin < TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION + TIME_TOLERANCE) ); + minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE; + maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE; + + DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) && + (timeToReachOrigin < maxTimeToReachOrigin) ); // 4. Repeat Scroll, but this time change overshoot function. scrollView.SetSnapOvershootDuration(TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION); @@ -1084,34 +1172,36 @@ int UtcDaliScrollViewOvershoot(void) SendPan(application, Gesture::Finished, currentPos); timeToReachOrigin = TestOvershootSnapDuration(application, scrollView); - DALI_TEST_CHECK( (timeToReachOrigin > TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION - TIME_TOLERANCE) && - (timeToReachOrigin < TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION + TIME_TOLERANCE) ); + minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE; + maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE; + + DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) && + (timeToReachOrigin < maxTimeToReachOrigin) ); END_TEST; } -int UtcDaliScrollViewSnapAlphaFunction(void) +int UtcDaliToolkitScrollViewSnapAlphaFunction(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliScrollViewSnapAlphaFunction"); + tet_infoline(" UtcDaliToolkitScrollViewSnapAlphaFunction"); // Set up a scrollView... ScrollView scrollView = ScrollView::New(); - scrollView.SetScrollSnapAlphaFunction( AlphaFunctions::EaseIn ); - DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction() == AlphaFunctions::EaseIn ); - scrollView.SetScrollSnapAlphaFunction( AlphaFunctions::EaseOut ); - DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction() == AlphaFunctions::EaseOut ); + scrollView.SetScrollSnapAlphaFunction( AlphaFunction::EASE_IN ); + DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction().GetBuiltinFunction() == AlphaFunction::EASE_IN ); + scrollView.SetScrollSnapAlphaFunction( AlphaFunction::EASE_OUT ); + DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction().GetBuiltinFunction() == AlphaFunction::EASE_OUT ); + + scrollView.SetScrollFlickAlphaFunction( AlphaFunction::BOUNCE ); + DALI_TEST_CHECK( scrollView.GetScrollFlickAlphaFunction().GetBuiltinFunction() == AlphaFunction::BOUNCE ); - scrollView.SetScrollFlickAlphaFunction( AlphaFunctions::Bounce ); - DALI_TEST_CHECK( scrollView.GetScrollFlickAlphaFunction() == AlphaFunctions::Bounce ); - scrollView.SetScrollFlickAlphaFunction( AlphaFunctions::BounceBack ); - DALI_TEST_CHECK( scrollView.GetScrollFlickAlphaFunction() == AlphaFunctions::BounceBack ); END_TEST; } -int UtcDaliScrollViewSnapDuration(void) +int UtcDaliToolkitScrollViewSnapDuration(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliScrollViewSnapDuration"); + tet_infoline(" UtcDaliToolkitScrollViewSnapDuration"); // Set up a scrollView... ScrollView scrollView = ScrollView::New(); @@ -1127,10 +1217,10 @@ int UtcDaliScrollViewSnapDuration(void) END_TEST; } -int UtcDaliScrollViewSignalsSnapStart(void) +int UtcDaliToolkitScrollViewSnapStartedSignalP(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliScrollViewSignalsSnapStart"); + tet_infoline(" UtcDaliToolkitScrollViewSnapStartedSignalP"); // Set up a scrollView... ScrollView scrollView = ScrollView::New(); @@ -1166,32 +1256,1032 @@ int UtcDaliScrollViewSignalsSnapStart(void) END_TEST; } +int UtcDaliToolkitScrollViewGetCurrentPageP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewGetCurrentPageP"); + + ScrollView scrollView = ScrollView::New(); + Stage::GetCurrent().Add( scrollView ); + RulerPtr rulerX = new FixedRuler( 100.0f ); + rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) ); + RulerPtr rulerY = new FixedRuler( 100.0f ); + rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) ); + + scrollView.SetRulerX( rulerX ); + scrollView.SetRulerY( rulerY ); + + scrollView.ScrollTo( 15 ); + Wait(application, RENDER_DELAY_SCROLL); + DALI_TEST_EQUALS( static_cast(scrollView.GetCurrentPage()), 15, TEST_LOCATION ); + + scrollView.ScrollTo( 3 ); + Wait(application, RENDER_DELAY_SCROLL); + DALI_TEST_EQUALS( static_cast(scrollView.GetCurrentPage()), 3, TEST_LOCATION ); + + scrollView.ScrollTo( 9 ); + Wait(application, RENDER_DELAY_SCROLL); + DALI_TEST_EQUALS( static_cast(scrollView.GetCurrentPage()), 9, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliToolkitScrollViewSetMaxOvershootP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewSetMaxOvershootP"); + + // 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); + + // Position rulers. + RulerPtr rulerX = new DefaultRuler(); + RulerPtr rulerY = new DefaultRuler(); + rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) ); + rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) ); + scrollView.SetRulerX(rulerX); + scrollView.SetRulerY(rulerY); + + // Set the max overshoot to be 50 pixels in both X axis and Y axis + scrollView.SetMaxOvershoot(50.0f, 50.0f); + + scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little. + 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); + DALI_TEST_EQUALS(overshootXValue, 0.0f, TEST_LOCATION); + DALI_TEST_EQUALS(overshootYValue, 0.0f, TEST_LOCATION); + + // 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); + // 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; + 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); + 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); + + // Check that overshoot should be now around 0.8. + overshootXValue = scrollView.GetProperty(ScrollView::Property::OVERSHOOT_X); + overshootYValue = scrollView.GetProperty(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); + DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION); + DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliToolkitScrollViewSetScrollingDirectionP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewSetScrollingDirectionP"); + + // 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); + + Vector2 START_POSITION = Vector2(10.0f, 10.0f); + + scrollView.ScrollTo(START_POSITION, 0.0f); + 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. + 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); + // Try a vertical swipe. + PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), START_POSITION, TEST_LOCATION ); + + scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL); + + scrollView.ScrollTo(Vector2(10.0f, 10.0f), 0.0f); + Wait(application); + // Try a vertical swipe. + PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliToolkitScrollViewRemoveScrollingDirectionP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewRemoveScrollingDirectionP"); + + // 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); + + Vector2 START_POSITION = Vector2(10.0f, 10.0f); + + 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); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), START_POSITION, TEST_LOCATION ); + + scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL); + + scrollView.ScrollTo(Vector2(10.0f, 10.0f), 0.0f); + 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. + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliToolkitScrollViewSetRulerXP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewSetRulerXP"); + + ScrollView scrollView = ScrollView::New(); + Stage::GetCurrent().Add( scrollView ); + RulerPtr rulerX = new FixedRuler( 100.0f ); + rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) ); + + scrollView.SetRulerX( rulerX ); + + scrollView.ScrollTo( 1, 0.0f ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 0.0f), TEST_LOCATION ); + + RulerPtr newRulerX = new FixedRuler( 200.0f ); + newRulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) ); + + scrollView.SetRulerX( newRulerX ); + + scrollView.ScrollTo( 1, 0.0f ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(200.0f, 0.0f), TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliToolkitScrollViewSetRulerYP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewSetRulerYP"); + + ScrollView scrollView = ScrollView::New(); + Stage::GetCurrent().Add( scrollView ); + + RulerPtr rulerY = new FixedRuler( 200.0f ); + rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) ); + + scrollView.SetRulerY( rulerY ); + + scrollView.ScrollTo( Vector2(0.0f, 350.0f), 0.0f ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 350.0f), TEST_LOCATION ); + + RulerPtr newRulerY = new FixedRuler( 100.0f ); + newRulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) ); + scrollView.SetRulerY( newRulerY ); + + scrollView.ScrollTo( Vector2(0.0f, 350.0f), 0.0f ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 200.0f), TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliToolkitScrollViewSetMinimumSpeedForFlickP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewSetMinimumSpeedForFlickP"); + + ScrollView scrollView = ScrollView::New(); + scrollView.SetMinimumSpeedForFlick(25.0f); + DALI_TEST_EQUALS( scrollView.GetMinimumSpeedForFlick(), 25.0f, TEST_LOCATION ); + scrollView.SetMinimumSpeedForFlick(60.0f); + DALI_TEST_EQUALS( scrollView.GetMinimumSpeedForFlick(), 60.0f, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliToolkitScrollViewSetMinimumDistanceForFlickP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewSetMinimumDistanceForFlick"); + + ScrollView scrollView = ScrollView::New(); + + scrollView.SetMinimumDistanceForFlick(Vector2(30.0f, 15.0f)); + DALI_TEST_EQUALS( scrollView.GetMinimumDistanceForFlick(), Vector2(30.0f, 15.0f), TEST_LOCATION ); + scrollView.SetMinimumDistanceForFlick(Vector2(60.0f, 30.0f)); + DALI_TEST_EQUALS( scrollView.GetMinimumDistanceForFlick(), Vector2(60.0f, 30.0f), TEST_LOCATION); + END_TEST; +} -int UtcDaliScrollViewSetMouseWheelScrollDistanceStep(void) +int UtcDaliToolkitScrollViewSetWheelScrollDistanceStepP(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliScrollViewSetMouseWheelScrollDistanceStep"); + tet_infoline(" UtcDaliToolkitScrollViewSetWheelScrollDistanceStepP"); ScrollView scrollView = ScrollView::New(); // Disable Refresh signal (TET environment cannot use adaptor's Timer) - scrollView.SetMouseWheelScrollDistanceStep(Vector2(30.0f, 15.0f)); - DALI_TEST_EQUALS( scrollView.GetMouseWheelScrollDistanceStep(), Vector2(30.0f, 15.0f), TEST_LOCATION ); - scrollView.SetMouseWheelScrollDistanceStep(Vector2(60.0f, 30.0f)); - DALI_TEST_EQUALS( scrollView.GetMouseWheelScrollDistanceStep(), Vector2(60.0f, 30.0f), TEST_LOCATION); + scrollView.SetWheelScrollDistanceStep(Vector2(30.0f, 15.0f)); + DALI_TEST_EQUALS( scrollView.GetWheelScrollDistanceStep(), Vector2(30.0f, 15.0f), TEST_LOCATION ); + scrollView.SetWheelScrollDistanceStep(Vector2(60.0f, 30.0f)); + DALI_TEST_EQUALS( scrollView.GetWheelScrollDistanceStep(), Vector2(60.0f, 30.0f), TEST_LOCATION); END_TEST; } -int UtcDaliScrollViewGetSet(void) +int UtcDaliToolkitScrollViewApplyEffectP(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliScrollViewGetSet"); + tet_infoline(" UtcDaliToolkitScrollViewApplyEffectP"); + + // Create a ScrollView ScrollView scrollView = ScrollView::New(); - scrollView.SetMaxOvershoot(50.0f, 50.0f); - scrollView.SetMaxFlickSpeed(0.5f); - DALI_TEST_EQUALS(scrollView.GetMaxFlickSpeed(), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION); - scrollView.SetFrictionCoefficient(0.6f); - DALI_TEST_EQUALS(scrollView.GetFrictionCoefficient(), 0.6f, Math::MACHINE_EPSILON_0, TEST_LOCATION); - scrollView.SetFlickSpeedCoefficient(0.7f); - DALI_TEST_EQUALS(scrollView.GetFlickSpeedCoefficient(), 0.7f, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + // Create two scroll view effects + Dali::Path path = Dali::Path::New(); + ScrollViewEffect effect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 0.0f, 0.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(100.0f, 100.0f, 0.0f), 2); + ScrollViewEffect newEffect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 1.0f, 1.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(200.0f, 150.0f, 0.0f), 5); + + // Apply both effects + scrollView.ApplyEffect(effect); + scrollView.ApplyEffect(newEffect); + + DALI_TEST_CHECK( true ); + + END_TEST; +} + +int UtcDaliToolkitScrollViewApplyEffectN(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewApplyEffectN"); + + // Create a ScrollView + ScrollView scrollView = ScrollView::New(); + + // Create two scroll view effects + Dali::Path path = Dali::Path::New(); + ScrollViewEffect effect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 0.0f, 0.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(100.0f, 100.0f, 0.0f), 2); + ScrollViewEffect newEffect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 1.0f, 1.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(200.0f, 150.0f, 0.0f), 5); + + // Apply both effects + scrollView.ApplyEffect(effect); + scrollView.ApplyEffect(newEffect); + + // Attempt to apply the same effect again + try + { + scrollView.ApplyEffect(newEffect); + tet_result( TET_FAIL ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION ); + } + + END_TEST; +} + +int UtcDaliToolkitScrollViewRemoveEffectP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectP"); + + // Create a ScrollView + ScrollView scrollView = ScrollView::New(); + + // Create two scroll view effects + Dali::Path path = Dali::Path::New(); + ScrollViewEffect effect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 0.0f, 0.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(100.0f, 100.0f, 0.0f), 2); + ScrollViewEffect newEffect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 1.0f, 1.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(200.0f, 150.0f, 0.0f), 5); + + // Apply both effects + scrollView.ApplyEffect(effect); + scrollView.ApplyEffect(newEffect); + + // Remove both effects + scrollView.RemoveEffect(effect); + scrollView.RemoveEffect(newEffect); + + DALI_TEST_CHECK( true ); + + END_TEST; +} + +int UtcDaliToolkitScrollViewRemoveEffectN(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectN"); + + // Create a ScrollView + ScrollView scrollView = ScrollView::New(); + + // Create two scroll view effects + Dali::Path path = Dali::Path::New(); + ScrollViewEffect effect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 0.0f, 0.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(100.0f, 100.0f, 0.0f), 2); + ScrollViewEffect newEffect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 1.0f, 1.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(200.0f, 150.0f, 0.0f), 5); + + // Apply the first effect + scrollView.ApplyEffect(effect); + + // Attempt to remove the second effect which has not been applied to scroll view + try + { + scrollView.RemoveEffect(newEffect); + tet_result( TET_FAIL ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT( e, "effectExistedInScrollView", TEST_LOCATION ); + } + + END_TEST; +} + +int UtcDaliToolkitScrollViewRemoveAllEffectsP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsP"); + + // Create a ScrollView + ScrollView scrollView = ScrollView::New(); + + // Create two scroll view effects + Dali::Path path = Dali::Path::New(); + ScrollViewEffect effect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 0.0f, 0.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(100.0f, 100.0f, 0.0f), 2); + ScrollViewEffect newEffect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 1.0f, 1.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(200.0f, 150.0f, 0.0f), 5); + + // Apply both effects + scrollView.ApplyEffect(effect); + scrollView.ApplyEffect(newEffect); + + // Attempt to apply the same first effect again + try + { + scrollView.ApplyEffect(effect); + tet_result( TET_FAIL ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION ); + } + + // Remove both effects + scrollView.RemoveAllEffects(); + + // Apply both effects again + scrollView.ApplyEffect(effect); + scrollView.ApplyEffect(newEffect); + + DALI_TEST_CHECK( true ); + + END_TEST; +} + +int UtcDaliToolkitScrollViewRemoveAllEffectsN(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsN"); + + // Create a ScrollView + ScrollView scrollView = ScrollView::New(); + + // Remove effects when there is no effect applied previously + scrollView.RemoveAllEffects(); + + DALI_TEST_CHECK( true ); + + END_TEST; +} + +int UtcDaliToolkitScrollViewSetOvershootEnabledP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEnabledP"); + + ScrollView scrollView = ScrollView::New(); + + scrollView.SetOvershootEnabled(true); + DALI_TEST_CHECK(scrollView.IsOvershootEnabled()); + + scrollView.SetOvershootEnabled(false); + DALI_TEST_CHECK(!scrollView.IsOvershootEnabled()); + + END_TEST; +} + +int UtcDaliToolkitScrollViewSetOvershootEffectColorP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEffectColorP"); + + ScrollView scrollView = ScrollView::New(); + + scrollView.SetOvershootEffectColor(Dali::Color::RED); + DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::RED, TEST_LOCATION); + + scrollView.SetOvershootEffectColor(Dali::Color::YELLOW); + DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::YELLOW, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP"); + + ScrollView scrollView = ScrollView::New(); + + scrollView.SetOvershootAnimationSpeed(55.0f); + DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 55.0f, TEST_LOCATION); + + scrollView.SetOvershootAnimationSpeed(120.0f); + DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 120.0f, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliToolkitScrollViewGetSet(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewGetSet"); + ScrollView scrollView = ScrollView::New(); + scrollView.SetMaxFlickSpeed(0.5f); + DALI_TEST_EQUALS(scrollView.GetMaxFlickSpeed(), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION); + scrollView.SetFrictionCoefficient(0.6f); + DALI_TEST_EQUALS(scrollView.GetFrictionCoefficient(), 0.6f, Math::MACHINE_EPSILON_0, TEST_LOCATION); + scrollView.SetFlickSpeedCoefficient(0.7f); + DALI_TEST_EQUALS(scrollView.GetFlickSpeedCoefficient(), 0.7f, Math::MACHINE_EPSILON_0, TEST_LOCATION); + END_TEST; +} + +int UtcDaliToolkitScrollViewRulerDomainConstructorP(void) +{ + ToolkitTestApplication application; + + RulerDomain domainX = RulerDomain(0.0f, 200.0f, true); + DALI_TEST_EQUALS( domainX.min, 0.0f, TEST_LOCATION); + DALI_TEST_EQUALS( domainX.max, 200.0f, TEST_LOCATION); + DALI_TEST_EQUALS( domainX.enabled, true, TEST_LOCATION); + + RulerDomain domainY = RulerDomain(100.0f, 500.0f, false); + DALI_TEST_EQUALS( domainY.min, 100.0f, TEST_LOCATION); + DALI_TEST_EQUALS( domainY.max, 500.0f, TEST_LOCATION); + DALI_TEST_EQUALS( domainY.enabled, false, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliToolkitScrollViewRulerDomainGetSizeP(void) +{ + ToolkitTestApplication application; + + RulerDomain domainX = RulerDomain(0.0f, 200.0f, true); + DALI_TEST_EQUALS( domainX.GetSize(), 200.0f, TEST_LOCATION); + + RulerDomain domainY = RulerDomain(100.0f, 500.0f, false); + DALI_TEST_EQUALS( domainY.GetSize(), 400.0f, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliToolkitScrollViewRulerDomainClampP(void) +{ + ToolkitTestApplication application; + + RulerDomain domainX = RulerDomain(0.0f, 200.0f, true); + + float value = domainX.Clamp(50.0f, 100.0f, 1.0f); + DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION); + + value = domainX.Clamp(300.0f, 20.0f, 1.0f); + DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION); + + value = domainX.Clamp(300.0f, 20.0f, 0.5f); + DALI_TEST_EQUALS( value, 80.0f, TEST_LOCATION); + + value = domainX.Clamp(250.0f, 200.0f, 2.0f); + DALI_TEST_EQUALS( value, 200.0f, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliToolkitScrollViewRulerDomainClampWithStateP(void) +{ + ToolkitTestApplication application; + + RulerDomain domainX = RulerDomain(0.0f, 200.0f, true); + + 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); + + 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); + + 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); + + END_TEST; +} + +int UtcDaliToolkitScrollViewDefaultRulerConstructorP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerConstructorP"); + + RulerPtr defaultRuler = new DefaultRuler(); + DALI_TEST_CHECK( defaultRuler ); + + END_TEST; +} + +int UtcDaliToolkitScrollViewDefaultRulerDestructorP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerDestructorP"); + + RulerPtr defaultRuler = new DefaultRuler(); + + DALI_TEST_CHECK( true ); + END_TEST; +} + +int UtcDaliToolkitScrollViewFixedRulerConstructorP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewFixedRulerConstructorP"); + + RulerPtr fixedRuler = new FixedRuler( 100.0f ); + DALI_TEST_CHECK( fixedRuler ); + + fixedRuler = new FixedRuler( 0.0f ); + DALI_TEST_CHECK( fixedRuler ); + + END_TEST; +} + +int UtcDaliToolkitScrollViewFixedRulerDestructorP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewFixedRulerDestructorP"); + + RulerPtr fixedRuler = new FixedRuler( 100.0f ); + + DALI_TEST_CHECK( true ); + END_TEST; +} + +int UtcDaliToolkitScrollViewRulerGetTypeP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewRulerGetTypeP"); + + RulerPtr defaultRuler = new DefaultRuler(); + DALI_TEST_CHECK( defaultRuler ); + 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); + + END_TEST; +} + +int UtcDaliToolkitScrollViewRulerGetExtensionP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewRulerGetExtensionP"); + + RulerPtr defaultRuler = new DefaultRuler(); + DALI_TEST_CHECK( defaultRuler ); + DALI_TEST_CHECK( !defaultRuler->GetExtension() ); + + RulerPtr fixedRuler = new FixedRuler( 100.0f ); + DALI_TEST_CHECK( fixedRuler ); + DALI_TEST_CHECK( !fixedRuler->GetExtension() ); + + END_TEST; +} + +int UtcDaliToolkitScrollViewRulerEnableDisable(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewRulerEnableDisable"); + + RulerPtr ruler = new DefaultRuler(); + + DALI_TEST_CHECK( ruler->IsEnabled() ); + ruler->Disable(); + DALI_TEST_CHECK( !ruler->IsEnabled() ); + ruler->Enable(); + DALI_TEST_CHECK( ruler->IsEnabled() ); + END_TEST; +} + +int UtcDaliToolkitScrollViewRulerDomainEnableDisable(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewRulerDomainEnableDisable"); + + RulerPtr ruler = new DefaultRuler(); + DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION ); + + ruler->SetDomain( RulerDomain(0.0f, 100.0f, true) ); + DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 100.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( ruler->Clamp(-200.0f), 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( ruler->Clamp(200.0f), 100.0f, TEST_LOCATION ); + + ruler->DisableDomain(); + DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( ruler->Clamp(-200.0f), -200.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( ruler->Clamp(200.0f), 200.0f, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliToolkitScrollViewRulerSnapAndClamp(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewRulerSnapAndClamp"); + + RulerPtr ruler = new FixedRuler( 50.0f ); + ruler->SetDomain( RulerDomain(0.0f, 400.0f, true) ); + + // default testing. (snap and clamp) + DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f), 50.0f, TEST_LOCATION); + DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f), 50.0f, TEST_LOCATION); + DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f), 0.0f, TEST_LOCATION); + DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f), 0.0f, TEST_LOCATION); + DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f), 400.0f, TEST_LOCATION); + DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f), 400.0f, TEST_LOCATION); + + // bias testing. + DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left + DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.5f), 50.0f, TEST_LOCATION); // No Flick + DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right + + DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left + DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.5f), 0.0f, TEST_LOCATION); // No Flick + DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right + + // length testing. + DALI_TEST_EQUALS( ruler->SnapAndClamp(-10.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (over left boundary) + DALI_TEST_EQUALS( ruler->SnapAndClamp(-5.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (slightly ovr left boundary) + DALI_TEST_EQUALS( ruler->SnapAndClamp(300.0f, 0.5f, 10.0f), 300.0f, TEST_LOCATION); // 10 units long (not over a boundary) + DALI_TEST_EQUALS( ruler->SnapAndClamp(395.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (slightly over right boundary) + DALI_TEST_EQUALS( ruler->SnapAndClamp(500.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (over right boundary) + + // scale testing. + DALI_TEST_EQUALS( ruler->SnapAndClamp(-100.0f, 0.5f, 0.0f, 2.0f), 0.0f, TEST_LOCATION); + DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 2.0f), 50.0f, TEST_LOCATION); + DALI_TEST_EQUALS( ruler->SnapAndClamp(700.0f, 0.5f, 0.0f, 2.0f), 700.0f, TEST_LOCATION); + DALI_TEST_EQUALS( ruler->SnapAndClamp(850.0f, 0.5f, 0.0f, 2.0f), 800.0f, TEST_LOCATION); + + // 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( 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( 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( 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( 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( ruler->SnapAndClamp(430.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION); + DALI_TEST_EQUALS( clamped, ClampedToMax, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP"); + + RulerPtr rulerNormal = new FixedRuler( 25.0f ); + rulerNormal->SetDomain( RulerDomain(10.0f, 90.0f, true) ); + + unsigned int volume; + float position; + + position = rulerNormal->GetPositionFromPage(1, volume, true); + DALI_TEST_EQUALS( position, 35.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION ); + + position = rulerNormal->GetPositionFromPage(2, volume, true); + DALI_TEST_EQUALS( position, 60.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION ); + + // Disable the ruler + rulerNormal->Disable(); + + position = rulerNormal->GetPositionFromPage(1, volume, true); + DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( volume, 1u, TEST_LOCATION ); + + position = rulerNormal->GetPositionFromPage(2, volume, true); + DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( volume, 2u, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP"); + + RulerPtr defaultRuler = new DefaultRuler(); + DALI_TEST_CHECK( defaultRuler ); + DALI_TEST_EQUALS( defaultRuler->GetTotalPages(), 1u, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP"); + + RulerPtr defaultRuler = new DefaultRuler(); + DALI_TEST_CHECK( defaultRuler ); + DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(100.0f, true), 0u, TEST_LOCATION); + DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(-300.0f, false), 0u, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP"); + + RulerPtr defaultRuler = new DefaultRuler(); + DALI_TEST_CHECK( defaultRuler ); + + unsigned int volume; + DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(0, volume, true), 0.0f, TEST_LOCATION); + DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION); + + DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(3, volume, false), 0.0f, TEST_LOCATION); + DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliToolkitScrollViewDefaultRulerSnapP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerSnapP"); + + RulerPtr defaultRuler = new DefaultRuler(); + DALI_TEST_CHECK( defaultRuler ); + + DALI_TEST_EQUALS( defaultRuler->Snap(50.0f, 0.5f), 50.0f, TEST_LOCATION); + DALI_TEST_EQUALS( defaultRuler->Snap(-120.0f, 1.0f), -120.0f, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP"); + + RulerPtr fixedRuler = new FixedRuler( 100.0f ); + fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) ); + + fixedRuler->Enable(); + DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 4u, TEST_LOCATION); + + fixedRuler->Disable(); + DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 1u, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP"); + + RulerPtr fixedRuler = new FixedRuler( 100.0f ); + fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) ); + + fixedRuler->Enable(); + DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 3u, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 1u, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION); + + fixedRuler->Disable(); + DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION); + + // Set domain size to be smaller than the ruler space + fixedRuler->SetDomain( RulerDomain(0.0f, 50.0f, true) ); + + fixedRuler->Enable(); + DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION); + + fixedRuler->Disable(); + DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliToolkitScrollViewFixedRulerSnapP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewFixedRulerSnapP"); + + RulerPtr fixedRuler = new FixedRuler( 100.0f ); + fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) ); + + DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.0f), -100.0f, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.0f), -100.0f, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.0f), -200.0f, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.0f), -500.0f, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.0f), 0.0f, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.0f), 0.0f, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.0f), 0.0f, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.0f), 100.0f, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.0f), 100.0f, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.0f), 200.0f, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.0f), 600.0f, TEST_LOCATION); + + DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.5f), 0.0f, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.5f), -100.0f, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.5f), -100.0f, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.5f), -500.0f, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.5f), 0.0f, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.5f), 100.0f, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.5f), 100.0f, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.5f), 100.0f, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.5f), 100.0f, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.5f), 300.0f, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.5f), 600.0f, TEST_LOCATION); + + DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 1.0f), 0.0f, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 1.0f), 0.0f, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 1.0f), -100.0f, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 1.0f), -400.0f, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 1.0f), 100.0f, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 1.0f), 100.0f, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 1.0f), 100.0f, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 1.0f), 200.0f, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 1.0f), 200.0f, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 1.0f), 300.0f, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 1.0f), 700.0f, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliToolkitScrollViewConstraintsMove(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewConstraintsMove"); + + // 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); + + // Position rulers. + RulerPtr rulerX = new DefaultRuler(); + RulerPtr rulerY = new DefaultRuler(); + rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) ); + rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) ); + scrollView.SetRulerX(rulerX); + scrollView.SetRulerY(rulerY); + + // Add an Actor to ScrollView, + Actor a = Actor::New(); + scrollView.Add(a); + a.SetPosition( TEST_ACTOR_POSITION ); + Wait(application); + + const Vector2 target = Vector2(100.0f, 100.0f); + const Vector2 target2 = Vector2(200.0f, 200.0f); + + Constraint constraint = Constraint::New( scrollView, Actor::Property::POSITION, MoveActorConstraint ); + constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) ); + constraint.SetRemoveAction(Constraint::Discard); + scrollView.ApplyConstraintToChildren(constraint); + + scrollView.ScrollTo( target, 0.0f ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION ); + scrollView.ScrollTo( target2 ); + Wait(application, RENDER_DELAY_SCROLL); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliToolkitScrollViewConstraintsWrap(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewConstraintsWrap"); + + // 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); + + // Position rulers. + RulerPtr rulerX = new DefaultRuler(); + RulerPtr rulerY = new DefaultRuler(); + rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) ); + rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) ); + scrollView.SetRulerX(rulerX); + scrollView.SetRulerY(rulerY); + + // Add an Actor to ScrollView, + Actor a = Actor::New(); + scrollView.Add(a); + a.SetPosition( TEST_ACTOR_POSITION ); + Wait(application); + + const Vector2 target = Vector2(100.0f, 100.0f); + const Vector2 target2 = Vector2(200.0f, 200.0f); + + Constraint constraint = Constraint::New( scrollView, Actor::Property::POSITION, WrapActorConstraint ); + constraint.AddSource( LocalSource( Actor::Property::SCALE ) ); + constraint.AddSource( LocalSource( Actor::Property::ANCHOR_POINT ) ); + constraint.AddSource( LocalSource( Actor::Property::SIZE ) ); + 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); + scrollView.ApplyConstraintToChildren(constraint); + + scrollView.ScrollTo( target, 0.0f ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION ); + scrollView.ScrollTo( target2 ); + Wait(application, RENDER_DELAY_SCROLL); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION ); + END_TEST; }