OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/string16.h" | 5 #include "base/string16.h" |
6 #include "base/utf_string_conversions.h" | 6 #include "base/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/view_messages.h" | 9 #include "content/common/view_messages.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 223 |
224 // Check the index in parent. | 224 // Check the index in parent. |
225 EXPECT_EQ(0, child1_accessible->index_in_parent()); | 225 EXPECT_EQ(0, child1_accessible->index_in_parent()); |
226 EXPECT_EQ(1, child2_accessible->index_in_parent()); | 226 EXPECT_EQ(1, child2_accessible->index_in_parent()); |
227 EXPECT_EQ(2, child3_accessible->index_in_parent()); | 227 EXPECT_EQ(2, child3_accessible->index_in_parent()); |
228 | 228 |
229 // Process a notification containing the changed subtree. | 229 // Process a notification containing the changed subtree. |
230 std::vector<ViewHostMsg_AccessibilityNotification_Params> params; | 230 std::vector<ViewHostMsg_AccessibilityNotification_Params> params; |
231 params.push_back(ViewHostMsg_AccessibilityNotification_Params()); | 231 params.push_back(ViewHostMsg_AccessibilityNotification_Params()); |
232 ViewHostMsg_AccessibilityNotification_Params* msg = ¶ms[0]; | 232 ViewHostMsg_AccessibilityNotification_Params* msg = ¶ms[0]; |
233 msg->notification_type = ViewHostMsg_AccessibilityNotification_Type:: | 233 msg->notification_type = ViewHostMsg_AccEvent::CHILDREN_CHANGED; |
234 NOTIFICATION_TYPE_CHILDREN_CHANGED; | |
235 msg->acc_obj = tree2_root; | 234 msg->acc_obj = tree2_root; |
236 manager->OnAccessibilityNotifications(params); | 235 manager->OnAccessibilityNotifications(params); |
237 | 236 |
238 // There should be 5 objects now: the 4 from the new tree, plus the | 237 // There should be 5 objects now: the 4 from the new tree, plus the |
239 // reference to child3 we kept. | 238 // reference to child3 we kept. |
240 EXPECT_EQ(5, CountedBrowserAccessibility::global_obj_count_); | 239 EXPECT_EQ(5, CountedBrowserAccessibility::global_obj_count_); |
241 | 240 |
242 // Check that our references to the root, child1, and child2 are still valid, | 241 // Check that our references to the root, child1, and child2 are still valid, |
243 // but that the reference to child3 is now invalid. | 242 // but that the reference to child3 is now invalid. |
244 EXPECT_TRUE(root_accessible->instance_active()); | 243 EXPECT_TRUE(root_accessible->instance_active()); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 | 427 |
429 // Check the index in parent. | 428 // Check the index in parent. |
430 EXPECT_EQ(1, child2_accessible->index_in_parent()); | 429 EXPECT_EQ(1, child2_accessible->index_in_parent()); |
431 EXPECT_EQ(2, child3_accessible->index_in_parent()); | 430 EXPECT_EQ(2, child3_accessible->index_in_parent()); |
432 | 431 |
433 // Process a notification containing the changed subtree rooted at | 432 // Process a notification containing the changed subtree rooted at |
434 // the container. | 433 // the container. |
435 std::vector<ViewHostMsg_AccessibilityNotification_Params> params; | 434 std::vector<ViewHostMsg_AccessibilityNotification_Params> params; |
436 params.push_back(ViewHostMsg_AccessibilityNotification_Params()); | 435 params.push_back(ViewHostMsg_AccessibilityNotification_Params()); |
437 ViewHostMsg_AccessibilityNotification_Params* msg = ¶ms[0]; | 436 ViewHostMsg_AccessibilityNotification_Params* msg = ¶ms[0]; |
438 msg->notification_type = ViewHostMsg_AccessibilityNotification_Type:: | 437 msg->notification_type = ViewHostMsg_AccEvent::CHILDREN_CHANGED; |
439 NOTIFICATION_TYPE_CHILDREN_CHANGED; | |
440 msg->acc_obj = tree2_container; | 438 msg->acc_obj = tree2_container; |
441 manager->OnAccessibilityNotifications(params); | 439 manager->OnAccessibilityNotifications(params); |
442 | 440 |
443 // There should be 9 objects now: the 8 from the new tree, plus the | 441 // There should be 9 objects now: the 8 from the new tree, plus the |
444 // reference to child3 we kept. | 442 // reference to child3 we kept. |
445 EXPECT_EQ(9, CountedBrowserAccessibility::global_obj_count_); | 443 EXPECT_EQ(9, CountedBrowserAccessibility::global_obj_count_); |
446 | 444 |
447 // Check that our references to the root and container and child2 are | 445 // Check that our references to the root and container and child2 are |
448 // still valid, but that the reference to child3 is now invalid. | 446 // still valid, but that the reference to child3 is now invalid. |
449 EXPECT_TRUE(root_accessible->instance_active()); | 447 EXPECT_TRUE(root_accessible->instance_active()); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 NULL, | 530 NULL, |
533 tree1_1, | 531 tree1_1, |
534 NULL, | 532 NULL, |
535 new CountedBrowserAccessibilityFactory()); | 533 new CountedBrowserAccessibilityFactory()); |
536 ASSERT_EQ(4, CountedBrowserAccessibility::global_obj_count_); | 534 ASSERT_EQ(4, CountedBrowserAccessibility::global_obj_count_); |
537 | 535 |
538 // Process a notification containing the changed subtree. | 536 // Process a notification containing the changed subtree. |
539 std::vector<ViewHostMsg_AccessibilityNotification_Params> params; | 537 std::vector<ViewHostMsg_AccessibilityNotification_Params> params; |
540 params.push_back(ViewHostMsg_AccessibilityNotification_Params()); | 538 params.push_back(ViewHostMsg_AccessibilityNotification_Params()); |
541 ViewHostMsg_AccessibilityNotification_Params* msg = ¶ms[0]; | 539 ViewHostMsg_AccessibilityNotification_Params* msg = ¶ms[0]; |
542 msg->notification_type = ViewHostMsg_AccessibilityNotification_Type:: | 540 msg->notification_type = ViewHostMsg_AccEvent::CHILDREN_CHANGED; |
543 NOTIFICATION_TYPE_CHILDREN_CHANGED; | |
544 msg->acc_obj = tree2_1; | 541 msg->acc_obj = tree2_1; |
545 manager->OnAccessibilityNotifications(params); | 542 manager->OnAccessibilityNotifications(params); |
546 | 543 |
547 // There should be 4 objects now. | 544 // There should be 4 objects now. |
548 EXPECT_EQ(4, CountedBrowserAccessibility::global_obj_count_); | 545 EXPECT_EQ(4, CountedBrowserAccessibility::global_obj_count_); |
549 | 546 |
550 // Delete the manager and make sure all memory is cleaned up. | 547 // Delete the manager and make sure all memory is cleaned up. |
551 delete manager; | 548 delete manager; |
552 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); | 549 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); |
553 } | 550 } |
(...skipping 21 matching lines...) Expand all Loading... |
575 WebAccessibility tree1_2; | 572 WebAccessibility tree1_2; |
576 tree1_2.id = 1001; | 573 tree1_2.id = 1001; |
577 tree1_2.role = WebAccessibility::ROLE_TEXT_FIELD; | 574 tree1_2.role = WebAccessibility::ROLE_TEXT_FIELD; |
578 | 575 |
579 tree1_1.children.push_back(tree1_2); | 576 tree1_1.children.push_back(tree1_2); |
580 | 577 |
581 // Process a load complete. | 578 // Process a load complete. |
582 std::vector<ViewHostMsg_AccessibilityNotification_Params> params; | 579 std::vector<ViewHostMsg_AccessibilityNotification_Params> params; |
583 params.push_back(ViewHostMsg_AccessibilityNotification_Params()); | 580 params.push_back(ViewHostMsg_AccessibilityNotification_Params()); |
584 ViewHostMsg_AccessibilityNotification_Params* msg = ¶ms[0]; | 581 ViewHostMsg_AccessibilityNotification_Params* msg = ¶ms[0]; |
585 msg->notification_type = ViewHostMsg_AccessibilityNotification_Type:: | 582 msg->notification_type = ViewHostMsg_AccEvent::LOAD_COMPLETE; |
586 NOTIFICATION_TYPE_LOAD_COMPLETE; | |
587 msg->acc_obj = tree1_1; | 583 msg->acc_obj = tree1_1; |
588 | 584 |
589 manager->OnAccessibilityNotifications(params); | 585 manager->OnAccessibilityNotifications(params); |
590 | 586 |
591 // Save for later comparison. | 587 // Save for later comparison. |
592 BrowserAccessibility* acc1_2 = manager->GetFromRendererID(1001); | 588 BrowserAccessibility* acc1_2 = manager->GetFromRendererID(1001); |
593 | 589 |
594 // Verify the root has not changed. | 590 // Verify the root has not changed. |
595 EXPECT_EQ(root, manager->GetRoot()); | 591 EXPECT_EQ(root, manager->GetRoot()); |
596 | 592 |
(...skipping 23 matching lines...) Expand all Loading... |
620 EXPECT_EQ(root, manager->GetRoot()); | 616 EXPECT_EQ(root, manager->GetRoot()); |
621 | 617 |
622 // And the new child exists. | 618 // And the new child exists. |
623 EXPECT_EQ(WebAccessibility::ROLE_BUTTON, acc2_2->role()); | 619 EXPECT_EQ(WebAccessibility::ROLE_BUTTON, acc2_2->role()); |
624 EXPECT_EQ(1002, acc2_2->renderer_id()); | 620 EXPECT_EQ(1002, acc2_2->renderer_id()); |
625 | 621 |
626 // Ensure we properly cleaned up. | 622 // Ensure we properly cleaned up. |
627 manager.reset(); | 623 manager.reset(); |
628 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); | 624 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); |
629 } | 625 } |
OLD | NEW |