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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include <X11/extensions/shape.h> | 7 #include <X11/extensions/shape.h> |
8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
9 | 9 |
10 // Get rid of X11 macros which conflict with gtest. | 10 // Get rid of X11 macros which conflict with gtest. |
11 #undef Bool | 11 #undef Bool |
12 #undef None | 12 #undef None |
13 | 13 |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/run_loop.h" |
15 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
16 #include "ui/aura/window_tree_host.h" | 17 #include "ui/aura/window_tree_host.h" |
17 #include "ui/base/hit_test.h" | 18 #include "ui/base/hit_test.h" |
18 #include "ui/base/x/x11_util.h" | 19 #include "ui/base/x/x11_util.h" |
19 #include "ui/events/platform/x11/x11_event_source.h" | 20 #include "ui/events/platform/x11/x11_event_source.h" |
20 #include "ui/gfx/path.h" | 21 #include "ui/gfx/path.h" |
21 #include "ui/gfx/point.h" | 22 #include "ui/gfx/point.h" |
22 #include "ui/gfx/rect.h" | 23 #include "ui/gfx/rect.h" |
23 #include "ui/gfx/x/x11_atom_cache.h" | 24 #include "ui/gfx/x/x11_atom_cache.h" |
24 #include "ui/views/test/views_test_base.h" | 25 #include "ui/views/test/views_test_base.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 int x, | 183 int x, |
183 int y) { | 184 int y) { |
184 gfx::Point point(x, y); | 185 gfx::Point point(x, y); |
185 for (size_t i = 0; i < shape_rects.size(); ++i) { | 186 for (size_t i = 0; i < shape_rects.size(); ++i) { |
186 if (shape_rects[i].Contains(point)) | 187 if (shape_rects[i].Contains(point)) |
187 return true; | 188 return true; |
188 } | 189 } |
189 return false; | 190 return false; |
190 } | 191 } |
191 | 192 |
| 193 // Flush the message loop. |
| 194 void RunAllPendingInMessageLoop() { |
| 195 base::RunLoop run_loop; |
| 196 run_loop.RunUntilIdle(); |
| 197 } |
| 198 |
192 } // namespace | 199 } // namespace |
193 | 200 |
194 class DesktopWindowTreeHostX11Test : public ViewsTestBase { | 201 class DesktopWindowTreeHostX11Test : public ViewsTestBase { |
195 public: | 202 public: |
196 DesktopWindowTreeHostX11Test() { | 203 DesktopWindowTreeHostX11Test() { |
197 } | 204 } |
198 virtual ~DesktopWindowTreeHostX11Test() { | 205 virtual ~DesktopWindowTreeHostX11Test() { |
199 } | 206 } |
200 | 207 |
201 virtual void SetUp() override { | 208 virtual void SetUp() override { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 | 263 |
257 if (ui::WmSupportsHint(ui::GetAtom("_NET_WM_STATE_MAXIMIZED_VERT"))) { | 264 if (ui::WmSupportsHint(ui::GetAtom("_NET_WM_STATE_MAXIMIZED_VERT"))) { |
258 // The shape should be changed to a rectangle which fills the entire screen | 265 // The shape should be changed to a rectangle which fills the entire screen |
259 // when |widget1| is maximized. | 266 // when |widget1| is maximized. |
260 { | 267 { |
261 WMStateWaiter waiter(xid1, "_NET_WM_STATE_MAXIMIZED_VERT", true); | 268 WMStateWaiter waiter(xid1, "_NET_WM_STATE_MAXIMIZED_VERT", true); |
262 widget1->Maximize(); | 269 widget1->Maximize(); |
263 waiter.Wait(); | 270 waiter.Wait(); |
264 } | 271 } |
265 | 272 |
| 273 // Ensure that the task which is posted when a window is resized is run. |
| 274 RunAllPendingInMessageLoop(); |
| 275 |
266 // xvfb does not support Xrandr so we cannot check the maximized window's | 276 // xvfb does not support Xrandr so we cannot check the maximized window's |
267 // bounds. | 277 // bounds. |
268 gfx::Rect maximized_bounds; | 278 gfx::Rect maximized_bounds; |
269 ui::GetWindowRect(xid1, &maximized_bounds); | 279 ui::GetWindowRect(xid1, &maximized_bounds); |
270 | 280 |
271 shape_rects = GetShapeRects(xid1); | 281 shape_rects = GetShapeRects(xid1); |
272 ASSERT_FALSE(shape_rects.empty()); | 282 ASSERT_FALSE(shape_rects.empty()); |
273 EXPECT_TRUE(ShapeRectContainsPoint(shape_rects, | 283 EXPECT_TRUE(ShapeRectContainsPoint(shape_rects, |
274 maximized_bounds.width() - 1, | 284 maximized_bounds.width() - 1, |
275 5)); | 285 5)); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 SubstructureRedirectMask | SubstructureNotifyMask, | 462 SubstructureRedirectMask | SubstructureNotifyMask, |
453 &xevent); | 463 &xevent); |
454 | 464 |
455 WMStateWaiter waiter(xid, "_NET_WM_STATE_FOCUSED", true); | 465 WMStateWaiter waiter(xid, "_NET_WM_STATE_FOCUSED", true); |
456 waiter.Wait(); | 466 waiter.Wait(); |
457 } | 467 } |
458 EXPECT_TRUE(widget.GetNativeWindow()->IsVisible()); | 468 EXPECT_TRUE(widget.GetNativeWindow()->IsVisible()); |
459 } | 469 } |
460 | 470 |
461 } // namespace views | 471 } // namespace views |
OLD | NEW |