OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" | 5 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" |
6 | 6 |
7 #include <X11/Xlib.h> | 7 #include <X11/Xlib.h> |
8 | 8 |
9 // Get rid of X11 macros which conflict with gtest. | 9 // Get rid of X11 macros which conflict with gtest. |
10 #undef Bool | 10 #undef Bool |
(...skipping 26 matching lines...) Expand all Loading... |
37 explicit ActivationWaiter(XID window) | 37 explicit ActivationWaiter(XID window) |
38 : X11PropertyChangeWaiter(ui::GetX11RootWindow(), "_NET_ACTIVE_WINDOW"), | 38 : X11PropertyChangeWaiter(ui::GetX11RootWindow(), "_NET_ACTIVE_WINDOW"), |
39 window_(window) { | 39 window_(window) { |
40 } | 40 } |
41 | 41 |
42 virtual ~ActivationWaiter() { | 42 virtual ~ActivationWaiter() { |
43 } | 43 } |
44 | 44 |
45 private: | 45 private: |
46 // X11PropertyChangeWaiter: | 46 // X11PropertyChangeWaiter: |
47 virtual bool ShouldKeepOnWaiting(const ui::PlatformEvent& event) OVERRIDE { | 47 virtual bool ShouldKeepOnWaiting(const ui::PlatformEvent& event) override { |
48 XID xid = 0; | 48 XID xid = 0; |
49 ui::GetXIDProperty(ui::GetX11RootWindow(), "_NET_ACTIVE_WINDOW", &xid); | 49 ui::GetXIDProperty(ui::GetX11RootWindow(), "_NET_ACTIVE_WINDOW", &xid); |
50 return xid != window_; | 50 return xid != window_; |
51 } | 51 } |
52 | 52 |
53 XID window_; | 53 XID window_; |
54 | 54 |
55 DISALLOW_COPY_AND_ASSIGN(ActivationWaiter); | 55 DISALLOW_COPY_AND_ASSIGN(ActivationWaiter); |
56 }; | 56 }; |
57 | 57 |
58 // An event handler which counts the number of mouse moves it has seen. | 58 // An event handler which counts the number of mouse moves it has seen. |
59 class MouseMoveCounterHandler : public ui::EventHandler { | 59 class MouseMoveCounterHandler : public ui::EventHandler { |
60 public: | 60 public: |
61 MouseMoveCounterHandler() : count_(0) { | 61 MouseMoveCounterHandler() : count_(0) { |
62 } | 62 } |
63 virtual ~MouseMoveCounterHandler() { | 63 virtual ~MouseMoveCounterHandler() { |
64 } | 64 } |
65 | 65 |
66 // ui::EventHandler: | 66 // ui::EventHandler: |
67 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { | 67 virtual void OnMouseEvent(ui::MouseEvent* event) override { |
68 if (event->type() == ui::ET_MOUSE_MOVED) | 68 if (event->type() == ui::ET_MOUSE_MOVED) |
69 ++count_; | 69 ++count_; |
70 } | 70 } |
71 | 71 |
72 int num_mouse_moves() const { | 72 int num_mouse_moves() const { |
73 return count_; | 73 return count_; |
74 } | 74 } |
75 | 75 |
76 private: | 76 private: |
77 int count_; | 77 int count_; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 128 |
129 static void SetUpTestCase() { | 129 static void SetUpTestCase() { |
130 gfx::GLSurface::InitializeOneOffForTests(); | 130 gfx::GLSurface::InitializeOneOffForTests(); |
131 ui::RegisterPathProvider(); | 131 ui::RegisterPathProvider(); |
132 base::FilePath ui_test_pak_path; | 132 base::FilePath ui_test_pak_path; |
133 ASSERT_TRUE(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path)); | 133 ASSERT_TRUE(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path)); |
134 ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path); | 134 ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path); |
135 } | 135 } |
136 | 136 |
137 // testing::Test | 137 // testing::Test |
138 virtual void SetUp() OVERRIDE { | 138 virtual void SetUp() override { |
139 ViewsTestBase::SetUp(); | 139 ViewsTestBase::SetUp(); |
140 | 140 |
141 // Make X11 synchronous for our display connection. This does not force the | 141 // Make X11 synchronous for our display connection. This does not force the |
142 // window manager to behave synchronously. | 142 // window manager to behave synchronously. |
143 XSynchronize(gfx::GetXDisplay(), True); | 143 XSynchronize(gfx::GetXDisplay(), True); |
144 } | 144 } |
145 | 145 |
146 virtual void TearDown() OVERRIDE { | 146 virtual void TearDown() override { |
147 XSynchronize(gfx::GetXDisplay(), False); | 147 XSynchronize(gfx::GetXDisplay(), False); |
148 ViewsTestBase::TearDown(); | 148 ViewsTestBase::TearDown(); |
149 } | 149 } |
150 | 150 |
151 private: | 151 private: |
152 DISALLOW_COPY_AND_ASSIGN(DesktopWindowTreeHostX11Test); | 152 DISALLOW_COPY_AND_ASSIGN(DesktopWindowTreeHostX11Test); |
153 }; | 153 }; |
154 | 154 |
155 // Test that calling Widget::Deactivate() sets the widget as inactive wrt to | 155 // Test that calling Widget::Deactivate() sets the widget as inactive wrt to |
156 // Chrome even if it not possible to deactivate the window wrt to the x server. | 156 // Chrome even if it not possible to deactivate the window wrt to the x server. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 EXPECT_EQ(3, recorder2.num_mouse_moves()); | 248 EXPECT_EQ(3, recorder2.num_mouse_moves()); |
249 EXPECT_EQ(point_in_screen.ToString(), | 249 EXPECT_EQ(point_in_screen.ToString(), |
250 aura::Env::GetInstance()->last_mouse_location().ToString()); | 250 aura::Env::GetInstance()->last_mouse_location().ToString()); |
251 | 251 |
252 // Cleanup | 252 // Cleanup |
253 window1->RemovePreTargetHandler(&recorder1); | 253 window1->RemovePreTargetHandler(&recorder1); |
254 window2->RemovePreTargetHandler(&recorder2); | 254 window2->RemovePreTargetHandler(&recorder2); |
255 } | 255 } |
256 | 256 |
257 } // namespace views | 257 } // namespace views |
OLD | NEW |