| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), | 69 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), |
| 70 HTMLToDataURI(input))); | 70 HTMLToDataURI(input))); |
| 71 | 71 |
| 72 ContentAutofillDriver* autofill_driver = | 72 ContentAutofillDriver* autofill_driver = |
| 73 ContentAutofillDriver::FromWebContents( | 73 ContentAutofillDriver::FromWebContents( |
| 74 browser()->tab_strip_model()->GetActiveWebContents()); | 74 browser()->tab_strip_model()->GetActiveWebContents()); |
| 75 ASSERT_NE(static_cast<ContentAutofillDriver*>(NULL), autofill_driver); | 75 ASSERT_NE(static_cast<ContentAutofillDriver*>(NULL), autofill_driver); |
| 76 AutofillManager* autofill_manager = autofill_driver->autofill_manager(); | 76 AutofillManager* autofill_manager = autofill_driver->autofill_manager(); |
| 77 ASSERT_NE(static_cast<AutofillManager*>(NULL), autofill_manager); | 77 ASSERT_NE(static_cast<AutofillManager*>(NULL), autofill_manager); |
| 78 std::vector<FormStructure*> forms = autofill_manager->form_structures_.get(); | 78 std::vector<FormStructure*> forms = autofill_manager->form_structures_.get(); |
| 79 *output = FormStructureBrowserTest::FormStructuresToString(forms); | 79 *output = FormStructuresToString(forms); |
| 80 } | 80 } |
| 81 | 81 |
| 82 std::string FormStructureBrowserTest::FormStructuresToString( | 82 std::string FormStructureBrowserTest::FormStructuresToString( |
| 83 const std::vector<FormStructure*>& forms) { | 83 const std::vector<FormStructure*>& forms) { |
| 84 std::string forms_string; | 84 std::string forms_string; |
| 85 for (std::vector<FormStructure*>::const_iterator iter = forms.begin(); | 85 for (const FormStructure* form : forms) { |
| 86 iter != forms.end(); | 86 for (const AutofillField* field : *form) { |
| 87 ++iter) { | 87 forms_string += field->Type().ToString(); |
| 88 | 88 forms_string += " | " + base::UTF16ToUTF8(field->name); |
| 89 for (std::vector<AutofillField*>::const_iterator field_iter = | 89 forms_string += " | " + base::UTF16ToUTF8(field->label); |
| 90 (*iter)->begin(); | 90 forms_string += " | " + base::UTF16ToUTF8(field->value); |
| 91 field_iter != (*iter)->end(); | 91 forms_string += " | " + field->section(); |
| 92 ++field_iter) { | |
| 93 forms_string += (*field_iter)->Type().ToString(); | |
| 94 forms_string += " | " + base::UTF16ToUTF8((*field_iter)->name); | |
| 95 forms_string += " | " + base::UTF16ToUTF8((*field_iter)->label); | |
| 96 forms_string += " | " + base::UTF16ToUTF8((*field_iter)->value); | |
| 97 forms_string += "\n"; | 92 forms_string += "\n"; |
| 98 } | 93 } |
| 99 } | 94 } |
| 100 return forms_string; | 95 return forms_string; |
| 101 } | 96 } |
| 102 | 97 |
| 103 // Heuristics tests time out on Windows (http://crbug.com/85276) and Chrome OS | 98 // Heuristics tests time out on Windows (http://crbug.com/85276) and Chrome OS |
| 104 // (http://crbug.com/423791). | 99 // (http://crbug.com/423791). |
| 105 #if defined(OS_WIN) || defined(OS_CHROMEOS) | 100 #if defined(OS_WIN) || defined(OS_CHROMEOS) |
| 106 #define MAYBE_DataDrivenHeuristics(n) DISABLED_DataDrivenHeuristics##n | 101 #define MAYBE_DataDrivenHeuristics(n) DISABLED_DataDrivenHeuristics##n |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 IN_PROC_BROWSER_TEST_F(FormStructureBrowserTest, | 266 IN_PROC_BROWSER_TEST_F(FormStructureBrowserTest, |
| 272 MAYBE_DataDrivenHeuristics(20)) { | 267 MAYBE_DataDrivenHeuristics(20)) { |
| 273 const base::FilePath::CharType kFileNamePattern[] = | 268 const base::FilePath::CharType kFileNamePattern[] = |
| 274 FILE_PATH_LITERAL("20_*.html"); | 269 FILE_PATH_LITERAL("20_*.html"); |
| 275 RunDataDrivenTest(GetInputDirectory(kTestName), | 270 RunDataDrivenTest(GetInputDirectory(kTestName), |
| 276 GetOutputDirectory(kTestName), | 271 GetOutputDirectory(kTestName), |
| 277 kFileNamePattern); | 272 kFileNamePattern); |
| 278 } | 273 } |
| 279 | 274 |
| 280 } // namespace autofill | 275 } // namespace autofill |
| OLD | NEW |