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/callback.h" | 5 #include "base/callback.h" |
6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "chrome/browser/sync/glue/autofill_data_type_controller.h" | 10 #include "chrome/browser/sync/glue/autofill_data_type_controller.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 &profile_, BuildWebDataService); | 89 &profile_, BuildWebDataService); |
90 | 90 |
91 autofill_dtc_ = | 91 autofill_dtc_ = |
92 new AutofillDataTypeController(&profile_sync_factory_, | 92 new AutofillDataTypeController(&profile_sync_factory_, |
93 &profile_, | 93 &profile_, |
94 &service_); | 94 &service_); |
95 } | 95 } |
96 | 96 |
97 // Passed to AutofillDTC::Start(). | 97 // Passed to AutofillDTC::Start(). |
98 void OnStartFinished(DataTypeController::StartResult result, | 98 void OnStartFinished(DataTypeController::StartResult result, |
99 const SyncError& error) { | 99 const csync::SyncError& error) { |
100 last_start_result_ = result; | 100 last_start_result_ = result; |
101 last_start_error_ = error; | 101 last_start_error_ = error; |
102 } | 102 } |
103 | 103 |
104 void OnLoadFinished(syncable::ModelType type, | 104 void OnLoadFinished(syncable::ModelType type, |
105 SyncError error) { | 105 csync::SyncError error) { |
106 EXPECT_FALSE(error.IsSet()); | 106 EXPECT_FALSE(error.IsSet()); |
107 EXPECT_EQ(type, syncable::AUTOFILL); | 107 EXPECT_EQ(type, syncable::AUTOFILL); |
108 } | 108 } |
109 | 109 |
110 virtual void TearDown() { | 110 virtual void TearDown() { |
111 autofill_dtc_ = NULL; | 111 autofill_dtc_ = NULL; |
112 change_processor_ = NULL; | 112 change_processor_ = NULL; |
113 } | 113 } |
114 | 114 |
115 static scoped_refptr<RefcountedProfileKeyedService> | 115 static scoped_refptr<RefcountedProfileKeyedService> |
116 BuildWebDataService(Profile* profile) { | 116 BuildWebDataService(Profile* profile) { |
117 return new FakeWebDataService(); | 117 return new FakeWebDataService(); |
118 } | 118 } |
119 | 119 |
120 protected: | 120 protected: |
121 base::WeakPtrFactory<SyncAutofillDataTypeControllerTest> weak_ptr_factory_; | 121 base::WeakPtrFactory<SyncAutofillDataTypeControllerTest> weak_ptr_factory_; |
122 MessageLoopForUI message_loop_; | 122 MessageLoopForUI message_loop_; |
123 content::TestBrowserThread ui_thread_; | 123 content::TestBrowserThread ui_thread_; |
124 content::TestBrowserThread db_thread_; | 124 content::TestBrowserThread db_thread_; |
125 | 125 |
126 scoped_refptr<NiceMock<SharedChangeProcessorMock> > change_processor_; | 126 scoped_refptr<NiceMock<SharedChangeProcessorMock> > change_processor_; |
127 ProfileSyncComponentsFactoryMock profile_sync_factory_; | 127 ProfileSyncComponentsFactoryMock profile_sync_factory_; |
128 ProfileSyncServiceMock service_; | 128 ProfileSyncServiceMock service_; |
129 ProfileMock profile_; | 129 ProfileMock profile_; |
130 scoped_refptr<AutofillDataTypeController> autofill_dtc_; | 130 scoped_refptr<AutofillDataTypeController> autofill_dtc_; |
131 | 131 |
132 // Stores arguments of most recent call of OnStartFinished(). | 132 // Stores arguments of most recent call of OnStartFinished(). |
133 DataTypeController::StartResult last_start_result_; | 133 DataTypeController::StartResult last_start_result_; |
134 SyncError last_start_error_; | 134 csync::SyncError last_start_error_; |
135 }; | 135 }; |
136 | 136 |
137 // Load the WDS's database, then start the Autofill DTC. It should | 137 // Load the WDS's database, then start the Autofill DTC. It should |
138 // immediately try to start association and fail (due to missing DB | 138 // immediately try to start association and fail (due to missing DB |
139 // thread). | 139 // thread). |
140 TEST_F(SyncAutofillDataTypeControllerTest, StartWDSReady) { | 140 TEST_F(SyncAutofillDataTypeControllerTest, StartWDSReady) { |
141 FakeWebDataService* web_db = | 141 FakeWebDataService* web_db = |
142 static_cast<FakeWebDataService*>(WebDataServiceFactory::GetForProfile( | 142 static_cast<FakeWebDataService*>(WebDataServiceFactory::GetForProfile( |
143 &profile_, Profile::EXPLICIT_ACCESS).get()); | 143 &profile_, Profile::EXPLICIT_ACCESS).get()); |
144 web_db->LoadDatabase(); | 144 web_db->LoadDatabase(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 178 |
179 EXPECT_EQ(DataTypeController::ASSOCIATION_FAILED, last_start_result_); | 179 EXPECT_EQ(DataTypeController::ASSOCIATION_FAILED, last_start_result_); |
180 EXPECT_TRUE(last_start_error_.IsSet()); | 180 EXPECT_TRUE(last_start_error_.IsSet()); |
181 | 181 |
182 EXPECT_EQ(DataTypeController::NOT_RUNNING, autofill_dtc_->state()); | 182 EXPECT_EQ(DataTypeController::NOT_RUNNING, autofill_dtc_->state()); |
183 } | 183 } |
184 | 184 |
185 } // namespace | 185 } // namespace |
186 | 186 |
187 } // namespace browser_sync | 187 } // namespace browser_sync |
OLD | NEW |