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

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

Issue 1924703002: Rename gfx::Display/Screen to display::Display/Screen in ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/wm/drag_window_resizer.cc ('k') | ash/wm/immersive_fullscreen_controller.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/display/display_manager.h" 7 #include "ash/display/display_manager.h"
8 #include "ash/display/mouse_cursor_event_filter.h" 8 #include "ash/display/mouse_cursor_event_filter.h"
9 #include "ash/root_window_controller.h" 9 #include "ash/root_window_controller.h"
10 #include "ash/shelf/shelf_layout_manager.h" 10 #include "ash/shelf/shelf_layout_manager.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 if (!SupportsMultipleDisplays()) 153 if (!SupportsMultipleDisplays())
154 return; 154 return;
155 155
156 // The secondary display is logically on the right, but on the system (e.g. X) 156 // The secondary display is logically on the right, but on the system (e.g. X)
157 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. 157 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc.
158 UpdateDisplay("800x600,400x300"); 158 UpdateDisplay("800x600,400x300");
159 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 159 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
160 ASSERT_EQ(2U, root_windows.size()); 160 ASSERT_EQ(2U, root_windows.size());
161 161
162 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 162 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
163 gfx::Screen::GetScreen()->GetPrimaryDisplay()); 163 display::Screen::GetScreen()->GetPrimaryDisplay());
164 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 164 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
165 { 165 {
166 // Grab (0, 0) of the window. 166 // Grab (0, 0) of the window.
167 std::unique_ptr<WindowResizer> resizer( 167 std::unique_ptr<WindowResizer> resizer(
168 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION)); 168 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION));
169 ASSERT_TRUE(resizer.get()); 169 ASSERT_TRUE(resizer.get());
170 // Drag the pointer to the right. Once it reaches the right edge of the 170 // Drag the pointer to the right. Once it reaches the right edge of the
171 // primary display, it warps to the secondary. 171 // primary display, it warps to the secondary.
172 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); 172 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0);
173 resizer->CompleteDrag(); 173 resizer->CompleteDrag();
174 // The whole window is on the secondary display now. The parent should be 174 // The whole window is on the secondary display now. The parent should be
175 // changed. 175 // changed.
176 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 176 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
177 EXPECT_EQ("0,10 50x60", window_->bounds().ToString()); 177 EXPECT_EQ("0,10 50x60", window_->bounds().ToString());
178 } 178 }
179 179
180 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 180 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
181 gfx::Screen::GetScreen()->GetPrimaryDisplay()); 181 display::Screen::GetScreen()->GetPrimaryDisplay());
182 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 182 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
183 { 183 {
184 // Grab (0, 0) of the window and move the pointer to (775, 10). 184 // Grab (0, 0) of the window and move the pointer to (775, 10).
185 std::unique_ptr<WindowResizer> resizer( 185 std::unique_ptr<WindowResizer> resizer(
186 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION)); 186 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION));
187 ASSERT_TRUE(resizer.get()); 187 ASSERT_TRUE(resizer.get());
188 resizer->Drag(CalculateDragPoint(*resizer, 795, 10), 0); 188 resizer->Drag(CalculateDragPoint(*resizer, 795, 10), 0);
189 // Window should be adjusted for minimum visibility (25px) during the drag. 189 // Window should be adjusted for minimum visibility (25px) during the drag.
190 EXPECT_EQ("775,10 50x60", window_->bounds().ToString()); 190 EXPECT_EQ("775,10 50x60", window_->bounds().ToString());
191 resizer->CompleteDrag(); 191 resizer->CompleteDrag();
192 // Since the pointer is still on the primary root window, the parent should 192 // Since the pointer is still on the primary root window, the parent should
193 // not be changed. 193 // not be changed.
194 // Window origin should be adjusted for minimum visibility (25px). 194 // Window origin should be adjusted for minimum visibility (25px).
195 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 195 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
196 EXPECT_EQ("775,10 50x60", window_->bounds().ToString()); 196 EXPECT_EQ("775,10 50x60", window_->bounds().ToString());
197 } 197 }
198 198
199 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 199 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
200 gfx::Screen::GetScreen()->GetPrimaryDisplay()); 200 display::Screen::GetScreen()->GetPrimaryDisplay());
201 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 201 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
202 { 202 {
203 // Grab the top-right edge of the window and move the pointer to (0, 10) 203 // Grab the top-right edge of the window and move the pointer to (0, 10)
204 // in the secondary root window's coordinates. 204 // in the secondary root window's coordinates.
205 std::unique_ptr<WindowResizer> resizer( 205 std::unique_ptr<WindowResizer> resizer(
206 CreateDragWindowResizer(window_.get(), gfx::Point(49, 0), HTCAPTION)); 206 CreateDragWindowResizer(window_.get(), gfx::Point(49, 0), HTCAPTION));
207 ASSERT_TRUE(resizer.get()); 207 ASSERT_TRUE(resizer.get());
208 resizer->Drag(CalculateDragPoint(*resizer, 751, 10), ui::EF_CONTROL_DOWN); 208 resizer->Drag(CalculateDragPoint(*resizer, 751, 10), ui::EF_CONTROL_DOWN);
209 resizer->CompleteDrag(); 209 resizer->CompleteDrag();
210 // Since the pointer is on the secondary, the parent should be changed 210 // Since the pointer is on the secondary, the parent should be changed
211 // even though only small fraction of the window is within the secondary 211 // even though only small fraction of the window is within the secondary
212 // root window's bounds. 212 // root window's bounds.
213 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 213 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
214 // Window origin should be adjusted for minimum visibility (25px). 214 // Window origin should be adjusted for minimum visibility (25px).
215 int expected_x = -50 + wm::kMinimumOnScreenArea; 215 int expected_x = -50 + wm::kMinimumOnScreenArea;
216 216
217 EXPECT_EQ(base::IntToString(expected_x) + ",10 50x60", 217 EXPECT_EQ(base::IntToString(expected_x) + ",10 50x60",
218 window_->bounds().ToString()); 218 window_->bounds().ToString());
219 } 219 }
220 // Dropping a window that is larger than the destination work area 220 // Dropping a window that is larger than the destination work area
221 // will shrink to fit to the work area. 221 // will shrink to fit to the work area.
222 window_->SetBoundsInScreen(gfx::Rect(0, 0, 700, 500), 222 window_->SetBoundsInScreen(gfx::Rect(0, 0, 700, 500),
223 gfx::Screen::GetScreen()->GetPrimaryDisplay()); 223 display::Screen::GetScreen()->GetPrimaryDisplay());
224 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 224 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
225 { 225 {
226 // Grab the top-right edge of the window and move the pointer to (0, 10) 226 // Grab the top-right edge of the window and move the pointer to (0, 10)
227 // in the secondary root window's coordinates. 227 // in the secondary root window's coordinates.
228 std::unique_ptr<WindowResizer> resizer( 228 std::unique_ptr<WindowResizer> resizer(
229 CreateDragWindowResizer(window_.get(), gfx::Point(699, 0), HTCAPTION)); 229 CreateDragWindowResizer(window_.get(), gfx::Point(699, 0), HTCAPTION));
230 ASSERT_TRUE(resizer.get()); 230 ASSERT_TRUE(resizer.get());
231 resizer->Drag(CalculateDragPoint(*resizer, 101, 10), ui::EF_CONTROL_DOWN); 231 resizer->Drag(CalculateDragPoint(*resizer, 101, 10), ui::EF_CONTROL_DOWN);
232 resizer->CompleteDrag(); 232 resizer->CompleteDrag();
233 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 233 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
234 // Window size should be adjusted to fit to the work area 234 // Window size should be adjusted to fit to the work area
235 EXPECT_EQ("400x253", window_->bounds().size().ToString()); 235 EXPECT_EQ("400x253", window_->bounds().size().ToString());
236 gfx::Rect window_bounds_in_screen = window_->GetBoundsInScreen(); 236 gfx::Rect window_bounds_in_screen = window_->GetBoundsInScreen();
237 gfx::Rect intersect(window_->GetRootWindow()->GetBoundsInScreen()); 237 gfx::Rect intersect(window_->GetRootWindow()->GetBoundsInScreen());
238 intersect.Intersect(window_bounds_in_screen); 238 intersect.Intersect(window_bounds_in_screen);
239 239
240 EXPECT_LE(10, intersect.width()); 240 EXPECT_LE(10, intersect.width());
241 EXPECT_LE(10, intersect.height()); 241 EXPECT_LE(10, intersect.height());
242 EXPECT_TRUE(window_bounds_in_screen.Contains(gfx::Point(800, 10))); 242 EXPECT_TRUE(window_bounds_in_screen.Contains(gfx::Point(800, 10)));
243 } 243 }
244 244
245 // Dropping a window that is larger than the destination work area 245 // Dropping a window that is larger than the destination work area
246 // will shrink to fit to the work area. 246 // will shrink to fit to the work area.
247 window_->SetBoundsInScreen(gfx::Rect(0, 0, 700, 500), 247 window_->SetBoundsInScreen(gfx::Rect(0, 0, 700, 500),
248 gfx::Screen::GetScreen()->GetPrimaryDisplay()); 248 display::Screen::GetScreen()->GetPrimaryDisplay());
249 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 249 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
250 { 250 {
251 // Grab the top-left edge of the window and move the pointer to (150, 10) 251 // Grab the top-left edge of the window and move the pointer to (150, 10)
252 // in the secondary root window's coordinates. Make sure the window is 252 // in the secondary root window's coordinates. Make sure the window is
253 // shrink in such a way that it keeps the cursor within. 253 // shrink in such a way that it keeps the cursor within.
254 std::unique_ptr<WindowResizer> resizer( 254 std::unique_ptr<WindowResizer> resizer(
255 CreateDragWindowResizer(window_.get(), gfx::Point(0, 0), HTCAPTION)); 255 CreateDragWindowResizer(window_.get(), gfx::Point(0, 0), HTCAPTION));
256 ASSERT_TRUE(resizer.get()); 256 ASSERT_TRUE(resizer.get());
257 resizer->Drag(CalculateDragPoint(*resizer, 799, 10), ui::EF_CONTROL_DOWN); 257 resizer->Drag(CalculateDragPoint(*resizer, 799, 10), ui::EF_CONTROL_DOWN);
258 resizer->Drag(CalculateDragPoint(*resizer, 850, 10), ui::EF_CONTROL_DOWN); 258 resizer->Drag(CalculateDragPoint(*resizer, 850, 10), ui::EF_CONTROL_DOWN);
(...skipping 21 matching lines...) Expand all
280 UpdateDisplay("800x600,800x600"); 280 UpdateDisplay("800x600,800x600");
281 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 281 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
282 ASSERT_EQ(2U, root_windows.size()); 282 ASSERT_EQ(2U, root_windows.size());
283 283
284 aura::test::TestWindowDelegate delegate; 284 aura::test::TestWindowDelegate delegate;
285 std::unique_ptr<aura::Window> window(new aura::Window(&delegate)); 285 std::unique_ptr<aura::Window> window(new aura::Window(&delegate));
286 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); 286 window->SetType(ui::wm::WINDOW_TYPE_NORMAL);
287 window->Init(ui::LAYER_TEXTURED); 287 window->Init(ui::LAYER_TEXTURED);
288 ParentWindowInPrimaryRootWindow(window.get()); 288 ParentWindowInPrimaryRootWindow(window.get());
289 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 289 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
290 gfx::Screen::GetScreen()->GetPrimaryDisplay()); 290 display::Screen::GetScreen()->GetPrimaryDisplay());
291 window->Show(); 291 window->Show();
292 EXPECT_TRUE(ash::wm::CanActivateWindow(window.get())); 292 EXPECT_TRUE(ash::wm::CanActivateWindow(window.get()));
293 ash::wm::ActivateWindow(window.get()); 293 ash::wm::ActivateWindow(window.get());
294 EXPECT_EQ(root_windows[0], window->GetRootWindow()); 294 EXPECT_EQ(root_windows[0], window->GetRootWindow());
295 EXPECT_EQ(root_windows[0], ash::Shell::GetTargetRootWindow()); 295 EXPECT_EQ(root_windows[0], ash::Shell::GetTargetRootWindow());
296 { 296 {
297 // Grab (0, 0) of the window. 297 // Grab (0, 0) of the window.
298 std::unique_ptr<WindowResizer> resizer( 298 std::unique_ptr<WindowResizer> resizer(
299 CreateDragWindowResizer(window.get(), gfx::Point(), HTCAPTION)); 299 CreateDragWindowResizer(window.get(), gfx::Point(), HTCAPTION));
300 ASSERT_TRUE(resizer.get()); 300 ASSERT_TRUE(resizer.get());
(...skipping 12 matching lines...) Expand all
313 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplaysRightToLeft) { 313 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplaysRightToLeft) {
314 if (!SupportsMultipleDisplays()) 314 if (!SupportsMultipleDisplays())
315 return; 315 return;
316 316
317 UpdateDisplay("800x600,800x600"); 317 UpdateDisplay("800x600,800x600");
318 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 318 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
319 ASSERT_EQ(2U, root_windows.size()); 319 ASSERT_EQ(2U, root_windows.size());
320 320
321 window_->SetBoundsInScreen( 321 window_->SetBoundsInScreen(
322 gfx::Rect(800, 00, 50, 60), 322 gfx::Rect(800, 00, 50, 60),
323 gfx::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[1])); 323 display::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[1]));
324 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 324 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
325 { 325 {
326 // Grab (0, 0) of the window. 326 // Grab (0, 0) of the window.
327 std::unique_ptr<WindowResizer> resizer( 327 std::unique_ptr<WindowResizer> resizer(
328 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION)); 328 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION));
329 ASSERT_TRUE(resizer.get()); 329 ASSERT_TRUE(resizer.get());
330 // Move the mouse near the right edge, (798, 0), of the primary display. 330 // Move the mouse near the right edge, (798, 0), of the primary display.
331 resizer->Drag(CalculateDragPoint(*resizer, -2, 0), ui::EF_CONTROL_DOWN); 331 resizer->Drag(CalculateDragPoint(*resizer, -2, 0), ui::EF_CONTROL_DOWN);
332 resizer->CompleteDrag(); 332 resizer->CompleteDrag();
333 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 333 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
334 // Window origin should be adjusted for minimum visibility (25px). 334 // Window origin should be adjusted for minimum visibility (25px).
335 EXPECT_EQ("775,0 50x60", window_->bounds().ToString()); 335 EXPECT_EQ("775,0 50x60", window_->bounds().ToString());
336 } 336 }
337 } 337 }
338 338
339 // Verifies the drag window is shown correctly. 339 // Verifies the drag window is shown correctly.
340 TEST_F(DragWindowResizerTest, DragWindowController) { 340 TEST_F(DragWindowResizerTest, DragWindowController) {
341 if (!SupportsMultipleDisplays()) 341 if (!SupportsMultipleDisplays())
342 return; 342 return;
343 343
344 UpdateDisplay("800x600,800x600"); 344 UpdateDisplay("800x600,800x600");
345 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 345 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
346 ASSERT_EQ(2U, root_windows.size()); 346 ASSERT_EQ(2U, root_windows.size());
347 347
348 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 348 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
349 gfx::Screen::GetScreen()->GetPrimaryDisplay()); 349 display::Screen::GetScreen()->GetPrimaryDisplay());
350 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 350 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
351 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 351 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
352 { 352 {
353 // Hold the center of the window so that the window doesn't stick to the 353 // Hold the center of the window so that the window doesn't stick to the
354 // edge when dragging around the edge of the display. 354 // edge when dragging around the edge of the display.
355 std::unique_ptr<WindowResizer> resizer( 355 std::unique_ptr<WindowResizer> resizer(
356 CreateDragWindowResizer(window_.get(), gfx::Point(25, 30), HTCAPTION)); 356 CreateDragWindowResizer(window_.get(), gfx::Point(25, 30), HTCAPTION));
357 ASSERT_TRUE(resizer.get()); 357 ASSERT_TRUE(resizer.get());
358 DragWindowResizer* drag_resizer = DragWindowResizer::instance_; 358 DragWindowResizer* drag_resizer = DragWindowResizer::instance_;
359 ASSERT_TRUE(drag_resizer); 359 ASSERT_TRUE(drag_resizer);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 EXPECT_GT(1.0f, window_->layer()->opacity()); 391 EXPECT_GT(1.0f, window_->layer()->opacity());
392 EXPECT_FLOAT_EQ(1.0f, drag_layer->opacity()); 392 EXPECT_FLOAT_EQ(1.0f, drag_layer->opacity());
393 393
394 resizer->CompleteDrag(); 394 resizer->CompleteDrag();
395 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 395 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
396 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 396 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
397 } 397 }
398 398
399 // Do the same test with RevertDrag(). 399 // Do the same test with RevertDrag().
400 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 400 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
401 gfx::Screen::GetScreen()->GetPrimaryDisplay()); 401 display::Screen::GetScreen()->GetPrimaryDisplay());
402 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 402 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
403 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 403 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
404 { 404 {
405 std::unique_ptr<WindowResizer> resizer( 405 std::unique_ptr<WindowResizer> resizer(
406 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION)); 406 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION));
407 ASSERT_TRUE(resizer.get()); 407 ASSERT_TRUE(resizer.get());
408 DragWindowResizer* drag_resizer = DragWindowResizer::instance_; 408 DragWindowResizer* drag_resizer = DragWindowResizer::instance_;
409 DragWindowController* controller = 409 DragWindowController* controller =
410 drag_resizer->drag_window_controller_.get(); 410 drag_resizer->drag_window_controller_.get();
411 ASSERT_TRUE(drag_resizer); 411 ASSERT_TRUE(drag_resizer);
(...skipping 10 matching lines...) Expand all
422 if (!SupportsMultipleDisplays()) 422 if (!SupportsMultipleDisplays())
423 return; 423 return;
424 424
425 UpdateDisplay("400x600,400x600,800x600"); 425 UpdateDisplay("400x600,400x600,800x600");
426 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 426 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
427 427
428 // Layout so that all three displays touch each other. 428 // Layout so that all three displays touch each other.
429 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 429 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
430 display::DisplayIdList list = display_manager->GetCurrentDisplayIdList(); 430 display::DisplayIdList list = display_manager->GetCurrentDisplayIdList();
431 ASSERT_EQ(3u, list.size()); 431 ASSERT_EQ(3u, list.size());
432 ASSERT_EQ(gfx::Screen::GetScreen()->GetPrimaryDisplay().id(), list[0]); 432 ASSERT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().id(), list[0]);
433 display::DisplayLayoutBuilder builder(list[0]); 433 display::DisplayLayoutBuilder builder(list[0]);
434 builder.AddDisplayPlacement(list[1], list[0], 434 builder.AddDisplayPlacement(list[1], list[0],
435 display::DisplayPlacement::RIGHT, 0); 435 display::DisplayPlacement::RIGHT, 0);
436 builder.AddDisplayPlacement(list[2], list[0], 436 builder.AddDisplayPlacement(list[2], list[0],
437 display::DisplayPlacement::BOTTOM, 0); 437 display::DisplayPlacement::BOTTOM, 0);
438 display_manager->SetLayoutForCurrentDisplays(builder.Build()); 438 display_manager->SetLayoutForCurrentDisplays(builder.Build());
439 // Sanity check. 439 // Sanity check.
440 ASSERT_EQ(gfx::Rect(0, 000, 400, 600), 440 ASSERT_EQ(gfx::Rect(0, 000, 400, 600),
441 display_manager->GetDisplayForId(list[0]).bounds()); 441 display_manager->GetDisplayForId(list[0]).bounds());
442 ASSERT_EQ(gfx::Rect(400, 0, 400, 600), 442 ASSERT_EQ(gfx::Rect(400, 0, 400, 600),
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. 574 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc.
575 UpdateDisplay("400x400,800x800*2"); 575 UpdateDisplay("400x400,800x800*2");
576 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 576 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
577 ASSERT_EQ(2U, root_windows.size()); 577 ASSERT_EQ(2U, root_windows.size());
578 578
579 test::CursorManagerTestApi cursor_test_api( 579 test::CursorManagerTestApi cursor_test_api(
580 Shell::GetInstance()->cursor_manager()); 580 Shell::GetInstance()->cursor_manager());
581 // Move window from the root window with 1.0 device scale factor to the root 581 // Move window from the root window with 1.0 device scale factor to the root
582 // window with 2.0 device scale factor. 582 // window with 2.0 device scale factor.
583 { 583 {
584 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 584 window_->SetBoundsInScreen(
585 gfx::Screen::GetScreen()->GetPrimaryDisplay()); 585 gfx::Rect(0, 0, 50, 60),
586 display::Screen::GetScreen()->GetPrimaryDisplay());
586 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 587 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
587 // Grab (0, 0) of the window. 588 // Grab (0, 0) of the window.
588 std::unique_ptr<WindowResizer> resizer( 589 std::unique_ptr<WindowResizer> resizer(
589 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION)); 590 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION));
590 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); 591 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor());
591 ASSERT_TRUE(resizer.get()); 592 ASSERT_TRUE(resizer.get());
592 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 593 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
593 TestIfMouseWarpsAt(gfx::Point(399, 200)); 594 TestIfMouseWarpsAt(gfx::Point(399, 200));
594 EXPECT_EQ(2.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); 595 EXPECT_EQ(2.0f, cursor_test_api.GetCurrentCursor().device_scale_factor());
595 resizer->CompleteDrag(); 596 resizer->CompleteDrag();
596 EXPECT_EQ(2.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); 597 EXPECT_EQ(2.0f, cursor_test_api.GetCurrentCursor().device_scale_factor());
597 } 598 }
598 599
599 // Move window from the root window with 2.0 device scale factor to the root 600 // Move window from the root window with 2.0 device scale factor to the root
600 // window with 1.0 device scale factor. 601 // window with 1.0 device scale factor.
601 { 602 {
602 // Make sure the window is on the default container first. 603 // Make sure the window is on the default container first.
603 aura::Window* default_container = 604 aura::Window* default_container =
604 GetRootWindowController(root_windows[1]) 605 GetRootWindowController(root_windows[1])
605 ->GetContainer(kShellWindowId_DefaultContainer); 606 ->GetContainer(kShellWindowId_DefaultContainer);
606 default_container->AddChild(window_.get()); 607 default_container->AddChild(window_.get());
607 window_->SetBoundsInScreen( 608 window_->SetBoundsInScreen(
608 gfx::Rect(600, 0, 50, 60), 609 gfx::Rect(600, 0, 50, 60),
609 gfx::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[1])); 610 display::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[1]));
610 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 611 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
611 // Grab (0, 0) of the window. 612 // Grab (0, 0) of the window.
612 std::unique_ptr<WindowResizer> resizer( 613 std::unique_ptr<WindowResizer> resizer(
613 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION)); 614 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION));
614 EXPECT_EQ(2.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); 615 EXPECT_EQ(2.0f, cursor_test_api.GetCurrentCursor().device_scale_factor());
615 ASSERT_TRUE(resizer.get()); 616 ASSERT_TRUE(resizer.get());
616 resizer->Drag(CalculateDragPoint(*resizer, -200, 200), 0); 617 resizer->Drag(CalculateDragPoint(*resizer, -200, 200), 0);
617 TestIfMouseWarpsAt(gfx::Point(400, 200)); 618 TestIfMouseWarpsAt(gfx::Point(400, 200));
618 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); 619 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor());
619 resizer->CompleteDrag(); 620 resizer->CompleteDrag();
620 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); 621 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor());
621 } 622 }
622 } 623 }
623 624
624 // Verifies several kinds of windows can be moved across displays. 625 // Verifies several kinds of windows can be moved across displays.
625 TEST_F(DragWindowResizerTest, MoveWindowAcrossDisplays) { 626 TEST_F(DragWindowResizerTest, MoveWindowAcrossDisplays) {
626 if (!SupportsMultipleDisplays()) 627 if (!SupportsMultipleDisplays())
627 return; 628 return;
628 629
629 // The secondary display is logically on the right, but on the system (e.g. X) 630 // The secondary display is logically on the right, but on the system (e.g. X)
630 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. 631 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc.
631 UpdateDisplay("400x400,400x400"); 632 UpdateDisplay("400x400,400x400");
632 633
633 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 634 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
634 ASSERT_EQ(2U, root_windows.size()); 635 ASSERT_EQ(2U, root_windows.size());
635 636
636 // Normal window can be moved across display. 637 // Normal window can be moved across display.
637 { 638 {
638 aura::Window* window = window_.get(); 639 aura::Window* window = window_.get();
639 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 640 window->SetBoundsInScreen(
640 gfx::Screen::GetScreen()->GetPrimaryDisplay()); 641 gfx::Rect(0, 0, 50, 60),
642 display::Screen::GetScreen()->GetPrimaryDisplay());
641 // Grab (0, 0) of the window. 643 // Grab (0, 0) of the window.
642 std::unique_ptr<WindowResizer> resizer( 644 std::unique_ptr<WindowResizer> resizer(
643 CreateDragWindowResizer(window, gfx::Point(), HTCAPTION)); 645 CreateDragWindowResizer(window, gfx::Point(), HTCAPTION));
644 ASSERT_TRUE(resizer.get()); 646 ASSERT_TRUE(resizer.get());
645 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 647 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
646 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200))); 648 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200)));
647 EXPECT_EQ("401,200", 649 EXPECT_EQ("401,200",
648 aura::Env::GetInstance()->last_mouse_location().ToString()); 650 aura::Env::GetInstance()->last_mouse_location().ToString());
649 resizer->CompleteDrag(); 651 resizer->CompleteDrag();
650 } 652 }
651 653
652 // Always on top window can be moved across display. 654 // Always on top window can be moved across display.
653 { 655 {
654 aura::Window* window = always_on_top_window_.get(); 656 aura::Window* window = always_on_top_window_.get();
655 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 657 window->SetBoundsInScreen(
656 gfx::Screen::GetScreen()->GetPrimaryDisplay()); 658 gfx::Rect(0, 0, 50, 60),
659 display::Screen::GetScreen()->GetPrimaryDisplay());
657 // Grab (0, 0) of the window. 660 // Grab (0, 0) of the window.
658 std::unique_ptr<WindowResizer> resizer( 661 std::unique_ptr<WindowResizer> resizer(
659 CreateDragWindowResizer(window, gfx::Point(), HTCAPTION)); 662 CreateDragWindowResizer(window, gfx::Point(), HTCAPTION));
660 ASSERT_TRUE(resizer.get()); 663 ASSERT_TRUE(resizer.get());
661 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 664 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
662 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200))); 665 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200)));
663 EXPECT_EQ("401,200", 666 EXPECT_EQ("401,200",
664 aura::Env::GetInstance()->last_mouse_location().ToString()); 667 aura::Env::GetInstance()->last_mouse_location().ToString());
665 resizer->CompleteDrag(); 668 resizer->CompleteDrag();
666 } 669 }
667 670
668 // System modal window can be moved across display. 671 // System modal window can be moved across display.
669 { 672 {
670 aura::Window* window = system_modal_window_.get(); 673 aura::Window* window = system_modal_window_.get();
671 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 674 window->SetBoundsInScreen(
672 gfx::Screen::GetScreen()->GetPrimaryDisplay()); 675 gfx::Rect(0, 0, 50, 60),
676 display::Screen::GetScreen()->GetPrimaryDisplay());
673 aura::Env::GetInstance()->set_last_mouse_location(gfx::Point(0, 0)); 677 aura::Env::GetInstance()->set_last_mouse_location(gfx::Point(0, 0));
674 // Grab (0, 0) of the window. 678 // Grab (0, 0) of the window.
675 std::unique_ptr<WindowResizer> resizer( 679 std::unique_ptr<WindowResizer> resizer(
676 CreateDragWindowResizer(window, gfx::Point(), HTCAPTION)); 680 CreateDragWindowResizer(window, gfx::Point(), HTCAPTION));
677 ASSERT_TRUE(resizer.get()); 681 ASSERT_TRUE(resizer.get());
678 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 682 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
679 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200))); 683 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200)));
680 EXPECT_EQ("401,200", 684 EXPECT_EQ("401,200",
681 aura::Env::GetInstance()->last_mouse_location().ToString()); 685 aura::Env::GetInstance()->last_mouse_location().ToString());
682 resizer->CompleteDrag(); 686 resizer->CompleteDrag();
683 } 687 }
684 688
685 // Transient window cannot be moved across display. 689 // Transient window cannot be moved across display.
686 { 690 {
687 aura::Window* window = transient_child_; 691 aura::Window* window = transient_child_;
688 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 692 window->SetBoundsInScreen(
689 gfx::Screen::GetScreen()->GetPrimaryDisplay()); 693 gfx::Rect(0, 0, 50, 60),
694 display::Screen::GetScreen()->GetPrimaryDisplay());
690 // Grab (0, 0) of the window. 695 // Grab (0, 0) of the window.
691 std::unique_ptr<WindowResizer> resizer( 696 std::unique_ptr<WindowResizer> resizer(
692 CreateDragWindowResizer(window, gfx::Point(), HTCAPTION)); 697 CreateDragWindowResizer(window, gfx::Point(), HTCAPTION));
693 ASSERT_TRUE(resizer.get()); 698 ASSERT_TRUE(resizer.get());
694 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 699 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
695 EXPECT_FALSE(TestIfMouseWarpsAt(gfx::Point(399, 200))); 700 EXPECT_FALSE(TestIfMouseWarpsAt(gfx::Point(399, 200)));
696 EXPECT_EQ("399,200", 701 EXPECT_EQ("399,200",
697 aura::Env::GetInstance()->last_mouse_location().ToString()); 702 aura::Env::GetInstance()->last_mouse_location().ToString());
698 resizer->CompleteDrag(); 703 resizer->CompleteDrag();
699 } 704 }
700 705
701 // The parent of transient window can be moved across display. 706 // The parent of transient window can be moved across display.
702 { 707 {
703 aura::Window* window = transient_parent_.get(); 708 aura::Window* window = transient_parent_.get();
704 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 709 window->SetBoundsInScreen(
705 gfx::Screen::GetScreen()->GetPrimaryDisplay()); 710 gfx::Rect(0, 0, 50, 60),
711 display::Screen::GetScreen()->GetPrimaryDisplay());
706 // Grab (0, 0) of the window. 712 // Grab (0, 0) of the window.
707 std::unique_ptr<WindowResizer> resizer( 713 std::unique_ptr<WindowResizer> resizer(
708 CreateDragWindowResizer(window, gfx::Point(), HTCAPTION)); 714 CreateDragWindowResizer(window, gfx::Point(), HTCAPTION));
709 ASSERT_TRUE(resizer.get()); 715 ASSERT_TRUE(resizer.get());
710 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 716 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
711 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200))); 717 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200)));
712 EXPECT_EQ("401,200", 718 EXPECT_EQ("401,200",
713 aura::Env::GetInstance()->last_mouse_location().ToString()); 719 aura::Env::GetInstance()->last_mouse_location().ToString());
714 resizer->CompleteDrag(); 720 resizer->CompleteDrag();
715 } 721 }
716 722
717 // Panel window can be moved across display. 723 // Panel window can be moved across display.
718 { 724 {
719 aura::Window* window = panel_window_.get(); 725 aura::Window* window = panel_window_.get();
720 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 726 window->SetBoundsInScreen(
721 gfx::Screen::GetScreen()->GetPrimaryDisplay()); 727 gfx::Rect(0, 0, 50, 60),
728 display::Screen::GetScreen()->GetPrimaryDisplay());
722 // Grab (0, 0) of the window. 729 // Grab (0, 0) of the window.
723 std::unique_ptr<WindowResizer> resizer( 730 std::unique_ptr<WindowResizer> resizer(
724 CreateDragWindowResizer(window, gfx::Point(), HTCAPTION)); 731 CreateDragWindowResizer(window, gfx::Point(), HTCAPTION));
725 ASSERT_TRUE(resizer.get()); 732 ASSERT_TRUE(resizer.get());
726 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 733 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
727 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200))); 734 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200)));
728 EXPECT_EQ("401,200", 735 EXPECT_EQ("401,200",
729 aura::Env::GetInstance()->last_mouse_location().ToString()); 736 aura::Env::GetInstance()->last_mouse_location().ToString());
730 resizer->CompleteDrag(); 737 resizer->CompleteDrag();
731 } 738 }
732 } 739 }
733 740
734 } // namespace ash 741 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/drag_window_resizer.cc ('k') | ash/wm/immersive_fullscreen_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698