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

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

Issue 2175933002: More aggressive IO asserts in content_browsertests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use 1 less instance of ScopedAllowIO in DumpAccessibilityTestBase::RunTestForPlatform. Created 4 years, 4 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
« no previous file with comments | « PRESUBMIT.py ('k') | content/browser/accessibility/dump_accessibility_events_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
14 #include "base/strings/string_split.h" 14 #include "base/strings/string_split.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
18 #include "base/threading/thread_restrictions.h"
18 #include "base/threading/thread_task_runner_handle.h" 19 #include "base/threading/thread_task_runner_handle.h"
19 #include "build/build_config.h" 20 #include "build/build_config.h"
20 #include "content/browser/accessibility/accessibility_tree_formatter.h" 21 #include "content/browser/accessibility/accessibility_tree_formatter.h"
21 #include "content/browser/accessibility/accessibility_tree_formatter_blink.h" 22 #include "content/browser/accessibility/accessibility_tree_formatter_blink.h"
22 #include "content/browser/accessibility/browser_accessibility.h" 23 #include "content/browser/accessibility/browser_accessibility.h"
23 #include "content/browser/accessibility/browser_accessibility_manager.h" 24 #include "content/browser/accessibility/browser_accessibility_manager.h"
24 #include "content/browser/accessibility/browser_accessibility_state_impl.h" 25 #include "content/browser/accessibility/browser_accessibility_state_impl.h"
25 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" 26 #include "content/browser/frame_host/render_widget_host_view_child_frame.h"
26 #include "content/browser/web_contents/web_contents_impl.h" 27 #include "content/browser/web_contents/web_contents_impl.h"
27 #include "content/public/browser/web_contents.h" 28 #include "content/public/browser/web_contents.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 198
198 NavigateToURL(shell(), GURL(url::kAboutBlankURL)); 199 NavigateToURL(shell(), GURL(url::kAboutBlankURL));
199 200
200 // Output the test path to help anyone who encounters a failure and needs 201 // Output the test path to help anyone who encounters a failure and needs
201 // to know where to look. 202 // to know where to look.
202 LOG(INFO) << "Testing: " << file_path.LossyDisplayName() 203 LOG(INFO) << "Testing: " << file_path.LossyDisplayName()
203 << (is_blink_pass_ ? " (internal Blink accessibility tree)" 204 << (is_blink_pass_ ? " (internal Blink accessibility tree)"
204 : " (native accessibility tree for this platform)"); 205 : " (native accessibility tree for this platform)");
205 206
206 std::string html_contents; 207 std::string html_contents;
207 base::ReadFileToString(file_path, &html_contents); 208 base::FilePath expected_file;
209 std::string expected_contents_raw;
210 {
211 base::ThreadRestrictions::ScopedAllowIO allow_io_for_test_setup;
212 base::ReadFileToString(file_path, &html_contents);
208 213
209 // Read the expected file. 214 // Read the expected file.
210 std::string expected_contents_raw; 215 expected_file =
211 base::FilePath expected_file = 216 base::FilePath(file_path.RemoveExtension().value() +
212 base::FilePath(file_path.RemoveExtension().value() + 217 formatter_->GetExpectedFileSuffix());
213 formatter_->GetExpectedFileSuffix()); 218
214 if (!base::PathExists(expected_file)) { 219 if (!base::PathExists(expected_file)) {
215 LOG(INFO) << "File not found: " << expected_file.LossyDisplayName(); 220 LOG(INFO) << "File not found: " << expected_file.LossyDisplayName();
216 LOG(INFO) << "No expectation file present, ignoring test on this platform." 221 LOG(INFO)
217 << " To run this test anyway, create " 222 << "No expectation file present, ignoring test on this platform."
218 << expected_file.LossyDisplayName() 223 << " To run this test anyway, create "
219 << " (it can be empty) and then run content_browsertests " 224 << expected_file.LossyDisplayName()
220 << "with the switch: --" 225 << " (it can be empty) and then run content_browsertests "
221 << switches::kGenerateAccessibilityTestExpectations; 226 << "with the switch: --"
222 return; 227 << switches::kGenerateAccessibilityTestExpectations;
228 return;
229 }
230 base::ReadFileToString(expected_file, &expected_contents_raw);
223 } 231 }
224 base::ReadFileToString(expected_file, &expected_contents_raw);
225 232
226 // Tolerate Windows-style line endings (\r\n) in the expected file: 233 // Tolerate Windows-style line endings (\r\n) in the expected file:
227 // normalize by deleting all \r from the file (if any) to leave only \n. 234 // normalize by deleting all \r from the file (if any) to leave only \n.
228 std::string expected_contents; 235 std::string expected_contents;
229 base::RemoveChars(expected_contents_raw, "\r", &expected_contents); 236 base::RemoveChars(expected_contents_raw, "\r", &expected_contents);
230 237
231 if (!expected_contents.compare(0, strlen(kMarkSkipFile), kMarkSkipFile)) { 238 if (!expected_contents.compare(0, strlen(kMarkSkipFile), kMarkSkipFile)) {
232 LOG(INFO) << "Skipping this test on this platform."; 239 LOG(INFO) << "Skipping this test on this platform.";
233 return; 240 return;
234 } 241 }
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 "%1s %4d %s\n", is_diff? kSignalDiff : "", line + 1, 380 "%1s %4d %s\n", is_diff? kSignalDiff : "", line + 1,
374 expected_lines[line].c_str()); 381 expected_lines[line].c_str());
375 } 382 }
376 diff += "\nActual\n"; 383 diff += "\nActual\n";
377 diff += "------\n"; 384 diff += "------\n";
378 diff += actual_contents; 385 diff += actual_contents;
379 LOG(ERROR) << "Diff:\n" << diff; 386 LOG(ERROR) << "Diff:\n" << diff;
380 387
381 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 388 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
382 switches::kGenerateAccessibilityTestExpectations)) { 389 switches::kGenerateAccessibilityTestExpectations)) {
390 base::ThreadRestrictions::ScopedAllowIO allow_io_to_write_expected_file;
383 CHECK(base::WriteFile( 391 CHECK(base::WriteFile(
384 expected_file, actual_contents.c_str(), actual_contents.size())); 392 expected_file, actual_contents.c_str(), actual_contents.size()));
385 LOG(INFO) << "Wrote expectations to: " 393 LOG(INFO) << "Wrote expectations to: "
386 << expected_file.LossyDisplayName(); 394 << expected_file.LossyDisplayName();
387 } 395 }
388 } else { 396 } else {
389 LOG(INFO) << "Test output matches expectations."; 397 LOG(INFO) << "Test output matches expectations.";
390 } 398 }
391 } 399 }
392 400
393 } // namespace content 401 } // namespace content
OLDNEW
« no previous file with comments | « PRESUBMIT.py ('k') | content/browser/accessibility/dump_accessibility_events_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698