OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/window_state.h" | 5 #include "ash/common/wm/window_state.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "ash/common/material_design/material_design_controller.h" | 9 #include "ash/common/material_design/material_design_controller.h" |
| 10 #include "ash/common/shelf/wm_shelf.h" |
10 #include "ash/common/wm/window_state.h" | 11 #include "ash/common/wm/window_state.h" |
11 #include "ash/common/wm/wm_event.h" | 12 #include "ash/common/wm/wm_event.h" |
12 #include "ash/screen_util.h" | 13 #include "ash/screen_util.h" |
13 #include "ash/test/ash_md_test_base.h" | 14 #include "ash/test/ash_md_test_base.h" |
14 #include "ash/wm/window_state_aura.h" | 15 #include "ash/wm/window_state_aura.h" |
15 #include "ui/aura/client/aura_constants.h" | 16 #include "ui/aura/client/aura_constants.h" |
16 #include "ui/aura/test/test_window_delegate.h" | 17 #include "ui/aura/test/test_window_delegate.h" |
17 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
18 #include "ui/display/screen.h" | 19 #include "ui/display/screen.h" |
19 | 20 |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 | 402 |
402 window_state->set_allow_set_bounds_in_maximized(false); | 403 window_state->set_allow_set_bounds_in_maximized(false); |
403 window_state->Maximize(); | 404 window_state->Maximize(); |
404 | 405 |
405 EXPECT_TRUE(window_state->IsMaximized()); | 406 EXPECT_TRUE(window_state->IsMaximized()); |
406 EXPECT_EQ(work_area, window->bounds()); | 407 EXPECT_EQ(work_area, window->bounds()); |
407 window->SetBounds(new_bounds); | 408 window->SetBounds(new_bounds); |
408 EXPECT_EQ(work_area, window->bounds()); | 409 EXPECT_EQ(work_area, window->bounds()); |
409 } | 410 } |
410 | 411 |
| 412 // When there is a workarea bounds changed event caused by shelf layout, the |
| 413 // wm::AdjustBoundsToEnsureMinimumWindowVisibility method may cause window |
| 414 // bounds change, which leads to the status bubble bug in crbug.com/624806. |
| 415 TEST_P(WindowStateTest, AvoidPossibleBoundsChangeIfIgnoredByShelf) { |
| 416 WmShelf* shelf = test::AshTestBase::GetPrimaryShelf(); |
| 417 shelf->SetAlignment(ash::SHELF_ALIGNMENT_LEFT); |
| 418 const gfx::Rect display_area = |
| 419 display::Screen::GetScreen()->GetPrimaryDisplay().bounds(); |
| 420 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); |
| 421 GetWindowState(window.get())->set_ignored_by_shelf(true); |
| 422 // window height should be smaller than wm::kMinimumOnScreenArea, |
| 423 // which is 25 to simulate a status bubble window. |
| 424 gfx::Rect bounds(0, 0, 80, 22); |
| 425 // Ensure the window abuts the bottom of screen. |
| 426 bounds.set_y(display_area.bottom() - bounds.height()); |
| 427 window->SetBounds(bounds); |
| 428 EXPECT_EQ(display_area.bottom(), window->bounds().bottom()); |
| 429 gfx::Rect expected = window->bounds(); |
| 430 |
| 431 shelf->SetAlignment(ash::SHELF_ALIGNMENT_BOTTOM); |
| 432 EXPECT_EQ(expected, window->bounds()); |
| 433 } |
| 434 |
411 // TODO(skuhne): Add more unit test to verify the correctness for the restore | 435 // TODO(skuhne): Add more unit test to verify the correctness for the restore |
412 // operation. | 436 // operation. |
413 | 437 |
414 } // namespace wm | 438 } // namespace wm |
415 } // namespace ash | 439 } // namespace ash |
OLD | NEW |