Search in sources :

Example 16 with IAccessibilityManager

use of android.view.accessibility.IAccessibilityManager in project android_frameworks_base by ParanoidAndroid.

the class AccessibilityManagerTest method testSendAccessibilityEvent_AccessibilityDisabled.

@MediumTest
public void testSendAccessibilityEvent_AccessibilityDisabled() throws Exception {
    // create an event to be dispatched
    AccessibilityEvent sentEvent = AccessibilityEvent.obtain();
    // configure the mock service behavior
    IAccessibilityManager mockServiceInterface = mMockServiceInterface;
    expect(mockServiceInterface.addClient(anyIAccessibilityManagerClient(), UserHandle.USER_OWNER)).andReturn(0);
    replay(mockServiceInterface);
    // invoke the method under test (accessibility disabled)
    AccessibilityManager manager = new AccessibilityManager(mContext, mockServiceInterface, UserHandle.USER_OWNER);
    try {
        manager.sendAccessibilityEvent(sentEvent);
        fail("No accessibility events are sent if accessibility is disabled");
    } catch (IllegalStateException ise) {
        // check expected result
        assertEquals("Accessibility off. Did you forget to check that?", ise.getMessage());
    }
    // verify the mock service was properly called
    verify(mockServiceInterface);
}
Also used : IAccessibilityManager(android.view.accessibility.IAccessibilityManager) AccessibilityManager(android.view.accessibility.AccessibilityManager) IAccessibilityManager(android.view.accessibility.IAccessibilityManager) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 17 with IAccessibilityManager

use of android.view.accessibility.IAccessibilityManager in project android_frameworks_base by ParanoidAndroid.

the class AccessibilityManagerTest method testInterrupt.

@MediumTest
public void testInterrupt() throws Exception {
    // configure the mock service behavior
    IAccessibilityManager mockServiceInterface = mMockServiceInterface;
    expect(mockServiceInterface.addClient(anyIAccessibilityManagerClient(), UserHandle.USER_OWNER)).andReturn(AccessibilityManager.STATE_FLAG_ACCESSIBILITY_ENABLED);
    mockServiceInterface.interrupt(UserHandle.USER_OWNER);
    replay(mockServiceInterface);
    // invoke the method under test
    AccessibilityManager manager = new AccessibilityManager(mContext, mockServiceInterface, UserHandle.USER_OWNER);
    manager.interrupt();
    // verify the mock service was properly called
    verify(mockServiceInterface);
}
Also used : IAccessibilityManager(android.view.accessibility.IAccessibilityManager) AccessibilityManager(android.view.accessibility.AccessibilityManager) IAccessibilityManager(android.view.accessibility.IAccessibilityManager) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 18 with IAccessibilityManager

use of android.view.accessibility.IAccessibilityManager in project android_frameworks_base by ParanoidAndroid.

the class AccessibilityManagerTest method testSendAccessibilityEvent_AccessibilityEnabled.

@MediumTest
public void testSendAccessibilityEvent_AccessibilityEnabled() throws Exception {
    // create an event to be dispatched
    AccessibilityEvent sentEvent = AccessibilityEvent.obtain();
    // configure the mock service behavior
    IAccessibilityManager mockServiceInterface = mMockServiceInterface;
    expect(mockServiceInterface.addClient(anyIAccessibilityManagerClient(), UserHandle.USER_OWNER)).andReturn(AccessibilityManager.STATE_FLAG_ACCESSIBILITY_ENABLED);
    expect(mockServiceInterface.sendAccessibilityEvent(eqAccessibilityEvent(sentEvent), UserHandle.USER_OWNER)).andReturn(true);
    expect(mockServiceInterface.sendAccessibilityEvent(eqAccessibilityEvent(sentEvent), UserHandle.USER_OWNER)).andReturn(false);
    replay(mockServiceInterface);
    // invoke the method under test (manager and service in different processes)
    AccessibilityManager manager = new AccessibilityManager(mContext, mockServiceInterface, UserHandle.USER_OWNER);
    manager.sendAccessibilityEvent(sentEvent);
    // check expected result
    AccessibilityEvent nextEventDifferentProcesses = AccessibilityEvent.obtain();
    assertSame("The manager and the service are in different processes, so the event must be " + "recycled", sentEvent, nextEventDifferentProcesses);
    // invoke the method under test (manager and service in the same process)
    manager.sendAccessibilityEvent(sentEvent);
    // check expected result
    AccessibilityEvent nextEventSameProcess = AccessibilityEvent.obtain();
    assertNotSame("The manager and the service are in the same process, so the event must not" + "be recycled", sentEvent, nextEventSameProcess);
    // verify the mock service was properly called
    verify(mockServiceInterface);
}
Also used : IAccessibilityManager(android.view.accessibility.IAccessibilityManager) AccessibilityManager(android.view.accessibility.AccessibilityManager) IAccessibilityManager(android.view.accessibility.IAccessibilityManager) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 19 with IAccessibilityManager

