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

Side by Side Diff: ash/wm/drag_window_resizer_unittest.cc

Issue 2067223003: Parameterize Ash unittests to pass with material design enabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: for landing Created 4 years, 6 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 | « ash/test/ash_md_test_base.cc ('k') | ash/wm/window_positioner_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/aura/wm_window_aura.h" 7 #include "ash/aura/wm_window_aura.h"
8 #include "ash/common/material_design/material_design_controller.h"
8 #include "ash/common/shell_window_ids.h" 9 #include "ash/common/shell_window_ids.h"
9 #include "ash/common/wm/window_positioning_utils.h" 10 #include "ash/common/wm/window_positioning_utils.h"
10 #include "ash/display/display_manager.h" 11 #include "ash/display/display_manager.h"
11 #include "ash/display/mouse_cursor_event_filter.h" 12 #include "ash/display/mouse_cursor_event_filter.h"
12 #include "ash/root_window_controller.h" 13 #include "ash/root_window_controller.h"
13 #include "ash/shelf/shelf_layout_manager.h" 14 #include "ash/shelf/shelf_layout_manager.h"
14 #include "ash/shell.h" 15 #include "ash/shell.h"
15 #include "ash/test/ash_test_base.h" 16 #include "ash/test/ash_md_test_base.h"
16 #include "ash/test/cursor_manager_test_api.h" 17 #include "ash/test/cursor_manager_test_api.h"
17 #include "ash/test/display_manager_test_api.h" 18 #include "ash/test/display_manager_test_api.h"
18 #include "ash/wm/drag_window_controller.h" 19 #include "ash/wm/drag_window_controller.h"
19 #include "ash/wm/window_util.h" 20 #include "ash/wm/window_util.h"
20 #include "base/strings/string_number_conversions.h" 21 #include "base/strings/string_number_conversions.h"
21 #include "base/strings/stringprintf.h" 22 #include "base/strings/stringprintf.h"
22 #include "ui/aura/client/aura_constants.h" 23 #include "ui/aura/client/aura_constants.h"
23 #include "ui/aura/env.h" 24 #include "ui/aura/env.h"
24 #include "ui/aura/test/test_window_delegate.h" 25 #include "ui/aura/test/test_window_delegate.h"
25 #include "ui/base/hit_test.h" 26 #include "ui/base/hit_test.h"
(...skipping 30 matching lines...) Expand all
56 return base::Closure(); 57 return base::Closure();
57 } 58 }
58 59
59 int paint_count_ = 0; 60 int paint_count_ = 0;
60 61
61 DISALLOW_COPY_AND_ASSIGN(TestLayerDelegate); 62 DISALLOW_COPY_AND_ASSIGN(TestLayerDelegate);
62 }; 63 };
63 64
64 } // namespace 65 } // namespace
65 66
66 class DragWindowResizerTest : public test::AshTestBase { 67 class DragWindowResizerTest : public test::AshMDTestBase {
67 public: 68 public:
68 DragWindowResizerTest() : transient_child_(nullptr) {} 69 DragWindowResizerTest() : transient_child_(nullptr) {}
69 ~DragWindowResizerTest() override {} 70 ~DragWindowResizerTest() override {}
70 71
71 void SetUp() override { 72 void SetUp() override {
72 AshTestBase::SetUp(); 73 AshMDTestBase::SetUp();
74
73 UpdateDisplay(base::StringPrintf("800x%d", kRootHeight)); 75 UpdateDisplay(base::StringPrintf("800x%d", kRootHeight));
74 76
75 aura::Window* root = Shell::GetPrimaryRootWindow(); 77 aura::Window* root = Shell::GetPrimaryRootWindow();
76 gfx::Rect root_bounds(root->bounds()); 78 gfx::Rect root_bounds(root->bounds());
77 EXPECT_EQ(kRootHeight, root_bounds.height()); 79 EXPECT_EQ(kRootHeight, root_bounds.height());
78 EXPECT_EQ(800, root_bounds.width()); 80 EXPECT_EQ(800, root_bounds.width());
79 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); 81 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets());
80 window_.reset(new aura::Window(&delegate_)); 82 window_.reset(new aura::Window(&delegate_));
81 window_->SetType(ui::wm::WINDOW_TYPE_NORMAL); 83 window_->SetType(ui::wm::WINDOW_TYPE_NORMAL);
82 window_->Init(ui::LAYER_NOT_DRAWN); 84 window_->Init(ui::LAYER_NOT_DRAWN);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 panel_window_->Init(ui::LAYER_NOT_DRAWN); 118 panel_window_->Init(ui::LAYER_NOT_DRAWN);
117 ParentWindowInPrimaryRootWindow(panel_window_.get()); 119 ParentWindowInPrimaryRootWindow(panel_window_.get());
118 } 120 }
119 121
120 void TearDown() override { 122 void TearDown() override {
121 window_.reset(); 123 window_.reset();
122 always_on_top_window_.reset(); 124 always_on_top_window_.reset();
123 system_modal_window_.reset(); 125 system_modal_window_.reset();
124 transient_parent_.reset(); 126 transient_parent_.reset();
125 panel_window_.reset(); 127 panel_window_.reset();
126 AshTestBase::TearDown(); 128 AshMDTestBase::TearDown();
127 } 129 }
128 130
129 protected: 131 protected:
130 gfx::Point CalculateDragPoint(const WindowResizer& resizer, 132 gfx::Point CalculateDragPoint(const WindowResizer& resizer,
131 int delta_x, 133 int delta_x,
132 int delta_y) const { 134 int delta_y) const {
133 gfx::Point location = resizer.GetInitialLocation(); 135 gfx::Point location = resizer.GetInitialLocation();
134 location.set_x(location.x() + delta_x); 136 location.set_x(location.x() + delta_x);
135 location.set_y(location.y() + delta_y); 137 location.set_y(location.y() + delta_y);
136 return location; 138 return location;
(...skipping 29 matching lines...) Expand all
166 std::unique_ptr<aura::Window> always_on_top_window_; 168 std::unique_ptr<aura::Window> always_on_top_window_;
167 std::unique_ptr<aura::Window> system_modal_window_; 169 std::unique_ptr<aura::Window> system_modal_window_;
168 std::unique_ptr<aura::Window> panel_window_; 170 std::unique_ptr<aura::Window> panel_window_;
169 aura::Window* transient_child_; 171 aura::Window* transient_child_;
170 std::unique_ptr<aura::Window> transient_parent_; 172 std::unique_ptr<aura::Window> transient_parent_;
171 173
172 private: 174 private:
173 DISALLOW_COPY_AND_ASSIGN(DragWindowResizerTest); 175 DISALLOW_COPY_AND_ASSIGN(DragWindowResizerTest);
174 }; 176 };
175 177
178 INSTANTIATE_TEST_CASE_P(
179 /* prefix intentionally left blank due to only one parameterization */,
180 DragWindowResizerTest,
181 testing::Values(MaterialDesignController::NON_MATERIAL,
182 MaterialDesignController::MATERIAL_NORMAL,
183 MaterialDesignController::MATERIAL_EXPERIMENTAL));
184
176 // Verifies a window can be moved from the primary display to another. 185 // Verifies a window can be moved from the primary display to another.
177 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplays) { 186 TEST_P(DragWindowResizerTest, WindowDragWithMultiDisplays) {
178 if (!SupportsMultipleDisplays()) 187 if (!SupportsMultipleDisplays())
179 return; 188 return;
189 const int height_offset = GetMdMaximizedWindowHeightOffset();
180 190
181 // The secondary display is logically on the right, but on the system (e.g. X) 191 // The secondary display is logically on the right, but on the system (e.g. X)
182 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. 192 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc.
183 UpdateDisplay("800x600,400x300"); 193 UpdateDisplay("800x600,400x300");
184 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 194 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
185 ASSERT_EQ(2U, root_windows.size()); 195 ASSERT_EQ(2U, root_windows.size());
186 196
187 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 197 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
188 display::Screen::GetScreen()->GetPrimaryDisplay()); 198 display::Screen::GetScreen()->GetPrimaryDisplay());
189 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 199 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 { 260 {
251 // Grab the top-right edge of the window and move the pointer to (0, 10) 261 // Grab the top-right edge of the window and move the pointer to (0, 10)
252 // in the secondary root window's coordinates. 262 // in the secondary root window's coordinates.
253 std::unique_ptr<WindowResizer> resizer( 263 std::unique_ptr<WindowResizer> resizer(
254 CreateDragWindowResizer(window_.get(), gfx::Point(699, 0), HTCAPTION)); 264 CreateDragWindowResizer(window_.get(), gfx::Point(699, 0), HTCAPTION));
255 ASSERT_TRUE(resizer.get()); 265 ASSERT_TRUE(resizer.get());
256 resizer->Drag(CalculateDragPoint(*resizer, 101, 10), ui::EF_CONTROL_DOWN); 266 resizer->Drag(CalculateDragPoint(*resizer, 101, 10), ui::EF_CONTROL_DOWN);
257 resizer->CompleteDrag(); 267 resizer->CompleteDrag();
258 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 268 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
259 // Window size should be adjusted to fit to the work area 269 // Window size should be adjusted to fit to the work area
260 EXPECT_EQ("400x253", window_->bounds().size().ToString()); 270 EXPECT_EQ(gfx::Size(400, 253 + height_offset).ToString(),
271 window_->bounds().size().ToString());
261 gfx::Rect window_bounds_in_screen = window_->GetBoundsInScreen(); 272 gfx::Rect window_bounds_in_screen = window_->GetBoundsInScreen();
262 gfx::Rect intersect(window_->GetRootWindow()->GetBoundsInScreen()); 273 gfx::Rect intersect(window_->GetRootWindow()->GetBoundsInScreen());
263 intersect.Intersect(window_bounds_in_screen); 274 intersect.Intersect(window_bounds_in_screen);
264 275
265 EXPECT_LE(10, intersect.width()); 276 EXPECT_LE(10, intersect.width());
266 EXPECT_LE(10, intersect.height()); 277 EXPECT_LE(10, intersect.height());
267 EXPECT_TRUE(window_bounds_in_screen.Contains(gfx::Point(800, 10))); 278 EXPECT_TRUE(window_bounds_in_screen.Contains(gfx::Point(800, 10)));
268 } 279 }
269 280
270 // Dropping a window that is larger than the destination work area 281 // Dropping a window that is larger than the destination work area
271 // will shrink to fit to the work area. 282 // will shrink to fit to the work area.
272 window_->SetBoundsInScreen(gfx::Rect(0, 0, 700, 500), 283 window_->SetBoundsInScreen(gfx::Rect(0, 0, 700, 500),
273 display::Screen::GetScreen()->GetPrimaryDisplay()); 284 display::Screen::GetScreen()->GetPrimaryDisplay());
274 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 285 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
275 { 286 {
276 // Grab the top-left edge of the window and move the pointer to (150, 10) 287 // Grab the top-left edge of the window and move the pointer to (150, 10)
277 // in the secondary root window's coordinates. Make sure the window is 288 // in the secondary root window's coordinates. Make sure the window is
278 // shrink in such a way that it keeps the cursor within. 289 // shrink in such a way that it keeps the cursor within.
279 std::unique_ptr<WindowResizer> resizer( 290 std::unique_ptr<WindowResizer> resizer(
280 CreateDragWindowResizer(window_.get(), gfx::Point(0, 0), HTCAPTION)); 291 CreateDragWindowResizer(window_.get(), gfx::Point(0, 0), HTCAPTION));
281 ASSERT_TRUE(resizer.get()); 292 ASSERT_TRUE(resizer.get());
282 resizer->Drag(CalculateDragPoint(*resizer, 799, 10), ui::EF_CONTROL_DOWN); 293 resizer->Drag(CalculateDragPoint(*resizer, 799, 10), ui::EF_CONTROL_DOWN);
283 resizer->Drag(CalculateDragPoint(*resizer, 850, 10), ui::EF_CONTROL_DOWN); 294 resizer->Drag(CalculateDragPoint(*resizer, 850, 10), ui::EF_CONTROL_DOWN);
284 resizer->CompleteDrag(); 295 resizer->CompleteDrag();
285 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 296 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
286 // Window size should be adjusted to fit to the work area 297 // Window size should be adjusted to fit to the work area
287 EXPECT_EQ("400x253", window_->bounds().size().ToString()); 298 EXPECT_EQ(gfx::Size(400, 253 + height_offset).ToString(),
299 window_->bounds().size().ToString());
288 gfx::Rect window_bounds_in_screen = window_->GetBoundsInScreen(); 300 gfx::Rect window_bounds_in_screen = window_->GetBoundsInScreen();
289 gfx::Rect intersect(window_->GetRootWindow()->GetBoundsInScreen()); 301 gfx::Rect intersect(window_->GetRootWindow()->GetBoundsInScreen());
290 intersect.Intersect(window_bounds_in_screen); 302 intersect.Intersect(window_bounds_in_screen);
291 EXPECT_LE(10, intersect.width()); 303 EXPECT_LE(10, intersect.width());
292 EXPECT_LE(10, intersect.height()); 304 EXPECT_LE(10, intersect.height());
293 EXPECT_TRUE(window_bounds_in_screen.Contains(gfx::Point(850, 10))); 305 EXPECT_TRUE(window_bounds_in_screen.Contains(gfx::Point(850, 10)));
294 } 306 }
295 } 307 }
296 308
297 // Verifies that dragging the active window to another display makes the new 309 // Verifies that dragging the active window to another display makes the new
298 // root window the active root window. 310 // root window the active root window.
299 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplaysActiveRoot) { 311 TEST_P(DragWindowResizerTest, WindowDragWithMultiDisplaysActiveRoot) {
300 if (!SupportsMultipleDisplays()) 312 if (!SupportsMultipleDisplays())
301 return; 313 return;
302 314
303 // The secondary display is logically on the right, but on the system (e.g. X) 315 // The secondary display is logically on the right, but on the system (e.g. X)
304 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. 316 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc.
305 UpdateDisplay("800x600,800x600"); 317 UpdateDisplay("800x600,800x600");
306 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 318 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
307 ASSERT_EQ(2U, root_windows.size()); 319 ASSERT_EQ(2U, root_windows.size());
308 320
309 aura::test::TestWindowDelegate delegate; 321 aura::test::TestWindowDelegate delegate;
(...skipping 18 matching lines...) Expand all
328 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); 340 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0);
329 resizer->CompleteDrag(); 341 resizer->CompleteDrag();
330 // The whole window is on the secondary display now. The parent should be 342 // The whole window is on the secondary display now. The parent should be
331 // changed. 343 // changed.
332 EXPECT_EQ(root_windows[1], window->GetRootWindow()); 344 EXPECT_EQ(root_windows[1], window->GetRootWindow());
333 EXPECT_EQ(root_windows[1], ash::Shell::GetTargetRootWindow()); 345 EXPECT_EQ(root_windows[1], ash::Shell::GetTargetRootWindow());
334 } 346 }
335 } 347 }
336 348
337 // Verifies a window can be moved from the secondary display to primary. 349 // Verifies a window can be moved from the secondary display to primary.
338 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplaysRightToLeft) { 350 TEST_P(DragWindowResizerTest, WindowDragWithMultiDisplaysRightToLeft) {
339 if (!SupportsMultipleDisplays()) 351 if (!SupportsMultipleDisplays())
340 return; 352 return;
341 353
342 UpdateDisplay("800x600,800x600"); 354 UpdateDisplay("800x600,800x600");
343 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 355 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
344 ASSERT_EQ(2U, root_windows.size()); 356 ASSERT_EQ(2U, root_windows.size());
345 357
346 window_->SetBoundsInScreen( 358 window_->SetBoundsInScreen(
347 gfx::Rect(800, 00, 50, 60), 359 gfx::Rect(800, 00, 50, 60),
348 display::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[1])); 360 display::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[1]));
349 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 361 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
350 { 362 {
351 // Grab (0, 0) of the window. 363 // Grab (0, 0) of the window.
352 std::unique_ptr<WindowResizer> resizer( 364 std::unique_ptr<WindowResizer> resizer(
353 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION)); 365 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION));
354 ASSERT_TRUE(resizer.get()); 366 ASSERT_TRUE(resizer.get());
355 // Move the mouse near the right edge, (798, 0), of the primary display. 367 // Move the mouse near the right edge, (798, 0), of the primary display.
356 resizer->Drag(CalculateDragPoint(*resizer, -2, 0), ui::EF_CONTROL_DOWN); 368 resizer->Drag(CalculateDragPoint(*resizer, -2, 0), ui::EF_CONTROL_DOWN);
357 resizer->CompleteDrag(); 369 resizer->CompleteDrag();
358 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 370 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
359 // Window origin should be adjusted for minimum visibility (25px). 371 // Window origin should be adjusted for minimum visibility (25px).
360 EXPECT_EQ("775,0 50x60", window_->bounds().ToString()); 372 EXPECT_EQ("775,0 50x60", window_->bounds().ToString());
361 } 373 }
362 } 374 }
363 375
364 // Verifies the drag window is shown correctly. 376 // Verifies the drag window is shown correctly.
365 TEST_F(DragWindowResizerTest, DragWindowController) { 377 TEST_P(DragWindowResizerTest, DragWindowController) {
366 if (!SupportsMultipleDisplays()) 378 if (!SupportsMultipleDisplays())
367 return; 379 return;
368 380
369 UpdateDisplay("800x600,800x600"); 381 UpdateDisplay("800x600,800x600");
370 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 382 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
371 ASSERT_EQ(2U, root_windows.size()); 383 ASSERT_EQ(2U, root_windows.size());
372 384
373 TestLayerDelegate delegate; 385 TestLayerDelegate delegate;
374 window_->layer()->set_delegate(&delegate); 386 window_->layer()->set_delegate(&delegate);
375 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 387 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 ASSERT_TRUE(drag_resizer); 460 ASSERT_TRUE(drag_resizer);
449 EXPECT_FALSE(controller); 461 EXPECT_FALSE(controller);
450 462
451 resizer->Drag(CalculateDragPoint(*resizer, 0, 610), 0); 463 resizer->Drag(CalculateDragPoint(*resizer, 0, 610), 0);
452 resizer->RevertDrag(); 464 resizer->RevertDrag();
453 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 465 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
454 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 466 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
455 } 467 }
456 } 468 }
457 469
458 TEST_F(DragWindowResizerTest, DragWindowControllerAcrossThreeDisplays) { 470 TEST_P(DragWindowResizerTest, DragWindowControllerAcrossThreeDisplays) {
459 if (!SupportsMultipleDisplays()) 471 if (!SupportsMultipleDisplays())
460 return; 472 return;
461 473
462 UpdateDisplay("400x600,400x600,800x600"); 474 UpdateDisplay("400x600,400x600,800x600");
463 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 475 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
464 476
465 // Layout so that all three displays touch each other. 477 // Layout so that all three displays touch each other.
466 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 478 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
467 display::DisplayIdList list = display_manager->GetCurrentDisplayIdList(); 479 display::DisplayIdList list = display_manager->GetCurrentDisplayIdList();
468 ASSERT_EQ(3u, list.size()); 480 ASSERT_EQ(3u, list.size());
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 EXPECT_FLOAT_EQ(0.0f, window_->layer()->opacity()); 564 EXPECT_FLOAT_EQ(0.0f, window_->layer()->opacity());
553 EXPECT_FLOAT_EQ(1.0f, drag_layer0->opacity()); 565 EXPECT_FLOAT_EQ(1.0f, drag_layer0->opacity());
554 566
555 resizer->CompleteDrag(); 567 resizer->CompleteDrag();
556 EXPECT_EQ(root_windows[2], window_->GetRootWindow()); 568 EXPECT_EQ(root_windows[2], window_->GetRootWindow());
557 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 569 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
558 } 570 }
559 571
560 // Verifies if the resizer sets and resets 572 // Verifies if the resizer sets and resets
561 // MouseCursorEventFilter::mouse_warp_mode_ as expected. 573 // MouseCursorEventFilter::mouse_warp_mode_ as expected.
562 TEST_F(DragWindowResizerTest, WarpMousePointer) { 574 TEST_P(DragWindowResizerTest, WarpMousePointer) {
563 MouseCursorEventFilter* event_filter = 575 MouseCursorEventFilter* event_filter =
564 Shell::GetInstance()->mouse_cursor_filter(); 576 Shell::GetInstance()->mouse_cursor_filter();
565 ASSERT_TRUE(event_filter); 577 ASSERT_TRUE(event_filter);
566 window_->SetBounds(gfx::Rect(0, 0, 50, 60)); 578 window_->SetBounds(gfx::Rect(0, 0, 50, 60));
567 579
568 EXPECT_TRUE(event_filter->mouse_warp_enabled_); 580 EXPECT_TRUE(event_filter->mouse_warp_enabled_);
569 { 581 {
570 std::unique_ptr<WindowResizer> resizer( 582 std::unique_ptr<WindowResizer> resizer(
571 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION)); 583 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION));
572 // While dragging a window, warp should be allowed. 584 // While dragging a window, warp should be allowed.
(...skipping 23 matching lines...) Expand all
596 std::unique_ptr<WindowResizer> resizer( 608 std::unique_ptr<WindowResizer> resizer(
597 CreateDragWindowResizer(window_.get(), gfx::Point(), HTRIGHT)); 609 CreateDragWindowResizer(window_.get(), gfx::Point(), HTRIGHT));
598 EXPECT_FALSE(event_filter->mouse_warp_enabled_); 610 EXPECT_FALSE(event_filter->mouse_warp_enabled_);
599 resizer->RevertDrag(); 611 resizer->RevertDrag();
600 } 612 }
601 EXPECT_TRUE(event_filter->mouse_warp_enabled_); 613 EXPECT_TRUE(event_filter->mouse_warp_enabled_);
602 } 614 }
603 615
604 // Verifies cursor's device scale factor is updated whe a window is moved across 616 // Verifies cursor's device scale factor is updated whe a window is moved across
605 // root windows with different device scale factors (http://crbug.com/154183). 617 // root windows with different device scale factors (http://crbug.com/154183).
606 TEST_F(DragWindowResizerTest, CursorDeviceScaleFactor) { 618 TEST_P(DragWindowResizerTest, CursorDeviceScaleFactor) {
607 if (!SupportsMultipleDisplays()) 619 if (!SupportsMultipleDisplays())
608 return; 620 return;
609 621
610 // The secondary display is logically on the right, but on the system (e.g. X) 622 // The secondary display is logically on the right, but on the system (e.g. X)
611 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. 623 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc.
612 UpdateDisplay("400x400,800x800*2"); 624 UpdateDisplay("400x400,800x800*2");
613 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 625 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
614 ASSERT_EQ(2U, root_windows.size()); 626 ASSERT_EQ(2U, root_windows.size());
615 627
616 test::CursorManagerTestApi cursor_test_api( 628 test::CursorManagerTestApi cursor_test_api(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 ASSERT_TRUE(resizer.get()); 665 ASSERT_TRUE(resizer.get());
654 resizer->Drag(CalculateDragPoint(*resizer, -200, 200), 0); 666 resizer->Drag(CalculateDragPoint(*resizer, -200, 200), 0);
655 TestIfMouseWarpsAt(gfx::Point(400, 200)); 667 TestIfMouseWarpsAt(gfx::Point(400, 200));
656 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); 668 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor());
657 resizer->CompleteDrag(); 669 resizer->CompleteDrag();
658 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); 670 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor());
659 } 671 }
660 } 672 }
661 673
662 // Verifies several kinds of windows can be moved across displays. 674 // Verifies several kinds of windows can be moved across displays.
663 TEST_F(DragWindowResizerTest, MoveWindowAcrossDisplays) { 675 TEST_P(DragWindowResizerTest, MoveWindowAcrossDisplays) {
664 if (!SupportsMultipleDisplays()) 676 if (!SupportsMultipleDisplays())
665 return; 677 return;
666 678
667 // The secondary display is logically on the right, but on the system (e.g. X) 679 // The secondary display is logically on the right, but on the system (e.g. X)
668 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. 680 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc.
669 UpdateDisplay("400x400,400x400"); 681 UpdateDisplay("400x400,400x400");
670 682
671 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 683 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
672 ASSERT_EQ(2U, root_windows.size()); 684 ASSERT_EQ(2U, root_windows.size());
673 685
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 ASSERT_TRUE(resizer.get()); 781 ASSERT_TRUE(resizer.get());
770 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 782 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
771 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200))); 783 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200)));
772 EXPECT_EQ("401,200", 784 EXPECT_EQ("401,200",
773 aura::Env::GetInstance()->last_mouse_location().ToString()); 785 aura::Env::GetInstance()->last_mouse_location().ToString());
774 resizer->CompleteDrag(); 786 resizer->CompleteDrag();
775 } 787 }
776 } 788 }
777 789
778 } // namespace ash 790 } // namespace ash
OLDNEW
« no previous file with comments | « ash/test/ash_md_test_base.cc ('k') | ash/wm/window_positioner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698