OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/sync/glue/ui_data_type_controller.h" | 5 #include "chrome/browser/sync/glue/ui_data_type_controller.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/tracked_objects.h" | 10 #include "base/tracked_objects.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 MessageLoopForUI message_loop_; | 98 MessageLoopForUI message_loop_; |
99 content::TestBrowserThread ui_thread_; | 99 content::TestBrowserThread ui_thread_; |
100 ProfileMock profile_; | 100 ProfileMock profile_; |
101 scoped_ptr<ProfileSyncComponentsFactoryMock> profile_sync_factory_; | 101 scoped_ptr<ProfileSyncComponentsFactoryMock> profile_sync_factory_; |
102 ProfileSyncServiceMock profile_sync_service_; | 102 ProfileSyncServiceMock profile_sync_service_; |
103 const syncable::ModelType type_; | 103 const syncable::ModelType type_; |
104 StartCallbackMock start_callback_; | 104 StartCallbackMock start_callback_; |
105 ModelLoadCallbackMock model_load_callback_; | 105 ModelLoadCallbackMock model_load_callback_; |
106 scoped_refptr<UIDataTypeController> preference_dtc_; | 106 scoped_refptr<UIDataTypeController> preference_dtc_; |
107 scoped_ptr<FakeGenericChangeProcessor> change_processor_; | 107 scoped_ptr<FakeGenericChangeProcessor> change_processor_; |
108 FakeSyncableService syncable_service_; | 108 csync::FakeSyncableService syncable_service_; |
109 }; | 109 }; |
110 | 110 |
111 // Start the DTC. Verify that the callback is called with OK, the | 111 // Start the DTC. Verify that the callback is called with OK, the |
112 // service has been told to start syncing and that the DTC is now in RUNNING | 112 // service has been told to start syncing and that the DTC is now in RUNNING |
113 // state. | 113 // state. |
114 TEST_F(SyncUIDataTypeControllerTest, Start) { | 114 TEST_F(SyncUIDataTypeControllerTest, Start) { |
115 SetActivateExpectations(); | 115 SetActivateExpectations(); |
116 EXPECT_CALL(start_callback_, Run(DataTypeController::OK, _)); | 116 EXPECT_CALL(start_callback_, Run(DataTypeController::OK, _)); |
117 | 117 |
118 EXPECT_EQ(DataTypeController::NOT_RUNNING, preference_dtc_->state()); | 118 EXPECT_EQ(DataTypeController::NOT_RUNNING, preference_dtc_->state()); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 } | 158 } |
159 | 159 |
160 // Start the DTC, but have the service fail association. Verify the callback | 160 // Start the DTC, but have the service fail association. Verify the callback |
161 // is called with ASSOCIATION_FAILED, the DTC goes to state DISABLED, and the | 161 // is called with ASSOCIATION_FAILED, the DTC goes to state DISABLED, and the |
162 // service is not syncing. Then stop the DTC. | 162 // service is not syncing. Then stop the DTC. |
163 TEST_F(SyncUIDataTypeControllerTest, StartAssociationFailed) { | 163 TEST_F(SyncUIDataTypeControllerTest, StartAssociationFailed) { |
164 SetStopExpectations(); | 164 SetStopExpectations(); |
165 EXPECT_CALL(start_callback_, | 165 EXPECT_CALL(start_callback_, |
166 Run(DataTypeController::ASSOCIATION_FAILED, _)); | 166 Run(DataTypeController::ASSOCIATION_FAILED, _)); |
167 syncable_service_.set_merge_data_and_start_syncing_error( | 167 syncable_service_.set_merge_data_and_start_syncing_error( |
168 SyncError(FROM_HERE, "Error", type_)); | 168 csync::SyncError(FROM_HERE, "Error", type_)); |
169 | 169 |
170 EXPECT_EQ(DataTypeController::NOT_RUNNING, preference_dtc_->state()); | 170 EXPECT_EQ(DataTypeController::NOT_RUNNING, preference_dtc_->state()); |
171 EXPECT_FALSE(syncable_service_.syncing()); | 171 EXPECT_FALSE(syncable_service_.syncing()); |
172 Start(); | 172 Start(); |
173 EXPECT_EQ(DataTypeController::DISABLED, preference_dtc_->state()); | 173 EXPECT_EQ(DataTypeController::DISABLED, preference_dtc_->state()); |
174 EXPECT_FALSE(syncable_service_.syncing()); | 174 EXPECT_FALSE(syncable_service_.syncing()); |
175 preference_dtc_->Stop(); | 175 preference_dtc_->Stop(); |
176 EXPECT_EQ(DataTypeController::NOT_RUNNING, preference_dtc_->state()); | 176 EXPECT_EQ(DataTypeController::NOT_RUNNING, preference_dtc_->state()); |
177 EXPECT_FALSE(syncable_service_.syncing()); | 177 EXPECT_FALSE(syncable_service_.syncing()); |
178 } | 178 } |
(...skipping 29 matching lines...) Expand all Loading... |
208 Start(); | 208 Start(); |
209 EXPECT_TRUE(syncable_service_.syncing()); | 209 EXPECT_TRUE(syncable_service_.syncing()); |
210 preference_dtc_->OnSingleDatatypeUnrecoverableError(FROM_HERE, "Test"); | 210 preference_dtc_->OnSingleDatatypeUnrecoverableError(FROM_HERE, "Test"); |
211 PumpLoop(); | 211 PumpLoop(); |
212 EXPECT_EQ(DataTypeController::NOT_RUNNING, preference_dtc_->state()); | 212 EXPECT_EQ(DataTypeController::NOT_RUNNING, preference_dtc_->state()); |
213 EXPECT_FALSE(syncable_service_.syncing()); | 213 EXPECT_FALSE(syncable_service_.syncing()); |
214 } | 214 } |
215 | 215 |
216 } // namespace | 216 } // namespace |
217 } // namespace browser_sync | 217 } // namespace browser_sync |
OLD | NEW |