use of android.view.accessibility.AccessibilityManager in project android_frameworks_base by DirtyUnicorns.
the class AccessibilityManagerTest method createManager.
private AccessibilityManager createManager(boolean enabled) throws Exception {
if (enabled) {
when(mMockService.addClient(any(IAccessibilityManagerClient.class), anyInt())).thenReturn(AccessibilityManager.STATE_FLAG_ACCESSIBILITY_ENABLED);
} else {
when(mMockService.addClient(any(IAccessibilityManagerClient.class), anyInt())).thenReturn(0);
}
AccessibilityManager manager = new AccessibilityManager(mContext, mMockService, UserHandle.USER_CURRENT);
verify(mMockService).addClient(any(IAccessibilityManagerClient.class), anyInt());
return manager;
}
use of android.view.accessibility.AccessibilityManager in project android_frameworks_base by DirtyUnicorns.
the class AccessibilityManagerTest method testIsEnabled.
@LargeTest
public void testIsEnabled() throws Exception {
// invoke the method under test
AccessibilityManager manager = createManager(true);
boolean isEnabledServiceEnabled = manager.isEnabled();
// check expected result
assertTrue("Must be enabled since the mock service is enabled", isEnabledServiceEnabled);
// disable accessibility
manager.getClient().setState(0);
// wait for the asynchronous IBinder call to complete
Thread.sleep(TIMEOUT_BINDER_CALL);
// invoke the method under test
boolean isEnabledServcieDisabled = manager.isEnabled();
// check expected result
assertFalse("Must be disabled since the mock service is disabled", isEnabledServcieDisabled);
}
use of android.view.accessibility.AccessibilityManager in project android_frameworks_base by DirtyUnicorns.
the class AccessibilityManagerTest method testSendAccessibilityEvent_AccessibilityEnabled.
@MediumTest
public void testSendAccessibilityEvent_AccessibilityEnabled() throws Exception {
AccessibilityEvent sentEvent = AccessibilityEvent.obtain();
when(mMockService.sendAccessibilityEvent(eq(sentEvent), anyInt())).thenReturn(true).thenReturn(false);
AccessibilityManager manager = createManager(true);
manager.sendAccessibilityEvent(sentEvent);
assertSame("The event should be recycled.", sentEvent, AccessibilityEvent.obtain());
manager.sendAccessibilityEvent(sentEvent);
assertNotSame("The event should not be recycled.", sentEvent, AccessibilityEvent.obtain());
}
use of android.view.accessibility.AccessibilityManager in project android_frameworks_base by DirtyUnicorns.
the class AccessibilityManagerTest method testInterrupt.
@MediumTest
public void testInterrupt() throws Exception {
AccessibilityManager manager = createManager(true);
manager.interrupt();
verify(mMockService).interrupt(UserHandle.USER_CURRENT);
}
use of android.view.accessibility.AccessibilityManager in project android_frameworks_base by DirtyUnicorns.
the class NotificationManagerService method sendAccessibilityEvent.
void sendAccessibilityEvent(Notification notification, CharSequence packageName) {
AccessibilityManager manager = AccessibilityManager.getInstance(getContext());
if (!manager.isEnabled()) {
return;
}
AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED);
event.setPackageName(packageName);
event.setClassName(Notification.class.getName());
event.setParcelableData(notification);
CharSequence tickerText = notification.tickerText;
if (!TextUtils.isEmpty(tickerText)) {
event.getText().add(tickerText);
}
try {
manager.sendAccessibilityEvent(event);
} catch (IllegalStateException e) {
Slog.e(TAG, "sendAccessibilityEvent failed.", e);
}
}
Aggregations