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 bc1bf944b7880bfe0542f53f6744bb8277b4aba8..4aa6835557be6f46e7f1c9f40f6b701695b75bb6 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" |
@@ -183,6 +185,7 @@ class TestAutofillDialogController : public AutofillDialogControllerImpl { |
} |
using AutofillDialogControllerImpl::IsEditingExistingData; |
+ using AutofillDialogControllerImpl::IsManuallyEditingSection; |
using AutofillDialogControllerImpl::IsPayingWithWallet; |
using AutofillDialogControllerImpl::IsSubmitPausedOn; |
using AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData; |
@@ -554,6 +557,10 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, FillInputFromAutofill) { |
AutofillProfile full_profile(test::GetFullProfile()); |
controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
+ 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; |
@@ -607,6 +614,10 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, |
ASCIIToUTF16("France"), "en-US"); |
controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
+ 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; |
@@ -1090,8 +1101,6 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, SimulateSuccessfulSignIn) { |
} |
IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AddAccount) { |
- InitializeController(); |
- |
controller()->OnDidFetchWalletCookieValue(std::string()); |
std::vector<std::string> usernames; |
usernames.push_back("user_0@example.com"); |
@@ -1331,6 +1340,67 @@ 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("China"), |
+ view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); |
+} |
+ |
// Like the parent test, but doesn't add the --reduce-security-for-testing flag. |
class AutofillDialogControllerSecurityTest : |
public AutofillDialogControllerTest { |