Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2599)

Unified Diff: chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc

Issue 124533003: Add country combobox to change country and rebuild address inputs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..8dee7ad4efee16d4372a048dead821b6ec0d41dc 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;
@@ -1090,8 +1093,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 +1332,53 @@ 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();
+
+ // 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());
+
+ for (size_t i = 0; i < us_inputs.size(); ++i) {
+ EXPECT_NE(us_inputs[i].type, ADDRESS_HOME_DEPENDENT_LOCALITY);
+ }
+
+ view->SetTextContentsOfInput(NAME_FULL, ASCIIToUTF16("B. Loblaw"));
+
+ // Switch country combobox from United States to China.
+ view->SetTextContentsOfInput(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("China"));
+ EXPECT_TRUE(controller()->IsManuallyEditingSection(SECTION_SHIPPING));
+
+ EXPECT_EQ(ASCIIToUTF16("China"),
+ view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY));
+ EXPECT_EQ(ASCIIToUTF16("B. Loblaw"), view->GetTextContentsOfInput(NAME_FULL));
+
+ const DetailInputs& cn_inputs =
+ controller()->RequestedFieldsForSection(SECTION_SHIPPING);
+ ASSERT_NE(&cn_inputs[0], &us_inputs[0]);
+ EXPECT_EQ(9U, cn_inputs.size());
+
+ 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());
+}
+
// Like the parent test, but doesn't add the --reduce-security-for-testing flag.
class AutofillDialogControllerSecurityTest :
public AutofillDialogControllerTest {

Powered by Google App Engine
This is Rietveld 408576698