Update V8 to version 4.7.21.
[chromium-blink-merge.git] / ash / wm / ash_native_cursor_manager_interactive_uitest.cc
blobba52bbd2a75cbd249e80b30f629dbe0a13aa921c
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
3 // found in the LICENSE file.
4 #include "ash/wm/ash_native_cursor_manager.h"
6 #include "ash/display/display_info.h"
7 #include "ash/display/display_manager.h"
8 #include "ash/shell.h"
9 #include "ash/test/ash_interactive_ui_test_base.h"
10 #include "ash/test/cursor_manager_test_api.h"
11 #include "base/run_loop.h"
12 #include "ui/aura/window.h"
13 #include "ui/aura/window_tree_host.h"
14 #include "ui/base/test/ui_controls.h"
16 #if defined(USE_X11)
17 #include <X11/Xlib.h>
19 #include "ui/gfx/x/x11_types.h"
20 #endif
22 namespace ash {
24 using AshNativeCursorManagerTest = test::AshInteractiveUITestBase;
26 namespace {
28 DisplayInfo CreateDisplayInfo(int64 id,
29 const gfx::Rect& bounds,
30 float device_scale_factor) {
31 DisplayInfo info(id, "", false);
32 info.SetBounds(bounds);
33 info.set_device_scale_factor(device_scale_factor);
34 return info;
37 void MoveMouseSync(aura::Window* window, int x, int y) {
38 #if defined(USE_X11)
39 XWarpPointer(gfx::GetXDisplay(),
40 None,
41 window->GetHost()->GetAcceleratedWidget(),
42 0, 0, 0, 0,
43 x, y);
44 #endif
45 // Send and wait for a key event to make sure that mouse
46 // events are fully processed.
47 base::RunLoop loop;
48 ui_controls::SendKeyPressNotifyWhenDone(
49 window,
50 ui::VKEY_SPACE,
51 false,
52 false,
53 false,
54 false,
55 loop.QuitClosure());
56 loop.Run();
59 } // namespace
61 #if defined(USE_X11)
62 #define MAYBE_CursorChangeOnEnterNotify CursorChangeOnEnterNotify
63 #else
64 #define MAYBE_CursorChangeOnEnterNotify DISABLED_CursorChangeOnEnterNotify
65 #endif
67 TEST_F(AshNativeCursorManagerTest, MAYBE_CursorChangeOnEnterNotify) {
68 ::wm::CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager();
69 test::CursorManagerTestApi test_api(cursor_manager);
71 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
72 DisplayInfo display_info1 =
73 CreateDisplayInfo(10, gfx::Rect(0, 0, 500, 300), 1.0f);
74 DisplayInfo display_info2 =
75 CreateDisplayInfo(20, gfx::Rect(500, 0, 500, 300), 2.0f);
76 std::vector<DisplayInfo> display_info_list;
77 display_info_list.push_back(display_info1);
78 display_info_list.push_back(display_info2);
79 display_manager->OnNativeDisplaysChanged(display_info_list);
81 MoveMouseSync(Shell::GetAllRootWindows()[0], 10, 10);
82 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor());
84 MoveMouseSync(Shell::GetAllRootWindows()[0], 600, 10);
85 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor());
88 } // namespace ash