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

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

Issue 1859453002: components/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 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/credit_card_field.h"
6
7 #include <memory>
8
5 #include "base/macros.h" 9 #include "base/macros.h"
6 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/ptr_util.h"
7 #include "base/memory/scoped_vector.h" 11 #include "base/memory/scoped_vector.h"
8 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
9 #include "components/autofill/core/browser/autofill_field.h" 13 #include "components/autofill/core/browser/autofill_field.h"
10 #include "components/autofill/core/browser/autofill_scanner.h" 14 #include "components/autofill/core/browser/autofill_scanner.h"
11 #include "components/autofill/core/browser/credit_card_field.h"
12 #include "components/autofill/core/common/form_field_data.h" 15 #include "components/autofill/core/common/form_field_data.h"
13 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
14 17
15 using base::ASCIIToUTF16; 18 using base::ASCIIToUTF16;
16 19
17 namespace autofill { 20 namespace autofill {
18 21
19 class CreditCardFieldTest : public testing::Test { 22 class CreditCardFieldTest : public testing::Test {
20 public: 23 public:
21 CreditCardFieldTest() {} 24 CreditCardFieldTest() {}
22 ~CreditCardFieldTest() override {} 25 ~CreditCardFieldTest() override {}
23 26
24 protected: 27 protected:
25 ScopedVector<AutofillField> list_; 28 ScopedVector<AutofillField> list_;
26 scoped_ptr<const CreditCardField> field_; 29 std::unique_ptr<const CreditCardField> field_;
27 FieldCandidatesMap field_candidates_map_; 30 FieldCandidatesMap field_candidates_map_;
28 31
29 // Parses the contents of |list_| as a form, and stores the result into 32 // Parses the contents of |list_| as a form, and stores the result into
30 // |field_|. 33 // |field_|.
31 void Parse() { 34 void Parse() {
32 AutofillScanner scanner(list_.get()); 35 AutofillScanner scanner(list_.get());
33 scoped_ptr<FormField> field = CreditCardField::Parse(&scanner); 36 std::unique_ptr<FormField> field = CreditCardField::Parse(&scanner);
34 field_ = make_scoped_ptr(static_cast<CreditCardField*>(field.release())); 37 field_ = base::WrapUnique(static_cast<CreditCardField*>(field.release()));
35 } 38 }
36 39
37 void MultipleParses() { 40 void MultipleParses() {
38 scoped_ptr<FormField> field; 41 std::unique_ptr<FormField> field;
39 42
40 AutofillScanner scanner(list_.get()); 43 AutofillScanner scanner(list_.get());
41 while (!scanner.IsEnd()) { 44 while (!scanner.IsEnd()) {
42 field = CreditCardField::Parse(&scanner); 45 field = CreditCardField::Parse(&scanner);
43 field_ = make_scoped_ptr(static_cast<CreditCardField*>(field.release())); 46 field_ = base::WrapUnique(static_cast<CreditCardField*>(field.release()));
44 if (field_ == nullptr) { 47 if (field_ == nullptr) {
45 scanner.Advance(); 48 scanner.Advance();
46 } else { 49 } else {
47 AddClassifications(); 50 AddClassifications();
48 } 51 }
49 } 52 }
50 } 53 }
51 54
52 // Associates fields with their corresponding types, based on the previous 55 // Associates fields with their corresponding types, based on the previous
53 // call to Parse(). 56 // call to Parse().
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 field_candidates_map_.end()); 771 field_candidates_map_.end());
769 EXPECT_EQ(CREDIT_CARD_VERIFICATION_CODE, 772 EXPECT_EQ(CREDIT_CARD_VERIFICATION_CODE,
770 field_candidates_map_[ASCIIToUTF16("cvc")].BestHeuristicType()); 773 field_candidates_map_[ASCIIToUTF16("cvc")].BestHeuristicType());
771 ASSERT_TRUE(field_candidates_map_.find(ASCIIToUTF16("unknown")) == 774 ASSERT_TRUE(field_candidates_map_.find(ASCIIToUTF16("unknown")) ==
772 field_candidates_map_.end()); 775 field_candidates_map_.end());
773 ASSERT_TRUE(field_candidates_map_.find(ASCIIToUTF16("cvc2")) == 776 ASSERT_TRUE(field_candidates_map_.find(ASCIIToUTF16("cvc2")) ==
774 field_candidates_map_.end()); 777 field_candidates_map_.end());
775 } 778 }
776 779
777 } // namespace autofill 780 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/credit_card_field.cc ('k') | components/autofill/core/browser/crypto/rc4_decryptor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698