| 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 #ifndef CONTENT_TEST_ACCESSIBILITY_BROWSER_TEST_UTILS_H_ | 5 #ifndef CONTENT_TEST_ACCESSIBILITY_BROWSER_TEST_UTILS_H_ |
| 6 #define CONTENT_TEST_ACCESSIBILITY_BROWSER_TEST_UTILS_H_ | 6 #define CONTENT_TEST_ACCESSIBILITY_BROWSER_TEST_UTILS_H_ |
| 7 | 7 |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "content/common/accessibility_mode_enums.h" | 9 #include "content/common/accessibility_mode_enums.h" |
| 10 #include "ui/accessibility/ax_node_data.h" | 10 #include "ui/accessibility/ax_node_data.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // clicking on a button). Then call WaitForNotification | 21 // clicking on a button). Then call WaitForNotification |
| 22 // afterwards to block until the specified accessibility notification has been | 22 // afterwards to block until the specified accessibility notification has been |
| 23 // received. | 23 // received. |
| 24 class AccessibilityNotificationWaiter { | 24 class AccessibilityNotificationWaiter { |
| 25 public: | 25 public: |
| 26 explicit AccessibilityNotificationWaiter(Shell* shell); | 26 explicit AccessibilityNotificationWaiter(Shell* shell); |
| 27 AccessibilityNotificationWaiter( | 27 AccessibilityNotificationWaiter( |
| 28 Shell* shell, | 28 Shell* shell, |
| 29 AccessibilityMode accessibility_mode, | 29 AccessibilityMode accessibility_mode, |
| 30 ui::AXEvent event); | 30 ui::AXEvent event); |
| 31 AccessibilityNotificationWaiter( |
| 32 RenderFrameHostImpl* frame_host, |
| 33 ui::AXEvent event); |
| 31 ~AccessibilityNotificationWaiter(); | 34 ~AccessibilityNotificationWaiter(); |
| 32 | 35 |
| 33 // Blocks until the specific accessibility notification registered in | 36 // Blocks until the specific accessibility notification registered in |
| 34 // AccessibilityNotificationWaiter is received. Ignores notifications for | 37 // AccessibilityNotificationWaiter is received. Ignores notifications for |
| 35 // "about:blank". | 38 // "about:blank". |
| 36 void WaitForNotification(); | 39 void WaitForNotification(); |
| 37 | 40 |
| 38 // After WaitForNotification has returned, this will retrieve | 41 // After WaitForNotification has returned, this will retrieve |
| 39 // the tree of accessibility nodes received from the renderer process. | 42 // the tree of accessibility nodes received from the renderer process. |
| 40 const ui::AXTree& GetAXTree() const; | 43 const ui::AXTree& GetAXTree() const; |
| 41 | 44 |
| 42 // After WaitForNotification returns, use this to retrieve the id of the | 45 // After WaitForNotification returns, use this to retrieve the id of the |
| 43 // node that was the target of the event. | 46 // node that was the target of the event. |
| 44 int event_target_id() { return event_target_id_; } | 47 int event_target_id() { return event_target_id_; } |
| 45 | 48 |
| 46 private: | 49 private: |
| 47 // Callback from RenderViewHostImpl. | 50 // Callback from RenderViewHostImpl. |
| 48 void OnAccessibilityEvent(ui::AXEvent event, int event_target_id); | 51 void OnAccessibilityEvent(ui::AXEvent event, int event_target_id); |
| 49 | 52 |
| 50 // Helper function to determine if the accessibility tree in | 53 // Helper function to determine if the accessibility tree in |
| 51 // GetAXTree() is about the page with the url "about:blank". | 54 // GetAXTree() is about the page with the url "about:blank". |
| 52 bool IsAboutBlank(); | 55 bool IsAboutBlank(); |
| 53 | 56 |
| 54 Shell* shell_; | |
| 55 RenderFrameHostImpl* frame_host_; | 57 RenderFrameHostImpl* frame_host_; |
| 56 ui::AXEvent event_to_wait_for_; | 58 ui::AXEvent event_to_wait_for_; |
| 57 scoped_refptr<MessageLoopRunner> loop_runner_; | 59 scoped_refptr<MessageLoopRunner> loop_runner_; |
| 58 base::WeakPtrFactory<AccessibilityNotificationWaiter> weak_factory_; | 60 base::WeakPtrFactory<AccessibilityNotificationWaiter> weak_factory_; |
| 59 int event_target_id_; | 61 int event_target_id_; |
| 60 | 62 |
| 61 DISALLOW_COPY_AND_ASSIGN(AccessibilityNotificationWaiter); | 63 DISALLOW_COPY_AND_ASSIGN(AccessibilityNotificationWaiter); |
| 62 }; | 64 }; |
| 63 | 65 |
| 64 } // namespace content | 66 } // namespace content |
| 65 | 67 |
| 66 #endif // CONTENT_TEST_ACCESSIBILITY_BROWSER_TEST_UTILS_H_ | 68 #endif // CONTENT_TEST_ACCESSIBILITY_BROWSER_TEST_UTILS_H_ |
| OLD | NEW |