Commit cd02b0f9 authored by Mihai Sardarescu's avatar Mihai Sardarescu Committed by Commit Bot

[iOS] Clear sign-in state on start-up.

This CL makes the sign-in tests more resilient:
* it clears the sign-in state on setup
* it commits pref changes on tear down to make sure that clearing the
last sign-in account is actually written to disk.

Bug: 961728

Change-Id: I833f3c888312c4a38ed13fa6bd9373989cf6dbb4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1605914
Commit-Queue: Mihai Sardarescu <msarda@chromium.org>
Reviewed-by: default avatarPeter Lee <pkl@chromium.org>
Reviewed-by: default avatarJérôme Lebel <jlebel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#659037}
parent 031945ba
......@@ -149,6 +149,11 @@ bool SignOutAndClearAccounts() {
browser_state->GetPrefs()->ClearPref(prefs::kGoogleServicesLastAccountId);
browser_state->GetPrefs()->ClearPref(prefs::kGoogleServicesLastUsername);
// |SignOutAndClearAccounts()| is called during shutdown. Commit all pref
// changes to ensure that clearing the last signed in account is saved on disk
// in case Chrome crashes during shutdown.
browser_state->GetPrefs()->CommitPendingWrite();
// Clear known identities.
ios::ChromeIdentityService* identity_service =
ios::GetChromeBrowserProvider()->GetChromeIdentityService();
......
......@@ -200,6 +200,11 @@ const CFTimeInterval kDrainTimeout = 5;
chrome_test_util::ResetSigninPromoPreferences();
chrome_test_util::ResetMockAuthentication();
// Reset any remaining sign-in state from previous tests.
GREYAssert(chrome_test_util::SignOutAndClearAccounts(),
@"Failed to clean up the sign-in state before starting the test.");
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey openNewTab]);
}
......
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