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

Side by Side Diff: components/autofill/core/browser/autofill_metrics_unittest.cc

Issue 2254983002: Remove test-only constructor from CreditCard. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use default constructor and nix guid include Created 4 years, 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_metrics.h" 5 #include "components/autofill/core/browser/autofill_metrics.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 148 }
149 149
150 // Removes all existing credit cards and creates 0 or 1 local profiles and 150 // Removes all existing credit cards and creates 0 or 1 local profiles and
151 // 0 or 1 server profile according to the paramters. 151 // 0 or 1 server profile according to the paramters.
152 void RecreateCreditCards(bool include_local_credit_card, 152 void RecreateCreditCards(bool include_local_credit_card,
153 bool include_masked_server_credit_card, 153 bool include_masked_server_credit_card,
154 bool include_full_server_credit_card) { 154 bool include_full_server_credit_card) {
155 local_credit_cards_.clear(); 155 local_credit_cards_.clear();
156 server_credit_cards_.clear(); 156 server_credit_cards_.clear();
157 if (include_local_credit_card) { 157 if (include_local_credit_card) {
158 CreditCard* credit_card = 158 std::unique_ptr<CreditCard> credit_card(new CreditCard(
159 new CreditCard(base::ASCIIToUTF16("4111111111111111"), 12, 24); 159 "10000000-0000-0000-0000-000000000001", std::string()));
160 credit_card->set_guid("10000000-0000-0000-0000-000000000001"); 160 test::SetCreditCardInfo(credit_card.get(), nullptr, "4111111111111111",
161 local_credit_cards_.push_back(credit_card); 161 "12", "24");
162 local_credit_cards_.push_back(credit_card.release());
162 } 163 }
163 if (include_masked_server_credit_card) { 164 if (include_masked_server_credit_card) {
164 CreditCard* credit_card = new CreditCard( 165 std::unique_ptr<CreditCard> credit_card(new CreditCard(
165 CreditCard::MASKED_SERVER_CARD, "server_id"); 166 CreditCard::MASKED_SERVER_CARD, "server_id"));
166 credit_card->set_guid("10000000-0000-0000-0000-000000000002"); 167 credit_card->set_guid("10000000-0000-0000-0000-000000000002");
167 credit_card->SetTypeForMaskedCard(kDiscoverCard); 168 credit_card->SetTypeForMaskedCard(kDiscoverCard);
168 server_credit_cards_.push_back(credit_card); 169 server_credit_cards_.push_back(credit_card.release());
169 } 170 }
170 if (include_full_server_credit_card) { 171 if (include_full_server_credit_card) {
171 CreditCard* credit_card = new CreditCard( 172 std::unique_ptr<CreditCard> credit_card(new CreditCard(
172 CreditCard::FULL_SERVER_CARD, "server_id"); 173 CreditCard::FULL_SERVER_CARD, "server_id"));
173 credit_card->set_guid("10000000-0000-0000-0000-000000000003"); 174 credit_card->set_guid("10000000-0000-0000-0000-000000000003");
174 server_credit_cards_.push_back(credit_card); 175 server_credit_cards_.push_back(credit_card.release());
175 } 176 }
176 Refresh(); 177 Refresh();
177 } 178 }
178 179
179 bool IsAutofillEnabled() const override { return autofill_enabled_; } 180 bool IsAutofillEnabled() const override { return autofill_enabled_; }
180 181
181 private: 182 private:
182 void CreateTestAutofillProfiles(ScopedVector<AutofillProfile>* profiles) { 183 void CreateTestAutofillProfiles(ScopedVector<AutofillProfile>* profiles) {
183 AutofillProfile* profile = new AutofillProfile; 184 AutofillProfile* profile = new AutofillProfile;
184 test::SetProfileInfo(profile, "Elvis", "Aaron", 185 test::SetProfileInfo(profile, "Elvis", "Aaron",
(...skipping 3883 matching lines...) Expand 10 before | Expand all | Expand 10 after
4068 EXPECT_THAT( 4069 EXPECT_THAT(
4069 histogram_tester.GetAllSamples("Autofill.ServerResponseHasDataForForm"), 4070 histogram_tester.GetAllSamples("Autofill.ServerResponseHasDataForForm"),
4070 ElementsAre(Bucket(true, 2))); 4071 ElementsAre(Bucket(true, 2)));
4071 4072
4072 // No RAPPOR metrics are logged in the case there is at least some server data 4073 // No RAPPOR metrics are logged in the case there is at least some server data
4073 // available for all forms. 4074 // available for all forms.
4074 EXPECT_EQ(0, rappor_service_.GetReportsCount()); 4075 EXPECT_EQ(0, rappor_service_.GetReportsCount());
4075 } 4076 }
4076 4077
4077 } // namespace autofill 4078 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698