Search in sources :

Example 1 with AccessibilityWindowInfo

use of android.view.accessibility.AccessibilityWindowInfo in project robolectric by robolectric.

the class ShadowAccessibilityNodeInfoTest method shouldRecordFlagsProperly.

@Test
@Config(minSdk = LOLLIPOP)
public void shouldRecordFlagsProperly() {
    node = AccessibilityNodeInfo.obtain();
    node.setClickable(false);
    shadow = (ShadowAccessibilityNodeInfo) ShadowExtractor.extract(node);
    shadow.setPasteable(false);
    assertThat(shadow.isClickable()).isEqualTo(false);
    assertThat(shadow.isPasteable()).isEqualTo(false);
    node.setText("Test");
    shadow.setTextSelectionSetable(true);
    shadow.addAction(AccessibilityNodeInfo.ACTION_SET_SELECTION);
    node.setTextSelection(0, 1);
    assertThat(shadow.getActions()).isEqualTo(AccessibilityNodeInfo.ACTION_SET_SELECTION);
    assertThat(shadow.getTextSelectionStart()).isEqualTo(0);
    assertThat(shadow.getTextSelectionEnd()).isEqualTo(1);
    AccessibilityWindowInfo window = ShadowAccessibilityWindowInfo.obtain();
    shadow.setAccessibilityWindowInfo(window);
    assertThat(node.getWindow()).isEqualTo(window);
    shadow.setAccessibilityWindowInfo(null);
    // Remove action was added in API 21
    node.removeAction(AccessibilityAction.ACTION_SET_SELECTION);
    shadow.setPasteable(true);
    shadow.setTextSelectionSetable(false);
    node.addAction(AccessibilityNodeInfo.ACTION_PASTE);
    assertThat(shadow.getActions()).isEqualTo(AccessibilityNodeInfo.ACTION_PASTE);
    node.setClickable(true);
    assertThat(shadow.isClickable()).isEqualTo(true);
    node.setClickable(false);
    shadow.setPasteable(false);
    node.removeAction(AccessibilityNodeInfo.ACTION_PASTE);
    node.addAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
    assertThat(shadow.getActions()).isEqualTo(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
    node.removeAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
}
Also used : AccessibilityWindowInfo(android.view.accessibility.AccessibilityWindowInfo) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 2 with AccessibilityWindowInfo

use of android.view.accessibility.AccessibilityWindowInfo in project robolectric by robolectric.

the class ShadowAccessibilityWindowInfo method obtain.

@Implementation
public static AccessibilityWindowInfo obtain(AccessibilityWindowInfo window) {
    final ShadowAccessibilityWindowInfo shadowInfo = ((ShadowAccessibilityWindowInfo) ShadowExtractor.extract(window));
    final AccessibilityWindowInfo obtainedInstance = shadowInfo.getClone();
    StrictEqualityWindowWrapper wrapper = new StrictEqualityWindowWrapper(obtainedInstance);
    obtainedInstances.put(wrapper, Thread.currentThread().getStackTrace());
    return obtainedInstance;
}
Also used : AccessibilityWindowInfo(android.view.accessibility.AccessibilityWindowInfo) Implementation(org.robolectric.annotation.Implementation)

Example 3 with AccessibilityWindowInfo

use of android.view.accessibility.AccessibilityWindowInfo in project robolectric by robolectric.

the class ShadowAccessibilityWindowInfo method getClone.

private AccessibilityWindowInfo getClone() {
    final AccessibilityWindowInfo newInfo = ReflectionHelpers.callConstructor(AccessibilityWindowInfo.class);
    final ShadowAccessibilityWindowInfo newShadow = (ShadowAccessibilityWindowInfo) ShadowExtractor.extract(newInfo);
    newShadow.boundsInScreen = new Rect(boundsInScreen);
    newShadow.parent = parent;
    newShadow.rootNode = rootNode;
    newShadow.type = type;
    newShadow.layer = layer;
    newShadow.id = id;
    newShadow.isAccessibilityFocused = isAccessibilityFocused;
    newShadow.isActive = isActive;
    newShadow.isFocused = isFocused;
    return newInfo;
}
Also used : Rect(android.graphics.Rect) AccessibilityWindowInfo(android.view.accessibility.AccessibilityWindowInfo)

Example 4 with AccessibilityWindowInfo

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

the class AccessibilityManagerService method dump.

@Override
public void dump(FileDescriptor fd, final PrintWriter pw, String[] args) {
    mSecurityPolicy.enforceCallingPermission(Manifest.permission.DUMP, FUNCTION_DUMP);
    synchronized (mLock) {
        pw.println("ACCESSIBILITY MANAGER (dumpsys accessibility)");
        pw.println();
        final int userCount = mUserStates.size();
        for (int i = 0; i < userCount; i++) {
            UserState userState = mUserStates.valueAt(i);
            pw.append("User state[attributes:{id=" + userState.mUserId);
            pw.append(", currentUser=" + (userState.mUserId == mCurrentUserId));
            pw.append(", touchExplorationEnabled=" + userState.mIsTouchExplorationEnabled);
            pw.append(", displayMagnificationEnabled=" + userState.mIsDisplayMagnificationEnabled);
            pw.append(", autoclickEnabled=" + userState.mIsAutoclickEnabled);
            if (userState.mUiAutomationService != null) {
                pw.append(", ");
                userState.mUiAutomationService.dump(fd, pw, args);
                pw.println();
            }
            pw.append("}");
            pw.println();
            pw.append("           services:{");
            final int serviceCount = userState.mBoundServices.size();
            for (int j = 0; j < serviceCount; j++) {
                if (j > 0) {
                    pw.append(", ");
                    pw.println();
                    pw.append("                     ");
                }
                Service service = userState.mBoundServices.get(j);
                service.dump(fd, pw, args);
            }
            pw.println("}]");
            pw.println();
        }
        if (mSecurityPolicy.mWindows != null) {
            final int windowCount = mSecurityPolicy.mWindows.size();
            for (int j = 0; j < windowCount; j++) {
                if (j > 0) {
                    pw.append(',');
                    pw.println();
                }
                pw.append("Window[");
                AccessibilityWindowInfo window = mSecurityPolicy.mWindows.get(j);
                pw.append(window.toString());
                pw.append(']');
            }
        }
    }
}
Also used : AccessibilityWindowInfo(android.view.accessibility.AccessibilityWindowInfo) AccessibilityService(android.accessibilityservice.AccessibilityService) Point(android.graphics.Point)

Example 5 with AccessibilityWindowInfo

use of android.view.accessibility.AccessibilityWindowInfo in project android_frameworks_base by AOSPA.

the class AccessibilityManagerService method dump.

@Override
public void dump(FileDescriptor fd, final PrintWriter pw, String[] args) {
    mSecurityPolicy.enforceCallingPermission(Manifest.permission.DUMP, FUNCTION_DUMP);
    synchronized (mLock) {
        pw.println("ACCESSIBILITY MANAGER (dumpsys accessibility)");
        pw.println();
        final int userCount = mUserStates.size();
        for (int i = 0; i < userCount; i++) {
            UserState userState = mUserStates.valueAt(i);
            pw.append("User state[attributes:{id=" + userState.mUserId);
            pw.append(", currentUser=" + (userState.mUserId == mCurrentUserId));
            pw.append(", touchExplorationEnabled=" + userState.mIsTouchExplorationEnabled);
            pw.append(", displayMagnificationEnabled=" + userState.mIsDisplayMagnificationEnabled);
            pw.append(", autoclickEnabled=" + userState.mIsAutoclickEnabled);
            if (userState.mUiAutomationService != null) {
                pw.append(", ");
                userState.mUiAutomationService.dump(fd, pw, args);
                pw.println();
            }
            pw.append("}");
            pw.println();
            pw.append("           services:{");
            final int serviceCount = userState.mBoundServices.size();
            for (int j = 0; j < serviceCount; j++) {
                if (j > 0) {
                    pw.append(", ");
                    pw.println();
                    pw.append("                     ");
                }
                Service service = userState.mBoundServices.get(j);
                service.dump(fd, pw, args);
            }
            pw.println("}]");
            pw.println();
        }
        if (mSecurityPolicy.mWindows != null) {
            final int windowCount = mSecurityPolicy.mWindows.size();
            for (int j = 0; j < windowCount; j++) {
                if (j > 0) {
                    pw.append(',');
                    pw.println();
                }
                pw.append("Window[");
                AccessibilityWindowInfo window = mSecurityPolicy.mWindows.get(j);
                pw.append(window.toString());
                pw.append(']');
            }
        }
    }
}
Also used : AccessibilityWindowInfo(android.view.accessibility.AccessibilityWindowInfo) AccessibilityService(android.accessibilityservice.AccessibilityService) Point(android.graphics.Point)

Aggregations

AccessibilityWindowInfo (android.view.accessibility.AccessibilityWindowInfo)10 AccessibilityService (android.accessibilityservice.AccessibilityService)5 Point (android.graphics.Point)5 Implementation (org.robolectric.annotation.Implementation)3 Rect (android.graphics.Rect)2 Test (org.junit.Test)1 Config (org.robolectric.annotation.Config)1