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

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 further feedback 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
« ash/test/ash_md_test_base.cc ('K') | « ash/test/ash_md_test_base.cc ('k') | no next file » | 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_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"
19 #include "ash/test/material_design_controller_test_api.h"
18 #include "ash/wm/drag_window_controller.h" 20 #include "ash/wm/drag_window_controller.h"
19 #include "ash/wm/window_util.h" 21 #include "ash/wm/window_util.h"
20 #include "base/strings/string_number_conversions.h" 22 #include "base/strings/string_number_conversions.h"
21 #include "base/strings/stringprintf.h" 23 #include "base/strings/stringprintf.h"
22 #include "ui/aura/client/aura_constants.h" 24 #include "ui/aura/client/aura_constants.h"
23 #include "ui/aura/env.h" 25 #include "ui/aura/env.h"
24 #include "ui/aura/test/test_window_delegate.h" 26 #include "ui/aura/test/test_window_delegate.h"
25 #include "ui/base/hit_test.h" 27 #include "ui/base/hit_test.h"
26 #include "ui/base/ui_base_types.h" 28 #include "ui/base/ui_base_types.h"
27 #include "ui/compositor/layer_delegate.h" 29 #include "ui/compositor/layer_delegate.h"
(...skipping 28 matching lines...) Expand all
56 return base::Closure(); 58 return base::Closure();
57 } 59 }
58 60
59 int paint_count_ = 0; 61 int paint_count_ = 0;
60 62
61 DISALLOW_COPY_AND_ASSIGN(TestLayerDelegate); 63 DISALLOW_COPY_AND_ASSIGN(TestLayerDelegate);
62 }; 64 };
63 65
64 } // namespace 66 } // namespace
65 67
66 class DragWindowResizerTest : public test::AshTestBase { 68 class DragWindowResizerTest
69 : public test::AshTestBase,
70 public testing::WithParamInterface<ash::MaterialDesignController::Mode> {
67 public: 71 public:
68 DragWindowResizerTest() : transient_child_(nullptr) {} 72 DragWindowResizerTest()
73 : transient_child_(nullptr),
74 md_maximized_window_height_offset_(0) {
75 }
69 ~DragWindowResizerTest() override {} 76 ~DragWindowResizerTest() override {}
70 77
71 void SetUp() override { 78 void SetUp() override {
72 AshTestBase::SetUp(); 79 AshTestBase::SetUp();
80
81 material_design_state_.reset(
82 new test::MaterialDesignControllerTestAPI(GetParam()));
83 md_maximized_window_height_offset_ =
84 ash::MaterialDesignController::IsMaterial() ? -1 : 0;
85
73 UpdateDisplay(base::StringPrintf("800x%d", kRootHeight)); 86 UpdateDisplay(base::StringPrintf("800x%d", kRootHeight));
74 87
75 aura::Window* root = Shell::GetPrimaryRootWindow(); 88 aura::Window* root = Shell::GetPrimaryRootWindow();
76 gfx::Rect root_bounds(root->bounds()); 89 gfx::Rect root_bounds(root->bounds());
77 EXPECT_EQ(kRootHeight, root_bounds.height()); 90 EXPECT_EQ(kRootHeight, root_bounds.height());
78 EXPECT_EQ(800, root_bounds.width()); 91 EXPECT_EQ(800, root_bounds.width());
79 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); 92 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets());
80 window_.reset(new aura::Window(&delegate_)); 93 window_.reset(new aura::Window(&delegate_));
81 window_->SetType(ui::wm::WINDOW_TYPE_NORMAL); 94 window_->SetType(ui::wm::WINDOW_TYPE_NORMAL);
82 window_->Init(ui::LAYER_NOT_DRAWN); 95 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); 129 panel_window_->Init(ui::LAYER_NOT_DRAWN);
117 ParentWindowInPrimaryRootWindow(panel_window_.get()); 130 ParentWindowInPrimaryRootWindow(panel_window_.get());
118 } 131 }
119 132
120 void TearDown() override { 133 void TearDown() override {
121 window_.reset(); 134 window_.reset();
122 always_on_top_window_.reset(); 135 always_on_top_window_.reset();
123 system_modal_window_.reset(); 136 system_modal_window_.reset();
124 transient_parent_.reset(); 137 transient_parent_.reset();
125 panel_window_.reset(); 138 panel_window_.reset();
139 material_design_state_.reset();
126 AshTestBase::TearDown(); 140 AshTestBase::TearDown();
127 } 141 }
128 142
143 int GetMdMaximizedWindowHeightOffset() {
144 return md_maximized_window_height_offset_;
145 }
146
129 protected: 147 protected:
130 gfx::Point CalculateDragPoint(const WindowResizer& resizer, 148 gfx::Point CalculateDragPoint(const WindowResizer& resizer,
131 int delta_x, 149 int delta_x,
132 int delta_y) const { 150 int delta_y) const {
133 gfx::Point location = resizer.GetInitialLocation(); 151 gfx::Point location = resizer.GetInitialLocation();
134 location.set_x(location.x() + delta_x); 152 location.set_x(location.x() + delta_x);
135 location.set_y(location.y() + delta_y); 153 location.set_y(location.y() + delta_y);
136 return location; 154 return location;
137 } 155 }
138 156
(...skipping 24 matching lines...) Expand all
163 aura::test::TestWindowDelegate delegate6_; 181 aura::test::TestWindowDelegate delegate6_;
164 182
165 std::unique_ptr<aura::Window> window_; 183 std::unique_ptr<aura::Window> window_;
166 std::unique_ptr<aura::Window> always_on_top_window_; 184 std::unique_ptr<aura::Window> always_on_top_window_;
167 std::unique_ptr<aura::Window> system_modal_window_; 185 std::unique_ptr<aura::Window> system_modal_window_;
168 std::unique_ptr<aura::Window> panel_window_; 186 std::unique_ptr<aura::Window> panel_window_;
169 aura::Window* transient_child_; 187 aura::Window* transient_child_;
170 std::unique_ptr<aura::Window> transient_parent_; 188 std::unique_ptr<aura::Window> transient_parent_;
171 189
172 private: 190 private:
191 std::unique_ptr<test::MaterialDesignControllerTestAPI>
192 material_design_state_;
193
194 // The material design shelf is taller (by 1px) so use this offset to
195 // adjust the expected height of a maximized window.
196 int md_maximized_window_height_offset_;
197
173 DISALLOW_COPY_AND_ASSIGN(DragWindowResizerTest); 198 DISALLOW_COPY_AND_ASSIGN(DragWindowResizerTest);
174 }; 199 };
175 200
201 // Note: First argument is optional and intentionally left blank.
202 // (it's a prefix for the generated test cases)
203 INSTANTIATE_TEST_CASE_P(
204 ,
205 DragWindowResizerTest,
206 testing::Values(ash::MaterialDesignController::NON_MATERIAL,
207 ash::MaterialDesignController::MATERIAL_NORMAL,
208 ash::MaterialDesignController::MATERIAL_EXPERIMENTAL));
209
176 // Verifies a window can be moved from the primary display to another. 210 // Verifies a window can be moved from the primary display to another.
177 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplays) { 211 TEST_P(DragWindowResizerTest, WindowDragWithMultiDisplays) {
178 if (!SupportsMultipleDisplays()) 212 if (!SupportsMultipleDisplays())
179 return; 213 return;
214 const int height_offset = GetMdMaximizedWindowHeightOffset();
180 215
181 // The secondary display is logically on the right, but on the system (e.g. X) 216 // 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. 217 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc.
183 UpdateDisplay("800x600,400x300"); 218 UpdateDisplay("800x600,400x300");
184 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 219 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
185 ASSERT_EQ(2U, root_windows.size()); 220 ASSERT_EQ(2U, root_windows.size());
186 221
187 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 222 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
188 display::Screen::GetScreen()->GetPrimaryDisplay()); 223 display::Screen::GetScreen()->GetPrimaryDisplay());
189 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 224 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 { 285 {
251 // Grab the top-right edge of the window and move the pointer to (0, 10) 286 // Grab the top-right edge of the window and move the pointer to (0, 10)
252 // in the secondary root window's coordinates. 287 // in the secondary root window's coordinates.
253 std::unique_ptr<WindowResizer> resizer( 288 std::unique_ptr<WindowResizer> resizer(
254 CreateDragWindowResizer(window_.get(), gfx::Point(699, 0), HTCAPTION)); 289 CreateDragWindowResizer(window_.get(), gfx::Point(699, 0), HTCAPTION));
255 ASSERT_TRUE(resizer.get()); 290 ASSERT_TRUE(resizer.get());
256 resizer->Drag(CalculateDragPoint(*resizer, 101, 10), ui::EF_CONTROL_DOWN); 291 resizer->Drag(CalculateDragPoint(*resizer, 101, 10), ui::EF_CONTROL_DOWN);
257 resizer->CompleteDrag(); 292 resizer->CompleteDrag();
258 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 293 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
259 // Window size should be adjusted to fit to the work area 294 // Window size should be adjusted to fit to the work area
260 EXPECT_EQ("400x253", window_->bounds().size().ToString()); 295 EXPECT_EQ(gfx::Size(400, 253 + height_offset).ToString(),
296 window_->bounds().size().ToString());
261 gfx::Rect window_bounds_in_screen = window_->GetBoundsInScreen(); 297 gfx::Rect window_bounds_in_screen = window_->GetBoundsInScreen();
262 gfx::Rect intersect(window_->GetRootWindow()->GetBoundsInScreen()); 298 gfx::Rect intersect(window_->GetRootWindow()->GetBoundsInScreen());
263 intersect.Intersect(window_bounds_in_screen); 299 intersect.Intersect(window_bounds_in_screen);
264 300
265 EXPECT_LE(10, intersect.width()); 301 EXPECT_LE(10, intersect.width());
266 EXPECT_LE(10, intersect.height()); 302 EXPECT_LE(10, intersect.height());
267 EXPECT_TRUE(window_bounds_in_screen.Contains(gfx::Point(800, 10))); 303 EXPECT_TRUE(window_bounds_in_screen.Contains(gfx::Point(800, 10)));
268 } 304 }
269 305
270 // Dropping a window that is larger than the destination work area 306 // Dropping a window that is larger than the destination work area
271 // will shrink to fit to the work area. 307 // will shrink to fit to the work area.
272 window_->SetBoundsInScreen(gfx::Rect(0, 0, 700, 500), 308 window_->SetBoundsInScreen(gfx::Rect(0, 0, 700, 500),
273 display::Screen::GetScreen()->GetPrimaryDisplay()); 309 display::Screen::GetScreen()->GetPrimaryDisplay());
274 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 310 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
275 { 311 {
276 // Grab the top-left edge of the window and move the pointer to (150, 10) 312 // 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 313 // in the secondary root window's coordinates. Make sure the window is
278 // shrink in such a way that it keeps the cursor within. 314 // shrink in such a way that it keeps the cursor within.
279 std::unique_ptr<WindowResizer> resizer( 315 std::unique_ptr<WindowResizer> resizer(
280 CreateDragWindowResizer(window_.get(), gfx::Point(0, 0), HTCAPTION)); 316 CreateDragWindowResizer(window_.get(), gfx::Point(0, 0), HTCAPTION));
281 ASSERT_TRUE(resizer.get()); 317 ASSERT_TRUE(resizer.get());
282 resizer->Drag(CalculateDragPoint(*resizer, 799, 10), ui::EF_CONTROL_DOWN); 318 resizer->Drag(CalculateDragPoint(*resizer, 799, 10), ui::EF_CONTROL_DOWN);
283 resizer->Drag(CalculateDragPoint(*resizer, 850, 10), ui::EF_CONTROL_DOWN); 319 resizer->Drag(CalculateDragPoint(*resizer, 850, 10), ui::EF_CONTROL_DOWN);
284 resizer->CompleteDrag(); 320 resizer->CompleteDrag();
285 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 321 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
286 // Window size should be adjusted to fit to the work area 322 // Window size should be adjusted to fit to the work area
287 EXPECT_EQ("400x253", window_->bounds().size().ToString()); 323 EXPECT_EQ(gfx::Size(400, 253 + height_offset).ToString(),
324 window_->bounds().size().ToString());
288 gfx::Rect window_bounds_in_screen = window_->GetBoundsInScreen(); 325 gfx::Rect window_bounds_in_screen = window_->GetBoundsInScreen();
289 gfx::Rect intersect(window_->GetRootWindow()->GetBoundsInScreen()); 326 gfx::Rect intersect(window_->GetRootWindow()->GetBoundsInScreen());
290 intersect.Intersect(window_bounds_in_screen); 327 intersect.Intersect(window_bounds_in_screen);
291 EXPECT_LE(10, intersect.width()); 328 EXPECT_LE(10, intersect.width());
292 EXPECT_LE(10, intersect.height()); 329 EXPECT_LE(10, intersect.height());
293 EXPECT_TRUE(window_bounds_in_screen.Contains(gfx::Point(850, 10))); 330 EXPECT_TRUE(window_bounds_in_screen.Contains(gfx::Point(850, 10)));
294 } 331 }
295 } 332 }
296 333
297 // Verifies that dragging the active window to another display makes the new 334 // Verifies that dragging the active window to another display makes the new
298 // root window the active root window. 335 // root window the active root window.
299 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplaysActiveRoot) { 336 TEST_P(DragWindowResizerTest, WindowDragWithMultiDisplaysActiveRoot) {
300 if (!SupportsMultipleDisplays()) 337 if (!SupportsMultipleDisplays())
301 return; 338 return;
302 339
303 // The secondary display is logically on the right, but on the system (e.g. X) 340 // 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. 341 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc.
305 UpdateDisplay("800x600,800x600"); 342 UpdateDisplay("800x600,800x600");
306 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 343 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
307 ASSERT_EQ(2U, root_windows.size()); 344 ASSERT_EQ(2U, root_windows.size());
308 345
309 aura::test::TestWindowDelegate delegate; 346 aura::test::TestWindowDelegate delegate;
(...skipping 18 matching lines...) Expand all
328 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); 365 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0);
329 resizer->CompleteDrag(); 366 resizer->CompleteDrag();
330 // The whole window is on the secondary display now. The parent should be 367 // The whole window is on the secondary display now. The parent should be
331 // changed. 368 // changed.
332 EXPECT_EQ(root_windows[1], window->GetRootWindow()); 369 EXPECT_EQ(root_windows[1], window->GetRootWindow());
333 EXPECT_EQ(root_windows[1], ash::Shell::GetTargetRootWindow()); 370 EXPECT_EQ(root_windows[1], ash::Shell::GetTargetRootWindow());
334 } 371 }
335 } 372 }
336 373
337 // Verifies a window can be moved from the secondary display to primary. 374 // Verifies a window can be moved from the secondary display to primary.
338 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplaysRightToLeft) { 375 TEST_P(DragWindowResizerTest, WindowDragWithMultiDisplaysRightToLeft) {
339 if (!SupportsMultipleDisplays()) 376 if (!SupportsMultipleDisplays())
340 return; 377 return;
341 378
342 UpdateDisplay("800x600,800x600"); 379 UpdateDisplay("800x600,800x600");
343 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 380 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
344 ASSERT_EQ(2U, root_windows.size()); 381 ASSERT_EQ(2U, root_windows.size());
345 382
346 window_->SetBoundsInScreen( 383 window_->SetBoundsInScreen(
347 gfx::Rect(800, 00, 50, 60), 384 gfx::Rect(800, 00, 50, 60),
348 display::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[1])); 385 display::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[1]));
349 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 386 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
350 { 387 {
351 // Grab (0, 0) of the window. 388 // Grab (0, 0) of the window.
352 std::unique_ptr<WindowResizer> resizer( 389 std::unique_ptr<WindowResizer> resizer(
353 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION)); 390 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION));
354 ASSERT_TRUE(resizer.get()); 391 ASSERT_TRUE(resizer.get());
355 // Move the mouse near the right edge, (798, 0), of the primary display. 392 // Move the mouse near the right edge, (798, 0), of the primary display.
356 resizer->Drag(CalculateDragPoint(*resizer, -2, 0), ui::EF_CONTROL_DOWN); 393 resizer->Drag(CalculateDragPoint(*resizer, -2, 0), ui::EF_CONTROL_DOWN);
357 resizer->CompleteDrag(); 394 resizer->CompleteDrag();
358 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 395 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
359 // Window origin should be adjusted for minimum visibility (25px). 396 // Window origin should be adjusted for minimum visibility (25px).
360 EXPECT_EQ("775,0 50x60", window_->bounds().ToString()); 397 EXPECT_EQ("775,0 50x60", window_->bounds().ToString());
361 } 398 }
362 } 399 }
363 400
364 // Verifies the drag window is shown correctly. 401 // Verifies the drag window is shown correctly.
365 TEST_F(DragWindowResizerTest, DragWindowController) { 402 TEST_P(DragWindowResizerTest, DragWindowController) {
366 if (!SupportsMultipleDisplays()) 403 if (!SupportsMultipleDisplays())
367 return; 404 return;
368 405
369 UpdateDisplay("800x600,800x600"); 406 UpdateDisplay("800x600,800x600");
370 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 407 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
371 ASSERT_EQ(2U, root_windows.size()); 408 ASSERT_EQ(2U, root_windows.size());
372 409
373 TestLayerDelegate delegate; 410 TestLayerDelegate delegate;
374 window_->layer()->set_delegate(&delegate); 411 window_->layer()->set_delegate(&delegate);
375 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 412 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); 485 ASSERT_TRUE(drag_resizer);
449 EXPECT_FALSE(controller); 486 EXPECT_FALSE(controller);
450 487
451 resizer->Drag(CalculateDragPoint(*resizer, 0, 610), 0); 488 resizer->Drag(CalculateDragPoint(*resizer, 0, 610), 0);
452 resizer->RevertDrag(); 489 resizer->RevertDrag();
453 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 490 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
454 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 491 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
455 } 492 }
456 } 493 }
457 494
458 TEST_F(DragWindowResizerTest, DragWindowControllerAcrossThreeDisplays) { 495 TEST_P(DragWindowResizerTest, DragWindowControllerAcrossThreeDisplays) {
459 if (!SupportsMultipleDisplays()) 496 if (!SupportsMultipleDisplays())
460 return; 497 return;
461 498
462 UpdateDisplay("400x600,400x600,800x600"); 499 UpdateDisplay("400x600,400x600,800x600");
463 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 500 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
464 501
465 // Layout so that all three displays touch each other. 502 // Layout so that all three displays touch each other.
466 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 503 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
467 display::DisplayIdList list = display_manager->GetCurrentDisplayIdList(); 504 display::DisplayIdList list = display_manager->GetCurrentDisplayIdList();
468 ASSERT_EQ(3u, list.size()); 505 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()); 589 EXPECT_FLOAT_EQ(0.0f, window_->layer()->opacity());
553 EXPECT_FLOAT_EQ(1.0f, drag_layer0->opacity()); 590 EXPECT_FLOAT_EQ(1.0f, drag_layer0->opacity());
554 591
555 resizer->CompleteDrag(); 592 resizer->CompleteDrag();
556 EXPECT_EQ(root_windows[2], window_->GetRootWindow()); 593 EXPECT_EQ(root_windows[2], window_->GetRootWindow());
557 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 594 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
558 } 595 }
559 596
560 // Verifies if the resizer sets and resets 597 // Verifies if the resizer sets and resets
561 // MouseCursorEventFilter::mouse_warp_mode_ as expected. 598 // MouseCursorEventFilter::mouse_warp_mode_ as expected.
562 TEST_F(DragWindowResizerTest, WarpMousePointer) { 599 TEST_P(DragWindowResizerTest, WarpMousePointer) {
563 MouseCursorEventFilter* event_filter = 600 MouseCursorEventFilter* event_filter =
564 Shell::GetInstance()->mouse_cursor_filter(); 601 Shell::GetInstance()->mouse_cursor_filter();
565 ASSERT_TRUE(event_filter); 602 ASSERT_TRUE(event_filter);
566 window_->SetBounds(gfx::Rect(0, 0, 50, 60)); 603 window_->SetBounds(gfx::Rect(0, 0, 50, 60));
567 604
568 EXPECT_TRUE(event_filter->mouse_warp_enabled_); 605 EXPECT_TRUE(event_filter->mouse_warp_enabled_);
569 { 606 {
570 std::unique_ptr<WindowResizer> resizer( 607 std::unique_ptr<WindowResizer> resizer(
571 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION)); 608 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION));
572 // While dragging a window, warp should be allowed. 609 // While dragging a window, warp should be allowed.
(...skipping 23 matching lines...) Expand all
596 std::unique_ptr<WindowResizer> resizer( 633 std::unique_ptr<WindowResizer> resizer(
597 CreateDragWindowResizer(window_.get(), gfx::Point(), HTRIGHT)); 634 CreateDragWindowResizer(window_.get(), gfx::Point(), HTRIGHT));
598 EXPECT_FALSE(event_filter->mouse_warp_enabled_); 635 EXPECT_FALSE(event_filter->mouse_warp_enabled_);
599 resizer->RevertDrag(); 636 resizer->RevertDrag();
600 } 637 }
601 EXPECT_TRUE(event_filter->mouse_warp_enabled_); 638 EXPECT_TRUE(event_filter->mouse_warp_enabled_);
602 } 639 }
603 640
604 // Verifies cursor's device scale factor is updated whe a window is moved across 641 // 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). 642 // root windows with different device scale factors (http://crbug.com/154183).
606 TEST_F(DragWindowResizerTest, CursorDeviceScaleFactor) { 643 TEST_P(DragWindowResizerTest, CursorDeviceScaleFactor) {
607 if (!SupportsMultipleDisplays()) 644 if (!SupportsMultipleDisplays())
608 return; 645 return;
609 646
610 // The secondary display is logically on the right, but on the system (e.g. X) 647 // 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. 648 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc.
612 UpdateDisplay("400x400,800x800*2"); 649 UpdateDisplay("400x400,800x800*2");
613 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 650 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
614 ASSERT_EQ(2U, root_windows.size()); 651 ASSERT_EQ(2U, root_windows.size());
615 652
616 test::CursorManagerTestApi cursor_test_api( 653 test::CursorManagerTestApi cursor_test_api(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 ASSERT_TRUE(resizer.get()); 690 ASSERT_TRUE(resizer.get());
654 resizer->Drag(CalculateDragPoint(*resizer, -200, 200), 0); 691 resizer->Drag(CalculateDragPoint(*resizer, -200, 200), 0);
655 TestIfMouseWarpsAt(gfx::Point(400, 200)); 692 TestIfMouseWarpsAt(gfx::Point(400, 200));
656 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); 693 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor());
657 resizer->CompleteDrag(); 694 resizer->CompleteDrag();
658 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); 695 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor());
659 } 696 }
660 } 697 }
661 698
662 // Verifies several kinds of windows can be moved across displays. 699 // Verifies several kinds of windows can be moved across displays.
663 TEST_F(DragWindowResizerTest, MoveWindowAcrossDisplays) { 700 TEST_P(DragWindowResizerTest, MoveWindowAcrossDisplays) {
664 if (!SupportsMultipleDisplays()) 701 if (!SupportsMultipleDisplays())
665 return; 702 return;
666 703
667 // The secondary display is logically on the right, but on the system (e.g. X) 704 // 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. 705 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc.
669 UpdateDisplay("400x400,400x400"); 706 UpdateDisplay("400x400,400x400");
670 707
671 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 708 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
672 ASSERT_EQ(2U, root_windows.size()); 709 ASSERT_EQ(2U, root_windows.size());
673 710
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 ASSERT_TRUE(resizer.get()); 806 ASSERT_TRUE(resizer.get());
770 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 807 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
771 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200))); 808 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200)));
772 EXPECT_EQ("401,200", 809 EXPECT_EQ("401,200",
773 aura::Env::GetInstance()->last_mouse_location().ToString()); 810 aura::Env::GetInstance()->last_mouse_location().ToString());
774 resizer->CompleteDrag(); 811 resizer->CompleteDrag();
775 } 812 }
776 } 813 }
777 814
778 } // namespace ash 815 } // namespace ash
OLDNEW
« ash/test/ash_md_test_base.cc ('K') | « ash/test/ash_md_test_base.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698