Chromium Code Reviews| 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..0899f6571ed073ac5f315ae9b1a720df9ce21afd 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,31 @@ void DumpAccessibilityTestBase::RunTestForPlatform( |
| : " (native accessibility tree for this platform)"); |
| std::string html_contents; |
| - base::ReadFileToString(file_path, &html_contents); |
| + { |
| + base::ThreadRestrictions::ScopedAllowIO allow_io_for_reading_test_input; |
| + base::ReadFileToString(file_path, &html_contents); |
| + } |
|
jam
2016/07/26 23:52:16
nit: seems more readable to keep this thread restr
Łukasz Anforowicz
2016/07/27 16:18:14
Done.
|
| // Read the 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_reading_expected_file; |
| + 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 +388,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: " |