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

Side by Side Diff: components/sync_driver/ui_data_type_controller_unittest.cc

Issue 1144153004: components: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/sync_driver/ui_data_type_controller.h" 5 #include "components/sync_driver/ui_data_type_controller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h"
8 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h" 10 #include "base/single_thread_task_runner.h"
11 #include "base/thread_task_runner_handle.h"
10 #include "base/tracked_objects.h" 12 #include "base/tracked_objects.h"
11 #include "components/sync_driver/data_type_controller_mock.h" 13 #include "components/sync_driver/data_type_controller_mock.h"
12 #include "components/sync_driver/fake_generic_change_processor.h" 14 #include "components/sync_driver/fake_generic_change_processor.h"
13 #include "sync/api/fake_syncable_service.h" 15 #include "sync/api/fake_syncable_service.h"
14 #include "sync/internal_api/public/attachments/attachment_service_impl.h" 16 #include "sync/internal_api/public/attachments/attachment_service_impl.h"
15 #include "sync/internal_api/public/base/model_type.h" 17 #include "sync/internal_api/public/base/model_type.h"
16 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
17 19
18 using testing::_; 20 using testing::_;
19 using testing::Invoke; 21 using testing::Invoke;
20 using testing::InvokeWithoutArgs; 22 using testing::InvokeWithoutArgs;
21 using testing::Return; 23 using testing::Return;
22 24
23 namespace sync_driver { 25 namespace sync_driver {
24 namespace { 26 namespace {
25 27
26 // TODO(zea): Expand this to make the dtc type paramterizable. This will let us 28 // TODO(zea): Expand this to make the dtc type paramterizable. This will let us
27 // test the basic functionality of all UIDataTypeControllers. We'll need to have 29 // test the basic functionality of all UIDataTypeControllers. We'll need to have
28 // intelligent default values for the methods queried in the dependent services 30 // intelligent default values for the methods queried in the dependent services
29 // (e.g. those queried in StartModels). 31 // (e.g. those queried in StartModels).
30 class SyncUIDataTypeControllerTest : public testing::Test, 32 class SyncUIDataTypeControllerTest : public testing::Test,
31 public SyncApiComponentFactory { 33 public SyncApiComponentFactory {
32 public: 34 public:
33 SyncUIDataTypeControllerTest() 35 SyncUIDataTypeControllerTest()
34 : type_(syncer::PREFERENCES), 36 : type_(syncer::PREFERENCES),
35 change_processor_(NULL) {} 37 change_processor_(NULL) {}
36 38
37 void SetUp() override { 39 void SetUp() override {
38 preference_dtc_ = 40 preference_dtc_ = new UIDataTypeController(
39 new UIDataTypeController( 41 base::ThreadTaskRunnerHandle::Get(), base::Closure(), type_, this);
40 base::MessageLoopProxy::current(),
41 base::Closure(),
42 type_,
43 this);
44 SetStartExpectations(); 42 SetStartExpectations();
45 } 43 }
46 44
47 void TearDown() override { 45 void TearDown() override {
48 // Must be done before we pump the loop. 46 // Must be done before we pump the loop.
49 syncable_service_.StopSyncing(type_); 47 syncable_service_.StopSyncing(type_);
50 preference_dtc_ = NULL; 48 preference_dtc_ = NULL;
51 PumpLoop(); 49 PumpLoop();
52 } 50 }
53 51
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 preference_dtc_->Stop(); 123 preference_dtc_->Stop();
126 EXPECT_EQ(DataTypeController::NOT_RUNNING, preference_dtc_->state()); 124 EXPECT_EQ(DataTypeController::NOT_RUNNING, preference_dtc_->state());
127 EXPECT_FALSE(syncable_service_.syncing()); 125 EXPECT_FALSE(syncable_service_.syncing());
128 } 126 }
129 127
130 // Start and then stop the DTC before the Start had a chance to perform 128 // Start and then stop the DTC before the Start had a chance to perform
131 // association. Verify that the service never started and is NOT_RUNNING. 129 // association. Verify that the service never started and is NOT_RUNNING.
132 TEST_F(SyncUIDataTypeControllerTest, StartStopBeforeAssociation) { 130 TEST_F(SyncUIDataTypeControllerTest, StartStopBeforeAssociation) {
133 EXPECT_EQ(DataTypeController::NOT_RUNNING, preference_dtc_->state()); 131 EXPECT_EQ(DataTypeController::NOT_RUNNING, preference_dtc_->state());
134 EXPECT_FALSE(syncable_service_.syncing()); 132 EXPECT_FALSE(syncable_service_.syncing());
135 message_loop_.PostTask(FROM_HERE, 133 message_loop_.task_runner()->PostTask(
136 base::Bind(&UIDataTypeController::Stop, 134 FROM_HERE, base::Bind(&UIDataTypeController::Stop, preference_dtc_));
137 preference_dtc_));
138 Start(); 135 Start();
139 EXPECT_EQ(DataTypeController::NOT_RUNNING, preference_dtc_->state()); 136 EXPECT_EQ(DataTypeController::NOT_RUNNING, preference_dtc_->state());
140 EXPECT_FALSE(syncable_service_.syncing()); 137 EXPECT_FALSE(syncable_service_.syncing());
141 } 138 }
142 139
143 // Start the DTC when no user nodes are created. Verify that the callback 140 // Start the DTC when no user nodes are created. Verify that the callback
144 // is called with OK_FIRST_RUN. Stop the DTC. 141 // is called with OK_FIRST_RUN. Stop the DTC.
145 TEST_F(SyncUIDataTypeControllerTest, StartStopFirstRun) { 142 TEST_F(SyncUIDataTypeControllerTest, StartStopFirstRun) {
146 EXPECT_CALL(start_callback_, Run(DataTypeController::OK_FIRST_RUN, _, _)); 143 EXPECT_CALL(start_callback_, Run(DataTypeController::OK_FIRST_RUN, _, _));
147 change_processor_->set_sync_model_has_user_created_nodes(false); 144 change_processor_->set_sync_model_has_user_created_nodes(false);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 EXPECT_CALL(model_load_callback_, Run(_, _)); 205 EXPECT_CALL(model_load_callback_, Run(_, _));
209 syncer::SyncError error(FROM_HERE, 206 syncer::SyncError error(FROM_HERE,
210 syncer::SyncError::DATATYPE_ERROR, 207 syncer::SyncError::DATATYPE_ERROR,
211 "error", 208 "error",
212 syncer::PREFERENCES); 209 syncer::PREFERENCES);
213 preference_dtc_->OnSingleDataTypeUnrecoverableError(error); 210 preference_dtc_->OnSingleDataTypeUnrecoverableError(error);
214 } 211 }
215 212
216 } // namespace 213 } // namespace
217 } // namespace sync_driver 214 } // namespace sync_driver
OLDNEW
« no previous file with comments | « components/sync_driver/ui_data_type_controller.cc ('k') | components/timers/alarm_timer_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698