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 17package com.google.android.droiddriver.actions; 18 19import android.view.InputEvent; 20 21import com.google.android.droiddriver.UiElement; 22 23/** 24 * Implements {@link Action} by injecting synthesized events. 25 */ 26public abstract class EventAction extends BaseAction { 27 protected EventAction(long timeoutMillis) { 28 super(timeoutMillis); 29 } 30 31 @Override 32 public boolean perform(UiElement element) { 33 return perform(element.getInjector(), element); 34 } 35 36 /** 37 * Performs the action by injecting synthesized events. 38 * 39 * @param injector the injector to inject {@link InputEvent}s 40 * @param element the UiElement to perform the action on 41 * @return Whether the action is successful. Some actions throw exceptions in 42 * case of failure, when that behavior is more appropriate. For 43 * example, if event injection returns false. 44 */ 45 protected abstract boolean perform(InputInjector injector, UiElement element); 46} 47