FileDocCategorySizeDatePackage
RecycleAccessibilityEventTest.javaAPI DocAndroid 5.1 API3038Thu Mar 12 22:22:12 GMT 2015android.view.accessibility

RecycleAccessibilityEventTest

public class RecycleAccessibilityEventTest extends TestCase
This class exercises the caching and recycling of {@link AccessibilityEvent}s.

Fields Summary
private static final String
CLASS_NAME
private static final String
PACKAGE_NAME
private static final String
TEXT
private static final String
CONTENT_DESCRIPTION
private static final int
ITEM_COUNT
private static final int
CURRENT_ITEM_INDEX
private static final int
FROM_INDEX
private static final int
ADDED_COUNT
private static final int
REMOVED_COUNT
Constructors Summary
Methods Summary
public voidtestAccessibilityEventViewTextChangedType()
If an {@link AccessibilityEvent} is marshaled/unmarshaled correctly


                
    
       
        AccessibilityEvent first =
            AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED);
        assertNotNull(first);

        first.setClassName(CLASS_NAME);
        first.setPackageName(PACKAGE_NAME);
        first.getText().add(TEXT);
        first.setFromIndex(FROM_INDEX);
        first.setAddedCount(ADDED_COUNT);
        first.setRemovedCount(REMOVED_COUNT);
        first.setChecked(true);
        first.setContentDescription(CONTENT_DESCRIPTION);
        first.setItemCount(ITEM_COUNT);
        first.setCurrentItemIndex(CURRENT_ITEM_INDEX);
        first.setEnabled(true);
        first.setPassword(true);

        first.recycle();

        assertNotNull(first);
        assertNull(first.getClassName());
        assertNull(first.getPackageName());
        assertEquals(0, first.getText().size());
        assertFalse(first.isChecked());
        assertNull(first.getContentDescription());
        assertEquals(-1, first.getItemCount());
        assertEquals(AccessibilityEvent.INVALID_POSITION, first.getCurrentItemIndex());
        assertFalse(first.isEnabled());
        assertFalse(first.isPassword());
        assertEquals(-1, first.getFromIndex());
        assertEquals(-1, first.getAddedCount());
        assertEquals(-1, first.getRemovedCount());

        // get another event from the pool (this must be the recycled first)
        AccessibilityEvent second = AccessibilityEvent.obtain();
        assertEquals(first, second);