diff options
author | 2023-11-22 17:44:27 +0000 | |
---|---|---|
committer | 2023-11-22 17:44:27 +0000 | |
commit | c0432a40a7ad69be5413784f37cd7859de2964b7 (patch) | |
tree | 8d00bb9f95c9560a0e8dfc0071ab6f966632cf6b | |
parent | d5a9e6eed9753dee917ed885bac6e0f6f4ca3b56 (diff) | |
parent | 7b5131b4a44923d2d79fbc664ccc1b8332aab641 (diff) |
Merge "Fix profile button tests in single user mode" into udc-mainline-prod
3 files changed, 17 insertions, 68 deletions
diff --git a/tests/src/com/android/providers/media/photopicker/espresso/MultiSelectTest.java b/tests/src/com/android/providers/media/photopicker/espresso/MultiSelectTest.java index a618a8fbe..1ee5378b2 100644 --- a/tests/src/com/android/providers/media/photopicker/espresso/MultiSelectTest.java +++ b/tests/src/com/android/providers/media/photopicker/espresso/MultiSelectTest.java @@ -79,11 +79,6 @@ public class MultiSelectTest extends PhotoPickerBaseTest { } @Test - public void testMultiSelectDoesNotShowProfileButton() { - assertProfileButtonNotShown(); - } - - @Test public void testMultiselect_showDragBar() { onView(withId(DRAG_BAR_ID)).check(matches(isDisplayed())); } @@ -307,29 +302,4 @@ public class MultiSelectTest extends PhotoPickerBaseTest { assertThat(mScenario.getResult().getResultCode()).isEqualTo( Activity.RESULT_CANCELED); } - - - private void assertProfileButtonNotShown() { - // Partial screen does not show profile button - onView(withId(R.id.profile_button)).check(matches(not(isDisplayed()))); - - // Navigate to Albums tab - onView(allOf(withText(PICKER_ALBUMS_STRING_ID), isDescendantOfA(withId(TAB_LAYOUT_ID)))) - .perform(click()); - onView(withId(R.id.profile_button)).check(matches(not(isDisplayed()))); - - final int cameraStringId = R.string.picker_category_camera; - // Navigate to photos in Camera album - onView(allOf(withText(cameraStringId), - isDescendantOfA(withId(PICKER_TAB_RECYCLERVIEW_ID)))).perform(click()); - onView(withId(R.id.profile_button)).check(matches(not(isDisplayed()))); - - // Click back button - onView(withContentDescription("Navigate up")).perform(click()); - - // on clicking back button we are back to Album grid - onView(allOf(withText(PICKER_ALBUMS_STRING_ID), isDescendantOfA(withId(TAB_LAYOUT_ID)))) - .check(matches(isSelected())); - onView(withId(R.id.profile_button)).check(matches(not(isDisplayed()))); - } } diff --git a/tests/src/com/android/providers/media/photopicker/espresso/PhotoPickerActivityTest.java b/tests/src/com/android/providers/media/photopicker/espresso/PhotoPickerActivityTest.java index d895bec1c..169744ba5 100644 --- a/tests/src/com/android/providers/media/photopicker/espresso/PhotoPickerActivityTest.java +++ b/tests/src/com/android/providers/media/photopicker/espresso/PhotoPickerActivityTest.java @@ -96,7 +96,8 @@ public class PhotoPickerActivityTest extends PhotoPickerBaseTest { onView(withId(R.id.fragment_container)).check(matches(isDisplayed())); onView(withId(DRAG_BAR_ID)).check(matches(isDisplayed())); onView(withId(PRIVACY_TEXT_ID)).check(matches(isDisplayed())); - // Partial screen does not show profile button + // Assuming by default, the tests run without a managed user + // Single user mode does not show profile button onView(withId(R.id.profile_button)).check(matches(not(isDisplayed()))); onView(withId(android.R.id.empty)).check(matches(not(isDisplayed()))); @@ -108,22 +109,24 @@ public class PhotoPickerActivityTest extends PhotoPickerBaseTest { } @Test - public void testDoesNotShowProfileButton_partialScreen() { - assertProfileButtonNotShown(); - } - - @Test - @Ignore("Enable after b/222013536 is fixed") - public void testDoesNotShowProfileButton_fullScreen() { - // Bottomsheet assertions are different for landscape mode - setPortraitOrientation(mScenario); + public void testProfileButtonHiddenInSingleUserMode() { + // Assuming that the test runs without a managed user - // Partial screen does not show profile button + // Single user mode does not show profile button in the main grid onView(withId(R.id.profile_button)).check(matches(not(isDisplayed()))); - BottomSheetTestUtils.swipeUp(mScenario); + onView(withId(TAB_LAYOUT_ID)).check(matches(isDisplayed())); - assertProfileButtonNotShown(); + // On clicking albums tab item, we should see albums tab + onView(allOf(withText(PICKER_ALBUMS_STRING_ID), isDescendantOfA(withId(TAB_LAYOUT_ID)))) + .perform(click()); + onView(allOf(withText(PICKER_ALBUMS_STRING_ID), isDescendantOfA(withId(TAB_LAYOUT_ID)))) + .check(matches(isSelected())); + onView(allOf(withText(PICKER_PHOTOS_STRING_ID), isDescendantOfA(withId(TAB_LAYOUT_ID)))) + .check(matches(isNotSelected())); + + // Single user mode does not show profile button in the albums grid + onView(withId(R.id.profile_button)).check(matches(not(isDisplayed()))); } @Test @@ -349,28 +352,4 @@ public class PhotoPickerActivityTest extends PhotoPickerBaseTest { onView(allOf(withText(PICKER_PHOTOS_STRING_ID), isDescendantOfA(withId(TAB_LAYOUT_ID)))) .check(matches(isSelected())); } - - private void assertProfileButtonNotShown() { - // Partial screen does not show profile button - onView(withId(R.id.profile_button)).check(matches(not(isDisplayed()))); - - // Navigate to Albums tab - onView(allOf(withText(PICKER_ALBUMS_STRING_ID), isDescendantOfA(withId(TAB_LAYOUT_ID)))) - .perform(click()); - onView(withId(R.id.profile_button)).check(matches(not(isDisplayed()))); - - final int cameraStringId = R.string.picker_category_camera; - // Navigate to photos in Camera album - onView(allOf(withText(cameraStringId), - isDescendantOfA(withId(PICKER_TAB_RECYCLERVIEW_ID)))).perform(click()); - onView(withId(R.id.profile_button)).check(matches(not(isDisplayed()))); - - // Click back button - onView(withContentDescription("Navigate up")).perform(click()); - - // on clicking back button we are back to Album grid - onView(allOf(withText(PICKER_ALBUMS_STRING_ID), isDescendantOfA(withId(TAB_LAYOUT_ID)))) - .check(matches(isSelected())); - onView(withId(R.id.profile_button)).check(matches(not(isDisplayed()))); - } } diff --git a/tests/src/com/android/providers/media/photopicker/espresso/PhotoPickerUserSelectActivityTest.java b/tests/src/com/android/providers/media/photopicker/espresso/PhotoPickerUserSelectActivityTest.java index e0818b4fb..110fbb786 100644 --- a/tests/src/com/android/providers/media/photopicker/espresso/PhotoPickerUserSelectActivityTest.java +++ b/tests/src/com/android/providers/media/photopicker/espresso/PhotoPickerUserSelectActivityTest.java @@ -92,7 +92,7 @@ public class PhotoPickerUserSelectActivityTest extends PhotoPickerBaseTest { @Test public void testActivityProfileButtonNotShown() { launchValidActivity(); - // Partial screen does not show profile button + // User select mode does not show profile button onView(withId(R.id.profile_button)).check(matches(not(isDisplayed()))); // Navigate to Albums tab |