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 
     19 import io.appium.droiddriver.DroidDriver;
     20 import io.appium.droiddriver.UiElement;
     21 import io.appium.droiddriver.finders.Finder;
     22 import io.appium.droiddriver.scroll.Direction.DirectionConverter;
     23 import io.appium.droiddriver.scroll.Direction.PhysicalDirection;
     24 
     25 /**
     26  * An abstract base class for implementing the <a
     27  * href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>,
     28  * forwarding calls to all methods of {@link ScrollStepStrategy} to delegate.
     29  */
     30 public abstract class ForwardingScrollStepStrategy implements ScrollStepStrategy {
     31 
     32   protected ForwardingScrollStepStrategy() {}
     33 
     34   /**
     35    * Returns the backing delegate instance that methods are forwarded to.
     36    */
     37   protected abstract ScrollStepStrategy delegate();
     38 
     39   public boolean scroll(DroidDriver driver, Finder containerFinder, PhysicalDirection direction) {
     40     return delegate().scroll(driver, containerFinder, direction);
     41   }
     42 
     43   @Override
     44   public final DirectionConverter getDirectionConverter() {
     45     return delegate().getDirectionConverter();
     46   }
     47 
     48   @Override
     49   public void beginScrolling(DroidDriver driver, Finder containerFinder, Finder itemFinder,
     50       PhysicalDirection direction) {
     51     delegate().beginScrolling(driver, containerFinder, itemFinder, direction);
     52   }
     53 
     54   @Override
     55   public void endScrolling(DroidDriver driver, Finder containerFinder, Finder itemFinder,
     56       PhysicalDirection direction) {
     57     delegate().endScrolling(driver, containerFinder, itemFinder, direction);
     58   }
     59 
     60   @Override
     61   public void doScroll(UiElement container, PhysicalDirection direction) {
     62     delegate().doScroll(container, direction);
     63   }
     64 }
     65