Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: chrome/browser/ui/aura/accessibility/automation_manager_aura_browsertest.cc

Issue 2803823002: Fix Chrome OS virtual keyboard accessibility (Closed)
Patch Set: Check for window_ == window Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/aura/accessibility/automation_manager_aura.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/aura/accessibility/automation_manager_aura.h"
6 #include "chrome/browser/ui/browser.h"
7 #include "chrome/browser/ui/browser_window.h"
8 #include "chrome/browser/ui/tabs/tab_strip_model.h"
9 #include "chrome/test/base/in_process_browser_test.h"
10 #include "chrome/test/base/ui_test_utils.h"
11 #include "content/public/browser/browser_accessibility_state.h"
12 #include "content/public/browser/render_frame_host.h"
13 #include "content/public/browser/web_contents.h"
14 #include "content/public/test/browser_test_utils.h"
15 #include "ui/accessibility/ax_node_data.h"
16
17 namespace {
18
19 // Given an AXTreeSourceAura and a node within that tree, recursively search
20 // for all nodes who have a child tree id of |target_ax_tree_id|, meaning
21 // that they're a parent of a particular web contents.
22 void FindAllHostsOfWebContentsWithAXTreeID(
23 AXTreeSourceAura* tree,
24 views::AXAuraObjWrapper* node,
25 int target_ax_tree_id,
26 std::vector<views::AXAuraObjWrapper*>* web_hosts) {
27 ui::AXNodeData node_data;
28 tree->SerializeNode(node, &node_data);
29 if (node_data.GetIntAttribute(ui::AX_ATTR_CHILD_TREE_ID) ==
30 target_ax_tree_id) {
31 web_hosts->push_back(node);
32 }
33
34 std::vector<views::AXAuraObjWrapper*> children;
35 tree->GetChildren(node, &children);
36 for (auto* child : children) {
37 FindAllHostsOfWebContentsWithAXTreeID(tree, child, target_ax_tree_id,
38 web_hosts);
39 }
40 }
41
42 } // namespace
43
44 typedef InProcessBrowserTest AutomationManagerAuraBrowserTest;
45
46 // A WebContents can be "hooked up" to the Chrome OS Desktop accessibility
47 // tree two different ways: via its aura::Window, and via a views::WebView.
48 // This test makes sure that we don't hook up both simultaneously, leading
49 // to the same web page appearing in the overall tree twice.
50 IN_PROC_BROWSER_TEST_F(AutomationManagerAuraBrowserTest, WebAppearsOnce) {
51 content::BrowserAccessibilityState::GetInstance()->EnableAccessibility();
52
53 AutomationManagerAura* manager = AutomationManagerAura::GetInstance();
54 manager->Enable(browser()->profile());
55 auto* tree = manager->current_tree_.get();
56
57 ui_test_utils::NavigateToURL(
58 browser(),
59 GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>"));
60
61 auto* web_contents = browser()->tab_strip_model()->GetActiveWebContents();
62
63 WaitForAccessibilityTreeToContainNodeWithName(web_contents, "Click me");
64
65 auto* frame_host = web_contents->GetMainFrame();
66 int ax_tree_id = frame_host->GetAXTreeID();
67 ASSERT_GT(ax_tree_id, 0);
68
69 std::vector<views::AXAuraObjWrapper*> web_hosts;
70 FindAllHostsOfWebContentsWithAXTreeID(tree, tree->GetRoot(), ax_tree_id,
71 &web_hosts);
72
73 EXPECT_EQ(1U, web_hosts.size());
74 if (web_hosts.size() == 1) {
75 ui::AXNodeData node_data;
76 tree->SerializeNode(web_hosts[0], &node_data);
77 EXPECT_EQ(ui::AX_ROLE_WEB_VIEW, node_data.role);
78 } else {
79 for (size_t i = 0; i < web_hosts.size(); i++) {
80 ui::AXNodeData node_data;
81 tree->SerializeNode(web_hosts[i], &node_data);
82 LOG(ERROR) << i << ": " << node_data.ToString();
83 }
84 }
85 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/aura/accessibility/automation_manager_aura.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698