Commit 00ac7340 authored by Anastasiia Nikolaienko's avatar Anastasiia Nikolaienko Committed by Commit Bot

Remove setting stub user as primary account

The stub account on ChromeOS is treated specially for test purposes.
Remove this special-casing since we have unified the interface for
setting the primary account on ChromeOS with that on other platforms.

Update tests: remove expectations that "the stub user is signed in by
default on browsertests".

Bug: 1014074
Change-Id: I37a812e060631c101d1b2d7d897c785c4c200f47
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1872066
Commit-Queue: Anastasiia Nikolaienko <anastasiian@chromium.org>
Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarAlexander Alekseev <alemate@chromium.org>
Reviewed-by: default avatarKush Sinha <sinhak@chromium.org>
Cr-Commit-Position: refs/heads/master@{#717684}
parent a2b4dc88
......@@ -58,13 +58,7 @@ IN_PROC_BROWSER_TEST_F(BrowsingDataCounterUtilsBrowserTest,
GetFakeServer()->AsWeakPtr()));
std::string username;
#if defined(OS_CHROMEOS)
// In browser tests, the profile may already by authenticated with stub
// account |user_manager::kStubUserEmail|.
CoreAccountInfo info =
IdentityManagerFactory::GetForProfile(profile)->GetPrimaryAccountInfo();
username = info.email;
#endif
if (username.empty())
username = "user@gmail.com";
......@@ -73,10 +67,6 @@ IN_PROC_BROWSER_TEST_F(BrowsingDataCounterUtilsBrowserTest,
profile, username, "unused" /* password */,
ProfileSyncServiceHarness::SigninType::FAKE_SIGNIN);
#if defined(OS_CHROMEOS)
// On Chrome OS, the profile is always authenticated.
EXPECT_TRUE(ShouldShowCookieException(profile));
#else
// By default, a fresh profile is not signed in, nor syncing, so no cookie
// exception should be shown.
EXPECT_FALSE(ShouldShowCookieException(profile));
......@@ -84,6 +74,10 @@ IN_PROC_BROWSER_TEST_F(BrowsingDataCounterUtilsBrowserTest,
// Sign the profile in.
EXPECT_TRUE(harness->SignInPrimaryAccount());
#if defined(OS_CHROMEOS)
// On Chrome OS sync in turned on by default.
EXPECT_TRUE(ShouldShowCookieException(profile));
#else
// Sign-in alone shouldn't lead to a cookie exception.
EXPECT_FALSE(ShouldShowCookieException(profile));
#endif
......
......@@ -269,21 +269,6 @@ void ChromeSessionManager::Initialize(
oobe_configuration_->CheckConfiguration();
}
if (login_account_id == user_manager::StubAccountId()) {
// Start a user session with stub user. This also happens on a dev machine
// when running Chrome w/o login flow. See PreEarlyInitialization().
// In these contexts, emulate as if sync has been initialized.
VLOG(1) << "Starting Chrome with stub login.";
std::string login_user_id = login_account_id.GetUserEmail();
IdentityManagerFactory::GetForProfile(profile)
->GetPrimaryAccountMutator()
->DeprecatedSetPrimaryAccountAndUpdateAccountInfo(login_user_id,
login_user_id);
StartUserSession(profile, login_user_id);
return;
}
VLOG(1) << "Starting Chrome with a user session.";
StartUserSession(profile, login_account_id.GetUserEmail());
}
......
......@@ -377,7 +377,13 @@ Polymer({
this.syncStatus = syncStatus;
if (shouldRecordSigninImpression && !this.shouldShowSyncAccountControl_()) {
if (
shouldRecordSigninImpression
// <if expr="not chromeos">
// Sync account control is not shown on Chrome OS.
&& !this.shouldShowSyncAccountControl_()
// </if>
) {
// SyncAccountControl records the impressions user actions.
chrome.metricsPrivate.recordUserAction('Signin_Impression_FromSettings');
}
......
......@@ -127,16 +127,11 @@ class ChromePasswordProtectionServiceBrowserTest : public InProcessBrowserTest {
// Makes user signed-in with the stub account's email and |hosted_domain|.
void SetUpPrimaryAccountWithHostedDomain(const std::string& hosted_domain) {
// Ensure that the stub user is signed in.
#if defined(OS_CHROMEOS)
// On ChromeOS, the stub user is signed in by default on browsertests.
CoreAccountInfo account_info =
identity_test_env()->identity_manager()->GetPrimaryAccountInfo();
identity_test_env()->SetRefreshTokenForPrimaryAccount();
#else
CoreAccountInfo account_info =
identity_test_env()->MakePrimaryAccountAvailable(
user_manager::kStubUserEmail);
#endif
ASSERT_EQ(account_info.email, user_manager::kStubUserEmail);
identity_test_env()->SimulateSuccessfulFetchOfAccountInfo(
......
......@@ -74,14 +74,6 @@ class ChromePasswordProtectionServiceSyncBrowserTest : public SyncTest {
GetFakeServer()->AsWeakPtr()));
std::string username;
#if defined(OS_CHROMEOS)
// In browser tests, the profile may already by authenticated with stub
// account |user_manager::kStubUserEmail|.
CoreAccountInfo info =
IdentityManagerFactory::GetForProfile(browser()->profile())
->GetPrimaryAccountInfo();
username = info.email;
#endif
if (username.empty()) {
username = "user@example.com";
}
......@@ -91,10 +83,8 @@ class ChromePasswordProtectionServiceSyncBrowserTest : public SyncTest {
browser()->profile(), username, "password",
ProfileSyncServiceHarness::SigninType::FAKE_SIGNIN);
#if !defined(OS_CHROMEOS)
// Sign the profile in.
ASSERT_TRUE(harness->SignInPrimaryAccount());
#endif
CoreAccountInfo current_info =
IdentityManagerFactory::GetForProfile(browser()->profile())
......
......@@ -97,14 +97,7 @@ class PageInfoBubbleViewSyncBrowserTest : public SyncTest {
GetFakeServer()->AsWeakPtr()));
std::string username;
#if defined(OS_CHROMEOS)
// In browser tests, the profile may already by authenticated with stub
// account |user_manager::kStubUserEmail|.
CoreAccountInfo info =
IdentityManagerFactory::GetForProfile(browser()->profile())
->GetPrimaryAccountInfo();
username = info.email;
#endif
if (username.empty()) {
username = "user@gmail.com";
}
......@@ -114,10 +107,8 @@ class PageInfoBubbleViewSyncBrowserTest : public SyncTest {
browser()->profile(), username, "password",
ProfileSyncServiceHarness::SigninType::FAKE_SIGNIN);
#if !defined(OS_CHROMEOS)
// Sign the profile in.
ASSERT_TRUE(harness->SignInPrimaryAccount());
#endif
CoreAccountInfo current_info =
IdentityManagerFactory::GetForProfile(browser()->profile())
......
......@@ -244,20 +244,16 @@ TEST_F('SyncInternalsWebUITest', 'Uninitialized', function() {
GEN('#if defined(OS_CHROMEOS)');
// On ChromeOS, browser tests are signed in by default to mimic production,
// so the sync transport layer should be enabled. Note that the sync *feature*
// might still be disabled depending on how the test infrastructure is
// configured.
TEST_F('SyncInternalsWebUITest', 'SyncTransportEnabledByDefault', function() {
// The specific transport state is dependent on the timing of startup, but it
// should not be disabled.
expectFalse(this.hasInDetails(true, 'Transport State', 'Disabled'));
// Sync should be disabled if there was no primary account set.
TEST_F('SyncInternalsWebUITest', 'SyncDisabledByDefaultChromeOS', function() {
expectTrue(this.hasInDetails(true, 'Transport State', 'Disabled'));
expectTrue(this.hasInDetails(true, 'Disable Reasons', 'Not signed in'));
expectTrue(this.hasInDetails(true, 'Username', ''));
});
GEN('#else');
// On non-ChromeOS, sync should be disabled if there was no primary account
// set.
// On non-ChromeOS, sync should be disabled if there was no primary account set.
TEST_F('SyncInternalsWebUITest', 'SyncDisabledByDefault', function() {
expectTrue(this.hasInDetails(true, 'Transport State', 'Disabled'));
expectTrue(
......
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