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/utf_string_conversions.h" | 8 #include "base/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 15 matching lines...) Expand all Loading... |
26 namespace content { | 26 namespace content { |
27 | 27 |
28 class CrossPlatformAccessibilityBrowserTest : public ContentBrowserTest { | 28 class CrossPlatformAccessibilityBrowserTest : public ContentBrowserTest { |
29 public: | 29 public: |
30 CrossPlatformAccessibilityBrowserTest() {} | 30 CrossPlatformAccessibilityBrowserTest() {} |
31 | 31 |
32 // Tell the renderer to send an accessibility tree, then wait for the | 32 // Tell the renderer to send an accessibility tree, then wait for the |
33 // notification that it's been received. | 33 // notification that it's been received. |
34 const AccessibilityNodeData& GetAccessibilityNodeDataTree( | 34 const AccessibilityNodeData& GetAccessibilityNodeDataTree( |
35 AccessibilityMode accessibility_mode = AccessibilityModeComplete) { | 35 AccessibilityMode accessibility_mode = AccessibilityModeComplete) { |
36 scoped_refptr<MessageLoopRunner> loop_runner(new MessageLoopRunner); | 36 WindowedNotificationObserver tree_updated_observer( |
| 37 NOTIFICATION_ACCESSIBILITY_LAYOUT_COMPLETE, |
| 38 NotificationService::AllSources()); |
37 RenderWidgetHostView* host_view = | 39 RenderWidgetHostView* host_view = |
38 shell()->web_contents()->GetRenderWidgetHostView(); | 40 shell()->web_contents()->GetRenderWidgetHostView(); |
39 RenderWidgetHostImpl* host = | 41 RenderWidgetHostImpl* host = |
40 RenderWidgetHostImpl::From(host_view->GetRenderWidgetHost()); | 42 RenderWidgetHostImpl::From(host_view->GetRenderWidgetHost()); |
41 RenderViewHostImpl* view_host = static_cast<RenderViewHostImpl*>(host); | 43 RenderViewHostImpl* view_host = static_cast<RenderViewHostImpl*>(host); |
42 view_host->SetAccessibilityLayoutCompleteCallbackForTesting( | |
43 loop_runner->QuitClosure()); | |
44 view_host->set_save_accessibility_tree_for_testing(true); | 44 view_host->set_save_accessibility_tree_for_testing(true); |
45 view_host->SetAccessibilityMode(accessibility_mode); | 45 view_host->SetAccessibilityMode(accessibility_mode); |
46 loop_runner->Run(); | 46 tree_updated_observer.Wait(); |
47 return view_host->accessibility_tree_for_testing(); | 47 return view_host->accessibility_tree_for_testing(); |
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 an unique id. |
51 void RecursiveAssertUniqueIds( | 51 void RecursiveAssertUniqueIds( |
52 const AccessibilityNodeData& node, base::hash_set<int>* ids) { | 52 const AccessibilityNodeData& 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 (size_t i = 0; i < node.children.size(); i++) | 55 for (size_t i = 0; i < node.children.size(); i++) |
56 RecursiveAssertUniqueIds(node.children[i], ids); | 56 RecursiveAssertUniqueIds(node.children[i], ids); |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 const AccessibilityNodeData& tree = GetAccessibilityNodeDataTree(); | 458 const AccessibilityNodeData& tree = GetAccessibilityNodeDataTree(); |
459 | 459 |
460 ASSERT_EQ(1U, tree.children.size()); | 460 ASSERT_EQ(1U, tree.children.size()); |
461 const AccessibilityNodeData& textbox = tree.children[0]; | 461 const AccessibilityNodeData& textbox = tree.children[0]; |
462 | 462 |
463 EXPECT_EQ( | 463 EXPECT_EQ( |
464 true, GetBoolAttr(textbox, AccessibilityNodeData::ATTR_CAN_SET_VALUE)); | 464 true, GetBoolAttr(textbox, AccessibilityNodeData::ATTR_CAN_SET_VALUE)); |
465 } | 465 } |
466 | 466 |
467 } // namespace content | 467 } // namespace content |
OLD | NEW |