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/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/browser_tabstrip.h" |
14 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 15 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
15 #include "chrome/test/base/in_process_browser_test.h" | 16 #include "chrome/test/base/in_process_browser_test.h" |
16 #include "chrome/test/base/ui_test_utils.h" | 17 #include "chrome/test/base/ui_test_utils.h" |
17 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
21 const FilePath::CharType kTestName[] = FILE_PATH_LITERAL("heuristics"); | 22 const FilePath::CharType kTestName[] = FILE_PATH_LITERAL("heuristics"); |
22 | 23 |
23 // Convert the |html| snippet to a data URI. | 24 // Convert the |html| snippet to a data URI. |
(...skipping 28 matching lines...) Expand all Loading... |
52 | 53 |
53 FormStructureBrowserTest::~FormStructureBrowserTest() { | 54 FormStructureBrowserTest::~FormStructureBrowserTest() { |
54 } | 55 } |
55 | 56 |
56 void FormStructureBrowserTest::GenerateResults(const std::string& input, | 57 void FormStructureBrowserTest::GenerateResults(const std::string& input, |
57 std::string* output) { | 58 std::string* output) { |
58 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), | 59 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), |
59 HTMLToDataURI(input))); | 60 HTMLToDataURI(input))); |
60 | 61 |
61 AutofillManager* autofill_manager = | 62 AutofillManager* autofill_manager = |
62 browser()->GetActiveTabContents()->autofill_manager(); | 63 chrome::GetActiveTabContents(browser())->autofill_manager(); |
63 ASSERT_NE(static_cast<AutofillManager*>(NULL), autofill_manager); | 64 ASSERT_NE(static_cast<AutofillManager*>(NULL), autofill_manager); |
64 std::vector<FormStructure*> forms = autofill_manager->form_structures_.get(); | 65 std::vector<FormStructure*> forms = autofill_manager->form_structures_.get(); |
65 *output = FormStructureBrowserTest::FormStructuresToString(forms); | 66 *output = FormStructureBrowserTest::FormStructuresToString(forms); |
66 } | 67 } |
67 | 68 |
68 std::string FormStructureBrowserTest::FormStructuresToString( | 69 std::string FormStructureBrowserTest::FormStructuresToString( |
69 const std::vector<FormStructure*>& forms) { | 70 const std::vector<FormStructure*>& forms) { |
70 std::string forms_string; | 71 std::string forms_string; |
71 for (std::vector<FormStructure*>::const_iterator iter = forms.begin(); | 72 for (std::vector<FormStructure*>::const_iterator iter = forms.begin(); |
72 iter != forms.end(); | 73 iter != forms.end(); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 kFileNamePattern); | 237 kFileNamePattern); |
237 } | 238 } |
238 | 239 |
239 IN_PROC_BROWSER_TEST_F(FormStructureBrowserTest, | 240 IN_PROC_BROWSER_TEST_F(FormStructureBrowserTest, |
240 MAYBE_DataDrivenHeuristics(20)) { | 241 MAYBE_DataDrivenHeuristics(20)) { |
241 const FilePath::CharType kFileNamePattern[] = FILE_PATH_LITERAL("20_*.html"); | 242 const FilePath::CharType kFileNamePattern[] = FILE_PATH_LITERAL("20_*.html"); |
242 RunDataDrivenTest(GetInputDirectory(kTestName), | 243 RunDataDrivenTest(GetInputDirectory(kTestName), |
243 GetOutputDirectory(kTestName), | 244 GetOutputDirectory(kTestName), |
244 kFileNamePattern); | 245 kFileNamePattern); |
245 } | 246 } |
OLD | NEW |