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

Side by Side Diff: chrome/browser/autofill/autofill_cc_infobar_delegate_unittest.cc

Issue 710453002: [Autofill] Componentize AutofillCCInfoBarDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Return nullptr for CreateInfoBar() in test_autofill_client.cc. Created 6 years 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 unified diff | Download patch
OLDNEW
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/autofill/autofill_cc_infobar_delegate.h" 5 #include "components/autofill/core/browser/autofill_cc_infobar_delegate.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "chrome/browser/autofill/personal_data_manager_factory.h" 8 #include "chrome/browser/autofill/personal_data_manager_factory.h"
9 #include "chrome/browser/ui/autofill/chrome_autofill_client.h" 9 #include "chrome/browser/ui/autofill/chrome_autofill_client.h"
10 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 10 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
11 #include "chrome/test/base/testing_profile.h" 11 #include "chrome/test/base/testing_profile.h"
12 #include "components/autofill/content/browser/content_autofill_driver.h"
12 #include "components/autofill/core/browser/autofill_metrics.h" 13 #include "components/autofill/core/browser/autofill_metrics.h"
13 #include "components/autofill/core/browser/autofill_test_utils.h" 14 #include "components/autofill/core/browser/autofill_test_utils.h"
14 #include "components/autofill/core/browser/personal_data_manager.h" 15 #include "components/autofill/core/browser/personal_data_manager.h"
15 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 18
18 using testing::_; 19 using testing::_;
19 20
20 namespace autofill { 21 namespace autofill {
21 22
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 } 90 }
90 91
91 scoped_ptr<ConfirmInfoBarDelegate> 92 scoped_ptr<ConfirmInfoBarDelegate>
92 AutofillCCInfobarDelegateTest::CreateDelegate( 93 AutofillCCInfobarDelegateTest::CreateDelegate(
93 MockAutofillMetrics* metric_logger) { 94 MockAutofillMetrics* metric_logger) {
94 EXPECT_CALL(*metric_logger, 95 EXPECT_CALL(*metric_logger,
95 LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN)); 96 LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN));
96 97
97 CreditCard credit_card; 98 CreditCard credit_card;
98 return AutofillCCInfoBarDelegate::Create( 99 return AutofillCCInfoBarDelegate::Create(
99 metric_logger, 100 ContentAutofillDriver::FromWebContents(web_contents()), metric_logger,
100 base::Bind( 101 base::Bind(
101 base::IgnoreResult(&TestPersonalDataManager::SaveImportedCreditCard), 102 base::IgnoreResult(&TestPersonalDataManager::SaveImportedCreditCard),
102 base::Unretained(personal_data_.get()), 103 base::Unretained(personal_data_.get()), credit_card));
103 credit_card));
104 } 104 }
105 105
106 // Test that credit card infobar metrics are logged correctly. 106 // Test that credit card infobar metrics are logged correctly.
107 TEST_F(AutofillCCInfobarDelegateTest, Metrics) { 107 TEST_F(AutofillCCInfobarDelegateTest, Metrics) {
108 MockAutofillMetrics metric_logger; 108 MockAutofillMetrics metric_logger;
109 ::testing::InSequence dummy; 109 ::testing::InSequence dummy;
110 110
111 // Accept the infobar. 111 // Accept the infobar.
112 { 112 {
113 scoped_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate(&metric_logger)); 113 scoped_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate(&metric_logger));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 { 152 {
153 scoped_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate(&metric_logger)); 153 scoped_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate(&metric_logger));
154 ASSERT_TRUE(infobar); 154 ASSERT_TRUE(infobar);
155 EXPECT_CALL(metric_logger, 155 EXPECT_CALL(metric_logger,
156 LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_IGNORED)) 156 LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_IGNORED))
157 .Times(1); 157 .Times(1);
158 } 158 }
159 } 159 }
160 160
161 } // namespace autofill 161 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698