public class StepBasedScroller extends java.lang.Object implements Scroller
Scroller
that looks for the desired item in the currently shown
content of the scrollable container, otherwise scrolls the container one step
at a time and looks again, until we cannot scroll any more. A
ScrollStepStrategy
is used to determine whether more scrolling is
possible.Constructor and Description |
---|
StepBasedScroller(int maxScrolls,
long perScrollTimeoutMillis,
Direction.Axis axis,
ScrollStepStrategy scrollStepStrategy,
boolean startFromBeginning) |
StepBasedScroller(ScrollStepStrategy scrollStepStrategy)
Constructs with default 100 maxScrolls, 1 second for
perScrollTimeoutMillis, vertical axis, not startFromBegining.
|
Modifier and Type | Method and Description |
---|---|
UiElement |
scrollTo(DroidDriver driver,
Finder containerFinder,
Finder itemFinder)
Scrolls
containerFinder in both directions if necessary to find itemFinder ,
which is a descendant of containerFinder . |
UiElement |
scrollTo(DroidDriver driver,
Finder containerFinder,
Finder itemFinder,
Direction.PhysicalDirection direction)
Scrolls
containerFinder in direction if necessary to find itemFinder ,
which is a descendant of containerFinder . |
protected UiElement |
scrollTo(DroidDriver driver,
Finder containerFinder,
Finder itemFinder,
Direction.PhysicalDirection direction,
boolean scrollBack) |
public StepBasedScroller(int maxScrolls, long perScrollTimeoutMillis, Direction.Axis axis, ScrollStepStrategy scrollStepStrategy, boolean startFromBeginning)
maxScrolls
- the maximum number of scrolls. It should be large enough
to allow any reasonable list sizeperScrollTimeoutMillis
- the timeout in millis that we poll for the
item after each scroll. 1000L is usually safe; if there are no
asynchronously updated views, 0L is also a reasonable value.axis
- the axis this scroller can scrollstartFromBeginning
- if true
,
scrollTo(DroidDriver, Finder, Finder)
starts from the
beginning and scrolls forward, instead of starting from the current
location and scrolling in both directions. It may not always work,
but when it works, it is faster.public StepBasedScroller(ScrollStepStrategy scrollStepStrategy)
protected UiElement scrollTo(DroidDriver driver, Finder containerFinder, Finder itemFinder, Direction.PhysicalDirection direction, boolean scrollBack)
public UiElement scrollTo(DroidDriver driver, Finder containerFinder, Finder itemFinder, Direction.PhysicalDirection direction)
Scroller
containerFinder
in direction
if necessary to find itemFinder
,
which is a descendant of containerFinder
.scrollTo
in interface Scroller
driver
- a DroidDriver instancecontainerFinder
- Finder for the container that can scroll, for instance a ListViewitemFinder
- Finder for the desired item; relative to containerFinder
direction
- specifies where the view port will move instead of the fingeritemFinder
public UiElement scrollTo(DroidDriver driver, Finder containerFinder, Finder itemFinder)
Scroller
containerFinder
in both directions if necessary to find itemFinder
,
which is a descendant of containerFinder
.