| 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: "
|
|
|