Commit 7576b181 authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

ProfileSyncService tests: Replace a bunch of EXPECTs with ASSERTs

The convention is to use ASSERTs for preconditions to the actual test,
so let's do that.

Bug: none
Change-Id: I8580438b70669adda6507192f226e96231a1ccf7
Reviewed-on: https://chromium-review.googlesource.com/995436Reviewed-by: default avatarJan Krcal <jkrcal@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548049}
parent 0a131772
...@@ -453,8 +453,8 @@ TEST_F(ProfileSyncServiceTest, DisabledByPolicyAfterInit) { ...@@ -453,8 +453,8 @@ TEST_F(ProfileSyncServiceTest, DisabledByPolicyAfterInit) {
ExpectSyncEngineCreation(1); ExpectSyncEngineCreation(1);
InitializeForNthSync(); InitializeForNthSync();
EXPECT_FALSE(service()->IsManaged()); ASSERT_FALSE(service()->IsManaged());
EXPECT_TRUE(service()->IsSyncActive()); ASSERT_TRUE(service()->IsSyncActive());
prefs()->SetManagedPref(syncer::prefs::kSyncManaged, prefs()->SetManagedPref(syncer::prefs::kSyncManaged,
std::make_unique<base::Value>(true)); std::make_unique<base::Value>(true));
...@@ -471,7 +471,7 @@ TEST_F(ProfileSyncServiceTest, AbortedByShutdown) { ...@@ -471,7 +471,7 @@ TEST_F(ProfileSyncServiceTest, AbortedByShutdown) {
IssueTestTokens(); IssueTestTokens();
InitializeForNthSync(); InitializeForNthSync();
EXPECT_FALSE(service()->IsSyncActive()); ASSERT_FALSE(service()->IsSyncActive());
ShutdownAndDeleteService(); ShutdownAndDeleteService();
} }
...@@ -505,8 +505,8 @@ TEST_F(ProfileSyncServiceTest, DisableAndEnableSyncTemporarily) { ...@@ -505,8 +505,8 @@ TEST_F(ProfileSyncServiceTest, DisableAndEnableSyncTemporarily) {
ExpectSyncEngineCreation(1); ExpectSyncEngineCreation(1);
InitializeForNthSync(); InitializeForNthSync();
EXPECT_TRUE(service()->IsSyncActive()); ASSERT_TRUE(service()->IsSyncActive());
EXPECT_FALSE(prefs()->GetBoolean(syncer::prefs::kSyncSuppressStart)); ASSERT_FALSE(prefs()->GetBoolean(syncer::prefs::kSyncSuppressStart));
testing::Mock::VerifyAndClearExpectations(component_factory()); testing::Mock::VerifyAndClearExpectations(component_factory());
...@@ -551,10 +551,10 @@ TEST_F(ProfileSyncServiceTest, GetSyncTokenStatus) { ...@@ -551,10 +551,10 @@ TEST_F(ProfileSyncServiceTest, GetSyncTokenStatus) {
// Initial status. // Initial status.
ProfileSyncService::SyncTokenStatus token_status = ProfileSyncService::SyncTokenStatus token_status =
service()->GetSyncTokenStatus(); service()->GetSyncTokenStatus();
EXPECT_EQ(syncer::CONNECTION_NOT_ATTEMPTED, token_status.connection_status); ASSERT_EQ(syncer::CONNECTION_NOT_ATTEMPTED, token_status.connection_status);
EXPECT_TRUE(token_status.connection_status_update_time.is_null()); ASSERT_TRUE(token_status.connection_status_update_time.is_null());
EXPECT_TRUE(token_status.token_request_time.is_null()); ASSERT_TRUE(token_status.token_request_time.is_null());
EXPECT_TRUE(token_status.token_receive_time.is_null()); ASSERT_TRUE(token_status.token_receive_time.is_null());
// Simulate an auth error. // Simulate an auth error.
service()->OnConnectionStatusChange(syncer::CONNECTION_AUTH_ERROR); service()->OnConnectionStatusChange(syncer::CONNECTION_AUTH_ERROR);
...@@ -584,13 +584,13 @@ TEST_F(ProfileSyncServiceTest, RevokeAccessTokenFromTokenService) { ...@@ -584,13 +584,13 @@ TEST_F(ProfileSyncServiceTest, RevokeAccessTokenFromTokenService) {
ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback()); ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback());
ExpectSyncEngineCreation(1); ExpectSyncEngineCreation(1);
InitializeForNthSync(); InitializeForNthSync();
EXPECT_TRUE(service()->IsSyncActive()); ASSERT_TRUE(service()->IsSyncActive());
std::string primary_account_id = std::string primary_account_id =
signin_manager()->GetAuthenticatedAccountId(); signin_manager()->GetAuthenticatedAccountId();
auth_service()->LoadCredentials(primary_account_id); auth_service()->LoadCredentials(primary_account_id);
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
EXPECT_FALSE(service()->GetAccessTokenForTest().empty()); ASSERT_FALSE(service()->GetAccessTokenForTest().empty());
std::string secondary_account_gaiaid = "1234567"; std::string secondary_account_gaiaid = "1234567";
std::string secondary_account_name = "test_user2@gmail.com"; std::string secondary_account_name = "test_user2@gmail.com";
...@@ -634,10 +634,10 @@ TEST_F(ProfileSyncServiceTest, ClearDataOnSignOut) { ...@@ -634,10 +634,10 @@ TEST_F(ProfileSyncServiceTest, ClearDataOnSignOut) {
ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback()); ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback());
ExpectSyncEngineCreation(1); ExpectSyncEngineCreation(1);
InitializeForNthSync(); InitializeForNthSync();
EXPECT_TRUE(service()->IsSyncActive()); ASSERT_TRUE(service()->IsSyncActive());
EXPECT_LT(base::Time::Now() - service()->GetLastSyncedTime(), ASSERT_LT(base::Time::Now() - service()->GetLastSyncedTime(),
base::TimeDelta::FromMinutes(1)); base::TimeDelta::FromMinutes(1));
EXPECT_TRUE(service()->GetLocalDeviceInfoProvider()->GetLocalDeviceInfo()); ASSERT_TRUE(service()->GetLocalDeviceInfoProvider()->GetLocalDeviceInfo());
// Sign out. // Sign out.
service()->RequestStop(ProfileSyncService::CLEAR_DATA); service()->RequestStop(ProfileSyncService::CLEAR_DATA);
...@@ -745,16 +745,16 @@ TEST_F(ProfileSyncServiceTest, MemoryPressureRecording) { ...@@ -745,16 +745,16 @@ TEST_F(ProfileSyncServiceTest, MemoryPressureRecording) {
ExpectSyncEngineCreation(1); ExpectSyncEngineCreation(1);
InitializeForNthSync(); InitializeForNthSync();
EXPECT_TRUE(service()->IsSyncActive()); ASSERT_TRUE(service()->IsSyncActive());
EXPECT_FALSE(prefs()->GetBoolean(syncer::prefs::kSyncSuppressStart)); ASSERT_FALSE(prefs()->GetBoolean(syncer::prefs::kSyncSuppressStart));
testing::Mock::VerifyAndClearExpectations(component_factory()); testing::Mock::VerifyAndClearExpectations(component_factory());
syncer::SyncPrefs sync_prefs(service()->GetSyncClient()->GetPrefService()); syncer::SyncPrefs sync_prefs(service()->GetSyncClient()->GetPrefService());
EXPECT_EQ(prefs()->GetInteger(syncer::prefs::kSyncMemoryPressureWarningCount), ASSERT_EQ(prefs()->GetInteger(syncer::prefs::kSyncMemoryPressureWarningCount),
0); 0);
EXPECT_FALSE(sync_prefs.DidSyncShutdownCleanly()); ASSERT_FALSE(sync_prefs.DidSyncShutdownCleanly());
// Simulate memory pressure notification. // Simulate memory pressure notification.
base::MemoryPressureListener::NotifyMemoryPressure( base::MemoryPressureListener::NotifyMemoryPressure(
...@@ -797,9 +797,9 @@ TEST_F(ProfileSyncServiceTest, OnLocalSetPassphraseEncryption) { ...@@ -797,9 +797,9 @@ TEST_F(ProfileSyncServiceTest, OnLocalSetPassphraseEncryption) {
ExpectDataTypeManagerCreation( ExpectDataTypeManagerCreation(
1, GetRecordingConfigureCalledCallback(&configure_reason)); 1, GetRecordingConfigureCalledCallback(&configure_reason));
InitializeForNthSync(); InitializeForNthSync();
EXPECT_TRUE(service()->IsSyncActive()); ASSERT_TRUE(service()->IsSyncActive());
testing::Mock::VerifyAndClearExpectations(component_factory()); testing::Mock::VerifyAndClearExpectations(component_factory());
EXPECT_EQ(syncer::CONFIGURE_REASON_NEWLY_ENABLED_DATA_TYPE, configure_reason); ASSERT_EQ(syncer::CONFIGURE_REASON_NEWLY_ENABLED_DATA_TYPE, configure_reason);
syncer::DataTypeManager::ConfigureResult result; syncer::DataTypeManager::ConfigureResult result;
result.status = syncer::DataTypeManager::OK; result.status = syncer::DataTypeManager::OK;
service()->OnConfigureDone(result); service()->OnConfigureDone(result);
...@@ -846,7 +846,7 @@ TEST_F(ProfileSyncServiceTest, ...@@ -846,7 +846,7 @@ TEST_F(ProfileSyncServiceTest,
1, GetRecordingConfigureCalledCallback(&configure_reason)); 1, GetRecordingConfigureCalledCallback(&configure_reason));
InitializeForNthSync(); InitializeForNthSync();
testing::Mock::VerifyAndClearExpectations(component_factory()); testing::Mock::VerifyAndClearExpectations(component_factory());
EXPECT_EQ(syncer::CONFIGURE_REASON_NEWLY_ENABLED_DATA_TYPE, configure_reason); ASSERT_EQ(syncer::CONFIGURE_REASON_NEWLY_ENABLED_DATA_TYPE, configure_reason);
syncer::DataTypeManager::ConfigureResult result; syncer::DataTypeManager::ConfigureResult result;
result.status = syncer::DataTypeManager::OK; result.status = syncer::DataTypeManager::OK;
service()->OnConfigureDone(result); service()->OnConfigureDone(result);
...@@ -956,7 +956,7 @@ TEST_F(ProfileSyncServiceTest, PassphrasePromptDueToVersion) { ...@@ -956,7 +956,7 @@ TEST_F(ProfileSyncServiceTest, PassphrasePromptDueToVersion) {
InitializeForNthSync(); InitializeForNthSync();
syncer::SyncPrefs sync_prefs(service()->GetSyncClient()->GetPrefService()); syncer::SyncPrefs sync_prefs(service()->GetSyncClient()->GetPrefService());
EXPECT_EQ(PRODUCT_VERSION, sync_prefs.GetLastRunVersion()); ASSERT_EQ(PRODUCT_VERSION, sync_prefs.GetLastRunVersion());
sync_prefs.SetPassphrasePrompted(true); sync_prefs.SetPassphrasePrompted(true);
...@@ -1002,10 +1002,10 @@ TEST_F(ProfileSyncServiceTest, DisableSyncOnClient) { ...@@ -1002,10 +1002,10 @@ TEST_F(ProfileSyncServiceTest, DisableSyncOnClient) {
ExpectSyncEngineCreation(1); ExpectSyncEngineCreation(1);
InitializeForNthSync(); InitializeForNthSync();
EXPECT_TRUE(service()->IsSyncActive()); ASSERT_TRUE(service()->IsSyncActive());
EXPECT_LT(base::Time::Now() - service()->GetLastSyncedTime(), ASSERT_LT(base::Time::Now() - service()->GetLastSyncedTime(),
base::TimeDelta::FromMinutes(1)); base::TimeDelta::FromMinutes(1));
EXPECT_TRUE(service()->GetLocalDeviceInfoProvider()->GetLocalDeviceInfo()); ASSERT_TRUE(service()->GetLocalDeviceInfoProvider()->GetLocalDeviceInfo());
syncer::SyncProtocolError client_cmd; syncer::SyncProtocolError client_cmd;
client_cmd.action = syncer::DISABLE_SYNC_ON_CLIENT; client_cmd.action = syncer::DISABLE_SYNC_ON_CLIENT;
......
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