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

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

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