Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: chrome/browser/autofill/form_structure_browsertest.cc

Issue 2403773002: Remove stl_util's STLDeleteContainerPointers from autofill. (Closed)
Patch Set: rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <algorithm> 5 #include <algorithm>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/files/file_enumerator.h" 8 #include "base/files/file_enumerator.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 public DataDrivenTest, 78 public DataDrivenTest,
79 public ::testing::WithParamInterface<base::FilePath> { 79 public ::testing::WithParamInterface<base::FilePath> {
80 protected: 80 protected:
81 FormStructureBrowserTest(); 81 FormStructureBrowserTest();
82 ~FormStructureBrowserTest() override; 82 ~FormStructureBrowserTest() override;
83 83
84 // DataDrivenTest: 84 // DataDrivenTest:
85 void GenerateResults(const std::string& input, std::string* output) override; 85 void GenerateResults(const std::string& input, std::string* output) override;
86 86
87 // Serializes the given |forms| into a string. 87 // Serializes the given |forms| into a string.
88 std::string FormStructuresToString(const std::vector<FormStructure*>& forms); 88 std::string FormStructuresToString(
89 const std::vector<std::unique_ptr<FormStructure>>& forms);
89 90
90 private: 91 private:
91 DISALLOW_COPY_AND_ASSIGN(FormStructureBrowserTest); 92 DISALLOW_COPY_AND_ASSIGN(FormStructureBrowserTest);
92 }; 93 };
93 94
94 FormStructureBrowserTest::FormStructureBrowserTest() 95 FormStructureBrowserTest::FormStructureBrowserTest()
95 : DataDrivenTest(GetTestDataDir()) { 96 : DataDrivenTest(GetTestDataDir()) {
96 } 97 }
97 98
98 FormStructureBrowserTest::~FormStructureBrowserTest() { 99 FormStructureBrowserTest::~FormStructureBrowserTest() {
99 } 100 }
100 101
101 void FormStructureBrowserTest::GenerateResults(const std::string& input, 102 void FormStructureBrowserTest::GenerateResults(const std::string& input,
102 std::string* output) { 103 std::string* output) {
103 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), 104 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(),
104 HTMLToDataURI(input))); 105 HTMLToDataURI(input)));
105 106
106 content::WebContents* web_contents = 107 content::WebContents* web_contents =
107 browser()->tab_strip_model()->GetActiveWebContents(); 108 browser()->tab_strip_model()->GetActiveWebContents();
108 ContentAutofillDriver* autofill_driver = 109 ContentAutofillDriver* autofill_driver =
109 ContentAutofillDriverFactory::FromWebContents(web_contents) 110 ContentAutofillDriverFactory::FromWebContents(web_contents)
110 ->DriverForFrame(web_contents->GetMainFrame()); 111 ->DriverForFrame(web_contents->GetMainFrame());
111 ASSERT_NE(nullptr, autofill_driver); 112 ASSERT_NE(nullptr, autofill_driver);
112 AutofillManager* autofill_manager = autofill_driver->autofill_manager(); 113 AutofillManager* autofill_manager = autofill_driver->autofill_manager();
113 ASSERT_NE(nullptr, autofill_manager); 114 ASSERT_NE(nullptr, autofill_manager);
114 std::vector<FormStructure*> forms = autofill_manager->form_structures_.get(); 115 const std::vector<std::unique_ptr<FormStructure>>& forms =
116 autofill_manager->form_structures_;
115 *output = FormStructuresToString(forms); 117 *output = FormStructuresToString(forms);
116 } 118 }
117 119
118 std::string FormStructureBrowserTest::FormStructuresToString( 120 std::string FormStructureBrowserTest::FormStructuresToString(
119 const std::vector<FormStructure*>& forms) { 121 const std::vector<std::unique_ptr<FormStructure>>& forms) {
120 std::string forms_string; 122 std::string forms_string;
121 for (const FormStructure* form : forms) { 123 for (const auto& form : forms) {
122 for (const AutofillField* field : *form) { 124 for (const AutofillField* field : *form) {
123 forms_string += field->Type().ToString(); 125 forms_string += field->Type().ToString();
124 forms_string += " | " + base::UTF16ToUTF8(field->name); 126 forms_string += " | " + base::UTF16ToUTF8(field->name);
125 forms_string += " | " + base::UTF16ToUTF8(field->label); 127 forms_string += " | " + base::UTF16ToUTF8(field->label);
126 forms_string += " | " + base::UTF16ToUTF8(field->value); 128 forms_string += " | " + base::UTF16ToUTF8(field->value);
127 forms_string += " | " + field->section(); 129 forms_string += " | " + field->section();
128 forms_string += "\n"; 130 forms_string += "\n";
129 } 131 }
130 } 132 }
131 return forms_string; 133 return forms_string;
132 } 134 }
133 135
134 IN_PROC_BROWSER_TEST_P(FormStructureBrowserTest, DataDrivenHeuristics) { 136 IN_PROC_BROWSER_TEST_P(FormStructureBrowserTest, DataDrivenHeuristics) {
135 // Prints the path of the test to be executed. 137 // Prints the path of the test to be executed.
136 LOG(INFO) << GetParam().MaybeAsASCII(); 138 LOG(INFO) << GetParam().MaybeAsASCII();
137 RunOneDataDrivenTest(GetParam(), GetOutputDirectory(kTestName)); 139 RunOneDataDrivenTest(GetParam(), GetOutputDirectory(kTestName));
138 } 140 }
139 141
140 INSTANTIATE_TEST_CASE_P(AllForms, 142 INSTANTIATE_TEST_CASE_P(AllForms,
141 FormStructureBrowserTest, 143 FormStructureBrowserTest,
142 testing::ValuesIn(GetTestFiles())); 144 testing::ValuesIn(GetTestFiles()));
143 145
144 } // namespace autofill 146 } // namespace autofill
OLDNEW
« no previous file with comments | « android_webview/browser/aw_form_database_service.cc ('k') | chrome/browser/password_manager/password_store_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698