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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « PRESUBMIT.py ('k') | content/browser/accessibility/dump_accessibility_events_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/accessibility/dump_accessibility_browsertest_base.cc
diff --git a/content/browser/accessibility/dump_accessibility_browsertest_base.cc b/content/browser/accessibility/dump_accessibility_browsertest_base.cc
index d4eab1b38746818e00f16e94c15a856aae22eb8f..af1e10e1d7863fb022ca4133e63638c851e9d739 100644
--- a/content/browser/accessibility/dump_accessibility_browsertest_base.cc
+++ b/content/browser/accessibility/dump_accessibility_browsertest_base.cc
@@ -15,6 +15,7 @@
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/threading/thread_restrictions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "content/browser/accessibility/accessibility_tree_formatter.h"
@@ -204,24 +205,30 @@ void DumpAccessibilityTestBase::RunTestForPlatform(
: " (native accessibility tree for this platform)");
std::string html_contents;
- base::ReadFileToString(file_path, &html_contents);
-
- // Read the expected file.
+ base::FilePath expected_file;
std::string expected_contents_raw;
- base::FilePath expected_file =
- base::FilePath(file_path.RemoveExtension().value() +
- formatter_->GetExpectedFileSuffix());
- if (!base::PathExists(expected_file)) {
- LOG(INFO) << "File not found: " << expected_file.LossyDisplayName();
- LOG(INFO) << "No expectation file present, ignoring test on this platform."
- << " To run this test anyway, create "
- << expected_file.LossyDisplayName()
- << " (it can be empty) and then run content_browsertests "
- << "with the switch: --"
- << switches::kGenerateAccessibilityTestExpectations;
- return;
+ {
+ base::ThreadRestrictions::ScopedAllowIO allow_io_for_test_setup;
+ base::ReadFileToString(file_path, &html_contents);
+
+ // Read the expected file.
+ expected_file =
+ base::FilePath(file_path.RemoveExtension().value() +
+ formatter_->GetExpectedFileSuffix());
+
+ if (!base::PathExists(expected_file)) {
+ LOG(INFO) << "File not found: " << expected_file.LossyDisplayName();
+ LOG(INFO)
+ << "No expectation file present, ignoring test on this platform."
+ << " To run this test anyway, create "
+ << expected_file.LossyDisplayName()
+ << " (it can be empty) and then run content_browsertests "
+ << "with the switch: --"
+ << switches::kGenerateAccessibilityTestExpectations;
+ return;
+ }
+ base::ReadFileToString(expected_file, &expected_contents_raw);
}
- base::ReadFileToString(expected_file, &expected_contents_raw);
// Tolerate Windows-style line endings (\r\n) in the expected file:
// normalize by deleting all \r from the file (if any) to leave only \n.
@@ -380,6 +387,7 @@ void DumpAccessibilityTestBase::RunTestForPlatform(
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kGenerateAccessibilityTestExpectations)) {
+ base::ThreadRestrictions::ScopedAllowIO allow_io_to_write_expected_file;
CHECK(base::WriteFile(
expected_file, actual_contents.c_str(), actual_contents.size()));
LOG(INFO) << "Wrote expectations to: "
« 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