Commit 45ebc1d7 authored by Tanmoy Mollik's avatar Tanmoy Mollik Committed by Commit Bot

[Android] Test sign out dialog in AccountManagerFragment

Test two different sign-out flows in AccountManagerFragment.

When the user is signed in without sync consent, sign out dialog should
not be shown and data on device should not be wiped.

When the user is signed in with sync consent, sign out dialog should be
shown giving the user the choice to wipe device data.

Bug: 1138935
Change-Id: Ie31d14b8fac938614dda927076e81344d52d5774
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2478980Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Commit-Queue: Tanmoy Mollik <triploblastic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820197}
parent 8ed81bab
...@@ -4,8 +4,17 @@ ...@@ -4,8 +4,17 @@
package org.chromium.chrome.browser.sync; package org.chromium.chrome.browser.sync;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.RootMatchers.isDialog;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import androidx.test.filters.MediumTest; import androidx.test.filters.MediumTest;
import androidx.test.filters.SmallTest;
import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
...@@ -13,15 +22,20 @@ import org.junit.runner.RunWith; ...@@ -13,15 +22,20 @@ import org.junit.runner.RunWith;
import org.chromium.base.test.util.CommandLineFlags; import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.flags.ChromeSwitches; import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.settings.SettingsActivityTestRule; import org.chromium.chrome.browser.settings.SettingsActivityTestRule;
import org.chromium.chrome.browser.signin.IdentityServicesProvider;
import org.chromium.chrome.browser.sync.settings.AccountManagementFragment; import org.chromium.chrome.browser.sync.settings.AccountManagementFragment;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule; import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.chrome.test.util.ChromeRenderTestRule; import org.chromium.chrome.test.util.ChromeRenderTestRule;
import org.chromium.chrome.test.util.browser.Features; import org.chromium.chrome.test.util.browser.Features;
import org.chromium.chrome.test.util.browser.signin.AccountManagerTestRule; import org.chromium.chrome.test.util.browser.signin.AccountManagerTestRule;
import org.chromium.components.signin.identitymanager.ConsentLevel;
import org.chromium.content_public.browser.test.util.TestThreadUtils;
@RunWith(ChromeJUnit4ClassRunner.class) @RunWith(ChromeJUnit4ClassRunner.class)
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE}) @CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
...@@ -79,4 +93,31 @@ public class AccountManagementFragmentTest { ...@@ -79,4 +93,31 @@ public class AccountManagementFragmentTest {
mRenderTestRule.render(mSettingsActivityTestRule.getFragment().getView(), mRenderTestRule.render(mSettingsActivityTestRule.getFragment().getView(),
"account_management_fragment_signed_in_account_on_top"); "account_management_fragment_signed_in_account_on_top");
} }
@Test
@SmallTest
@Features.EnableFeatures(ChromeFeatureList.MOBILE_IDENTITY_CONSISTENCY)
public void testSignOutUserWithoutShowingSignOutDialog() {
mAccountManagerTestRule.addTestAccountThenSignin();
mSettingsActivityTestRule.startSettingsActivity();
onView(withText(R.string.sign_out)).perform(click());
TestThreadUtils.runOnUiThreadBlocking(
()
-> Assert.assertNull("Account should be signed out!",
IdentityServicesProvider.get()
.getIdentityManager(Profile.getLastUsedRegularProfile())
.getPrimaryAccountInfo(ConsentLevel.NOT_REQUIRED)));
}
@Test
@SmallTest
@Features.EnableFeatures(ChromeFeatureList.MOBILE_IDENTITY_CONSISTENCY)
public void showSignOutDialogBeforeSigningUserOut() {
mAccountManagerTestRule.addTestAccountThenSigninAndEnableSync();
mSettingsActivityTestRule.startSettingsActivity();
onView(withText(R.string.sign_out_and_turn_off_sync)).perform(click());
onView(withText(R.string.signout_title)).inRoot(isDialog()).check(matches(isDisplayed()));
}
} }
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