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

Unified Diff: components/sync_driver/non_blocking_data_type_controller_unittest.cc

Issue 1321613003: [Sync] Use ModelTypeProcessor instead of ModelTypeProcessorImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert unnecessary changes. Created 5 years, 3 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/non_blocking_data_type_controller_unittest.cc
diff --git a/components/sync_driver/non_blocking_data_type_controller_unittest.cc b/components/sync_driver/non_blocking_data_type_controller_unittest.cc
index 02871ac9f66c41656138beeb89229b730e5c7113..c0e0ecb198cd4705c41a9f110b6d864931e1762e 100644
--- a/components/sync_driver/non_blocking_data_type_controller_unittest.cc
+++ b/components/sync_driver/non_blocking_data_type_controller_unittest.cc
@@ -47,11 +47,11 @@ class MockSyncContext {
void Connect(
syncer::ModelType type,
const scoped_refptr<base::SingleThreadTaskRunner>& model_task_runner,
- const base::WeakPtr<syncer_v2::ModelTypeProcessorImpl>& type_proxy) {
+ const base::WeakPtr<syncer_v2::ModelTypeProcessor>& type_processor) {
enabled_types_.Put(type);
model_task_runner->PostTask(
FROM_HERE,
- base::Bind(&syncer_v2::ModelTypeProcessorImpl::OnConnect, type_proxy,
+ base::Bind(&syncer_v2::ModelTypeProcessor::OnConnect, type_processor,
base::Passed(scoped_ptr<syncer_v2::CommitQueue>(
new NullCommitQueue())
.Pass())));
@@ -83,7 +83,7 @@ class MockSyncContextProxy : public syncer_v2::SyncContextProxy {
syncer::ModelType type,
const syncer_v2::DataTypeState& data_type_state,
const syncer_v2::UpdateResponseDataList& saved_pending_updates,
- const base::WeakPtr<syncer_v2::ModelTypeProcessorImpl>& type_proxy)
+ const base::WeakPtr<syncer_v2::ModelTypeProcessor>& type_processor)
override {
// Normally we'd use ThreadTaskRunnerHandle::Get() as the TaskRunner
// argument
@@ -94,7 +94,7 @@ class MockSyncContextProxy : public syncer_v2::SyncContextProxy {
base::Unretained(mock_sync_context_),
type,
model_task_runner_,
- type_proxy));
+ type_processor));
}
void Disconnect(syncer::ModelType type) override {
@@ -120,7 +120,7 @@ class MockSyncContextProxy : public syncer_v2::SyncContextProxy {
class NonBlockingDataTypeControllerTest : public testing::Test {
public:
NonBlockingDataTypeControllerTest()
- : type_sync_proxy_(syncer::DICTIONARY),
+ : type_processor_(syncer::DICTIONARY),
model_thread_(new base::TestSimpleTaskRunner()),
sync_thread_(new base::TestSimpleTaskRunner()),
controller_(syncer::DICTIONARY, true),
@@ -132,7 +132,7 @@ class NonBlockingDataTypeControllerTest : public testing::Test {
// Connects the sync type proxy to the NonBlockingDataTypeController.
void InitTypeSyncProxy() {
controller_.InitializeType(model_thread_,
- type_sync_proxy_.AsWeakPtrForUI());
+ type_processor_.AsWeakPtrForUI());
if (auto_run_tasks_) {
RunAllTasks();
}
@@ -182,7 +182,7 @@ class NonBlockingDataTypeControllerTest : public testing::Test {
}
protected:
- syncer_v2::ModelTypeProcessorImpl type_sync_proxy_;
+ syncer_v2::ModelTypeProcessorImpl type_processor_;
scoped_refptr<base::TestSimpleTaskRunner> model_thread_;
scoped_refptr<base::TestSimpleTaskRunner> sync_thread_;
@@ -200,45 +200,45 @@ TEST_F(NonBlockingDataTypeControllerTest, UserDisabled) {
InitTypeSyncProxy();
InitSyncBackend();
- EXPECT_FALSE(type_sync_proxy_.IsPreferred());
- EXPECT_FALSE(type_sync_proxy_.IsConnected());
+ EXPECT_FALSE(type_processor_.IsPreferred());
+ EXPECT_FALSE(type_processor_.IsConnected());
UninitializeSyncBackend();
- EXPECT_FALSE(type_sync_proxy_.IsPreferred());
- EXPECT_FALSE(type_sync_proxy_.IsConnected());
+ EXPECT_FALSE(type_processor_.IsPreferred());
+ EXPECT_FALSE(type_processor_.IsConnected());
}
// Init the sync backend then the type sync proxy.
TEST_F(NonBlockingDataTypeControllerTest, Enabled_SyncFirst) {
SetIsPreferred(true);
InitSyncBackend();
- EXPECT_FALSE(type_sync_proxy_.IsPreferred());
- EXPECT_FALSE(type_sync_proxy_.IsConnected());
+ EXPECT_FALSE(type_processor_.IsPreferred());
+ EXPECT_FALSE(type_processor_.IsConnected());
InitTypeSyncProxy();
- EXPECT_TRUE(type_sync_proxy_.IsPreferred());
- EXPECT_TRUE(type_sync_proxy_.IsConnected());
+ EXPECT_TRUE(type_processor_.IsPreferred());
+ EXPECT_TRUE(type_processor_.IsConnected());
UninitializeSyncBackend();
- EXPECT_TRUE(type_sync_proxy_.IsPreferred());
- EXPECT_FALSE(type_sync_proxy_.IsConnected());
+ EXPECT_TRUE(type_processor_.IsPreferred());
+ EXPECT_FALSE(type_processor_.IsConnected());
}
// Init the type sync proxy then the sync backend.
TEST_F(NonBlockingDataTypeControllerTest, Enabled_ProcessorFirst) {
SetIsPreferred(true);
InitTypeSyncProxy();
- EXPECT_FALSE(type_sync_proxy_.IsPreferred());
- EXPECT_FALSE(type_sync_proxy_.IsConnected());
+ EXPECT_FALSE(type_processor_.IsPreferred());
+ EXPECT_FALSE(type_processor_.IsConnected());
InitSyncBackend();
- EXPECT_TRUE(type_sync_proxy_.IsPreferred());
- EXPECT_TRUE(type_sync_proxy_.IsConnected());
+ EXPECT_TRUE(type_processor_.IsPreferred());
+ EXPECT_TRUE(type_processor_.IsConnected());
UninitializeSyncBackend();
- EXPECT_TRUE(type_sync_proxy_.IsPreferred());
- EXPECT_FALSE(type_sync_proxy_.IsConnected());
+ EXPECT_TRUE(type_processor_.IsPreferred());
+ EXPECT_FALSE(type_processor_.IsConnected());
}
// Initialize sync then disable it with a pref change.
@@ -247,12 +247,12 @@ TEST_F(NonBlockingDataTypeControllerTest, PreferThenNot) {
InitTypeSyncProxy();
InitSyncBackend();
- EXPECT_TRUE(type_sync_proxy_.IsPreferred());
- EXPECT_TRUE(type_sync_proxy_.IsConnected());
+ EXPECT_TRUE(type_processor_.IsPreferred());
+ EXPECT_TRUE(type_processor_.IsConnected());
SetIsPreferred(false);
- EXPECT_FALSE(type_sync_proxy_.IsPreferred());
- EXPECT_FALSE(type_sync_proxy_.IsConnected());
+ EXPECT_FALSE(type_processor_.IsPreferred());
+ EXPECT_FALSE(type_processor_.IsConnected());
}
// Connect type sync proxy and sync backend, then toggle prefs repeatedly.
@@ -260,24 +260,24 @@ TEST_F(NonBlockingDataTypeControllerTest, RepeatedTogglePreference) {
SetIsPreferred(false);
InitTypeSyncProxy();
InitSyncBackend();
- EXPECT_FALSE(type_sync_proxy_.IsPreferred());
- EXPECT_FALSE(type_sync_proxy_.IsConnected());
+ EXPECT_FALSE(type_processor_.IsPreferred());
+ EXPECT_FALSE(type_processor_.IsConnected());
SetIsPreferred(true);
- EXPECT_TRUE(type_sync_proxy_.IsPreferred());
- EXPECT_TRUE(type_sync_proxy_.IsConnected());
+ EXPECT_TRUE(type_processor_.IsPreferred());
+ EXPECT_TRUE(type_processor_.IsConnected());
SetIsPreferred(false);
- EXPECT_FALSE(type_sync_proxy_.IsPreferred());
- EXPECT_FALSE(type_sync_proxy_.IsConnected());
+ EXPECT_FALSE(type_processor_.IsPreferred());
+ EXPECT_FALSE(type_processor_.IsConnected());
SetIsPreferred(true);
- EXPECT_TRUE(type_sync_proxy_.IsPreferred());
- EXPECT_TRUE(type_sync_proxy_.IsConnected());
+ EXPECT_TRUE(type_processor_.IsPreferred());
+ EXPECT_TRUE(type_processor_.IsConnected());
SetIsPreferred(false);
- EXPECT_FALSE(type_sync_proxy_.IsPreferred());
- EXPECT_FALSE(type_sync_proxy_.IsConnected());
+ EXPECT_FALSE(type_processor_.IsPreferred());
+ EXPECT_FALSE(type_processor_.IsConnected());
}
// Test sync backend getting restarted while processor is connected.
@@ -285,18 +285,18 @@ TEST_F(NonBlockingDataTypeControllerTest, RestartSyncBackend) {
SetIsPreferred(true);
InitTypeSyncProxy();
InitSyncBackend();
- EXPECT_TRUE(type_sync_proxy_.IsPreferred());
- EXPECT_TRUE(type_sync_proxy_.IsConnected());
+ EXPECT_TRUE(type_processor_.IsPreferred());
+ EXPECT_TRUE(type_processor_.IsConnected());
// Shutting down sync backend should disconnect but not disable the type.
UninitializeSyncBackend();
- EXPECT_TRUE(type_sync_proxy_.IsPreferred());
- EXPECT_FALSE(type_sync_proxy_.IsConnected());
+ EXPECT_TRUE(type_processor_.IsPreferred());
+ EXPECT_FALSE(type_processor_.IsConnected());
// Brining the backend back should reconnect the type.
InitSyncBackend();
- EXPECT_TRUE(type_sync_proxy_.IsPreferred());
- EXPECT_TRUE(type_sync_proxy_.IsConnected());
+ EXPECT_TRUE(type_processor_.IsPreferred());
+ EXPECT_TRUE(type_processor_.IsConnected());
}
// Test sync backend being restarted before processor connects.
@@ -305,15 +305,15 @@ TEST_F(NonBlockingDataTypeControllerTest, RestartSyncBackendEarly) {
// Toggle sync off and on before the type sync proxy is available.
InitSyncBackend();
- EXPECT_FALSE(type_sync_proxy_.IsConnected());
+ EXPECT_FALSE(type_processor_.IsConnected());
UninitializeSyncBackend();
- EXPECT_FALSE(type_sync_proxy_.IsConnected());
+ EXPECT_FALSE(type_processor_.IsConnected());
InitSyncBackend();
- EXPECT_FALSE(type_sync_proxy_.IsConnected());
+ EXPECT_FALSE(type_processor_.IsConnected());
// Introduce the processor.
InitTypeSyncProxy();
- EXPECT_TRUE(type_sync_proxy_.IsConnected());
+ EXPECT_TRUE(type_processor_.IsConnected());
}
// Test pref toggling before the sync backend has connected.
@@ -323,18 +323,18 @@ TEST_F(NonBlockingDataTypeControllerTest, TogglePreferenceWithoutBackend) {
// This should emit a disable signal.
SetIsPreferred(false);
- EXPECT_FALSE(type_sync_proxy_.IsConnected());
- EXPECT_FALSE(type_sync_proxy_.IsPreferred());
+ EXPECT_FALSE(type_processor_.IsConnected());
+ EXPECT_FALSE(type_processor_.IsPreferred());
// This won't enable us, since we don't have a sync backend.
SetIsPreferred(true);
- EXPECT_FALSE(type_sync_proxy_.IsConnected());
- EXPECT_FALSE(type_sync_proxy_.IsPreferred());
+ EXPECT_FALSE(type_processor_.IsConnected());
+ EXPECT_FALSE(type_processor_.IsPreferred());
// Only now do we start sending enable signals.
InitSyncBackend();
- EXPECT_TRUE(type_sync_proxy_.IsConnected());
- EXPECT_TRUE(type_sync_proxy_.IsPreferred());
+ EXPECT_TRUE(type_processor_.IsConnected());
+ EXPECT_TRUE(type_processor_.IsPreferred());
}
// Turns off auto-task-running to test the effects of delaying a connection
@@ -355,16 +355,16 @@ TEST_F(NonBlockingDataTypeControllerTest, DelayedConnect) {
// That should result in a request to connect, but it won't be
// executed right away.
- EXPECT_FALSE(type_sync_proxy_.IsConnected());
- EXPECT_TRUE(type_sync_proxy_.IsPreferred());
+ EXPECT_FALSE(type_processor_.IsConnected());
+ EXPECT_TRUE(type_processor_.IsPreferred());
// Let the sync thread process the request and the model thread handle its
// response.
RunQueuedSyncThreadTasks();
RunQueuedModelThreadTasks();
- EXPECT_TRUE(type_sync_proxy_.IsConnected());
- EXPECT_TRUE(type_sync_proxy_.IsPreferred());
+ EXPECT_TRUE(type_processor_.IsConnected());
+ EXPECT_TRUE(type_processor_.IsPreferred());
}
// Send Disable signal while a connection request is in progress.
@@ -380,8 +380,8 @@ TEST_F(NonBlockingDataTypeControllerTest, DisableRacesWithOnConnect) {
// That should result in a request to connect, but it won't be
// executed right away.
- EXPECT_FALSE(type_sync_proxy_.IsConnected());
- EXPECT_TRUE(type_sync_proxy_.IsPreferred());
+ EXPECT_FALSE(type_processor_.IsConnected());
+ EXPECT_TRUE(type_processor_.IsPreferred());
// Send and execute a disable signal before the OnConnect callback returns.
SetIsPreferred(false);
@@ -396,8 +396,8 @@ TEST_F(NonBlockingDataTypeControllerTest, DisableRacesWithOnConnect) {
// from the UI thread earlier. We need to make sure that doesn't happen.
RunQueuedModelThreadTasks();
- EXPECT_FALSE(type_sync_proxy_.IsPreferred());
- EXPECT_FALSE(type_sync_proxy_.IsConnected());
+ EXPECT_FALSE(type_processor_.IsPreferred());
+ EXPECT_FALSE(type_processor_.IsConnected());
}
// Send a request to enable, then disable, then re-enable the data type.
@@ -413,18 +413,18 @@ TEST_F(NonBlockingDataTypeControllerTest, EnableDisableEnableRace) {
RunQueuedModelThreadTasks();
// That was the first enable.
- EXPECT_FALSE(type_sync_proxy_.IsConnected());
- EXPECT_TRUE(type_sync_proxy_.IsPreferred());
+ EXPECT_FALSE(type_processor_.IsConnected());
+ EXPECT_TRUE(type_processor_.IsPreferred());
// Now disable.
SetIsPreferred(false);
RunQueuedModelThreadTasks();
- EXPECT_FALSE(type_sync_proxy_.IsPreferred());
+ EXPECT_FALSE(type_processor_.IsPreferred());
// And re-enable.
SetIsPreferred(true);
RunQueuedModelThreadTasks();
- EXPECT_TRUE(type_sync_proxy_.IsPreferred());
+ EXPECT_TRUE(type_processor_.IsPreferred());
// The sync thread has three messages related to those enables and
// disables sittin in its queue. Let's allow it to process them.
@@ -432,8 +432,8 @@ TEST_F(NonBlockingDataTypeControllerTest, EnableDisableEnableRace) {
// Let the model thread process any messages from the sync thread.
RunQueuedModelThreadTasks();
- EXPECT_TRUE(type_sync_proxy_.IsPreferred());
- EXPECT_TRUE(type_sync_proxy_.IsConnected());
+ EXPECT_TRUE(type_processor_.IsPreferred());
+ EXPECT_TRUE(type_processor_.IsConnected());
}
} // namespace sync_driver_v2
« no previous file with comments | « components/sync_driver/non_blocking_data_type_controller.h ('k') | sync/engine/model_type_processor_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698