| 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 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 // There should be 4 objects now. | 547 // There should be 4 objects now. |
| 548 EXPECT_EQ(4, CountedBrowserAccessibility::global_obj_count_); | 548 EXPECT_EQ(4, CountedBrowserAccessibility::global_obj_count_); |
| 549 | 549 |
| 550 // Delete the manager and make sure all memory is cleaned up. | 550 // Delete the manager and make sure all memory is cleaned up. |
| 551 delete manager; | 551 delete manager; |
| 552 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); | 552 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); |
| 553 } | 553 } |
| 554 | 554 |
| 555 TEST(BrowserAccessibilityManagerTest, TestCreateEmptyDocument) { | 555 TEST(BrowserAccessibilityManagerTest, TestCreateEmptyDocument) { |
| 556 // Try creating an empty document with busy state. | 556 // Try creating an empty document with busy state. |
| 557 BrowserAccessibilityManager* manager = | 557 scoped_ptr<BrowserAccessibilityManager> manager; |
| 558 BrowserAccessibilityManager::CreateEmptyDocument( | 558 manager.reset(BrowserAccessibilityManager::CreateEmptyDocument( |
| 559 NULL, | 559 NULL, |
| 560 WebAccessibility::STATE_BUSY, | 560 WebAccessibility::STATE_BUSY, |
| 561 NULL, | 561 NULL, |
| 562 new CountedBrowserAccessibilityFactory()); | 562 new CountedBrowserAccessibilityFactory())); |
| 563 | 563 |
| 564 // Verify the root is as we expect by default. | 564 // Verify the root is as we expect by default. |
| 565 BrowserAccessibility* root = manager->GetRoot(); | 565 BrowserAccessibility* root = manager->GetRoot(); |
| 566 EXPECT_EQ(1000, root->renderer_id()); | 566 EXPECT_EQ(1000, root->renderer_id()); |
| 567 EXPECT_EQ(WebAccessibility::ROLE_WEB_AREA, root->role()); | 567 EXPECT_EQ(WebAccessibility::ROLE_WEB_AREA, root->role()); |
| 568 EXPECT_EQ(WebAccessibility::STATE_BUSY, root->state()); | 568 EXPECT_EQ(WebAccessibility::STATE_BUSY, root->state()); |
| 569 | 569 |
| 570 // Tree with a child textfield. | 570 // Tree with a child textfield. |
| 571 WebAccessibility tree1_1; | 571 WebAccessibility tree1_1; |
| 572 tree1_1.id = 1000; | 572 tree1_1.id = 1000; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 | 618 |
| 619 // Verify the root has not changed. | 619 // Verify the root has not changed. |
| 620 EXPECT_EQ(root, manager->GetRoot()); | 620 EXPECT_EQ(root, manager->GetRoot()); |
| 621 | 621 |
| 622 // And the proper child remains. | 622 // And the proper child remains. |
| 623 EXPECT_EQ(WebAccessibility::ROLE_BUTTON, acc2_2->role()); | 623 EXPECT_EQ(WebAccessibility::ROLE_BUTTON, acc2_2->role()); |
| 624 EXPECT_EQ(1001, acc2_2->renderer_id()); | 624 EXPECT_EQ(1001, acc2_2->renderer_id()); |
| 625 | 625 |
| 626 // Verify we don't reuse objects that have changed roles. | 626 // Verify we don't reuse objects that have changed roles. |
| 627 EXPECT_NE(acc1_2, acc2_2); | 627 EXPECT_NE(acc1_2, acc2_2); |
| 628 |
| 629 // Ensure we properly cleaned up. |
| 630 manager.reset(); |
| 631 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); |
| 628 } | 632 } |
| OLD | NEW |