Commit c3346b5b authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

ProfileSyncServiceHarness: Rename signin/signout methods

This adds "PrimaryAccount" to the names (in preparation for supporting
secondary accounts), and also makes the SignIn/SignOut names symmetric.

TBRing trivial call site update in ukm_browsertest.cc
TBR=bcwhite

Bug: 871221
Change-Id: I136a4e91154a736d58ca67c060c66a09aed8a458
Reviewed-on: https://chromium-review.googlesource.com/1209605
Commit-Queue: Marc Treib <treib@chromium.org>
Reviewed-by: default avatarMohamed Amir Yosef <mamir@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589154}
parent 074455de
......@@ -871,7 +871,7 @@ IN_PROC_BROWSER_TEST_P(UkmBrowserTest, SingleSyncSignoutCheck) {
uint64_t original_client_id = client_id();
EXPECT_NE(0U, original_client_id);
harness->SignoutSyncService();
harness->SignOutPrimaryAccount();
EXPECT_FALSE(ukm_enabled());
EXPECT_NE(original_client_id, client_id());
......@@ -903,7 +903,7 @@ IN_PROC_BROWSER_TEST_P(UkmBrowserTest, MultiSyncSignoutCheck) {
EXPECT_TRUE(ukm_enabled());
EXPECT_EQ(original_client_id, client_id());
harness2->SignoutSyncService();
harness2->SignOutPrimaryAccount();
EXPECT_FALSE(ukm_enabled());
EXPECT_NE(original_client_id, client_id());
......
......@@ -120,7 +120,7 @@ ProfileSyncServiceHarness::ProfileSyncServiceHarness(
ProfileSyncServiceHarness::~ProfileSyncServiceHarness() { }
bool ProfileSyncServiceHarness::SignIn() {
bool ProfileSyncServiceHarness::SignInPrimaryAccount() {
// TODO(crbug.com/871221): This function should distinguish primary account
// (aka sync account) from secondary accounts (content area signin). Let's
// migrate tests that exercise transport-only sync to secondary accounts.
......@@ -171,6 +171,16 @@ bool ProfileSyncServiceHarness::SignIn() {
return false;
}
#if !defined(OS_CHROMEOS)
void ProfileSyncServiceHarness::SignOutPrimaryAccount() {
DCHECK(!username_.empty());
identity::ClearPrimaryAccount(
SigninManagerFactory::GetForProfile(profile_),
IdentityManagerFactory::GetForProfile(profile_),
identity::ClearPrimaryAccountPolicy::REMOVE_ALL_ACCOUNTS);
}
#endif // !OS_CHROMEOS
bool ProfileSyncServiceHarness::SetupSync() {
bool result = SetupSync(syncer::UserSelectableTypes(), false);
if (!result) {
......@@ -208,7 +218,7 @@ bool ProfileSyncServiceHarness::SetupSync(syncer::ModelTypeSet synced_datatypes,
// until we've finished configuration.
sync_blocker_ = service()->GetSetupInProgressHandle();
if (!SignIn()) {
if (!SignInPrimaryAccount()) {
return false;
}
......@@ -326,16 +336,6 @@ bool ProfileSyncServiceHarness::StartSyncService() {
return true;
}
#if !defined(OS_CHROMEOS)
void ProfileSyncServiceHarness::SignoutSyncService() {
DCHECK(!username_.empty());
identity::ClearPrimaryAccount(
SigninManagerFactory::GetForProfile(profile_),
IdentityManagerFactory::GetForProfile(profile_),
identity::ClearPrimaryAccountPolicy::REMOVE_ALL_ACCOUNTS);
}
#endif // !OS_CHROMEOS
bool ProfileSyncServiceHarness::HasUnsyncedItems() {
base::RunLoop loop;
bool result = false;
......
......@@ -44,8 +44,13 @@ class ProfileSyncServiceHarness {
~ProfileSyncServiceHarness();
// Signs in to a primary account without actually enabling sync the feature.
// TODO(treib): Rename this to SignInToPrimaryAccount.
bool SignIn();
bool SignInPrimaryAccount();
#if !defined(OS_CHROMEOS)
// Signs out of the primary account. ChromeOS doesn't have the concept of
// sign-out, so this only exists on other platforms.
void SignOutPrimaryAccount();
#endif // !OS_CHROMEOS
// Enables and configures sync for all available datatypes. Returns true only
// after sync has been fully initialized and authenticated, and we are ready
......@@ -83,14 +88,6 @@ class ProfileSyncServiceHarness {
// Starts the sync service after a previous stop.
bool StartSyncService();
#if !defined(OS_CHROMEOS)
// Signs out of the primary account. ChromeOS doesn't have the concept of
// sign-out, so this only exists on other platforms.
// TODO(treib): Rename this to SignOut() - it does nothing with the
// SyncService.
void SignoutSyncService();
#endif // !OS_CHROMEOS
// Returns whether this client has unsynced items. Avoid verifying false
// return values, because tests typically shouldn't make assumptions about
// other datatypes.
......
......@@ -48,7 +48,7 @@ IN_PROC_BROWSER_TEST_F(SingleClientStandaloneTransportSyncTest,
// Since standalone transport is disabled, signing in should *not* start the
// Sync machinery.
ASSERT_TRUE(GetClient(0)->SignIn());
ASSERT_TRUE(GetClient(0)->SignInPrimaryAccount());
EXPECT_EQ(syncer::SyncService::TransportState::WAITING_FOR_START_REQUEST,
GetSyncService(0)->GetTransportState());
}
......@@ -66,7 +66,7 @@ IN_PROC_BROWSER_TEST_F(SingleClientStandaloneTransportSyncTest,
// Signing in (without explicitly setting up Sync) should trigger starting the
// Sync machinery. Because IsFirstSetupComplete gets set automatically, this
// will actually start the full Sync feature, not just the transport.
ASSERT_TRUE(GetClient(0)->SignIn());
ASSERT_TRUE(GetClient(0)->SignInPrimaryAccount());
EXPECT_EQ(syncer::SyncService::TransportState::INITIALIZING,
GetSyncService(0)->GetTransportState());
......@@ -90,7 +90,7 @@ IN_PROC_BROWSER_TEST_F(SingleClientStandaloneTransportSyncTest,
// Signing in (without explicitly setting up Sync) should trigger starting the
// Sync machinery in standalone transport mode.
ASSERT_TRUE(GetClient(0)->SignIn());
ASSERT_TRUE(GetClient(0)->SignInPrimaryAccount());
EXPECT_EQ(syncer::SyncService::TransportState::START_DEFERRED,
GetSyncService(0)->GetTransportState());
......
......@@ -175,7 +175,7 @@ IN_PROC_BROWSER_TEST_F(SingleClientUserConsentsSyncTest,
// We avoid calling SetupSync(), because we don't want to turn on full sync,
// only sign in such that the standalone transport starts.
ASSERT_TRUE(SetupClients());
ASSERT_TRUE(GetClient(0)->SignIn());
ASSERT_TRUE(GetClient(0)->SignInPrimaryAccount());
ASSERT_TRUE(GetClient(0)->AwaitEngineInitialization());
ASSERT_TRUE(AwaitQuiescence());
ASSERT_FALSE(GetSyncService(0)->IsSyncActive())
......
......@@ -428,7 +428,7 @@ IN_PROC_BROWSER_TEST_P(SingleClientWalletSyncTest,
GetFakeServer()->SetWalletData(
{CreateDefaultSyncWalletAddress(), CreateDefaultSyncWalletCard()});
ASSERT_TRUE(GetClient(0)->SignIn());
ASSERT_TRUE(GetClient(0)->SignInPrimaryAccount());
ASSERT_TRUE(GetClient(0)->AwaitEngineInitialization(
/*skip_passphrase_verification=*/false));
ASSERT_TRUE(AwaitQuiescence());
......
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