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/command_line.h" | 6 #include "base/command_line.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/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 | 40 |
41 namespace autofill { | 41 namespace autofill { |
42 | 42 |
43 namespace { | 43 namespace { |
44 | 44 |
45 void MockCallback(const FormStructure*, const std::string&) {} | 45 void MockCallback(const FormStructure*, const std::string&) {} |
46 | 46 |
47 class MockAutofillMetrics : public AutofillMetrics { | 47 class MockAutofillMetrics : public AutofillMetrics { |
48 public: | 48 public: |
49 MockAutofillMetrics() | 49 MockAutofillMetrics() |
50 : dialog_type_(static_cast<DialogType>(-1)), | 50 : dialog_dismissal_action_( |
51 dialog_dismissal_action_( | |
52 static_cast<AutofillMetrics::DialogDismissalAction>(-1)) {} | 51 static_cast<AutofillMetrics::DialogDismissalAction>(-1)) {} |
53 virtual ~MockAutofillMetrics() {} | 52 virtual ~MockAutofillMetrics() {} |
54 | 53 |
55 virtual void LogDialogUiDuration( | 54 virtual void LogDialogUiDuration( |
56 const base::TimeDelta& duration, | 55 const base::TimeDelta& duration, |
57 DialogType dialog_type, | |
58 DialogDismissalAction dismissal_action) const OVERRIDE { | 56 DialogDismissalAction dismissal_action) const OVERRIDE { |
59 // Ignore constness for testing. | 57 // Ignore constness for testing. |
60 MockAutofillMetrics* mutable_this = const_cast<MockAutofillMetrics*>(this); | 58 MockAutofillMetrics* mutable_this = const_cast<MockAutofillMetrics*>(this); |
61 mutable_this->dialog_type_ = dialog_type; | |
62 mutable_this->dialog_dismissal_action_ = dismissal_action; | 59 mutable_this->dialog_dismissal_action_ = dismissal_action; |
63 } | 60 } |
64 | 61 |
65 DialogType dialog_type() const { return dialog_type_; } | |
66 AutofillMetrics::DialogDismissalAction dialog_dismissal_action() const { | 62 AutofillMetrics::DialogDismissalAction dialog_dismissal_action() const { |
67 return dialog_dismissal_action_; | 63 return dialog_dismissal_action_; |
68 } | 64 } |
69 | 65 |
70 MOCK_CONST_METHOD2(LogDialogDismissalState, | 66 MOCK_CONST_METHOD1(LogDialogDismissalState, |
71 void(DialogType dialog_type, DialogDismissalState state)); | 67 void(DialogDismissalState state)); |
72 | 68 |
73 private: | 69 private: |
74 DialogType dialog_type_; | |
75 AutofillMetrics::DialogDismissalAction dialog_dismissal_action_; | 70 AutofillMetrics::DialogDismissalAction dialog_dismissal_action_; |
76 | 71 |
77 DISALLOW_COPY_AND_ASSIGN(MockAutofillMetrics); | 72 DISALLOW_COPY_AND_ASSIGN(MockAutofillMetrics); |
78 }; | 73 }; |
79 | 74 |
80 class TestAutofillDialogController : public AutofillDialogControllerImpl { | 75 class TestAutofillDialogController : public AutofillDialogControllerImpl { |
81 public: | 76 public: |
82 TestAutofillDialogController(content::WebContents* contents, | 77 TestAutofillDialogController(content::WebContents* contents, |
83 const FormData& form_data, | 78 const FormData& form_data, |
84 const AutofillMetrics& metric_logger, | 79 const AutofillMetrics& metric_logger, |
85 scoped_refptr<content::MessageLoopRunner> runner, | 80 scoped_refptr<content::MessageLoopRunner> runner) |
86 const DialogType dialog_type) | |
87 : AutofillDialogControllerImpl(contents, | 81 : AutofillDialogControllerImpl(contents, |
88 form_data, | 82 form_data, |
89 GURL(), | 83 GURL(), |
90 dialog_type, | |
91 base::Bind(&MockCallback)), | 84 base::Bind(&MockCallback)), |
92 metric_logger_(metric_logger), | 85 metric_logger_(metric_logger), |
93 mock_wallet_client_( | 86 mock_wallet_client_( |
94 Profile::FromBrowserContext(contents->GetBrowserContext())-> | 87 Profile::FromBrowserContext(contents->GetBrowserContext())-> |
95 GetRequestContext(), this), | 88 GetRequestContext(), this), |
96 message_loop_runner_(runner), | 89 message_loop_runner_(runner), |
97 use_validation_(false), | 90 use_validation_(false), |
98 weak_ptr_factory_(this) {} | 91 weak_ptr_factory_(this) {} |
99 | 92 |
100 virtual ~TestAutofillDialogController() {} | 93 virtual ~TestAutofillDialogController() {} |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 | 183 |
191 } // namespace | 184 } // namespace |
192 | 185 |
193 class AutofillDialogControllerTest : public InProcessBrowserTest { | 186 class AutofillDialogControllerTest : public InProcessBrowserTest { |
194 public: | 187 public: |
195 AutofillDialogControllerTest() {} | 188 AutofillDialogControllerTest() {} |
196 virtual ~AutofillDialogControllerTest() {} | 189 virtual ~AutofillDialogControllerTest() {} |
197 | 190 |
198 virtual void SetUpOnMainThread() OVERRIDE { | 191 virtual void SetUpOnMainThread() OVERRIDE { |
199 autofill::test::DisableSystemServices(browser()->profile()); | 192 autofill::test::DisableSystemServices(browser()->profile()); |
| 193 InitializeController(); |
200 } | 194 } |
201 | 195 |
202 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 196 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
203 #if defined(OS_MACOSX) | 197 #if defined(OS_MACOSX) |
204 // OSX support for requestAutocomplete is still hidden behind a switch. | 198 // OSX support for requestAutocomplete is still hidden behind a switch. |
205 // Pending resolution of http://crbug.com/157274 | 199 // Pending resolution of http://crbug.com/157274 |
206 CommandLine::ForCurrentProcess()->AppendSwitch( | 200 CommandLine::ForCurrentProcess()->AppendSwitch( |
207 switches::kEnableInteractiveAutocomplete); | 201 switches::kEnableInteractiveAutocomplete); |
208 #endif | 202 #endif |
209 } | 203 } |
210 | 204 |
211 void InitializeControllerOfType(DialogType dialog_type) { | 205 void InitializeController() { |
212 FormData form; | 206 FormData form; |
213 form.name = ASCIIToUTF16("TestForm"); | 207 form.name = ASCIIToUTF16("TestForm"); |
214 form.method = ASCIIToUTF16("POST"); | 208 form.method = ASCIIToUTF16("POST"); |
215 form.origin = GURL("http://example.com/form.html"); | 209 form.origin = GURL("http://example.com/form.html"); |
216 form.action = GURL("http://example.com/submit.html"); | 210 form.action = GURL("http://example.com/submit.html"); |
217 form.user_submitted = true; | 211 form.user_submitted = true; |
218 | 212 |
219 FormFieldData field; | 213 FormFieldData field; |
220 field.autocomplete_attribute = "shipping tel"; | 214 field.autocomplete_attribute = "shipping tel"; |
221 form.fields.push_back(field); | 215 form.fields.push_back(field); |
222 | 216 |
223 message_loop_runner_ = new content::MessageLoopRunner; | 217 message_loop_runner_ = new content::MessageLoopRunner; |
224 controller_ = new TestAutofillDialogController( | 218 controller_ = new TestAutofillDialogController( |
225 GetActiveWebContents(), | 219 GetActiveWebContents(), |
226 form, | 220 form, |
227 metric_logger_, | 221 metric_logger_, |
228 message_loop_runner_, | 222 message_loop_runner_); |
229 dialog_type); | |
230 controller_->Show(); | 223 controller_->Show(); |
231 } | 224 } |
232 | 225 |
233 content::WebContents* GetActiveWebContents() { | 226 content::WebContents* GetActiveWebContents() { |
234 return browser()->tab_strip_model()->GetActiveWebContents(); | 227 return browser()->tab_strip_model()->GetActiveWebContents(); |
235 } | 228 } |
236 | 229 |
237 const MockAutofillMetrics& metric_logger() { return metric_logger_; } | 230 const MockAutofillMetrics& metric_logger() { return metric_logger_; } |
238 TestAutofillDialogController* controller() { return controller_; } | 231 TestAutofillDialogController* controller() { return controller_; } |
239 | 232 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 MockAutofillMetrics metric_logger_; | 313 MockAutofillMetrics metric_logger_; |
321 TestAutofillDialogController* controller_; // Weak reference. | 314 TestAutofillDialogController* controller_; // Weak reference. |
322 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; | 315 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; |
323 scoped_ptr<content::DOMMessageQueue> dom_message_queue_; | 316 scoped_ptr<content::DOMMessageQueue> dom_message_queue_; |
324 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerTest); | 317 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerTest); |
325 }; | 318 }; |
326 | 319 |
327 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) | 320 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) |
328 // Submit the form data. | 321 // Submit the form data. |
329 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Submit) { | 322 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Submit) { |
330 InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE); | |
331 controller()->GetTestableView()->SubmitForTesting(); | 323 controller()->GetTestableView()->SubmitForTesting(); |
332 | 324 |
333 RunMessageLoop(); | 325 RunMessageLoop(); |
334 | 326 |
335 EXPECT_EQ(AutofillMetrics::DIALOG_ACCEPTED, | 327 EXPECT_EQ(AutofillMetrics::DIALOG_ACCEPTED, |
336 metric_logger().dialog_dismissal_action()); | 328 metric_logger().dialog_dismissal_action()); |
337 EXPECT_EQ(DIALOG_TYPE_REQUEST_AUTOCOMPLETE, metric_logger().dialog_type()); | |
338 } | 329 } |
339 | 330 |
340 // Cancel out of the dialog. | 331 // Cancel out of the dialog. |
341 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Cancel) { | 332 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Cancel) { |
342 InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE); | |
343 controller()->GetTestableView()->CancelForTesting(); | 333 controller()->GetTestableView()->CancelForTesting(); |
344 | 334 |
345 RunMessageLoop(); | 335 RunMessageLoop(); |
346 | 336 |
347 EXPECT_EQ(AutofillMetrics::DIALOG_CANCELED, | 337 EXPECT_EQ(AutofillMetrics::DIALOG_CANCELED, |
348 metric_logger().dialog_dismissal_action()); | 338 metric_logger().dialog_dismissal_action()); |
349 EXPECT_EQ(DIALOG_TYPE_REQUEST_AUTOCOMPLETE, metric_logger().dialog_type()); | |
350 } | 339 } |
351 | 340 |
352 // Take some other action that dismisses the dialog. | 341 // Take some other action that dismisses the dialog. |
353 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Hide) { | 342 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Hide) { |
354 InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE); | |
355 controller()->Hide(); | 343 controller()->Hide(); |
356 | 344 |
357 RunMessageLoop(); | 345 RunMessageLoop(); |
358 | 346 |
359 EXPECT_EQ(AutofillMetrics::DIALOG_CANCELED, | 347 EXPECT_EQ(AutofillMetrics::DIALOG_CANCELED, |
360 metric_logger().dialog_dismissal_action()); | 348 metric_logger().dialog_dismissal_action()); |
361 EXPECT_EQ(DIALOG_TYPE_REQUEST_AUTOCOMPLETE, metric_logger().dialog_type()); | |
362 } | 349 } |
363 | 350 |
364 // Ensure that Hide() will only destroy the controller object after the | 351 // Ensure that Hide() will only destroy the controller object after the |
365 // message loop has run. Otherwise, there may be read-after-free issues | 352 // message loop has run. Otherwise, there may be read-after-free issues |
366 // during some tests. | 353 // during some tests. |
367 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, DeferredDestruction) { | 354 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, DeferredDestruction) { |
368 InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE); | |
369 | |
370 base::WeakPtr<TestAutofillDialogController> weak_ptr = | 355 base::WeakPtr<TestAutofillDialogController> weak_ptr = |
371 controller()->AsWeakPtr(); | 356 controller()->AsWeakPtr(); |
372 EXPECT_TRUE(weak_ptr.get()); | 357 EXPECT_TRUE(weak_ptr.get()); |
373 | 358 |
374 controller()->Hide(); | 359 controller()->Hide(); |
375 EXPECT_TRUE(weak_ptr.get()); | 360 EXPECT_TRUE(weak_ptr.get()); |
376 | 361 |
377 RunMessageLoop(); | 362 RunMessageLoop(); |
378 EXPECT_FALSE(weak_ptr.get()); | 363 EXPECT_FALSE(weak_ptr.get()); |
379 } | 364 } |
380 | 365 |
381 // Ensure that the expected metric is logged when the dialog is closed during | 366 // Ensure that the expected metric is logged when the dialog is closed during |
382 // signin. | 367 // signin. |
383 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, CloseDuringSignin) { | 368 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, CloseDuringSignin) { |
384 InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE); | |
385 controller()->SignInLinkClicked(); | 369 controller()->SignInLinkClicked(); |
386 | 370 |
387 EXPECT_CALL(metric_logger(), | 371 EXPECT_CALL(metric_logger(), |
388 LogDialogDismissalState( | 372 LogDialogDismissalState( |
389 DIALOG_TYPE_REQUEST_AUTOCOMPLETE, | |
390 AutofillMetrics::DIALOG_CANCELED_DURING_SIGNIN)); | 373 AutofillMetrics::DIALOG_CANCELED_DURING_SIGNIN)); |
391 controller()->GetTestableView()->CancelForTesting(); | 374 controller()->GetTestableView()->CancelForTesting(); |
392 | 375 |
393 RunMessageLoop(); | 376 RunMessageLoop(); |
394 | 377 |
395 EXPECT_EQ(AutofillMetrics::DIALOG_CANCELED, | 378 EXPECT_EQ(AutofillMetrics::DIALOG_CANCELED, |
396 metric_logger().dialog_dismissal_action()); | 379 metric_logger().dialog_dismissal_action()); |
397 EXPECT_EQ(DIALOG_TYPE_REQUEST_AUTOCOMPLETE, metric_logger().dialog_type()); | |
398 } | 380 } |
399 | 381 |
400 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, FillInputFromAutofill) { | 382 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, FillInputFromAutofill) { |
401 InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE); | |
402 | |
403 AutofillProfile full_profile(test::GetFullProfile()); | 383 AutofillProfile full_profile(test::GetFullProfile()); |
404 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 384 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
405 | 385 |
406 const DetailInputs& inputs = | 386 const DetailInputs& inputs = |
407 controller()->RequestedFieldsForSection(SECTION_SHIPPING); | 387 controller()->RequestedFieldsForSection(SECTION_SHIPPING); |
408 const DetailInput& triggering_input = inputs[0]; | 388 const DetailInput& triggering_input = inputs[0]; |
409 string16 value = full_profile.GetRawInfo(triggering_input.type); | 389 string16 value = full_profile.GetRawInfo(triggering_input.type); |
410 TestableAutofillDialogView* view = controller()->GetTestableView(); | 390 TestableAutofillDialogView* view = controller()->GetTestableView(); |
411 view->SetTextContentsOfInput(triggering_input, | 391 view->SetTextContentsOfInput(triggering_input, |
412 value.substr(0, value.size() / 2)); | 392 value.substr(0, value.size() / 2)); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 // Flaky on Win7, WinXP, and Win Aura. http://crbug.com/270314. | 432 // Flaky on Win7, WinXP, and Win Aura. http://crbug.com/270314. |
453 // TODO(groby): Enable this test on mac once AutofillDialogCocoa handles | 433 // TODO(groby): Enable this test on mac once AutofillDialogCocoa handles |
454 // comboboxes for GetTextContentsForInput. http://crbug.com/270205 | 434 // comboboxes for GetTextContentsForInput. http://crbug.com/270205 |
455 #if defined(OS_MACOSX) || defined(OS_WIN) | 435 #if defined(OS_MACOSX) || defined(OS_WIN) |
456 #define MAYBE_FillComboboxFromAutofill DISABLED_FillComboboxFromAutofill | 436 #define MAYBE_FillComboboxFromAutofill DISABLED_FillComboboxFromAutofill |
457 #else | 437 #else |
458 #define MAYBE_FillComboboxFromAutofill FillComboboxFromAutofill | 438 #define MAYBE_FillComboboxFromAutofill FillComboboxFromAutofill |
459 #endif | 439 #endif |
460 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, | 440 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, |
461 MAYBE_FillComboboxFromAutofill) { | 441 MAYBE_FillComboboxFromAutofill) { |
462 InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE); | |
463 | |
464 CreditCard card1; | 442 CreditCard card1; |
465 test::SetCreditCardInfo(&card1, "JJ Smith", "4111111111111111", "12", "2018"); | 443 test::SetCreditCardInfo(&card1, "JJ Smith", "4111111111111111", "12", "2018"); |
466 controller()->GetTestingManager()->AddTestingCreditCard(&card1); | 444 controller()->GetTestingManager()->AddTestingCreditCard(&card1); |
467 CreditCard card2; | 445 CreditCard card2; |
468 test::SetCreditCardInfo(&card2, "B Bird", "3111111111111111", "11", "2017"); | 446 test::SetCreditCardInfo(&card2, "B Bird", "3111111111111111", "11", "2017"); |
469 controller()->GetTestingManager()->AddTestingCreditCard(&card2); | 447 controller()->GetTestingManager()->AddTestingCreditCard(&card2); |
470 AutofillProfile full_profile(test::GetFullProfile()); | 448 AutofillProfile full_profile(test::GetFullProfile()); |
471 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 449 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
472 | 450 |
473 const DetailInputs& inputs = | 451 const DetailInputs& inputs = |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 EXPECT_TRUE(view->GetTextContentsOfInput(input).empty()); | 515 EXPECT_TRUE(view->GetTextContentsOfInput(input).empty()); |
538 } else { | 516 } else { |
539 EXPECT_EQ(wrapper1.GetInfo(AutofillType(input.type)), | 517 EXPECT_EQ(wrapper1.GetInfo(AutofillType(input.type)), |
540 view->GetTextContentsOfInput(input)); | 518 view->GetTextContentsOfInput(input)); |
541 } | 519 } |
542 } | 520 } |
543 } | 521 } |
544 | 522 |
545 // Tests that credit card number is disabled while editing a Wallet instrument. | 523 // Tests that credit card number is disabled while editing a Wallet instrument. |
546 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, WalletCreditCardDisabled) { | 524 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, WalletCreditCardDisabled) { |
547 InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE); | |
548 controller()->OnUserNameFetchSuccess("user@example.com"); | 525 controller()->OnUserNameFetchSuccess("user@example.com"); |
549 | 526 |
550 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); | 527 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); |
551 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); | 528 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); |
552 controller()->OnDidGetWalletItems(wallet_items.Pass()); | 529 controller()->OnDidGetWalletItems(wallet_items.Pass()); |
553 | 530 |
554 // Click "Edit" in the billing section (while using Wallet). | 531 // Click "Edit" in the billing section (while using Wallet). |
555 controller()->EditClickedForSection(SECTION_CC_BILLING); | 532 controller()->EditClickedForSection(SECTION_CC_BILLING); |
556 | 533 |
557 const DetailInputs& edit_inputs = | 534 const DetailInputs& edit_inputs = |
(...skipping 17 matching lines...) Expand all Loading... |
575 if (add_inputs[i].type == CREDIT_CARD_NUMBER) { | 552 if (add_inputs[i].type == CREDIT_CARD_NUMBER) { |
576 EXPECT_TRUE(add_inputs[i].editable); | 553 EXPECT_TRUE(add_inputs[i].editable); |
577 break; | 554 break; |
578 } | 555 } |
579 } | 556 } |
580 ASSERT_LT(i, add_inputs.size()); | 557 ASSERT_LT(i, add_inputs.size()); |
581 } | 558 } |
582 | 559 |
583 // Ensure that expired cards trigger invalid suggestions. | 560 // Ensure that expired cards trigger invalid suggestions. |
584 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, ExpiredCard) { | 561 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, ExpiredCard) { |
585 InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE); | |
586 | |
587 CreditCard verified_card(test::GetCreditCard()); | 562 CreditCard verified_card(test::GetCreditCard()); |
588 verified_card.set_origin("Chrome settings"); | 563 verified_card.set_origin("Chrome settings"); |
589 ASSERT_TRUE(verified_card.IsVerified()); | 564 ASSERT_TRUE(verified_card.IsVerified()); |
590 controller()->GetTestingManager()->AddTestingCreditCard(&verified_card); | 565 controller()->GetTestingManager()->AddTestingCreditCard(&verified_card); |
591 | 566 |
592 CreditCard expired_card(test::GetCreditCard()); | 567 CreditCard expired_card(test::GetCreditCard()); |
593 expired_card.set_origin("Chrome settings"); | 568 expired_card.set_origin("Chrome settings"); |
594 expired_card.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2007")); | 569 expired_card.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2007")); |
595 ASSERT_TRUE(expired_card.IsVerified()); | 570 ASSERT_TRUE(expired_card.IsVerified()); |
596 ASSERT_FALSE( | 571 ASSERT_FALSE( |
597 autofill::IsValidCreditCardExpirationDate( | 572 autofill::IsValidCreditCardExpirationDate( |
598 expired_card.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR), | 573 expired_card.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR), |
599 expired_card.GetRawInfo(CREDIT_CARD_EXP_MONTH), | 574 expired_card.GetRawInfo(CREDIT_CARD_EXP_MONTH), |
600 base::Time::Now())); | 575 base::Time::Now())); |
601 controller()->GetTestingManager()->AddTestingCreditCard(&expired_card); | 576 controller()->GetTestingManager()->AddTestingCreditCard(&expired_card); |
602 | 577 |
603 ui::MenuModel* model = controller()->MenuModelForSection(SECTION_CC); | 578 ui::MenuModel* model = controller()->MenuModelForSection(SECTION_CC); |
604 ASSERT_EQ(4, model->GetItemCount()); | 579 ASSERT_EQ(4, model->GetItemCount()); |
605 | 580 |
606 ASSERT_TRUE(model->IsItemCheckedAt(0)); | 581 ASSERT_TRUE(model->IsItemCheckedAt(0)); |
607 EXPECT_FALSE(controller()->IsEditingExistingData(SECTION_CC)); | 582 EXPECT_FALSE(controller()->IsEditingExistingData(SECTION_CC)); |
608 | 583 |
609 model->ActivatedAt(1); | 584 model->ActivatedAt(1); |
610 ASSERT_TRUE(model->IsItemCheckedAt(1)); | 585 ASSERT_TRUE(model->IsItemCheckedAt(1)); |
611 EXPECT_TRUE(controller()->IsEditingExistingData(SECTION_CC)); | 586 EXPECT_TRUE(controller()->IsEditingExistingData(SECTION_CC)); |
612 } | 587 } |
613 | 588 |
614 // Notifications with long message text should not make the dialog bigger. | 589 // Notifications with long message text should not make the dialog bigger. |
615 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, LongNotifications) { | 590 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, LongNotifications) { |
616 InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE); | |
617 | |
618 const gfx::Size no_notification_size = | 591 const gfx::Size no_notification_size = |
619 controller()->GetTestableView()->GetSize(); | 592 controller()->GetTestableView()->GetSize(); |
620 ASSERT_GT(no_notification_size.width(), 0); | 593 ASSERT_GT(no_notification_size.width(), 0); |
621 | 594 |
622 std::vector<DialogNotification> notifications; | 595 std::vector<DialogNotification> notifications; |
623 notifications.push_back( | 596 notifications.push_back( |
624 DialogNotification(DialogNotification::DEVELOPER_WARNING, ASCIIToUTF16( | 597 DialogNotification(DialogNotification::DEVELOPER_WARNING, ASCIIToUTF16( |
625 "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do " | 598 "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do " |
626 "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim " | 599 "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim " |
627 "ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut " | 600 "ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut " |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 } | 643 } |
671 | 644 |
672 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, | 645 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, |
673 AutocompleteErrorEventReasonCancel) { | 646 AutocompleteErrorEventReasonCancel) { |
674 SetUpHtmlAndInvoke("<input autocomplete='cc-name'>")->GetTestableView()-> | 647 SetUpHtmlAndInvoke("<input autocomplete='cc-name'>")->GetTestableView()-> |
675 CancelForTesting(); | 648 CancelForTesting(); |
676 ExpectDomMessage("error: cancel"); | 649 ExpectDomMessage("error: cancel"); |
677 } | 650 } |
678 | 651 |
679 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, NoCvcSegfault) { | 652 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, NoCvcSegfault) { |
680 InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE); | |
681 controller()->set_use_validation(true); | 653 controller()->set_use_validation(true); |
682 | 654 |
683 CreditCard credit_card(test::GetVerifiedCreditCard()); | 655 CreditCard credit_card(test::GetVerifiedCreditCard()); |
684 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card); | 656 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card); |
685 EXPECT_FALSE(controller()->IsEditingExistingData(SECTION_CC)); | 657 EXPECT_FALSE(controller()->IsEditingExistingData(SECTION_CC)); |
686 | 658 |
687 ASSERT_NO_FATAL_FAILURE( | 659 ASSERT_NO_FATAL_FAILURE( |
688 controller()->GetTestableView()->SubmitForTesting()); | 660 controller()->GetTestableView()->SubmitForTesting()); |
689 } | 661 } |
690 | 662 |
691 // Flaky on Win7, WinXP, and Win Aura. http://crbug.com/270314. | 663 // Flaky on Win7, WinXP, and Win Aura. http://crbug.com/270314. |
692 #if defined(OS_WIN) | 664 #if defined(OS_WIN) |
693 #define MAYBE_PreservedSections DISABLED_PreservedSections | 665 #define MAYBE_PreservedSections DISABLED_PreservedSections |
694 #else | 666 #else |
695 #define MAYBE_PreservedSections PreservedSections | 667 #define MAYBE_PreservedSections PreservedSections |
696 #endif | 668 #endif |
697 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, MAYBE_PreservedSections) { | 669 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, MAYBE_PreservedSections) { |
698 InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE); | |
699 controller()->set_use_validation(true); | 670 controller()->set_use_validation(true); |
700 | 671 |
701 // Set up some Autofill state. | 672 // Set up some Autofill state. |
702 CreditCard credit_card(test::GetVerifiedCreditCard()); | 673 CreditCard credit_card(test::GetVerifiedCreditCard()); |
703 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card); | 674 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card); |
704 | 675 |
705 AutofillProfile profile(test::GetVerifiedProfile()); | 676 AutofillProfile profile(test::GetVerifiedProfile()); |
706 controller()->GetTestingManager()->AddTestingProfile(&profile); | 677 controller()->GetTestingManager()->AddTestingProfile(&profile); |
707 | 678 |
708 EXPECT_TRUE(controller()->SectionIsActive(SECTION_CC)); | 679 EXPECT_TRUE(controller()->SectionIsActive(SECTION_CC)); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 EXPECT_EQ(cc_number.type, new_cc_number.type); | 740 EXPECT_EQ(cc_number.type, new_cc_number.type); |
770 EXPECT_EQ(ASCIIToUTF16("4111111111111111"), | 741 EXPECT_EQ(ASCIIToUTF16("4111111111111111"), |
771 view->GetTextContentsOfInput(new_cc_number)); | 742 view->GetTextContentsOfInput(new_cc_number)); |
772 | 743 |
773 EXPECT_NE(ASCIIToUTF16("shipping name"), | 744 EXPECT_NE(ASCIIToUTF16("shipping name"), |
774 view->GetTextContentsOfInput(shipping_zip)); | 745 view->GetTextContentsOfInput(shipping_zip)); |
775 } | 746 } |
776 #endif // defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) | 747 #endif // defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) |
777 | 748 |
778 } // namespace autofill | 749 } // namespace autofill |
OLD | NEW |