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