/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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.
bool* mCallbackFlag;
};
-const int MILLISECONDS_PER_SECOND = 1000;
const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
-const int RENDER_ANIMATION_TEST_DURATION_MS = 1000; ///< 1000ms to test animation
const int RENDER_DELAY_SCROLL = 1000; ///< duration to wait for any scroll to complete.
// For Clamp Signal testing...
const float CLAMP_EXCESS_WIDTH = 200.0f; ///< Amount of width that can be panned outside scrollview
const float CLAMP_EXCESS_HEIGHT = 200.0f; ///< Amount of height that can be panned outside scrollview
-const int CLAMP_STEP_0_CHECK_NOTCLAMPED = 0; ///< FSM: "First check that scrollview isn't clamped"
-const int CLAMP_STEP_1_CHECK_CLAMPED_WEST = 1; ///< FSM: "Next check that scrollview clamps against left side"
-const int CLAMP_STEP_2_CHECK_CLAMPED_SOUTH_WEST = 2; ///< FSM: "Then check that scrollview clamps against bottom-left side"
-const int CLAMP_STEP_3_SUCCESS = 3; ///< FSM: "Finished (Success)"
const Vector2 CLAMP_START_SCROLL_POSITION(30.0f, 100.0f); ///< Scroll start position for the Clamping tests.
const Vector2 CLAMP_TOUCH_START( 100.0f, 100.0f ); ///< Start point to touch from for the Clamping tests.
const Vector2 CLAMP_TOUCH_MOVEMENT( 5.0f, -5.0f ); ///< Amount to move touch for each frame for the Clamping tests.
const int CLAMP_GESTURE_FRAMES = 100; ///< Number of Frames to synthesize a gesture for the Clamping tests.
const Vector3 TEST_ACTOR_POSITION(100.0f, 100.0f, 0.0f); ///< A Test actor position offset (arbitrary value)
const Vector3 TEST_CONSTRAINT_OFFSET(1.0f, 2.0f, 0.0f); ///< A Test constraint offset (arbitrary value to test effects)
-const float TEST_RATIO_TOLERANCE = 0.05; ///< +/-5% tolerance for ratio comparisons.
const float DEFAULT_SNAP_OVERSHOOT_DURATION(0.5f); ///< Default overshoot snapping animation time.
const float DEFAULT_MAX_OVERSHOOT(100.0f); ///< Default maximum allowed overshoot in pixels
int timeToReachOrigin = -1;
for(int i = 0;i<MAX_FRAMES_TO_TEST_OVERSHOOT;i++)
{
- float overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
- float overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
+ float overshootXValue = scrollView.GetCurrentProperty<float>( ScrollView::Property::OVERSHOOT_X );
+ float overshootYValue = scrollView.GetCurrentProperty<float>( ScrollView::Property::OVERSHOOT_Y );
if(overshootXValue == 0.0f && overshootYValue == 0.0f)
{
break;
return std::min( progress * 2.0f, 1.0f );
}
+static Vector2 PerformGestureDiagonalSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, bool finish = true)
+{
+ gOnScrollStartCalled = false;
+ gOnScrollUpdateCalled = false;
+ gOnScrollCompleteCalled = false;
+ gOnSnapStartCalled = false;
+
+ // Now do a pan starting from (start) and heading (direction)
+ Vector2 pos(start);
+ SendPan(application, Gesture::Possible, pos);
+ SendPan(application, Gesture::Started, pos);
+ Wait(application);
+
+ for(int i = 0;i<frames;i++)
+ {
+ pos += direction; // Move in this direction
+ SendPan(application, Gesture::Continuing, pos);
+ Wait(application);
+ }
+
+ if(finish)
+ {
+ pos += direction; // Move in this direction.
+ SendPan(application, Gesture::Finished, pos);
+ Wait(application, RENDER_DELAY_SCROLL);
+ }
+
+ return pos;
+}
+
+
} // unnamed namespace
END_TEST;
}
+
+int UtcDaliToolkitScrollModeP1(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliToolkitScrollView ScrollMode property" );
+
+ // Set up a scrollView.
+ ScrollView scrollView = ScrollView::New();
+
+ // Do not rely on stage size for UTC tests.
+ Vector2 pageSize( 720.0f, 1280.0f );
+ scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
+ scrollView.SetSize( pageSize );
+ scrollView.SetParentOrigin( ParentOrigin::CENTER );
+ scrollView.SetAnchorPoint( AnchorPoint::CENTER );
+ scrollView.SetPosition( 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, pageSize.width );
+ rulerMap.Add( ScrollMode::X_AXIS_SCROLL_BOUNDARY, pageSize.width*3 );
+ rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, false );
+ scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap);
+
+ scrollView.SetWrapMode( false );
+ scrollView.SetScrollSensitive( true );
+
+ Stage::GetCurrent().Add( scrollView );
+
+ // Set up a gesture to perform.
+ Vector2 startPos( 50.0f, 0.0f );
+ Vector2 direction( -5.0f, 0.0f );
+ int frames = 200;
+
+ // Force starting position.
+ scrollView.ScrollTo( startPos, 0.0f );
+ Wait( application );
+
+ // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
+ Vector2 currentPos( PerformGestureDiagonalSwipe( application, startPos, direction, frames - 1, false ) );
+
+ // Confirm the final X coord has not moved more than one page from the start X position.
+ DALI_TEST_GREATER( ( startPos.x + pageSize.width ), scrollView.GetCurrentScrollPosition().x, TEST_LOCATION );
+
+ // Finish the gesture and wait for the snap.
+ currentPos += direction;
+ SendPan( application, Gesture::Finished, currentPos );
+ // 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 X coord has snapped to exactly one page ahead of the start page.
+ DALI_TEST_EQUALS( pageSize.width, scrollView.GetCurrentScrollPosition().x, Math::MACHINE_EPSILON_0, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollModeP2(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliToolkitScrollView ScrollMode property" );
+
+ // Set up a scrollView.
+ ScrollView scrollView = ScrollView::New();
+
+ // Do not rely on stage size for UTC tests.
+ Vector2 pageSize( 720.0f, 1280.0f );
+ scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
+ scrollView.SetSize( pageSize );
+ scrollView.SetParentOrigin( ParentOrigin::CENTER );
+ scrollView.SetAnchorPoint( AnchorPoint::CENTER );
+ scrollView.SetPosition( 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, pageSize.height );
+ rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_BOUNDARY, pageSize.height*3 );
+ scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap);
+
+ scrollView.SetWrapMode( false );
+ scrollView.SetScrollSensitive( true );
+
+ Stage::GetCurrent().Add( scrollView );
+
+ // Set up a gesture to perform.
+ Vector2 startPos( 0.0f, 50.0f );
+ Vector2 direction( 0.0f, -6.0f );
+ int frames = 200;
+
+ // Force starting position.
+ scrollView.ScrollTo( startPos, 0.0f );
+ Wait( application );
+
+ // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
+ Vector2 currentPos( PerformGestureDiagonalSwipe( application, startPos, direction, frames - 1, false ) );
+
+ // Confirm the final X coord has not moved more than one page from the start X position.
+ DALI_TEST_GREATER( ( startPos.y + pageSize.height ), scrollView.GetCurrentScrollPosition().y, TEST_LOCATION );
+
+ // Finish the gesture and wait for the snap.
+ currentPos += direction;
+ SendPan( application, Gesture::Finished, currentPos );
+ // 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( pageSize.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 pageSize( 720.0f, 1280.0f );
+ scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
+ scrollView.SetSize( pageSize );
+ scrollView.SetParentOrigin( ParentOrigin::CENTER );
+ scrollView.SetAnchorPoint( AnchorPoint::CENTER );
+ scrollView.SetPosition( 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, pageSize.height );
+ rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_BOUNDARY, pageSize.height*3 );
+ scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap);
+
+ scrollView.SetWrapMode( false );
+ scrollView.SetScrollSensitive( true );
+
+ Stage::GetCurrent().Add( scrollView );
+
+ // Set up a gesture to perform.
+ Vector2 startPos( 0.0f, 50.0f );
+ Vector2 direction( 0.0f, -6.0f );
+ int frames = 200;
+
+ // Force starting position.
+ scrollView.ScrollTo( startPos, 0.0f );
+ Wait( application );
+
+ // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
+ Vector2 currentPos( PerformGestureDiagonalSwipe( application, startPos, direction, frames - 1, false ) );
+
+ // Confirm the final X coord has not moved more than one page from the start X position.
+ DALI_TEST_GREATER( ( startPos.y + pageSize.height ), scrollView.GetCurrentScrollPosition().y, TEST_LOCATION );
+
+ // Finish the gesture and wait for the snap.
+ currentPos += direction;
+ SendPan( application, Gesture::Finished, currentPos );
+ // 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( pageSize.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 pageSize( 720.0f, 1280.0f );
+ scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
+ scrollView.SetSize( pageSize );
+ scrollView.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ scrollView.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ scrollView.SetPosition( 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 );
+
+ Stage::GetCurrent().Add( scrollView );
+
+ 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 );
+
+
+ END_TEST;
+}
+
int UtcDaliToolkitScrollViewScrollToPageWithDirectionBiasP(void)
{
ToolkitTestApplication application;
END_TEST;
}
-static Vector2 PerformGestureDiagonalSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, bool finish = true)
-{
- gOnScrollStartCalled = false;
- gOnScrollUpdateCalled = false;
- gOnScrollCompleteCalled = false;
- gOnSnapStartCalled = false;
-
- // Now do a pan starting from (start) and heading (direction)
- Vector2 pos(start);
- SendPan(application, Gesture::Possible, pos);
- SendPan(application, Gesture::Started, pos);
- Wait(application);
-
- for(int i = 0;i<frames;i++)
- {
- pos += direction; // Move in this direction
- SendPan(application, Gesture::Continuing, pos);
- Wait(application);
- }
-
- if(finish)
- {
- pos += direction; // Move in this direction.
- SendPan(application, Gesture::Finished, pos);
- Wait(application, RENDER_DELAY_SCROLL);
- }
-
- return pos;
-}
-
int UtcDaliToolkitScrollViewScrollSensitive(void)
{
ToolkitTestApplication application;
// 1. Scroll page in NW (-500,-500 pixels), then inspect overshoot. (don't release touch)
Vector2 currentPos = Vector2(100.0f, 100.0f);
currentPos = PerformGestureDiagonalSwipe(application, currentPos, Vector2(5.0f, 5.0f), 100, false);
- float overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
- float overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
- Vector2 positionValue = scrollView.GetProperty<Vector2>(ScrollView::Property::SCROLL_POSITION);
+ 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);
// 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<float>(ScrollView::Property::OVERSHOOT_X);
- float overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
+ 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);
// 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<float>(ScrollView::Property::OVERSHOOT_X);
- overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
+ overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
+ overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
// The overshoot value is a 0.0f - 1.0f ranged value of the amount overshot related to the maximum overshoot.
// EG. If we move 105, max overshoot is 50, then we overshot 50 / 105.
float correctOvershootValue = 50.0f / 105.f;
// 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<float>(ScrollView::Property::OVERSHOOT_X);
- overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
+ 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);
Wait(application);
// Check that overshoot should be now around 0.8.
- overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
- overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
+ overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
+ overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
DALI_TEST_CHECK(overshootXValue > 0.79f && overshootXValue < 0.81f);
DALI_TEST_CHECK(overshootYValue > 0.79f && overshootYValue < 0.81f);
// Scroll page further in NW (-30,-30 pixels), then check that overshoot should be now 1.0. (don't release touch)
currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 30, false);
- overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
- overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
+ 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);