| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/ui/autofill/save_card_bubble_controller_impl.h" | 5 #include "chrome/browser/ui/autofill/save_card_bubble_controller_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/test/histogram_tester.h" | 14 #include "base/test/histogram_tester.h" |
| 15 #include "base/test/scoped_feature_list.h" |
| 15 #include "base/values.h" | 16 #include "base/values.h" |
| 16 #include "chrome/browser/ui/autofill/save_card_bubble_view.h" | 17 #include "chrome/browser/ui/autofill/save_card_bubble_view.h" |
| 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 18 #include "chrome/test/base/browser_with_test_window_test.h" | 19 #include "chrome/test/base/browser_with_test_window_test.h" |
| 19 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 20 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 21 #include "components/autofill/core/browser/autofill_experiments.h" |
| 20 #include "components/autofill/core/browser/autofill_metrics.h" | 22 #include "components/autofill/core/browser/autofill_metrics.h" |
| 21 #include "components/autofill/core/browser/autofill_test_utils.h" | 23 #include "components/autofill/core/browser/autofill_test_utils.h" |
| 22 #include "components/autofill/core/browser/credit_card.h" | 24 #include "components/autofill/core/browser/credit_card.h" |
| 23 #include "components/autofill/core/common/autofill_pref_names.h" | 25 #include "components/autofill/core/common/autofill_pref_names.h" |
| 24 #include "components/user_prefs/user_prefs.h" | 26 #include "components/user_prefs/user_prefs.h" |
| 25 #include "content/public/browser/navigation_handle.h" | 27 #include "content/public/browser/navigation_handle.h" |
| 26 #include "testing/gmock/include/gmock/gmock.h" | 28 #include "testing/gmock/include/gmock/gmock.h" |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
| 28 | 30 |
| 29 using base::Bucket; | 31 using base::Bucket; |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 | 529 |
| 528 base::HistogramTester histogram_tester; | 530 base::HistogramTester histogram_tester; |
| 529 controller()->OnLearnMoreClicked(); | 531 controller()->OnLearnMoreClicked(); |
| 530 | 532 |
| 531 histogram_tester.ExpectUniqueSample( | 533 histogram_tester.ExpectUniqueSample( |
| 532 "Autofill.SaveCreditCardPrompt.Local.Reshows", | 534 "Autofill.SaveCreditCardPrompt.Local.Reshows", |
| 533 AutofillMetrics::SAVE_CARD_PROMPT_DISMISS_CLICK_LEARN_MORE, 1); | 535 AutofillMetrics::SAVE_CARD_PROMPT_DISMISS_CLICK_LEARN_MORE, 1); |
| 534 } | 536 } |
| 535 | 537 |
| 536 TEST_F(SaveCardBubbleControllerImplTest, Metrics_Upload_FirstShow_LearnMore) { | 538 TEST_F(SaveCardBubbleControllerImplTest, Metrics_Upload_FirstShow_LearnMore) { |
| 539 // Learn More link only appears on upload if new UI is disabled. |
| 540 base::test::ScopedFeatureList scoped_feature_list_; |
| 541 scoped_feature_list_.InitAndDisableFeature(kAutofillUpstreamShowNewUi); |
| 542 |
| 537 ShowUploadBubble(); | 543 ShowUploadBubble(); |
| 538 | 544 |
| 539 base::HistogramTester histogram_tester; | 545 base::HistogramTester histogram_tester; |
| 540 controller()->OnLearnMoreClicked(); | 546 controller()->OnLearnMoreClicked(); |
| 541 | 547 |
| 542 histogram_tester.ExpectUniqueSample( | 548 histogram_tester.ExpectUniqueSample( |
| 543 "Autofill.SaveCreditCardPrompt.Upload.FirstShow", | 549 "Autofill.SaveCreditCardPrompt.Upload.FirstShow", |
| 544 AutofillMetrics::SAVE_CARD_PROMPT_DISMISS_CLICK_LEARN_MORE, 1); | 550 AutofillMetrics::SAVE_CARD_PROMPT_DISMISS_CLICK_LEARN_MORE, 1); |
| 545 } | 551 } |
| 546 | 552 |
| 547 TEST_F(SaveCardBubbleControllerImplTest, Metrics_Upload_Reshows_LearnMore) { | 553 TEST_F(SaveCardBubbleControllerImplTest, Metrics_Upload_Reshows_LearnMore) { |
| 554 // Learn More link only appears on upload if new UI is disabled. |
| 555 base::test::ScopedFeatureList scoped_feature_list_; |
| 556 scoped_feature_list_.InitAndDisableFeature(kAutofillUpstreamShowNewUi); |
| 557 |
| 548 ShowUploadBubble(); | 558 ShowUploadBubble(); |
| 549 CloseAndReshowBubble(); | 559 CloseAndReshowBubble(); |
| 550 | 560 |
| 551 base::HistogramTester histogram_tester; | 561 base::HistogramTester histogram_tester; |
| 552 controller()->OnLearnMoreClicked(); | 562 controller()->OnLearnMoreClicked(); |
| 553 | 563 |
| 554 histogram_tester.ExpectUniqueSample( | 564 histogram_tester.ExpectUniqueSample( |
| 555 "Autofill.SaveCreditCardPrompt.Upload.Reshows", | 565 "Autofill.SaveCreditCardPrompt.Upload.Reshows", |
| 556 AutofillMetrics::SAVE_CARD_PROMPT_DISMISS_CLICK_LEARN_MORE, 1); | 566 AutofillMetrics::SAVE_CARD_PROMPT_DISMISS_CLICK_LEARN_MORE, 1); |
| 557 } | 567 } |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 EXPECT_TRUE(controller()->InputCvcIsValid(base::ASCIIToUTF16("999"))); | 690 EXPECT_TRUE(controller()->InputCvcIsValid(base::ASCIIToUTF16("999"))); |
| 681 // 4-digit CVC: | 691 // 4-digit CVC: |
| 682 CreditCard amex = autofill::test::GetCreditCard2(); // Amex | 692 CreditCard amex = autofill::test::GetCreditCard2(); // Amex |
| 683 ShowLocalBubble(&amex); | 693 ShowLocalBubble(&amex); |
| 684 EXPECT_FALSE(controller()->InputCvcIsValid(base::ASCIIToUTF16("123"))); | 694 EXPECT_FALSE(controller()->InputCvcIsValid(base::ASCIIToUTF16("123"))); |
| 685 EXPECT_TRUE(controller()->InputCvcIsValid(base::ASCIIToUTF16("1234"))); | 695 EXPECT_TRUE(controller()->InputCvcIsValid(base::ASCIIToUTF16("1234"))); |
| 686 EXPECT_FALSE(controller()->InputCvcIsValid(base::ASCIIToUTF16("12345"))); | 696 EXPECT_FALSE(controller()->InputCvcIsValid(base::ASCIIToUTF16("12345"))); |
| 687 } | 697 } |
| 688 | 698 |
| 689 } // namespace autofill | 699 } // namespace autofill |
| OLD | NEW |