Java Code Examples for androidx.core.view.ViewCompat#onInitializeAccessibilityNodeInfo()
The following examples show how to use
androidx.core.view.ViewCompat#onInitializeAccessibilityNodeInfo() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MaterialButtonToggleGroupTest.java From material-components-android with Apache License 2.0 | 6 votes |
@Test @Config(sdk = 23) public void onInitializeAccessibilityNodeInfo() { AccessibilityNodeInfoCompat groupInfoCompat = AccessibilityNodeInfoCompat.obtain(); ViewCompat.onInitializeAccessibilityNodeInfo(toggleGroup, groupInfoCompat); CollectionInfoCompat collectionInfo = groupInfoCompat.getCollectionInfo(); assertEquals(3, collectionInfo.getColumnCount()); assertEquals(1, collectionInfo.getRowCount()); MaterialButton secondChild = (MaterialButton) toggleGroup.getChildAt(1); secondChild.setChecked(true); AccessibilityNodeInfoCompat buttonInfoCompat = AccessibilityNodeInfoCompat.obtain(); ViewCompat.onInitializeAccessibilityNodeInfo(secondChild, buttonInfoCompat); CollectionItemInfoCompat itemInfo = buttonInfoCompat.getCollectionItemInfo(); assertEquals(1, itemInfo.getColumnIndex()); assertEquals(0, itemInfo.getRowIndex()); assertTrue(itemInfo.isSelected()); }
Example 2
Source File: ChipGroupTest.java From material-components-android with Apache License 2.0 | 6 votes |
@Test @Config(minSdk = 23, maxSdk = 28) public void isSingleLine_initializesAccessibilityNodeInfo() { chipgroup.setSingleLine(true); AccessibilityNodeInfoCompat groupInfoCompat = AccessibilityNodeInfoCompat.obtain(); // onLayout must be triggered for rowCount chipgroup.layout(0, 0, 100, 100); ViewCompat.onInitializeAccessibilityNodeInfo(chipgroup, groupInfoCompat); CollectionInfoCompat collectionInfo = groupInfoCompat.getCollectionInfo(); assertEquals(chipgroup.getChildCount(), collectionInfo.getColumnCount()); assertEquals(1, collectionInfo.getRowCount()); Chip secondChild = (Chip) chipgroup.getChildAt(1); secondChild.setChecked(true); AccessibilityNodeInfoCompat chipInfoCompat = AccessibilityNodeInfoCompat.obtain(); ViewCompat.onInitializeAccessibilityNodeInfo(secondChild, chipInfoCompat); CollectionItemInfoCompat itemInfo = chipInfoCompat.getCollectionItemInfo(); assertEquals(1, itemInfo.getColumnIndex()); assertEquals(0, itemInfo.getRowIndex()); assertTrue(itemInfo.isSelected()); }
Example 3
Source File: ChipGroupTest.java From material-components-android with Apache License 2.0 | 6 votes |
@Test @Config(minSdk = 23, maxSdk = 28) public void isNotSingleLine_initializesAccessibilityNodeInfo() { AccessibilityNodeInfoCompat groupInfoCompat = AccessibilityNodeInfoCompat.obtain(); // onLayout must be triggered for rowCount chipgroup.layout(0, 0, 10, 100); ViewCompat.onInitializeAccessibilityNodeInfo(chipgroup, groupInfoCompat); CollectionInfoCompat collectionInfo = groupInfoCompat.getCollectionInfo(); assertEquals(-1, collectionInfo.getColumnCount()); assertEquals(2, collectionInfo.getRowCount()); Chip secondChild = (Chip) chipgroup.getChildAt(2); secondChild.setChecked(true); AccessibilityNodeInfoCompat chipInfoCompat = AccessibilityNodeInfoCompat.obtain(); ViewCompat.onInitializeAccessibilityNodeInfo(secondChild, chipInfoCompat); CollectionItemInfoCompat itemInfo = chipInfoCompat.getCollectionItemInfo(); assertEquals(-1, itemInfo.getColumnIndex()); assertEquals(1, itemInfo.getRowIndex()); assertTrue(itemInfo.isSelected()); }
Example 4
Source File: BottomNavigationViewTest.java From material-components-android with Apache License 2.0 | 5 votes |
@UiThreadTest @Test @SmallTest @SdkSuppress(minSdkVersion = Build.VERSION_CODES.M) public void testOnInitializeAccessibilityNodeInfo() { BottomNavigationMenuView menuView = bottomNavigation.menuView; AccessibilityNodeInfoCompat groupInfoCompat = AccessibilityNodeInfoCompat.obtain(); ViewCompat.onInitializeAccessibilityNodeInfo(menuView, groupInfoCompat); CollectionInfoCompat collectionInfo = groupInfoCompat.getCollectionInfo(); Assert.assertEquals(3, collectionInfo.getColumnCount()); Assert.assertEquals(1, collectionInfo.getRowCount()); BottomNavigationItemView secondChild = (BottomNavigationItemView) menuView.getChildAt(1); secondChild.setSelected(true); AccessibilityNodeInfoCompat buttonInfoCompat = AccessibilityNodeInfoCompat.obtain(); ViewCompat.onInitializeAccessibilityNodeInfo(secondChild, buttonInfoCompat); // A tab that is currently selected won't be clickable by a11y assertFalse(buttonInfoCompat.isClickable()); assertFalse( AccessibilityUtils.hasAction(buttonInfoCompat, AccessibilityActionCompat.ACTION_CLICK)); CollectionItemInfoCompat itemInfo = buttonInfoCompat.getCollectionItemInfo(); Assert.assertEquals(1, itemInfo.getColumnIndex()); Assert.assertEquals(0, itemInfo.getRowIndex()); assertTrue(itemInfo.isSelected()); }
Example 5
Source File: TabLayoutTest.java From material-components-android with Apache License 2.0 | 5 votes |
@Test @SdkSuppress(minSdkVersion = Build.VERSION_CODES.M) public void initializesAccessibilityNodeInfo() { final LayoutInflater inflater = LayoutInflater.from(activityTestRule.getActivity()); final TabLayout tabs = (TabLayout) inflater.inflate(R.layout.design_tabs, null); final TabLayout.Tab tab1 = tabs.newTab(); tabs.addTab(tab1); final TabLayout.Tab tab2 = tabs.newTab(); tabs.addTab(tab2, true); tabs.getTabAt(0).setCustomView(R.layout.design_tab_item_custom); tabs.getTabAt(1).setCustomView(R.layout.design_tab_item_custom); AccessibilityNodeInfoCompat groupInfoCompat = AccessibilityNodeInfoCompat.obtain(); ViewCompat.onInitializeAccessibilityNodeInfo(tabs, groupInfoCompat); CollectionInfoCompat collectionInfo = groupInfoCompat.getCollectionInfo(); assertEquals(2, collectionInfo.getColumnCount()); assertEquals(1, collectionInfo.getRowCount()); TabView secondChild = tabs.getTabAt(1).view; secondChild.setSelected(true); AccessibilityNodeInfoCompat tabInfoCompat = AccessibilityNodeInfoCompat.obtain(); ViewCompat.onInitializeAccessibilityNodeInfo(secondChild, tabInfoCompat); // A tab that is currently selected won't be clickable assertFalse(tabInfoCompat.isClickable()); assertFalse( AccessibilityUtils.hasAction(tabInfoCompat, AccessibilityActionCompat.ACTION_CLICK)); CollectionItemInfoCompat itemInfo = tabInfoCompat.getCollectionItemInfo(); assertEquals(1, itemInfo.getColumnIndex()); assertEquals(0, itemInfo.getRowIndex()); assertTrue(itemInfo.isSelected()); }