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/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 14 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/ui/autofill/account_chooser_model.h" | 16 #include "chrome/browser/ui/autofill/account_chooser_model.h" |
17 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" | 17 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" |
| 18 #include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h" |
18 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" | 19 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" |
19 #include "chrome/browser/ui/autofill/data_model_wrapper.h" | 20 #include "chrome/browser/ui/autofill/data_model_wrapper.h" |
20 #include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" | 21 #include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" |
21 #include "chrome/browser/ui/autofill/test_generated_credit_card_bubble_controlle
r.h" | 22 #include "chrome/browser/ui/autofill/test_generated_credit_card_bubble_controlle
r.h" |
22 #include "chrome/browser/ui/autofill/testable_autofill_dialog_view.h" | 23 #include "chrome/browser/ui/autofill/testable_autofill_dialog_view.h" |
23 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
24 #include "chrome/browser/ui/browser_tabstrip.h" | 25 #include "chrome/browser/ui/browser_tabstrip.h" |
25 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 26 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 27 #include "chrome/common/chrome_switches.h" |
26 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
27 #include "chrome/common/url_constants.h" | 29 #include "chrome/common/url_constants.h" |
28 #include "chrome/test/base/in_process_browser_test.h" | 30 #include "chrome/test/base/in_process_browser_test.h" |
29 #include "chrome/test/base/ui_test_utils.h" | 31 #include "chrome/test/base/ui_test_utils.h" |
30 #include "components/autofill/content/browser/risk/proto/fingerprint.pb.h" | 32 #include "components/autofill/content/browser/risk/proto/fingerprint.pb.h" |
31 #include "components/autofill/content/browser/wallet/mock_wallet_client.h" | 33 #include "components/autofill/content/browser/wallet/mock_wallet_client.h" |
32 #include "components/autofill/content/browser/wallet/wallet_service_url.h" | 34 #include "components/autofill/content/browser/wallet/wallet_service_url.h" |
33 #include "components/autofill/content/browser/wallet/wallet_test_util.h" | 35 #include "components/autofill/content/browser/wallet/wallet_test_util.h" |
34 #include "components/autofill/core/browser/autofill_metrics.h" | 36 #include "components/autofill/core/browser/autofill_metrics.h" |
35 #include "components/autofill/core/browser/autofill_test_utils.h" | 37 #include "components/autofill/core/browser/autofill_test_utils.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 180 |
179 void set_notifications(const std::vector<DialogNotification>& notifications) { | 181 void set_notifications(const std::vector<DialogNotification>& notifications) { |
180 notifications_ = notifications; | 182 notifications_ = notifications; |
181 } | 183 } |
182 | 184 |
183 TestPersonalDataManager* GetTestingManager() { | 185 TestPersonalDataManager* GetTestingManager() { |
184 return &test_manager_; | 186 return &test_manager_; |
185 } | 187 } |
186 | 188 |
187 using AutofillDialogControllerImpl::IsEditingExistingData; | 189 using AutofillDialogControllerImpl::IsEditingExistingData; |
| 190 using AutofillDialogControllerImpl::IsManuallyEditingSection; |
188 using AutofillDialogControllerImpl::IsPayingWithWallet; | 191 using AutofillDialogControllerImpl::IsPayingWithWallet; |
189 using AutofillDialogControllerImpl::IsSubmitPausedOn; | 192 using AutofillDialogControllerImpl::IsSubmitPausedOn; |
190 using AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData; | 193 using AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData; |
191 using AutofillDialogControllerImpl::AccountChooserModelForTesting; | 194 using AutofillDialogControllerImpl::AccountChooserModelForTesting; |
192 using AutofillDialogControllerImpl:: | 195 using AutofillDialogControllerImpl:: |
193 ClearLastWalletItemsFetchTimestampForTesting; | 196 ClearLastWalletItemsFetchTimestampForTesting; |
194 | 197 |
195 void set_use_validation(bool use_validation) { | 198 void set_use_validation(bool use_validation) { |
196 use_validation_ = use_validation; | 199 use_validation_ = use_validation; |
197 } | 200 } |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 RunMessageLoop(); | 552 RunMessageLoop(); |
550 | 553 |
551 EXPECT_EQ(AutofillMetrics::DIALOG_CANCELED, | 554 EXPECT_EQ(AutofillMetrics::DIALOG_CANCELED, |
552 metric_logger().dialog_dismissal_action()); | 555 metric_logger().dialog_dismissal_action()); |
553 } | 556 } |
554 | 557 |
555 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, FillInputFromAutofill) { | 558 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, FillInputFromAutofill) { |
556 AutofillProfile full_profile(test::GetFullProfile()); | 559 AutofillProfile full_profile(test::GetFullProfile()); |
557 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 560 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
558 | 561 |
| 562 // Select "Add new shipping address...". |
| 563 ui::MenuModel* model = controller()->MenuModelForSection(SECTION_SHIPPING); |
| 564 model->ActivatedAt(model->GetItemCount() - 2); |
| 565 ASSERT_TRUE(controller()->IsManuallyEditingSection(SECTION_SHIPPING)); |
| 566 |
559 const DetailInputs& inputs = | 567 const DetailInputs& inputs = |
560 controller()->RequestedFieldsForSection(SECTION_SHIPPING); | 568 controller()->RequestedFieldsForSection(SECTION_SHIPPING); |
561 const ServerFieldType triggering_type = inputs[0].type; | 569 const ServerFieldType triggering_type = inputs[0].type; |
562 base::string16 value = full_profile.GetRawInfo(triggering_type); | 570 base::string16 value = full_profile.GetRawInfo(triggering_type); |
563 TestableAutofillDialogView* view = controller()->GetTestableView(); | 571 TestableAutofillDialogView* view = controller()->GetTestableView(); |
564 view->SetTextContentsOfInput(triggering_type, | 572 view->SetTextContentsOfInput(triggering_type, |
565 value.substr(0, value.size() / 2)); | 573 value.substr(0, value.size() / 2)); |
566 view->ActivateInput(triggering_type); | 574 view->ActivateInput(triggering_type); |
567 | 575 |
568 ASSERT_EQ(triggering_type, controller()->popup_input_type()); | 576 ASSERT_EQ(triggering_type, controller()->popup_input_type()); |
569 controller()->DidAcceptSuggestion(base::string16(), 0); | 577 controller()->DidAcceptSuggestion(base::string16(), 0); |
570 | 578 |
571 // All inputs should be filled. | 579 // All inputs should be filled. |
572 AutofillProfileWrapper wrapper(&full_profile); | 580 AutofillProfileWrapper wrapper(&full_profile); |
573 for (size_t i = 0; i < inputs.size(); ++i) { | 581 for (size_t i = 0; i < inputs.size(); ++i) { |
574 EXPECT_EQ(wrapper.GetInfo(AutofillType(inputs[i].type)), | 582 EXPECT_EQ(wrapper.GetInfo(AutofillType(inputs[i].type)), |
575 view->GetTextContentsOfInput(inputs[i].type)); | 583 view->GetTextContentsOfInput(inputs[i].type)); |
576 } | 584 } |
577 | 585 |
578 // Now simulate some user edits and try again. | 586 // Now simulate some user edits and try again. |
579 std::vector<base::string16> expectations; | 587 std::vector<base::string16> expectations; |
580 for (size_t i = 0; i < inputs.size(); ++i) { | 588 for (size_t i = 0; i < inputs.size(); ++i) { |
| 589 if (controller()->ComboboxModelForAutofillType(inputs[i].type)) { |
| 590 expectations.push_back(base::string16()); |
| 591 continue; |
| 592 } |
581 base::string16 users_input = i % 2 == 0 ? base::string16() | 593 base::string16 users_input = i % 2 == 0 ? base::string16() |
582 : ASCIIToUTF16("dummy"); | 594 : ASCIIToUTF16("dummy"); |
583 view->SetTextContentsOfInput(inputs[i].type, users_input); | 595 view->SetTextContentsOfInput(inputs[i].type, users_input); |
584 // Empty inputs should be filled, others should be left alone. | 596 // Empty inputs should be filled, others should be left alone. |
585 base::string16 expectation = | 597 base::string16 expectation = |
586 inputs[i].type == triggering_type || users_input.empty() ? | 598 inputs[i].type == triggering_type || users_input.empty() ? |
587 wrapper.GetInfo(AutofillType(inputs[i].type)) : | 599 wrapper.GetInfo(AutofillType(inputs[i].type)) : |
588 users_input; | 600 users_input; |
589 expectations.push_back(expectation); | 601 expectations.push_back(expectation); |
590 } | 602 } |
591 | 603 |
592 view->SetTextContentsOfInput(triggering_type, | 604 view->SetTextContentsOfInput(triggering_type, |
593 value.substr(0, value.size() / 2)); | 605 value.substr(0, value.size() / 2)); |
594 view->ActivateInput(triggering_type); | 606 view->ActivateInput(triggering_type); |
595 ASSERT_EQ(triggering_type, controller()->popup_input_type()); | 607 ASSERT_EQ(triggering_type, controller()->popup_input_type()); |
596 controller()->DidAcceptSuggestion(base::string16(), 0); | 608 controller()->DidAcceptSuggestion(base::string16(), 0); |
597 | 609 |
598 for (size_t i = 0; i < inputs.size(); ++i) { | 610 for (size_t i = 0; i < inputs.size(); ++i) { |
| 611 if (controller()->ComboboxModelForAutofillType(inputs[i].type)) |
| 612 continue; |
599 EXPECT_EQ(expectations[i], view->GetTextContentsOfInput(inputs[i].type)); | 613 EXPECT_EQ(expectations[i], view->GetTextContentsOfInput(inputs[i].type)); |
600 } | 614 } |
601 } | 615 } |
602 | 616 |
603 // For now, no matter what, the country must always be US. See | 617 // For now, no matter what, the country must always be US. See |
604 // http://crbug.com/247518 | 618 // http://crbug.com/247518 |
605 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, | 619 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, |
606 FillInputFromForeignProfile) { | 620 FillInputFromForeignProfile) { |
607 AutofillProfile full_profile(test::GetFullProfile()); | 621 AutofillProfile full_profile(test::GetFullProfile()); |
608 full_profile.SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), | 622 full_profile.SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), |
609 ASCIIToUTF16("France"), "en-US"); | 623 ASCIIToUTF16("France"), "en-US"); |
610 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 624 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
611 | 625 |
| 626 // Select "Add new shipping address...". |
| 627 ui::MenuModel* model = controller()->MenuModelForSection(SECTION_SHIPPING); |
| 628 model->ActivatedAt(model->GetItemCount() - 2); |
| 629 ASSERT_TRUE(controller()->IsManuallyEditingSection(SECTION_SHIPPING)); |
| 630 |
612 const DetailInputs& inputs = | 631 const DetailInputs& inputs = |
613 controller()->RequestedFieldsForSection(SECTION_SHIPPING); | 632 controller()->RequestedFieldsForSection(SECTION_SHIPPING); |
614 const ServerFieldType triggering_type = inputs[0].type; | 633 const ServerFieldType triggering_type = inputs[0].type; |
615 base::string16 value = full_profile.GetRawInfo(triggering_type); | 634 base::string16 value = full_profile.GetRawInfo(triggering_type); |
616 TestableAutofillDialogView* view = controller()->GetTestableView(); | 635 TestableAutofillDialogView* view = controller()->GetTestableView(); |
617 view->SetTextContentsOfInput(triggering_type, | 636 view->SetTextContentsOfInput(triggering_type, |
618 value.substr(0, value.size() / 2)); | 637 value.substr(0, value.size() / 2)); |
619 view->ActivateInput(triggering_type); | 638 view->ActivateInput(triggering_type); |
620 | 639 |
621 ASSERT_EQ(triggering_type, controller()->popup_input_type()); | 640 ASSERT_EQ(triggering_type, controller()->popup_input_type()); |
622 controller()->DidAcceptSuggestion(base::string16(), 0); | 641 controller()->DidAcceptSuggestion(base::string16(), 0); |
623 | 642 |
624 // All inputs should be filled. | 643 // All inputs should be filled. |
625 AutofillProfileWrapper wrapper(&full_profile); | 644 AutofillProfileWrapper wrapper(&full_profile); |
626 for (size_t i = 0; i < inputs.size(); ++i) { | 645 for (size_t i = 0; i < inputs.size(); ++i) { |
627 const ServerFieldType type = inputs[i].type; | 646 const ServerFieldType type = inputs[i].type; |
628 base::string16 expectation = | 647 base::string16 expectation = |
629 AutofillType(type).GetStorableType() == ADDRESS_HOME_COUNTRY ? | 648 AutofillType(type).GetStorableType() == ADDRESS_HOME_COUNTRY ? |
630 ASCIIToUTF16("United States") : wrapper.GetInfo(AutofillType(type)); | 649 ASCIIToUTF16("United States") : wrapper.GetInfo(AutofillType(type)); |
631 EXPECT_EQ(expectation, view->GetTextContentsOfInput(type)); | 650 EXPECT_EQ(expectation, view->GetTextContentsOfInput(type)); |
632 } | 651 } |
633 | 652 |
634 // Now simulate some user edits and try again. | 653 // Now simulate some user edits and try again. |
635 std::vector<base::string16> expectations; | 654 std::vector<base::string16> expectations; |
636 for (size_t i = 0; i < inputs.size(); ++i) { | 655 for (size_t i = 0; i < inputs.size(); ++i) { |
| 656 if (controller()->ComboboxModelForAutofillType(inputs[i].type)) { |
| 657 expectations.push_back(base::string16()); |
| 658 continue; |
| 659 } |
637 base::string16 users_input = i % 2 == 0 ? base::string16() | 660 base::string16 users_input = i % 2 == 0 ? base::string16() |
638 : ASCIIToUTF16("dummy"); | 661 : ASCIIToUTF16("dummy"); |
639 view->SetTextContentsOfInput(inputs[i].type, users_input); | 662 view->SetTextContentsOfInput(inputs[i].type, users_input); |
640 // Empty inputs should be filled, others should be left alone. | 663 // Empty inputs should be filled, others should be left alone. |
641 base::string16 expectation = | 664 base::string16 expectation = |
642 inputs[i].type == triggering_type || users_input.empty() ? | 665 inputs[i].type == triggering_type || users_input.empty() ? |
643 wrapper.GetInfo(AutofillType(inputs[i].type)) : | 666 wrapper.GetInfo(AutofillType(inputs[i].type)) : |
644 users_input; | 667 users_input; |
645 if (AutofillType(inputs[i].type).GetStorableType() == ADDRESS_HOME_COUNTRY) | 668 if (AutofillType(inputs[i].type).GetStorableType() == ADDRESS_HOME_COUNTRY) |
646 expectation = ASCIIToUTF16("United States"); | 669 expectation = ASCIIToUTF16("United States"); |
647 | 670 |
648 expectations.push_back(expectation); | 671 expectations.push_back(expectation); |
649 } | 672 } |
650 | 673 |
651 view->SetTextContentsOfInput(triggering_type, | 674 view->SetTextContentsOfInput(triggering_type, |
652 value.substr(0, value.size() / 2)); | 675 value.substr(0, value.size() / 2)); |
653 view->ActivateInput(triggering_type); | 676 view->ActivateInput(triggering_type); |
654 ASSERT_EQ(triggering_type, controller()->popup_input_type()); | 677 ASSERT_EQ(triggering_type, controller()->popup_input_type()); |
655 controller()->DidAcceptSuggestion(base::string16(), 0); | 678 controller()->DidAcceptSuggestion(base::string16(), 0); |
656 | 679 |
657 for (size_t i = 0; i < inputs.size(); ++i) { | 680 for (size_t i = 0; i < inputs.size(); ++i) { |
| 681 if (controller()->ComboboxModelForAutofillType(inputs[i].type)) |
| 682 continue; |
658 EXPECT_EQ(expectations[i], view->GetTextContentsOfInput(inputs[i].type)); | 683 EXPECT_EQ(expectations[i], view->GetTextContentsOfInput(inputs[i].type)); |
659 } | 684 } |
660 } | 685 } |
661 | 686 |
662 // This test makes sure that picking a profile variant in the Autofill | 687 // This test makes sure that picking a profile variant in the Autofill |
663 // popup works as expected. | 688 // popup works as expected. |
664 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, | 689 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, |
665 FillInputFromAutofillVariant) { | 690 FillInputFromAutofillVariant) { |
666 AutofillProfile full_profile(test::GetFullProfile()); | 691 AutofillProfile full_profile(test::GetFullProfile()); |
667 | 692 |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 // happen if the WebContents is deleted while proccessing a nav entry commit). | 1120 // happen if the WebContents is deleted while proccessing a nav entry commit). |
1096 EXPECT_TRUE(account_chooser_model->WalletIsSelected()); | 1121 EXPECT_TRUE(account_chooser_model->WalletIsSelected()); |
1097 } | 1122 } |
1098 | 1123 |
1099 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AddAccount) { | 1124 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AddAccount) { |
1100 #if defined(OS_WIN) | 1125 #if defined(OS_WIN) |
1101 // TODO(msw): Fix potential flakiness on Windows XP; http://crbug.com/333641 | 1126 // TODO(msw): Fix potential flakiness on Windows XP; http://crbug.com/333641 |
1102 if (base::win::GetVersion() <= base::win::VERSION_XP) | 1127 if (base::win::GetVersion() <= base::win::VERSION_XP) |
1103 return; | 1128 return; |
1104 #endif | 1129 #endif |
1105 InitializeController(); | |
1106 | 1130 |
1107 controller()->OnDidFetchWalletCookieValue(std::string()); | 1131 controller()->OnDidFetchWalletCookieValue(std::string()); |
1108 std::vector<std::string> usernames; | 1132 std::vector<std::string> usernames; |
1109 usernames.push_back("user_0@example.com"); | 1133 usernames.push_back("user_0@example.com"); |
1110 controller()->OnDidGetWalletItems( | 1134 controller()->OnDidGetWalletItems( |
1111 wallet::GetTestWalletItemsWithUsers(usernames, 0)); | 1135 wallet::GetTestWalletItemsWithUsers(usernames, 0)); |
1112 | 1136 |
1113 // Switch to Autofill. | 1137 // Switch to Autofill. |
1114 AccountChooserModel* account_chooser_model = | 1138 AccountChooserModel* account_chooser_model = |
1115 controller()->AccountChooserModelForTesting(); | 1139 controller()->AccountChooserModelForTesting(); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1336 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, | 1360 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, |
1337 MAYBE_DoesWorkOnHttpWithFlag) { | 1361 MAYBE_DoesWorkOnHttpWithFlag) { |
1338 net::SpawnedTestServer http_server( | 1362 net::SpawnedTestServer http_server( |
1339 net::SpawnedTestServer::TYPE_HTTP, | 1363 net::SpawnedTestServer::TYPE_HTTP, |
1340 net::SpawnedTestServer::kLocalhost, | 1364 net::SpawnedTestServer::kLocalhost, |
1341 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); | 1365 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); |
1342 ASSERT_TRUE(http_server.Start()); | 1366 ASSERT_TRUE(http_server.Start()); |
1343 EXPECT_TRUE(RunTestPage(http_server)); | 1367 EXPECT_TRUE(RunTestPage(http_server)); |
1344 } | 1368 } |
1345 | 1369 |
| 1370 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, |
| 1371 CountryChangeRebuildsSection) { |
| 1372 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 1373 command_line->AppendSwitch(::switches::kEnableAutofillAddressI18n); |
| 1374 ASSERT_TRUE(i18ninput::Enabled()); |
| 1375 |
| 1376 InitializeController(); |
| 1377 |
| 1378 controller()->OnDidFetchWalletCookieValue(std::string()); |
| 1379 controller()->OnDidGetWalletItems( |
| 1380 wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED)); |
| 1381 EXPECT_TRUE(controller()->IsPayingWithWallet()); |
| 1382 |
| 1383 // Select "Add new shipping address...". |
| 1384 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(1); |
| 1385 ASSERT_TRUE(controller()->IsManuallyEditingSection(SECTION_SHIPPING)); |
| 1386 |
| 1387 TestableAutofillDialogView* view = controller()->GetTestableView(); |
| 1388 ASSERT_EQ(ASCIIToUTF16("United States"), |
| 1389 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); |
| 1390 |
| 1391 const DetailInputs& us_inputs = |
| 1392 controller()->RequestedFieldsForSection(SECTION_SHIPPING); |
| 1393 EXPECT_EQ(8U, us_inputs.size()); |
| 1394 |
| 1395 // Check that there's no dependent locality for the US layout. |
| 1396 for (size_t i = 0; i < us_inputs.size(); ++i) { |
| 1397 EXPECT_NE(us_inputs[i].type, ADDRESS_HOME_DEPENDENT_LOCALITY); |
| 1398 } |
| 1399 |
| 1400 // Add some valid user input that should be preserved when country changes and |
| 1401 // switch from United States to China. |
| 1402 view->SetTextContentsOfInput(NAME_FULL, ASCIIToUTF16("B. Loblaw")); |
| 1403 view->SetTextContentsOfInput(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("China")); |
| 1404 ASSERT_TRUE(controller()->IsManuallyEditingSection(SECTION_SHIPPING)); |
| 1405 |
| 1406 EXPECT_EQ(ASCIIToUTF16("B. Loblaw"), view->GetTextContentsOfInput(NAME_FULL)); |
| 1407 EXPECT_EQ(ASCIIToUTF16("China"), |
| 1408 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); |
| 1409 |
| 1410 const DetailInputs& cn_inputs = |
| 1411 controller()->RequestedFieldsForSection(SECTION_SHIPPING); |
| 1412 EXPECT_EQ(9U, cn_inputs.size()); |
| 1413 |
| 1414 // Check that there is dependent locality for the Chinese layout. |
| 1415 size_t i = 0; |
| 1416 for (; i < cn_inputs.size(); ++i) { |
| 1417 if (cn_inputs[i].type == ADDRESS_HOME_DEPENDENT_LOCALITY) |
| 1418 break; |
| 1419 } |
| 1420 EXPECT_LT(i, cn_inputs.size()); |
| 1421 |
| 1422 // Changing data sources should preserve country selection. |
| 1423 ui::MenuModel* account_chooser = controller()->MenuModelForAccountChooser(); |
| 1424 account_chooser->ActivatedAt(account_chooser->GetItemCount() - 1); |
| 1425 EXPECT_FALSE(controller()->IsPayingWithWallet()); |
| 1426 |
| 1427 EXPECT_EQ(ASCIIToUTF16("B. Loblaw"), view->GetTextContentsOfInput(NAME_FULL)); |
| 1428 EXPECT_EQ(ASCIIToUTF16("China"), |
| 1429 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); |
| 1430 |
| 1431 // Selecting "Add new shipping address..." with a non-default country should |
| 1432 // clear the manual input in that section and reset to default country. |
| 1433 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(1); |
| 1434 |
| 1435 EXPECT_EQ(base::string16(), view->GetTextContentsOfInput(NAME_FULL)); |
| 1436 EXPECT_EQ(ASCIIToUTF16("United States"), |
| 1437 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); |
| 1438 } |
| 1439 |
1346 // Like the parent test, but doesn't add the --reduce-security-for-testing flag. | 1440 // Like the parent test, but doesn't add the --reduce-security-for-testing flag. |
1347 class AutofillDialogControllerSecurityTest : | 1441 class AutofillDialogControllerSecurityTest : |
1348 public AutofillDialogControllerTest { | 1442 public AutofillDialogControllerTest { |
1349 public: | 1443 public: |
1350 AutofillDialogControllerSecurityTest() {} | 1444 AutofillDialogControllerSecurityTest() {} |
1351 virtual ~AutofillDialogControllerSecurityTest() {} | 1445 virtual ~AutofillDialogControllerSecurityTest() {} |
1352 | 1446 |
1353 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 1447 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
1354 CHECK(!command_line->HasSwitch(::switches::kReduceSecurityForTesting)); | 1448 CHECK(!command_line->HasSwitch(::switches::kReduceSecurityForTesting)); |
1355 } | 1449 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1402 MAYBE_DoesntWorkOnBrokenHttps) { | 1496 MAYBE_DoesntWorkOnBrokenHttps) { |
1403 net::SpawnedTestServer https_server( | 1497 net::SpawnedTestServer https_server( |
1404 net::SpawnedTestServer::TYPE_HTTPS, | 1498 net::SpawnedTestServer::TYPE_HTTPS, |
1405 SSLOptions(SSLOptions::CERT_EXPIRED), | 1499 SSLOptions(SSLOptions::CERT_EXPIRED), |
1406 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); | 1500 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); |
1407 ASSERT_TRUE(https_server.Start()); | 1501 ASSERT_TRUE(https_server.Start()); |
1408 EXPECT_FALSE(RunTestPage(https_server)); | 1502 EXPECT_FALSE(RunTestPage(https_server)); |
1409 } | 1503 } |
1410 | 1504 |
1411 } // namespace autofill | 1505 } // namespace autofill |
OLD | NEW |