| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   62 } |   63 } | 
|   63  |   64  | 
|   64 FormStructureBrowserTest::~FormStructureBrowserTest() { |   65 FormStructureBrowserTest::~FormStructureBrowserTest() { | 
|   65 } |   66 } | 
|   66  |   67  | 
|   67 void FormStructureBrowserTest::GenerateResults(const std::string& input, |   68 void FormStructureBrowserTest::GenerateResults(const std::string& input, | 
|   68                                                std::string* output) { |   69                                                std::string* output) { | 
|   69   ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), |   70   ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), | 
|   70                                                        HTMLToDataURI(input))); |   71                                                        HTMLToDataURI(input))); | 
|   71  |   72  | 
 |   73   content::WebContents* web_contents = | 
 |   74       browser()->tab_strip_model()->GetActiveWebContents(); | 
|   72   ContentAutofillDriver* autofill_driver = |   75   ContentAutofillDriver* autofill_driver = | 
|   73       ContentAutofillDriver::FromWebContents( |   76       ContentAutofillDriverFactory::FromWebContents(web_contents) | 
|   74           browser()->tab_strip_model()->GetActiveWebContents()); |   77           ->DriverForFrame(web_contents->GetMainFrame()); | 
|   75   ASSERT_NE(static_cast<ContentAutofillDriver*>(NULL), autofill_driver); |   78   ASSERT_NE(static_cast<ContentAutofillDriver*>(NULL), autofill_driver); | 
|   76   AutofillManager* autofill_manager = autofill_driver->autofill_manager(); |   79   AutofillManager* autofill_manager = autofill_driver->autofill_manager(); | 
|   77   ASSERT_NE(static_cast<AutofillManager*>(NULL), autofill_manager); |   80   ASSERT_NE(static_cast<AutofillManager*>(NULL), autofill_manager); | 
|   78   std::vector<FormStructure*> forms = autofill_manager->form_structures_.get(); |   81   std::vector<FormStructure*> forms = autofill_manager->form_structures_.get(); | 
|   79   *output = FormStructuresToString(forms); |   82   *output = FormStructuresToString(forms); | 
|   80 } |   83 } | 
|   81  |   84  | 
|   82 std::string FormStructureBrowserTest::FormStructuresToString( |   85 std::string FormStructureBrowserTest::FormStructuresToString( | 
|   83     const std::vector<FormStructure*>& forms) { |   86     const std::vector<FormStructure*>& forms) { | 
|   84   std::string forms_string; |   87   std::string forms_string; | 
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  293 IN_PROC_BROWSER_TEST_F(FormStructureBrowserTest, |  296 IN_PROC_BROWSER_TEST_F(FormStructureBrowserTest, | 
|  294     MAYBE_DataDrivenHeuristics(23)) { |  297     MAYBE_DataDrivenHeuristics(23)) { | 
|  295   const base::FilePath::CharType kFileNamePattern[] = |  298   const base::FilePath::CharType kFileNamePattern[] = | 
|  296       FILE_PATH_LITERAL("23_*.html"); |  299       FILE_PATH_LITERAL("23_*.html"); | 
|  297   RunDataDrivenTest(GetInputDirectory(kTestName), |  300   RunDataDrivenTest(GetInputDirectory(kTestName), | 
|  298                     GetOutputDirectory(kTestName), |  301                     GetOutputDirectory(kTestName), | 
|  299                     kFileNamePattern); |  302                     kFileNamePattern); | 
|  300 } |  303 } | 
|  301  |  304  | 
|  302 }  // namespace autofill |  305 }  // namespace autofill | 
| OLD | NEW |