Commit 1ab167c2 authored by Kevin Babbitt's avatar Kevin Babbitt Committed by Commit Bot

Address comments on DumpAccessibilityTestHelper

Address comments left on http://crrev.com/c/1669947 post-land.

Bug: 974397
Change-Id: I2f50f9c676d89ed1c20b06913d6607cd0dc41122
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1750151Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Reviewed-by: default avatarNektarios Paisios <nektar@chromium.org>
Commit-Queue: Kevin Babbitt <kbabbitt@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#686602}
parent 47a0f04e
...@@ -2337,16 +2337,16 @@ class PDFExtensionAccessibilityTreeDumpTest ...@@ -2337,16 +2337,16 @@ class PDFExtensionAccessibilityTreeDumpTest
// the expectation file contains a skip marker. // the expectation file contains a skip marker.
// This is used to skip certain tests on certain platforms. // This is used to skip certain tests on certain platforms.
content::DumpAccessibilityTestHelper test_helper(formatter.get()); content::DumpAccessibilityTestHelper test_helper(formatter.get());
base::Optional<base::FilePath> expected_file_path = base::FilePath expected_file_path =
test_helper.GetExpectationFilePath(test_file_path); test_helper.GetExpectationFilePath(test_file_path);
if (!expected_file_path) { if (expected_file_path.empty()) {
LOG(INFO) << "No expectation file present, ignoring test on this " LOG(INFO) << "No expectation file present, ignoring test on this "
"platform."; "platform.";
return; return;
} }
base::Optional<std::vector<std::string>> expected_lines = base::Optional<std::vector<std::string>> expected_lines =
test_helper.LoadExpectationFile(*expected_file_path); test_helper.LoadExpectationFile(expected_file_path);
if (!expected_lines) { if (!expected_lines) {
LOG(INFO) << "Skipping this test on this platform."; LOG(INFO) << "Skipping this test on this platform.";
return; return;
...@@ -2378,7 +2378,7 @@ class PDFExtensionAccessibilityTreeDumpTest ...@@ -2378,7 +2378,7 @@ class PDFExtensionAccessibilityTreeDumpTest
// Validate the dump against the expectation file. // Validate the dump against the expectation file.
EXPECT_TRUE(test_helper.ValidateAgainstExpectation( EXPECT_TRUE(test_helper.ValidateAgainstExpectation(
test_file_path, *expected_file_path, actual_lines, *expected_lines)); test_file_path, expected_file_path, actual_lines, *expected_lines));
} }
void AddDefaultFilters(std::vector<PropertyFilter>* property_filters) { void AddDefaultFilters(std::vector<PropertyFilter>* property_filters) {
......
...@@ -225,16 +225,15 @@ void DumpAccessibilityTestBase::RunTestForPlatform( ...@@ -225,16 +225,15 @@ void DumpAccessibilityTestBase::RunTestForPlatform(
// We have to check for this in advance in order to avoid waiting on a // We have to check for this in advance in order to avoid waiting on a
// WAIT-FOR directive in the source file that's looking for something not // WAIT-FOR directive in the source file that's looking for something not
// supported on the current platform. // supported on the current platform.
base::Optional<base::FilePath> expected_file = base::FilePath expected_file = test_helper.GetExpectationFilePath(file_path);
test_helper.GetExpectationFilePath(file_path); if (expected_file.empty()) {
if (!expected_file) {
LOG(INFO) << "No expectation file present, ignoring test on this " LOG(INFO) << "No expectation file present, ignoring test on this "
"platform."; "platform.";
return; return;
} }
base::Optional<std::vector<std::string>> expected_lines = base::Optional<std::vector<std::string>> expected_lines =
test_helper.LoadExpectationFile(*expected_file); test_helper.LoadExpectationFile(expected_file);
if (!expected_lines) { if (!expected_lines) {
LOG(INFO) << "Skipping this test on this platform."; LOG(INFO) << "Skipping this test on this platform.";
return; return;
...@@ -377,7 +376,7 @@ void DumpAccessibilityTestBase::RunTestForPlatform( ...@@ -377,7 +376,7 @@ void DumpAccessibilityTestBase::RunTestForPlatform(
// Validate against the expectation file. // Validate against the expectation file.
bool matches_expectation = test_helper.ValidateAgainstExpectation( bool matches_expectation = test_helper.ValidateAgainstExpectation(
file_path, *expected_file, actual_lines, *expected_lines); file_path, expected_file, actual_lines, *expected_lines);
EXPECT_TRUE(matches_expectation); EXPECT_TRUE(matches_expectation);
if (!matches_expectation) if (!matches_expectation)
OnDiffFailed(); OnDiffFailed();
......
...@@ -26,8 +26,7 @@ DumpAccessibilityTestHelper::DumpAccessibilityTestHelper( ...@@ -26,8 +26,7 @@ DumpAccessibilityTestHelper::DumpAccessibilityTestHelper(
AccessibilityTreeFormatter* formatter) AccessibilityTreeFormatter* formatter)
: formatter_(formatter) {} : formatter_(formatter) {}
base::Optional<base::FilePath> base::FilePath DumpAccessibilityTestHelper::GetExpectationFilePath(
DumpAccessibilityTestHelper::GetExpectationFilePath(
const base::FilePath& test_file_path) { const base::FilePath& test_file_path) {
base::ScopedAllowBlockingForTesting allow_blocking; base::ScopedAllowBlockingForTesting allow_blocking;
base::FilePath expected_file_path; base::FilePath expected_file_path;
...@@ -56,7 +55,7 @@ DumpAccessibilityTestHelper::GetExpectationFilePath( ...@@ -56,7 +55,7 @@ DumpAccessibilityTestHelper::GetExpectationFilePath(
<< " (it can be empty) and then run this test " << " (it can be empty) and then run this test "
<< "with the switch: --" << "with the switch: --"
<< switches::kGenerateAccessibilityTestExpectations; << switches::kGenerateAccessibilityTestExpectations;
return base::nullopt; return base::FilePath();
} }
base::Optional<std::vector<std::string>> base::Optional<std::vector<std::string>>
......
...@@ -18,17 +18,17 @@ class AccessibilityTreeFormatter; ...@@ -18,17 +18,17 @@ class AccessibilityTreeFormatter;
// A helper class for writing accessibility tree dump tests. // A helper class for writing accessibility tree dump tests.
class DumpAccessibilityTestHelper { class DumpAccessibilityTestHelper {
public: public:
DumpAccessibilityTestHelper(AccessibilityTreeFormatter* formatter); explicit DumpAccessibilityTestHelper(AccessibilityTreeFormatter* formatter);
~DumpAccessibilityTestHelper() = default; ~DumpAccessibilityTestHelper() = default;
// Returns a path to an expectation file for the current platform. If no // Returns a path to an expectation file for the current platform. If no
// suitable expectation file can be found, logs an error message and returns // suitable expectation file can be found, logs an error message and returns
// nullopt. // an empty path.
base::Optional<base::FilePath> GetExpectationFilePath( base::FilePath GetExpectationFilePath(const base::FilePath& test_file_path);
const base::FilePath& test_file_path);
// Loads the given expectation file. Returns nullopt if the file contains a // Loads the given expectation file and returns the contents. An expectation
// skip marker. // file may be empty, in which case an empty vector is returned.
// Returns nullopt if the file contains a skip marker.
static base::Optional<std::vector<std::string>> LoadExpectationFile( static base::Optional<std::vector<std::string>> LoadExpectationFile(
const base::FilePath& expected_file); const base::FilePath& expected_file);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment