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

Side by Side Diff: content/browser/accessibility/dump_accessibility_tree_browsertest.cc

Issue 12213066: Use base namespace for FilePath in content/browser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
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 <set> 5 #include <set>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } else if (StartsWithASCII(line, allow_str, true)) { 101 } else if (StartsWithASCII(line, allow_str, true)) {
102 filters->push_back(Filter(UTF8ToUTF16(line.substr(allow_str.size())), 102 filters->push_back(Filter(UTF8ToUTF16(line.substr(allow_str.size())),
103 Filter::ALLOW)); 103 Filter::ALLOW));
104 } else if (StartsWithASCII(line, deny_str, true)) { 104 } else if (StartsWithASCII(line, deny_str, true)) {
105 filters->push_back(Filter(UTF8ToUTF16(line.substr(deny_str.size())), 105 filters->push_back(Filter(UTF8ToUTF16(line.substr(deny_str.size())),
106 Filter::DENY)); 106 Filter::DENY));
107 } 107 }
108 } 108 }
109 } 109 }
110 110
111 void RunTest(const FilePath::CharType* file_path); 111 void RunTest(const base::FilePath::CharType* file_path);
112 112
113 DumpAccessibilityTreeHelper helper_; 113 DumpAccessibilityTreeHelper helper_;
114 }; 114 };
115 115
116 void DumpAccessibilityTreeTest::RunTest(const FilePath::CharType* file_path) { 116 void DumpAccessibilityTreeTest::RunTest(
117 const base::FilePath::CharType* file_path) {
117 NavigateToURL(shell(), GURL("about:blank")); 118 NavigateToURL(shell(), GURL("about:blank"));
118 RenderWidgetHostViewPort* host_view = static_cast<RenderWidgetHostViewPort*>( 119 RenderWidgetHostViewPort* host_view = static_cast<RenderWidgetHostViewPort*>(
119 shell()->web_contents()->GetRenderWidgetHostView()); 120 shell()->web_contents()->GetRenderWidgetHostView());
120 RenderWidgetHostImpl* host = 121 RenderWidgetHostImpl* host =
121 RenderWidgetHostImpl::From(host_view->GetRenderWidgetHost()); 122 RenderWidgetHostImpl::From(host_view->GetRenderWidgetHost());
122 RenderViewHostImpl* view_host = static_cast<RenderViewHostImpl*>(host); 123 RenderViewHostImpl* view_host = static_cast<RenderViewHostImpl*>(host);
123 view_host->set_save_accessibility_tree_for_testing(true); 124 view_host->set_save_accessibility_tree_for_testing(true);
124 view_host->SetAccessibilityMode(AccessibilityModeComplete); 125 view_host->SetAccessibilityMode(AccessibilityModeComplete);
125 126
126 // Setup test paths. 127 // Setup test paths.
127 FilePath dir_test_data; 128 base::FilePath dir_test_data;
128 ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &dir_test_data)); 129 ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &dir_test_data));
129 FilePath test_path(dir_test_data.Append(FILE_PATH_LITERAL("accessibility"))); 130 base::FilePath test_path(
131 dir_test_data.Append(FILE_PATH_LITERAL("accessibility")));
130 ASSERT_TRUE(file_util::PathExists(test_path)) 132 ASSERT_TRUE(file_util::PathExists(test_path))
131 << test_path.LossyDisplayName(); 133 << test_path.LossyDisplayName();
132 134
133 FilePath html_file = test_path.Append(FilePath(file_path)); 135 base::FilePath html_file = test_path.Append(base::FilePath(file_path));
134 // Output the test path to help anyone who encounters a failure and needs 136 // Output the test path to help anyone who encounters a failure and needs
135 // to know where to look. 137 // to know where to look.
136 printf("Testing: %s\n", html_file.MaybeAsASCII().c_str()); 138 printf("Testing: %s\n", html_file.MaybeAsASCII().c_str());
137 139
138 std::string html_contents; 140 std::string html_contents;
139 file_util::ReadFileToString(html_file, &html_contents); 141 file_util::ReadFileToString(html_file, &html_contents);
140 142
141 // Parse filters in the test file. 143 // Parse filters in the test file.
142 std::vector<Filter> filters; 144 std::vector<Filter> filters;
143 AddDefaultFilters(&filters); 145 AddDefaultFilters(&filters);
144 ParseFilters(html_contents, &filters); 146 ParseFilters(html_contents, &filters);
145 helper_.SetFilters(filters); 147 helper_.SetFilters(filters);
146 148
147 // Read the expected file. 149 // Read the expected file.
148 std::string expected_contents_raw; 150 std::string expected_contents_raw;
149 FilePath expected_file = 151 base::FilePath expected_file =
150 FilePath(html_file.RemoveExtension().value() + 152 base::FilePath(html_file.RemoveExtension().value() +
151 helper_.GetExpectedFileSuffix()); 153 helper_.GetExpectedFileSuffix());
152 file_util::ReadFileToString( 154 file_util::ReadFileToString(
153 expected_file, 155 expected_file,
154 &expected_contents_raw); 156 &expected_contents_raw);
155 157
156 // Tolerate Windows-style line endings (\r\n) in the expected file: 158 // Tolerate Windows-style line endings (\r\n) in the expected file:
157 // normalize by deleting all \r from the file (if any) to leave only \n. 159 // normalize by deleting all \r from the file (if any) to leave only \n.
158 std::string expected_contents; 160 std::string expected_contents;
159 RemoveChars(expected_contents_raw, "\r", &expected_contents); 161 RemoveChars(expected_contents_raw, "\r", &expected_contents);
160 162
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 } 210 }
209 printf("%1s %4d %s\n", is_diff? kSignalDiff : "", line + 1, 211 printf("%1s %4d %s\n", is_diff? kSignalDiff : "", line + 1,
210 expected_lines[line].c_str()); 212 expected_lines[line].c_str());
211 } 213 }
212 printf("\nActual\n"); 214 printf("\nActual\n");
213 printf("------\n"); 215 printf("------\n");
214 printf("%s\n", actual_contents.c_str()); 216 printf("%s\n", actual_contents.c_str());
215 } 217 }
216 218
217 if (!file_util::PathExists(expected_file)) { 219 if (!file_util::PathExists(expected_file)) {
218 FilePath actual_file = 220 base::FilePath actual_file =
219 FilePath(html_file.RemoveExtension().value() + 221 base::FilePath(html_file.RemoveExtension().value() +
220 helper_.GetActualFileSuffix()); 222 helper_.GetActualFileSuffix());
221 223
222 EXPECT_TRUE(file_util::WriteFile( 224 EXPECT_TRUE(file_util::WriteFile(
223 actual_file, actual_contents.c_str(), actual_contents.size())); 225 actual_file, actual_contents.c_str(), actual_contents.size()));
224 226
225 ADD_FAILURE() << "No expectation found. Create it by doing:\n" 227 ADD_FAILURE() << "No expectation found. Create it by doing:\n"
226 << "mv " << actual_file.LossyDisplayName() << " " 228 << "mv " << actual_file.LossyDisplayName() << " "
227 << expected_file.LossyDisplayName(); 229 << expected_file.LossyDisplayName();
228 } 230 }
229 } 231 }
230 232
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 436
435 IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityUl) { 437 IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityUl) {
436 RunTest(FILE_PATH_LITERAL("ul.html")); 438 RunTest(FILE_PATH_LITERAL("ul.html"));
437 } 439 }
438 440
439 IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityWbr) { 441 IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityWbr) {
440 RunTest(FILE_PATH_LITERAL("wbr.html")); 442 RunTest(FILE_PATH_LITERAL("wbr.html"));
441 } 443 }
442 444
443 } // namespace content 445 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698