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

Unified Diff: components/sync/driver/ui_model_type_controller_unittest.cc

Issue 2388163002: [Sync] Move //components/sync to the syncer namespace, take 2. (Closed)
Patch Set: Rebase. Created 4 years, 2 months 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
Index: components/sync/driver/ui_model_type_controller_unittest.cc
diff --git a/components/sync/driver/ui_model_type_controller_unittest.cc b/components/sync/driver/ui_model_type_controller_unittest.cc
index 1d975b8ac160bc880d3708e4c36f5e74dff6b287..4935ada603f2ad696fe665aea703c7e38a3aff13 100644
--- a/components/sync/driver/ui_model_type_controller_unittest.cc
+++ b/components/sync/driver/ui_model_type_controller_unittest.cc
@@ -26,17 +26,17 @@
#include "components/sync/engine/commit_queue.h"
#include "testing/gtest/include/gtest/gtest.h"
-namespace sync_driver_v2 {
+namespace syncer {
namespace {
// A no-op instance of CommitQueue.
-class NullCommitQueue : public syncer_v2::CommitQueue {
+class NullCommitQueue : public CommitQueue {
public:
NullCommitQueue() {}
~NullCommitQueue() override {}
- void EnqueueForCommit(const syncer_v2::CommitRequestDataList& list) override {
+ void EnqueueForCommit(const CommitRequestDataList& list) override {
NOTREACHED() << "Not implemented.";
}
};
@@ -44,27 +44,25 @@ class NullCommitQueue : public syncer_v2::CommitQueue {
// A class that pretends to be the sync backend.
class MockSyncBackend {
public:
- void Connect(
- syncer::ModelType type,
- std::unique_ptr<syncer_v2::ActivationContext> activation_context) {
+ void Connect(ModelType type,
+ std::unique_ptr<ActivationContext> activation_context) {
enabled_types_.Put(type);
activation_context->type_processor->ConnectSync(
base::MakeUnique<NullCommitQueue>());
}
- void Disconnect(syncer::ModelType type) {
+ void Disconnect(ModelType type) {
DCHECK(enabled_types_.Has(type));
enabled_types_.Remove(type);
}
private:
- syncer::ModelTypeSet enabled_types_;
+ ModelTypeSet enabled_types_;
};
// Fake implementation of BackendDataTypeConfigurer that pretends to be Sync
// backend.
-class MockBackendDataTypeConfigurer
- : public sync_driver::BackendDataTypeConfigurer {
+class MockBackendDataTypeConfigurer : public BackendDataTypeConfigurer {
public:
MockBackendDataTypeConfigurer(
MockSyncBackend* backend,
@@ -72,30 +70,28 @@ class MockBackendDataTypeConfigurer
: backend_(backend), sync_task_runner_(sync_task_runner) {}
~MockBackendDataTypeConfigurer() override {}
- syncer::ModelTypeSet ConfigureDataTypes(
- syncer::ConfigureReason reason,
+ ModelTypeSet ConfigureDataTypes(
+ ConfigureReason reason,
const DataTypeConfigStateMap& config_state_map,
- const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>&
- ready_task,
+ const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task,
const base::Callback<void()>& retry_callback) override {
NOTREACHED() << "Not implemented.";
- return syncer::ModelTypeSet();
+ return ModelTypeSet();
}
- void ActivateDirectoryDataType(
- syncer::ModelType type,
- syncer::ModelSafeGroup group,
- sync_driver::ChangeProcessor* change_processor) override {
+ void ActivateDirectoryDataType(ModelType type,
+ ModelSafeGroup group,
+ ChangeProcessor* change_processor) override {
NOTREACHED() << "Not implemented.";
}
- void DeactivateDirectoryDataType(syncer::ModelType type) override {
+ void DeactivateDirectoryDataType(ModelType type) override {
NOTREACHED() << "Not implemented.";
}
- void ActivateNonBlockingDataType(syncer::ModelType type,
- std::unique_ptr<syncer_v2::ActivationContext>
- activation_context) override {
+ void ActivateNonBlockingDataType(
+ ModelType type,
+ std::unique_ptr<ActivationContext> activation_context) override {
// Post on Sync thread just like the real implementation does.
sync_task_runner_->PostTask(
FROM_HERE,
@@ -103,7 +99,7 @@ class MockBackendDataTypeConfigurer
base::Passed(std::move(activation_context))));
}
- void DeactivateNonBlockingDataType(syncer::ModelType type) override {
+ void DeactivateNonBlockingDataType(ModelType type) override {
sync_task_runner_->PostTask(FROM_HERE,
base::Bind(&MockSyncBackend::Disconnect,
base::Unretained(backend_), type));
@@ -116,8 +112,7 @@ class MockBackendDataTypeConfigurer
} // namespace
-class UIModelTypeControllerTest : public testing::Test,
- public sync_driver::FakeSyncClient {
+class UIModelTypeControllerTest : public testing::Test, public FakeSyncClient {
public:
UIModelTypeControllerTest()
: auto_run_tasks_(true),
@@ -129,8 +124,8 @@ class UIModelTypeControllerTest : public testing::Test,
void SetUp() override {
controller_ = base::MakeUnique<UIModelTypeController>(
- syncer::DEVICE_INFO, base::Closure(), this);
- service_ = base::MakeUnique<syncer_v2::StubModelTypeService>(base::Bind(
+ DEVICE_INFO, base::Closure(), this);
+ service_ = base::MakeUnique<StubModelTypeService>(base::Bind(
&UIModelTypeControllerTest::CreateProcessor, base::Unretained(this)));
}
@@ -139,17 +134,17 @@ class UIModelTypeControllerTest : public testing::Test,
RunAllTasks();
}
- base::WeakPtr<syncer_v2::ModelTypeService> GetModelTypeServiceForType(
- syncer::ModelType type) override {
+ base::WeakPtr<ModelTypeService> GetModelTypeServiceForType(
+ ModelType type) override {
return service_->AsWeakPtr();
}
protected:
- std::unique_ptr<syncer_v2::ModelTypeChangeProcessor> CreateProcessor(
- syncer::ModelType type,
- syncer_v2::ModelTypeService* service) {
- std::unique_ptr<syncer_v2::SharedModelTypeProcessor> processor =
- base::MakeUnique<syncer_v2::SharedModelTypeProcessor>(type, service);
+ std::unique_ptr<ModelTypeChangeProcessor> CreateProcessor(
+ ModelType type,
+ ModelTypeService* service) {
+ std::unique_ptr<SharedModelTypeProcessor> processor =
+ base::MakeUnique<SharedModelTypeProcessor>(type, service);
type_processor_ = processor.get();
return std::move(processor);
}
@@ -163,8 +158,8 @@ class UIModelTypeControllerTest : public testing::Test,
controller_->LoadModels(base::Bind(
&UIModelTypeControllerTest::LoadModelsDone, base::Unretained(this)));
if (!type_processor_->IsAllowingChanges()) {
- type_processor_->OnMetadataLoaded(
- syncer::SyncError(), base::MakeUnique<syncer_v2::MetadataBatch>());
+ type_processor_->OnMetadataLoaded(SyncError(),
+ base::MakeUnique<MetadataBatch>());
}
if (auto_run_tasks_) {
@@ -201,40 +196,39 @@ class UIModelTypeControllerTest : public testing::Test,
auto_run_tasks_ = auto_run_tasks;
}
- void LoadModelsDone(syncer::ModelType type, const syncer::SyncError& error) {
+ void LoadModelsDone(ModelType type, const SyncError& error) {
load_models_callback_called_ = true;
load_models_error_ = error;
}
- void AssociationDone(sync_driver::DataTypeController::ConfigureResult result,
- const syncer::SyncMergeResult& local_merge_result,
- const syncer::SyncMergeResult& syncer_merge_result) {
- EXPECT_EQ(sync_driver::DataTypeController::OK, result);
+ void AssociationDone(DataTypeController::ConfigureResult result,
+ const SyncMergeResult& local_merge_result,
+ const SyncMergeResult& syncer_merge_result) {
+ EXPECT_EQ(DataTypeController::OK, result);
association_callback_called_ = true;
}
- syncer_v2::SharedModelTypeProcessor* type_processor_;
+ SharedModelTypeProcessor* type_processor_;
std::unique_ptr<UIModelTypeController> controller_;
bool auto_run_tasks_;
bool load_models_callback_called_;
- syncer::SyncError load_models_error_;
+ SyncError load_models_error_;
bool association_callback_called_;
base::MessageLoopForUI ui_loop_;
MockSyncBackend backend_;
MockBackendDataTypeConfigurer configurer_;
- std::unique_ptr<syncer_v2::StubModelTypeService> service_;
+ std::unique_ptr<StubModelTypeService> service_;
};
TEST_F(UIModelTypeControllerTest, InitialState) {
- EXPECT_EQ(syncer::DEVICE_INFO, controller_->type());
- EXPECT_EQ(sync_driver::DataTypeController::NOT_RUNNING, controller_->state());
+ EXPECT_EQ(DEVICE_INFO, controller_->type());
+ EXPECT_EQ(DataTypeController::NOT_RUNNING, controller_->state());
}
TEST_F(UIModelTypeControllerTest, LoadModelsOnUIThread) {
LoadModels();
- EXPECT_EQ(sync_driver::DataTypeController::MODEL_LOADED,
- controller_->state());
+ EXPECT_EQ(DataTypeController::MODEL_LOADED, controller_->state());
EXPECT_TRUE(load_models_callback_called_);
EXPECT_FALSE(load_models_error_.IsSet());
ExpectProcessorConnected(false);
@@ -244,21 +238,19 @@ TEST_F(UIModelTypeControllerTest, LoadModelsTwice) {
LoadModels();
SetAutoRunTasks(false);
LoadModels();
- EXPECT_EQ(sync_driver::DataTypeController::MODEL_LOADED,
- controller_->state());
+ EXPECT_EQ(DataTypeController::MODEL_LOADED, controller_->state());
// The second LoadModels call should set the error.
EXPECT_TRUE(load_models_error_.IsSet());
}
TEST_F(UIModelTypeControllerTest, ActivateDataTypeOnUIThread) {
LoadModels();
- EXPECT_EQ(sync_driver::DataTypeController::MODEL_LOADED,
- controller_->state());
+ EXPECT_EQ(DataTypeController::MODEL_LOADED, controller_->state());
RegisterWithBackend();
ExpectProcessorConnected(true);
StartAssociating();
- EXPECT_EQ(sync_driver::DataTypeController::RUNNING, controller_->state());
+ EXPECT_EQ(DataTypeController::RUNNING, controller_->state());
}
TEST_F(UIModelTypeControllerTest, Stop) {
@@ -268,7 +260,7 @@ TEST_F(UIModelTypeControllerTest, Stop) {
StartAssociating();
DeactivateDataTypeAndStop();
- EXPECT_EQ(sync_driver::DataTypeController::NOT_RUNNING, controller_->state());
+ EXPECT_EQ(DataTypeController::NOT_RUNNING, controller_->state());
}
-} // namespace sync_driver_v2
+} // namespace syncer
« no previous file with comments | « components/sync/driver/ui_model_type_controller.cc ('k') | components/sync/driver/user_selectable_sync_type.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698