Index: components/sync/driver/frontend_data_type_controller_unittest.cc |
diff --git a/components/sync_driver/frontend_data_type_controller_unittest.cc b/components/sync/driver/frontend_data_type_controller_unittest.cc |
similarity index 73% |
rename from components/sync_driver/frontend_data_type_controller_unittest.cc |
rename to components/sync/driver/frontend_data_type_controller_unittest.cc |
index a64ccc86319016d686cbe0ed210bcae763e11005..9d7e6ac056750e56f2cd8bc12cf65f3dd7301a46 100644 |
--- a/components/sync_driver/frontend_data_type_controller_unittest.cc |
+++ b/components/sync/driver/frontend_data_type_controller_unittest.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "components/sync_driver/frontend_data_type_controller.h" |
+#include "components/sync/driver/frontend_data_type_controller.h" |
#include <memory> |
@@ -15,13 +15,13 @@ |
#include "base/single_thread_task_runner.h" |
#include "base/threading/thread_task_runner_handle.h" |
#include "base/tracked_objects.h" |
-#include "components/sync_driver/change_processor_mock.h" |
-#include "components/sync_driver/data_type_controller_mock.h" |
-#include "components/sync_driver/fake_sync_client.h" |
-#include "components/sync_driver/fake_sync_service.h" |
-#include "components/sync_driver/frontend_data_type_controller_mock.h" |
-#include "components/sync_driver/model_associator_mock.h" |
-#include "components/sync_driver/sync_api_component_factory_mock.h" |
+#include "components/sync/driver/change_processor_mock.h" |
+#include "components/sync/driver/data_type_controller_mock.h" |
+#include "components/sync/driver/fake_sync_client.h" |
+#include "components/sync/driver/fake_sync_service.h" |
+#include "components/sync/driver/frontend_data_type_controller_mock.h" |
+#include "components/sync/driver/model_associator_mock.h" |
+#include "components/sync/driver/sync_api_component_factory_mock.h" |
#include "testing/gtest/include/gtest/gtest.h" |
using browser_sync::FrontendDataTypeController; |
@@ -42,9 +42,8 @@ namespace { |
class FrontendDataTypeControllerFake : public FrontendDataTypeController { |
public: |
- FrontendDataTypeControllerFake( |
- sync_driver::SyncClient* sync_client, |
- FrontendDataTypeControllerMock* mock) |
+ FrontendDataTypeControllerFake(sync_driver::SyncClient* sync_client, |
+ FrontendDataTypeControllerMock* mock) |
: FrontendDataTypeController(base::ThreadTaskRunnerHandle::Get(), |
base::Closure(), |
sync_client), |
@@ -57,8 +56,8 @@ class FrontendDataTypeControllerFake : public FrontendDataTypeController { |
void CreateSyncComponents() override { |
sync_driver::SyncApiComponentFactory::SyncComponents sync_components = |
- sync_client_->GetSyncApiComponentFactory()-> |
- CreateBookmarkSyncComponents(nullptr, this); |
+ sync_client_->GetSyncApiComponentFactory() |
+ ->CreateBookmarkSyncComponents(nullptr, this); |
model_associator_.reset(sync_components.model_associator); |
change_processor_.reset(sync_components.change_processor); |
} |
@@ -86,19 +85,14 @@ class SyncFrontendDataTypeControllerTest : public testing::Test, |
public sync_driver::FakeSyncClient { |
public: |
SyncFrontendDataTypeControllerTest() |
- : sync_driver::FakeSyncClient(&profile_sync_factory_), |
- service_() {} |
+ : sync_driver::FakeSyncClient(&profile_sync_factory_), service_() {} |
// FakeSyncClient overrides. |
- sync_driver::SyncService* GetSyncService() override { |
- return &service_; |
- } |
+ sync_driver::SyncService* GetSyncService() override { return &service_; } |
void SetUp() override { |
dtc_mock_ = new StrictMock<FrontendDataTypeControllerMock>(); |
- frontend_dtc_ = |
- new FrontendDataTypeControllerFake(this, |
- dtc_mock_.get()); |
+ frontend_dtc_ = new FrontendDataTypeControllerFake(this, dtc_mock_.get()); |
} |
protected: |
@@ -107,18 +101,18 @@ class SyncFrontendDataTypeControllerTest : public testing::Test, |
EXPECT_CALL(model_load_callback_, Run(_, _)); |
model_associator_ = new ModelAssociatorMock(); |
change_processor_ = new ChangeProcessorMock(); |
- EXPECT_CALL(profile_sync_factory_, CreateBookmarkSyncComponents(_, _)). |
- WillOnce(Return(sync_driver::SyncApiComponentFactory::SyncComponents( |
+ EXPECT_CALL(profile_sync_factory_, CreateBookmarkSyncComponents(_, _)) |
+ .WillOnce(Return(sync_driver::SyncApiComponentFactory::SyncComponents( |
model_associator_, change_processor_))); |
} |
void SetAssociateExpectations() { |
- EXPECT_CALL(*model_associator_, CryptoReadyIfNecessary()). |
- WillOnce(Return(true)); |
- EXPECT_CALL(*model_associator_, SyncModelHasUserCreatedNodes(_)). |
- WillOnce(DoAll(SetArgumentPointee<0>(true), Return(true))); |
- EXPECT_CALL(*model_associator_, AssociateModels(_, _)). |
- WillOnce(Return(syncer::SyncError())); |
+ EXPECT_CALL(*model_associator_, CryptoReadyIfNecessary()) |
+ .WillOnce(Return(true)); |
+ EXPECT_CALL(*model_associator_, SyncModelHasUserCreatedNodes(_)) |
+ .WillOnce(DoAll(SetArgumentPointee<0>(true), Return(true))); |
+ EXPECT_CALL(*model_associator_, AssociateModels(_, _)) |
+ .WillOnce(Return(syncer::SyncError())); |
EXPECT_CALL(*dtc_mock_.get(), RecordAssociationTime(_)); |
} |
@@ -128,8 +122,8 @@ class SyncFrontendDataTypeControllerTest : public testing::Test, |
void SetStopExpectations() { |
EXPECT_CALL(*dtc_mock_.get(), CleanUpState()); |
- EXPECT_CALL(*model_associator_, DisassociateModels()). |
- WillOnce(Return(syncer::SyncError())); |
+ EXPECT_CALL(*model_associator_, DisassociateModels()) |
+ .WillOnce(Return(syncer::SyncError())); |
} |
void SetStartFailExpectations(DataTypeController::ConfigureResult result) { |
@@ -141,12 +135,10 @@ class SyncFrontendDataTypeControllerTest : public testing::Test, |
} |
void Start() { |
- frontend_dtc_->LoadModels( |
- base::Bind(&ModelLoadCallbackMock::Run, |
- base::Unretained(&model_load_callback_))); |
- frontend_dtc_->StartAssociating( |
- base::Bind(&StartCallbackMock::Run, |
- base::Unretained(&start_callback_))); |
+ frontend_dtc_->LoadModels(base::Bind( |
+ &ModelLoadCallbackMock::Run, base::Unretained(&model_load_callback_))); |
+ frontend_dtc_->StartAssociating(base::Bind( |
+ &StartCallbackMock::Run, base::Unretained(&start_callback_))); |
PumpLoop(); |
} |
@@ -174,12 +166,12 @@ TEST_F(SyncFrontendDataTypeControllerTest, StartOk) { |
TEST_F(SyncFrontendDataTypeControllerTest, StartFirstRun) { |
SetStartExpectations(); |
- EXPECT_CALL(*model_associator_, CryptoReadyIfNecessary()). |
- WillOnce(Return(true)); |
- EXPECT_CALL(*model_associator_, SyncModelHasUserCreatedNodes(_)). |
- WillOnce(DoAll(SetArgumentPointee<0>(false), Return(true))); |
- EXPECT_CALL(*model_associator_, AssociateModels(_, _)). |
- WillOnce(Return(syncer::SyncError())); |
+ EXPECT_CALL(*model_associator_, CryptoReadyIfNecessary()) |
+ .WillOnce(Return(true)); |
+ EXPECT_CALL(*model_associator_, SyncModelHasUserCreatedNodes(_)) |
+ .WillOnce(DoAll(SetArgumentPointee<0>(false), Return(true))); |
+ EXPECT_CALL(*model_associator_, AssociateModels(_, _)) |
+ .WillOnce(Return(syncer::SyncError())); |
EXPECT_CALL(*dtc_mock_.get(), RecordAssociationTime(_)); |
SetActivateExpectations(DataTypeController::OK_FIRST_RUN); |
EXPECT_EQ(DataTypeController::NOT_RUNNING, frontend_dtc_->state()); |
@@ -202,9 +194,8 @@ TEST_F(SyncFrontendDataTypeControllerTest, AbortDuringStartModels) { |
EXPECT_CALL(*dtc_mock_.get(), StartModels()).WillOnce(Return(false)); |
EXPECT_CALL(*dtc_mock_.get(), CleanUpState()); |
EXPECT_EQ(DataTypeController::NOT_RUNNING, frontend_dtc_->state()); |
- frontend_dtc_->LoadModels( |
- base::Bind(&ModelLoadCallbackMock::Run, |
- base::Unretained(&model_load_callback_))); |
+ frontend_dtc_->LoadModels(base::Bind( |
+ &ModelLoadCallbackMock::Run, base::Unretained(&model_load_callback_))); |
EXPECT_EQ(DataTypeController::MODEL_STARTING, frontend_dtc_->state()); |
frontend_dtc_->Stop(); |
EXPECT_EQ(DataTypeController::NOT_RUNNING, frontend_dtc_->state()); |
@@ -212,15 +203,14 @@ TEST_F(SyncFrontendDataTypeControllerTest, AbortDuringStartModels) { |
TEST_F(SyncFrontendDataTypeControllerTest, StartAssociationFailed) { |
SetStartExpectations(); |
- EXPECT_CALL(*model_associator_, CryptoReadyIfNecessary()). |
- WillOnce(Return(true)); |
- EXPECT_CALL(*model_associator_, SyncModelHasUserCreatedNodes(_)). |
- WillOnce(DoAll(SetArgumentPointee<0>(true), Return(true))); |
- EXPECT_CALL(*model_associator_, AssociateModels(_, _)). |
- WillOnce(Return(syncer::SyncError(FROM_HERE, |
- syncer::SyncError::DATATYPE_ERROR, |
- "error", |
- syncer::BOOKMARKS))); |
+ EXPECT_CALL(*model_associator_, CryptoReadyIfNecessary()) |
+ .WillOnce(Return(true)); |
+ EXPECT_CALL(*model_associator_, SyncModelHasUserCreatedNodes(_)) |
+ .WillOnce(DoAll(SetArgumentPointee<0>(true), Return(true))); |
+ EXPECT_CALL(*model_associator_, AssociateModels(_, _)) |
+ .WillOnce( |
+ Return(syncer::SyncError(FROM_HERE, syncer::SyncError::DATATYPE_ERROR, |
+ "error", syncer::BOOKMARKS))); |
EXPECT_CALL(*dtc_mock_.get(), RecordAssociationTime(_)); |
SetStartFailExpectations(DataTypeController::ASSOCIATION_FAILED); |
@@ -235,10 +225,10 @@ TEST_F(SyncFrontendDataTypeControllerTest, |
SetStartExpectations(); |
SetStartFailExpectations(DataTypeController::UNRECOVERABLE_ERROR); |
// Set up association to fail with an unrecoverable error. |
- EXPECT_CALL(*model_associator_, CryptoReadyIfNecessary()). |
- WillRepeatedly(Return(true)); |
- EXPECT_CALL(*model_associator_, SyncModelHasUserCreatedNodes(_)). |
- WillRepeatedly(DoAll(SetArgumentPointee<0>(false), Return(false))); |
+ EXPECT_CALL(*model_associator_, CryptoReadyIfNecessary()) |
+ .WillRepeatedly(Return(true)); |
+ EXPECT_CALL(*model_associator_, SyncModelHasUserCreatedNodes(_)) |
+ .WillRepeatedly(DoAll(SetArgumentPointee<0>(false), Return(false))); |
EXPECT_EQ(DataTypeController::NOT_RUNNING, frontend_dtc_->state()); |
Start(); |
EXPECT_EQ(DataTypeController::NOT_RUNNING, frontend_dtc_->state()); |
@@ -248,8 +238,8 @@ TEST_F(SyncFrontendDataTypeControllerTest, StartAssociationCryptoNotReady) { |
SetStartExpectations(); |
SetStartFailExpectations(DataTypeController::NEEDS_CRYPTO); |
// Set up association to fail with a NEEDS_CRYPTO error. |
- EXPECT_CALL(*model_associator_, CryptoReadyIfNecessary()). |
- WillRepeatedly(Return(false)); |
+ EXPECT_CALL(*model_associator_, CryptoReadyIfNecessary()) |
+ .WillRepeatedly(Return(false)); |
EXPECT_EQ(DataTypeController::NOT_RUNNING, frontend_dtc_->state()); |
Start(); |
EXPECT_EQ(DataTypeController::NOT_RUNNING, frontend_dtc_->state()); |