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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
|
// 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.
#include <oleacc.h>
#include "base/file_path.h"
#include "base/win_util.h"
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/common/l10n_util.h"
#include "chrome/test/accessibility/accessibility_util.h"
#include "chrome/test/ui/ui_test.h"
#include "chrome/test/automation/browser_proxy.h"
#include "chrome/test/automation/window_proxy.h"
#include "chrome/test/automation/tab_proxy.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "net/base/net_util.h"
namespace {
#define CHK_RELEASE(obj) { if (obj) { (obj)->Release(); (obj) = NULL; } }
class AccessibilityTest : public UITest {
protected:
AccessibilityTest() {
show_window_ = true;
CoInitialize(NULL);
}
~AccessibilityTest() {
CoUninitialize();
}
};
} // Namespace.
// Check browser handle and accessibility object browser client.
TEST_F(AccessibilityTest, DISABLED_TestChromeBrowserAccObject) {
IAccessible* acc_obj = NULL;
HWND hwnd = GetChromeBrowserWnd(&acc_obj);
ASSERT_TRUE(NULL != hwnd);
ASSERT_TRUE(NULL != acc_obj);
CHK_RELEASE(acc_obj);
}
// Check accessibility object for toolbar and its properties Name, Role, State.
TEST_F(AccessibilityTest, DISABLED_TestChromeToolbarAccObject) {
HRESULT hr = S_OK;
IAccessible* acc_obj = NULL;
hr = GetToolbarAccessible(&acc_obj);
ASSERT_TRUE(S_OK == hr);
ASSERT_TRUE(NULL != acc_obj);
// Check Name - IDS_ACCNAME_TOOLBAR.
EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_TOOLBAR), GetName(acc_obj));
// Check Role - "tool bar".
EXPECT_EQ(ROLE_SYSTEM_TOOLBAR, GetRole(acc_obj));
// Check State - "focusable"
EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(acc_obj));
CHK_RELEASE(acc_obj);
}
// Check accessibility object for tabstrip and its properties Name, Role,
// State.
TEST_F(AccessibilityTest, DISABLED_TestChromeTabstripAccObject) {
HRESULT hr = S_OK;
IAccessible* acc_obj = NULL;
hr = GetTabStripAccessible(&acc_obj);
ASSERT_TRUE(S_OK == hr);
ASSERT_TRUE(NULL != acc_obj);
// Check Name - IDS_ACCNAME_TABSTRIP.
EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_TABSTRIP), GetName(acc_obj));
// Check Role - "grouping".
EXPECT_EQ(ROLE_SYSTEM_GROUPING, GetRole(acc_obj));
// Check State - "focusable"
EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(acc_obj));
CHK_RELEASE(acc_obj);
}
// This test is disabled for now, see issue 2243.
// Check Browser buttons and their Name, Role, State.
TEST_F(AccessibilityTest, DISABLED_TestChromeButtons) {
// TODO(klink): Implement with indexing from ViewIDs.
}
// Check Back button and its Name, Role, State.
TEST_F(AccessibilityTest, DISABLED_TestBackButton) {
HRESULT hr = S_OK;
IAccessible* acc_obj = NULL;
// Retrieve IAccessible for Back button.
hr = GetBackButton(&acc_obj);
ASSERT_TRUE(S_OK == hr);
ASSERT_TRUE(NULL != acc_obj);
// Check button and its Name, Role, State.
EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_BACK), GetName(acc_obj));
EXPECT_EQ(ROLE_SYSTEM_BUTTONDROPDOWN, GetRole(acc_obj));
// State "has popup" only supported in XP and higher.
if (win_util::GetWinVersion() > win_util::WINVERSION_2000) {
EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
STATE_SYSTEM_FOCUSABLE |
STATE_SYSTEM_UNAVAILABLE,
GetState(acc_obj));
} else {
EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE,
GetState(acc_obj));
}
CHK_RELEASE(acc_obj);
}
// Check Back button and its Name, Role, State, upon adding a new tab.
TEST_F(AccessibilityTest, DISABLED_TestBackBtnStatusOnNewTab) {
HRESULT hr = S_OK;
IAccessible* acc_obj = NULL;
// Retrieve IAccessible for Back button.
hr = GetBackButton(&acc_obj);
ASSERT_TRUE(S_OK == hr);
ASSERT_TRUE(NULL != acc_obj);
// Check button and its Name, Role, State.
EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_BACK), GetName(acc_obj));
EXPECT_EQ(ROLE_SYSTEM_BUTTONDROPDOWN, GetRole(acc_obj));
EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
STATE_SYSTEM_FOCUSABLE |
STATE_SYSTEM_UNAVAILABLE,
GetState(acc_obj));
// Now check Back status in different situations.
scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0));
ASSERT_TRUE(window.get());
int tab_count = -1;
// Set URL and check button status.
scoped_ptr<TabProxy> tab1(window->GetTab(0));
ASSERT_TRUE(tab1.get());
FilePath test_file1(test_data_directory_);
test_file1 = test_file1.AppendASCII("title1.html");
tab1->NavigateToURL(net::FilePathToFileURL(test_file1));
Sleep(sleep_timeout_ms());
EXPECT_EQ(STATE_SYSTEM_HASPOPUP | STATE_SYSTEM_FOCUSABLE,
GetState(acc_obj));
// Go Back and check status.
window->ApplyAccelerator(IDC_BACK);
Sleep(sleep_timeout_ms());
EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
STATE_SYSTEM_FOCUSABLE |
STATE_SYSTEM_UNAVAILABLE,
GetState(acc_obj));
// Add empty new tab and check status.
ASSERT_TRUE(window->GetTabCount(&tab_count));
ASSERT_TRUE(window->ApplyAccelerator(IDC_NEW_TAB));
ASSERT_TRUE(window->WaitForTabCountToBecome(tab_count + 1,
action_max_timeout_ms()));
// Check accessibility object's children.
EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
STATE_SYSTEM_FOCUSABLE |
STATE_SYSTEM_UNAVAILABLE,
GetState(acc_obj));
// Add new tab with URL and check status.
ASSERT_TRUE(window->GetTabCount(&tab_count));
FilePath test_file2(test_data_directory_);
test_file2 = test_file2.AppendASCII("title1.html");
ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(test_file2)));
ASSERT_TRUE(window->WaitForTabCountToBecome(tab_count + 1,
action_max_timeout_ms()));
// Check accessibility object's children.
Sleep(sleep_timeout_ms());
EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
STATE_SYSTEM_FOCUSABLE |
STATE_SYSTEM_UNAVAILABLE,
GetState(acc_obj));
CHK_RELEASE(acc_obj);
}
// Check Forward button and its Name, Role, State.
TEST_F(AccessibilityTest, DISABLED_TestForwardButton) {
HRESULT hr = S_OK;
IAccessible* acc_obj = NULL;
// Retrieve IAccessible for Forward button.
hr = GetForwardButton(&acc_obj);
ASSERT_TRUE(S_OK == hr);
ASSERT_TRUE(NULL != acc_obj);
// Check button and its Name, Role, State.
EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_FORWARD),
GetName(acc_obj));
EXPECT_EQ(ROLE_SYSTEM_BUTTONDROPDOWN, GetRole(acc_obj));
// State "has popup" only supported in XP and higher.
if (win_util::GetWinVersion() > win_util::WINVERSION_2000) {
EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
STATE_SYSTEM_FOCUSABLE |
STATE_SYSTEM_UNAVAILABLE,
GetState(acc_obj));
} else {
EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE,
GetState(acc_obj));
}
CHK_RELEASE(acc_obj);
}
// Check Forward button and its Name, Role, State, upon adding a new tab.
TEST_F(AccessibilityTest, DISABLED_TestForwardBtnStatusOnNewTab) {
HRESULT hr = S_OK;
IAccessible* acc_obj = NULL;
// Retrieve IAccessible for Forward button.
hr = GetForwardButton(&acc_obj);
ASSERT_TRUE(S_OK == hr);
ASSERT_TRUE(NULL != acc_obj);
// Check button and its Name, Role, State.
EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_FORWARD),
GetName(acc_obj));
EXPECT_EQ(ROLE_SYSTEM_BUTTONDROPDOWN, GetRole(acc_obj));
// State "has popup" only supported in XP and higher.
if (win_util::GetWinVersion() > win_util::WINVERSION_2000) {
EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
STATE_SYSTEM_FOCUSABLE |
STATE_SYSTEM_UNAVAILABLE,
GetState(acc_obj));
} else {
EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE,
GetState(acc_obj));
}
// Now check Back status in different situations.
scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0));
ASSERT_TRUE(window.get());
int tab_count = -1;
// Set URL and check button status.
scoped_ptr<TabProxy> tab1(window->GetTab(0));
ASSERT_TRUE(tab1.get());
FilePath test_file1(test_data_directory_);
test_file1 = test_file1.AppendASCII("title1.html");
tab1->NavigateToURL(net::FilePathToFileURL(test_file1));
Sleep(sleep_timeout_ms());
EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
STATE_SYSTEM_FOCUSABLE |
STATE_SYSTEM_UNAVAILABLE,
GetState(acc_obj));
// Go Back and check status.
window->ApplyAccelerator(IDC_BACK);
Sleep(sleep_timeout_ms());
EXPECT_EQ(STATE_SYSTEM_HASPOPUP | STATE_SYSTEM_FOCUSABLE,
GetState(acc_obj));
// Go Forward and check status.
window->ApplyAccelerator(IDC_FORWARD);
Sleep(sleep_timeout_ms());
EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
STATE_SYSTEM_FOCUSABLE |
STATE_SYSTEM_UNAVAILABLE,
GetState(acc_obj));
// Add empty new tab and check status.
ASSERT_TRUE(window->GetTabCount(&tab_count));
ASSERT_TRUE(window->ApplyAccelerator(IDC_NEW_TAB));
ASSERT_TRUE(window->WaitForTabCountToBecome(tab_count + 1,
action_max_timeout_ms()));
EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
STATE_SYSTEM_FOCUSABLE |
STATE_SYSTEM_UNAVAILABLE,
GetState(acc_obj));
// Add new tab with URL and check status.
ASSERT_TRUE(window->GetTabCount(&tab_count));
FilePath test_file2(test_data_directory_);
test_file2 = test_file2.AppendASCII("title1.html");
ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(test_file2)));
ASSERT_TRUE(window->WaitForTabCountToBecome(tab_count + 1,
action_max_timeout_ms()));
Sleep(sleep_timeout_ms());
EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
STATE_SYSTEM_FOCUSABLE |
STATE_SYSTEM_UNAVAILABLE,
GetState(acc_obj));
CHK_RELEASE(acc_obj);
}
// Check Star button and its Name, Role, State.
TEST_F(AccessibilityTest, DISABLED_TestStarButton) {
HRESULT hr = S_OK;
IAccessible* acc_obj = NULL;
// Retrieve IAccessible for Star button.
hr = GetStarButton(&acc_obj);
ASSERT_TRUE(S_OK == hr);
ASSERT_TRUE(NULL != acc_obj);
// Check button and its Name, Role, State.
EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_STAR), GetName(acc_obj));
EXPECT_EQ(ROLE_SYSTEM_PUSHBUTTON, GetRole(acc_obj));
EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(acc_obj));
CHK_RELEASE(acc_obj);
}
// Check Star button and its Name, Role, State, upon adding a new tab.
TEST_F(AccessibilityTest, DISABLED_TestStarBtnStatusOnNewTab) {
HRESULT hr = S_OK;
IAccessible* acc_obj = NULL;
// Retrieve IAccessible for Star button.
hr = GetStarButton(&acc_obj);
ASSERT_TRUE(S_OK == hr);
ASSERT_TRUE(NULL != acc_obj);
// Check button and its Name, Role, State.
EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_STAR), GetName(acc_obj));
EXPECT_EQ(ROLE_SYSTEM_PUSHBUTTON, GetRole(acc_obj));
EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(acc_obj));
// Now, check Star status in different situations.
scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0));
ASSERT_TRUE(window.get());
// Set URL and check button status.
scoped_ptr<TabProxy> tab1(window->GetTab(0));
ASSERT_TRUE(tab1.get());
FilePath test_file1(test_data_directory_);
test_file1 = test_file1.AppendASCII("title1.html");
tab1->NavigateToURL(net::FilePathToFileURL(test_file1));
Sleep(sleep_timeout_ms());
EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(acc_obj));
// Add empty new tab and check status.
int tab_count = -1;
ASSERT_TRUE(window->GetTabCount(&tab_count));
ASSERT_TRUE(window->ApplyAccelerator(IDC_NEW_TAB));
ASSERT_TRUE(window->WaitForTabCountToBecome(tab_count + 1,
action_max_timeout_ms()));
// Check tab count. Also, check accessibility object's state.
Sleep(sleep_timeout_ms());
EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(acc_obj));
// Add new tab with URL and check status.
ASSERT_TRUE(window->GetTabCount(&tab_count));
FilePath test_file2(test_data_directory_);
test_file2 = test_file2.AppendASCII("title1.html");
ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(test_file2)));
ASSERT_TRUE(window->WaitForTabCountToBecome(tab_count + 1,
action_max_timeout_ms()));
// Check tab count. Also, check accessibility object's state.
Sleep(sleep_timeout_ms());
EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(acc_obj));
CHK_RELEASE(acc_obj);
}
// Check Go button and its Name, Role, State.
TEST_F(AccessibilityTest, DISABLED_TestGoButton) {
HRESULT hr = S_OK;
IAccessible* acc_obj = NULL;
// Retrieve IAccessible for Go button.
hr = GetGoButton(&acc_obj);
ASSERT_TRUE(S_OK == hr);
ASSERT_TRUE(NULL != acc_obj);
// Check button and its Name, Role, State.
EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_GO), GetName(acc_obj));
EXPECT_EQ(ROLE_SYSTEM_PUSHBUTTON, GetRole(acc_obj));
EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(acc_obj));
CHK_RELEASE(acc_obj);
}
// Check Page menu button and its Name, Role, State.
TEST_F(AccessibilityTest, DISABLED_TestPageMenuButton) {
HRESULT hr = S_OK;
IAccessible* acc_obj = NULL;
// Retrieve IAccessible for Page menu button.
hr = GetPageMenuButton(&acc_obj);
ASSERT_TRUE(S_OK == hr);
ASSERT_TRUE(NULL != acc_obj);
// Check button and its Name, Role, State.
EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_PAGE), GetName(acc_obj));
EXPECT_EQ(ROLE_SYSTEM_BUTTONDROPDOWN, GetRole(acc_obj));
// State "has popup" only supported in XP and higher.
if (win_util::GetWinVersion() > win_util::WINVERSION_2000) {
EXPECT_EQ(STATE_SYSTEM_HASPOPUP | STATE_SYSTEM_FOCUSABLE,
GetState(acc_obj));
} else {
EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(acc_obj));
}
CHK_RELEASE(acc_obj);
}
// Check App (wrench) menu button and its Name, Role, State.
TEST_F(AccessibilityTest, DISABLED_TestAppMenuButton) {
HRESULT hr = S_OK;
IAccessible* acc_obj = NULL;
// Retrieve IAccessible for App menu button.
hr = GetAppMenuButton(&acc_obj);
ASSERT_TRUE(S_OK == hr);
ASSERT_TRUE(NULL != acc_obj);
// Check button and its Name, Role, State.
EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_APP), GetName(acc_obj));
EXPECT_EQ(ROLE_SYSTEM_BUTTONDROPDOWN, GetRole(acc_obj));
// State "has popup" only supported in XP and higher.
if (win_util::GetWinVersion() > win_util::WINVERSION_2000) {
EXPECT_EQ(STATE_SYSTEM_HASPOPUP | STATE_SYSTEM_FOCUSABLE,
GetState(acc_obj));
} else {
EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(acc_obj));
}
CHK_RELEASE(acc_obj);
}
|