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/workspace/workspace_manager.h" | 5 #include "ash/wm/workspace/workspace_manager.h" |
6 | 6 |
7 #include "ash/screen_ash.h" | 7 #include "ash/screen_ash.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
10 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
22 #include "ui/base/ui_base_types.h" | 22 #include "ui/base/ui_base_types.h" |
23 #include "ui/compositor/layer.h" | 23 #include "ui/compositor/layer.h" |
24 #include "ui/gfx/screen.h" | 24 #include "ui/gfx/screen.h" |
25 | 25 |
26 using aura::Window; | 26 using aura::Window; |
27 | 27 |
28 namespace ash { | 28 namespace ash { |
29 namespace internal { | 29 namespace internal { |
30 | 30 |
| 31 namespace { |
| 32 |
| 33 bool GetWindowOverlapsShelf() { |
| 34 return Shell::GetInstance()->shelf()->window_overlaps_shelf(); |
| 35 } |
| 36 |
| 37 } // namespace |
| 38 |
31 class WorkspaceManagerTest : public test::AshTestBase { | 39 class WorkspaceManagerTest : public test::AshTestBase { |
32 public: | 40 public: |
33 WorkspaceManagerTest() : manager_(NULL) {} | 41 WorkspaceManagerTest() : manager_(NULL) {} |
34 virtual ~WorkspaceManagerTest() {} | 42 virtual ~WorkspaceManagerTest() {} |
35 | 43 |
36 aura::Window* CreateTestWindowUnparented() { | 44 aura::Window* CreateTestWindowUnparented() { |
37 aura::Window* window = new aura::Window(NULL); | 45 aura::Window* window = new aura::Window(NULL); |
38 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 46 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
39 window->SetType(aura::client::WINDOW_TYPE_NORMAL); | 47 window->SetType(aura::client::WINDOW_TYPE_NORMAL); |
40 window->Init(ui::LAYER_TEXTURED); | 48 window->Init(ui::LAYER_TEXTURED); |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 // updated. | 461 // updated. |
454 TEST_F(WorkspaceManagerTest, ShelfStateUpdated) { | 462 TEST_F(WorkspaceManagerTest, ShelfStateUpdated) { |
455 // Since ShelfLayoutManager queries for mouse location, move the mouse so | 463 // Since ShelfLayoutManager queries for mouse location, move the mouse so |
456 // it isn't over the shelf. | 464 // it isn't over the shelf. |
457 aura::test::EventGenerator generator( | 465 aura::test::EventGenerator generator( |
458 Shell::GetPrimaryRootWindow(), gfx::Point()); | 466 Shell::GetPrimaryRootWindow(), gfx::Point()); |
459 generator.MoveMouseTo(0, 0); | 467 generator.MoveMouseTo(0, 0); |
460 | 468 |
461 // Two windows, w1 normal, w2 maximized. | 469 // Two windows, w1 normal, w2 maximized. |
462 scoped_ptr<Window> w1(CreateTestWindow()); | 470 scoped_ptr<Window> w1(CreateTestWindow()); |
463 w1->SetBounds(gfx::Rect(0, 1, 101, 102)); | 471 const gfx::Rect w1_bounds(0, 1, 101, 102); |
| 472 ShelfLayoutManager* shelf = Shell::GetInstance()->shelf(); |
| 473 const gfx::Rect touches_shelf_bounds( |
| 474 0, shelf->GetIdealBounds().y() - 10, 101, 102); |
| 475 // Move |w1| to overlap the shelf. |
| 476 w1->SetBounds(touches_shelf_bounds); |
| 477 EXPECT_FALSE(GetWindowOverlapsShelf()); |
| 478 |
| 479 // A visible ignored window should not trigger the overlap. |
| 480 scoped_ptr<Window> w_ignored(CreateTestWindow()); |
| 481 w_ignored->SetBounds(touches_shelf_bounds); |
| 482 SetIgnoredByShelf(&(*w_ignored), true); |
| 483 w_ignored->Show(); |
| 484 EXPECT_FALSE(GetWindowOverlapsShelf()); |
| 485 |
| 486 // Make it visible, since visible shelf overlaps should be true. |
464 w1->Show(); | 487 w1->Show(); |
| 488 EXPECT_TRUE(GetWindowOverlapsShelf()); |
465 | 489 |
466 ShelfLayoutManager* shelf = Shell::GetInstance()->shelf(); | 490 wm::ActivateWindow(w1.get()); |
| 491 w1->SetBounds(w1_bounds); |
| 492 w1->Show(); |
| 493 wm::ActivateWindow(w1.get()); |
467 | 494 |
468 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 495 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); |
469 | 496 |
470 // Maximize the window. | 497 // Maximize the window. |
471 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 498 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
472 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); | 499 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); |
473 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 500 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
474 | 501 |
475 // Restore. | 502 // Restore. |
476 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 503 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 wm::ActivateWindow(w1.get()); | 730 wm::ActivateWindow(w1.get()); |
704 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 731 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
705 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 732 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
706 EXPECT_EQ(ShelfLayoutManager::VISIBLE, | 733 EXPECT_EQ(ShelfLayoutManager::VISIBLE, |
707 Shell::GetInstance()->shelf()->visibility_state()); | 734 Shell::GetInstance()->shelf()->visibility_state()); |
708 EXPECT_FALSE(Shell::GetInstance()->launcher()->paints_background()); | 735 EXPECT_FALSE(Shell::GetInstance()->launcher()->paints_background()); |
709 } | 736 } |
710 | 737 |
711 } // namespace internal | 738 } // namespace internal |
712 } // namespace ash | 739 } // namespace ash |
OLD | NEW |