Chromium Code Reviews| Index: chrome/browser/accessibility/browser_accessibility_manager_unittest.cc |
| diff --git a/chrome/browser/accessibility/browser_accessibility_manager_unittest.cc b/chrome/browser/accessibility/browser_accessibility_manager_unittest.cc |
| index 79f96b8573c644964b5e12b438f5a0472ba12045..2a76597f18f842654ee66b735eeadc0ab1e4f712 100644 |
| --- a/chrome/browser/accessibility/browser_accessibility_manager_unittest.cc |
| +++ b/chrome/browser/accessibility/browser_accessibility_manager_unittest.cc |
| @@ -551,3 +551,78 @@ TEST(BrowserAccessibilityManagerTest, TestMoveChildUp) { |
| delete manager; |
| ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); |
| } |
| + |
| +TEST(BrowserAccessibilityManagerTest, TestCreateEmptyDocument) { |
| + // Try creating an empty document with busy state. |
| + BrowserAccessibilityManager* manager = |
| + BrowserAccessibilityManager::CreateEmptyDocument( |
| + NULL, |
| + WebAccessibility::STATE_BUSY, |
| + NULL, |
| + new CountedBrowserAccessibilityFactory()); |
| + |
| +// Verify the root is as we expect by default. |
|
dmazzoni
2011/08/04 16:29:07
Indent comment
David Tseng
2011/08/04 16:41:58
Done.
|
| + BrowserAccessibility* root = manager->GetRoot(); |
| + EXPECT_EQ(1000, root->renderer_id()); |
| + EXPECT_EQ(WebAccessibility::ROLE_WEB_AREA, root->role()); |
| + EXPECT_EQ(WebAccessibility::STATE_BUSY, root->state()); |
| + |
| + // Tree with a child textfield. |
| + WebAccessibility tree1_1; |
| + tree1_1.id = 1000; |
| + tree1_1.role = WebAccessibility::ROLE_WEB_AREA; |
| + |
| + WebAccessibility tree1_2; |
| + tree1_2.id = 1001; |
| + tree1_2.role = WebAccessibility::ROLE_TEXT_FIELD; |
| + |
| + tree1_1.children.push_back(tree1_2); |
| + |
| + // Process a load complete. |
| + std::vector<ViewHostMsg_AccessibilityNotification_Params> params; |
| + params.push_back(ViewHostMsg_AccessibilityNotification_Params()); |
| + ViewHostMsg_AccessibilityNotification_Params* msg = ¶ms[0]; |
| + msg->notification_type = ViewHostMsg_AccessibilityNotification_Type:: |
| + NOTIFICATION_TYPE_LOAD_COMPLETE; |
| + msg->acc_obj = tree1_1; |
| + |
| + manager->OnAccessibilityNotifications(params); |
| + |
| + // Save for later comparison. |
| + BrowserAccessibility* acc1_2 = manager->GetFromRendererID(1001); |
| + |
| + // Verify the root has not changed. |
| + EXPECT_EQ(root, manager->GetRoot()); |
| + |
| + // And the proper child remains. |
| + EXPECT_EQ(WebAccessibility::ROLE_TEXT_FIELD, acc1_2->role()); |
| + EXPECT_EQ(1001, acc1_2->renderer_id()); |
| + |
| + // Tree with a child button. |
| + WebAccessibility tree2_1; |
| + tree2_1.id = 1000; |
| + tree2_1.role = WebAccessibility::ROLE_WEB_AREA; |
| + |
| + WebAccessibility tree2_2; |
| + tree2_2.id = 1001; |
| + tree2_2.role = WebAccessibility::ROLE_BUTTON; |
| + |
| + tree2_1.children.push_back(tree2_2); |
| + |
| + msg->acc_obj = tree2_1; |
| + |
| + // Fire another load complete. |
| + manager->OnAccessibilityNotifications(params); |
| + |
| + BrowserAccessibility* acc2_2 = manager->GetFromRendererID(1001); |
| + |
| + // Verify the root has not changed. |
| + EXPECT_EQ(root, manager->GetRoot()); |
| + |
| + // And the proper child remains. |
| + EXPECT_EQ(WebAccessibility::ROLE_BUTTON, acc2_2->role()); |
| + EXPECT_EQ(1001, acc2_2->renderer_id()); |
| + |
| + // Verify we don't reuse objects that have changed roles. |
| + EXPECT_NE(acc1_2, acc2_2); |
| +} |