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

Side by Side Diff: content/browser/accessibility/touch_accessibility_aura_browsertest.cc

Issue 2694413006: Scope and clean up uses of AccessibilityMode. (Closed)
Patch Set: merge Created 3 years, 9 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/macros.h" 5 #include "base/macros.h"
6 #include "base/strings/string_number_conversions.h" 6 #include "base/strings/string_number_conversions.h"
7 #include "content/browser/accessibility/browser_accessibility.h" 7 #include "content/browser/accessibility/browser_accessibility.h"
8 #include "content/browser/web_contents/web_contents_impl.h" 8 #include "content/browser/web_contents/web_contents_impl.h"
9 #include "content/public/test/browser_test_utils.h" 9 #include "content/public/test/browser_test_utils.h"
10 #include "content/public/test/content_browser_test.h" 10 #include "content/public/test/content_browser_test.h"
(...skipping 16 matching lines...) Expand all
27 TouchAccessibilityBrowserTest() {} 27 TouchAccessibilityBrowserTest() {}
28 28
29 protected: 29 protected:
30 void SetUpOnMainThread() override { 30 void SetUpOnMainThread() override {
31 host_resolver()->AddRule("*", "127.0.0.1"); 31 host_resolver()->AddRule("*", "127.0.0.1");
32 SetupCrossSiteRedirector(embedded_test_server()); 32 SetupCrossSiteRedirector(embedded_test_server());
33 ASSERT_TRUE(embedded_test_server()->Start()); 33 ASSERT_TRUE(embedded_test_server()->Start());
34 } 34 }
35 35
36 void NavigateToUrlAndWaitForAccessibilityTree(const GURL& url) { 36 void NavigateToUrlAndWaitForAccessibilityTree(const GURL& url) {
37 AccessibilityNotificationWaiter waiter( 37 AccessibilityNotificationWaiter waiter(shell()->web_contents(),
38 shell()->web_contents(), 38 kAccessibilityModeComplete,
39 ACCESSIBILITY_MODE_COMPLETE, 39 ui::AX_EVENT_LOAD_COMPLETE);
40 ui::AX_EVENT_LOAD_COMPLETE);
41 NavigateToURL(shell(), url); 40 NavigateToURL(shell(), url);
42 waiter.WaitForNotification(); 41 waiter.WaitForNotification();
43 } 42 }
44 43
45 void SendTouchExplorationEvent(int x, int y) { 44 void SendTouchExplorationEvent(int x, int y) {
46 aura::Window* window = shell()->web_contents()->GetContentNativeView(); 45 aura::Window* window = shell()->web_contents()->GetContentNativeView();
47 ui::EventProcessor* dispatcher = window->GetHost()->event_processor(); 46 ui::EventProcessor* dispatcher = window->GetHost()->event_processor();
48 gfx::Rect bounds = window->GetBoundsInRootWindow(); 47 gfx::Rect bounds = window->GetBoundsInRootWindow();
49 gfx::Point location(bounds.x() + x, bounds.y() + y); 48 gfx::Point location(bounds.x() + x, bounds.y() + y);
50 int flags = ui::EF_TOUCH_ACCESSIBILITY; 49 int flags = ui::EF_TOUCH_ACCESSIBILITY;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( 85 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(
87 shell()->web_contents()); 86 shell()->web_contents());
88 BrowserAccessibilityManager* manager = 87 BrowserAccessibilityManager* manager =
89 web_contents->GetRootBrowserAccessibilityManager(); 88 web_contents->GetRootBrowserAccessibilityManager();
90 ASSERT_NE(nullptr, manager); 89 ASSERT_NE(nullptr, manager);
91 90
92 // Loop over all of the cells in the table. For each one, send a simulated 91 // Loop over all of the cells in the table. For each one, send a simulated
93 // touch exploration event in the center of that cell, and assert that we 92 // touch exploration event in the center of that cell, and assert that we
94 // get an accessibility hover event fired in the correct cell. 93 // get an accessibility hover event fired in the correct cell.
95 AccessibilityNotificationWaiter waiter( 94 AccessibilityNotificationWaiter waiter(
96 shell()->web_contents(), ACCESSIBILITY_MODE_COMPLETE, ui::AX_EVENT_HOVER); 95 shell()->web_contents(), kAccessibilityModeComplete, ui::AX_EVENT_HOVER);
97 for (int row = 0; row < 5; ++row) { 96 for (int row = 0; row < 5; ++row) {
98 for (int col = 0; col < 7; ++col) { 97 for (int col = 0; col < 7; ++col) {
99 std::string expected_cell_text = base::IntToString(row * 7 + col); 98 std::string expected_cell_text = base::IntToString(row * 7 + col);
100 VLOG(1) << "Sending event in row " << row << " col " << col 99 VLOG(1) << "Sending event in row " << row << " col " << col
101 << " with text " << expected_cell_text; 100 << " with text " << expected_cell_text;
102 SendTouchExplorationEvent(50 * col + 25, 50 * row + 25); 101 SendTouchExplorationEvent(50 * col + 25, 50 * row + 25);
103 102
104 // Wait until we get a hover event in the expected grid cell. 103 // Wait until we get a hover event in the expected grid cell.
105 // Tolerate additional events, keep looping until we get the expected one. 104 // Tolerate additional events, keep looping until we get the expected one.
106 std::string cell_text; 105 std::string cell_text;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 SendTouchExplorationEvent(50, 350); 174 SendTouchExplorationEvent(50, 350);
176 waiter.WaitForNotification(); 175 waiter.WaitForNotification();
177 int target_id = waiter.event_target_id(); 176 int target_id = waiter.event_target_id();
178 BrowserAccessibility* hit = child_manager->GetFromID(target_id); 177 BrowserAccessibility* hit = child_manager->GetFromID(target_id);
179 EXPECT_EQ(ui::AX_ROLE_BUTTON, hit->GetData().role); 178 EXPECT_EQ(ui::AX_ROLE_BUTTON, hit->GetData().role);
180 std::string text = hit->GetData().GetStringAttribute(ui::AX_ATTR_NAME); 179 std::string text = hit->GetData().GetStringAttribute(ui::AX_ATTR_NAME);
181 EXPECT_EQ("Ordinary Button", text); 180 EXPECT_EQ("Ordinary Button", text);
182 } 181 }
183 182
184 } // namespace content 183 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/accessibility/hit_testing_browsertest.cc ('k') | content/browser/android/content_view_core_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698