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 "components/autofill/core/browser/autofill_cc_infobar_delegate.h" | 5 #include "components/autofill/core/browser/autofill_cc_infobar_delegate.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/test/histogram_tester.h" | 9 #include "base/test/histogram_tester.h" |
10 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 10 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 scoped_ptr<ConfirmInfoBarDelegate> | 89 scoped_ptr<ConfirmInfoBarDelegate> |
90 AutofillCCInfobarDelegateTest::CreateDelegate() { | 90 AutofillCCInfobarDelegateTest::CreateDelegate() { |
91 base::HistogramTester histogram_tester; | 91 base::HistogramTester histogram_tester; |
92 CreditCard credit_card; | 92 CreditCard credit_card; |
93 scoped_ptr<ConfirmInfoBarDelegate> delegate(AutofillCCInfoBarDelegate::Create( | 93 scoped_ptr<ConfirmInfoBarDelegate> delegate(AutofillCCInfoBarDelegate::Create( |
94 base::Bind( | 94 base::Bind( |
95 base::IgnoreResult(&TestPersonalDataManager::SaveImportedCreditCard), | 95 base::IgnoreResult(&TestPersonalDataManager::SaveImportedCreditCard), |
96 base::Unretained(personal_data_.get()), credit_card))); | 96 base::Unretained(personal_data_.get()), credit_card))); |
97 histogram_tester.ExpectUniqueSample("Autofill.CreditCardInfoBar", | 97 histogram_tester.ExpectUniqueSample("Autofill.CreditCardInfoBar", |
98 AutofillMetrics::INFOBAR_SHOWN, 1); | 98 AutofillMetrics::INFOBAR_SHOWN, 1); |
99 return delegate.Pass(); | 99 return delegate; |
100 } | 100 } |
101 | 101 |
102 // Test that credit card infobar metrics are logged correctly. | 102 // Test that credit card infobar metrics are logged correctly. |
103 TEST_F(AutofillCCInfobarDelegateTest, Metrics) { | 103 TEST_F(AutofillCCInfobarDelegateTest, Metrics) { |
104 ::testing::InSequence dummy; | 104 ::testing::InSequence dummy; |
105 | 105 |
106 // Accept the infobar. | 106 // Accept the infobar. |
107 { | 107 { |
108 scoped_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate()); | 108 scoped_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate()); |
109 EXPECT_CALL(*personal_data_, SaveImportedCreditCard(_)); | 109 EXPECT_CALL(*personal_data_, SaveImportedCreditCard(_)); |
(...skipping 29 matching lines...) Expand all Loading... |
139 scoped_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate()); | 139 scoped_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate()); |
140 | 140 |
141 base::HistogramTester histogram_tester; | 141 base::HistogramTester histogram_tester; |
142 infobar.reset(); | 142 infobar.reset(); |
143 histogram_tester.ExpectUniqueSample("Autofill.CreditCardInfoBar", | 143 histogram_tester.ExpectUniqueSample("Autofill.CreditCardInfoBar", |
144 AutofillMetrics::INFOBAR_IGNORED, 1); | 144 AutofillMetrics::INFOBAR_IGNORED, 1); |
145 } | 145 } |
146 } | 146 } |
147 | 147 |
148 } // namespace autofill | 148 } // namespace autofill |
OLD | NEW |