summaryrefslogtreecommitdiffstats
path: root/chrome/test/accessibility/accessibility_util.h
blob: 0659be8c9ba4776bbbe711b924efc9b17f0bb2cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_TEST_ACCESSIBILITY_ACCESSIBILITY_UTIL_H_
#define CHROME_TEST_ACCESSIBILITY_ACCESSIBILITY_UTIL_H_

#include <oleacc.h>

#include "base/string_util.h"

///////////////////////////////////////////////////////////////////////////////
// Functions and Globals that use the IAccessible interface.
// These are the wrappers to fetch accessible object interface and properties.
///////////////////////////////////////////////////////////////////////////////

// Variant ID pointing to object itself.
extern VARIANT id_self;

// Returns window handle to Chrome Browser, along with (if requested) its
// IAccessible implementation, by calling AccessibleObjectFromWindow on the
// window handle. The IAccessible hierarchy (root->app->client) is also verified
// in terms of accessible name and role. If [acc_obj] is NULL, only the window
// handle is returned.
HWND GetChromeBrowserWnd(IAccessible** acc_obj);

// Returns IAccessible pointer of object's child window, provided [parent_name]
// and its (0-based) [child_index]. If child is a leaf element (has no children)
// its variant id is returned with S_FALSE.
HRESULT GetChildAccessible(std::wstring parent_name, unsigned int child_index,
                           IAccessible** acc_obj);

// Returns IAccessible pointer for Tabstrip (does not have a window handle), by
// calling upon GetChildAccessible. Will never be a leaf element, as it always
// has at least one child.
HRESULT GetTabStripAccessible(IAccessible** acc_obj);

// Returns IAccessible pointer for BrowserView (does not have a window handle),
// by calling upon GetChildAccessible. Will never be a leaf element, as it
// always has at least one child.
HRESULT GetBrowserViewAccessible(IAccessible** acc_obj);

// Returns IAccessible pointer for Toolbar (does not have a window handle), by
// calling upon GetChildAccessible. Will never be a leaf element, as it always
// has at least one child.
HRESULT GetToolbarAccessible(IAccessible** acc_obj);

// Returns window handle to OmniBox(AddressBar) and IAccessible pointer (if
// requested), by calling AccessibleObjectFromWindow on the window handle. If
// [acc_obj] is NULL, only the window handle is returned.
HWND GetAddressBarWnd(IAccessible** acc_obj);

// Returns window handle to Find edit box and IAccessible pointer (if
// requested), by calling AccessibleObjectFromWindow on the window handle.  If
// [acc_obj] is NULL, only the window handle is returned.
HWND GetFindTextWnd(IAccessible** acc_obj);

// Returns window handle to Authentication dialog and IAccessible pointer (if
// requested), by calling AccessibleObjectFromWindow on the window handle.  If
// [acc_obj] is NULL, only the window handle is returned.
HWND GetAuthWnd(IAccessible** acc_obj);

// Fetches IAccessible pointer for a child, given the IAccessible for the parent
// ([acc_obj]) and a child id (passed in with the [child] VARIANT). Retrieves
// the child by calling get_accChild on [acc_obj].
HRESULT GetChildAccObject(IAccessible* acc_obj, VARIANT child,
                          IAccessible** child_acc_obj);

// Fetches IAccessible pointer for the parent of specified IAccessible object
// (by calling get_accParent on [acc_obj]).
HRESULT GetParentAccObject(IAccessible* acc_obj, IAccessible** parent_acc_obj);

// Returns number of children for the specified IAccessible. If [acc_obj]
// parameter is NULL, -1 is returned.
INT64 GetChildCount(IAccessible* acc_obj);

// Extracts (VARIANT)array of child items of specified IAccessible pointer,
// by calling the AccessibleChildren function in MSAA.
HRESULT GetChildrenArray(IAccessible* acc_obj, VARIANT* children);

// Activates specified window using IAccessible pointer and/or window handle.
// Also calls accSelect on [acc_obj] to set accessibility focus and selection.
HRESULT ActivateWnd(IAccessible* acc_obj, HWND hwnd);

// Returns title of tab whose index is specified. Tab index starts from 1.
BSTR GetTabName(INT64 tab_index);

// Returns number of tabs in tabstrip. If processing fails, it returns -1.
INT64 GetTabCnt();

// Returns Name of specified [acc_obj] or its [child], by calling get_accName.
// If input is invalid, an empty std::wstring is returned.
std::wstring GetName(IAccessible* acc_obj, VARIANT child = id_self);

// Returns Role of specified [acc_obj] or its [child], by calling get_accRole. A
// returned value of -1 indicates error.
LONG GetRole(IAccessible* acc_obj, VARIANT child = id_self);

// Returns State of specified [acc_obj] or its [child], by calling get_accState.
// A returned value of -1 indicates error.
LONG GetState(IAccessible* acc_obj, VARIANT child = id_self);

// Returns IAccessible pointer for Chrome Minimize Button, by calling
// GetChildAccessible. It does not have window handle.
HRESULT GetBrowserMinimizeButton(IAccessible** acc_obj);

// Returns IAccessible pointer for Chrome Maximize Button, by calling
// GetChildAccessible. It does not have window handle.
HRESULT GetBrowserMaximizeButton(IAccessible** acc_obj);

// Returns IAccessible pointer for Chrome Restore Button, by calling
// GetChildAccessible. It does not have window handle.
HRESULT GetBrowserRestoreButton(IAccessible** acc_obj);

// Returns IAccessible pointer for Chrome Close Button, by calling
// GetChildAccessible. It does not have window handle.
HRESULT GetBrowserCloseButton(IAccessible** acc_obj);

// Returns IAccessible pointer for Chrome Back Button, by calling
// GetChildAccessible. It does not have window handle.
HRESULT GetBackButton(IAccessible** acc_obj);

// Returns IAccessible pointer for Chrome Forward Button, by calling
// GetChildAccessible. It does not have window handle.
HRESULT GetForwardButton(IAccessible** acc_obj);

// Returns IAccessible pointer for Chrome Star Button, by calling
// GetChildAccessible. It does not have window handle.
HRESULT GetStarButton(IAccessible** acc_obj);

// Returns IAccessible pointer for Chrome Go Button, by calling
// GetChildAccessible. It does not have window handle.
HRESULT GetGoButton(IAccessible** acc_obj);

// Returns IAccessible pointer for Chrome Page Menu Button, by calling
// GetChildAccessible. It does not have window handle.
HRESULT GetPageMenuButton(IAccessible** acc_obj);

// Returns IAccessible pointer for Chrome App Menu Button, by calling
// GetChildAccessible. It does not have window handle.
HRESULT GetAppMenuButton(IAccessible** acc_obj);

#endif  // CHROME_TEST_ACCESSIBILITY_ACCESSIBILITY_UTIL_H_