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

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: mac 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 d9c15ec6b6ada8a83ab0598acdc469870d4b4f09..f41b8237ad70ce24c2cc5f8d94b0fd64e999d70e 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,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));
Evan Stade 2014/01/14 17:19:38 nit: add comment about what the second to last ite
Dan Beam 2014/01/15 03:10:48 Done.
+
const DetailInputs& inputs =
controller()->RequestedFieldsForSection(SECTION_SHIPPING);
const ServerFieldType triggering_type = inputs[0].type;
@@ -609,6 +616,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;
@@ -1097,8 +1108,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");
@@ -1338,6 +1347,75 @@ 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));
+
+ // 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));
Evan Stade 2014/01/14 17:19:38 you should also check that NAME_FULL still has som
Dan Beam 2014/01/15 03:10:48 oh, I did have that... somehow it got dropped. ad
+ 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 {

Powered by Google App Engine
This is Rietveld 408576698