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 <map> | 5 #include <map> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/guid.h" | 9 #include "base/guid.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 194 |
195 DISALLOW_COPY_AND_ASSIGN(TestAutofillDialogView); | 195 DISALLOW_COPY_AND_ASSIGN(TestAutofillDialogView); |
196 }; | 196 }; |
197 | 197 |
198 // Bring over command-ids from AccountChooserModel. | 198 // Bring over command-ids from AccountChooserModel. |
199 class TestAccountChooserModel : public AccountChooserModel { | 199 class TestAccountChooserModel : public AccountChooserModel { |
200 public: | 200 public: |
201 TestAccountChooserModel(AccountChooserModelDelegate* delegate, | 201 TestAccountChooserModel(AccountChooserModelDelegate* delegate, |
202 PrefService* prefs, | 202 PrefService* prefs, |
203 const AutofillMetrics& metric_logger) | 203 const AutofillMetrics& metric_logger) |
204 : AccountChooserModel(delegate, prefs, metric_logger, | 204 : AccountChooserModel(delegate, prefs, metric_logger) {} |
205 DIALOG_TYPE_REQUEST_AUTOCOMPLETE) {} | |
206 virtual ~TestAccountChooserModel() {} | 205 virtual ~TestAccountChooserModel() {} |
207 | 206 |
208 using AccountChooserModel::kActiveWalletItemId; | 207 using AccountChooserModel::kActiveWalletItemId; |
209 using AccountChooserModel::kAutofillItemId; | 208 using AccountChooserModel::kAutofillItemId; |
210 | 209 |
211 private: | 210 private: |
212 DISALLOW_COPY_AND_ASSIGN(TestAccountChooserModel); | 211 DISALLOW_COPY_AND_ASSIGN(TestAccountChooserModel); |
213 }; | 212 }; |
214 | 213 |
215 class TestAutofillDialogController | 214 class TestAutofillDialogController |
216 : public AutofillDialogControllerImpl, | 215 : public AutofillDialogControllerImpl, |
217 public base::SupportsWeakPtr<TestAutofillDialogController> { | 216 public base::SupportsWeakPtr<TestAutofillDialogController> { |
218 public: | 217 public: |
219 TestAutofillDialogController( | 218 TestAutofillDialogController( |
220 content::WebContents* contents, | 219 content::WebContents* contents, |
221 const FormData& form_structure, | 220 const FormData& form_structure, |
222 const GURL& source_url, | 221 const GURL& source_url, |
223 const AutofillMetrics& metric_logger, | 222 const AutofillMetrics& metric_logger, |
224 const DialogType dialog_type, | |
225 const base::Callback<void(const FormStructure*, | 223 const base::Callback<void(const FormStructure*, |
226 const std::string&)>& callback, | 224 const std::string&)>& callback, |
227 MockNewCreditCardBubbleController* mock_new_card_bubble_controller) | 225 MockNewCreditCardBubbleController* mock_new_card_bubble_controller) |
228 : AutofillDialogControllerImpl(contents, | 226 : AutofillDialogControllerImpl(contents, |
229 form_structure, | 227 form_structure, |
230 source_url, | 228 source_url, |
231 dialog_type, | |
232 callback), | 229 callback), |
233 metric_logger_(metric_logger), | 230 metric_logger_(metric_logger), |
234 mock_wallet_client_( | 231 mock_wallet_client_( |
235 Profile::FromBrowserContext(contents->GetBrowserContext())-> | 232 Profile::FromBrowserContext(contents->GetBrowserContext())-> |
236 GetRequestContext(), this), | 233 GetRequestContext(), this), |
237 dialog_type_(dialog_type), | |
238 mock_new_card_bubble_controller_(mock_new_card_bubble_controller) {} | 234 mock_new_card_bubble_controller_(mock_new_card_bubble_controller) {} |
239 | 235 |
240 virtual ~TestAutofillDialogController() {} | 236 virtual ~TestAutofillDialogController() {} |
241 | 237 |
242 virtual AutofillDialogView* CreateView() OVERRIDE { | 238 virtual AutofillDialogView* CreateView() OVERRIDE { |
243 return new testing::NiceMock<TestAutofillDialogView>(); | 239 return new testing::NiceMock<TestAutofillDialogView>(); |
244 } | 240 } |
245 | 241 |
246 void Init(content::BrowserContext* browser_context) { | 242 void Init(content::BrowserContext* browser_context) { |
247 test_manager_.Init(browser_context); | 243 test_manager_.Init(browser_context); |
248 } | 244 } |
249 | 245 |
250 TestAutofillDialogView* GetView() { | 246 TestAutofillDialogView* GetView() { |
251 return static_cast<TestAutofillDialogView*>(view()); | 247 return static_cast<TestAutofillDialogView*>(view()); |
252 } | 248 } |
253 | 249 |
254 TestPersonalDataManager* GetTestingManager() { | 250 TestPersonalDataManager* GetTestingManager() { |
255 return &test_manager_; | 251 return &test_manager_; |
256 } | 252 } |
257 | 253 |
258 wallet::MockWalletClient* GetTestingWalletClient() { | 254 wallet::MockWalletClient* GetTestingWalletClient() { |
259 return &mock_wallet_client_; | 255 return &mock_wallet_client_; |
260 } | 256 } |
261 | 257 |
262 const GURL& open_tab_url() { return open_tab_url_; } | 258 const GURL& open_tab_url() { return open_tab_url_; } |
263 | 259 |
264 virtual DialogType GetDialogType() const OVERRIDE { | |
265 return dialog_type_; | |
266 } | |
267 | |
268 void set_dialog_type(DialogType dialog_type) { dialog_type_ = dialog_type; } | |
269 | |
270 void SimulateSigninError() { | 260 void SimulateSigninError() { |
271 OnWalletSigninError(); | 261 OnWalletSigninError(); |
272 } | 262 } |
273 | 263 |
274 MOCK_METHOD0(LoadRiskFingerprintData, void()); | 264 MOCK_METHOD0(LoadRiskFingerprintData, void()); |
275 using AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData; | 265 using AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData; |
276 using AutofillDialogControllerImpl::IsEditingExistingData; | 266 using AutofillDialogControllerImpl::IsEditingExistingData; |
277 | 267 |
278 protected: | 268 protected: |
279 virtual PersonalDataManager* GetManager() OVERRIDE { | 269 virtual PersonalDataManager* GetManager() OVERRIDE { |
(...skipping 24 matching lines...) Expand all Loading... |
304 private: | 294 private: |
305 // To specify our own metric logger. | 295 // To specify our own metric logger. |
306 virtual const AutofillMetrics& GetMetricLogger() const OVERRIDE { | 296 virtual const AutofillMetrics& GetMetricLogger() const OVERRIDE { |
307 return metric_logger_; | 297 return metric_logger_; |
308 } | 298 } |
309 | 299 |
310 const AutofillMetrics& metric_logger_; | 300 const AutofillMetrics& metric_logger_; |
311 TestPersonalDataManager test_manager_; | 301 TestPersonalDataManager test_manager_; |
312 testing::NiceMock<wallet::MockWalletClient> mock_wallet_client_; | 302 testing::NiceMock<wallet::MockWalletClient> mock_wallet_client_; |
313 GURL open_tab_url_; | 303 GURL open_tab_url_; |
314 DialogType dialog_type_; | |
315 MockNewCreditCardBubbleController* mock_new_card_bubble_controller_; | 304 MockNewCreditCardBubbleController* mock_new_card_bubble_controller_; |
316 | 305 |
317 DISALLOW_COPY_AND_ASSIGN(TestAutofillDialogController); | 306 DISALLOW_COPY_AND_ASSIGN(TestAutofillDialogController); |
318 }; | 307 }; |
319 | 308 |
320 class TestGeneratedCreditCardBubbleController : | 309 class TestGeneratedCreditCardBubbleController : |
321 public GeneratedCreditCardBubbleController { | 310 public GeneratedCreditCardBubbleController { |
322 public: | 311 public: |
323 explicit TestGeneratedCreditCardBubbleController( | 312 explicit TestGeneratedCreditCardBubbleController( |
324 content::WebContents* contents) | 313 content::WebContents* contents) |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 controller_->ViewClosed(); | 382 controller_->ViewClosed(); |
394 | 383 |
395 base::Callback<void(const FormStructure*, const std::string&)> callback = | 384 base::Callback<void(const FormStructure*, const std::string&)> callback = |
396 base::Bind(&AutofillDialogControllerTest::FinishedCallback, | 385 base::Bind(&AutofillDialogControllerTest::FinishedCallback, |
397 base::Unretained(this)); | 386 base::Unretained(this)); |
398 controller_ = (new testing::NiceMock<TestAutofillDialogController>( | 387 controller_ = (new testing::NiceMock<TestAutofillDialogController>( |
399 web_contents(), | 388 web_contents(), |
400 form_data, | 389 form_data, |
401 GURL(), | 390 GURL(), |
402 metric_logger_, | 391 metric_logger_, |
403 DIALOG_TYPE_REQUEST_AUTOCOMPLETE, | |
404 callback, | 392 callback, |
405 mock_new_card_bubble_controller_.get()))->AsWeakPtr(); | 393 mock_new_card_bubble_controller_.get()))->AsWeakPtr(); |
406 controller_->Init(profile()); | 394 controller_->Init(profile()); |
407 controller_->Show(); | 395 controller_->Show(); |
408 controller_->OnUserNameFetchSuccess(kFakeEmail); | 396 controller_->OnUserNameFetchSuccess(kFakeEmail); |
409 } | 397 } |
410 | 398 |
411 void FillCreditCardInputs() { | 399 void FillCreditCardInputs() { |
412 DetailOutputMap cc_outputs; | 400 DetailOutputMap cc_outputs; |
413 const DetailInputs& cc_inputs = | 401 const DetailInputs& cc_inputs = |
(...skipping 1937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2351 controller()->TabActivated(); | 2339 controller()->TabActivated(); |
2352 | 2340 |
2353 controller()->OnDidGetWalletItems(wallet::GetTestWalletItems()); | 2341 controller()->OnDidGetWalletItems(wallet::GetTestWalletItems()); |
2354 | 2342 |
2355 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_CC_BILLING)); | 2343 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_CC_BILLING)); |
2356 EXPECT_EQ( | 2344 EXPECT_EQ( |
2357 3, controller()->MenuModelForSection(SECTION_SHIPPING)->GetItemCount()); | 2345 3, controller()->MenuModelForSection(SECTION_SHIPPING)->GetItemCount()); |
2358 } | 2346 } |
2359 | 2347 |
2360 } // namespace autofill | 2348 } // namespace autofill |
OLD | NEW |