Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(346)

Side by Side Diff: content/browser/accessibility/browser_accessibility_manager_unittest.cc

Issue 23651003: Use Blink accessibility enums in Chromium (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "base/strings/string16.h" 5 #include "base/strings/string16.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "content/browser/accessibility/browser_accessibility.h" 7 #include "content/browser/accessibility/browser_accessibility.h"
8 #include "content/browser/accessibility/browser_accessibility_manager.h" 8 #include "content/browser/accessibility/browser_accessibility_manager.h"
9 #include "content/common/accessibility_messages.h" 9 #include "content/common/accessibility_messages.h"
10 #include "content/common/accessibility_node_data.h" 10 #include "content/common/accessibility_node_data.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 } // anonymous namespace 87 } // anonymous namespace
88 88
89 TEST(BrowserAccessibilityManagerTest, TestNoLeaks) { 89 TEST(BrowserAccessibilityManagerTest, TestNoLeaks) {
90 // Create AccessibilityNodeData objects for a simple document tree, 90 // Create AccessibilityNodeData objects for a simple document tree,
91 // representing the accessibility information used to initialize 91 // representing the accessibility information used to initialize
92 // BrowserAccessibilityManager. 92 // BrowserAccessibilityManager.
93 AccessibilityNodeData button; 93 AccessibilityNodeData button;
94 button.id = 2; 94 button.id = 2;
95 button.SetName("Button"); 95 button.SetName("Button");
96 button.role = AccessibilityNodeData::ROLE_BUTTON; 96 button.role = WebKit::WebAXRoleButton;
97 button.state = 0; 97 button.state = 0;
98 98
99 AccessibilityNodeData checkbox; 99 AccessibilityNodeData checkbox;
100 checkbox.id = 3; 100 checkbox.id = 3;
101 checkbox.SetName("Checkbox"); 101 checkbox.SetName("Checkbox");
102 checkbox.role = AccessibilityNodeData::ROLE_CHECKBOX; 102 checkbox.role = WebKit::WebAXRoleCheckBox;
103 checkbox.state = 0; 103 checkbox.state = 0;
104 104
105 AccessibilityNodeData root; 105 AccessibilityNodeData root;
106 root.id = 1; 106 root.id = 1;
107 root.SetName("Document"); 107 root.SetName("Document");
108 root.role = AccessibilityNodeData::ROLE_ROOT_WEB_AREA; 108 root.role = WebKit::WebAXRoleRootWebArea;
109 root.state = 0; 109 root.state = 0;
110 root.child_ids.push_back(2); 110 root.child_ids.push_back(2);
111 root.child_ids.push_back(3); 111 root.child_ids.push_back(3);
112 112
113 // Construct a BrowserAccessibilityManager with this 113 // Construct a BrowserAccessibilityManager with this
114 // AccessibilityNodeData tree and a factory for an instance-counting 114 // AccessibilityNodeData tree and a factory for an instance-counting
115 // BrowserAccessibility, and ensure that exactly 3 instances were 115 // BrowserAccessibility, and ensure that exactly 3 instances were
116 // created. Note that the manager takes ownership of the factory. 116 // created. Note that the manager takes ownership of the factory.
117 CountedBrowserAccessibility::global_obj_count_ = 0; 117 CountedBrowserAccessibility::global_obj_count_ = 0;
118 BrowserAccessibilityManager* manager = 118 BrowserAccessibilityManager* manager =
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 // Tree 1: 164 // Tree 1:
165 // 165 //
166 // root 166 // root
167 // child1 167 // child1
168 // child2 168 // child2
169 // child3 169 // child3
170 170
171 AccessibilityNodeData tree1_child1; 171 AccessibilityNodeData tree1_child1;
172 tree1_child1.id = 2; 172 tree1_child1.id = 2;
173 tree1_child1.SetName("Child1"); 173 tree1_child1.SetName("Child1");
174 tree1_child1.role = AccessibilityNodeData::ROLE_BUTTON; 174 tree1_child1.role = WebKit::WebAXRoleButton;
175 tree1_child1.state = 0; 175 tree1_child1.state = 0;
176 176
177 AccessibilityNodeData tree1_child2; 177 AccessibilityNodeData tree1_child2;
178 tree1_child2.id = 3; 178 tree1_child2.id = 3;
179 tree1_child2.SetName("Child2"); 179 tree1_child2.SetName("Child2");
180 tree1_child2.role = AccessibilityNodeData::ROLE_BUTTON; 180 tree1_child2.role = WebKit::WebAXRoleButton;
181 tree1_child2.state = 0; 181 tree1_child2.state = 0;
182 182
183 AccessibilityNodeData tree1_child3; 183 AccessibilityNodeData tree1_child3;
184 tree1_child3.id = 4; 184 tree1_child3.id = 4;
185 tree1_child3.SetName("Child3"); 185 tree1_child3.SetName("Child3");
186 tree1_child3.role = AccessibilityNodeData::ROLE_BUTTON; 186 tree1_child3.role = WebKit::WebAXRoleButton;
187 tree1_child3.state = 0; 187 tree1_child3.state = 0;
188 188
189 AccessibilityNodeData tree1_root; 189 AccessibilityNodeData tree1_root;
190 tree1_root.id = 1; 190 tree1_root.id = 1;
191 tree1_root.SetName("Document"); 191 tree1_root.SetName("Document");
192 tree1_root.role = AccessibilityNodeData::ROLE_ROOT_WEB_AREA; 192 tree1_root.role = WebKit::WebAXRoleRootWebArea;
193 tree1_root.state = 0; 193 tree1_root.state = 0;
194 tree1_root.child_ids.push_back(2); 194 tree1_root.child_ids.push_back(2);
195 tree1_root.child_ids.push_back(3); 195 tree1_root.child_ids.push_back(3);
196 tree1_root.child_ids.push_back(4); 196 tree1_root.child_ids.push_back(4);
197 197
198 // Tree 2: 198 // Tree 2:
199 // 199 //
200 // root 200 // root
201 // child0 <-- inserted 201 // child0 <-- inserted
202 // child1 202 // child1
203 // child2 203 // child2
204 // <-- child3 deleted 204 // <-- child3 deleted
205 205
206 AccessibilityNodeData tree2_child0; 206 AccessibilityNodeData tree2_child0;
207 tree2_child0.id = 5; 207 tree2_child0.id = 5;
208 tree2_child0.SetName("Child0"); 208 tree2_child0.SetName("Child0");
209 tree2_child0.role = AccessibilityNodeData::ROLE_BUTTON; 209 tree2_child0.role = WebKit::WebAXRoleButton;
210 tree2_child0.state = 0; 210 tree2_child0.state = 0;
211 211
212 AccessibilityNodeData tree2_root; 212 AccessibilityNodeData tree2_root;
213 tree2_root.id = 1; 213 tree2_root.id = 1;
214 tree2_root.SetName("DocumentChanged"); 214 tree2_root.SetName("DocumentChanged");
215 tree2_root.role = AccessibilityNodeData::ROLE_ROOT_WEB_AREA; 215 tree2_root.role = WebKit::WebAXRoleRootWebArea;
216 tree2_root.state = 0; 216 tree2_root.state = 0;
217 tree2_root.child_ids.push_back(5); 217 tree2_root.child_ids.push_back(5);
218 tree2_root.child_ids.push_back(2); 218 tree2_root.child_ids.push_back(2);
219 tree2_root.child_ids.push_back(3); 219 tree2_root.child_ids.push_back(3);
220 220
221 // Construct a BrowserAccessibilityManager with tree1. 221 // Construct a BrowserAccessibilityManager with tree1.
222 CountedBrowserAccessibility::global_obj_count_ = 0; 222 CountedBrowserAccessibility::global_obj_count_ = 0;
223 BrowserAccessibilityManager* manager = 223 BrowserAccessibilityManager* manager =
224 BrowserAccessibilityManager::Create( 224 BrowserAccessibilityManager::Create(
225 tree1_root, 225 tree1_root,
(...skipping 15 matching lines...) Expand all
241 CountedBrowserAccessibility* child3_accessible = 241 CountedBrowserAccessibility* child3_accessible =
242 static_cast<CountedBrowserAccessibility*>(root_accessible->GetChild(2)); 242 static_cast<CountedBrowserAccessibility*>(root_accessible->GetChild(2));
243 child3_accessible->NativeAddReference(); 243 child3_accessible->NativeAddReference();
244 244
245 // Check the index in parent. 245 // Check the index in parent.
246 EXPECT_EQ(0, child1_accessible->index_in_parent()); 246 EXPECT_EQ(0, child1_accessible->index_in_parent());
247 EXPECT_EQ(1, child2_accessible->index_in_parent()); 247 EXPECT_EQ(1, child2_accessible->index_in_parent());
248 EXPECT_EQ(2, child3_accessible->index_in_parent()); 248 EXPECT_EQ(2, child3_accessible->index_in_parent());
249 249
250 // Process a notification containing the changed subtree. 250 // Process a notification containing the changed subtree.
251 std::vector<AccessibilityHostMsg_NotificationParams> params; 251 std::vector<AccessibilityHostMsg_EventParams> params;
252 params.push_back(AccessibilityHostMsg_NotificationParams()); 252 params.push_back(AccessibilityHostMsg_EventParams());
253 AccessibilityHostMsg_NotificationParams* msg = &params[0]; 253 AccessibilityHostMsg_EventParams* msg = &params[0];
254 msg->notification_type = AccessibilityNotificationChildrenChanged; 254 msg->event_type = WebKit::WebAXEventChildrenChanged;
255 msg->nodes.push_back(tree2_root); 255 msg->nodes.push_back(tree2_root);
256 msg->nodes.push_back(tree2_child0); 256 msg->nodes.push_back(tree2_child0);
257 msg->id = tree2_root.id; 257 msg->id = tree2_root.id;
258 manager->OnAccessibilityNotifications(params); 258 manager->OnAccessibilityEvents(params);
259 259
260 // There should be 5 objects now: the 4 from the new tree, plus the 260 // There should be 5 objects now: the 4 from the new tree, plus the
261 // reference to child3 we kept. 261 // reference to child3 we kept.
262 EXPECT_EQ(5, CountedBrowserAccessibility::global_obj_count_); 262 EXPECT_EQ(5, CountedBrowserAccessibility::global_obj_count_);
263 263
264 // Check that our references to the root, child1, and child2 are still valid, 264 // Check that our references to the root, child1, and child2 are still valid,
265 // but that the reference to child3 is now invalid. 265 // but that the reference to child3 is now invalid.
266 EXPECT_TRUE(root_accessible->instance_active()); 266 EXPECT_TRUE(root_accessible->instance_active());
267 EXPECT_TRUE(child1_accessible->instance_active()); 267 EXPECT_TRUE(child1_accessible->instance_active());
268 EXPECT_TRUE(child2_accessible->instance_active()); 268 EXPECT_TRUE(child2_accessible->instance_active());
(...skipping 27 matching lines...) Expand all
296 // child1 296 // child1
297 // grandchild1 297 // grandchild1
298 // child2 298 // child2
299 // grandchild2 299 // grandchild2
300 // child3 300 // child3
301 // grandchild3 301 // grandchild3
302 302
303 AccessibilityNodeData tree1_grandchild1; 303 AccessibilityNodeData tree1_grandchild1;
304 tree1_grandchild1.id = 4; 304 tree1_grandchild1.id = 4;
305 tree1_grandchild1.SetName("GrandChild1"); 305 tree1_grandchild1.SetName("GrandChild1");
306 tree1_grandchild1.role = AccessibilityNodeData::ROLE_BUTTON; 306 tree1_grandchild1.role = WebKit::WebAXRoleButton;
307 tree1_grandchild1.state = 0; 307 tree1_grandchild1.state = 0;
308 308
309 AccessibilityNodeData tree1_child1; 309 AccessibilityNodeData tree1_child1;
310 tree1_child1.id = 3; 310 tree1_child1.id = 3;
311 tree1_child1.SetName("Child1"); 311 tree1_child1.SetName("Child1");
312 tree1_child1.role = AccessibilityNodeData::ROLE_BUTTON; 312 tree1_child1.role = WebKit::WebAXRoleButton;
313 tree1_child1.state = 0; 313 tree1_child1.state = 0;
314 tree1_child1.child_ids.push_back(4); 314 tree1_child1.child_ids.push_back(4);
315 315
316 AccessibilityNodeData tree1_grandchild2; 316 AccessibilityNodeData tree1_grandchild2;
317 tree1_grandchild2.id = 6; 317 tree1_grandchild2.id = 6;
318 tree1_grandchild2.SetName("GrandChild1"); 318 tree1_grandchild2.SetName("GrandChild1");
319 tree1_grandchild2.role = AccessibilityNodeData::ROLE_BUTTON; 319 tree1_grandchild2.role = WebKit::WebAXRoleButton;
320 tree1_grandchild2.state = 0; 320 tree1_grandchild2.state = 0;
321 321
322 AccessibilityNodeData tree1_child2; 322 AccessibilityNodeData tree1_child2;
323 tree1_child2.id = 5; 323 tree1_child2.id = 5;
324 tree1_child2.SetName("Child2"); 324 tree1_child2.SetName("Child2");
325 tree1_child2.role = AccessibilityNodeData::ROLE_BUTTON; 325 tree1_child2.role = WebKit::WebAXRoleButton;
326 tree1_child2.state = 0; 326 tree1_child2.state = 0;
327 tree1_child2.child_ids.push_back(6); 327 tree1_child2.child_ids.push_back(6);
328 328
329 AccessibilityNodeData tree1_grandchild3; 329 AccessibilityNodeData tree1_grandchild3;
330 tree1_grandchild3.id = 8; 330 tree1_grandchild3.id = 8;
331 tree1_grandchild3.SetName("GrandChild3"); 331 tree1_grandchild3.SetName("GrandChild3");
332 tree1_grandchild3.role = AccessibilityNodeData::ROLE_BUTTON; 332 tree1_grandchild3.role = WebKit::WebAXRoleButton;
333 tree1_grandchild3.state = 0; 333 tree1_grandchild3.state = 0;
334 334
335 AccessibilityNodeData tree1_child3; 335 AccessibilityNodeData tree1_child3;
336 tree1_child3.id = 7; 336 tree1_child3.id = 7;
337 tree1_child3.SetName("Child3"); 337 tree1_child3.SetName("Child3");
338 tree1_child3.role = AccessibilityNodeData::ROLE_BUTTON; 338 tree1_child3.role = WebKit::WebAXRoleButton;
339 tree1_child3.state = 0; 339 tree1_child3.state = 0;
340 tree1_child3.child_ids.push_back(8); 340 tree1_child3.child_ids.push_back(8);
341 341
342 AccessibilityNodeData tree1_container; 342 AccessibilityNodeData tree1_container;
343 tree1_container.id = 2; 343 tree1_container.id = 2;
344 tree1_container.SetName("Container"); 344 tree1_container.SetName("Container");
345 tree1_container.role = AccessibilityNodeData::ROLE_GROUP; 345 tree1_container.role = WebKit::WebAXRoleGroup;
346 tree1_container.state = 0; 346 tree1_container.state = 0;
347 tree1_container.child_ids.push_back(3); 347 tree1_container.child_ids.push_back(3);
348 tree1_container.child_ids.push_back(5); 348 tree1_container.child_ids.push_back(5);
349 tree1_container.child_ids.push_back(7); 349 tree1_container.child_ids.push_back(7);
350 350
351 AccessibilityNodeData tree1_root; 351 AccessibilityNodeData tree1_root;
352 tree1_root.id = 1; 352 tree1_root.id = 1;
353 tree1_root.SetName("Document"); 353 tree1_root.SetName("Document");
354 tree1_root.role = AccessibilityNodeData::ROLE_ROOT_WEB_AREA; 354 tree1_root.role = WebKit::WebAXRoleRootWebArea;
355 tree1_root.state = 0; 355 tree1_root.state = 0;
356 tree1_root.child_ids.push_back(2); 356 tree1_root.child_ids.push_back(2);
357 357
358 // Tree 2: 358 // Tree 2:
359 // 359 //
360 // root 360 // root
361 // container 361 // container
362 // child0 <-- inserted 362 // child0 <-- inserted
363 // grandchild0 <-- 363 // grandchild0 <--
364 // child1 364 // child1
365 // grandchild1 365 // grandchild1
366 // child2 366 // child2
367 // grandchild2 367 // grandchild2
368 // <-- child3 (and grandchild3) deleted 368 // <-- child3 (and grandchild3) deleted
369 369
370 AccessibilityNodeData tree2_grandchild0; 370 AccessibilityNodeData tree2_grandchild0;
371 tree2_grandchild0.id = 9; 371 tree2_grandchild0.id = 9;
372 tree2_grandchild0.SetName("GrandChild0"); 372 tree2_grandchild0.SetName("GrandChild0");
373 tree2_grandchild0.role = AccessibilityNodeData::ROLE_BUTTON; 373 tree2_grandchild0.role = WebKit::WebAXRoleButton;
374 tree2_grandchild0.state = 0; 374 tree2_grandchild0.state = 0;
375 375
376 AccessibilityNodeData tree2_child0; 376 AccessibilityNodeData tree2_child0;
377 tree2_child0.id = 10; 377 tree2_child0.id = 10;
378 tree2_child0.SetName("Child0"); 378 tree2_child0.SetName("Child0");
379 tree2_child0.role = AccessibilityNodeData::ROLE_BUTTON; 379 tree2_child0.role = WebKit::WebAXRoleButton;
380 tree2_child0.state = 0; 380 tree2_child0.state = 0;
381 tree2_child0.child_ids.push_back(9); 381 tree2_child0.child_ids.push_back(9);
382 382
383 AccessibilityNodeData tree2_container; 383 AccessibilityNodeData tree2_container;
384 tree2_container.id = 2; 384 tree2_container.id = 2;
385 tree2_container.SetName("Container"); 385 tree2_container.SetName("Container");
386 tree2_container.role = AccessibilityNodeData::ROLE_GROUP; 386 tree2_container.role = WebKit::WebAXRoleGroup;
387 tree2_container.state = 0; 387 tree2_container.state = 0;
388 tree2_container.child_ids.push_back(10); 388 tree2_container.child_ids.push_back(10);
389 tree2_container.child_ids.push_back(3); 389 tree2_container.child_ids.push_back(3);
390 tree2_container.child_ids.push_back(5); 390 tree2_container.child_ids.push_back(5);
391 391
392 // Construct a BrowserAccessibilityManager with tree1. 392 // Construct a BrowserAccessibilityManager with tree1.
393 CountedBrowserAccessibility::global_obj_count_ = 0; 393 CountedBrowserAccessibility::global_obj_count_ = 0;
394 BrowserAccessibilityManager* manager = 394 BrowserAccessibilityManager* manager =
395 BrowserAccessibilityManager::Create( 395 BrowserAccessibilityManager::Create(
396 tree1_root, 396 tree1_root,
(...skipping 20 matching lines...) Expand all
417 static_cast<CountedBrowserAccessibility*>( 417 static_cast<CountedBrowserAccessibility*>(
418 container_accessible->GetChild(2)); 418 container_accessible->GetChild(2));
419 child3_accessible->NativeAddReference(); 419 child3_accessible->NativeAddReference();
420 420
421 // Check the index in parent. 421 // Check the index in parent.
422 EXPECT_EQ(1, child2_accessible->index_in_parent()); 422 EXPECT_EQ(1, child2_accessible->index_in_parent());
423 EXPECT_EQ(2, child3_accessible->index_in_parent()); 423 EXPECT_EQ(2, child3_accessible->index_in_parent());
424 424
425 // Process a notification containing the changed subtree rooted at 425 // Process a notification containing the changed subtree rooted at
426 // the container. 426 // the container.
427 std::vector<AccessibilityHostMsg_NotificationParams> params; 427 std::vector<AccessibilityHostMsg_EventParams> params;
428 params.push_back(AccessibilityHostMsg_NotificationParams()); 428 params.push_back(AccessibilityHostMsg_EventParams());
429 AccessibilityHostMsg_NotificationParams* msg = &params[0]; 429 AccessibilityHostMsg_EventParams* msg = &params[0];
430 msg->notification_type = AccessibilityNotificationChildrenChanged; 430 msg->event_type = WebKit::WebAXEventChildrenChanged;
431 msg->nodes.push_back(tree2_container); 431 msg->nodes.push_back(tree2_container);
432 msg->nodes.push_back(tree2_child0); 432 msg->nodes.push_back(tree2_child0);
433 msg->nodes.push_back(tree2_grandchild0); 433 msg->nodes.push_back(tree2_grandchild0);
434 msg->id = tree2_container.id; 434 msg->id = tree2_container.id;
435 manager->OnAccessibilityNotifications(params); 435 manager->OnAccessibilityEvents(params);
436 436
437 // There should be 9 objects now: the 8 from the new tree, plus the 437 // There should be 9 objects now: the 8 from the new tree, plus the
438 // reference to child3 we kept. 438 // reference to child3 we kept.
439 EXPECT_EQ(9, CountedBrowserAccessibility::global_obj_count_); 439 EXPECT_EQ(9, CountedBrowserAccessibility::global_obj_count_);
440 440
441 // Check that our references to the root and container and child2 are 441 // Check that our references to the root and container and child2 are
442 // still valid, but that the reference to child3 is now invalid. 442 // still valid, but that the reference to child3 is now invalid.
443 EXPECT_TRUE(root_accessible->instance_active()); 443 EXPECT_TRUE(root_accessible->instance_active());
444 EXPECT_TRUE(container_accessible->instance_active()); 444 EXPECT_TRUE(container_accessible->instance_active());
445 EXPECT_TRUE(child2_accessible->instance_active()); 445 EXPECT_TRUE(child2_accessible->instance_active());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 tree1_3.id = 3; 482 tree1_3.id = 3;
483 tree1_3.state = 0; 483 tree1_3.state = 0;
484 tree1_3.child_ids.push_back(4); 484 tree1_3.child_ids.push_back(4);
485 485
486 AccessibilityNodeData tree1_2; 486 AccessibilityNodeData tree1_2;
487 tree1_2.id = 2; 487 tree1_2.id = 2;
488 tree1_2.state = 0; 488 tree1_2.state = 0;
489 489
490 AccessibilityNodeData tree1_1; 490 AccessibilityNodeData tree1_1;
491 tree1_1.id = 1; 491 tree1_1.id = 1;
492 tree1_1.role = AccessibilityNodeData::ROLE_ROOT_WEB_AREA; 492 tree1_1.role = WebKit::WebAXRoleRootWebArea;
493 tree1_1.state = 0; 493 tree1_1.state = 0;
494 tree1_1.child_ids.push_back(2); 494 tree1_1.child_ids.push_back(2);
495 tree1_1.child_ids.push_back(3); 495 tree1_1.child_ids.push_back(3);
496 496
497 // Tree 2: 497 // Tree 2:
498 // 498 //
499 // 1 499 // 1
500 // 4 <-- moves up a level and gains child 500 // 4 <-- moves up a level and gains child
501 // 6 <-- new 501 // 6 <-- new
502 // 5 <-- new 502 // 5 <-- new
(...skipping 21 matching lines...) Expand all
524 CountedBrowserAccessibility::global_obj_count_ = 0; 524 CountedBrowserAccessibility::global_obj_count_ = 0;
525 BrowserAccessibilityManager* manager = 525 BrowserAccessibilityManager* manager =
526 BrowserAccessibilityManager::Create( 526 BrowserAccessibilityManager::Create(
527 tree1_1, 527 tree1_1,
528 NULL, 528 NULL,
529 new CountedBrowserAccessibilityFactory()); 529 new CountedBrowserAccessibilityFactory());
530 manager->UpdateNodesForTesting(tree1_2, tree1_3, tree1_4); 530 manager->UpdateNodesForTesting(tree1_2, tree1_3, tree1_4);
531 ASSERT_EQ(4, CountedBrowserAccessibility::global_obj_count_); 531 ASSERT_EQ(4, CountedBrowserAccessibility::global_obj_count_);
532 532
533 // Process a notification containing the changed subtree. 533 // Process a notification containing the changed subtree.
534 std::vector<AccessibilityHostMsg_NotificationParams> params; 534 std::vector<AccessibilityHostMsg_EventParams> params;
535 params.push_back(AccessibilityHostMsg_NotificationParams()); 535 params.push_back(AccessibilityHostMsg_EventParams());
536 AccessibilityHostMsg_NotificationParams* msg = &params[0]; 536 AccessibilityHostMsg_EventParams* msg = &params[0];
537 msg->notification_type = AccessibilityNotificationChildrenChanged; 537 msg->event_type = WebKit::WebAXEventChildrenChanged;
538 msg->nodes.push_back(tree2_1); 538 msg->nodes.push_back(tree2_1);
539 msg->nodes.push_back(tree2_4); 539 msg->nodes.push_back(tree2_4);
540 msg->nodes.push_back(tree2_5); 540 msg->nodes.push_back(tree2_5);
541 msg->nodes.push_back(tree2_6); 541 msg->nodes.push_back(tree2_6);
542 msg->id = tree2_1.id; 542 msg->id = tree2_1.id;
543 manager->OnAccessibilityNotifications(params); 543 manager->OnAccessibilityEvents(params);
544 544
545 // There should be 4 objects now. 545 // There should be 4 objects now.
546 EXPECT_EQ(4, CountedBrowserAccessibility::global_obj_count_); 546 EXPECT_EQ(4, CountedBrowserAccessibility::global_obj_count_);
547 547
548 // Delete the manager and make sure all memory is cleaned up. 548 // Delete the manager and make sure all memory is cleaned up.
549 delete manager; 549 delete manager;
550 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); 550 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_);
551 } 551 }
552 552
553 TEST(BrowserAccessibilityManagerTest, TestFatalError) { 553 TEST(BrowserAccessibilityManagerTest, TestFatalError) {
554 // Test that BrowserAccessibilityManager raises a fatal error 554 // Test that BrowserAccessibilityManager raises a fatal error
555 // (which will crash the renderer) if the same id is used in 555 // (which will crash the renderer) if the same id is used in
556 // two places in the tree. 556 // two places in the tree.
557 557
558 AccessibilityNodeData root; 558 AccessibilityNodeData root;
559 root.id = 1; 559 root.id = 1;
560 root.role = AccessibilityNodeData::ROLE_ROOT_WEB_AREA; 560 root.role = WebKit::WebAXRoleRootWebArea;
561 root.child_ids.push_back(2); 561 root.child_ids.push_back(2);
562 root.child_ids.push_back(2); 562 root.child_ids.push_back(2);
563 563
564 CountedBrowserAccessibilityFactory* factory = 564 CountedBrowserAccessibilityFactory* factory =
565 new CountedBrowserAccessibilityFactory(); 565 new CountedBrowserAccessibilityFactory();
566 scoped_ptr<TestBrowserAccessibilityDelegate> delegate( 566 scoped_ptr<TestBrowserAccessibilityDelegate> delegate(
567 new TestBrowserAccessibilityDelegate()); 567 new TestBrowserAccessibilityDelegate());
568 scoped_ptr<BrowserAccessibilityManager> manager; 568 scoped_ptr<BrowserAccessibilityManager> manager;
569 ASSERT_FALSE(delegate->got_fatal_error()); 569 ASSERT_FALSE(delegate->got_fatal_error());
570 manager.reset(BrowserAccessibilityManager::Create( 570 manager.reset(BrowserAccessibilityManager::Create(
571 root, 571 root,
572 delegate.get(), 572 delegate.get(),
573 factory)); 573 factory));
574 ASSERT_TRUE(delegate->got_fatal_error()); 574 ASSERT_TRUE(delegate->got_fatal_error());
575 575
576 AccessibilityNodeData root2; 576 AccessibilityNodeData root2;
577 root2.id = 1; 577 root2.id = 1;
578 root2.role = AccessibilityNodeData::ROLE_ROOT_WEB_AREA; 578 root2.role = WebKit::WebAXRoleRootWebArea;
579 root2.child_ids.push_back(2); 579 root2.child_ids.push_back(2);
580 root2.child_ids.push_back(3); 580 root2.child_ids.push_back(3);
581 581
582 AccessibilityNodeData child1; 582 AccessibilityNodeData child1;
583 child1.id = 2; 583 child1.id = 2;
584 child1.child_ids.push_back(4); 584 child1.child_ids.push_back(4);
585 child1.child_ids.push_back(5); 585 child1.child_ids.push_back(5);
586 586
587 AccessibilityNodeData child2; 587 AccessibilityNodeData child2;
588 child2.id = 3; 588 child2.id = 3;
589 child2.child_ids.push_back(6); 589 child2.child_ids.push_back(6);
590 child2.child_ids.push_back(5); // Duplicate 590 child2.child_ids.push_back(5); // Duplicate
591 591
592 delegate->reset_got_fatal_error(); 592 delegate->reset_got_fatal_error();
593 factory = new CountedBrowserAccessibilityFactory(); 593 factory = new CountedBrowserAccessibilityFactory();
594 manager.reset(BrowserAccessibilityManager::Create( 594 manager.reset(BrowserAccessibilityManager::Create(
595 root2, 595 root2,
596 delegate.get(), 596 delegate.get(),
597 factory)); 597 factory));
598 ASSERT_FALSE(delegate->got_fatal_error()); 598 ASSERT_FALSE(delegate->got_fatal_error());
599 manager->UpdateNodesForTesting(child1, child2); 599 manager->UpdateNodesForTesting(child1, child2);
600 ASSERT_TRUE(delegate->got_fatal_error()); 600 ASSERT_TRUE(delegate->got_fatal_error());
601 } 601 }
602 602
603 } // namespace content 603 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698