| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/common/wm/dock/docked_window_layout_manager.h" | 5 #include "ash/common/wm/dock/docked_window_layout_manager.h" |
| 6 | 6 |
| 7 #include "ash/aura/wm_window_aura.h" | 7 #include "ash/aura/wm_window_aura.h" |
| 8 #include "ash/common/ash_switches.h" | 8 #include "ash/common/ash_switches.h" |
| 9 #include "ash/common/shelf/shelf_model.h" | 9 #include "ash/common/shelf/shelf_model.h" |
| 10 #include "ash/common/shelf/shelf_types.h" | 10 #include "ash/common/shelf/shelf_types.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 return CreateWindowResizer(WmWindowAura::Get(window), point_in_parent, | 107 return CreateWindowResizer(WmWindowAura::Get(window), point_in_parent, |
| 108 window_component, | 108 window_component, |
| 109 aura::client::WINDOW_MOVE_SOURCE_MOUSE) | 109 aura::client::WINDOW_MOVE_SOURCE_MOUSE) |
| 110 .release(); | 110 .release(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void DragStart(aura::Window* window) { | 113 void DragStart(aura::Window* window) { |
| 114 DragStartAtOffsetFromwindowOrigin(window, 0, 0); | 114 DragStartAtOffsetFromwindowOrigin(window, 0, 0); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void DragStartAtOffsetFromwindowOrigin(aura::Window* window, | 117 void DragStartAtOffsetFromwindowOrigin(aura::Window* window, int dx, int dy) { |
| 118 int dx, int dy) { | |
| 119 initial_location_in_parent_ = | 118 initial_location_in_parent_ = |
| 120 window->bounds().origin() + gfx::Vector2d(dx, dy); | 119 window->bounds().origin() + gfx::Vector2d(dx, dy); |
| 121 resizer_.reset(CreateSomeWindowResizer(window, | 120 resizer_.reset(CreateSomeWindowResizer(window, initial_location_in_parent_, |
| 122 initial_location_in_parent_, | |
| 123 HTCAPTION)); | 121 HTCAPTION)); |
| 124 ASSERT_TRUE(resizer_.get()); | 122 ASSERT_TRUE(resizer_.get()); |
| 125 } | 123 } |
| 126 | 124 |
| 127 void DragMove(int dx, int dy) { | 125 void DragMove(int dx, int dy) { |
| 128 resizer_->Drag(initial_location_in_parent_ + gfx::Vector2d(dx, dy), 0); | 126 resizer_->Drag(initial_location_in_parent_ + gfx::Vector2d(dx, dy), 0); |
| 129 } | 127 } |
| 130 | 128 |
| 131 void DragEnd() { | 129 void DragEnd() { |
| 132 resizer_->CompleteDrag(); | 130 resizer_->CompleteDrag(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 145 int CorrectContainerIdDuringDrag() { | 143 int CorrectContainerIdDuringDrag() { |
| 146 if (window_type_ == ui::wm::WINDOW_TYPE_PANEL) | 144 if (window_type_ == ui::wm::WINDOW_TYPE_PANEL) |
| 147 return kShellWindowId_PanelContainer; | 145 return kShellWindowId_PanelContainer; |
| 148 return kShellWindowId_DockedContainer; | 146 return kShellWindowId_DockedContainer; |
| 149 } | 147 } |
| 150 | 148 |
| 151 // Test dragging the window vertically (to detach if it is a panel) and then | 149 // Test dragging the window vertically (to detach if it is a panel) and then |
| 152 // horizontally to the edge with an added offset from the edge of |dx|. | 150 // horizontally to the edge with an added offset from the edge of |dx|. |
| 153 void DragRelativeToEdge(DockedEdge edge, aura::Window* window, int dx) { | 151 void DragRelativeToEdge(DockedEdge edge, aura::Window* window, int dx) { |
| 154 DragVerticallyAndRelativeToEdge( | 152 DragVerticallyAndRelativeToEdge( |
| 155 edge, | 153 edge, window, dx, |
| 156 window, | |
| 157 dx, | |
| 158 window_type_ == ui::wm::WINDOW_TYPE_PANEL ? -100 : 20); | 154 window_type_ == ui::wm::WINDOW_TYPE_PANEL ? -100 : 20); |
| 159 } | 155 } |
| 160 | 156 |
| 161 void DragToVerticalPositionAndToEdge(DockedEdge edge, | 157 void DragToVerticalPositionAndToEdge(DockedEdge edge, |
| 162 aura::Window* window, | 158 aura::Window* window, |
| 163 int y) { | 159 int y) { |
| 164 DragToVerticalPositionRelativeToEdge(edge, window, 0, y); | 160 DragToVerticalPositionRelativeToEdge(edge, window, 0, y); |
| 165 } | 161 } |
| 166 | 162 |
| 167 void DragToVerticalPositionRelativeToEdge(DockedEdge edge, | 163 void DragToVerticalPositionRelativeToEdge(DockedEdge edge, |
| 168 aura::Window* window, | 164 aura::Window* window, |
| 169 int dx, | 165 int dx, |
| 170 int y) { | 166 int y) { |
| 171 gfx::Rect initial_bounds = window->GetBoundsInScreen(); | 167 gfx::Rect initial_bounds = window->GetBoundsInScreen(); |
| 172 DragVerticallyAndRelativeToEdge(edge, window, dx, y - initial_bounds.y()); | 168 DragVerticallyAndRelativeToEdge(edge, window, dx, y - initial_bounds.y()); |
| 173 } | 169 } |
| 174 | 170 |
| 175 // Detach if our window is a panel, then drag it vertically by |dy| and | 171 // Detach if our window is a panel, then drag it vertically by |dy| and |
| 176 // horizontally to the edge with an added offset from the edge of |dx|. | 172 // horizontally to the edge with an added offset from the edge of |dx|. |
| 177 void DragVerticallyAndRelativeToEdge(DockedEdge edge, | 173 void DragVerticallyAndRelativeToEdge(DockedEdge edge, |
| 178 aura::Window* window, | 174 aura::Window* window, |
| 179 int dx, int dy) { | 175 int dx, |
| 176 int dy) { |
| 180 gfx::Rect initial_bounds = window->GetBoundsInScreen(); | 177 gfx::Rect initial_bounds = window->GetBoundsInScreen(); |
| 181 // avoid snap by clicking away from the border | 178 // avoid snap by clicking away from the border |
| 182 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(window, 25, 5)); | 179 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(window, 25, 5)); |
| 183 | 180 |
| 184 gfx::Rect work_area = display::Screen::GetScreen() | 181 gfx::Rect work_area = display::Screen::GetScreen() |
| 185 ->GetDisplayNearestWindow(window) | 182 ->GetDisplayNearestWindow(window) |
| 186 .work_area(); | 183 .work_area(); |
| 187 gfx::Point initial_location_in_screen = initial_location_in_parent_; | 184 gfx::Point initial_location_in_screen = initial_location_in_parent_; |
| 188 ::wm::ConvertPointToScreen(window->parent(), &initial_location_in_screen); | 185 ::wm::ConvertPointToScreen(window->parent(), &initial_location_in_screen); |
| 189 // Drag the window left or right to the edge (or almost to it). | 186 // Drag the window left or right to the edge (or almost to it). |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 DockedWindowLayoutManager::Get(WmWindowAura::Get(window.get())); | 266 DockedWindowLayoutManager::Get(WmWindowAura::Get(window.get())); |
| 270 | 267 |
| 271 // Create two additional windows and test their auto-placement | 268 // Create two additional windows and test their auto-placement |
| 272 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); | 269 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); |
| 273 gfx::Rect desktop_area = window1->parent()->bounds(); | 270 gfx::Rect desktop_area = window1->parent()->bounds(); |
| 274 wm::GetWindowState(window1.get())->set_window_position_managed(true); | 271 wm::GetWindowState(window1.get())->set_window_position_managed(true); |
| 275 window1->Hide(); | 272 window1->Hide(); |
| 276 window1->SetBounds(gfx::Rect(250, 32, 231, 320)); | 273 window1->SetBounds(gfx::Rect(250, 32, 231, 320)); |
| 277 window1->Show(); | 274 window1->Show(); |
| 278 // |window1| should be centered in work area. | 275 // |window1| should be centered in work area. |
| 279 EXPECT_EQ(base::IntToString( | 276 EXPECT_EQ(base::IntToString(docked_width(manager) + min_dock_gap() + |
| 280 docked_width(manager) + min_dock_gap() + | 277 (desktop_area.width() - docked_width(manager) - |
| 281 (desktop_area.width() - docked_width(manager) - | 278 min_dock_gap() - window1->bounds().width()) / |
| 282 min_dock_gap() - window1->bounds().width()) / 2) + | 279 2) + |
| 283 ",32 231x320", window1->bounds().ToString()); | 280 ",32 231x320", |
| 281 window1->bounds().ToString()); |
| 284 | 282 |
| 285 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); | 283 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); |
| 286 wm::GetWindowState(window2.get())->set_window_position_managed(true); | 284 wm::GetWindowState(window2.get())->set_window_position_managed(true); |
| 287 // To avoid any auto window manager changes due to SetBounds, the window | 285 // To avoid any auto window manager changes due to SetBounds, the window |
| 288 // gets first hidden and then shown again. | 286 // gets first hidden and then shown again. |
| 289 window2->Hide(); | 287 window2->Hide(); |
| 290 window2->SetBounds(gfx::Rect(250, 48, 150, 300)); | 288 window2->SetBounds(gfx::Rect(250, 48, 150, 300)); |
| 291 window2->Show(); | 289 window2->Show(); |
| 292 | 290 |
| 293 // |window1| should be flush left and |window2| flush right. | 291 // |window1| should be flush left and |window2| flush right. |
| 294 EXPECT_EQ( | 292 EXPECT_EQ( |
| 295 base::IntToString(docked_width(manager) + min_dock_gap()) + | 293 base::IntToString(docked_width(manager) + min_dock_gap()) + ",32 231x320", |
| 296 ",32 231x320", window1->bounds().ToString()); | 294 window1->bounds().ToString()); |
| 297 EXPECT_EQ( | 295 EXPECT_EQ( |
| 298 base::IntToString( | 296 base::IntToString(desktop_area.width() - window2->bounds().width()) + |
| 299 desktop_area.width() - window2->bounds().width()) + | 297 ",48 150x300", |
| 300 ",48 150x300", window2->bounds().ToString()); | 298 window2->bounds().ToString()); |
| 301 } | 299 } |
| 302 | 300 |
| 303 // Tests that with a window docked on the right the auto-placing logic in | 301 // Tests that with a window docked on the right the auto-placing logic in |
| 304 // RearrangeVisibleWindowOnShow places windows flush with work area edges. | 302 // RearrangeVisibleWindowOnShow places windows flush with work area edges. |
| 305 TEST_P(DockedWindowLayoutManagerTest, AutoPlacingRight) { | 303 TEST_P(DockedWindowLayoutManagerTest, AutoPlacingRight) { |
| 306 if (!SupportsHostWindowResize()) | 304 if (!SupportsHostWindowResize()) |
| 307 return; | 305 return; |
| 308 | 306 |
| 309 gfx::Rect bounds(0, 0, 201, 201); | 307 gfx::Rect bounds(0, 0, 201, 201); |
| 310 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds)); | 308 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds)); |
| 311 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 309 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
| 312 | 310 |
| 313 // The window should be attached and snapped to the right side of the screen. | 311 // The window should be attached and snapped to the right side of the screen. |
| 314 EXPECT_EQ(window->GetRootWindow()->bounds().right(), | 312 EXPECT_EQ(window->GetRootWindow()->bounds().right(), |
| 315 window->GetBoundsInScreen().right()); | 313 window->GetBoundsInScreen().right()); |
| 316 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 314 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
| 317 | 315 |
| 318 DockedWindowLayoutManager* manager = | 316 DockedWindowLayoutManager* manager = |
| 319 DockedWindowLayoutManager::Get(WmWindowAura::Get(window.get())); | 317 DockedWindowLayoutManager::Get(WmWindowAura::Get(window.get())); |
| 320 | 318 |
| 321 // Create two additional windows and test their auto-placement | 319 // Create two additional windows and test their auto-placement |
| 322 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); | 320 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); |
| 323 gfx::Rect desktop_area = window1->parent()->bounds(); | 321 gfx::Rect desktop_area = window1->parent()->bounds(); |
| 324 wm::GetWindowState(window1.get())->set_window_position_managed(true); | 322 wm::GetWindowState(window1.get())->set_window_position_managed(true); |
| 325 window1->Hide(); | 323 window1->Hide(); |
| 326 window1->SetBounds(gfx::Rect(16, 32, 231, 320)); | 324 window1->SetBounds(gfx::Rect(16, 32, 231, 320)); |
| 327 window1->Show(); | 325 window1->Show(); |
| 328 | 326 |
| 329 // |window1| should be centered in work area. | 327 // |window1| should be centered in work area. |
| 330 EXPECT_EQ(base::IntToString( | 328 EXPECT_EQ(base::IntToString((desktop_area.width() - docked_width(manager) - |
| 331 (desktop_area.width() - docked_width(manager) - | 329 min_dock_gap() - window1->bounds().width()) / |
| 332 min_dock_gap() - window1->bounds().width()) / 2) + | 330 2) + |
| 333 ",32 231x320", window1->bounds().ToString()); | 331 ",32 231x320", |
| 332 window1->bounds().ToString()); |
| 334 | 333 |
| 335 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); | 334 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); |
| 336 wm::GetWindowState(window2.get())->set_window_position_managed(true); | 335 wm::GetWindowState(window2.get())->set_window_position_managed(true); |
| 337 // To avoid any auto window manager changes due to SetBounds, the window | 336 // To avoid any auto window manager changes due to SetBounds, the window |
| 338 // gets first hidden and then shown again. | 337 // gets first hidden and then shown again. |
| 339 window2->Hide(); | 338 window2->Hide(); |
| 340 window2->SetBounds(gfx::Rect(32, 48, 256, 512)); | 339 window2->SetBounds(gfx::Rect(32, 48, 256, 512)); |
| 341 window2->Show(); | 340 window2->Show(); |
| 342 | 341 |
| 343 // |window1| should be flush left and |window2| flush right. | 342 // |window1| should be flush left and |window2| flush right. |
| 344 EXPECT_EQ("0,32 231x320", window1->bounds().ToString()); | 343 EXPECT_EQ("0,32 231x320", window1->bounds().ToString()); |
| 345 EXPECT_EQ( | 344 EXPECT_EQ(base::IntToString(desktop_area.width() - window2->bounds().width() - |
| 346 base::IntToString( | 345 docked_width(manager) - min_dock_gap()) + |
| 347 desktop_area.width() - window2->bounds().width() - | 346 ",48 256x512", |
| 348 docked_width(manager) - min_dock_gap()) + | 347 window2->bounds().ToString()); |
| 349 ",48 256x512", window2->bounds().ToString()); | |
| 350 } | 348 } |
| 351 | 349 |
| 352 // Tests that with a window docked on the right the auto-placing logic in | 350 // Tests that with a window docked on the right the auto-placing logic in |
| 353 // RearrangeVisibleWindowOnShow places windows flush with work area edges. | 351 // RearrangeVisibleWindowOnShow places windows flush with work area edges. |
| 354 // Test case for the secondary screen. | 352 // Test case for the secondary screen. |
| 355 TEST_P(DockedWindowLayoutManagerTest, AutoPlacingRightSecondScreen) { | 353 TEST_P(DockedWindowLayoutManagerTest, AutoPlacingRightSecondScreen) { |
| 356 if (!SupportsMultipleDisplays() || !SupportsHostWindowResize()) | 354 if (!SupportsMultipleDisplays() || !SupportsHostWindowResize()) |
| 357 return; | 355 return; |
| 358 | 356 |
| 359 // Create a dual screen layout. | 357 // Create a dual screen layout. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 375 // Create two additional windows and test their auto-placement | 373 // Create two additional windows and test their auto-placement |
| 376 bounds = gfx::Rect(616, 32, 231, 320); | 374 bounds = gfx::Rect(616, 32, 231, 320); |
| 377 std::unique_ptr<aura::Window> window1( | 375 std::unique_ptr<aura::Window> window1( |
| 378 CreateTestWindowInShellWithDelegate(nullptr, 1, bounds)); | 376 CreateTestWindowInShellWithDelegate(nullptr, 1, bounds)); |
| 379 gfx::Rect desktop_area = window1->parent()->bounds(); | 377 gfx::Rect desktop_area = window1->parent()->bounds(); |
| 380 wm::GetWindowState(window1.get())->set_window_position_managed(true); | 378 wm::GetWindowState(window1.get())->set_window_position_managed(true); |
| 381 window1->Hide(); | 379 window1->Hide(); |
| 382 window1->Show(); | 380 window1->Show(); |
| 383 | 381 |
| 384 // |window1| should be centered in work area. | 382 // |window1| should be centered in work area. |
| 385 EXPECT_EQ(base::IntToString( | 383 EXPECT_EQ(base::IntToString(600 + |
| 386 600 + (desktop_area.width() - docked_width(manager) - | 384 (desktop_area.width() - docked_width(manager) - |
| 387 min_dock_gap() - window1->bounds().width()) / 2) + | 385 min_dock_gap() - window1->bounds().width()) / |
| 388 ",32 231x320", window1->GetBoundsInScreen().ToString()); | 386 2) + |
| 387 ",32 231x320", |
| 388 window1->GetBoundsInScreen().ToString()); |
| 389 | 389 |
| 390 bounds = gfx::Rect(632, 48, 256, 512); | 390 bounds = gfx::Rect(632, 48, 256, 512); |
| 391 std::unique_ptr<aura::Window> window2( | 391 std::unique_ptr<aura::Window> window2( |
| 392 CreateTestWindowInShellWithDelegate(nullptr, 2, bounds)); | 392 CreateTestWindowInShellWithDelegate(nullptr, 2, bounds)); |
| 393 wm::GetWindowState(window2.get())->set_window_position_managed(true); | 393 wm::GetWindowState(window2.get())->set_window_position_managed(true); |
| 394 // To avoid any auto window manager changes due to SetBounds, the window | 394 // To avoid any auto window manager changes due to SetBounds, the window |
| 395 // gets first hidden and then shown again. | 395 // gets first hidden and then shown again. |
| 396 window2->Hide(); | 396 window2->Hide(); |
| 397 window2->Show(); | 397 window2->Show(); |
| 398 | 398 |
| 399 // |window1| should be flush left and |window2| flush right. | 399 // |window1| should be flush left and |window2| flush right. |
| 400 EXPECT_EQ("600,32 231x320", window1->GetBoundsInScreen().ToString()); | 400 EXPECT_EQ("600,32 231x320", window1->GetBoundsInScreen().ToString()); |
| 401 EXPECT_EQ( | 401 EXPECT_EQ( |
| 402 base::IntToString( | 402 base::IntToString(600 + desktop_area.width() - window2->bounds().width() - |
| 403 600 + desktop_area.width() - window2->bounds().width() - | 403 docked_width(manager) - min_dock_gap()) + |
| 404 docked_width(manager) - min_dock_gap()) + | 404 ",48 256x512", |
| 405 ",48 256x512", window2->GetBoundsInScreen().ToString()); | 405 window2->GetBoundsInScreen().ToString()); |
| 406 } | 406 } |
| 407 | 407 |
| 408 // Adds two windows and tests that the gaps are evenly distributed. | 408 // Adds two windows and tests that the gaps are evenly distributed. |
| 409 TEST_P(DockedWindowLayoutManagerTest, AddTwoWindows) { | 409 TEST_P(DockedWindowLayoutManagerTest, AddTwoWindows) { |
| 410 if (!SupportsHostWindowResize()) | 410 if (!SupportsHostWindowResize()) |
| 411 return; | 411 return; |
| 412 | 412 |
| 413 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 413 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
| 414 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 202))); | 414 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 202))); |
| 415 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 415 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 return; | 689 return; |
| 690 | 690 |
| 691 aura::test::TestWindowDelegate delegate; | 691 aura::test::TestWindowDelegate delegate; |
| 692 delegate.set_minimum_size(gfx::Size(400, 0)); | 692 delegate.set_minimum_size(gfx::Size(400, 0)); |
| 693 std::unique_ptr<aura::Window> window( | 693 std::unique_ptr<aura::Window> window( |
| 694 CreateTestWindowWithDelegate(gfx::Rect(0, 0, 400, 201), &delegate)); | 694 CreateTestWindowWithDelegate(gfx::Rect(0, 0, 400, 201), &delegate)); |
| 695 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, window.get(), 20); | 695 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, window.get(), 20); |
| 696 | 696 |
| 697 // Secondary drag ensures that we are testing the minimum size restriction | 697 // Secondary drag ensures that we are testing the minimum size restriction |
| 698 // and not just failure to get past the tiling step in SnapSizer. | 698 // and not just failure to get past the tiling step in SnapSizer. |
| 699 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(window.get(), | 699 ASSERT_NO_FATAL_FAILURE( |
| 700 25, 5)); | 700 DragStartAtOffsetFromwindowOrigin(window.get(), 25, 5)); |
| 701 DragMove(150,0); | 701 DragMove(150, 0); |
| 702 DragEnd(); | 702 DragEnd(); |
| 703 | 703 |
| 704 // The window should not get docked even though it is dragged past the edge. | 704 // The window should not get docked even though it is dragged past the edge. |
| 705 EXPECT_NE(window->GetRootWindow()->bounds().right(), | 705 EXPECT_NE(window->GetRootWindow()->bounds().right(), |
| 706 window->GetBoundsInScreen().right()); | 706 window->GetBoundsInScreen().right()); |
| 707 EXPECT_NE(kShellWindowId_DockedContainer, window->parent()->id()); | 707 EXPECT_NE(kShellWindowId_DockedContainer, window->parent()->id()); |
| 708 } | 708 } |
| 709 | 709 |
| 710 // Docks three windows and tests that the very first window gets minimized. | 710 // Docks three windows and tests that the very first window gets minimized. |
| 711 TEST_P(DockedWindowLayoutManagerTest, ThreeWindowsMinimize) { | 711 TEST_P(DockedWindowLayoutManagerTest, ThreeWindowsMinimize) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 760 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
| 761 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), | 761 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), |
| 762 w2->GetBoundsInScreen().right()); | 762 w2->GetBoundsInScreen().right()); |
| 763 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 763 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
| 764 | 764 |
| 765 // The two windows should be same size vertically and almost 1/2 of work area. | 765 // The two windows should be same size vertically and almost 1/2 of work area. |
| 766 gfx::Rect work_area = display::Screen::GetScreen() | 766 gfx::Rect work_area = display::Screen::GetScreen() |
| 767 ->GetDisplayNearestWindow(w1.get()) | 767 ->GetDisplayNearestWindow(w1.get()) |
| 768 .work_area(); | 768 .work_area(); |
| 769 EXPECT_NEAR(w1->GetBoundsInScreen().height(), | 769 EXPECT_NEAR(w1->GetBoundsInScreen().height(), |
| 770 w2->GetBoundsInScreen().height(), | 770 w2->GetBoundsInScreen().height(), 1); |
| 771 1); | |
| 772 EXPECT_NEAR(work_area.height() / 2, w1->GetBoundsInScreen().height(), | 771 EXPECT_NEAR(work_area.height() / 2, w1->GetBoundsInScreen().height(), |
| 773 min_dock_gap() * 2); | 772 min_dock_gap() * 2); |
| 774 | 773 |
| 775 // Create and dock the third window. | 774 // Create and dock the third window. |
| 776 std::unique_ptr<aura::Window> w3(CreateTestWindow(gfx::Rect(0, 0, 220, 204))); | 775 std::unique_ptr<aura::Window> w3(CreateTestWindow(gfx::Rect(0, 0, 220, 204))); |
| 777 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w3.get(), 300); | 776 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w3.get(), 300); |
| 778 | 777 |
| 779 // All three windows should be docked and snapped to the right edge. | 778 // All three windows should be docked and snapped to the right edge. |
| 780 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 779 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
| 781 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 780 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
| 782 EXPECT_EQ(kShellWindowId_DockedContainer, w3->parent()->id()); | 781 EXPECT_EQ(kShellWindowId_DockedContainer, w3->parent()->id()); |
| 783 | 782 |
| 784 // All windows should be near same size vertically and about 1/3 of work area. | 783 // All windows should be near same size vertically and about 1/3 of work area. |
| 785 EXPECT_NEAR(w1->GetBoundsInScreen().height(), | 784 EXPECT_NEAR(w1->GetBoundsInScreen().height(), |
| 786 w2->GetBoundsInScreen().height(), | 785 w2->GetBoundsInScreen().height(), 1); |
| 787 1); | |
| 788 EXPECT_NEAR(w2->GetBoundsInScreen().height(), | 786 EXPECT_NEAR(w2->GetBoundsInScreen().height(), |
| 789 w3->GetBoundsInScreen().height(), | 787 w3->GetBoundsInScreen().height(), 1); |
| 790 1); | |
| 791 EXPECT_NEAR(work_area.height() / 3, w1->GetBoundsInScreen().height(), | 788 EXPECT_NEAR(work_area.height() / 3, w1->GetBoundsInScreen().height(), |
| 792 min_dock_gap() * 2); | 789 min_dock_gap() * 2); |
| 793 } | 790 } |
| 794 | 791 |
| 795 // Docks two windows and tests that restrictions on vertical size are honored. | 792 // Docks two windows and tests that restrictions on vertical size are honored. |
| 796 TEST_P(DockedWindowLayoutManagerTest, TwoWindowsHeightRestrictions) { | 793 TEST_P(DockedWindowLayoutManagerTest, TwoWindowsHeightRestrictions) { |
| 797 if (!SupportsHostWindowResize()) | 794 if (!SupportsHostWindowResize()) |
| 798 return; | 795 return; |
| 799 | 796 |
| 800 // The first window is fixed height. | 797 // The first window is fixed height. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 EXPECT_EQ(work_area.height(), window->GetBoundsInScreen().height()); | 859 EXPECT_EQ(work_area.height(), window->GetBoundsInScreen().height()); |
| 863 } | 860 } |
| 864 | 861 |
| 865 // Tests run twice - on both panels and normal windows | 862 // Tests run twice - on both panels and normal windows |
| 866 INSTANTIATE_TEST_CASE_P(NormalOrPanel, | 863 INSTANTIATE_TEST_CASE_P(NormalOrPanel, |
| 867 DockedWindowLayoutManagerTest, | 864 DockedWindowLayoutManagerTest, |
| 868 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, | 865 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, |
| 869 ui::wm::WINDOW_TYPE_PANEL)); | 866 ui::wm::WINDOW_TYPE_PANEL)); |
| 870 | 867 |
| 871 } // namespace ash | 868 } // namespace ash |
| OLD | NEW |