| 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" |
| 11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 13 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
| 14 #include "chrome/test/base/in_process_browser_test.h" | 14 #include "chrome/test/base/in_process_browser_test.h" |
| 15 #include "chrome/test/base/ui_test_utils.h" | 15 #include "chrome/test/base/ui_test_utils.h" |
| 16 #include "components/autofill/content/browser/content_autofill_driver.h" | 16 #include "components/autofill/content/browser/content_autofill_driver.h" |
| 17 #include "components/autofill/content/browser/content_autofill_driver_factory.h" |
| 17 #include "components/autofill/core/browser/autofill_manager.h" | 18 #include "components/autofill/core/browser/autofill_manager.h" |
| 18 #include "components/autofill/core/browser/data_driven_test.h" | 19 #include "components/autofill/core/browser/data_driven_test.h" |
| 19 #include "components/autofill/core/browser/form_structure.h" | 20 #include "components/autofill/core/browser/form_structure.h" |
| 20 #include "url/gurl.h" | 21 #include "url/gurl.h" |
| 21 | 22 |
| 22 namespace autofill { | 23 namespace autofill { |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 const base::FilePath::CharType kTestName[] = FILE_PATH_LITERAL("heuristics"); | 26 const base::FilePath::CharType kTestName[] = FILE_PATH_LITERAL("heuristics"); |
| 26 | 27 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 } | 65 } |
| 65 | 66 |
| 66 FormStructureBrowserTest::~FormStructureBrowserTest() { | 67 FormStructureBrowserTest::~FormStructureBrowserTest() { |
| 67 } | 68 } |
| 68 | 69 |
| 69 void FormStructureBrowserTest::GenerateResults(const std::string& input, | 70 void FormStructureBrowserTest::GenerateResults(const std::string& input, |
| 70 std::string* output) { | 71 std::string* output) { |
| 71 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), | 72 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), |
| 72 HTMLToDataURI(input))); | 73 HTMLToDataURI(input))); |
| 73 | 74 |
| 75 content::WebContents* web_contents = |
| 76 browser()->tab_strip_model()->GetActiveWebContents(); |
| 74 ContentAutofillDriver* autofill_driver = | 77 ContentAutofillDriver* autofill_driver = |
| 75 ContentAutofillDriver::FromWebContents( | 78 ContentAutofillDriverFactory::FromWebContents(web_contents) |
| 76 browser()->tab_strip_model()->GetActiveWebContents()); | 79 ->DriverForFrame(web_contents->GetMainFrame()); |
| 77 ASSERT_NE(static_cast<ContentAutofillDriver*>(NULL), autofill_driver); | 80 ASSERT_NE(static_cast<ContentAutofillDriver*>(NULL), autofill_driver); |
| 78 AutofillManager* autofill_manager = autofill_driver->autofill_manager(); | 81 AutofillManager* autofill_manager = autofill_driver->autofill_manager(); |
| 79 ASSERT_NE(static_cast<AutofillManager*>(NULL), autofill_manager); | 82 ASSERT_NE(static_cast<AutofillManager*>(NULL), autofill_manager); |
| 80 std::vector<FormStructure*> forms = autofill_manager->form_structures_.get(); | 83 std::vector<FormStructure*> forms = autofill_manager->form_structures_.get(); |
| 81 *output = FormStructuresToString(forms); | 84 *output = FormStructuresToString(forms); |
| 82 } | 85 } |
| 83 | 86 |
| 84 std::string FormStructureBrowserTest::FormStructuresToString( | 87 std::string FormStructureBrowserTest::FormStructuresToString( |
| 85 const std::vector<FormStructure*>& forms) { | 88 const std::vector<FormStructure*>& forms) { |
| 86 std::string forms_string; | 89 std::string forms_string; |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 IN_PROC_BROWSER_TEST_F(FormStructureBrowserTest, | 307 IN_PROC_BROWSER_TEST_F(FormStructureBrowserTest, |
| 305 MAYBE_DataDrivenHeuristics(24)) { | 308 MAYBE_DataDrivenHeuristics(24)) { |
| 306 const base::FilePath::CharType kFileNamePattern[] = | 309 const base::FilePath::CharType kFileNamePattern[] = |
| 307 FILE_PATH_LITERAL("24_*.html"); | 310 FILE_PATH_LITERAL("24_*.html"); |
| 308 RunDataDrivenTest(GetInputDirectory(kTestName), | 311 RunDataDrivenTest(GetInputDirectory(kTestName), |
| 309 GetOutputDirectory(kTestName), | 312 GetOutputDirectory(kTestName), |
| 310 kFileNamePattern); | 313 kFileNamePattern); |
| 311 } | 314 } |
| 312 | 315 |
| 313 } // namespace autofill | 316 } // namespace autofill |
| OLD | NEW |