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 |