| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <set> | 5 #include <set> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 14 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
| 15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "content/browser/accessibility/accessibility_tree_formatter.h" | 17 #include "content/browser/accessibility/accessibility_tree_formatter.h" |
| 18 #include "content/browser/accessibility/browser_accessibility.h" | 18 #include "content/browser/accessibility/browser_accessibility.h" |
| 19 #include "content/browser/accessibility/browser_accessibility_manager.h" | 19 #include "content/browser/accessibility/browser_accessibility_manager.h" |
| 20 #include "content/browser/renderer_host/render_view_host_impl.h" | 20 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 21 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 21 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 22 #include "content/browser/web_contents/web_contents_impl.h" |
| 22 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
| 23 #include "content/public/common/content_paths.h" | 24 #include "content/public/common/content_paths.h" |
| 24 #include "content/public/common/content_switches.h" | 25 #include "content/public/common/content_switches.h" |
| 25 #include "content/public/common/url_constants.h" | 26 #include "content/public/common/url_constants.h" |
| 26 #include "content/public/test/content_browser_test.h" | 27 #include "content/public/test/content_browser_test.h" |
| 27 #include "content/public/test/content_browser_test_utils.h" | 28 #include "content/public/test/content_browser_test_utils.h" |
| 28 #include "content/shell/browser/shell.h" | 29 #include "content/shell/browser/shell.h" |
| 29 #include "content/test/accessibility_browser_test_utils.h" | 30 #include "content/test/accessibility_browser_test_utils.h" |
| 30 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
| 31 | 32 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 waiter.reset(new AccessibilityNotificationWaiter( | 217 waiter.reset(new AccessibilityNotificationWaiter( |
| 217 shell(), AccessibilityModeComplete, ui::AX_EVENT_LOAD_COMPLETE)); | 218 shell(), AccessibilityModeComplete, ui::AX_EVENT_LOAD_COMPLETE)); |
| 218 } | 219 } |
| 219 | 220 |
| 220 // Load the test html. | 221 // Load the test html. |
| 221 NavigateToURL(shell(), url); | 222 NavigateToURL(shell(), url); |
| 222 | 223 |
| 223 // Wait for notifications. If there's a @WAIT-FOR directive, break when | 224 // Wait for notifications. If there's a @WAIT-FOR directive, break when |
| 224 // the text we're waiting for appears in the dump, otherwise break after | 225 // the text we're waiting for appears in the dump, otherwise break after |
| 225 // the first notification, which will be a load complete. | 226 // the first notification, which will be a load complete. |
| 226 RenderWidgetHostViewBase* host_view = static_cast<RenderWidgetHostViewBase*>( | 227 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( |
| 227 shell()->web_contents()->GetRenderWidgetHostView()); | 228 shell()->web_contents()); |
| 228 std::string actual_contents; | 229 std::string actual_contents; |
| 229 do { | 230 do { |
| 230 waiter->WaitForNotification(); | 231 waiter->WaitForNotification(); |
| 231 base::string16 actual_contents_utf16; | 232 base::string16 actual_contents_utf16; |
| 232 AccessibilityTreeFormatter formatter( | 233 AccessibilityTreeFormatter formatter( |
| 233 host_view->GetBrowserAccessibilityManager()->GetRoot()); | 234 web_contents->GetRootBrowserAccessibilityManager()->GetRoot()); |
| 234 formatter.SetFilters(filters); | 235 formatter.SetFilters(filters); |
| 235 formatter.FormatAccessibilityTree(&actual_contents_utf16); | 236 formatter.FormatAccessibilityTree(&actual_contents_utf16); |
| 236 actual_contents = base::UTF16ToUTF8(actual_contents_utf16); | 237 actual_contents = base::UTF16ToUTF8(actual_contents_utf16); |
| 237 } while (!wait_for.empty() && | 238 } while (!wait_for.empty() && |
| 238 actual_contents.find(wait_for) == std::string::npos); | 239 actual_contents.find(wait_for) == std::string::npos); |
| 239 | 240 |
| 240 // Perform a diff (or write the initial baseline). | 241 // Perform a diff (or write the initial baseline). |
| 241 std::vector<std::string> actual_lines, expected_lines; | 242 std::vector<std::string> actual_lines, expected_lines; |
| 242 Tokenize(actual_contents, "\n", &actual_lines); | 243 Tokenize(actual_contents, "\n", &actual_lines); |
| 243 Tokenize(expected_contents, "\n", &expected_lines); | 244 Tokenize(expected_contents, "\n", &expected_lines); |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityWbr) { | 589 IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityWbr) { |
| 589 RunTest(FILE_PATH_LITERAL("wbr.html")); | 590 RunTest(FILE_PATH_LITERAL("wbr.html")); |
| 590 } | 591 } |
| 591 | 592 |
| 592 IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, | 593 IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, |
| 593 AccessibilityAriaActivedescendant) { | 594 AccessibilityAriaActivedescendant) { |
| 594 RunTest(FILE_PATH_LITERAL("aria-activedescendant.html")); | 595 RunTest(FILE_PATH_LITERAL("aria-activedescendant.html")); |
| 595 } | 596 } |
| 596 | 597 |
| 597 } // namespace content | 598 } // namespace content |
| OLD | NEW |