+
+int UtcDaliToolkitScrollModeP1(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( " UtcDaliToolkitScrollView ScrollMode property" );
+
+ // Set up a scrollView.
+ ScrollView scrollView = ScrollView::New();
+
+ // Do not rely on stage size for UTC tests.
+ Vector2 viewPageSize( 720.0f, 1280.0f );
+ scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
+ scrollView.SetProperty( Actor::Property::SIZE, viewPageSize );
+ scrollView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+ scrollView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
+ scrollView.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
+
+ // Position rulers.
+ Property::Map rulerMap;
+ rulerMap.Add( ScrollMode::X_AXIS_SCROLL_ENABLED, true );
+ rulerMap.Add( ScrollMode::X_AXIS_SNAP_TO_INTERVAL, viewPageSize.width );
+ rulerMap.Add( ScrollMode::X_AXIS_SCROLL_BOUNDARY, viewPageSize.width*3 );
+ rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, false );
+ scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap);
+
+ scrollView.SetWrapMode( false );
+ scrollView.SetScrollSensitive( true );
+
+ application.GetScene().Add( scrollView );
+
+ // Set up a gesture to perform.
+ Vector2 startPos( 50.0f, 0.0f );
+ Vector2 direction( -5.0f, 0.0f );
+ int frames = 200;
+ uint32_t time = 0;
+
+ // Force starting position.
+ scrollView.ScrollTo( startPos, 0.0f );
+ time += Wait( application );
+
+ // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
+ Vector2 currentPos( PerformGestureSwipe( application, startPos, direction, frames - 1, time, false ) );
+
+ // Confirm the final X coord has not moved more than one page from the start X position.
+ DALI_TEST_GREATER( ( startPos.x + viewPageSize.width ), scrollView.GetCurrentScrollPosition().x, TEST_LOCATION );
+
+ // Finish the gesture and wait for the snap.
+ currentPos += direction;
+ TestEndPan( application, currentPos, time );
+ // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
+ time += Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL );
+
+ // Confirm the final X coord has snapped to exactly one page ahead of the start page.
+ DALI_TEST_EQUALS( viewPageSize.width, scrollView.GetCurrentScrollPosition().x, Math::MACHINE_EPSILON_0, TEST_LOCATION );
+
+ // 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;
+}
+