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_manager2.h" | 5 #include "ash/wm/workspace/workspace_manager2.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/screen_ash.h" | 8 #include "ash/screen_ash.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 // updated. | 454 // updated. |
455 TEST_F(WorkspaceManager2Test, ShelfStateUpdated) { | 455 TEST_F(WorkspaceManager2Test, ShelfStateUpdated) { |
456 // Since ShelfLayoutManager queries for mouse location, move the mouse so | 456 // Since ShelfLayoutManager queries for mouse location, move the mouse so |
457 // it isn't over the shelf. | 457 // it isn't over the shelf. |
458 aura::test::EventGenerator generator( | 458 aura::test::EventGenerator generator( |
459 Shell::GetPrimaryRootWindow(), gfx::Point()); | 459 Shell::GetPrimaryRootWindow(), gfx::Point()); |
460 generator.MoveMouseTo(0, 0); | 460 generator.MoveMouseTo(0, 0); |
461 | 461 |
462 scoped_ptr<Window> w1(CreateTestWindow()); | 462 scoped_ptr<Window> w1(CreateTestWindow()); |
463 const gfx::Rect w1_bounds(0, 1, 101, 102); | 463 const gfx::Rect w1_bounds(0, 1, 101, 102); |
| 464 ShelfLayoutManager* shelf = Shell::GetInstance()->shelf(); |
| 465 const gfx::Rect touches_shelf_bounds( |
| 466 0, shelf->GetIdealBounds().y() - 10, 101, 102); |
| 467 // Move |w1| to overlap the shelf. |
| 468 w1->SetBounds(touches_shelf_bounds); |
| 469 EXPECT_FALSE(GetWindowOverlapsShelf()); |
| 470 |
| 471 // Make it visible, since visible shelf overlaps should be true. |
| 472 w1->Show(); |
| 473 EXPECT_TRUE(GetWindowOverlapsShelf()); |
| 474 |
| 475 wm::ActivateWindow(w1.get()); |
464 w1->SetBounds(w1_bounds); | 476 w1->SetBounds(w1_bounds); |
465 w1->Show(); | 477 w1->Show(); |
466 wm::ActivateWindow(w1.get()); | 478 wm::ActivateWindow(w1.get()); |
467 | 479 |
468 ShelfLayoutManager* shelf = Shell::GetInstance()->shelf(); | |
469 | |
470 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 480 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); |
471 | 481 |
472 // Maximize the window. | 482 // Maximize the window. |
473 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 483 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
474 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); | 484 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); |
475 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 485 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
476 | 486 |
477 // Restore. | 487 // Restore. |
478 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 488 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
479 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 489 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); |
480 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); | 490 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); |
481 | 491 |
482 // Fullscreen. | 492 // Fullscreen. |
483 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 493 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
484 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); | 494 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); |
485 | 495 |
486 // Normal. | 496 // Normal. |
487 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 497 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
488 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 498 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); |
489 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); | 499 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); |
490 EXPECT_FALSE(GetWindowOverlapsShelf()); | 500 EXPECT_FALSE(GetWindowOverlapsShelf()); |
491 | 501 |
492 // Move window so it obscures shelf. | 502 // Move window so it obscures shelf. |
493 const gfx::Rect touches_shelf_bounds( | |
494 0, shelf->GetIdealBounds().y() - 10, 101, 102); | |
495 w1->SetBounds(touches_shelf_bounds); | 503 w1->SetBounds(touches_shelf_bounds); |
496 EXPECT_TRUE(GetWindowOverlapsShelf()); | 504 EXPECT_TRUE(GetWindowOverlapsShelf()); |
497 | 505 |
498 // Move it back. | 506 // Move it back. |
499 w1->SetBounds(w1_bounds); | 507 w1->SetBounds(w1_bounds); |
500 EXPECT_FALSE(GetWindowOverlapsShelf()); | 508 EXPECT_FALSE(GetWindowOverlapsShelf()); |
501 | 509 |
502 // Maximize again. | 510 // Maximize again. |
503 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 511 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
504 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); | 512 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 EXPECT_FALSE(w1->IsVisible()); | 856 EXPECT_FALSE(w1->IsVisible()); |
849 | 857 |
850 // Close |w2|. | 858 // Close |w2|. |
851 w2.reset(); | 859 w2.reset(); |
852 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity()); | 860 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity()); |
853 EXPECT_TRUE(w1->IsVisible()); | 861 EXPECT_TRUE(w1->IsVisible()); |
854 } | 862 } |
855 | 863 |
856 } // namespace internal | 864 } // namespace internal |
857 } // namespace ash | 865 } // namespace ash |
OLD | NEW |