OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/wm/drag_window_resizer.h" | 5 #include "ash/wm/drag_window_resizer.h" |
6 | 6 |
7 #include "ash/common/material_design/material_design_controller.h" | |
8 #include "ash/common/shelf/shelf_layout_manager.h" | 7 #include "ash/common/shelf/shelf_layout_manager.h" |
9 #include "ash/common/wm/window_positioning_utils.h" | 8 #include "ash/common/wm/window_positioning_utils.h" |
10 #include "ash/common/wm_window.h" | 9 #include "ash/common/wm_window.h" |
11 #include "ash/display/mouse_cursor_event_filter.h" | 10 #include "ash/display/mouse_cursor_event_filter.h" |
12 #include "ash/public/cpp/shell_window_ids.h" | 11 #include "ash/public/cpp/shell_window_ids.h" |
13 #include "ash/root_window_controller.h" | 12 #include "ash/root_window_controller.h" |
14 #include "ash/shell.h" | 13 #include "ash/shell.h" |
15 #include "ash/test/ash_md_test_base.h" | 14 #include "ash/test/ash_test_base.h" |
16 #include "ash/test/cursor_manager_test_api.h" | 15 #include "ash/test/cursor_manager_test_api.h" |
17 #include "ash/wm/drag_window_controller.h" | 16 #include "ash/wm/drag_window_controller.h" |
18 #include "ash/wm/window_util.h" | 17 #include "ash/wm/window_util.h" |
19 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
20 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
21 #include "ui/aura/client/aura_constants.h" | 20 #include "ui/aura/client/aura_constants.h" |
22 #include "ui/aura/env.h" | 21 #include "ui/aura/env.h" |
23 #include "ui/aura/test/test_window_delegate.h" | 22 #include "ui/aura/test/test_window_delegate.h" |
24 #include "ui/base/hit_test.h" | 23 #include "ui/base/hit_test.h" |
25 #include "ui/base/ui_base_types.h" | 24 #include "ui/base/ui_base_types.h" |
(...skipping 27 matching lines...) Expand all Loading... |
53 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override {} | 52 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override {} |
54 void OnDeviceScaleFactorChanged(float device_scale_factor) override {} | 53 void OnDeviceScaleFactorChanged(float device_scale_factor) override {} |
55 | 54 |
56 int paint_count_ = 0; | 55 int paint_count_ = 0; |
57 | 56 |
58 DISALLOW_COPY_AND_ASSIGN(TestLayerDelegate); | 57 DISALLOW_COPY_AND_ASSIGN(TestLayerDelegate); |
59 }; | 58 }; |
60 | 59 |
61 } // namespace | 60 } // namespace |
62 | 61 |
63 class DragWindowResizerTest : public test::AshMDTestBase { | 62 class DragWindowResizerTest : public test::AshTestBase { |
64 public: | 63 public: |
65 DragWindowResizerTest() : transient_child_(nullptr) {} | 64 DragWindowResizerTest() : transient_child_(nullptr) {} |
66 ~DragWindowResizerTest() override {} | 65 ~DragWindowResizerTest() override {} |
67 | 66 |
68 void SetUp() override { | 67 void SetUp() override { |
69 AshMDTestBase::SetUp(); | 68 AshTestBase::SetUp(); |
70 | 69 |
71 UpdateDisplay(base::StringPrintf("800x%d", kRootHeight)); | 70 UpdateDisplay(base::StringPrintf("800x%d", kRootHeight)); |
72 | 71 |
73 aura::Window* root = Shell::GetPrimaryRootWindow(); | 72 aura::Window* root = Shell::GetPrimaryRootWindow(); |
74 gfx::Rect root_bounds(root->bounds()); | 73 gfx::Rect root_bounds(root->bounds()); |
75 EXPECT_EQ(kRootHeight, root_bounds.height()); | 74 EXPECT_EQ(kRootHeight, root_bounds.height()); |
76 EXPECT_EQ(800, root_bounds.width()); | 75 EXPECT_EQ(800, root_bounds.width()); |
77 window_.reset(new aura::Window(&delegate_)); | 76 window_.reset(new aura::Window(&delegate_)); |
78 window_->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 77 window_->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
79 window_->Init(ui::LAYER_NOT_DRAWN); | 78 window_->Init(ui::LAYER_NOT_DRAWN); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 panel_window_->Init(ui::LAYER_NOT_DRAWN); | 112 panel_window_->Init(ui::LAYER_NOT_DRAWN); |
114 ParentWindowInPrimaryRootWindow(panel_window_.get()); | 113 ParentWindowInPrimaryRootWindow(panel_window_.get()); |
115 } | 114 } |
116 | 115 |
117 void TearDown() override { | 116 void TearDown() override { |
118 window_.reset(); | 117 window_.reset(); |
119 always_on_top_window_.reset(); | 118 always_on_top_window_.reset(); |
120 system_modal_window_.reset(); | 119 system_modal_window_.reset(); |
121 transient_parent_.reset(); | 120 transient_parent_.reset(); |
122 panel_window_.reset(); | 121 panel_window_.reset(); |
123 AshMDTestBase::TearDown(); | 122 AshTestBase::TearDown(); |
124 } | 123 } |
125 | 124 |
126 protected: | 125 protected: |
127 gfx::Point CalculateDragPoint(const WindowResizer& resizer, | 126 gfx::Point CalculateDragPoint(const WindowResizer& resizer, |
128 int delta_x, | 127 int delta_x, |
129 int delta_y) const { | 128 int delta_y) const { |
130 gfx::Point location = resizer.GetInitialLocation(); | 129 gfx::Point location = resizer.GetInitialLocation(); |
131 location.set_x(location.x() + delta_x); | 130 location.set_x(location.x() + delta_x); |
132 location.set_y(location.y() + delta_y); | 131 location.set_y(location.y() + delta_y); |
133 return location; | 132 return location; |
(...skipping 29 matching lines...) Expand all Loading... |
163 std::unique_ptr<aura::Window> always_on_top_window_; | 162 std::unique_ptr<aura::Window> always_on_top_window_; |
164 std::unique_ptr<aura::Window> system_modal_window_; | 163 std::unique_ptr<aura::Window> system_modal_window_; |
165 std::unique_ptr<aura::Window> panel_window_; | 164 std::unique_ptr<aura::Window> panel_window_; |
166 aura::Window* transient_child_; | 165 aura::Window* transient_child_; |
167 std::unique_ptr<aura::Window> transient_parent_; | 166 std::unique_ptr<aura::Window> transient_parent_; |
168 | 167 |
169 private: | 168 private: |
170 DISALLOW_COPY_AND_ASSIGN(DragWindowResizerTest); | 169 DISALLOW_COPY_AND_ASSIGN(DragWindowResizerTest); |
171 }; | 170 }; |
172 | 171 |
173 INSTANTIATE_TEST_CASE_P( | |
174 /* prefix intentionally left blank due to only one parameterization */, | |
175 DragWindowResizerTest, | |
176 testing::Values(MaterialDesignController::NON_MATERIAL, | |
177 MaterialDesignController::MATERIAL_NORMAL, | |
178 MaterialDesignController::MATERIAL_EXPERIMENTAL)); | |
179 | |
180 // Verifies a window can be moved from the primary display to another. | 172 // Verifies a window can be moved from the primary display to another. |
181 TEST_P(DragWindowResizerTest, WindowDragWithMultiDisplays) { | 173 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplays) { |
182 const int height_offset = GetMdMaximizedWindowHeightOffset(); | |
183 | |
184 // The secondary display is logically on the right, but on the system (e.g. X) | 174 // The secondary display is logically on the right, but on the system (e.g. X) |
185 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. | 175 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. |
186 UpdateDisplay("800x600,400x300"); | 176 UpdateDisplay("800x600,400x300"); |
187 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 177 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
188 ASSERT_EQ(2U, root_windows.size()); | 178 ASSERT_EQ(2U, root_windows.size()); |
189 | 179 |
190 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), | 180 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), |
191 display::Screen::GetScreen()->GetPrimaryDisplay()); | 181 display::Screen::GetScreen()->GetPrimaryDisplay()); |
192 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | 182 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); |
193 { | 183 { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 { | 243 { |
254 // Grab the top-right edge of the window and move the pointer to (0, 10) | 244 // Grab the top-right edge of the window and move the pointer to (0, 10) |
255 // in the secondary root window's coordinates. | 245 // in the secondary root window's coordinates. |
256 std::unique_ptr<WindowResizer> resizer( | 246 std::unique_ptr<WindowResizer> resizer( |
257 CreateDragWindowResizer(window_.get(), gfx::Point(699, 0), HTCAPTION)); | 247 CreateDragWindowResizer(window_.get(), gfx::Point(699, 0), HTCAPTION)); |
258 ASSERT_TRUE(resizer.get()); | 248 ASSERT_TRUE(resizer.get()); |
259 resizer->Drag(CalculateDragPoint(*resizer, 101, 10), ui::EF_CONTROL_DOWN); | 249 resizer->Drag(CalculateDragPoint(*resizer, 101, 10), ui::EF_CONTROL_DOWN); |
260 resizer->CompleteDrag(); | 250 resizer->CompleteDrag(); |
261 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); | 251 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); |
262 // Window size should be adjusted to fit to the work area | 252 // Window size should be adjusted to fit to the work area |
263 EXPECT_EQ(gfx::Size(400, 253 + height_offset).ToString(), | 253 EXPECT_EQ(gfx::Size(400, 252).ToString(), |
264 window_->bounds().size().ToString()); | 254 window_->bounds().size().ToString()); |
265 gfx::Rect window_bounds_in_screen = window_->GetBoundsInScreen(); | 255 gfx::Rect window_bounds_in_screen = window_->GetBoundsInScreen(); |
266 gfx::Rect intersect(window_->GetRootWindow()->GetBoundsInScreen()); | 256 gfx::Rect intersect(window_->GetRootWindow()->GetBoundsInScreen()); |
267 intersect.Intersect(window_bounds_in_screen); | 257 intersect.Intersect(window_bounds_in_screen); |
268 | 258 |
269 EXPECT_LE(10, intersect.width()); | 259 EXPECT_LE(10, intersect.width()); |
270 EXPECT_LE(10, intersect.height()); | 260 EXPECT_LE(10, intersect.height()); |
271 EXPECT_TRUE(window_bounds_in_screen.Contains(gfx::Point(800, 10))); | 261 EXPECT_TRUE(window_bounds_in_screen.Contains(gfx::Point(800, 10))); |
272 } | 262 } |
273 | 263 |
274 // Dropping a window that is larger than the destination work area | 264 // Dropping a window that is larger than the destination work area |
275 // will shrink to fit to the work area. | 265 // will shrink to fit to the work area. |
276 window_->SetBoundsInScreen(gfx::Rect(0, 0, 700, 500), | 266 window_->SetBoundsInScreen(gfx::Rect(0, 0, 700, 500), |
277 display::Screen::GetScreen()->GetPrimaryDisplay()); | 267 display::Screen::GetScreen()->GetPrimaryDisplay()); |
278 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | 268 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); |
279 { | 269 { |
280 // Grab the top-left edge of the window and move the pointer to (150, 10) | 270 // Grab the top-left edge of the window and move the pointer to (150, 10) |
281 // in the secondary root window's coordinates. Make sure the window is | 271 // in the secondary root window's coordinates. Make sure the window is |
282 // shrink in such a way that it keeps the cursor within. | 272 // shrink in such a way that it keeps the cursor within. |
283 std::unique_ptr<WindowResizer> resizer( | 273 std::unique_ptr<WindowResizer> resizer( |
284 CreateDragWindowResizer(window_.get(), gfx::Point(0, 0), HTCAPTION)); | 274 CreateDragWindowResizer(window_.get(), gfx::Point(0, 0), HTCAPTION)); |
285 ASSERT_TRUE(resizer.get()); | 275 ASSERT_TRUE(resizer.get()); |
286 resizer->Drag(CalculateDragPoint(*resizer, 799, 10), ui::EF_CONTROL_DOWN); | 276 resizer->Drag(CalculateDragPoint(*resizer, 799, 10), ui::EF_CONTROL_DOWN); |
287 resizer->Drag(CalculateDragPoint(*resizer, 850, 10), ui::EF_CONTROL_DOWN); | 277 resizer->Drag(CalculateDragPoint(*resizer, 850, 10), ui::EF_CONTROL_DOWN); |
288 resizer->CompleteDrag(); | 278 resizer->CompleteDrag(); |
289 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); | 279 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); |
290 // Window size should be adjusted to fit to the work area | 280 // Window size should be adjusted to fit to the work area |
291 EXPECT_EQ(gfx::Size(400, 253 + height_offset).ToString(), | 281 EXPECT_EQ(gfx::Size(400, 252).ToString(), |
292 window_->bounds().size().ToString()); | 282 window_->bounds().size().ToString()); |
293 gfx::Rect window_bounds_in_screen = window_->GetBoundsInScreen(); | 283 gfx::Rect window_bounds_in_screen = window_->GetBoundsInScreen(); |
294 gfx::Rect intersect(window_->GetRootWindow()->GetBoundsInScreen()); | 284 gfx::Rect intersect(window_->GetRootWindow()->GetBoundsInScreen()); |
295 intersect.Intersect(window_bounds_in_screen); | 285 intersect.Intersect(window_bounds_in_screen); |
296 EXPECT_LE(10, intersect.width()); | 286 EXPECT_LE(10, intersect.width()); |
297 EXPECT_LE(10, intersect.height()); | 287 EXPECT_LE(10, intersect.height()); |
298 EXPECT_TRUE(window_bounds_in_screen.Contains(gfx::Point(850, 10))); | 288 EXPECT_TRUE(window_bounds_in_screen.Contains(gfx::Point(850, 10))); |
299 } | 289 } |
300 } | 290 } |
301 | 291 |
302 // Verifies that dragging the active window to another display makes the new | 292 // Verifies that dragging the active window to another display makes the new |
303 // root window the active root window. | 293 // root window the active root window. |
304 TEST_P(DragWindowResizerTest, WindowDragWithMultiDisplaysActiveRoot) { | 294 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplaysActiveRoot) { |
305 // The secondary display is logically on the right, but on the system (e.g. X) | 295 // The secondary display is logically on the right, but on the system (e.g. X) |
306 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. | 296 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. |
307 UpdateDisplay("800x600,800x600"); | 297 UpdateDisplay("800x600,800x600"); |
308 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 298 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
309 ASSERT_EQ(2U, root_windows.size()); | 299 ASSERT_EQ(2U, root_windows.size()); |
310 | 300 |
311 aura::test::TestWindowDelegate delegate; | 301 aura::test::TestWindowDelegate delegate; |
312 std::unique_ptr<aura::Window> window(new aura::Window(&delegate)); | 302 std::unique_ptr<aura::Window> window(new aura::Window(&delegate)); |
313 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 303 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
314 window->Init(ui::LAYER_TEXTURED); | 304 window->Init(ui::LAYER_TEXTURED); |
(...skipping 15 matching lines...) Expand all Loading... |
330 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); | 320 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); |
331 resizer->CompleteDrag(); | 321 resizer->CompleteDrag(); |
332 // The whole window is on the secondary display now. The parent should be | 322 // The whole window is on the secondary display now. The parent should be |
333 // changed. | 323 // changed. |
334 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 324 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
335 EXPECT_EQ(root_windows[1], ash::Shell::GetTargetRootWindow()); | 325 EXPECT_EQ(root_windows[1], ash::Shell::GetTargetRootWindow()); |
336 } | 326 } |
337 } | 327 } |
338 | 328 |
339 // Verifies a window can be moved from the secondary display to primary. | 329 // Verifies a window can be moved from the secondary display to primary. |
340 TEST_P(DragWindowResizerTest, WindowDragWithMultiDisplaysRightToLeft) { | 330 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplaysRightToLeft) { |
341 UpdateDisplay("800x600,800x600"); | 331 UpdateDisplay("800x600,800x600"); |
342 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 332 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
343 ASSERT_EQ(2U, root_windows.size()); | 333 ASSERT_EQ(2U, root_windows.size()); |
344 | 334 |
345 window_->SetBoundsInScreen( | 335 window_->SetBoundsInScreen( |
346 gfx::Rect(800, 00, 50, 60), | 336 gfx::Rect(800, 00, 50, 60), |
347 display::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[1])); | 337 display::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[1])); |
348 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); | 338 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); |
349 { | 339 { |
350 // Grab (0, 0) of the window. | 340 // Grab (0, 0) of the window. |
351 std::unique_ptr<WindowResizer> resizer( | 341 std::unique_ptr<WindowResizer> resizer( |
352 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION)); | 342 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION)); |
353 ASSERT_TRUE(resizer.get()); | 343 ASSERT_TRUE(resizer.get()); |
354 // Move the mouse near the right edge, (798, 0), of the primary display. | 344 // Move the mouse near the right edge, (798, 0), of the primary display. |
355 resizer->Drag(CalculateDragPoint(*resizer, -2, 0), ui::EF_CONTROL_DOWN); | 345 resizer->Drag(CalculateDragPoint(*resizer, -2, 0), ui::EF_CONTROL_DOWN); |
356 resizer->CompleteDrag(); | 346 resizer->CompleteDrag(); |
357 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | 347 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); |
358 // Window origin should be adjusted for minimum visibility (25px). | 348 // Window origin should be adjusted for minimum visibility (25px). |
359 EXPECT_EQ("775,0 50x60", window_->bounds().ToString()); | 349 EXPECT_EQ("775,0 50x60", window_->bounds().ToString()); |
360 } | 350 } |
361 } | 351 } |
362 | 352 |
363 // Verifies the drag window is shown correctly. | 353 // Verifies the drag window is shown correctly. |
364 TEST_P(DragWindowResizerTest, DragWindowController) { | 354 TEST_F(DragWindowResizerTest, DragWindowController) { |
365 UpdateDisplay("800x600,800x600"); | 355 UpdateDisplay("800x600,800x600"); |
366 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 356 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
367 ASSERT_EQ(2U, root_windows.size()); | 357 ASSERT_EQ(2U, root_windows.size()); |
368 | 358 |
369 TestLayerDelegate delegate; | 359 TestLayerDelegate delegate; |
370 window_->layer()->set_delegate(&delegate); | 360 window_->layer()->set_delegate(&delegate); |
371 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), | 361 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), |
372 display::Screen::GetScreen()->GetPrimaryDisplay()); | 362 display::Screen::GetScreen()->GetPrimaryDisplay()); |
373 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | 363 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); |
374 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); | 364 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 ASSERT_TRUE(drag_resizer); | 434 ASSERT_TRUE(drag_resizer); |
445 EXPECT_FALSE(controller); | 435 EXPECT_FALSE(controller); |
446 | 436 |
447 resizer->Drag(CalculateDragPoint(*resizer, 0, 610), 0); | 437 resizer->Drag(CalculateDragPoint(*resizer, 0, 610), 0); |
448 resizer->RevertDrag(); | 438 resizer->RevertDrag(); |
449 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | 439 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); |
450 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); | 440 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); |
451 } | 441 } |
452 } | 442 } |
453 | 443 |
454 TEST_P(DragWindowResizerTest, DragWindowControllerAcrossThreeDisplays) { | 444 TEST_F(DragWindowResizerTest, DragWindowControllerAcrossThreeDisplays) { |
455 UpdateDisplay("400x600,400x600,800x600"); | 445 UpdateDisplay("400x600,400x600,800x600"); |
456 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 446 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
457 | 447 |
458 // Layout so that all three displays touch each other. | 448 // Layout so that all three displays touch each other. |
459 display::DisplayIdList list = display_manager()->GetCurrentDisplayIdList(); | 449 display::DisplayIdList list = display_manager()->GetCurrentDisplayIdList(); |
460 ASSERT_EQ(3u, list.size()); | 450 ASSERT_EQ(3u, list.size()); |
461 ASSERT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().id(), list[0]); | 451 ASSERT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().id(), list[0]); |
462 display::DisplayLayoutBuilder builder(list[0]); | 452 display::DisplayLayoutBuilder builder(list[0]); |
463 builder.AddDisplayPlacement(list[1], list[0], | 453 builder.AddDisplayPlacement(list[1], list[0], |
464 display::DisplayPlacement::RIGHT, 0); | 454 display::DisplayPlacement::RIGHT, 0); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 EXPECT_FLOAT_EQ(0.0f, window_->layer()->opacity()); | 534 EXPECT_FLOAT_EQ(0.0f, window_->layer()->opacity()); |
545 EXPECT_FLOAT_EQ(1.0f, drag_layer0->opacity()); | 535 EXPECT_FLOAT_EQ(1.0f, drag_layer0->opacity()); |
546 | 536 |
547 resizer->CompleteDrag(); | 537 resizer->CompleteDrag(); |
548 EXPECT_EQ(root_windows[2], window_->GetRootWindow()); | 538 EXPECT_EQ(root_windows[2], window_->GetRootWindow()); |
549 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); | 539 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); |
550 } | 540 } |
551 | 541 |
552 // Verifies if the resizer sets and resets | 542 // Verifies if the resizer sets and resets |
553 // MouseCursorEventFilter::mouse_warp_mode_ as expected. | 543 // MouseCursorEventFilter::mouse_warp_mode_ as expected. |
554 TEST_P(DragWindowResizerTest, WarpMousePointer) { | 544 TEST_F(DragWindowResizerTest, WarpMousePointer) { |
555 MouseCursorEventFilter* event_filter = | 545 MouseCursorEventFilter* event_filter = |
556 Shell::GetInstance()->mouse_cursor_filter(); | 546 Shell::GetInstance()->mouse_cursor_filter(); |
557 ASSERT_TRUE(event_filter); | 547 ASSERT_TRUE(event_filter); |
558 window_->SetBounds(gfx::Rect(0, 0, 50, 60)); | 548 window_->SetBounds(gfx::Rect(0, 0, 50, 60)); |
559 | 549 |
560 EXPECT_TRUE(event_filter->mouse_warp_enabled_); | 550 EXPECT_TRUE(event_filter->mouse_warp_enabled_); |
561 { | 551 { |
562 std::unique_ptr<WindowResizer> resizer( | 552 std::unique_ptr<WindowResizer> resizer( |
563 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION)); | 553 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION)); |
564 // While dragging a window, warp should be allowed. | 554 // While dragging a window, warp should be allowed. |
(...skipping 23 matching lines...) Expand all Loading... |
588 std::unique_ptr<WindowResizer> resizer( | 578 std::unique_ptr<WindowResizer> resizer( |
589 CreateDragWindowResizer(window_.get(), gfx::Point(), HTRIGHT)); | 579 CreateDragWindowResizer(window_.get(), gfx::Point(), HTRIGHT)); |
590 EXPECT_FALSE(event_filter->mouse_warp_enabled_); | 580 EXPECT_FALSE(event_filter->mouse_warp_enabled_); |
591 resizer->RevertDrag(); | 581 resizer->RevertDrag(); |
592 } | 582 } |
593 EXPECT_TRUE(event_filter->mouse_warp_enabled_); | 583 EXPECT_TRUE(event_filter->mouse_warp_enabled_); |
594 } | 584 } |
595 | 585 |
596 // Verifies cursor's device scale factor is updated whe a window is moved across | 586 // Verifies cursor's device scale factor is updated whe a window is moved across |
597 // root windows with different device scale factors (http://crbug.com/154183). | 587 // root windows with different device scale factors (http://crbug.com/154183). |
598 TEST_P(DragWindowResizerTest, CursorDeviceScaleFactor) { | 588 TEST_F(DragWindowResizerTest, CursorDeviceScaleFactor) { |
599 // The secondary display is logically on the right, but on the system (e.g. X) | 589 // The secondary display is logically on the right, but on the system (e.g. X) |
600 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. | 590 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. |
601 UpdateDisplay("400x400,800x800*2"); | 591 UpdateDisplay("400x400,800x800*2"); |
602 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 592 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
603 ASSERT_EQ(2U, root_windows.size()); | 593 ASSERT_EQ(2U, root_windows.size()); |
604 | 594 |
605 test::CursorManagerTestApi cursor_test_api( | 595 test::CursorManagerTestApi cursor_test_api( |
606 Shell::GetInstance()->cursor_manager()); | 596 Shell::GetInstance()->cursor_manager()); |
607 // Move window from the root window with 1.0 device scale factor to the root | 597 // Move window from the root window with 1.0 device scale factor to the root |
608 // window with 2.0 device scale factor. | 598 // window with 2.0 device scale factor. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 ASSERT_TRUE(resizer.get()); | 632 ASSERT_TRUE(resizer.get()); |
643 resizer->Drag(CalculateDragPoint(*resizer, -200, 200), 0); | 633 resizer->Drag(CalculateDragPoint(*resizer, -200, 200), 0); |
644 TestIfMouseWarpsAt(gfx::Point(400, 200)); | 634 TestIfMouseWarpsAt(gfx::Point(400, 200)); |
645 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); | 635 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); |
646 resizer->CompleteDrag(); | 636 resizer->CompleteDrag(); |
647 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); | 637 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); |
648 } | 638 } |
649 } | 639 } |
650 | 640 |
651 // Verifies several kinds of windows can be moved across displays. | 641 // Verifies several kinds of windows can be moved across displays. |
652 TEST_P(DragWindowResizerTest, MoveWindowAcrossDisplays) { | 642 TEST_F(DragWindowResizerTest, MoveWindowAcrossDisplays) { |
653 // The secondary display is logically on the right, but on the system (e.g. X) | 643 // The secondary display is logically on the right, but on the system (e.g. X) |
654 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. | 644 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. |
655 UpdateDisplay("400x400,400x400"); | 645 UpdateDisplay("400x400,400x400"); |
656 | 646 |
657 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 647 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
658 ASSERT_EQ(2U, root_windows.size()); | 648 ASSERT_EQ(2U, root_windows.size()); |
659 | 649 |
660 // Normal window can be moved across display. | 650 // Normal window can be moved across display. |
661 { | 651 { |
662 aura::Window* window = window_.get(); | 652 aura::Window* window = window_.get(); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 ASSERT_TRUE(resizer.get()); | 745 ASSERT_TRUE(resizer.get()); |
756 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); | 746 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); |
757 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200))); | 747 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200))); |
758 EXPECT_EQ("401,200", | 748 EXPECT_EQ("401,200", |
759 aura::Env::GetInstance()->last_mouse_location().ToString()); | 749 aura::Env::GetInstance()->last_mouse_location().ToString()); |
760 resizer->CompleteDrag(); | 750 resizer->CompleteDrag(); |
761 } | 751 } |
762 } | 752 } |
763 | 753 |
764 } // namespace ash | 754 } // namespace ash |
OLD | NEW |