| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/test/accessibility_browser_test_utils.h" | 5 #include "content/test/accessibility_browser_test_utils.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "content/browser/renderer_host/render_view_host_impl.h" | 11 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 12 #include "content/common/view_message_enums.h" | 12 #include "content/common/view_message_enums.h" |
| 13 #include "content/port/browser/render_widget_host_view_port.h" | 13 #include "content/port/browser/render_widget_host_view_port.h" |
| 14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 15 #include "content/public/common/url_constants.h" | 15 #include "content/public/common/url_constants.h" |
| 16 #include "content/public/test/test_utils.h" | 16 #include "content/public/test/test_utils.h" |
| 17 #include "content/shell/browser/shell.h" | 17 #include "content/shell/browser/shell.h" |
| 18 #include "ui/accessibility/ax_node.h" | 18 #include "ui/accessibility/ax_node.h" |
| 19 | 19 |
| 20 namespace content { | 20 namespace content { |
| 21 | 21 |
| 22 AccessibilityNotificationWaiter::AccessibilityNotificationWaiter(Shell* shell) | |
| 23 : shell_(shell), | |
| 24 event_to_wait_for_(ui::AX_EVENT_NONE), | |
| 25 loop_runner_(new MessageLoopRunner()), | |
| 26 weak_factory_(this) { | |
| 27 WebContents* web_contents = shell_->web_contents(); | |
| 28 view_host_ = static_cast<RenderViewHostImpl*>( | |
| 29 web_contents->GetRenderViewHost()); | |
| 30 view_host_->SetAccessibilityCallbackForTesting( | |
| 31 base::Bind(&AccessibilityNotificationWaiter::OnAccessibilityEvent, | |
| 32 weak_factory_.GetWeakPtr())); | |
| 33 } | |
| 34 | |
| 35 AccessibilityNotificationWaiter::AccessibilityNotificationWaiter( | 22 AccessibilityNotificationWaiter::AccessibilityNotificationWaiter( |
| 36 Shell* shell, | 23 Shell* shell, |
| 37 AccessibilityMode accessibility_mode, | 24 AccessibilityMode accessibility_mode, |
| 38 ui::AXEvent event_type) | 25 ui::AXEvent event_type, |
| 26 RenderViewHostImpl* render_view_host_impl) |
| 39 : shell_(shell), | 27 : shell_(shell), |
| 40 event_to_wait_for_(event_type), | 28 event_to_wait_for_(event_type), |
| 41 loop_runner_(new MessageLoopRunner()), | 29 loop_runner_(new MessageLoopRunner()), |
| 42 weak_factory_(this) { | 30 weak_factory_(this) { |
| 43 WebContents* web_contents = shell_->web_contents(); | 31 if (render_view_host_impl) { |
| 44 view_host_ = static_cast<RenderViewHostImpl*>( | 32 view_host_ = render_view_host_impl; |
| 45 web_contents->GetRenderViewHost()); | 33 } else { |
| 34 WebContents* web_contents = shell_->web_contents(); |
| 35 view_host_ = static_cast<RenderViewHostImpl*>( |
| 36 web_contents->GetRenderViewHost()); |
| 37 } |
| 46 view_host_->SetAccessibilityCallbackForTesting( | 38 view_host_->SetAccessibilityCallbackForTesting( |
| 47 base::Bind(&AccessibilityNotificationWaiter::OnAccessibilityEvent, | 39 base::Bind(&AccessibilityNotificationWaiter::OnAccessibilityEvent, |
| 48 weak_factory_.GetWeakPtr())); | 40 weak_factory_.GetWeakPtr())); |
| 49 view_host_->AddAccessibilityMode(accessibility_mode); | 41 view_host_->AddAccessibilityMode(accessibility_mode); |
| 50 } | 42 } |
| 51 | 43 |
| 52 AccessibilityNotificationWaiter::~AccessibilityNotificationWaiter() { | 44 AccessibilityNotificationWaiter::~AccessibilityNotificationWaiter() { |
| 53 } | 45 } |
| 54 | 46 |
| 55 void AccessibilityNotificationWaiter::WaitForNotification() { | 47 void AccessibilityNotificationWaiter::WaitForNotification() { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 76 for (size_t i = 0; i < root.string_attributes.size(); ++i) { | 68 for (size_t i = 0; i < root.string_attributes.size(); ++i) { |
| 77 if (root.string_attributes[i].first != ui::AX_ATTR_DOC_URL) | 69 if (root.string_attributes[i].first != ui::AX_ATTR_DOC_URL) |
| 78 continue; | 70 continue; |
| 79 const std::string& doc_url = root.string_attributes[i].second; | 71 const std::string& doc_url = root.string_attributes[i].second; |
| 80 return doc_url == kAboutBlankURL; | 72 return doc_url == kAboutBlankURL; |
| 81 } | 73 } |
| 82 return false; | 74 return false; |
| 83 } | 75 } |
| 84 | 76 |
| 85 } // namespace content | 77 } // namespace content |
| OLD | NEW |