Home | History | Annotate | Download | only in scroll
      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  */
     16 package io.appium.droiddriver.scroll;
     17 
     18 import io.appium.droiddriver.DroidDriver;
     19 import io.appium.droiddriver.UiElement;
     20 import io.appium.droiddriver.exceptions.ElementNotFoundException;
     21 import io.appium.droiddriver.finders.Finder;
     22 import io.appium.droiddriver.scroll.Direction.PhysicalDirection;
     23 
     24 /**
     25  * Interface for scrolling to the desired item in a scrollable container view.
     26  */
     27 public interface Scroller {
     28   /**
     29    * Scrolls {@code containerFinder} in both directions if necessary to find {@code itemFinder},
     30    * which is a descendant of {@code containerFinder}.
     31    *
     32    * @param driver          a DroidDriver instance
     33    * @param containerFinder Finder for the container that can scroll, for instance a ListView
     34    * @param itemFinder      Finder for the desired item; relative to {@code containerFinder}
     35    * @return the UiElement matching {@code itemFinder}
     36    * @throws ElementNotFoundException If no match is found
     37    */
     38   UiElement scrollTo(DroidDriver driver, Finder containerFinder, Finder itemFinder);
     39 
     40   /**
     41    * Scrolls {@code containerFinder} in {@code direction} if necessary to find {@code itemFinder},
     42    * which is a descendant of {@code containerFinder}.
     43    *
     44    * @param driver          a DroidDriver instance
     45    * @param containerFinder Finder for the container that can scroll, for instance a ListView
     46    * @param itemFinder      Finder for the desired item; relative to {@code containerFinder}
     47    * @param direction       specifies where the view port will move instead of the finger
     48    * @return the UiElement matching {@code itemFinder}
     49    * @throws ElementNotFoundException If no match is found
     50    */
     51   UiElement scrollTo(DroidDriver driver, Finder containerFinder, Finder itemFinder,
     52                      PhysicalDirection direction);
     53 }
     54