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

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

Issue 2789843004: [Payments] Upload card UI now has a CVC prompt (Closed)
Patch Set: Addressing code review comments Created 3 years, 8 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/save_card_bubble_controller_impl_unittest.cc
diff --git a/chrome/browser/ui/autofill/save_card_bubble_controller_impl_unittest.cc b/chrome/browser/ui/autofill/save_card_bubble_controller_impl_unittest.cc
index 9689355727f31bdfc495d4582a57f41668b0298f..28ade5d18feda7763c5269036b946bc6b884e853 100644
--- a/chrome/browser/ui/autofill/save_card_bubble_controller_impl_unittest.cc
+++ b/chrome/browser/ui/autofill/save_card_bubble_controller_impl_unittest.cc
@@ -69,7 +69,8 @@ class SaveCardBubbleControllerImplTest : public BrowserWithTestWindowTest {
return new SaveCardBubbleTestBrowserWindow();
}
- void SetLegalMessage(const std::string& message_json) {
+ void SetLegalMessage(const std::string& message_json,
+ bool should_cvc_be_requested) {
Evan Stade 2017/04/10 18:32:09 you can give this a default value
Jared Saul 2017/04/11 00:53:06 Done.
std::unique_ptr<base::Value> value(base::JSONReader::Read(message_json));
ASSERT_TRUE(value);
base::DictionaryValue* dictionary;
@@ -77,6 +78,7 @@ class SaveCardBubbleControllerImplTest : public BrowserWithTestWindowTest {
std::unique_ptr<base::DictionaryValue> legal_message =
dictionary->CreateDeepCopy();
controller()->ShowBubbleForUpload(CreditCard(), std::move(legal_message),
+ should_cvc_be_requested,
base::Bind(&SaveCardCallback));
}
@@ -85,13 +87,14 @@ class SaveCardBubbleControllerImplTest : public BrowserWithTestWindowTest {
base::Bind(&SaveCardCallback));
}
- void ShowUploadBubble() {
+ void ShowUploadBubble(bool should_cvc_be_requested) {
SetLegalMessage(
"{"
" \"line\" : [ {"
" \"template\": \"This is the entire message.\""
" } ]"
- "}");
+ "}",
+ should_cvc_be_requested);
}
void CloseAndReshowBubble() {
@@ -134,12 +137,24 @@ class SaveCardBubbleControllerImplTest : public BrowserWithTestWindowTest {
// Tests that the legal message lines vector is empty when doing a local save so
// that no legal messages will be shown to the user in that case.
TEST_F(SaveCardBubbleControllerImplTest, LegalMessageLinesEmptyOnLocalSave) {
- ShowUploadBubble();
+ ShowUploadBubble(false /* should_cvc_be_requested */);
controller()->OnBubbleClosed();
ShowLocalBubble();
EXPECT_TRUE(controller()->GetLegalMessageLines().empty());
}
+TEST_F(SaveCardBubbleControllerImplTest,
+ PropagateShouldRequestCvcFromUserWhenFalse) {
+ ShowUploadBubble(false /* should_cvc_be_requested */);
+ EXPECT_FALSE(controller()->ShouldRequestCvcFromUser());
+}
+
+TEST_F(SaveCardBubbleControllerImplTest,
+ PropagateShouldRequestCvcFromUserWhenTrue) {
+ ShowUploadBubble(true /* should_cvc_be_requested */);
+ EXPECT_TRUE(controller()->ShouldRequestCvcFromUser());
+}
+
TEST_F(SaveCardBubbleControllerImplTest, Metrics_Local_FirstShow_ShowBubble) {
base::HistogramTester histogram_tester;
ShowLocalBubble();
@@ -164,9 +179,22 @@ TEST_F(SaveCardBubbleControllerImplTest, Metrics_Local_Reshows_ShowBubble) {
Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOWN, 1)));
}
-TEST_F(SaveCardBubbleControllerImplTest, Metrics_Upload_FirstShow_ShowBubble) {
+TEST_F(SaveCardBubbleControllerImplTest,
+ Metrics_Upload_FirstShow_ShowBubble_NotRequestCvc) {
+ base::HistogramTester histogram_tester;
+ ShowUploadBubble(false /* should_cvc_be_requested */);
+
+ EXPECT_THAT(
+ histogram_tester.GetAllSamples(
+ "Autofill.SaveCreditCardPrompt.Upload.FirstShow"),
+ ElementsAre(Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, 1),
+ Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOWN, 1)));
+}
+
+TEST_F(SaveCardBubbleControllerImplTest,
+ Metrics_Upload_FirstShow_ShowBubble_RequestCvc) {
base::HistogramTester histogram_tester;
- ShowUploadBubble();
+ ShowUploadBubble(true /* should_cvc_be_requested */);
EXPECT_THAT(
histogram_tester.GetAllSamples(
@@ -176,7 +204,7 @@ TEST_F(SaveCardBubbleControllerImplTest, Metrics_Upload_FirstShow_ShowBubble) {
}
TEST_F(SaveCardBubbleControllerImplTest, Metrics_Upload_Reshows_ShowBubble) {
- ShowUploadBubble();
+ ShowUploadBubble(false /* should_cvc_be_requested */);
base::HistogramTester histogram_tester;
CloseAndReshowBubble();
@@ -300,7 +328,7 @@ TEST_F(SaveCardBubbleControllerImplTest,
}
TEST_F(SaveCardBubbleControllerImplTest, Metrics_Upload_FirstShow_LearnMore) {
- ShowUploadBubble();
+ ShowUploadBubble(false /* should_cvc_be_requested */);
base::HistogramTester histogram_tester;
controller()->OnLearnMoreClicked();
@@ -311,7 +339,7 @@ TEST_F(SaveCardBubbleControllerImplTest, Metrics_Upload_FirstShow_LearnMore) {
}
TEST_F(SaveCardBubbleControllerImplTest, Metrics_Upload_Reshows_LearnMore) {
- ShowUploadBubble();
+ ShowUploadBubble(false /* should_cvc_be_requested */);
CloseAndReshowBubble();
base::HistogramTester histogram_tester;
@@ -324,7 +352,7 @@ TEST_F(SaveCardBubbleControllerImplTest, Metrics_Upload_Reshows_LearnMore) {
TEST_F(SaveCardBubbleControllerImplTest,
Metrics_Upload_FirstShow_LegalMessageLink) {
- ShowUploadBubble();
+ ShowUploadBubble(false /* should_cvc_be_requested */);
base::HistogramTester histogram_tester;
controller()->OnLegalMessageLinkClicked(GURL("http://www.example.com"));
@@ -336,7 +364,7 @@ TEST_F(SaveCardBubbleControllerImplTest,
TEST_F(SaveCardBubbleControllerImplTest,
Metrics_Upload_Reshows_LegalMessageLink) {
- ShowUploadBubble();
+ ShowUploadBubble(false /* should_cvc_be_requested */);
CloseAndReshowBubble();
base::HistogramTester histogram_tester;
@@ -362,7 +390,8 @@ TEST_F(SaveCardBubbleControllerImplTest,
" \"display_text\": \"bear\""
" } ]"
" } ]"
- "}");
+ "}",
+ false /* should_cvc_be_requested */);
EXPECT_THAT(
histogram_tester.GetAllSamples(

Powered by Google App Engine
This is Rietveld 408576698