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.accessibility; 18 19import com.google.android.droiddriver.UiElement; 20import com.google.android.droiddriver.actions.TextAction; 21import com.google.android.droiddriver.actions.UiElementActor; 22import com.google.android.droiddriver.scroll.Direction.PhysicalDirection; 23 24/** 25 * A {@link UiElementActor} that performs actions via the Accessibility API. 26 */ 27public class AccessibilityUiElementActor implements UiElementActor { 28 public static final AccessibilityUiElementActor INSTANCE = new AccessibilityUiElementActor(); 29 30 @Override 31 public void setText(UiElement uiElement, String text) { 32 uiElement.perform(new TextAction(text)); 33 } 34 35 @Override 36 public void click(UiElement uiElement) { 37 uiElement.perform(AccessibilityClickAction.SINGLE); 38 } 39 40 @Override 41 public void longClick(UiElement uiElement) { 42 uiElement.perform(AccessibilityClickAction.LONG); 43 } 44 45 @Override 46 public void doubleClick(UiElement uiElement) { 47 uiElement.perform(AccessibilityClickAction.DOUBLE); 48 } 49 50 @Override 51 public void scroll(UiElement uiElement, PhysicalDirection direction) { 52 uiElement.perform(new AccessibilityScrollAction(direction)); 53 } 54} 55