+ 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);
+
+ // Change scroll mode during pan, should not crash
+ PerformGestureSwipe(application, startPos, direction, frames - 1, time, false);
+ try
+ {
+ scrollView.SetScrollSensitive(false);
+ DALI_TEST_CHECK(true);
+ }
+ catch(...)
+ {
+ DALI_TEST_CHECK(false);
+ }
+
+ END_TEST;
+}
+
+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();
+ application.GetScene().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::DIRECTION_BIAS_LEFT);
+
+ 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<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION);
+ DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION);
+
+ scrollView.ScrollTo(0, 0.25, Dali::Toolkit::DIRECTION_BIAS_RIGHT);
+
+ 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<int>(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(" UtcDaliToolkitScrollViewScrollToActorP");
+
+ ScrollView scrollView = ScrollView::New();
+ application.GetScene().Add(scrollView);
+
+ Actor actorA = Actor::New();
+ const Vector3 positionA = Vector3(100.0f, 400.0f, 0.0f);
+ actorA.SetProperty(Actor::Property::POSITION, positionA);
+ scrollView.Add(actorA);
+
+ Actor actorB = Actor::New();
+ const Vector3 positionB = Vector3(500.0f, 200.0f, 0.0f);
+ actorB.SetProperty(Actor::Property::POSITION, positionB);
+ scrollView.Add(actorB);
+
+ Wait(application);
+
+ scrollView.ScrollTo(actorA, 0.0f);
+ Wait(application);
+ DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), positionA.GetVectorXY(), TEST_LOCATION);
+
+ Wait(application);
+ scrollView.ScrollTo(actorB, 0.0f);
+ Wait(application);
+ DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), positionB.GetVectorXY(), TEST_LOCATION);
+
+ scrollView.ScrollTo(actorA);
+ Wait(application, RENDER_DELAY_SCROLL);
+ DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), positionA.GetVectorXY(), TEST_LOCATION);
+
+ scrollView.ScrollTo(actorB);
+ Wait(application, RENDER_DELAY_SCROLL);
+ DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), positionB.GetVectorXY(), TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewScrollToSnapPointP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewScrollToSnapPointP");
+
+ ScrollView scrollView = ScrollView::New();
+ application.GetScene().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(Vector2(120.0f, 190.0f), 0.0f);
+ Wait(application);
+ DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), Vector2(120.0f, 190.0f), TEST_LOCATION);
+
+ scrollView.ScrollToSnapPoint();
+
+ Wait(application, RENDER_DELAY_SCROLL);
+ DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 200.0f), TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewSetScrollUpdateDistanceP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewSetScrollUpdateDistanceP");
+
+ ScrollView scrollView = ScrollView::New();
+
+ scrollView.SetScrollUpdateDistance(0);
+ DALI_TEST_EQUALS(scrollView.GetScrollUpdateDistance(), 0, TEST_LOCATION);
+ scrollView.SetScrollUpdateDistance(10);
+ DALI_TEST_EQUALS(scrollView.GetScrollUpdateDistance(), 10, TEST_LOCATION);
+ scrollView.SetScrollUpdateDistance(1000);
+ DALI_TEST_EQUALS(scrollView.GetScrollUpdateDistance(), 1000, TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewSetWrapModeP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewSetWrapModeP");
+
+ ScrollView scrollView = ScrollView::New();
+ application.GetScene().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);
+ rulerX->SetDomain(RulerDomain(0.0f, 200.0f, false));
+ rulerY->SetDomain(RulerDomain(0.0f, 200.0f, false));
+ scrollView.SetRulerX(rulerX);
+ scrollView.SetRulerY(rulerY);
+
+ scrollView.SetWrapMode(false);
+ 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<int>(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<int>(scrollView.GetCurrentPage()), 13, TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewActorAutoSnap(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewActorAutoSnap");
+
+ ScrollView scrollView = ScrollView::New();
+ application.GetScene().Add(scrollView);
+
+ // 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);
+
+ const Vector3 aPosition = Vector3(200.0f, 50.0f, 0.0f);
+ Actor a = Actor::New();
+ scrollView.Add(a);
+ a.SetProperty(Actor::Property::POSITION, aPosition);
+
+ const Vector3 bPosition = Vector3(600.0f, 600.0f, 0.0f);
+ Actor b = Actor::New();
+ scrollView.Add(b);
+ b.SetProperty(Actor::Property::POSITION, bPosition);
+
+ // Goto a random position, and execute snap (should not move)
+ Vector2 targetScroll = Vector2(500.0f, 500.0f);
+ scrollView.ScrollTo(targetScroll, 0.0f);
+ Wait(application);
+ scrollView.ScrollToSnapPoint();
+ Wait(application, RENDER_DELAY_SCROLL);
+ DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), targetScroll, TEST_LOCATION);
+
+ // Enable ActorAutoSnap, and now try snapping.
+ scrollView.SetActorAutoSnap(true);
+ scrollView.ScrollToSnapPoint();
+ Wait(application, RENDER_DELAY_SCROLL);
+ DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), bPosition.GetVectorXY(), TEST_LOCATION);
+
+ scrollView.ScrollTo(Vector2(0.0f, 0.0f), 0.0f);
+ Wait(application);
+ scrollView.ScrollToSnapPoint();
+ Wait(application, RENDER_DELAY_SCROLL);
+ DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), aPosition.GetVectorXY(), TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewSignalsStartComplete(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewSignalsStartComplete");
+
+ gOnScrollStartCalled = false;
+ gOnScrollCompleteCalled = false;
+
+ ScrollView scrollView = ScrollView::New();
+ application.GetScene().Add(scrollView);
+
+ // 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);
+ scrollView.ScrollStartedSignal().Connect(&OnScrollStart);
+ scrollView.ScrollUpdatedSignal().Connect(&OnScrollUpdate);
+ scrollView.ScrollCompletedSignal().Connect(&OnScrollComplete);
+ scrollView.ScrollTo(Vector2(100.0f, 100.0f));
+ Wait(application, RENDER_DELAY_SCROLL);
+
+ DALI_TEST_CHECK(gOnScrollStartCalled);
+ DALI_TEST_CHECK(gOnScrollCompleteCalled);
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewSignalsUpdate01(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewSignalsUpdate");
+
+ gOnScrollStartCalled = false;
+ gOnScrollUpdateCalled = false;
+ gOnScrollCompleteCalled = false;
+
+ 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);
+ scrollView.ScrollStartedSignal().Connect(&OnScrollStart);
+ scrollView.ScrollUpdatedSignal().Connect(&OnScrollUpdate);
+ scrollView.ScrollCompletedSignal().Connect(&OnScrollComplete);
+
+ 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);
+ 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++)
+ {
+ time += RENDER_FRAME_INTERVAL;
+ TestMovePan(application, pos, time);
+ pos.x += 5.0f;
+ pos.y += 5.0f;
+ Wait(application);
+ }
+
+ time += RENDER_FRAME_INTERVAL;
+ TestEndPan(application, pos, time);
+ Wait(application, RENDER_DELAY_SCROLL);
+
+ DALI_TEST_CHECK(gOnScrollStartCalled);
+ DALI_TEST_CHECK(gOnScrollUpdateCalled);
+ DALI_TEST_CHECK(gOnScrollCompleteCalled);
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewSignalsUpdate02(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewSignalsUpdate");
+
+ gOnScrollStartCalled = false;
+ gOnScrollUpdateCalled = false;
+ gOnScrollCompleteCalled = false;
+
+ 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);
+
+ // Do a pan starting from 100,100 and moving down diagonally.
+ Vector2 pos(100.0f, 100.0f);
+ 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++)
+ {
+ time += RENDER_FRAME_INTERVAL;
+ TestMovePan(application, pos, time);
+ pos.x += 5.0f;
+ pos.y += 5.0f;
+ Wait(application);
+ }
+
+ time += RENDER_FRAME_INTERVAL;
+ TestEndPan(application, pos, time);
+ Wait(application, RENDER_DELAY_SCROLL);
+
+ DALI_TEST_CHECK(scrollStarted);
+ DALI_TEST_CHECK(scrollUpdated);
+ DALI_TEST_CHECK(scrollCompleted);
+
+ application.GetScene().Remove(scrollView);
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewScrollSensitive(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewScrollSensitive");
+
+ // Set up a scrollView...
+ ScrollView scrollView = ScrollView::New();
+ scrollView.SetOvershootEnabled(true);
+ 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, stageSize.width + CLAMP_EXCESS_WIDTH, true));
+ rulerY->SetDomain(RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true));
+ scrollView.SetRulerX(rulerX);
+ scrollView.SetRulerY(rulerY);
+ scrollView.ScrollStartedSignal().Connect(&OnScrollStart);
+ scrollView.ScrollUpdatedSignal().Connect(&OnScrollUpdate);
+ scrollView.ScrollCompletedSignal().Connect(&OnScrollComplete);
+ scrollView.SnapStartedSignal().Connect(&OnSnapStart);
+
+ scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
+ uint32_t time = 0;
+ time += Wait(application);
+
+ // First try insensitive swipe.
+ scrollView.SetScrollSensitive(false);
+ PerformGestureSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, time, true);
+
+ DALI_TEST_CHECK(!gOnScrollStartCalled);
+ DALI_TEST_CHECK(!gOnScrollCompleteCalled);
+ DALI_TEST_CHECK(!gOnSnapStartCalled);
+
+ // Second try sensitive swipe.
+ scrollView.SetScrollSensitive(true);
+ PerformGestureSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, time, true);
+
+ DALI_TEST_CHECK(gOnScrollStartCalled);
+ DALI_TEST_CHECK(gOnScrollCompleteCalled);
+ DALI_TEST_CHECK(gOnSnapStartCalled);
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewAxisAutoLock(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLock");
+
+ // Set up a scrollView...
+ 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, stageSize.width + CLAMP_EXCESS_WIDTH, true));
+ rulerY->SetDomain(RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true));
+ scrollView.SetRulerX(rulerX);
+ scrollView.SetRulerY(rulerY);
+ scrollView.ScrollStartedSignal().Connect(&OnScrollStart);
+ scrollView.ScrollUpdatedSignal().Connect(&OnScrollUpdate);
+ scrollView.ScrollCompletedSignal().Connect(&OnScrollComplete);
+
+ // Normal
+ scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
+ uint32_t time = 0;
+ time += Wait(application);
+
+ Vector2 startPosition = scrollView.GetCurrentScrollPosition();
+ Vector2 dir(5.0f, 1.0f);
+
+ // PerformGestureSwipe not used as a different initial direction was required
+
+ Vector2 pos(CLAMP_TOUCH_START + Vector2(15.0f, 3.0f));
+
+ TestStartPan(application, CLAMP_TOUCH_START, pos, time);
+
+ time += Wait(application);
+
+ for(int i = 0; i < 47; i++)
+ {
+ pos += dir;
+ TestMovePan(application, pos, time);
+ time += Wait(application);
+ }
+
+ pos += dir;
+
+ TestEndPan(application, pos, time);
+
+ const Vector2 positionAfterNormal = scrollView.GetCurrentScrollPosition();
+
+ // Autolock
+ scrollView.SetAxisAutoLock(true);
+ DALI_TEST_CHECK(scrollView.GetAxisAutoLock());
+
+ scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
+ time += Wait(application);
+
+ Vector2 pos2(CLAMP_TOUCH_START + Vector2(15.0f, 3.0f));
+
+ TestStartPan(application, CLAMP_TOUCH_START, pos2, time);
+
+ time += Wait(application);
+
+ for(int i = 0; i < 47; i++)
+ {
+ pos2 += dir;
+ TestMovePan(application, pos2, time);
+ time += Wait(application);
+ }
+
+ pos2 += dir;
+
+ TestEndPan(application, pos2, time);
+
+ 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);
+ const float devianceAutoLock = fabsf(startPosition.y - positionAfterAutoLock.y);
+
+ // in auto-lock it should be a mostly horizontal pan (thus deviance should be much lower)
+ DALI_TEST_CHECK(devianceAutoLock < devianceNormal);
+
+ scrollView.SetAxisAutoLock(false);
+ DALI_TEST_CHECK(!scrollView.GetAxisAutoLock());
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewAxisAutoLockGradient(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLockGradient");
+
+ // Set up a scrollView...
+ ScrollView scrollView = ScrollView::New();
+ scrollView.SetAxisAutoLockGradient(0.5f);
+ DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 0.5f, TEST_LOCATION);
+ scrollView.SetAxisAutoLockGradient(1.0f);
+ DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 1.0f, TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewConstraints(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewConstraints");
+
+ // Set up a scrollView...
+ 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, 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,
+ // Apply TestSumConstraint to ScrollView's children (includes this Actor)
+ gConstraintResult = Vector3::ZERO;
+ Actor a = Actor::New();
+ scrollView.Add(a);
+ a.SetProperty(Actor::Property::POSITION, TEST_ACTOR_POSITION);
+ Wait(application);
+
+ Constraint constraint = Constraint::New<Vector3>(scrollView, Actor::Property::POSITION, TestSumConstraint(TEST_CONSTRAINT_OFFSET));
+ constraint.AddSource(Source(scrollView, ScrollView::Property::SCROLL_POSITION));
+ constraint.SetRemoveAction(Constraint::DISCARD);
+ scrollView.ApplyConstraintToChildren(constraint);
+ Wait(application);
+
+ DALI_TEST_EQUALS(gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION);
+
+ gConstraintResult = Vector3::ZERO;
+ scrollView.RemoveConstraintsFromChildren();
+ Wait(application);
+
+ DALI_TEST_EQUALS(gConstraintResult, Vector3::ZERO, TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewBind(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewBind");
+
+ // Set up a scrollView...
+ 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, 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,
+ // Apply TestSumConstraint to ScrollView's children (includes this Actor)
+
+ gConstraintResult = Vector3::ZERO;
+ Actor a = Actor::New();
+ scrollView.Add(a);
+ a.SetProperty(Actor::Property::POSITION, TEST_ACTOR_POSITION);
+ Wait(application);
+
+ // apply this constraint to scrollview
+ Constraint constraint = Constraint::New<Vector3>(scrollView, Actor::Property::POSITION, TestSumConstraint(TEST_CONSTRAINT_OFFSET));
+ constraint.AddSource(Source(scrollView, ScrollView::Property::SCROLL_POSITION));
+ constraint.SetRemoveAction(Constraint::DISCARD);
+ scrollView.ApplyConstraintToChildren(constraint);
+
+ Wait(application);
+ // Defaulty Bound.
+ DALI_TEST_EQUALS(gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION);
+
+ // UnBind
+ gConstraintResult = Vector3::ZERO;
+ scrollView.UnbindActor(a);
+ Wait(application);
+ DALI_TEST_EQUALS(gConstraintResult, Vector3::ZERO, TEST_LOCATION);
+
+ // Bind
+ gConstraintResult = Vector3::ZERO;
+ scrollView.BindActor(a);
+ Wait(application);
+ DALI_TEST_EQUALS(gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewOvershoot(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewOvershoot");
+
+ // Set up a scrollView...
+ ScrollView scrollView = ScrollView::New();
+ 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<Vector2>(), 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();
+ 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);
+ scrollView.ScrollStartedSignal().Connect(&OnScrollStart);
+ scrollView.ScrollUpdatedSignal().Connect(&OnScrollUpdate);
+ scrollView.ScrollCompletedSignal().Connect(&OnScrollComplete);
+
+ scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
+ 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 = 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);
+
+ float timeToReachOrigin;
+
+ // Now release touch. Overshoot should snap back to zero.
+ 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;
+ 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);
+
+ 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.
+ 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;
+ 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);
+
+ 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.
+ 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;
+ 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);
+ scrollView.SetSnapOvershootAlphaFunction(TestAlphaFunction);
+
+ 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.
+ 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;
+ 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 UtcDaliToolkitScrollViewSnapAlphaFunction(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewSnapAlphaFunction");
+
+ // Set up a scrollView...
+ ScrollView scrollView = ScrollView::New();
+ 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);
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewSnapDuration(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewSnapDuration");
+
+ // Set up a scrollView...
+ ScrollView scrollView = ScrollView::New();
+ scrollView.SetScrollSnapDuration(1.0f);
+ DALI_TEST_EQUALS(scrollView.GetScrollSnapDuration(), 1.0f, TEST_LOCATION);
+ scrollView.SetScrollSnapDuration(0.5f);
+ DALI_TEST_EQUALS(scrollView.GetScrollSnapDuration(), 0.5f, TEST_LOCATION);
+
+ scrollView.SetScrollFlickDuration(2.0f);
+ DALI_TEST_EQUALS(scrollView.GetScrollFlickDuration(), 2.0f, TEST_LOCATION);
+ scrollView.SetScrollFlickDuration(1.5f);
+ DALI_TEST_EQUALS(scrollView.GetScrollFlickDuration(), 1.5f, TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewSnapStartedSignalP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewSnapStartedSignalP");
+
+ // Set up a scrollView...
+ 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, stageSize.width + CLAMP_EXCESS_WIDTH, true));
+ rulerY->SetDomain(RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true));
+ scrollView.SetRulerX(rulerX);
+ scrollView.SetRulerY(rulerY);
+ scrollView.SnapStartedSignal().Connect(&OnSnapStart);
+
+ scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
+ uint32_t time = 0;
+ time += Wait(application);
+
+ // First try a snap.
+ 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.
+ PerformGestureSwipe(application, CLAMP_TOUCH_START, Vector2(20.0f, 0.0f), 60, time, true);
+
+ DALI_TEST_CHECK(gOnSnapStartCalled);
+ DALI_TEST_CHECK(gLastSnapType == Toolkit::FLICK);
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewGetCurrentPageP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewGetCurrentPageP");
+
+ ScrollView scrollView = ScrollView::New();
+ application.GetScene().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<int>(scrollView.GetCurrentPage()), 15, TEST_LOCATION);
+
+ scrollView.ScrollTo(3);
+ Wait(application, RENDER_DELAY_SCROLL);
+ DALI_TEST_EQUALS(static_cast<int>(scrollView.GetCurrentPage()), 3, TEST_LOCATION);
+
+ scrollView.ScrollTo(9);
+ Wait(application, RENDER_DELAY_SCROLL);
+ DALI_TEST_EQUALS(static_cast<int>(scrollView.GetCurrentPage()), 9, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewSetMaxOvershootP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewSetMaxOvershootP");
+
+ // Set up a scrollView...
+ 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, 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.
+ 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 = 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)
+ 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 = 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 (-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 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.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 (-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);
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewSetScrollingDirectionP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewSetScrollingDirectionP");