OLD | NEW |
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 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 const base::FilePath file_path, const char* file_dir) { | 190 const base::FilePath file_path, const char* file_dir) { |
191 formatter_.reset(CreateAccessibilityTreeFormatter()); | 191 formatter_.reset(CreateAccessibilityTreeFormatter()); |
192 | 192 |
193 // Disable the "hot tracked" state (set when the mouse is hovering over | 193 // Disable the "hot tracked" state (set when the mouse is hovering over |
194 // an object) because it makes test output change based on the mouse position. | 194 // an object) because it makes test output change based on the mouse position. |
195 BrowserAccessibilityStateImpl::GetInstance()-> | 195 BrowserAccessibilityStateImpl::GetInstance()-> |
196 set_disable_hot_tracking_for_testing(true); | 196 set_disable_hot_tracking_for_testing(true); |
197 | 197 |
198 NavigateToURL(shell(), GURL(url::kAboutBlankURL)); | 198 NavigateToURL(shell(), GURL(url::kAboutBlankURL)); |
199 | 199 |
200 // Output the test path to help anyone who encounters a failure and needs | |
201 // to know where to look. | |
202 LOG(INFO) << "Testing: " << file_path.LossyDisplayName() | |
203 << (is_blink_pass_ ? " (internal Blink accessibility tree)" | |
204 : " (native accessibility tree for this platform)"); | |
205 | |
206 std::string html_contents; | 200 std::string html_contents; |
207 base::FilePath expected_file; | 201 base::FilePath expected_file; |
208 std::string expected_contents_raw; | 202 std::string expected_contents_raw; |
209 { | 203 { |
210 base::ThreadRestrictions::ScopedAllowIO allow_io_for_test_setup; | 204 base::ThreadRestrictions::ScopedAllowIO allow_io_for_test_setup; |
211 base::ReadFileToString(file_path, &html_contents); | 205 base::ReadFileToString(file_path, &html_contents); |
212 | 206 |
213 // Read the expected file. | 207 // Read the expected file. |
214 expected_file = | 208 expected_file = |
215 base::FilePath(file_path.RemoveExtension().value() + | 209 base::FilePath(file_path.RemoveExtension().value() + |
216 formatter_->GetExpectedFileSuffix()); | 210 formatter_->GetExpectedFileSuffix()); |
217 | 211 |
218 if (!base::PathExists(expected_file)) { | 212 if (!base::PathExists(expected_file)) { |
219 LOG(INFO) << "File not found: " << expected_file.LossyDisplayName(); | 213 LOG(INFO) << "File not found: " << expected_file.LossyDisplayName(); |
220 LOG(INFO) | 214 LOG(INFO) |
221 << "No expectation file present, ignoring test on this platform." | 215 << "No expectation file present, ignoring test on this platform." |
222 << " To run this test anyway, create " | 216 << " To run this test anyway, create " |
223 << expected_file.LossyDisplayName() | 217 << expected_file.LossyDisplayName() |
224 << " (it can be empty) and then run content_browsertests " | 218 << " (it can be empty) and then run content_browsertests " |
225 << "with the switch: --" | 219 << "with the switch: --" |
226 << switches::kGenerateAccessibilityTestExpectations; | 220 << switches::kGenerateAccessibilityTestExpectations; |
227 return; | 221 return; |
228 } | 222 } |
229 base::ReadFileToString(expected_file, &expected_contents_raw); | 223 base::ReadFileToString(expected_file, &expected_contents_raw); |
230 } | 224 } |
231 | 225 |
| 226 // Output the test path to help anyone who encounters a failure and needs |
| 227 // to know where to look. |
| 228 LOG(INFO) << "Testing: " |
| 229 << file_path.NormalizePathSeparatorsTo('/').LossyDisplayName(); |
| 230 LOG(INFO) << "Expected output: " |
| 231 << expected_file.NormalizePathSeparatorsTo('/').LossyDisplayName(); |
| 232 |
232 // Tolerate Windows-style line endings (\r\n) in the expected file: | 233 // Tolerate Windows-style line endings (\r\n) in the expected file: |
233 // 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. |
234 std::string expected_contents; | 235 std::string expected_contents; |
235 base::RemoveChars(expected_contents_raw, "\r", &expected_contents); | 236 base::RemoveChars(expected_contents_raw, "\r", &expected_contents); |
236 | 237 |
237 if (!expected_contents.compare(0, strlen(kMarkSkipFile), kMarkSkipFile)) { | 238 if (!expected_contents.compare(0, strlen(kMarkSkipFile), kMarkSkipFile)) { |
238 LOG(INFO) << "Skipping this test on this platform."; | 239 LOG(INFO) << "Skipping this test on this platform."; |
239 return; | 240 return; |
240 } | 241 } |
241 | 242 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 expected_file, actual_contents.c_str(), actual_contents.size())); | 393 expected_file, actual_contents.c_str(), actual_contents.size())); |
393 LOG(INFO) << "Wrote expectations to: " | 394 LOG(INFO) << "Wrote expectations to: " |
394 << expected_file.LossyDisplayName(); | 395 << expected_file.LossyDisplayName(); |
395 } | 396 } |
396 } else { | 397 } else { |
397 LOG(INFO) << "Test output matches expectations."; | 398 LOG(INFO) << "Test output matches expectations."; |
398 } | 399 } |
399 } | 400 } |
400 | 401 |
401 } // namespace content | 402 } // namespace content |
OLD | NEW |