19c92f46280cf3943701e75349833c68b584992e2Kevin Jin/* 29c92f46280cf3943701e75349833c68b584992e2Kevin Jin * Copyright (C) 2013 DroidDriver committers 39c92f46280cf3943701e75349833c68b584992e2Kevin Jin * 49c92f46280cf3943701e75349833c68b584992e2Kevin Jin * Licensed under the Apache License, Version 2.0 (the "License"); 59c92f46280cf3943701e75349833c68b584992e2Kevin Jin * you may not use this file except in compliance with the License. 69c92f46280cf3943701e75349833c68b584992e2Kevin Jin * You may obtain a copy of the License at 79c92f46280cf3943701e75349833c68b584992e2Kevin Jin * 89c92f46280cf3943701e75349833c68b584992e2Kevin Jin * http://www.apache.org/licenses/LICENSE-2.0 99c92f46280cf3943701e75349833c68b584992e2Kevin Jin * 109c92f46280cf3943701e75349833c68b584992e2Kevin Jin * Unless required by applicable law or agreed to in writing, software 119c92f46280cf3943701e75349833c68b584992e2Kevin Jin * distributed under the License is distributed on an "AS IS" BASIS, 129c92f46280cf3943701e75349833c68b584992e2Kevin Jin * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 139c92f46280cf3943701e75349833c68b584992e2Kevin Jin * See the License for the specific language governing permissions and 149c92f46280cf3943701e75349833c68b584992e2Kevin Jin * limitations under the License. 159c92f46280cf3943701e75349833c68b584992e2Kevin Jin */ 164b31201b5a2dbf8036da5a8d089a68a39cc1dc44Kevin Jinpackage io.appium.droiddriver.scroll; 179c92f46280cf3943701e75349833c68b584992e2Kevin Jin 184b31201b5a2dbf8036da5a8d089a68a39cc1dc44Kevin Jinimport io.appium.droiddriver.DroidDriver; 194b31201b5a2dbf8036da5a8d089a68a39cc1dc44Kevin Jinimport io.appium.droiddriver.UiElement; 204b31201b5a2dbf8036da5a8d089a68a39cc1dc44Kevin Jinimport io.appium.droiddriver.finders.Finder; 214b31201b5a2dbf8036da5a8d089a68a39cc1dc44Kevin Jinimport io.appium.droiddriver.scroll.Direction.DirectionConverter; 224b31201b5a2dbf8036da5a8d089a68a39cc1dc44Kevin Jinimport io.appium.droiddriver.scroll.Direction.PhysicalDirection; 239c92f46280cf3943701e75349833c68b584992e2Kevin Jin 249c92f46280cf3943701e75349833c68b584992e2Kevin Jin/** 259c92f46280cf3943701e75349833c68b584992e2Kevin Jin * Interface for determining whether scrolling is possible. 269c92f46280cf3943701e75349833c68b584992e2Kevin Jin */ 279c92f46280cf3943701e75349833c68b584992e2Kevin Jinpublic interface ScrollStepStrategy { 289c92f46280cf3943701e75349833c68b584992e2Kevin Jin /** 29e66c531bb9bd973a8dfd76cf5c404b5dc03facfeKevin Jin * Tries to scroll {@code containerFinder} in {@code direction}. Returns whether scrolling is 30e66c531bb9bd973a8dfd76cf5c404b5dc03facfeKevin Jin * effective. 319c92f46280cf3943701e75349833c68b584992e2Kevin Jin * 32e66c531bb9bd973a8dfd76cf5c404b5dc03facfeKevin Jin * @param driver a DroidDriver instance 33e66c531bb9bd973a8dfd76cf5c404b5dc03facfeKevin Jin * @param containerFinder Finder for the container that can scroll, for instance a ListView 34e66c531bb9bd973a8dfd76cf5c404b5dc03facfeKevin Jin * @param direction specifies where the view port will move instead of the finger 359c92f46280cf3943701e75349833c68b584992e2Kevin Jin * @return whether scrolling is effective 369c92f46280cf3943701e75349833c68b584992e2Kevin Jin */ 379c92f46280cf3943701e75349833c68b584992e2Kevin Jin boolean scroll(DroidDriver driver, Finder containerFinder, PhysicalDirection direction); 389c92f46280cf3943701e75349833c68b584992e2Kevin Jin 399c92f46280cf3943701e75349833c68b584992e2Kevin Jin /** 409c92f46280cf3943701e75349833c68b584992e2Kevin Jin * Returns the {@link DirectionConverter}. 419c92f46280cf3943701e75349833c68b584992e2Kevin Jin */ 429c92f46280cf3943701e75349833c68b584992e2Kevin Jin DirectionConverter getDirectionConverter(); 439c92f46280cf3943701e75349833c68b584992e2Kevin Jin 449c92f46280cf3943701e75349833c68b584992e2Kevin Jin /** 45e66c531bb9bd973a8dfd76cf5c404b5dc03facfeKevin Jin * Called only if this step is at the beginning of a series of scroll steps with regard to the 46e66c531bb9bd973a8dfd76cf5c404b5dc03facfeKevin Jin * given arguments. 47026e2d0318ee13637adbc71365592705c149c157Kevin Jin * 48e66c531bb9bd973a8dfd76cf5c404b5dc03facfeKevin Jin * @param driver a DroidDriver instance 49e66c531bb9bd973a8dfd76cf5c404b5dc03facfeKevin Jin * @param containerFinder Finder for the container that can scroll, for instance a ListView 50e66c531bb9bd973a8dfd76cf5c404b5dc03facfeKevin Jin * @param itemFinder Finder for the desired item; relative to {@code containerFinder} 51e66c531bb9bd973a8dfd76cf5c404b5dc03facfeKevin Jin * @param direction specifies where the view port will move instead of the finger 52026e2d0318ee13637adbc71365592705c149c157Kevin Jin */ 535cf5f03c64b65b1f1ecd2140b8d6605ac05b6199Kevin Jin void beginScrolling(DroidDriver driver, Finder containerFinder, Finder itemFinder, 54e66c531bb9bd973a8dfd76cf5c404b5dc03facfeKevin Jin PhysicalDirection direction); 55026e2d0318ee13637adbc71365592705c149c157Kevin Jin 56026e2d0318ee13637adbc71365592705c149c157Kevin Jin /** 57e66c531bb9bd973a8dfd76cf5c404b5dc03facfeKevin Jin * Called only if this step is at the end of a series of scroll steps with regard to the given 58e66c531bb9bd973a8dfd76cf5c404b5dc03facfeKevin Jin * arguments. 59026e2d0318ee13637adbc71365592705c149c157Kevin Jin * 60e66c531bb9bd973a8dfd76cf5c404b5dc03facfeKevin Jin * @param driver a DroidDriver instance 61e66c531bb9bd973a8dfd76cf5c404b5dc03facfeKevin Jin * @param containerFinder Finder for the container that can scroll, for instance a ListView 62e66c531bb9bd973a8dfd76cf5c404b5dc03facfeKevin Jin * @param itemFinder Finder for the desired item; relative to {@code containerFinder} 63e66c531bb9bd973a8dfd76cf5c404b5dc03facfeKevin Jin * @param direction specifies where the view port will move instead of the finger 64026e2d0318ee13637adbc71365592705c149c157Kevin Jin */ 655cf5f03c64b65b1f1ecd2140b8d6605ac05b6199Kevin Jin void endScrolling(DroidDriver driver, Finder containerFinder, Finder itemFinder, 66e66c531bb9bd973a8dfd76cf5c404b5dc03facfeKevin Jin PhysicalDirection direction); 67026e2d0318ee13637adbc71365592705c149c157Kevin Jin 68026e2d0318ee13637adbc71365592705c149c157Kevin Jin /** 69e66c531bb9bd973a8dfd76cf5c404b5dc03facfeKevin Jin * Performs the scroll action on {@code container}. Subclasses can override this to customize the 70e66c531bb9bd973a8dfd76cf5c404b5dc03facfeKevin Jin * scroll action, for example, to adjust the scroll margins. 719031ed9b636ccd3b942eefb85dbfae2aed9e4f11Kevin Jin * 729031ed9b636ccd3b942eefb85dbfae2aed9e4f11Kevin Jin * @param container the container that can scroll 73e66c531bb9bd973a8dfd76cf5c404b5dc03facfeKevin Jin * @param direction specifies where the view port will move instead of the finger 749031ed9b636ccd3b942eefb85dbfae2aed9e4f11Kevin Jin */ 759031ed9b636ccd3b942eefb85dbfae2aed9e4f11Kevin Jin void doScroll(UiElement container, PhysicalDirection direction); 769031ed9b636ccd3b942eefb85dbfae2aed9e4f11Kevin Jin 779031ed9b636ccd3b942eefb85dbfae2aed9e4f11Kevin Jin /** 78e66c531bb9bd973a8dfd76cf5c404b5dc03facfeKevin Jin * {@inheritDoc} It is recommended that this method return a description to help debugging. 799c92f46280cf3943701e75349833c68b584992e2Kevin Jin */ 809c92f46280cf3943701e75349833c68b584992e2Kevin Jin @Override 819c92f46280cf3943701e75349833c68b584992e2Kevin Jin String toString(); 829c92f46280cf3943701e75349833c68b584992e2Kevin Jin} 83