Commit c5868cd1 authored by Alice Wang's avatar Alice Wang Committed by Chromium LUCI CQ

[Android] Test account management view for child account

This CL adds two render tests for account management view in child
account mode when the sign-out option should be hidden.

Bug: 1045525
Change-Id: I9e53396fe642c78eaa37dd04457cfcf72730109e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2597553Reviewed-by: default avatarTanmoy Mollik <triploblastic@chromium.org>
Reviewed-by: default avatarVictor Vianna (OOO 21/12-05/01) <victorvianna@google.com>
Commit-Queue: Alice Wang <aliceywang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#840107}
parent 61fe0266
...@@ -13,6 +13,8 @@ import static androidx.test.espresso.matcher.ViewMatchers.withText; ...@@ -13,6 +13,8 @@ import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.CoreMatchers.allOf; import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import static org.chromium.chrome.test.util.ViewUtils.onViewWaiting; import static org.chromium.chrome.test.util.ViewUtils.onViewWaiting;
...@@ -45,6 +47,9 @@ import org.chromium.chrome.test.util.browser.signin.AccountManagerTestRule; ...@@ -45,6 +47,9 @@ import org.chromium.chrome.test.util.browser.signin.AccountManagerTestRule;
import org.chromium.components.signin.identitymanager.ConsentLevel; import org.chromium.components.signin.identitymanager.ConsentLevel;
import org.chromium.content_public.browser.test.util.TestThreadUtils; import org.chromium.content_public.browser.test.util.TestThreadUtils;
/**
* Tests {@link AccountManagementFragment}.
*/
@RunWith(ChromeJUnit4ClassRunner.class) @RunWith(ChromeJUnit4ClassRunner.class)
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE}) @CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
public class AccountManagementFragmentTest { public class AccountManagementFragmentTest {
...@@ -67,9 +72,16 @@ public class AccountManagementFragmentTest { ...@@ -67,9 +72,16 @@ public class AccountManagementFragmentTest {
public final ChromeRenderTestRule mRenderTestRule = public final ChromeRenderTestRule mRenderTestRule =
ChromeRenderTestRule.Builder.withPublicCorpus().build(); ChromeRenderTestRule.Builder.withPublicCorpus().build();
private Profile mSpyProfile;
@Before @Before
public void setUp() { public void setUp() {
mActivityTestRule.startMainActivityOnBlankPage(); mActivityTestRule.startMainActivityOnBlankPage();
TestThreadUtils.runOnUiThreadBlocking(() -> {
mSpyProfile = spy(Profile.getLastUsedRegularProfile());
when(mSpyProfile.isChild()).thenReturn(false);
Profile.setLastUsedProfileForTesting(mSpyProfile);
});
} }
@Test @Test
...@@ -109,6 +121,32 @@ public class AccountManagementFragmentTest { ...@@ -109,6 +121,32 @@ public class AccountManagementFragmentTest {
mRenderTestRule.render(view, "account_management_fragment_signed_in_account_on_top"); mRenderTestRule.render(view, "account_management_fragment_signed_in_account_on_top");
} }
@Test
@MediumTest
@Feature("RenderTest")
@Features.DisableFeatures(ChromeFeatureList.MOBILE_IDENTITY_CONSISTENCY)
public void testAccountManagementViewForChildAccountLegacy() throws Exception {
when(mSpyProfile.isChild()).thenReturn(true);
mAccountManagerTestRule.addTestAccountThenSigninAndEnableSync();
mSettingsActivityTestRule.startSettingsActivity();
View view = mSettingsActivityTestRule.getFragment().getView();
onViewWaiting(allOf(is(view), isDisplayed()));
mRenderTestRule.render(view, "account_management_fragment_for_child_account_legacy");
}
@Test
@MediumTest
@Feature("RenderTest")
@Features.EnableFeatures(ChromeFeatureList.MOBILE_IDENTITY_CONSISTENCY)
public void testAccountManagementViewForChildAccount() throws Exception {
when(mSpyProfile.isChild()).thenReturn(true);
mAccountManagerTestRule.addTestAccountThenSigninAndEnableSync();
mSettingsActivityTestRule.startSettingsActivity();
View view = mSettingsActivityTestRule.getFragment().getView();
onViewWaiting(allOf(is(view), isDisplayed()));
mRenderTestRule.render(view, "account_management_fragment_for_child_account");
}
@Test @Test
@SmallTest @SmallTest
@Features.EnableFeatures(ChromeFeatureList.MOBILE_IDENTITY_CONSISTENCY) @Features.EnableFeatures(ChromeFeatureList.MOBILE_IDENTITY_CONSISTENCY)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment