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 17 package io.appium.droiddriver.actions.accessibility; 18 19 import android.view.accessibility.AccessibilityNodeInfo; 20 21 import io.appium.droiddriver.UiElement; 22 import io.appium.droiddriver.actions.Action; 23 import io.appium.droiddriver.actions.BaseAction; 24 import io.appium.droiddriver.uiautomation.UiAutomationElement; 25 26 /** 27 * Implements {@link Action} via the Accessibility API. 28 */ 29 public abstract class AccessibilityAction extends BaseAction { AccessibilityAction(long timeoutMillis)30 protected AccessibilityAction(long timeoutMillis) { 31 super(timeoutMillis); 32 } 33 34 @Override perform(UiElement element)35 public final boolean perform(UiElement element) { 36 return perform(((UiAutomationElement) element).getRawElement(), element); 37 } 38 39 /** 40 * Performs the action via the Accessibility API. 41 * 42 * @param node the AccessibilityNodeInfo used to create the UiElement 43 * @param element the UiElement to perform the action on 44 * @return Whether the action is successful. Some actions throw exceptions in 45 * case of failure, when that behavior is more appropriate. 46 */ perform(AccessibilityNodeInfo node, UiElement element)47 protected abstract boolean perform(AccessibilityNodeInfo node, UiElement element); 48 } 49