1/*
2 * Copyright (C) 2013 DroidDriver committers
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package com.google.android.droiddriver.scroll;
17
18import com.google.android.droiddriver.DroidDriver;
19import com.google.android.droiddriver.UiElement;
20import com.google.android.droiddriver.actions.ScrollDirection;
21import com.google.android.droiddriver.exceptions.ElementNotFoundException;
22import com.google.android.droiddriver.finders.Finder;
23
24/**
25 * Interface for scrolling to the desired child in a scrollable parent view.
26 */
27public interface Scroller {
28  /**
29   * Scrolls {@code parentFinder} in both directions if necessary to find
30   * {@code childFinder}.
31   *
32   * @param driver
33   * @param parentFinder Finder for the container that can scroll, for instance
34   *        a ListView
35   * @param childFinder Finder for the desired child; relative to
36   *        {@code parentFinder}
37   * @return the UiElement matching {@code childFinder}
38   * @throws ElementNotFoundException If no match is found
39   */
40  UiElement scrollTo(DroidDriver driver, Finder parentFinder, Finder childFinder);
41
42  /**
43   * Scrolls {@code parentFinder} in {@code direction} if necessary to find
44   * {@code childFinder}.
45   *
46   * @param driver
47   * @param parentFinder Finder for the container that can scroll, for instance
48   *        a ListView
49   * @param childFinder Finder for the desired child; relative to
50   *        {@code parentFinder}
51   * @param direction
52   * @return the UiElement matching {@code childFinder}
53   * @throws ElementNotFoundException If no match is found
54   */
55  UiElement scrollTo(DroidDriver driver, Finder parentFinder, Finder childFinder,
56      ScrollDirection direction);
57}
58