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

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

Issue 2712963003: mustash: Use ui::chromeos::EventRewriter in mus (Closed)
Patch Set: Fix build issues. 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"
11 #include "content/public/test/content_browser_test_utils.h" 11 #include "content/public/test/content_browser_test_utils.h"
12 #include "content/shell/browser/shell.h" 12 #include "content/shell/browser/shell.h"
13 #include "content/test/accessibility_browser_test_utils.h" 13 #include "content/test/accessibility_browser_test_utils.h"
14 #include "net/dns/mock_host_resolver.h" 14 #include "net/dns/mock_host_resolver.h"
15 #include "net/test/embedded_test_server/embedded_test_server.h" 15 #include "net/test/embedded_test_server/embedded_test_server.h"
16 #include "ui/accessibility/ax_node_data.h" 16 #include "ui/accessibility/ax_node_data.h"
17 #include "ui/aura/window.h" 17 #include "ui/aura/window.h"
18 #include "ui/aura/window_tree_host.h" 18 #include "ui/aura/window_tree_host.h"
19 #include "ui/events/event.h" 19 #include "ui/events/event.h"
20 #include "ui/events/event_processor.h" 20 #include "ui/events/event_sink.h"
21 #include "ui/events/event_utils.h" 21 #include "ui/events/event_utils.h"
22 22
23 namespace content { 23 namespace content {
24 24
25 class TouchAccessibilityBrowserTest : public ContentBrowserTest { 25 class TouchAccessibilityBrowserTest : public ContentBrowserTest {
26 public: 26 public:
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(shell()->web_contents(), 37 AccessibilityNotificationWaiter waiter(shell()->web_contents(),
38 kAccessibilityModeComplete, 38 kAccessibilityModeComplete,
39 ui::AX_EVENT_LOAD_COMPLETE); 39 ui::AX_EVENT_LOAD_COMPLETE);
40 NavigateToURL(shell(), url); 40 NavigateToURL(shell(), url);
41 waiter.WaitForNotification(); 41 waiter.WaitForNotification();
42 } 42 }
43 43
44 void SendTouchExplorationEvent(int x, int y) { 44 void SendTouchExplorationEvent(int x, int y) {
45 aura::Window* window = shell()->web_contents()->GetContentNativeView(); 45 aura::Window* window = shell()->web_contents()->GetContentNativeView();
46 ui::EventProcessor* dispatcher = window->GetHost()->event_processor(); 46 ui::EventSink* sink = window->GetHost()->event_sink();
47 gfx::Rect bounds = window->GetBoundsInRootWindow(); 47 gfx::Rect bounds = window->GetBoundsInRootWindow();
48 gfx::Point location(bounds.x() + x, bounds.y() + y); 48 gfx::Point location(bounds.x() + x, bounds.y() + y);
49 int flags = ui::EF_TOUCH_ACCESSIBILITY; 49 int flags = ui::EF_TOUCH_ACCESSIBILITY;
50 std::unique_ptr<ui::Event> mouse_move_event( 50 std::unique_ptr<ui::Event> mouse_move_event(
51 new ui::MouseEvent(ui::ET_MOUSE_MOVED, location, location, 51 new ui::MouseEvent(ui::ET_MOUSE_MOVED, location, location,
52 ui::EventTimeForNow(), flags, 0)); 52 ui::EventTimeForNow(), flags, 0));
53 ignore_result(dispatcher->OnEventFromSource(mouse_move_event.get())); 53 ignore_result(sink->OnEventFromSource(mouse_move_event.get()));
54 } 54 }
55 55
56 DISALLOW_COPY_AND_ASSIGN(TouchAccessibilityBrowserTest); 56 DISALLOW_COPY_AND_ASSIGN(TouchAccessibilityBrowserTest);
57 }; 57 };
58 58
59 IN_PROC_BROWSER_TEST_F(TouchAccessibilityBrowserTest, 59 IN_PROC_BROWSER_TEST_F(TouchAccessibilityBrowserTest,
60 TouchExplorationSendsHoverEvents) { 60 TouchExplorationSendsHoverEvents) {
61 // Create HTML with a 7 x 5 table, each exactly 50 x 50 pixels. 61 // Create HTML with a 7 x 5 table, each exactly 50 x 50 pixels.
62 std::string html_url = 62 std::string html_url =
63 "data:text/html," 63 "data:text/html,"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 SendTouchExplorationEvent(50, 350); 174 SendTouchExplorationEvent(50, 350);
175 waiter.WaitForNotification(); 175 waiter.WaitForNotification();
176 int target_id = waiter.event_target_id(); 176 int target_id = waiter.event_target_id();
177 BrowserAccessibility* hit = child_manager->GetFromID(target_id); 177 BrowserAccessibility* hit = child_manager->GetFromID(target_id);
178 EXPECT_EQ(ui::AX_ROLE_BUTTON, hit->GetData().role); 178 EXPECT_EQ(ui::AX_ROLE_BUTTON, hit->GetData().role);
179 std::string text = hit->GetData().GetStringAttribute(ui::AX_ATTR_NAME); 179 std::string text = hit->GetData().GetStringAttribute(ui::AX_ATTR_NAME);
180 EXPECT_EQ("Ordinary Button", text); 180 EXPECT_EQ("Ordinary Button", text);
181 } 181 }
182 182
183 } // namespace content 183 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698