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

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

Issue 21668003: Implement newly saved card bubble for realz and update generated card bubble to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 5 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_unittest.cc
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
index 8d7b8362c69ff834e67fbf1a066ad0acb6d9094f..08d292f71d2b7d098ee1f1597ae41d5e9d803b9f 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
@@ -285,7 +285,8 @@ class TestAutofillCreditCardBubbleController :
public:
explicit TestAutofillCreditCardBubbleController(
content::WebContents* contents)
- : AutofillCreditCardBubbleController(contents) {
+ : AutofillCreditCardBubbleController(contents),
+ new_card_bubbles_shown_(0) {
contents->SetUserData(UserDataKey(), this);
CHECK_EQ(contents->GetUserData(UserDataKey()), this);
}
@@ -295,10 +296,19 @@ class TestAutofillCreditCardBubbleController :
MOCK_METHOD2(ShowAsGeneratedCardBubble,
void(const base::string16& backing_card_name,
const base::string16& fronting_card_name));
- MOCK_METHOD1(ShowAsNewCardSavedBubble,
- void(const base::string16& newly_saved_card_name));
+
+ int new_card_bubbles_shown() const { return new_card_bubbles_shown_; }
+ const CreditCard* new_card() const { return new_card_.get(); }
protected:
+ virtual void ShowAsNewCardSavedBubble(
+ scoped_ptr<CreditCard> new_card,
+ scoped_ptr<AutofillProfile> billing_profile) OVERRIDE {
+ ++new_card_bubbles_shown_;
+ new_card_ = new_card.Pass();
+ // At the moment there's no keep |billing_profile|.
+ }
+
virtual base::WeakPtr<AutofillCreditCardBubble> CreateBubble() OVERRIDE {
return TestAutofillCreditCardBubble::Create(GetWeakPtr());
}
@@ -308,6 +318,12 @@ class TestAutofillCreditCardBubbleController :
}
private:
+ // The number of new card saved bubble shown through this class.
+ int new_card_bubbles_shown_;
+
+ // The last credit card and billing info shown in a new card bubble.
+ scoped_ptr<CreditCard> new_card_;
+
DISALLOW_COPY_AND_ASSIGN(TestAutofillCreditCardBubbleController);
};
@@ -2290,24 +2306,27 @@ TEST_F(AutofillDialogControllerTest, DetailedSteps) {
TEST_F(AutofillDialogControllerTest, NewCardBubbleShown) {
EXPECT_CALL(*test_bubble_controller(),
- ShowAsNewCardSavedBubble(ASCIIToUTF16("Visa - 1111"))).Times(1);
- EXPECT_CALL(*test_bubble_controller(),
ShowAsGeneratedCardBubble(_, _)).Times(0);
SwitchToAutofill();
FillCreditCardInputs();
controller()->OnAccept();
controller()->ViewClosed();
+
+ EXPECT_EQ(1, test_bubble_controller()->new_card_bubbles_shown());
+ EXPECT_EQ(ASCIIToUTF16("Visa - 4111"),
+ test_bubble_controller()->new_card()->TypeAndLastFourDigits());
}
TEST_F(AutofillDialogControllerTest, GeneratedCardBubbleShown) {
EXPECT_CALL(*test_bubble_controller(),
ShowAsGeneratedCardBubble(_, _)).Times(1);
- EXPECT_CALL(*test_bubble_controller(), ShowAsNewCardSavedBubble(_)).Times(0);
SubmitWithWalletItems(CompleteAndValidWalletItems());
controller()->OnDidGetFullWallet(wallet::GetTestFullWallet());
controller()->ViewClosed();
+
+ EXPECT_EQ(0, test_bubble_controller()->new_card_bubbles_shown());
}
TEST_F(AutofillDialogControllerTest, ReloadWalletItemsOnActivation) {
@@ -2385,13 +2404,14 @@ TEST_F(AutofillDialogControllerTest, ReloadWithEmptyWalletItems) {
TEST_F(AutofillDialogControllerTest, GeneratedCardBubbleNotShown) {
EXPECT_CALL(*test_bubble_controller(),
ShowAsGeneratedCardBubble(_, _)).Times(0);
- EXPECT_CALL(*test_bubble_controller(), ShowAsNewCardSavedBubble(_)).Times(0);
SubmitWithWalletItems(CompleteAndValidWalletItems());
controller()->set_dialog_type(DIALOG_TYPE_AUTOCHECKOUT);
controller()->OnDidGetFullWallet(wallet::GetTestFullWallet());
controller()->OnAutocheckoutError();
controller()->ViewClosed();
+
+ EXPECT_EQ(0, test_bubble_controller()->new_card_bubbles_shown());
}
} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698