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/display/mouse_cursor_event_filter.h" | 7 #include "ash/display/mouse_cursor_event_filter.h" |
8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
9 #include "ash/shelf/shelf_layout_manager.h" | 9 #include "ash/shelf/shelf_layout_manager.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 ASSERT_TRUE(resizer.get()); | 237 ASSERT_TRUE(resizer.get()); |
238 resizer->Drag(CalculateDragPoint(*resizer, 101, 10), ui::EF_CONTROL_DOWN); | 238 resizer->Drag(CalculateDragPoint(*resizer, 101, 10), ui::EF_CONTROL_DOWN); |
239 resizer->CompleteDrag(); | 239 resizer->CompleteDrag(); |
240 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); | 240 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); |
241 // Window size should be adjusted to fit to the work area | 241 // Window size should be adjusted to fit to the work area |
242 EXPECT_EQ("400x253", window_->bounds().size().ToString()); | 242 EXPECT_EQ("400x253", window_->bounds().size().ToString()); |
243 gfx::Rect window_bounds_in_screen = window_->GetBoundsInScreen(); | 243 gfx::Rect window_bounds_in_screen = window_->GetBoundsInScreen(); |
244 gfx::Rect intersect(window_->GetRootWindow()->GetBoundsInScreen()); | 244 gfx::Rect intersect(window_->GetRootWindow()->GetBoundsInScreen()); |
245 intersect.Intersect(window_bounds_in_screen); | 245 intersect.Intersect(window_bounds_in_screen); |
246 | 246 |
247 // TODO(oshima): Following condition fails without docked window resizer. | 247 EXPECT_LE(10, intersect.width()); |
248 // Proper fix caused the other failures, so I'm disabling these | 248 EXPECT_LE(10, intersect.height()); |
249 // for m33 (Which is harmless). | 249 EXPECT_TRUE(window_bounds_in_screen.Contains(gfx::Point(800, 10))); |
250 // EXPECT_LE(10, intersect.width()); | |
251 // EXPECT_LE(10, intersect.height()); | |
252 // EXPECT_TRUE(window_bounds_in_screen.Contains(gfx::Point(800, 10))); | |
253 } | 250 } |
254 | 251 |
255 // Dropping a window that is larger than the destination work area | 252 // Dropping a window that is larger than the destination work area |
256 // will shrink to fit to the work area. | 253 // will shrink to fit to the work area. |
257 window_->SetBoundsInScreen(gfx::Rect(0, 0, 700, 500), | 254 window_->SetBoundsInScreen(gfx::Rect(0, 0, 700, 500), |
258 Shell::GetScreen()->GetPrimaryDisplay()); | 255 Shell::GetScreen()->GetPrimaryDisplay()); |
259 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | 256 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); |
260 { | 257 { |
261 // Grab the top-left edge of the window and move the pointer to (150, 10) | 258 // Grab the top-left edge of the window and move the pointer to (150, 10) |
262 // in the secondary root window's coordinates. Make sure the window is | 259 // in the secondary root window's coordinates. Make sure the window is |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); | 506 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); |
510 WarpMouseCursorIfNecessary(root_windows[0], gfx::Point(399, 200)); | 507 WarpMouseCursorIfNecessary(root_windows[0], gfx::Point(399, 200)); |
511 EXPECT_EQ(2.0f, cursor_test_api.GetDisplay().device_scale_factor()); | 508 EXPECT_EQ(2.0f, cursor_test_api.GetDisplay().device_scale_factor()); |
512 resizer->CompleteDrag(); | 509 resizer->CompleteDrag(); |
513 EXPECT_EQ(2.0f, cursor_test_api.GetDisplay().device_scale_factor()); | 510 EXPECT_EQ(2.0f, cursor_test_api.GetDisplay().device_scale_factor()); |
514 } | 511 } |
515 | 512 |
516 // Move window from the root window with 2.0 device scale factor to the root | 513 // Move window from the root window with 2.0 device scale factor to the root |
517 // window with 1.0 device scale factor. | 514 // window with 1.0 device scale factor. |
518 { | 515 { |
| 516 // Make sure the window is on the default container first. |
| 517 aura::Window* default_container = |
| 518 GetRootWindowController(root_windows[1])->GetContainer( |
| 519 internal::kShellWindowId_DefaultContainer); |
| 520 default_container->AddChild(window_.get()); |
519 window_->SetBoundsInScreen( | 521 window_->SetBoundsInScreen( |
520 gfx::Rect(600, 0, 50, 60), | 522 gfx::Rect(600, 0, 50, 60), |
521 Shell::GetScreen()->GetDisplayNearestWindow(root_windows[1])); | 523 Shell::GetScreen()->GetDisplayNearestWindow(root_windows[1])); |
522 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); | 524 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); |
523 // Grab (0, 0) of the window. | 525 // Grab (0, 0) of the window. |
524 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( | 526 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( |
525 window_.get(), gfx::Point(), HTCAPTION)); | 527 window_.get(), gfx::Point(), HTCAPTION)); |
526 EXPECT_EQ(2.0f, cursor_test_api.GetDisplay().device_scale_factor()); | 528 EXPECT_EQ(2.0f, cursor_test_api.GetDisplay().device_scale_factor()); |
527 ASSERT_TRUE(resizer.get()); | 529 ASSERT_TRUE(resizer.get()); |
528 resizer->Drag(CalculateDragPoint(*resizer, -200, 200), 0); | 530 resizer->Drag(CalculateDragPoint(*resizer, -200, 200), 0); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 resizer->CompleteDrag(); | 721 resizer->CompleteDrag(); |
720 EXPECT_EQ(1, session_delegate->num_transfer_to_desktop_of_user_calls()); | 722 EXPECT_EQ(1, session_delegate->num_transfer_to_desktop_of_user_calls()); |
721 EXPECT_NE(initial_bounds.ToString(), window->bounds().ToString()); | 723 EXPECT_NE(initial_bounds.ToString(), window->bounds().ToString()); |
722 } | 724 } |
723 } | 725 } |
724 #endif | 726 #endif |
725 | 727 |
726 | 728 |
727 } // namespace internal | 729 } // namespace internal |
728 } // namespace ash | 730 } // namespace ash |
OLD | NEW |