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

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

Issue 12260054: [Autofill] Enable heuristic detection of credit card issuer fields. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/autofill/address_field.cc ('k') | chrome/browser/autofill/credit_card_field.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/memory/scoped_vector.h" 6 #include "base/memory/scoped_vector.h"
7 #include "base/string16.h" 7 #include "base/string16.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/autofill/address_field.h" 9 #include "chrome/browser/autofill/address_field.h"
10 #include "chrome/browser/autofill/autofill_field.h" 10 #include "chrome/browser/autofill/autofill_field.h"
11 #include "chrome/browser/autofill/autofill_scanner.h" 11 #include "chrome/browser/autofill/autofill_scanner.h"
12 #include "chrome/common/form_field_data.h" 12 #include "chrome/common/form_field_data.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 class AddressFieldTest : public testing::Test { 15 class AddressFieldTest : public testing::Test {
16 public: 16 public:
17 AddressFieldTest() {} 17 AddressFieldTest() {}
18 18
19 protected: 19 protected:
20 ScopedVector<const AutofillField> list_; 20 ScopedVector<const AutofillField> list_;
21 scoped_ptr<AddressField> field_; 21 scoped_ptr<AddressField> field_;
22 FieldTypeMap field_type_map_; 22 FieldTypeMap field_type_map_;
23 23
24 // Downcast for tests. 24 // Downcast for tests.
25 static AddressField* Parse(AutofillScanner* scanner) { 25 static AddressField* Parse(AutofillScanner* scanner) {
26 return static_cast<AddressField*>(AddressField::Parse(scanner, false)); 26 return static_cast<AddressField*>(AddressField::Parse(scanner));
27 } 27 }
28 28
29 private: 29 private:
30 DISALLOW_COPY_AND_ASSIGN(AddressFieldTest); 30 DISALLOW_COPY_AND_ASSIGN(AddressFieldTest);
31 }; 31 };
32 32
33 TEST_F(AddressFieldTest, Empty) { 33 TEST_F(AddressFieldTest, Empty) {
34 AutofillScanner scanner(list_.get()); 34 AutofillScanner scanner(list_.get());
35 field_.reset(Parse(&scanner)); 35 field_.reset(Parse(&scanner));
36 ASSERT_EQ(static_cast<AddressField*>(NULL), field_.get()); 36 ASSERT_EQ(static_cast<AddressField*>(NULL), field_.get());
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 285
286 AutofillScanner scanner(list_.get()); 286 AutofillScanner scanner(list_.get());
287 field_.reset(Parse(&scanner)); 287 field_.reset(Parse(&scanner));
288 ASSERT_NE(static_cast<AddressField*>(NULL), field_.get()); 288 ASSERT_NE(static_cast<AddressField*>(NULL), field_.get());
289 EXPECT_EQ(AddressField::kGenericAddress, field_->FindType()); 289 EXPECT_EQ(AddressField::kGenericAddress, field_->FindType());
290 ASSERT_TRUE(field_->ClassifyField(&field_type_map_)); 290 ASSERT_TRUE(field_->ClassifyField(&field_type_map_));
291 ASSERT_TRUE( 291 ASSERT_TRUE(
292 field_type_map_.find(ASCIIToUTF16("company1")) != field_type_map_.end()); 292 field_type_map_.find(ASCIIToUTF16("company1")) != field_type_map_.end());
293 EXPECT_EQ(COMPANY_NAME, field_type_map_[ASCIIToUTF16("company1")]); 293 EXPECT_EQ(COMPANY_NAME, field_type_map_[ASCIIToUTF16("company1")]);
294 } 294 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/address_field.cc ('k') | chrome/browser/autofill/credit_card_field.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698