| Index: chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc
|
| diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc
|
| index 8036aeb61156221ba693d3aea2d976af47412616..6306f434578ea35b571dbe01fd5fe82f6f29cd75 100644
|
| --- a/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc
|
| +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc
|
| @@ -15,6 +15,7 @@
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/ui/autofill/account_chooser_model.h"
|
| #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h"
|
| +#include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h"
|
| #include "chrome/browser/ui/autofill/autofill_dialog_view.h"
|
| #include "chrome/browser/ui/autofill/data_model_wrapper.h"
|
| #include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h"
|
| @@ -23,6 +24,7 @@
|
| #include "chrome/browser/ui/browser.h"
|
| #include "chrome/browser/ui/browser_tabstrip.h"
|
| #include "chrome/browser/ui/tabs/tab_strip_model.h"
|
| +#include "chrome/common/chrome_switches.h"
|
| #include "chrome/common/pref_names.h"
|
| #include "chrome/common/url_constants.h"
|
| #include "chrome/test/base/in_process_browser_test.h"
|
| @@ -185,6 +187,7 @@ class TestAutofillDialogController : public AutofillDialogControllerImpl {
|
| }
|
|
|
| using AutofillDialogControllerImpl::IsEditingExistingData;
|
| + using AutofillDialogControllerImpl::IsManuallyEditingSection;
|
| using AutofillDialogControllerImpl::IsPayingWithWallet;
|
| using AutofillDialogControllerImpl::IsSubmitPausedOn;
|
| using AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData;
|
| @@ -556,6 +559,11 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, FillInputFromAutofill) {
|
| AutofillProfile full_profile(test::GetFullProfile());
|
| controller()->GetTestingManager()->AddTestingProfile(&full_profile);
|
|
|
| + // Select "Add new shipping address...".
|
| + ui::MenuModel* model = controller()->MenuModelForSection(SECTION_SHIPPING);
|
| + model->ActivatedAt(model->GetItemCount() - 2);
|
| + ASSERT_TRUE(controller()->IsManuallyEditingSection(SECTION_SHIPPING));
|
| +
|
| const DetailInputs& inputs =
|
| controller()->RequestedFieldsForSection(SECTION_SHIPPING);
|
| const ServerFieldType triggering_type = inputs[0].type;
|
| @@ -578,6 +586,10 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, FillInputFromAutofill) {
|
| // Now simulate some user edits and try again.
|
| std::vector<base::string16> expectations;
|
| for (size_t i = 0; i < inputs.size(); ++i) {
|
| + if (controller()->ComboboxModelForAutofillType(inputs[i].type)) {
|
| + expectations.push_back(base::string16());
|
| + continue;
|
| + }
|
| base::string16 users_input = i % 2 == 0 ? base::string16()
|
| : ASCIIToUTF16("dummy");
|
| view->SetTextContentsOfInput(inputs[i].type, users_input);
|
| @@ -596,6 +608,8 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, FillInputFromAutofill) {
|
| controller()->DidAcceptSuggestion(base::string16(), 0);
|
|
|
| for (size_t i = 0; i < inputs.size(); ++i) {
|
| + if (controller()->ComboboxModelForAutofillType(inputs[i].type))
|
| + continue;
|
| EXPECT_EQ(expectations[i], view->GetTextContentsOfInput(inputs[i].type));
|
| }
|
| }
|
| @@ -609,6 +623,11 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
|
| ASCIIToUTF16("France"), "en-US");
|
| controller()->GetTestingManager()->AddTestingProfile(&full_profile);
|
|
|
| + // Select "Add new shipping address...".
|
| + ui::MenuModel* model = controller()->MenuModelForSection(SECTION_SHIPPING);
|
| + model->ActivatedAt(model->GetItemCount() - 2);
|
| + ASSERT_TRUE(controller()->IsManuallyEditingSection(SECTION_SHIPPING));
|
| +
|
| const DetailInputs& inputs =
|
| controller()->RequestedFieldsForSection(SECTION_SHIPPING);
|
| const ServerFieldType triggering_type = inputs[0].type;
|
| @@ -634,6 +653,10 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
|
| // Now simulate some user edits and try again.
|
| std::vector<base::string16> expectations;
|
| for (size_t i = 0; i < inputs.size(); ++i) {
|
| + if (controller()->ComboboxModelForAutofillType(inputs[i].type)) {
|
| + expectations.push_back(base::string16());
|
| + continue;
|
| + }
|
| base::string16 users_input = i % 2 == 0 ? base::string16()
|
| : ASCIIToUTF16("dummy");
|
| view->SetTextContentsOfInput(inputs[i].type, users_input);
|
| @@ -655,6 +678,8 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
|
| controller()->DidAcceptSuggestion(base::string16(), 0);
|
|
|
| for (size_t i = 0; i < inputs.size(); ++i) {
|
| + if (controller()->ComboboxModelForAutofillType(inputs[i].type))
|
| + continue;
|
| EXPECT_EQ(expectations[i], view->GetTextContentsOfInput(inputs[i].type));
|
| }
|
| }
|
| @@ -1102,7 +1127,6 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AddAccount) {
|
| if (base::win::GetVersion() <= base::win::VERSION_XP)
|
| return;
|
| #endif
|
| - InitializeController();
|
|
|
| controller()->OnDidFetchWalletCookieValue(std::string());
|
| std::vector<std::string> usernames;
|
| @@ -1343,6 +1367,76 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
|
| EXPECT_TRUE(RunTestPage(http_server));
|
| }
|
|
|
| +IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
|
| + CountryChangeRebuildsSection) {
|
| + CommandLine* command_line = CommandLine::ForCurrentProcess();
|
| + command_line->AppendSwitch(::switches::kEnableAutofillAddressI18n);
|
| + ASSERT_TRUE(i18ninput::Enabled());
|
| +
|
| + InitializeController();
|
| +
|
| + controller()->OnDidFetchWalletCookieValue(std::string());
|
| + controller()->OnDidGetWalletItems(
|
| + wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED));
|
| + EXPECT_TRUE(controller()->IsPayingWithWallet());
|
| +
|
| + // Select "Add new shipping address...".
|
| + controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(1);
|
| + ASSERT_TRUE(controller()->IsManuallyEditingSection(SECTION_SHIPPING));
|
| +
|
| + TestableAutofillDialogView* view = controller()->GetTestableView();
|
| + ASSERT_EQ(ASCIIToUTF16("United States"),
|
| + view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY));
|
| +
|
| + const DetailInputs& us_inputs =
|
| + controller()->RequestedFieldsForSection(SECTION_SHIPPING);
|
| + EXPECT_EQ(8U, us_inputs.size());
|
| +
|
| + // Check that there's no dependent locality for the US layout.
|
| + for (size_t i = 0; i < us_inputs.size(); ++i) {
|
| + EXPECT_NE(us_inputs[i].type, ADDRESS_HOME_DEPENDENT_LOCALITY);
|
| + }
|
| +
|
| + // Add some valid user input that should be preserved when country changes and
|
| + // switch from United States to China.
|
| + view->SetTextContentsOfInput(NAME_FULL, ASCIIToUTF16("B. Loblaw"));
|
| + view->SetTextContentsOfInput(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("China"));
|
| + ASSERT_TRUE(controller()->IsManuallyEditingSection(SECTION_SHIPPING));
|
| +
|
| + EXPECT_EQ(ASCIIToUTF16("B. Loblaw"), view->GetTextContentsOfInput(NAME_FULL));
|
| + EXPECT_EQ(ASCIIToUTF16("China"),
|
| + view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY));
|
| +
|
| + const DetailInputs& cn_inputs =
|
| + controller()->RequestedFieldsForSection(SECTION_SHIPPING);
|
| + EXPECT_EQ(9U, cn_inputs.size());
|
| +
|
| + // Check that there is dependent locality for the Chinese layout.
|
| + size_t i = 0;
|
| + for (; i < cn_inputs.size(); ++i) {
|
| + if (cn_inputs[i].type == ADDRESS_HOME_DEPENDENT_LOCALITY)
|
| + break;
|
| + }
|
| + EXPECT_LT(i, cn_inputs.size());
|
| +
|
| + // Changing data sources should preserve country selection.
|
| + ui::MenuModel* account_chooser = controller()->MenuModelForAccountChooser();
|
| + account_chooser->ActivatedAt(account_chooser->GetItemCount() - 1);
|
| + EXPECT_FALSE(controller()->IsPayingWithWallet());
|
| +
|
| + EXPECT_EQ(ASCIIToUTF16("B. Loblaw"), view->GetTextContentsOfInput(NAME_FULL));
|
| + EXPECT_EQ(ASCIIToUTF16("China"),
|
| + view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY));
|
| +
|
| + // Selecting "Add new shipping address..." with a non-default country should
|
| + // clear the manual input in that section and reset to default country.
|
| + controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(1);
|
| +
|
| + EXPECT_EQ(base::string16(), view->GetTextContentsOfInput(NAME_FULL));
|
| + EXPECT_EQ(ASCIIToUTF16("United States"),
|
| + view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY));
|
| +}
|
| +
|
| // Like the parent test, but doesn't add the --reduce-security-for-testing flag.
|
| class AutofillDialogControllerSecurityTest :
|
| public AutofillDialogControllerTest {
|
|
|