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

Unified Diff: chrome/browser/autofill/form_structure_browsertest.cc

Issue 6026010: Autofill heuristics regular expressions should be stored in external data files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nits Created 10 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/autofill/form_field.cc ('k') | chrome/browser/autofill/name_field.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autofill/form_structure_browsertest.cc
diff --git a/chrome/browser/autofill/form_structure_browsertest.cc b/chrome/browser/autofill/form_structure_browsertest.cc
index ae38f7dc7a43cd38e41341504420dbacb7158e09..f6bda60d91cca004a512836fff087903ba4e1d3e 100644
--- a/chrome/browser/autofill/form_structure_browsertest.cc
+++ b/chrome/browser/autofill/form_structure_browsertest.cc
@@ -47,19 +47,13 @@ const std::string ConvertToURLFormat(const std::string& html) {
return std::string("data:text/html;charset=utf-8,") + html;
}
-// Compare |output_file_source| with |form_string|. Returns true when they are
-// identical.
-bool CompareText(const std::string& output_file_source,
- const std::string& form_string) {
- std::string output_file = output_file_source;
- std::string form = form_string;
-
- ReplaceSubstringsAfterOffset(&output_file, 0, "\r\n", " ");
- ReplaceSubstringsAfterOffset(&output_file, 0, "\r", " ");
- ReplaceSubstringsAfterOffset(&output_file, 0, "\n", " ");
- ReplaceSubstringsAfterOffset(&form, 0, "\n", " ");
-
- return (output_file == form);
+// Convert strings with platform end-of-line characters with spaces.
+const std::string NormalizeText(const std::string& text) {
+ std::string normalized = text;
+ ReplaceSubstringsAfterOffset(&normalized, 0, "\r\n", " ");
+ ReplaceSubstringsAfterOffset(&normalized, 0, "\r", " ");
+ ReplaceSubstringsAfterOffset(&normalized, 0, "\n", " ");
+ return normalized;
}
} // namespace
@@ -253,9 +247,9 @@ IN_PROC_BROWSER_TEST_F(FormStructureBrowserTest, HTMLFiles) {
std::string output_file_source;
if (file_util::ReadFileToString(output_file_path, &output_file_source)) {
- ASSERT_TRUE(CompareText(
- output_file_source,
- FormStructureBrowserTest::FormStructuresToString(forms)));
+ ASSERT_EQ(NormalizeText(output_file_source),
+ NormalizeText(
+ FormStructureBrowserTest::FormStructuresToString(forms)));
} else {
ASSERT_TRUE(WriteFile(
« no previous file with comments | « chrome/browser/autofill/form_field.cc ('k') | chrome/browser/autofill/name_field.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698