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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/tracked_objects.h" | 9 #include "base/tracked_objects.h" |
10 #include "chrome/browser/search_engines/template_url_service_factory.h" | 10 #include "chrome/browser/search_engines/template_url_service_factory.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 } | 96 } |
97 | 97 |
98 // This also manages a BrowserThread and MessageLoop for us. Note that this | 98 // This also manages a BrowserThread and MessageLoop for us. Note that this |
99 // must be declared here as the destruction order of the BrowserThread | 99 // must be declared here as the destruction order of the BrowserThread |
100 // matters - we could leak if this is declared below. | 100 // matters - we could leak if this is declared below. |
101 TemplateURLServiceTestUtil test_util_; | 101 TemplateURLServiceTestUtil test_util_; |
102 scoped_refptr<SearchEngineDataTypeController> search_engine_dtc_; | 102 scoped_refptr<SearchEngineDataTypeController> search_engine_dtc_; |
103 scoped_ptr<ProfileSyncComponentsFactoryMock> profile_sync_factory_; | 103 scoped_ptr<ProfileSyncComponentsFactoryMock> profile_sync_factory_; |
104 ProfileSyncServiceMock service_; | 104 ProfileSyncServiceMock service_; |
105 scoped_ptr<FakeGenericChangeProcessor> change_processor_; | 105 scoped_ptr<FakeGenericChangeProcessor> change_processor_; |
106 FakeSyncableService syncable_service_; | 106 csync::FakeSyncableService syncable_service_; |
107 StartCallbackMock start_callback_; | 107 StartCallbackMock start_callback_; |
108 ModelLoadCallbackMock model_load_callback_; | 108 ModelLoadCallbackMock model_load_callback_; |
109 }; | 109 }; |
110 | 110 |
111 TEST_F(SyncSearchEngineDataTypeControllerTest, StartURLServiceReady) { | 111 TEST_F(SyncSearchEngineDataTypeControllerTest, StartURLServiceReady) { |
112 SetStartExpectations(); | 112 SetStartExpectations(); |
113 // We want to start ready. | 113 // We want to start ready. |
114 PreloadTemplateURLService(); | 114 PreloadTemplateURLService(); |
115 SetActivateExpectations(); | 115 SetActivateExpectations(); |
116 EXPECT_CALL(start_callback_, Run(DataTypeController::OK, _)); | 116 EXPECT_CALL(start_callback_, Run(DataTypeController::OK, _)); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 EXPECT_TRUE(syncable_service_.syncing()); | 154 EXPECT_TRUE(syncable_service_.syncing()); |
155 } | 155 } |
156 | 156 |
157 TEST_F(SyncSearchEngineDataTypeControllerTest, StartAssociationFailed) { | 157 TEST_F(SyncSearchEngineDataTypeControllerTest, StartAssociationFailed) { |
158 SetStartExpectations(); | 158 SetStartExpectations(); |
159 PreloadTemplateURLService(); | 159 PreloadTemplateURLService(); |
160 SetStopExpectations(); | 160 SetStopExpectations(); |
161 EXPECT_CALL(start_callback_, | 161 EXPECT_CALL(start_callback_, |
162 Run(DataTypeController::ASSOCIATION_FAILED, _)); | 162 Run(DataTypeController::ASSOCIATION_FAILED, _)); |
163 syncable_service_.set_merge_data_and_start_syncing_error( | 163 syncable_service_.set_merge_data_and_start_syncing_error( |
164 SyncError(FROM_HERE, "Error", syncable::SEARCH_ENGINES)); | 164 csync::SyncError(FROM_HERE, "Error", syncable::SEARCH_ENGINES)); |
165 | 165 |
166 Start(); | 166 Start(); |
167 EXPECT_EQ(DataTypeController::DISABLED, search_engine_dtc_->state()); | 167 EXPECT_EQ(DataTypeController::DISABLED, search_engine_dtc_->state()); |
168 EXPECT_FALSE(syncable_service_.syncing()); | 168 EXPECT_FALSE(syncable_service_.syncing()); |
169 search_engine_dtc_->Stop(); | 169 search_engine_dtc_->Stop(); |
170 EXPECT_EQ(DataTypeController::NOT_RUNNING, search_engine_dtc_->state()); | 170 EXPECT_EQ(DataTypeController::NOT_RUNNING, search_engine_dtc_->state()); |
171 EXPECT_FALSE(syncable_service_.syncing()); | 171 EXPECT_FALSE(syncable_service_.syncing()); |
172 } | 172 } |
173 | 173 |
174 TEST_F(SyncSearchEngineDataTypeControllerTest, | 174 TEST_F(SyncSearchEngineDataTypeControllerTest, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 Start(); | 216 Start(); |
217 // This should cause search_engine_dtc_->Stop() to be called. | 217 // This should cause search_engine_dtc_->Stop() to be called. |
218 search_engine_dtc_->OnSingleDatatypeUnrecoverableError(FROM_HERE, "Test"); | 218 search_engine_dtc_->OnSingleDatatypeUnrecoverableError(FROM_HERE, "Test"); |
219 test_util_.PumpLoop(); | 219 test_util_.PumpLoop(); |
220 EXPECT_EQ(DataTypeController::NOT_RUNNING, search_engine_dtc_->state()); | 220 EXPECT_EQ(DataTypeController::NOT_RUNNING, search_engine_dtc_->state()); |
221 EXPECT_FALSE(syncable_service_.syncing()); | 221 EXPECT_FALSE(syncable_service_.syncing()); |
222 } | 222 } |
223 | 223 |
224 } // namespace | 224 } // namespace |
225 } // namespace browser_sync | 225 } // namespace browser_sync |
OLD | NEW |