xiaofans / robotium

Automatically exported from code.google.com/p/robotium
0 stars 0 forks source link

ViewPager scrollToSide don't work with new Android Support Library #402

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Update to latest Android Support Library
2. use solo.scrollToSide(Solo.RIGHT);

What is the expected output? What do you see instead?

Expected: ViewPager scroll to the right page
See: ViewPager try to scroll to right page but bounce back to actual page

What version of the product are you using? On what operating system?

Robotium 3.6 and 4.0

HOW TO FIX:

Change scrollToSide in Scroller.java 

    /**
     * Scrolls horizontally.
     *
     * @param side the side to which to scroll; {@link Side#RIGHT} or {@link Side#LEFT}
     */

    @SuppressWarnings("deprecation")
    public void scrollToSide(Side side) {
        int screenHeight = activityUtils.getCurrentActivity().getWindowManager().getDefaultDisplay()
                .getHeight();
        int screenWidth = activityUtils.getCurrentActivity(false).getWindowManager().getDefaultDisplay()
                .getWidth();
        float x = screenWidth / 3.0f * 2.0f;
        float y = screenHeight / 3.0f * 2.0f;
        if (side == Side.LEFT)
            drag(0, x, y, y, 40);
        else if (side == Side.RIGHT)
            drag(x, 0, y, y, 40);
    }

Original issue reported on code.google.com by stermi on 5 Mar 2013 at 2:58

GoogleCodeExporter commented 9 years ago
Thanks for reporting this. Would it be possible for you to share an application 
that exhibits this issue?

Original comment by renasr...@gmail.com on 5 Mar 2013 at 3:06

GoogleCodeExporter commented 9 years ago
Please try with Robotium 4.1

Original comment by renasr...@gmail.com on 8 Apr 2013 at 4:13

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I've run into exactly this issue on several devices. Apparently whatever math 
is being used to calculate the screen size is not accurate. It works on my 
Nexus 7, by not on an old LG G2, or and HTC One. All the examples I've been 
able to find don't work correctly either. The above code (tweaked for 4.2), 
mostly works, but I have a few views that need to be swiped from the very edge, 
and this is off.

Original comment by mark.and...@gmail.com on 24 Aug 2013 at 3:48

GoogleCodeExporter commented 9 years ago
Why is it that this bug was marked as invalid?

I get this issue with a Nexus 5 with Android 4.4.2 and Robotium 5.0.1

Original comment by german...@gmail.com on 12 Feb 2014 at 9:24

GoogleCodeExporter commented 9 years ago
still happens. PLEASE fix this, you even have code that shows how to do it.

Original comment by freakedo...@gmail.com on 17 Feb 2014 at 12:16

GoogleCodeExporter commented 9 years ago
This will be fixed in the next release. 

Original comment by renasr...@gmail.com on 17 Feb 2014 at 2:08

GoogleCodeExporter commented 9 years ago
You can use:

/**
     * Scrolls horizontally.
     *
     * @param side the side to scroll; {@link #RIGHT} or {@link #LEFT}
     * @param scrollPosition the position to scroll to, from 0 to 1 where 1 is all the way. Example is: 0.60.
     */

    public void scrollToSide(int side, float scrollPosition)

Example:

solo.scrollToSide(Scroller.Side.RIGHT, 1F); 

Original comment by renasr...@gmail.com on 17 Feb 2014 at 2:37

GoogleCodeExporter commented 9 years ago
Thanks again for reporting this. This has been fixed in 5.1. 

Original comment by renasr...@gmail.com on 17 Mar 2014 at 6:10

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
This issue is back in 5.4.1,I had to return back to 5.3.1 for this 
solo.scrolltoSide(solo.Left) to work. Please fix this.

Original comment by itsprabh...@gmail.com on 11 Jun 2015 at 12:25