use of android.view.accessibility.IAccessibilityManager in project platform_frameworks_base by android.

the class UiAutomationConnection method registerUiTestAutomationServiceLocked.

private void registerUiTestAutomationServiceLocked(IAccessibilityServiceClient client, int flags) {
    IAccessibilityManager manager = IAccessibilityManager.Stub.asInterface(ServiceManager.getService(Context.ACCESSIBILITY_SERVICE));
    final AccessibilityServiceInfo info = new AccessibilityServiceInfo();
    info.eventTypes = AccessibilityEvent.TYPES_ALL_MASK;
    info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
    info.flags |= AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS | AccessibilityServiceInfo.FLAG_REPORT_VIEW_IDS | AccessibilityServiceInfo.FLAG_FORCE_DIRECT_BOOT_AWARE;
    info.setCapabilities(AccessibilityServiceInfo.CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT | AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION | AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_ENHANCED_WEB_ACCESSIBILITY | AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_FILTER_KEY_EVENTS);
    try {
        // Calling out with a lock held is fine since if the system
        // process is gone the client calling in will be killed.
        manager.registerUiTestAutomationService(mToken, client, info, flags);
        mClient = client;
    } catch (RemoteException re) {
        throw new IllegalStateException("Error while registering UiTestAutomationService.", re);
    }
}
Also used : IAccessibilityManager(android.view.accessibility.IAccessibilityManager) AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) RemoteException(android.os.RemoteException)

Example 20 with IAccessibilityManager

use of android.view.accessibility.IAccessibilityManager in project platform_frameworks_base by android.

the class UiAutomationConnection method unregisterUiTestAutomationServiceLocked.

private void unregisterUiTestAutomationServiceLocked() {
    IAccessibilityManager manager = IAccessibilityManager.Stub.asInterface(ServiceManager.getService(Context.ACCESSIBILITY_SERVICE));
    try {
        // Calling out with a lock held is fine since if the system
        // process is gone the client calling in will be killed.
        manager.unregisterUiTestAutomationService(mClient);
        mClient = null;
    } catch (RemoteException re) {
        throw new IllegalStateException("Error while unregistering UiTestAutomationService", re);
    }
}
Also used : IAccessibilityManager(android.view.accessibility.IAccessibilityManager) RemoteException(android.os.RemoteException)

Aggregations

IAccessibilityManager (android.view.accessibility.IAccessibilityManager)28 RemoteException (android.os.RemoteException)20 ComponentName (android.content.ComponentName)8 AccessibilityManager (android.view.accessibility.AccessibilityManager)8 AccessibilityServiceInfo (android.accessibilityservice.AccessibilityServiceInfo)7 UserManager (android.os.UserManager)4 MediumTest (android.test.suitebuilder.annotation.MediumTest)4 WindowManagerInternal (android.view.WindowManagerInternal)4 IBinder (android.os.IBinder)3 AccessibilityEvent (android.view.accessibility.AccessibilityEvent)2 LargeTest (android.test.suitebuilder.annotation.LargeTest)1 ArrayList (java.util.ArrayList)1