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

Side by Side Diff: ui/views/test/ui_controls_factory_desktop_aurax11.cc

Issue 2327623002: X11: Add TestDesktopScreenX11 to simulate mouse movement in ui tests (Closed)
Patch Set: Move test_desktop_screen_x11 to test_support_internal Created 4 years, 3 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 | « ui/views/test/test_desktop_screen_x11.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <X11/keysym.h> 5 #include <X11/keysym.h>
6 #include <X11/Xlib.h> 6 #include <X11/Xlib.h>
7 7
8 // X macro fail. 8 // X macro fail.
9 #if defined(RootWindow) 9 #if defined(RootWindow)
10 #undef RootWindow 10 #undef RootWindow
11 #endif 11 #endif
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "ui/aura/client/screen_position_client.h" 16 #include "ui/aura/client/screen_position_client.h"
17 #include "ui/aura/env.h" 17 #include "ui/aura/env.h"
18 #include "ui/aura/test/aura_test_utils.h" 18 #include "ui/aura/test/aura_test_utils.h"
19 #include "ui/aura/test/ui_controls_factory_aura.h" 19 #include "ui/aura/test/ui_controls_factory_aura.h"
20 #include "ui/aura/test/x11_event_sender.h" 20 #include "ui/aura/test/x11_event_sender.h"
21 #include "ui/aura/window_event_dispatcher.h" 21 #include "ui/aura/window_event_dispatcher.h"
22 #include "ui/base/test/ui_controls_aura.h" 22 #include "ui/base/test/ui_controls_aura.h"
23 #include "ui/base/x/x11_util.h" 23 #include "ui/base/x/x11_util.h"
24 #include "ui/compositor/dip_util.h" 24 #include "ui/compositor/dip_util.h"
25 #include "ui/events/keycodes/keyboard_code_conversion_x.h" 25 #include "ui/events/keycodes/keyboard_code_conversion_x.h"
26 #include "ui/events/test/platform_event_waiter.h" 26 #include "ui/events/test/platform_event_waiter.h"
27 #include "ui/gfx/x/x11_connection.h" 27 #include "ui/gfx/x/x11_connection.h"
28 #include "ui/views/test/test_desktop_screen_x11.h"
28 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" 29 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
29 30
30 namespace views { 31 namespace views {
31 namespace test { 32 namespace test {
32 namespace { 33 namespace {
33 34
34 using ui_controls::DOWN; 35 using ui_controls::DOWN;
35 using ui_controls::LEFT; 36 using ui_controls::LEFT;
36 using ui_controls::MIDDLE; 37 using ui_controls::MIDDLE;
37 using ui_controls::MouseButton; 38 using ui_controls::MouseButton;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 if (screen_position_client) { 139 if (screen_position_client) {
139 screen_position_client->ConvertPointFromScreen(root_window, 140 screen_position_client->ConvertPointFromScreen(root_window,
140 &root_location); 141 &root_location);
141 } 142 }
142 143
143 aura::WindowTreeHost* host = root_window->GetHost(); 144 aura::WindowTreeHost* host = root_window->GetHost();
144 gfx::Point root_current_location = 145 gfx::Point root_current_location =
145 aura::test::QueryLatestMousePositionRequestInHost(host); 146 aura::test::QueryLatestMousePositionRequestInHost(host);
146 host->ConvertPointFromHost(&root_current_location); 147 host->ConvertPointFromHost(&root_current_location);
147 148
149 auto screen = views::test::TestDesktopScreenX11::GetInstance();
150 DCHECK_EQ(screen, display::Screen::GetScreen());
151 screen->set_cursor_screen_point(gfx::Point(screen_x, screen_y));
152
148 if (root_location != root_current_location && button_down_mask == 0) { 153 if (root_location != root_current_location && button_down_mask == 0) {
149 // Move the cursor because EnterNotify/LeaveNotify are generated with the 154 // Move the cursor because EnterNotify/LeaveNotify are generated with the
150 // current mouse position as a result of XGrabPointer() 155 // current mouse position as a result of XGrabPointer()
151 root_window->MoveCursorTo(root_location); 156 root_window->MoveCursorTo(root_location);
152 } else { 157 } else {
153 XEvent xevent = {0}; 158 XEvent xevent = {0};
154 XMotionEvent* xmotion = &xevent.xmotion; 159 XMotionEvent* xmotion = &xevent.xmotion;
155 xmotion->type = MotionNotify; 160 xmotion->type = MotionNotify;
156 xmotion->x = root_location.x(); 161 xmotion->x = root_location.x();
157 xmotion->y = root_location.y(); 162 xmotion->y = root_location.y();
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 285
281 UIControlsAura* CreateUIControlsDesktopAura() { 286 UIControlsAura* CreateUIControlsDesktopAura() {
282 // The constructor of UIControlsDesktopX11 needs X11 connection to be 287 // The constructor of UIControlsDesktopX11 needs X11 connection to be
283 // initialized. 288 // initialized.
284 gfx::InitializeThreadedX11(); 289 gfx::InitializeThreadedX11();
285 return new UIControlsDesktopX11(); 290 return new UIControlsDesktopX11();
286 } 291 }
287 292
288 } // namespace test 293 } // namespace test
289 } // namespace views 294 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/test/test_desktop_screen_x11.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698