Loading tests/common/com/android/documentsui/bots/SidebarBot.java +0 −24 Original line number Diff line number Diff line Loading @@ -37,8 +37,6 @@ import android.util.Log; import android.view.MotionEvent; import android.view.View; import androidx.annotation.IdRes; import androidx.recyclerview.widget.RecyclerView; import androidx.test.espresso.ViewInteraction; import androidx.test.uiautomator.UiDevice; import androidx.test.uiautomator.UiObject; Loading Loading @@ -247,26 +245,4 @@ public class SidebarBot extends Bots.BaseBot { assertNotNull("Context menu item " + menuOption + " not found", menuItem); menuItem.perform(new RelaxedClickAction()); } /** * Check if the specified position inside the root lists has focus or not. * @param containerId the root list container id, the root list must be a recycler view. * @param position the item position in */ public void assertPositionFocused(@IdRes int containerId, int position) { onView(allOf(withId(R.id.roots_list), isDescendantOfA(withId(containerId)))).check( (view, noViewFoundException) -> { if (noViewFoundException != null) { throw noViewFoundException; } RecyclerView recyclerView = (RecyclerView) view; RecyclerView.ViewHolder viewHolder = recyclerView.findViewHolderForAdapterPosition(position); if (!viewHolder.itemView.isFocused()) { throw new AssertionError( "Expect item at position " + position + " to be focused but it's not."); } }); } } tests/functional/com/android/documentsui/KeyboardNavigationUiTest.java +0 −46 Original line number Diff line number Diff line Loading @@ -16,19 +16,11 @@ package com.android.documentsui; import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.assertion.ViewAssertions.matches; import static androidx.test.espresso.matcher.ViewMatchers.hasFocus; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static com.android.documentsui.StubProvider.ROOT_0_ID; import static com.android.documentsui.flags.Flags.FLAG_USE_MATERIAL3; import static com.android.documentsui.util.Material3Config.getRes; import android.platform.test.annotations.EnableFlags; import android.view.KeyEvent; import androidx.annotation.IdRes; import androidx.test.filters.LargeTest; import com.android.documentsui.base.RootInfo; Loading Loading @@ -111,42 +103,4 @@ public class KeyboardNavigationUiTest extends ActivityTestJunit4<FilesActivity> bots.roots.assertHasFocus(); } } @Test @EnableFlags({FLAG_USE_MATERIAL3}) public void testKeyboard_tabCycleInRootsList() throws Exception { // Focus the root CoordinatorLayout explicitly before the test to avoid the first // Tab press accidentally focus on the root CoordinatorLayout. // TODO(b/417871278): remove this after removing the grey overlay. onView(withId(R.id.coordinator_layout)).check((view, noViewFoundException) -> { if (view != null) { view.post(view::requestFocus); } }).check(matches(hasFocus())); // We want to explicitly check the focus inside the nav rail root list in nav rail layout, // otherwise, check it in the drawer (container_roots). final @IdRes int containerId = bots.main.inNavRailLayout() ? getRes(R.id.nav_rail_container_roots) : getRes(R.id.container_roots); if (bots.main.inDrawerLayout()) { // If drawer layout is used, we need to open drawer first to show all the nav roots. bots.roots.openDrawer(); } else if (bots.main.inNavRailLayout()) { // If nav rail layout is used, the first Tab will move the focus to the burger menu // inside the nav rail root list. bots.keyboard.pressKey(KeyEvent.KEYCODE_TAB); onView(withId(R.id.nav_rail_burger_menu)).check(matches(hasFocus())); } // Only check the first 2 items here because we don't want to deal with the divider item // (which is also a child of the root list), the first 2 items are guaranteed not to be // divider items. for (int i = 0; i <= 1; i++) { bots.keyboard.pressKey(KeyEvent.KEYCODE_TAB); bots.roots.assertPositionFocused(containerId, i); } } } Loading
tests/common/com/android/documentsui/bots/SidebarBot.java +0 −24 Original line number Diff line number Diff line Loading @@ -37,8 +37,6 @@ import android.util.Log; import android.view.MotionEvent; import android.view.View; import androidx.annotation.IdRes; import androidx.recyclerview.widget.RecyclerView; import androidx.test.espresso.ViewInteraction; import androidx.test.uiautomator.UiDevice; import androidx.test.uiautomator.UiObject; Loading Loading @@ -247,26 +245,4 @@ public class SidebarBot extends Bots.BaseBot { assertNotNull("Context menu item " + menuOption + " not found", menuItem); menuItem.perform(new RelaxedClickAction()); } /** * Check if the specified position inside the root lists has focus or not. * @param containerId the root list container id, the root list must be a recycler view. * @param position the item position in */ public void assertPositionFocused(@IdRes int containerId, int position) { onView(allOf(withId(R.id.roots_list), isDescendantOfA(withId(containerId)))).check( (view, noViewFoundException) -> { if (noViewFoundException != null) { throw noViewFoundException; } RecyclerView recyclerView = (RecyclerView) view; RecyclerView.ViewHolder viewHolder = recyclerView.findViewHolderForAdapterPosition(position); if (!viewHolder.itemView.isFocused()) { throw new AssertionError( "Expect item at position " + position + " to be focused but it's not."); } }); } }
tests/functional/com/android/documentsui/KeyboardNavigationUiTest.java +0 −46 Original line number Diff line number Diff line Loading @@ -16,19 +16,11 @@ package com.android.documentsui; import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.assertion.ViewAssertions.matches; import static androidx.test.espresso.matcher.ViewMatchers.hasFocus; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static com.android.documentsui.StubProvider.ROOT_0_ID; import static com.android.documentsui.flags.Flags.FLAG_USE_MATERIAL3; import static com.android.documentsui.util.Material3Config.getRes; import android.platform.test.annotations.EnableFlags; import android.view.KeyEvent; import androidx.annotation.IdRes; import androidx.test.filters.LargeTest; import com.android.documentsui.base.RootInfo; Loading Loading @@ -111,42 +103,4 @@ public class KeyboardNavigationUiTest extends ActivityTestJunit4<FilesActivity> bots.roots.assertHasFocus(); } } @Test @EnableFlags({FLAG_USE_MATERIAL3}) public void testKeyboard_tabCycleInRootsList() throws Exception { // Focus the root CoordinatorLayout explicitly before the test to avoid the first // Tab press accidentally focus on the root CoordinatorLayout. // TODO(b/417871278): remove this after removing the grey overlay. onView(withId(R.id.coordinator_layout)).check((view, noViewFoundException) -> { if (view != null) { view.post(view::requestFocus); } }).check(matches(hasFocus())); // We want to explicitly check the focus inside the nav rail root list in nav rail layout, // otherwise, check it in the drawer (container_roots). final @IdRes int containerId = bots.main.inNavRailLayout() ? getRes(R.id.nav_rail_container_roots) : getRes(R.id.container_roots); if (bots.main.inDrawerLayout()) { // If drawer layout is used, we need to open drawer first to show all the nav roots. bots.roots.openDrawer(); } else if (bots.main.inNavRailLayout()) { // If nav rail layout is used, the first Tab will move the focus to the burger menu // inside the nav rail root list. bots.keyboard.pressKey(KeyEvent.KEYCODE_TAB); onView(withId(R.id.nav_rail_burger_menu)).check(matches(hasFocus())); } // Only check the first 2 items here because we don't want to deal with the divider item // (which is also a child of the root list), the first 2 items are guaranteed not to be // divider items. for (int i = 0; i <= 1; i++) { bots.keyboard.pressKey(KeyEvent.KEYCODE_TAB); bots.roots.assertPositionFocused(containerId, i); } } }