Package org.robolectric.shadows
Class ShadowAccessibilityService
- java.lang.Object
-
- org.robolectric.shadows.ShadowContextWrapper
-
- org.robolectric.shadows.ShadowService
-
- org.robolectric.shadows.ShadowAccessibilityService
-
@Implements(android.accessibilityservice.AccessibilityService.class) public class ShadowAccessibilityService extends ShadowService
Shadow of AccessibilityService that tracks global actions and provides a mechanism to simulate the window list.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ShadowAccessibilityService.GestureDispatch
Represents a gesture that has been dispatched through the accessibility service.
-
Constructor Summary
Constructors Constructor Description ShadowAccessibilityService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
dispatchGesture(GestureDescription gesture, AccessibilityService.GestureResultCallback callback, Handler handler)
List<ShadowAccessibilityService.GestureDispatch>
getGesturesDispatched()
Returns a list of gestures that have been dispatched.List<Integer>
getGlobalActionsPerformed()
protected List<AccessibilityWindowInfo>
getWindows()
Returns a representation of interactive windows shown on the device screen.protected boolean
performGlobalAction(int action)
void
setCanDispatchGestures(boolean canDispatchGestures)
Sets whether the service is currently able to dispatch gestures.void
setTakeScreenshotErrorCode(int errorCode)
SetsAccessibilityService.takeScreenshot(int, Executor, TakeScreenshotCallback)
to start returning the givenerrorCode
.void
setWindows(List<AccessibilityWindowInfo> windowList)
Sets the list of interactive windows shown on the device screen as reported bygetWindows()
protected void
takeScreenshot(int displayId, Executor executor, AccessibilityService.TakeScreenshotCallback callback)
void
unsetTakeScreenshotErrorCode()
SetsAccessibilityService.takeScreenshot(int, Executor, TakeScreenshotCallback)
to start returning successful results again.-
Methods inherited from class org.robolectric.shadows.ShadowService
getForegroundServiceType, getLastForegroundNotification, getLastForegroundNotificationId, getNotificationShouldRemoved, getStopSelfId, getStopSelfResultId, isForegroundStopped, isLastForegroundNotificationAttached, isStoppedBySelf, onDestroy, startForeground, startForeground, stopForeground, stopForeground, stopSelf, stopSelf, stopSelfResult
-
Methods inherited from class org.robolectric.shadows.ShadowContextWrapper
clearBroadcastIntents, clearNextStartedActivities, clearStartedServices, denyPermissions, denyPermissions, getAllStartedServices, getBroadcastIntents, getBroadcastIntentsForUser, getBroadcastOptions, getNextStartedActivity, getNextStartedActivityForResult, getNextStartedService, getNextStoppedService, grantPermissions, grantPermissions, peekNextStartedActivity, peekNextStartedActivityForResult, peekNextStartedService, removeSystemService
-
-
-
-
Method Detail
-
performGlobalAction
@Implementation protected final boolean performGlobalAction(int action)
-
getWindows
@Implementation(minSdk=21) protected List<AccessibilityWindowInfo> getWindows()
Returns a representation of interactive windows shown on the device screen. Mirrors the values provided to#setWindows(List
. Returns an empty List if not set.)
-
dispatchGesture
@Implementation(minSdk=24) protected boolean dispatchGesture(GestureDescription gesture, AccessibilityService.GestureResultCallback callback, Handler handler)
-
takeScreenshot
@Implementation(minSdk=30) protected void takeScreenshot(int displayId, Executor executor, AccessibilityService.TakeScreenshotCallback callback)
-
setTakeScreenshotErrorCode
public void setTakeScreenshotErrorCode(int errorCode)
SetsAccessibilityService.takeScreenshot(int, Executor, TakeScreenshotCallback)
to start returning the givenerrorCode
.- See Also:
to unset the error condition.
-
unsetTakeScreenshotErrorCode
public void unsetTakeScreenshotErrorCode()
SetsAccessibilityService.takeScreenshot(int, Executor, TakeScreenshotCallback)
to start returning successful results again.- See Also:
to set an error condition instead.
-
setWindows
public void setWindows(List<AccessibilityWindowInfo> windowList)
Sets the list of interactive windows shown on the device screen as reported bygetWindows()
-
getGesturesDispatched
public List<ShadowAccessibilityService.GestureDispatch> getGesturesDispatched()
Returns a list of gestures that have been dispatched. Gestures are dispatched by callingAccessibilityService.dispatchGesture(android.accessibilityservice.GestureDescription, android.accessibilityservice.AccessibilityService.GestureResultCallback, android.os.Handler)
.
-
setCanDispatchGestures
public void setCanDispatchGestures(boolean canDispatchGestures)
Sets whether the service is currently able to dispatch gestures. Iffalse
,AccessibilityService.dispatchGesture(android.accessibilityservice.GestureDescription, android.accessibilityservice.AccessibilityService.GestureResultCallback, android.os.Handler)
will returnfalse
.
-
-