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
3 // found in the LICENSE file.
5 #ifndef CONTENT_TEST_ACCESSIBILITY_BROWSER_TEST_UTILS_H_
6 #define CONTENT_TEST_ACCESSIBILITY_BROWSER_TEST_UTILS_H_
8 #include "base/memory/weak_ptr.h"
9 #include "content/common/accessibility_mode_enums.h"
10 #include "ui/accessibility/ax_node_data.h"
11 #include "ui/accessibility/ax_tree.h"
15 class MessageLoopRunner
;
16 class RenderFrameHostImpl
;
19 // Create an instance of this class *before* doing any operation that
20 // might generate an accessibility event (like a page navigation or
21 // clicking on a button). Then call WaitForNotification
22 // afterwards to block until the specified accessibility notification has been
24 class AccessibilityNotificationWaiter
{
26 explicit AccessibilityNotificationWaiter(Shell
* shell
);
27 AccessibilityNotificationWaiter(
29 AccessibilityMode accessibility_mode
,
31 AccessibilityNotificationWaiter(
32 RenderFrameHostImpl
* frame_host
,
34 ~AccessibilityNotificationWaiter();
36 // Blocks until the specific accessibility notification registered in
37 // AccessibilityNotificationWaiter is received. Ignores notifications for
39 void WaitForNotification();
41 // After WaitForNotification has returned, this will retrieve
42 // the tree of accessibility nodes received from the renderer process.
43 const ui::AXTree
& GetAXTree() const;
45 // After WaitForNotification returns, use this to retrieve the id of the
46 // node that was the target of the event.
47 int event_target_id() { return event_target_id_
; }
50 // Callback from RenderViewHostImpl.
51 void OnAccessibilityEvent(ui::AXEvent event
, int event_target_id
);
53 // Helper function to determine if the accessibility tree in
54 // GetAXTree() is about the page with the url "about:blank".
57 RenderFrameHostImpl
* frame_host_
;
58 ui::AXEvent event_to_wait_for_
;
59 scoped_refptr
<MessageLoopRunner
> loop_runner_
;
60 base::WeakPtrFactory
<AccessibilityNotificationWaiter
> weak_factory_
;
63 DISALLOW_COPY_AND_ASSIGN(AccessibilityNotificationWaiter
);
66 } // namespace content
68 #endif // CONTENT_TEST_ACCESSIBILITY_BROWSER_TEST_UTILS_H_