Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1413 view->ActivateInput(ADDRESS_HOME_COUNTRY); | 1413 view->ActivateInput(ADDRESS_HOME_COUNTRY); |
| 1414 | 1414 |
| 1415 // Verify the name is still there. | 1415 // Verify the name is still there. |
| 1416 EXPECT_EQ(ASCIIToUTF16("B. Loblaw"), view->GetTextContentsOfInput(NAME_FULL)); | 1416 EXPECT_EQ(ASCIIToUTF16("B. Loblaw"), view->GetTextContentsOfInput(NAME_FULL)); |
| 1417 | 1417 |
| 1418 EXPECT_TRUE( | 1418 EXPECT_TRUE( |
| 1419 SectionHasField(SECTION_BILLING, ADDRESS_BILLING_DEPENDENT_LOCALITY)); | 1419 SectionHasField(SECTION_BILLING, ADDRESS_BILLING_DEPENDENT_LOCALITY)); |
| 1420 EXPECT_TRUE(SectionHasField(SECTION_SHIPPING, ADDRESS_HOME_SORTING_CODE)); | 1420 EXPECT_TRUE(SectionHasField(SECTION_SHIPPING, ADDRESS_HOME_SORTING_CODE)); |
| 1421 } | 1421 } |
| 1422 | 1422 |
| 1423 // Changing the data source to or from Wallet preserves the shipping country, | |
| 1424 // but not the billing country because Wallet only supports US billing | |
| 1425 // addresses. | |
| 1423 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerI18nTest, | 1426 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerI18nTest, |
| 1424 ChangingDataSourcePreservesCountry) { | 1427 ChangingDataSourcePreservesCountry) { |
| 1425 AutofillProfile verified_profile(test::GetVerifiedProfile()); | 1428 AutofillProfile verified_profile(test::GetVerifiedProfile()); |
| 1426 controller()->GetTestingManager()->AddTestingProfile(&verified_profile); | 1429 controller()->GetTestingManager()->AddTestingProfile(&verified_profile); |
| 1427 | 1430 |
| 1428 CreditCard verified_card(test::GetVerifiedCreditCard()); | 1431 CreditCard verified_card(test::GetVerifiedCreditCard()); |
| 1429 controller()->GetTestingManager()->AddTestingCreditCard(&verified_card); | 1432 controller()->GetTestingManager()->AddTestingCreditCard(&verified_card); |
| 1430 | 1433 |
| 1431 controller()->OnDidFetchWalletCookieValue(std::string()); | 1434 controller()->OnDidFetchWalletCookieValue(std::string()); |
| 1432 scoped_ptr<wallet::WalletItems> items = | 1435 scoped_ptr<wallet::WalletItems> items = |
| 1433 wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED); | 1436 wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED); |
| 1434 items->AddAccount(wallet::GetTestGaiaAccount()); | 1437 items->AddAccount(wallet::GetTestGaiaAccount()); |
| 1435 items->AddInstrument(wallet::GetTestMaskedInstrument()); | 1438 items->AddInstrument(wallet::GetTestMaskedInstrument()); |
| 1436 items->AddAddress(wallet::GetTestShippingAddress()); | 1439 items->AddAddress(wallet::GetTestShippingAddress()); |
| 1437 controller()->OnDidGetWalletItems(items.Pass()); | 1440 controller()->OnDidGetWalletItems(items.Pass()); |
| 1438 | 1441 |
| 1439 EXPECT_TRUE(controller()->IsPayingWithWallet()); | 1442 EXPECT_TRUE(controller()->IsPayingWithWallet()); |
| 1440 | 1443 |
| 1441 // Select "Add new billing/shipping address...". | 1444 // Select "Add new shipping address...". |
| 1442 controller()->MenuModelForSection(SECTION_CC_BILLING)->ActivatedAt(1); | |
| 1443 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(2); | 1445 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(2); |
| 1444 | 1446 |
| 1445 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); | 1447 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); |
| 1446 ASSERT_EQ(ASCIIToUTF16("United States"), | 1448 ASSERT_EQ(ASCIIToUTF16("United States"), |
| 1447 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY)); | |
| 1448 ASSERT_EQ(ASCIIToUTF16("United States"), | |
| 1449 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); | 1449 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); |
| 1450 | 1450 |
| 1451 // Switch both billing and shipping countries. | 1451 // Switch the shipping country. |
| 1452 view->SetTextContentsOfInput(ADDRESS_BILLING_COUNTRY, ASCIIToUTF16("China")); | 1452 view->SetTextContentsOfInput(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("China")); |
| 1453 view->ActivateInput(ADDRESS_BILLING_COUNTRY); | |
| 1454 view->SetTextContentsOfInput(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("France")); | |
| 1455 view->ActivateInput(ADDRESS_HOME_COUNTRY); | 1453 view->ActivateInput(ADDRESS_HOME_COUNTRY); |
| 1456 | 1454 |
| 1457 // Switch to using Autofill instead of Wallet. | 1455 // Switch to using Autofill instead of Wallet. |
| 1458 ui::MenuModel* account_chooser = controller()->MenuModelForAccountChooser(); | 1456 ui::MenuModel* account_chooser = controller()->MenuModelForAccountChooser(); |
| 1459 account_chooser->ActivatedAt(account_chooser->GetItemCount() - 1); | 1457 account_chooser->ActivatedAt(account_chooser->GetItemCount() - 1); |
| 1460 | 1458 |
| 1461 EXPECT_FALSE(controller()->IsPayingWithWallet()); | 1459 EXPECT_FALSE(controller()->IsPayingWithWallet()); |
| 1462 | 1460 |
| 1463 // Countries should have stayed the same. | 1461 // Shipping country should have stayed the same. |
| 1464 EXPECT_EQ(ASCIIToUTF16("China"), | 1462 EXPECT_EQ(ASCIIToUTF16("China"), |
| 1465 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY)); | |
| 1466 EXPECT_EQ(ASCIIToUTF16("France"), | |
| 1467 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); | 1463 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); |
| 1468 | 1464 |
| 1469 ASSERT_TRUE( | 1465 ASSERT_TRUE( |
| 1470 SectionHasField(SECTION_BILLING, ADDRESS_BILLING_DEPENDENT_LOCALITY)); | 1466 SectionHasField(SECTION_SHIPPING, ADDRESS_HOME_DEPENDENT_LOCALITY)); |
| 1471 | 1467 |
| 1472 view->SetTextContentsOfInput(ADDRESS_BILLING_COUNTRY, | 1468 controller()->MenuModelForSection(SECTION_BILLING)->ActivatedAt(1); |
| 1473 ASCIIToUTF16("Antarctica")); | 1469 view->SetTextContentsOfInput(ADDRESS_BILLING_COUNTRY, ASCIIToUTF16("China")); |
| 1474 view->ActivateInput(ADDRESS_BILLING_COUNTRY); | 1470 view->ActivateInput(ADDRESS_BILLING_COUNTRY); |
| 1471 EXPECT_EQ(ASCIIToUTF16("China"), | |
| 1472 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY)); | |
|
Dan Beam
2014/02/11 20:21:45
\n
| |
| 1473 // Switch back to Wallet. Country should go back to US. | |
| 1474 account_chooser->ActivatedAt(0); | |
| 1475 EXPECT_EQ(ASCIIToUTF16("United States"), | |
| 1476 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY)); | |
| 1475 | 1477 |
| 1476 // Select the first Wallet account. | 1478 // Make sure shipping is still on China. |
| 1477 account_chooser->ActivatedAt(0); | 1479 EXPECT_EQ(ASCIIToUTF16("China"), |
| 1478 ASSERT_TRUE(controller()->IsManuallyEditingSection(SECTION_CC_BILLING)); | 1480 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); |
|
Dan Beam
2014/02/11 20:21:45
EXPECT_FALSE(
SectionHasField(SECTION_CC_BILLI
| |
| 1479 | |
| 1480 // Verify that inputs are rebuilt for billing sections across changes. | |
| 1481 EXPECT_FALSE( | |
| 1482 SectionHasField(SECTION_CC_BILLING, ADDRESS_BILLING_DEPENDENT_LOCALITY)); | |
| 1483 } | 1481 } |
| 1484 | 1482 |
| 1485 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerI18nTest, AddNewResetsCountry) { | 1483 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerI18nTest, AddNewResetsCountry) { |
| 1486 AutofillProfile verified_profile(test::GetVerifiedProfile()); | 1484 AutofillProfile verified_profile(test::GetVerifiedProfile()); |
| 1487 controller()->GetTestingManager()->AddTestingProfile(&verified_profile); | 1485 controller()->GetTestingManager()->AddTestingProfile(&verified_profile); |
| 1488 | 1486 |
| 1489 // Select "Add new billing/shipping address...". | 1487 // Select "Add new billing/shipping address...". |
| 1490 controller()->MenuModelForSection(SECTION_BILLING)->ActivatedAt(1); | 1488 controller()->MenuModelForSection(SECTION_BILLING)->ActivatedAt(1); |
| 1491 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(2); | 1489 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(2); |
| 1492 | 1490 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1560 ASSERT_EQ(NAME_FULL, controller()->popup_input_type()); | 1558 ASSERT_EQ(NAME_FULL, controller()->popup_input_type()); |
| 1561 controller()->DidAcceptSuggestion(base::string16(), 0); | 1559 controller()->DidAcceptSuggestion(base::string16(), 0); |
| 1562 | 1560 |
| 1563 EXPECT_EQ(ASCIIToUTF16("France"), | 1561 EXPECT_EQ(ASCIIToUTF16("France"), |
| 1564 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY)); | 1562 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY)); |
| 1565 EXPECT_EQ(ASCIIToUTF16("Belarus"), | 1563 EXPECT_EQ(ASCIIToUTF16("Belarus"), |
| 1566 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); | 1564 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); |
| 1567 } | 1565 } |
| 1568 | 1566 |
| 1569 } // namespace autofill | 1567 } // namespace autofill |
| OLD | NEW |