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_node_data.h" | 9 #include "content/common/accessibility_node_data.h" |
10 #include "content/common/accessibility_notification.h" | |
11 #include "content/common/view_message_enums.h" | 10 #include "content/common/view_message_enums.h" |
12 | 11 |
13 namespace content { | 12 namespace content { |
14 | 13 |
15 class MessageLoopRunner; | 14 class MessageLoopRunner; |
16 class RenderViewHostImpl; | 15 class RenderViewHostImpl; |
17 class Shell; | 16 class Shell; |
18 | 17 |
19 // Create an instance of this class *before* doing any operation that | 18 // Create an instance of this class *before* doing any operation that |
20 // might generate an accessibility event (like a page navigation or | 19 // might generate an accessibility event (like a page navigation or |
21 // clicking on a button). Then call WaitForNotification | 20 // clicking on a button). Then call WaitForNotification |
22 // afterwards to block until the specified accessibility notification has been | 21 // afterwards to block until the specified accessibility notification has been |
23 // received. | 22 // received. |
24 class AccessibilityNotificationWaiter { | 23 class AccessibilityNotificationWaiter { |
25 public: | 24 public: |
26 AccessibilityNotificationWaiter( | 25 AccessibilityNotificationWaiter( |
27 Shell* shell, | 26 Shell* shell, |
28 AccessibilityMode accessibility_mode, | 27 AccessibilityMode accessibility_mode, |
29 AccessibilityNotification notification); | 28 WebKit::WebAXEvent event); |
30 ~AccessibilityNotificationWaiter(); | 29 ~AccessibilityNotificationWaiter(); |
31 | 30 |
32 // Blocks until the specific accessibility notification registered in | 31 // Blocks until the specific accessibility notification registered in |
33 // AccessibilityNotificationWaiter is received. Ignores notifications for | 32 // AccessibilityNotificationWaiter is received. Ignores notifications for |
34 // "about:blank". | 33 // "about:blank". |
35 void WaitForNotification(); | 34 void WaitForNotification(); |
36 | 35 |
37 // After WaitForNotification has returned, this will retrieve | 36 // After WaitForNotification has returned, this will retrieve |
38 // the tree of accessibility nodes received from the renderer process. | 37 // the tree of accessibility nodes received from the renderer process. |
39 const AccessibilityNodeDataTreeNode& GetAccessibilityNodeDataTree() const; | 38 const AccessibilityNodeDataTreeNode& GetAccessibilityNodeDataTree() const; |
40 | 39 |
41 private: | 40 private: |
42 // Callback from RenderViewHostImpl. | 41 // Callback from RenderViewHostImpl. |
43 void OnAccessibilityNotification(AccessibilityNotification notification); | 42 void OnAccessibilityEvent(WebKit::WebAXEvent event); |
44 | 43 |
45 // Helper function to determine if the accessibility tree in | 44 // Helper function to determine if the accessibility tree in |
46 // GetAccessibilityNodeDataTree() is about the page with the url | 45 // GetAccessibilityNodeDataTree() is about the page with the url |
47 // "about:blank". | 46 // "about:blank". |
48 bool IsAboutBlank(); | 47 bool IsAboutBlank(); |
49 | 48 |
50 Shell* shell_; | 49 Shell* shell_; |
51 RenderViewHostImpl* view_host_; | 50 RenderViewHostImpl* view_host_; |
52 AccessibilityNotification notification_to_wait_for_; | 51 WebKit::WebAXEvent event_to_wait_for_; |
53 scoped_refptr<MessageLoopRunner> loop_runner_; | 52 scoped_refptr<MessageLoopRunner> loop_runner_; |
54 base::WeakPtrFactory<AccessibilityNotificationWaiter> weak_factory_; | 53 base::WeakPtrFactory<AccessibilityNotificationWaiter> weak_factory_; |
55 | 54 |
56 DISALLOW_COPY_AND_ASSIGN(AccessibilityNotificationWaiter); | 55 DISALLOW_COPY_AND_ASSIGN(AccessibilityNotificationWaiter); |
57 }; | 56 }; |
58 | 57 |
59 } // namespace content | 58 } // namespace content |
60 | 59 |
61 #endif // CONTENT_TEST_ACCESSIBILITY_BROWSER_TEST_UTILS_H_ | 60 #endif // CONTENT_TEST_ACCESSIBILITY_BROWSER_TEST_UTILS_H_ |
OLD | NEW |