| OLD | NEW |
| 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "content/browser/renderer_host/render_view_host_impl.h" | 9 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 10 #include "content/public/browser/notification_service.h" | 10 #include "content/public/browser/notification_service.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 // Tell the renderer to send an accessibility tree, then wait for the | 40 // Tell the renderer to send an accessibility tree, then wait for the |
| 41 // notification that it's been received. | 41 // notification that it's been received. |
| 42 const ui::AXTree& GetAXTree( | 42 const ui::AXTree& GetAXTree( |
| 43 AccessibilityMode accessibility_mode = AccessibilityModeComplete) { | 43 AccessibilityMode accessibility_mode = AccessibilityModeComplete) { |
| 44 AccessibilityNotificationWaiter waiter( | 44 AccessibilityNotificationWaiter waiter( |
| 45 shell(), accessibility_mode, ui::AX_EVENT_LAYOUT_COMPLETE); | 45 shell(), accessibility_mode, ui::AX_EVENT_LAYOUT_COMPLETE); |
| 46 waiter.WaitForNotification(); | 46 waiter.WaitForNotification(); |
| 47 return waiter.GetAXTree(); | 47 return waiter.GetAXTree(); |
| 48 } | 48 } |
| 49 | 49 |
| 50 // Make sure each node in the tree has an unique id. | 50 // Make sure each node in the tree has a unique id. |
| 51 void RecursiveAssertUniqueIds( | 51 void RecursiveAssertUniqueIds( |
| 52 const ui::AXNode* node, base::hash_set<int>* ids) { | 52 const ui::AXNode* node, base::hash_set<int>* ids) { |
| 53 ASSERT_TRUE(ids->find(node->id()) == ids->end()); | 53 ASSERT_TRUE(ids->find(node->id()) == ids->end()); |
| 54 ids->insert(node->id()); | 54 ids->insert(node->id()); |
| 55 for (int i = 0; i < node->child_count(); i++) | 55 for (int i = 0; i < node->child_count(); i++) |
| 56 RecursiveAssertUniqueIds(node->ChildAtIndex(i), ids); | 56 RecursiveAssertUniqueIds(node->ChildAtIndex(i), ids); |
| 57 } | 57 } |
| 58 | 58 |
| 59 // ContentBrowserTest | 59 // ContentBrowserTest |
| 60 void SetUpInProcessBrowserTestFixture() override; | 60 void SetUpInProcessBrowserTestFixture() override; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 EXPECT_STREQ( | 153 EXPECT_STREQ( |
| 154 "html", GetAttr(root, ui::AX_ATTR_DOC_DOCTYPE).c_str()); | 154 "html", GetAttr(root, ui::AX_ATTR_DOC_DOCTYPE).c_str()); |
| 155 EXPECT_STREQ( | 155 EXPECT_STREQ( |
| 156 "text/html", | 156 "text/html", |
| 157 GetAttr(root, ui::AX_ATTR_DOC_MIMETYPE).c_str()); | 157 GetAttr(root, ui::AX_ATTR_DOC_MIMETYPE).c_str()); |
| 158 EXPECT_STREQ( | 158 EXPECT_STREQ( |
| 159 "Accessibility Test", | 159 "Accessibility Test", |
| 160 GetAttr(root, ui::AX_ATTR_NAME).c_str()); | 160 GetAttr(root, ui::AX_ATTR_NAME).c_str()); |
| 161 EXPECT_EQ(ui::AX_ROLE_ROOT_WEB_AREA, root->data().role); | 161 EXPECT_EQ(ui::AX_ROLE_ROOT_WEB_AREA, root->data().role); |
| 162 | 162 |
| 163 // Check properites of the BODY element. | 163 // Check properties of the BODY element. |
| 164 ASSERT_EQ(1, root->child_count()); | 164 ASSERT_EQ(1, root->child_count()); |
| 165 const ui::AXNode* body = root->ChildAtIndex(0); | 165 const ui::AXNode* body = root->ChildAtIndex(0); |
| 166 EXPECT_EQ(ui::AX_ROLE_GROUP, body->data().role); | 166 EXPECT_EQ(ui::AX_ROLE_GROUP, body->data().role); |
| 167 EXPECT_STREQ("body", | 167 EXPECT_STREQ("body", |
| 168 GetAttr(body, ui::AX_ATTR_HTML_TAG).c_str()); | 168 GetAttr(body, ui::AX_ATTR_HTML_TAG).c_str()); |
| 169 EXPECT_STREQ("block", | 169 EXPECT_STREQ("block", |
| 170 GetAttr(body, ui::AX_ATTR_DISPLAY).c_str()); | 170 GetAttr(body, ui::AX_ATTR_DISPLAY).c_str()); |
| 171 | 171 |
| 172 // Check properties of the two children of the BODY element. | 172 // Check properties of the two children of the BODY element. |
| 173 ASSERT_EQ(2, body->child_count()); | 173 ASSERT_EQ(2, body->child_count()); |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 GURL url(url_str); | 488 GURL url(url_str); |
| 489 NavigateToURL(shell(), url); | 489 NavigateToURL(shell(), url); |
| 490 const ui::AXTree& tree = GetAXTree(); | 490 const ui::AXTree& tree = GetAXTree(); |
| 491 const ui::AXNode* root = tree.root(); | 491 const ui::AXNode* root = tree.root(); |
| 492 ASSERT_EQ(1, root->child_count()); | 492 ASSERT_EQ(1, root->child_count()); |
| 493 const ui::AXNode* textbox = root->ChildAtIndex(0); | 493 const ui::AXNode* textbox = root->ChildAtIndex(0); |
| 494 EXPECT_EQ(true, GetBoolAttr(textbox, ui::AX_ATTR_CAN_SET_VALUE)); | 494 EXPECT_EQ(true, GetBoolAttr(textbox, ui::AX_ATTR_CAN_SET_VALUE)); |
| 495 } | 495 } |
| 496 | 496 |
| 497 } // namespace content | 497 } // namespace content |
| OLD | NEW |