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

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

Issue 1857663002: chrome/browser/autofill: scoped_ptr -> unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments addressed Created 4 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 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 "components/autofill/core/browser/autofill_save_card_infobar_delegate_m obile.h" 5 #include <memory>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "base/test/histogram_tester.h" 8 #include "base/test/histogram_tester.h"
10 #include "chrome/browser/autofill/personal_data_manager_factory.h" 9 #include "chrome/browser/autofill/personal_data_manager_factory.h"
11 #include "chrome/browser/ui/autofill/chrome_autofill_client.h" 10 #include "chrome/browser/ui/autofill/chrome_autofill_client.h"
12 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 11 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
13 #include "chrome/test/base/testing_profile.h" 12 #include "chrome/test/base/testing_profile.h"
13 #include "components/autofill/core/browser/autofill_save_card_infobar_delegate_m obile.h"
14 #include "components/autofill/core/browser/autofill_test_utils.h" 14 #include "components/autofill/core/browser/autofill_test_utils.h"
15 #include "components/autofill/core/browser/personal_data_manager.h" 15 #include "components/autofill/core/browser/personal_data_manager.h"
16 #include "components/infobars/core/confirm_infobar_delegate.h" 16 #include "components/infobars/core/confirm_infobar_delegate.h"
17 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 19
20 using testing::_; 20 using testing::_;
21 21
22 namespace autofill { 22 namespace autofill {
23 23
(...skipping 22 matching lines...) Expand all
46 class AutofillSaveCardInfoBarDelegateMobileTest 46 class AutofillSaveCardInfoBarDelegateMobileTest
47 : public ChromeRenderViewHostTestHarness { 47 : public ChromeRenderViewHostTestHarness {
48 public: 48 public:
49 AutofillSaveCardInfoBarDelegateMobileTest(); 49 AutofillSaveCardInfoBarDelegateMobileTest();
50 ~AutofillSaveCardInfoBarDelegateMobileTest() override; 50 ~AutofillSaveCardInfoBarDelegateMobileTest() override;
51 51
52 void SetUp() override; 52 void SetUp() override;
53 void TearDown() override; 53 void TearDown() override;
54 54
55 protected: 55 protected:
56 scoped_ptr<ConfirmInfoBarDelegate> CreateDelegate(); 56 std::unique_ptr<ConfirmInfoBarDelegate> CreateDelegate();
57 57
58 scoped_ptr<TestPersonalDataManager> personal_data_; 58 std::unique_ptr<TestPersonalDataManager> personal_data_;
59 59
60 private: 60 private:
61 DISALLOW_COPY_AND_ASSIGN(AutofillSaveCardInfoBarDelegateMobileTest); 61 DISALLOW_COPY_AND_ASSIGN(AutofillSaveCardInfoBarDelegateMobileTest);
62 }; 62 };
63 63
64 AutofillSaveCardInfoBarDelegateMobileTest:: 64 AutofillSaveCardInfoBarDelegateMobileTest::
65 AutofillSaveCardInfoBarDelegateMobileTest() {} 65 AutofillSaveCardInfoBarDelegateMobileTest() {}
66 66
67 AutofillSaveCardInfoBarDelegateMobileTest:: 67 AutofillSaveCardInfoBarDelegateMobileTest::
68 ~AutofillSaveCardInfoBarDelegateMobileTest() {} 68 ~AutofillSaveCardInfoBarDelegateMobileTest() {}
(...skipping 10 matching lines...) Expand all
79 personal_data_.reset(new TestPersonalDataManager()); 79 personal_data_.reset(new TestPersonalDataManager());
80 personal_data_->set_database(autofill_client->GetDatabase()); 80 personal_data_->set_database(autofill_client->GetDatabase());
81 personal_data_->SetPrefService(profile()->GetPrefs()); 81 personal_data_->SetPrefService(profile()->GetPrefs());
82 } 82 }
83 83
84 void AutofillSaveCardInfoBarDelegateMobileTest::TearDown() { 84 void AutofillSaveCardInfoBarDelegateMobileTest::TearDown() {
85 personal_data_.reset(); 85 personal_data_.reset();
86 ChromeRenderViewHostTestHarness::TearDown(); 86 ChromeRenderViewHostTestHarness::TearDown();
87 } 87 }
88 88
89 scoped_ptr<ConfirmInfoBarDelegate> 89 std::unique_ptr<ConfirmInfoBarDelegate>
90 AutofillSaveCardInfoBarDelegateMobileTest::CreateDelegate() { 90 AutofillSaveCardInfoBarDelegateMobileTest::CreateDelegate() {
91 base::HistogramTester histogram_tester; 91 base::HistogramTester histogram_tester;
92 CreditCard credit_card; 92 CreditCard credit_card;
93 scoped_ptr<base::DictionaryValue> legal_message; 93 std::unique_ptr<base::DictionaryValue> legal_message;
94 scoped_ptr<ConfirmInfoBarDelegate> delegate( 94 std::unique_ptr<ConfirmInfoBarDelegate> delegate(
95 new AutofillSaveCardInfoBarDelegateMobile( 95 new AutofillSaveCardInfoBarDelegateMobile(
96 false, credit_card, std::move(legal_message), 96 false, credit_card, std::move(legal_message),
97 base::Bind(base::IgnoreResult( 97 base::Bind(base::IgnoreResult(
98 &TestPersonalDataManager::SaveImportedCreditCard), 98 &TestPersonalDataManager::SaveImportedCreditCard),
99 base::Unretained(personal_data_.get()), credit_card))); 99 base::Unretained(personal_data_.get()), credit_card)));
100 histogram_tester.ExpectUniqueSample("Autofill.CreditCardInfoBar", 100 histogram_tester.ExpectUniqueSample("Autofill.CreditCardInfoBar",
101 AutofillMetrics::INFOBAR_SHOWN, 1); 101 AutofillMetrics::INFOBAR_SHOWN, 1);
102 return delegate; 102 return delegate;
103 } 103 }
104 104
105 // Test that credit card infobar metrics are logged correctly. 105 // Test that credit card infobar metrics are logged correctly.
106 TEST_F(AutofillSaveCardInfoBarDelegateMobileTest, Metrics) { 106 TEST_F(AutofillSaveCardInfoBarDelegateMobileTest, Metrics) {
107 ::testing::InSequence dummy; 107 ::testing::InSequence dummy;
108 108
109 // Accept the infobar. 109 // Accept the infobar.
110 { 110 {
111 scoped_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate()); 111 std::unique_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate());
112 EXPECT_CALL(*personal_data_, SaveImportedCreditCard(_)); 112 EXPECT_CALL(*personal_data_, SaveImportedCreditCard(_));
113 113
114 base::HistogramTester histogram_tester; 114 base::HistogramTester histogram_tester;
115 EXPECT_TRUE(infobar->Accept()); 115 EXPECT_TRUE(infobar->Accept());
116 histogram_tester.ExpectUniqueSample("Autofill.CreditCardInfoBar", 116 histogram_tester.ExpectUniqueSample("Autofill.CreditCardInfoBar",
117 AutofillMetrics::INFOBAR_ACCEPTED, 1); 117 AutofillMetrics::INFOBAR_ACCEPTED, 1);
118 } 118 }
119 119
120 // Cancel the infobar. 120 // Cancel the infobar.
121 { 121 {
122 scoped_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate()); 122 std::unique_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate());
123 123
124 base::HistogramTester histogram_tester; 124 base::HistogramTester histogram_tester;
125 EXPECT_TRUE(infobar->Cancel()); 125 EXPECT_TRUE(infobar->Cancel());
126 histogram_tester.ExpectUniqueSample("Autofill.CreditCardInfoBar", 126 histogram_tester.ExpectUniqueSample("Autofill.CreditCardInfoBar",
127 AutofillMetrics::INFOBAR_DENIED, 1); 127 AutofillMetrics::INFOBAR_DENIED, 1);
128 } 128 }
129 129
130 // Dismiss the infobar. 130 // Dismiss the infobar.
131 { 131 {
132 scoped_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate()); 132 std::unique_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate());
133 133
134 base::HistogramTester histogram_tester; 134 base::HistogramTester histogram_tester;
135 infobar->InfoBarDismissed(); 135 infobar->InfoBarDismissed();
136 histogram_tester.ExpectUniqueSample("Autofill.CreditCardInfoBar", 136 histogram_tester.ExpectUniqueSample("Autofill.CreditCardInfoBar",
137 AutofillMetrics::INFOBAR_DENIED, 1); 137 AutofillMetrics::INFOBAR_DENIED, 1);
138 } 138 }
139 139
140 // Ignore the infobar. 140 // Ignore the infobar.
141 { 141 {
142 scoped_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate()); 142 std::unique_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate());
143 143
144 base::HistogramTester histogram_tester; 144 base::HistogramTester histogram_tester;
145 infobar.reset(); 145 infobar.reset();
146 histogram_tester.ExpectUniqueSample("Autofill.CreditCardInfoBar", 146 histogram_tester.ExpectUniqueSample("Autofill.CreditCardInfoBar",
147 AutofillMetrics::INFOBAR_IGNORED, 1); 147 AutofillMetrics::INFOBAR_IGNORED, 1);
148 } 148 }
149 } 149 }
150 150
151 } // namespace autofill 151 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_interactive_uitest.cc ('k') | chrome/browser/autofill/autofill_server_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698