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

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

Issue 2440833002: Revert of Accessibility: Ignore all anonymous blocks (Closed)
Patch Set: Rebase after revert of another change touching cursors_test.js Created 4 years, 1 month 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/accessibility/dump_accessibility_browsertest_base.h" 5 #include "content/browser/accessibility/dump_accessibility_browsertest_base.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 const base::FilePath file_path, const char* file_dir) { 190 const base::FilePath file_path, const char* file_dir) {
191 formatter_.reset(CreateAccessibilityTreeFormatter()); 191 formatter_.reset(CreateAccessibilityTreeFormatter());
192 192
193 // Disable the "hot tracked" state (set when the mouse is hovering over 193 // Disable the "hot tracked" state (set when the mouse is hovering over
194 // an object) because it makes test output change based on the mouse position. 194 // an object) because it makes test output change based on the mouse position.
195 BrowserAccessibilityStateImpl::GetInstance()-> 195 BrowserAccessibilityStateImpl::GetInstance()->
196 set_disable_hot_tracking_for_testing(true); 196 set_disable_hot_tracking_for_testing(true);
197 197
198 NavigateToURL(shell(), GURL(url::kAboutBlankURL)); 198 NavigateToURL(shell(), GURL(url::kAboutBlankURL));
199 199
200 // Output the test path to help anyone who encounters a failure and needs
201 // to know where to look.
202 LOG(INFO) << "Testing: " << file_path.LossyDisplayName()
203 << (is_blink_pass_ ? " (internal Blink accessibility tree)"
204 : " (native accessibility tree for this platform)");
205
200 std::string html_contents; 206 std::string html_contents;
201 base::FilePath expected_file; 207 base::FilePath expected_file;
202 std::string expected_contents_raw; 208 std::string expected_contents_raw;
203 { 209 {
204 base::ThreadRestrictions::ScopedAllowIO allow_io_for_test_setup; 210 base::ThreadRestrictions::ScopedAllowIO allow_io_for_test_setup;
205 base::ReadFileToString(file_path, &html_contents); 211 base::ReadFileToString(file_path, &html_contents);
206 212
207 // Read the expected file. 213 // Read the expected file.
208 expected_file = 214 expected_file =
209 base::FilePath(file_path.RemoveExtension().value() + 215 base::FilePath(file_path.RemoveExtension().value() +
210 formatter_->GetExpectedFileSuffix()); 216 formatter_->GetExpectedFileSuffix());
211 217
212 if (!base::PathExists(expected_file)) { 218 if (!base::PathExists(expected_file)) {
213 LOG(INFO) << "File not found: " << expected_file.LossyDisplayName(); 219 LOG(INFO) << "File not found: " << expected_file.LossyDisplayName();
214 LOG(INFO) 220 LOG(INFO)
215 << "No expectation file present, ignoring test on this platform." 221 << "No expectation file present, ignoring test on this platform."
216 << " To run this test anyway, create " 222 << " To run this test anyway, create "
217 << expected_file.LossyDisplayName() 223 << expected_file.LossyDisplayName()
218 << " (it can be empty) and then run content_browsertests " 224 << " (it can be empty) and then run content_browsertests "
219 << "with the switch: --" 225 << "with the switch: --"
220 << switches::kGenerateAccessibilityTestExpectations; 226 << switches::kGenerateAccessibilityTestExpectations;
221 return; 227 return;
222 } 228 }
223 base::ReadFileToString(expected_file, &expected_contents_raw); 229 base::ReadFileToString(expected_file, &expected_contents_raw);
224 } 230 }
225 231
226 // Output the test path to help anyone who encounters a failure and needs
227 // to know where to look.
228 LOG(INFO) << "Testing: "
229 << file_path.NormalizePathSeparatorsTo('/').LossyDisplayName();
230 LOG(INFO) << "Expected output: "
231 << expected_file.NormalizePathSeparatorsTo('/').LossyDisplayName();
232
233 // Tolerate Windows-style line endings (\r\n) in the expected file: 232 // Tolerate Windows-style line endings (\r\n) in the expected file:
234 // normalize by deleting all \r from the file (if any) to leave only \n. 233 // normalize by deleting all \r from the file (if any) to leave only \n.
235 std::string expected_contents; 234 std::string expected_contents;
236 base::RemoveChars(expected_contents_raw, "\r", &expected_contents); 235 base::RemoveChars(expected_contents_raw, "\r", &expected_contents);
237 236
238 if (!expected_contents.compare(0, strlen(kMarkSkipFile), kMarkSkipFile)) { 237 if (!expected_contents.compare(0, strlen(kMarkSkipFile), kMarkSkipFile)) {
239 LOG(INFO) << "Skipping this test on this platform."; 238 LOG(INFO) << "Skipping this test on this platform.";
240 return; 239 return;
241 } 240 }
242 241
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 expected_file, actual_contents.c_str(), actual_contents.size())); 392 expected_file, actual_contents.c_str(), actual_contents.size()));
394 LOG(INFO) << "Wrote expectations to: " 393 LOG(INFO) << "Wrote expectations to: "
395 << expected_file.LossyDisplayName(); 394 << expected_file.LossyDisplayName();
396 } 395 }
397 } else { 396 } else {
398 LOG(INFO) << "Test output matches expectations."; 397 LOG(INFO) << "Test output matches expectations.";
399 } 398 }
400 } 399 }
401 400
402 } // namespace content 401 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698