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

Side by Side Diff: chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc

Issue 157093002: rAc - hardcode wallet billing address to US in i18n mode (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
(...skipping 1414 matching lines...) Expand 10 before | Expand all | Expand 10 after
1425 view->ActivateInput(ADDRESS_HOME_COUNTRY); 1425 view->ActivateInput(ADDRESS_HOME_COUNTRY);
1426 1426
1427 // Verify the name is still there. 1427 // Verify the name is still there.
1428 EXPECT_EQ(ASCIIToUTF16("B. Loblaw"), view->GetTextContentsOfInput(NAME_FULL)); 1428 EXPECT_EQ(ASCIIToUTF16("B. Loblaw"), view->GetTextContentsOfInput(NAME_FULL));
1429 1429
1430 EXPECT_TRUE( 1430 EXPECT_TRUE(
1431 SectionHasField(SECTION_BILLING, ADDRESS_BILLING_DEPENDENT_LOCALITY)); 1431 SectionHasField(SECTION_BILLING, ADDRESS_BILLING_DEPENDENT_LOCALITY));
1432 EXPECT_TRUE(SectionHasField(SECTION_SHIPPING, ADDRESS_HOME_SORTING_CODE)); 1432 EXPECT_TRUE(SectionHasField(SECTION_SHIPPING, ADDRESS_HOME_SORTING_CODE));
1433 } 1433 }
1434 1434
1435 // Changing the data source to or from Wallet preserves the shipping country,
1436 // but not the billing country because Wallet only supports US billing
1437 // addresses.
1435 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerI18nTest, 1438 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerI18nTest,
1436 ChangingDataSourcePreservesCountry) { 1439 ChangingDataSourcePreservesCountry) {
1437 AutofillProfile verified_profile(test::GetVerifiedProfile()); 1440 AutofillProfile verified_profile(test::GetVerifiedProfile());
1438 controller()->GetTestingManager()->AddTestingProfile(&verified_profile); 1441 controller()->GetTestingManager()->AddTestingProfile(&verified_profile);
1439 1442
1440 CreditCard verified_card(test::GetVerifiedCreditCard()); 1443 CreditCard verified_card(test::GetVerifiedCreditCard());
1441 controller()->GetTestingManager()->AddTestingCreditCard(&verified_card); 1444 controller()->GetTestingManager()->AddTestingCreditCard(&verified_card);
1442 1445
1443 controller()->OnDidFetchWalletCookieValue(std::string()); 1446 controller()->OnDidFetchWalletCookieValue(std::string());
1444 scoped_ptr<wallet::WalletItems> items = 1447 scoped_ptr<wallet::WalletItems> items =
1445 wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED); 1448 wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED);
1446 items->AddAccount(wallet::GetTestGaiaAccount()); 1449 items->AddAccount(wallet::GetTestGaiaAccount());
1447 items->AddInstrument(wallet::GetTestMaskedInstrument()); 1450 items->AddInstrument(wallet::GetTestMaskedInstrument());
1448 items->AddAddress(wallet::GetTestShippingAddress()); 1451 items->AddAddress(wallet::GetTestShippingAddress());
1449 controller()->OnDidGetWalletItems(items.Pass()); 1452 controller()->OnDidGetWalletItems(items.Pass());
1450 1453
1451 EXPECT_TRUE(controller()->IsPayingWithWallet()); 1454 EXPECT_TRUE(controller()->IsPayingWithWallet());
1452 1455
1453 // Select "Add new billing/shipping address...". 1456 // Select "Add new shipping address...".
1454 controller()->MenuModelForSection(SECTION_CC_BILLING)->ActivatedAt(1);
1455 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(2); 1457 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(2);
1456 1458
1457 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); 1459 scoped_ptr<AutofillDialogViewTester> view = GetViewTester();
1458 ASSERT_EQ(ASCIIToUTF16("United States"), 1460 ASSERT_EQ(ASCIIToUTF16("United States"),
1459 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY));
1460 ASSERT_EQ(ASCIIToUTF16("United States"),
1461 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); 1461 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY));
1462 1462
1463 // Switch both billing and shipping countries. 1463 // Switch the shipping country.
1464 view->SetTextContentsOfInput(ADDRESS_BILLING_COUNTRY, ASCIIToUTF16("China")); 1464 view->SetTextContentsOfInput(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("China"));
1465 view->ActivateInput(ADDRESS_BILLING_COUNTRY);
1466 view->SetTextContentsOfInput(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("France"));
1467 view->ActivateInput(ADDRESS_HOME_COUNTRY); 1465 view->ActivateInput(ADDRESS_HOME_COUNTRY);
1468 1466
1469 // Switch to using Autofill instead of Wallet. 1467 // Switch to using Autofill instead of Wallet.
1470 ui::MenuModel* account_chooser = controller()->MenuModelForAccountChooser(); 1468 ui::MenuModel* account_chooser = controller()->MenuModelForAccountChooser();
1471 account_chooser->ActivatedAt(account_chooser->GetItemCount() - 1); 1469 account_chooser->ActivatedAt(account_chooser->GetItemCount() - 1);
1472 1470
1473 EXPECT_FALSE(controller()->IsPayingWithWallet()); 1471 EXPECT_FALSE(controller()->IsPayingWithWallet());
1474 1472
1475 // Countries should have stayed the same. 1473 // Shipping country should have stayed the same.
1474 EXPECT_EQ(ASCIIToUTF16("China"),
1475 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY));
1476 ASSERT_TRUE(
1477 SectionHasField(SECTION_SHIPPING, ADDRESS_HOME_DEPENDENT_LOCALITY));
1478
1479 controller()->MenuModelForSection(SECTION_BILLING)->ActivatedAt(1);
1480 view->SetTextContentsOfInput(ADDRESS_BILLING_COUNTRY, ASCIIToUTF16("China"));
1481 view->ActivateInput(ADDRESS_BILLING_COUNTRY);
1476 EXPECT_EQ(ASCIIToUTF16("China"), 1482 EXPECT_EQ(ASCIIToUTF16("China"),
1477 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY)); 1483 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY));
1478 EXPECT_EQ(ASCIIToUTF16("France"),
1479 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY));
1480
1481 ASSERT_TRUE( 1484 ASSERT_TRUE(
1482 SectionHasField(SECTION_BILLING, ADDRESS_BILLING_DEPENDENT_LOCALITY)); 1485 SectionHasField(SECTION_BILLING, ADDRESS_BILLING_DEPENDENT_LOCALITY));
1483 1486
1484 view->SetTextContentsOfInput(ADDRESS_BILLING_COUNTRY, 1487 // Switch back to Wallet. Country should go back to US.
1485 ASCIIToUTF16("Antarctica")); 1488 account_chooser->ActivatedAt(0);
1486 view->ActivateInput(ADDRESS_BILLING_COUNTRY); 1489 EXPECT_EQ(ASCIIToUTF16("United States"),
1490 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY));
1491 ASSERT_FALSE(
1492 SectionHasField(SECTION_CC_BILLING, ADDRESS_BILLING_DEPENDENT_LOCALITY));
1487 1493
1488 // Select the first Wallet account. 1494 // Make sure shipping is still on China.
1489 account_chooser->ActivatedAt(0); 1495 EXPECT_EQ(ASCIIToUTF16("China"),
1490 ASSERT_TRUE(controller()->IsManuallyEditingSection(SECTION_CC_BILLING)); 1496 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY));
1491 1497 ASSERT_TRUE(
1492 // Verify that inputs are rebuilt for billing sections across changes. 1498 SectionHasField(SECTION_SHIPPING, ADDRESS_HOME_DEPENDENT_LOCALITY));
1493 EXPECT_FALSE(
1494 SectionHasField(SECTION_CC_BILLING, ADDRESS_BILLING_DEPENDENT_LOCALITY));
1495 } 1499 }
1496 1500
1497 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerI18nTest, AddNewResetsCountry) { 1501 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerI18nTest, AddNewResetsCountry) {
1498 AutofillProfile verified_profile(test::GetVerifiedProfile()); 1502 AutofillProfile verified_profile(test::GetVerifiedProfile());
1499 controller()->GetTestingManager()->AddTestingProfile(&verified_profile); 1503 controller()->GetTestingManager()->AddTestingProfile(&verified_profile);
1500 1504
1501 // Select "Add new billing/shipping address...". 1505 // Select "Add new billing/shipping address...".
1502 controller()->MenuModelForSection(SECTION_BILLING)->ActivatedAt(1); 1506 controller()->MenuModelForSection(SECTION_BILLING)->ActivatedAt(1);
1503 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(2); 1507 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(2);
1504 1508
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 // Relevant country loaded but revalidation already happened, no further 1606 // Relevant country loaded but revalidation already happened, no further
1603 // validation should occur. 1607 // validation should occur.
1604 controller()->OnAddressValidationRulesLoaded("CN", false); 1608 controller()->OnAddressValidationRulesLoaded("CN", false);
1605 1609
1606 // Cancelling the dialog causes additional validation to see if the user 1610 // Cancelling the dialog causes additional validation to see if the user
1607 // cancelled with invalid fields, so verify and clear here. 1611 // cancelled with invalid fields, so verify and clear here.
1608 testing::Mock::VerifyAndClearExpectations(controller()->GetMockValidator()); 1612 testing::Mock::VerifyAndClearExpectations(controller()->GetMockValidator());
1609 } 1613 }
1610 1614
1611 } // namespace autofill 1615 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/autofill_dialog_common.cc ('k') | chrome/browser/ui/autofill/autofill_dialog_controller_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698