Loading core/tests/coretests/src/android/view/accessibility/AccessibilityNodeInfoTest.java +27 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.view.accessibility; import static junit.framework.Assert.assertEquals; import static org.hamcrest.Matchers.emptyCollectionOf; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasItem; Loading @@ -33,6 +35,8 @@ import com.android.internal.util.CollectionUtils; import org.junit.Test; import org.junit.runner.RunWith; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.ArrayList; @LargeTest Loading @@ -41,13 +45,19 @@ public class AccessibilityNodeInfoTest { // The number of fields tested in the corresponding CTS AccessibilityNodeInfoTest: // See fullyPopulateAccessibilityNodeInfo, assertEqualsAccessibilityNodeInfo, // and assertAccessibilityNodeInfoCleared in that class. private static final int NUM_MARSHALLED_PROPERTIES = 35; private static final int NUM_MARSHALLED_PROPERTIES = 33; /** * The number of properties that are purposely not marshalled * mOriginalText - Used when resolving clickable spans; intentionally not parceled * mSealed - Unparceling sets the sealed bit * mConnectionId - Set after unparceling. Actually is parceled, but probably shouldn't be. */ private static final int NUM_NONMARSHALLED_PROPERTIES = 1; private static final int NUM_NONMARSHALLED_PROPERTIES = 3; // The number of flags held in boolean properties. Their values should also be double-checked // in the methods above. private static final int NUM_BOOLEAN_PROPERTIES = 22; @Test public void testStandardActions_serializationFlagIsValid() { Loading Loading @@ -130,4 +140,19 @@ public class AccessibilityNodeInfoTest { AccessibilityEventTest.assertNoNewNonStaticFieldsAdded(AccessibilityNodeInfo.class, NUM_MARSHALLED_PROPERTIES + NUM_NONMARSHALLED_PROPERTIES); } @Test public void updateCtsToTestNewBooleanProperties() { int booleanPropertiesCount = 0; for (Field field : AccessibilityNodeInfo.class.getDeclaredFields()) { if (((field.getModifiers() & Modifier.STATIC) != 0) && (field.getName().contains("BOOLEAN_PROPERTY"))) { booleanPropertiesCount++; } } assertEquals("New boolean properties. Make sure you're testing them in CTS", NUM_BOOLEAN_PROPERTIES, booleanPropertiesCount); } } Loading
core/tests/coretests/src/android/view/accessibility/AccessibilityNodeInfoTest.java +27 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.view.accessibility; import static junit.framework.Assert.assertEquals; import static org.hamcrest.Matchers.emptyCollectionOf; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasItem; Loading @@ -33,6 +35,8 @@ import com.android.internal.util.CollectionUtils; import org.junit.Test; import org.junit.runner.RunWith; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.ArrayList; @LargeTest Loading @@ -41,13 +45,19 @@ public class AccessibilityNodeInfoTest { // The number of fields tested in the corresponding CTS AccessibilityNodeInfoTest: // See fullyPopulateAccessibilityNodeInfo, assertEqualsAccessibilityNodeInfo, // and assertAccessibilityNodeInfoCleared in that class. private static final int NUM_MARSHALLED_PROPERTIES = 35; private static final int NUM_MARSHALLED_PROPERTIES = 33; /** * The number of properties that are purposely not marshalled * mOriginalText - Used when resolving clickable spans; intentionally not parceled * mSealed - Unparceling sets the sealed bit * mConnectionId - Set after unparceling. Actually is parceled, but probably shouldn't be. */ private static final int NUM_NONMARSHALLED_PROPERTIES = 1; private static final int NUM_NONMARSHALLED_PROPERTIES = 3; // The number of flags held in boolean properties. Their values should also be double-checked // in the methods above. private static final int NUM_BOOLEAN_PROPERTIES = 22; @Test public void testStandardActions_serializationFlagIsValid() { Loading Loading @@ -130,4 +140,19 @@ public class AccessibilityNodeInfoTest { AccessibilityEventTest.assertNoNewNonStaticFieldsAdded(AccessibilityNodeInfo.class, NUM_MARSHALLED_PROPERTIES + NUM_NONMARSHALLED_PROPERTIES); } @Test public void updateCtsToTestNewBooleanProperties() { int booleanPropertiesCount = 0; for (Field field : AccessibilityNodeInfo.class.getDeclaredFields()) { if (((field.getModifiers() & Modifier.STATIC) != 0) && (field.getName().contains("BOOLEAN_PROPERTY"))) { booleanPropertiesCount++; } } assertEquals("New boolean properties. Make sure you're testing them in CTS", NUM_BOOLEAN_PROPERTIES, booleanPropertiesCount); } }