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

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

Issue 106033007: Disable wallet in countries where it's not supported, take 2. (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 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 <map> 5 #include <map>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/guid.h" 9 #include "base/guid.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 2604 matching lines...) Expand 10 before | Expand all | Expand 10 after
2615 if (inputs[j].type == CREDIT_CARD_NUMBER) 2615 if (inputs[j].type == CREDIT_CARD_NUMBER)
2616 EXPECT_FALSE(controller()->InputIsEditable(inputs[j], sections[i])); 2616 EXPECT_FALSE(controller()->InputIsEditable(inputs[j], sections[i]));
2617 else 2617 else
2618 EXPECT_TRUE(controller()->InputIsEditable(inputs[j], sections[i])); 2618 EXPECT_TRUE(controller()->InputIsEditable(inputs[j], sections[i]));
2619 } 2619 }
2620 } 2620 }
2621 } 2621 }
2622 2622
2623 // When the default country is something besides US, wallet is not selected 2623 // When the default country is something besides US, wallet is not selected
2624 // and the account chooser shouldn't be visible. 2624 // and the account chooser shouldn't be visible.
2625 // TODO(estade): this is disabled until http://crbug.com/323641 is fixed. 2625 TEST_F(AutofillDialogControllerTest, HideWalletInOtherCountries) {
2626 TEST_F(AutofillDialogControllerTest, DISABLED_HideWalletInOtherCountries) { 2626 // Addresses from different countries.
2627 AutofillProfile us_profile(base::GenerateGUID(), kSettingsOrigin),
2628 es_profile(base::GenerateGUID(), kSettingsOrigin),
2629 es_profile2(base::GenerateGUID(), kSettingsOrigin);
2630 us_profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"));
2631 es_profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("ES"));
2632 es_profile2.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("ES"));
2633
2634 // If US is indicated (via timezone), show Wallet.
2627 ResetControllerWithFormData(DefaultFormData()); 2635 ResetControllerWithFormData(DefaultFormData());
2628 controller()->GetTestingManager()->set_default_country_code("US"); 2636 controller()->GetTestingManager()->set_timezone_country_code("US");
2629 controller()->Show(); 2637 controller()->Show();
2630 EXPECT_TRUE( 2638 EXPECT_TRUE(
2631 controller()->AccountChooserModelForTesting()->WalletIsSelected()); 2639 controller()->AccountChooserModelForTesting()->WalletIsSelected());
2632 controller()->OnDidFetchWalletCookieValue(std::string()); 2640 controller()->OnDidFetchWalletCookieValue(std::string());
2633 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems()); 2641 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems());
2634 EXPECT_TRUE(controller()->ShouldShowAccountChooser()); 2642 EXPECT_TRUE(controller()->ShouldShowAccountChooser());
2635 EXPECT_TRUE( 2643 EXPECT_TRUE(
2636 controller()->AccountChooserModelForTesting()->WalletIsSelected()); 2644 controller()->AccountChooserModelForTesting()->WalletIsSelected());
2637 2645
2646 // If US is not indicated, don't show Wallet.
2638 ResetControllerWithFormData(DefaultFormData()); 2647 ResetControllerWithFormData(DefaultFormData());
2639 controller()->GetTestingManager()->set_default_country_code("ES"); 2648 controller()->GetTestingManager()->set_timezone_country_code("ES");
2640 controller()->Show(); 2649 controller()->Show();
2650 controller()->OnDidFetchWalletCookieValue(std::string());
2651 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems());
2641 EXPECT_FALSE(controller()->ShouldShowAccountChooser()); 2652 EXPECT_FALSE(controller()->ShouldShowAccountChooser());
2642 EXPECT_FALSE( 2653
2654 // If US is indicated (via a profile), show Wallet.
2655 ResetControllerWithFormData(DefaultFormData());
2656 controller()->GetTestingManager()->set_timezone_country_code("ES");
2657 controller()->GetTestingManager()->AddTestingProfile(&us_profile);
2658 controller()->Show();
2659 controller()->OnDidFetchWalletCookieValue(std::string());
2660 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems());
2661 EXPECT_TRUE(controller()->ShouldShowAccountChooser());
2662 EXPECT_TRUE(
2663 controller()->AccountChooserModelForTesting()->WalletIsSelected());
2664
2665 // Make sure the profile doesn't just override the timezone.
2666 ResetControllerWithFormData(DefaultFormData());
2667 controller()->GetTestingManager()->set_timezone_country_code("US");
2668 controller()->GetTestingManager()->AddTestingProfile(&es_profile);
2669 controller()->Show();
2670 controller()->OnDidFetchWalletCookieValue(std::string());
2671 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems());
2672 EXPECT_TRUE(controller()->ShouldShowAccountChooser());
2673 EXPECT_TRUE(
2674 controller()->AccountChooserModelForTesting()->WalletIsSelected());
2675
2676 // Only takes one US address to enable Wallet.
2677 ResetControllerWithFormData(DefaultFormData());
2678 controller()->GetTestingManager()->set_timezone_country_code("FR");
2679 controller()->GetTestingManager()->AddTestingProfile(&es_profile);
2680 controller()->GetTestingManager()->AddTestingProfile(&es_profile2);
2681 controller()->GetTestingManager()->AddTestingProfile(&us_profile);
2682 controller()->Show();
2683 controller()->OnDidFetchWalletCookieValue(std::string());
2684 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems());
2685 EXPECT_TRUE(controller()->ShouldShowAccountChooser());
2686 EXPECT_TRUE(
2643 controller()->AccountChooserModelForTesting()->WalletIsSelected()); 2687 controller()->AccountChooserModelForTesting()->WalletIsSelected());
2644 } 2688 }
2645 2689
2646 TEST_F(AutofillDialogControllerTest, DontGetWalletTillNecessary) { 2690 TEST_F(AutofillDialogControllerTest, DontGetWalletTillNecessary) {
2647 // When starting on local data mode, the dialog will provide a "Use Google 2691 // When starting on local data mode, the dialog will provide a "Use Google
2648 // Wallet" link. 2692 // Wallet" link.
2649 profile()->GetPrefs()->SetBoolean( 2693 profile()->GetPrefs()->SetBoolean(
2650 ::prefs::kAutofillDialogPayWithoutWallet, true); 2694 ::prefs::kAutofillDialogPayWithoutWallet, true);
2651 ResetControllerWithFormData(DefaultFormData()); 2695 ResetControllerWithFormData(DefaultFormData());
2652 controller()->Show(); 2696 controller()->Show();
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
2763 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 2807 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
2764 for (size_t i = 0; i < arraysize(kSupportedCardIdrs); ++i) { 2808 for (size_t i = 0; i < arraysize(kSupportedCardIdrs); ++i) {
2765 SCOPED_TRACE(base::IntToString(i)); 2809 SCOPED_TRACE(base::IntToString(i));
2766 gfx::Image supported_card_icon = rb.GetImageNamed(kSupportedCardIdrs[i]); 2810 gfx::Image supported_card_icon = rb.GetImageNamed(kSupportedCardIdrs[i]);
2767 EXPECT_GE(placeholder_icon.Width(), supported_card_icon.Width()); 2811 EXPECT_GE(placeholder_icon.Width(), supported_card_icon.Width());
2768 EXPECT_GE(placeholder_icon.Height(), supported_card_icon.Height()); 2812 EXPECT_GE(placeholder_icon.Height(), supported_card_icon.Height());
2769 } 2813 }
2770 } 2814 }
2771 2815
2772 } // namespace autofill 2816 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698