Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1381)

Unified Diff: components/browser_sync/profile_sync_service_unittest.cc

Issue 2533083002: [Sync] SyncEngine refactor part 1: interfaces. (Closed)
Patch Set: Rebase. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/browser_sync/profile_sync_service_startup_unittest.cc ('k') | components/sync/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/browser_sync/profile_sync_service_unittest.cc
diff --git a/components/browser_sync/profile_sync_service_unittest.cc b/components/browser_sync/profile_sync_service_unittest.cc
index be4ced19fe7d66962b58d524ad646cc23d60a1a3..824304b1435f3a9316afb5f3a084fb9f71a7c3f5 100644
--- a/components/browser_sync/profile_sync_service_unittest.cc
+++ b/components/browser_sync/profile_sync_service_unittest.cc
@@ -27,11 +27,11 @@
#include "components/strings/grit/components_strings.h"
#include "components/sync/base/pref_names.h"
#include "components/sync/driver/fake_data_type_controller.h"
-#include "components/sync/driver/glue/sync_backend_host_mock.h"
#include "components/sync/driver/sync_api_component_factory_mock.h"
#include "components/sync/driver/sync_driver_switches.h"
#include "components/sync/driver/sync_service_observer.h"
#include "components/sync/driver/sync_util.h"
+#include "components/sync/engine/fake_sync_engine.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "components/version_info/version_info_values.h"
#include "google_apis/gaia/gaia_constants.h"
@@ -40,7 +40,7 @@
#include "ui/base/l10n/l10n_util.h"
using syncer::DataTypeController;
-using syncer::SyncBackendHostMock;
+using syncer::FakeSyncEngine;
using syncer::SyncMergeResult;
using testing::Return;
@@ -99,12 +99,12 @@ class TestSyncServiceObserver : public syncer::SyncServiceObserver {
bool setup_in_progress_;
};
-// A variant of the SyncBackendHostMock that won't automatically
-// call back when asked to initialized. Allows us to test things
-// that could happen while backend init is in progress.
-class SyncBackendHostNoReturn : public SyncBackendHostMock {
+// A variant of the FakeSyncEngine that won't automatically call back when asked
+// to initialized. Allows us to test things that could happen while backend init
+// is in progress.
+class SyncEngineNoReturn : public FakeSyncEngine {
void Initialize(
- syncer::SyncFrontend* frontend,
+ syncer::SyncEngineHost* host,
scoped_refptr<base::SingleThreadTaskRunner> sync_task_runner,
const syncer::WeakHandle<syncer::JsEventHandler>& event_handler,
const GURL& service_url,
@@ -122,14 +122,14 @@ class SyncBackendHostNoReturn : public SyncBackendHostMock {
saved_nigori_state) override {}
};
-class SyncBackendHostMockCollectDeleteDirParam : public SyncBackendHostMock {
+class FakeSyncEngineCollectDeleteDirParam : public FakeSyncEngine {
public:
- explicit SyncBackendHostMockCollectDeleteDirParam(
+ explicit FakeSyncEngineCollectDeleteDirParam(
std::vector<bool>* delete_dir_param)
: delete_dir_param_(delete_dir_param) {}
void Initialize(
- syncer::SyncFrontend* frontend,
+ syncer::SyncEngineHost* host,
scoped_refptr<base::SingleThreadTaskRunner> sync_task_runner,
const syncer::WeakHandle<syncer::JsEventHandler>& event_handler,
const GURL& service_url,
@@ -146,8 +146,8 @@ class SyncBackendHostMockCollectDeleteDirParam : public SyncBackendHostMock {
std::unique_ptr<syncer::SyncEncryptionHandler::NigoriState>
saved_nigori_state) override {
delete_dir_param_->push_back(delete_sync_data_folder);
- SyncBackendHostMock::Initialize(
- frontend, std::move(sync_task_runner), event_handler, service_url,
+ FakeSyncEngine::Initialize(
+ host, std::move(sync_task_runner), event_handler, service_url,
sync_user_agent, credentials, delete_sync_data_folder,
enable_local_sync_backend, local_sync_backend_folder,
std::move(sync_manager_factory), unrecoverable_error_handler,
@@ -159,14 +159,14 @@ class SyncBackendHostMockCollectDeleteDirParam : public SyncBackendHostMock {
std::vector<bool>* delete_dir_param_;
};
-// SyncBackendHostMock that calls an external callback when ClearServerData is
+// FakeSyncEngine that calls an external callback when ClearServerData is
// called.
-class SyncBackendHostCaptureClearServerData : public SyncBackendHostMock {
+class SyncEngineCaptureClearServerData : public FakeSyncEngine {
public:
typedef base::Callback<void(
const syncer::SyncManager::ClearServerDataCallback&)>
ClearServerDataCalled;
- explicit SyncBackendHostCaptureClearServerData(
+ explicit SyncEngineCaptureClearServerData(
const ClearServerDataCalled& clear_server_data_called)
: clear_server_data_called_(clear_server_data_called) {}
@@ -179,16 +179,16 @@ class SyncBackendHostCaptureClearServerData : public SyncBackendHostMock {
ClearServerDataCalled clear_server_data_called_;
};
-ACTION(ReturnNewSyncBackendHostMock) {
- return new SyncBackendHostMock();
+ACTION(ReturnNewFakeSyncEngine) {
+ return new FakeSyncEngine();
}
-ACTION(ReturnNewSyncBackendHostNoReturn) {
- return new SyncBackendHostNoReturn();
+ACTION(ReturnNewSyncEngineNoReturn) {
+ return new SyncEngineNoReturn();
}
ACTION_P(ReturnNewMockHostCollectDeleteDirParam, delete_dir_param) {
- return new SyncBackendHostMockCollectDeleteDirParam(delete_dir_param);
+ return new FakeSyncEngineCollectDeleteDirParam(delete_dir_param);
}
void OnClearServerDataCalled(
@@ -198,7 +198,7 @@ void OnClearServerDataCalled(
}
ACTION_P(ReturnNewMockHostCaptureClearServerData, captured_callback) {
- return new SyncBackendHostCaptureClearServerData(base::Bind(
+ return new SyncEngineCaptureClearServerData(base::Bind(
&OnClearServerDataCalled, base::Unretained(captured_callback)));
}
@@ -207,10 +207,10 @@ void DoNothing(DataTypeController::ConfigureResult ignored1,
const SyncMergeResult& ignored3) {}
// A test harness that uses a real ProfileSyncService and in most cases a
-// MockSyncBackendHost.
+// MockSyncEngine.
//
// This is useful if we want to test the ProfileSyncService and don't care about
-// testing the SyncBackendHost.
+// testing the SyncEngine.
class ProfileSyncServiceTest : public ::testing::Test {
protected:
ProfileSyncServiceTest() : component_factory_(nullptr) {}
@@ -315,31 +315,31 @@ class ProfileSyncServiceTest : public ::testing::Test {
.WillRepeatedly(ReturnNewDataTypeManager(callback));
}
- void ExpectSyncBackendHostCreation(int times) {
- EXPECT_CALL(*component_factory_, CreateSyncBackendHost(_, _, _, _))
+ void ExpectSyncEngineCreation(int times) {
+ EXPECT_CALL(*component_factory_, CreateSyncEngine(_, _, _, _))
.Times(times)
- .WillRepeatedly(ReturnNewSyncBackendHostMock());
+ .WillRepeatedly(ReturnNewFakeSyncEngine());
}
- void ExpectSyncBackendHostCreationCollectDeleteDir(
+ void ExpectSyncEngineCreationCollectDeleteDir(
int times,
std::vector<bool>* delete_dir_param) {
- EXPECT_CALL(*component_factory_, CreateSyncBackendHost(_, _, _, _))
+ EXPECT_CALL(*component_factory_, CreateSyncEngine(_, _, _, _))
.Times(times)
.WillRepeatedly(
ReturnNewMockHostCollectDeleteDirParam(delete_dir_param));
}
- void ExpectSyncBackendHostCreationCaptureClearServerData(
+ void ExpectSyncEngineCreationCaptureClearServerData(
syncer::SyncManager::ClearServerDataCallback* captured_callback) {
- EXPECT_CALL(*component_factory_, CreateSyncBackendHost(_, _, _, _))
+ EXPECT_CALL(*component_factory_, CreateSyncEngine(_, _, _, _))
.Times(1)
.WillOnce(ReturnNewMockHostCaptureClearServerData(captured_callback));
}
- void PrepareDelayedInitSyncBackendHost() {
- EXPECT_CALL(*component_factory_, CreateSyncBackendHost(_, _, _, _))
- .WillOnce(ReturnNewSyncBackendHostNoReturn());
+ void PrepareDelayedInitSyncEngine() {
+ EXPECT_CALL(*component_factory_, CreateSyncEngine(_, _, _, _))
+ .WillOnce(ReturnNewSyncEngineNoReturn());
}
AccountTrackerService* account_tracker() {
@@ -404,7 +404,7 @@ TEST_F(ProfileSyncServiceTest, SuccessfulInitialization) {
IssueTestTokens();
CreateService(ProfileSyncService::AUTO_START);
ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback());
- ExpectSyncBackendHostCreation(1);
+ ExpectSyncEngineCreation(1);
InitializeForNthSync();
EXPECT_FALSE(service()->IsManaged());
EXPECT_TRUE(service()->IsSyncActive());
@@ -464,7 +464,7 @@ TEST_F(ProfileSyncServiceTest, DisabledByPolicyAfterInit) {
IssueTestTokens();
CreateService(ProfileSyncService::AUTO_START);
ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback());
- ExpectSyncBackendHostCreation(1);
+ ExpectSyncEngineCreation(1);
InitializeForNthSync();
EXPECT_FALSE(service()->IsManaged());
@@ -481,7 +481,7 @@ TEST_F(ProfileSyncServiceTest, DisabledByPolicyAfterInit) {
// before the backend initialize call returns.
TEST_F(ProfileSyncServiceTest, AbortedByShutdown) {
CreateService(ProfileSyncService::AUTO_START);
- PrepareDelayedInitSyncBackendHost();
+ PrepareDelayedInitSyncEngine();
IssueTestTokens();
InitializeForNthSync();
@@ -495,7 +495,7 @@ TEST_F(ProfileSyncServiceTest, EarlyRequestStop) {
CreateService(ProfileSyncService::AUTO_START);
IssueTestTokens();
ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback());
- ExpectSyncBackendHostCreation(1);
+ ExpectSyncEngineCreation(1);
service()->RequestStop(ProfileSyncService::KEEP_DATA);
EXPECT_FALSE(service()->IsSyncRequested());
@@ -516,7 +516,7 @@ TEST_F(ProfileSyncServiceTest, DisableAndEnableSyncTemporarily) {
CreateService(ProfileSyncService::AUTO_START);
IssueTestTokens();
ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback());
- ExpectSyncBackendHostCreation(1);
+ ExpectSyncEngineCreation(1);
InitializeForNthSync();
EXPECT_TRUE(service()->IsSyncActive());
@@ -529,7 +529,7 @@ TEST_F(ProfileSyncServiceTest, DisableAndEnableSyncTemporarily) {
EXPECT_TRUE(prefs()->GetBoolean(syncer::prefs::kSyncSuppressStart));
ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback());
- ExpectSyncBackendHostCreation(1);
+ ExpectSyncEngineCreation(1);
service()->RequestStart();
EXPECT_TRUE(service()->IsSyncActive());
@@ -542,7 +542,7 @@ TEST_F(ProfileSyncServiceTest, DisableAndEnableSyncTemporarily) {
TEST_F(ProfileSyncServiceTest, EnableSyncAndSignOut) {
CreateService(ProfileSyncService::AUTO_START);
ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback());
- ExpectSyncBackendHostCreation(1);
+ ExpectSyncEngineCreation(1);
IssueTestTokens();
InitializeForNthSync();
@@ -559,7 +559,7 @@ TEST_F(ProfileSyncServiceTest, GetSyncTokenStatus) {
CreateService(ProfileSyncService::AUTO_START);
IssueTestTokens();
ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback());
- ExpectSyncBackendHostCreation(1);
+ ExpectSyncEngineCreation(1);
InitializeForNthSync();
// Initial status.
@@ -596,7 +596,7 @@ TEST_F(ProfileSyncServiceTest, RevokeAccessTokenFromTokenService) {
CreateService(ProfileSyncService::AUTO_START);
IssueTestTokens();
ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback());
- ExpectSyncBackendHostCreation(1);
+ ExpectSyncEngineCreation(1);
InitializeForNthSync();
EXPECT_TRUE(service()->IsSyncActive());
@@ -625,7 +625,7 @@ TEST_F(ProfileSyncServiceTest, SignOutRevokeAccessToken) {
CreateService(ProfileSyncService::AUTO_START);
IssueTestTokens();
ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback());
- ExpectSyncBackendHostCreation(1);
+ ExpectSyncEngineCreation(1);
InitializeForNthSync();
EXPECT_TRUE(service()->IsSyncActive());
@@ -646,7 +646,7 @@ TEST_F(ProfileSyncServiceTest, ClearDataOnSignOut) {
IssueTestTokens();
CreateService(ProfileSyncService::AUTO_START);
ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback());
- ExpectSyncBackendHostCreation(1);
+ ExpectSyncEngineCreation(1);
InitializeForNthSync();
EXPECT_TRUE(service()->IsSyncActive());
EXPECT_EQ(l10n_util::GetStringUTF16(IDS_SYNC_TIME_JUST_NOW),
@@ -678,7 +678,7 @@ TEST_F(ProfileSyncServiceTest, MemoryPressureRecording) {
CreateService(ProfileSyncService::AUTO_START);
IssueTestTokens();
ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback());
- ExpectSyncBackendHostCreation(1);
+ ExpectSyncEngineCreation(1);
InitializeForNthSync();
EXPECT_TRUE(service()->IsSyncActive());
@@ -726,10 +726,10 @@ TEST_F(ProfileSyncServiceTest, OnLocalSetPassphraseEncryption) {
syncer::SyncManager::ClearServerDataCallback captured_callback;
syncer::ConfigureReason configure_reason = syncer::CONFIGURE_REASON_UNKNOWN;
- // Initialize sync, ensure that both DataTypeManager and SyncBackendHost are
+ // Initialize sync, ensure that both DataTypeManager and SyncEngine are
// initialized and DTM::Configure is called with
// CONFIGURE_REASON_NEWLY_ENABLED_DATA_TYPE.
- ExpectSyncBackendHostCreationCaptureClearServerData(&captured_callback);
+ ExpectSyncEngineCreationCaptureClearServerData(&captured_callback);
ExpectDataTypeManagerCreation(
1, GetRecordingConfigureCalledCallback(&configure_reason));
InitializeForNthSync();
@@ -755,7 +755,7 @@ TEST_F(ProfileSyncServiceTest, OnLocalSetPassphraseEncryption) {
// Once SBH::ClearServerData finishes successfully ensure that sync is
// restarted.
configure_reason = syncer::CONFIGURE_REASON_UNKNOWN;
- ExpectSyncBackendHostCreation(1);
+ ExpectSyncEngineCreation(1);
ExpectDataTypeManagerCreation(
1, GetRecordingConfigureCalledCallback(&configure_reason));
captured_callback.Run();
@@ -774,7 +774,7 @@ TEST_F(ProfileSyncServiceTest,
switches::kSyncClearDataOnPassphraseEncryption);
IssueTestTokens();
CreateService(ProfileSyncService::AUTO_START);
- ExpectSyncBackendHostCreation(1);
+ ExpectSyncEngineCreation(1);
ExpectDataTypeManagerCreation(
1, GetRecordingConfigureCalledCallback(&configure_reason));
InitializeForNthSync();
@@ -793,7 +793,7 @@ TEST_F(ProfileSyncServiceTest,
// Simulate browser restart. First configuration is a regular one.
service()->Shutdown();
syncer::SyncManager::ClearServerDataCallback captured_callback;
- ExpectSyncBackendHostCreationCaptureClearServerData(&captured_callback);
+ ExpectSyncEngineCreationCaptureClearServerData(&captured_callback);
ExpectDataTypeManagerCreation(
1, GetRecordingConfigureCalledCallback(&configure_reason));
service()->RequestStart();
@@ -811,7 +811,7 @@ TEST_F(ProfileSyncServiceTest,
service()->OnConfigureDone(result);
EXPECT_FALSE(captured_callback.is_null());
- ExpectSyncBackendHostCreation(1);
+ ExpectSyncEngineCreation(1);
ExpectDataTypeManagerCreation(
1, GetRecordingConfigureCalledCallback(&configure_reason));
captured_callback.Run();
@@ -830,7 +830,7 @@ TEST_F(ProfileSyncServiceTest,
switches::kSyncClearDataOnPassphraseEncryption);
IssueTestTokens();
CreateService(ProfileSyncService::AUTO_START);
- ExpectSyncBackendHostCreationCaptureClearServerData(&captured_callback);
+ ExpectSyncEngineCreationCaptureClearServerData(&captured_callback);
ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback());
InitializeForNthSync();
testing::Mock::VerifyAndClearExpectations(component_factory());
@@ -843,7 +843,7 @@ TEST_F(ProfileSyncServiceTest,
// Simulate browser restart. First configuration is a regular one.
service()->Shutdown();
- ExpectSyncBackendHostCreationCaptureClearServerData(&captured_callback);
+ ExpectSyncEngineCreationCaptureClearServerData(&captured_callback);
ExpectDataTypeManagerCreation(
1, GetRecordingConfigureCalledCallback(&configure_reason));
service()->RequestStart();
@@ -863,7 +863,7 @@ TEST_F(ProfileSyncServiceTest,
service()->OnConfigureDone(result);
EXPECT_FALSE(captured_callback.is_null());
- ExpectSyncBackendHostCreation(1);
+ ExpectSyncEngineCreation(1);
ExpectDataTypeManagerCreation(
1, GetRecordingConfigureCalledCallback(&configure_reason));
captured_callback.Run();
@@ -877,7 +877,7 @@ TEST_F(ProfileSyncServiceTest, PassphrasePromptDueToVersion) {
IssueTestTokens();
CreateService(ProfileSyncService::AUTO_START);
ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback());
- ExpectSyncBackendHostCreation(1);
+ ExpectSyncEngineCreation(1);
InitializeForNthSync();
syncer::SyncPrefs sync_prefs(service()->GetSyncClient()->GetPrefService());
@@ -910,7 +910,7 @@ TEST_F(ProfileSyncServiceTest, ResetSyncData) {
// Backend should get initialized two times: once during initialization and
// once when handling actionable error.
ExpectDataTypeManagerCreation(2, GetDefaultConfigureCalledCallback());
- ExpectSyncBackendHostCreation(2);
+ ExpectSyncEngineCreation(2);
InitializeForNthSync();
syncer::SyncProtocolError client_cmd;
@@ -924,7 +924,7 @@ TEST_F(ProfileSyncServiceTest, DisableSyncOnClient) {
IssueTestTokens();
CreateService(ProfileSyncService::AUTO_START);
ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback());
- ExpectSyncBackendHostCreation(1);
+ ExpectSyncEngineCreation(1);
InitializeForNthSync();
EXPECT_TRUE(service()->IsSyncActive());
« no previous file with comments | « components/browser_sync/profile_sync_service_startup_unittest.cc ('k') | components/sync/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698