OLD | NEW |
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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/autofill/autofill_manager.h" | 10 #include "chrome/browser/autofill/autofill_manager.h" |
11 #include "chrome/browser/autofill/data_driven_test.h" | 11 #include "chrome/browser/autofill/data_driven_test.h" |
12 #include "chrome/browser/autofill/form_structure.h" | 12 #include "chrome/browser/autofill/form_structure.h" |
13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
15 #include "chrome/test/in_process_browser_test.h" | 15 #include "chrome/test/in_process_browser_test.h" |
16 #include "chrome/test/ui_test_utils.h" | 16 #include "chrome/test/ui_test_utils.h" |
17 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 const FilePath::CharType kTestName[] = FILE_PATH_LITERAL("heuristics"); | 21 const FilePath::CharType kTestName[] = FILE_PATH_LITERAL("heuristics"); |
22 const FilePath::CharType kFileNamePattern[] = FILE_PATH_LITERAL("*.html"); | |
23 | 22 |
24 // Convert the |html| snippet to a data URI. | 23 // Convert the |html| snippet to a data URI. |
25 GURL HTMLToDataURI(const std::string& html) { | 24 GURL HTMLToDataURI(const std::string& html) { |
26 return GURL(std::string("data:text/html;charset=utf-8,") + html); | 25 return GURL(std::string("data:text/html;charset=utf-8,") + html); |
27 } | 26 } |
28 | 27 |
29 } // namespace | 28 } // namespace |
30 | 29 |
31 // A data-driven test for verifying Autofill heuristics. Each input is an HTML | 30 // A data-driven test for verifying Autofill heuristics. Each input is an HTML |
32 // file that contains one or more forms. The corresponding output file lists the | 31 // file that contains one or more forms. The corresponding output file lists the |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 (*iter)->begin(); | 76 (*iter)->begin(); |
78 field_iter != (*iter)->end(); | 77 field_iter != (*iter)->end(); |
79 ++field_iter) { | 78 ++field_iter) { |
80 forms_string += AutofillType::FieldTypeToString((*field_iter)->type()); | 79 forms_string += AutofillType::FieldTypeToString((*field_iter)->type()); |
81 forms_string += "\n"; | 80 forms_string += "\n"; |
82 } | 81 } |
83 } | 82 } |
84 return forms_string; | 83 return forms_string; |
85 } | 84 } |
86 | 85 |
87 IN_PROC_BROWSER_TEST_F(FormStructureBrowserTest, DataDrivenHeuristics) { | 86 IN_PROC_BROWSER_TEST_F(FormStructureBrowserTest, DataDrivenHeuristics00) { |
| 87 const FilePath::CharType kFileNamePattern[] = FILE_PATH_LITERAL("00_*.html"); |
88 RunDataDrivenTest(GetInputDirectory(kTestName), | 88 RunDataDrivenTest(GetInputDirectory(kTestName), |
89 GetOutputDirectory(kTestName), | 89 GetOutputDirectory(kTestName), |
90 kFileNamePattern); | 90 kFileNamePattern); |
| 91 } |
| 92 |
| 93 IN_PROC_BROWSER_TEST_F(FormStructureBrowserTest, DataDrivenHeuristics01) { |
| 94 const FilePath::CharType kFileNamePattern[] = FILE_PATH_LITERAL("01_*.html"); |
| 95 RunDataDrivenTest(GetInputDirectory(kTestName), |
| 96 GetOutputDirectory(kTestName), |
| 97 kFileNamePattern); |
| 98 } |
| 99 |
| 100 IN_PROC_BROWSER_TEST_F(FormStructureBrowserTest, DataDrivenHeuristics02) { |
| 101 const FilePath::CharType kFileNamePattern[] = FILE_PATH_LITERAL("02_*.html"); |
| 102 RunDataDrivenTest(GetInputDirectory(kTestName), |
| 103 GetOutputDirectory(kTestName), |
| 104 kFileNamePattern); |
| 105 } |
| 106 |
| 107 IN_PROC_BROWSER_TEST_F(FormStructureBrowserTest, DataDrivenHeuristics03) { |
| 108 const FilePath::CharType kFileNamePattern[] = FILE_PATH_LITERAL("03_*.html"); |
| 109 RunDataDrivenTest(GetInputDirectory(kTestName), |
| 110 GetOutputDirectory(kTestName), |
| 111 kFileNamePattern); |
| 112 } |
| 113 |
| 114 IN_PROC_BROWSER_TEST_F(FormStructureBrowserTest, DataDrivenHeuristics04) { |
| 115 const FilePath::CharType kFileNamePattern[] = FILE_PATH_LITERAL("04_*.html"); |
| 116 RunDataDrivenTest(GetInputDirectory(kTestName), |
| 117 GetOutputDirectory(kTestName), |
| 118 kFileNamePattern); |
| 119 } |
| 120 |
| 121 IN_PROC_BROWSER_TEST_F(FormStructureBrowserTest, DataDrivenHeuristics05) { |
| 122 const FilePath::CharType kFileNamePattern[] = FILE_PATH_LITERAL("05_*.html"); |
| 123 RunDataDrivenTest(GetInputDirectory(kTestName), |
| 124 GetOutputDirectory(kTestName), |
| 125 kFileNamePattern); |
| 126 } |
| 127 |
| 128 IN_PROC_BROWSER_TEST_F(FormStructureBrowserTest, DataDrivenHeuristics06) { |
| 129 const FilePath::CharType kFileNamePattern[] = FILE_PATH_LITERAL("06_*.html"); |
| 130 RunDataDrivenTest(GetInputDirectory(kTestName), |
| 131 GetOutputDirectory(kTestName), |
| 132 kFileNamePattern); |
| 133 } |
| 134 |
| 135 IN_PROC_BROWSER_TEST_F(FormStructureBrowserTest, DataDrivenHeuristics08) { |
| 136 const FilePath::CharType kFileNamePattern[] = FILE_PATH_LITERAL("08_*.html"); |
| 137 RunDataDrivenTest(GetInputDirectory(kTestName), |
| 138 GetOutputDirectory(kTestName), |
| 139 kFileNamePattern); |
| 140 } |
| 141 |
| 142 IN_PROC_BROWSER_TEST_F(FormStructureBrowserTest, DataDrivenHeuristics09) { |
| 143 const FilePath::CharType kFileNamePattern[] = FILE_PATH_LITERAL("09_*.html"); |
| 144 RunDataDrivenTest(GetInputDirectory(kTestName), |
| 145 GetOutputDirectory(kTestName), |
| 146 kFileNamePattern); |
| 147 } |
| 148 |
| 149 IN_PROC_BROWSER_TEST_F(FormStructureBrowserTest, DataDrivenHeuristics10) { |
| 150 const FilePath::CharType kFileNamePattern[] = FILE_PATH_LITERAL("10_*.html"); |
| 151 RunDataDrivenTest(GetInputDirectory(kTestName), |
| 152 GetOutputDirectory(kTestName), |
| 153 kFileNamePattern); |
| 154 } |
| 155 |
| 156 IN_PROC_BROWSER_TEST_F(FormStructureBrowserTest, DataDrivenHeuristics11) { |
| 157 const FilePath::CharType kFileNamePattern[] = FILE_PATH_LITERAL("11_*.html"); |
| 158 RunDataDrivenTest(GetInputDirectory(kTestName), |
| 159 GetOutputDirectory(kTestName), |
| 160 kFileNamePattern); |
| 161 } |
| 162 |
| 163 IN_PROC_BROWSER_TEST_F(FormStructureBrowserTest, DataDrivenHeuristics12) { |
| 164 const FilePath::CharType kFileNamePattern[] = FILE_PATH_LITERAL("12_*.html"); |
| 165 RunDataDrivenTest(GetInputDirectory(kTestName), |
| 166 GetOutputDirectory(kTestName), |
| 167 kFileNamePattern); |
| 168 } |
| 169 |
| 170 IN_PROC_BROWSER_TEST_F(FormStructureBrowserTest, DataDrivenHeuristics13) { |
| 171 const FilePath::CharType kFileNamePattern[] = FILE_PATH_LITERAL("13_*.html"); |
| 172 RunDataDrivenTest(GetInputDirectory(kTestName), |
| 173 GetOutputDirectory(kTestName), |
| 174 kFileNamePattern); |
| 175 } |
| 176 |
| 177 IN_PROC_BROWSER_TEST_F(FormStructureBrowserTest, DataDrivenHeuristics14) { |
| 178 const FilePath::CharType kFileNamePattern[] = FILE_PATH_LITERAL("14_*.html"); |
| 179 RunDataDrivenTest(GetInputDirectory(kTestName), |
| 180 GetOutputDirectory(kTestName), |
| 181 kFileNamePattern); |
91 } | 182 } |
OLD | NEW |