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/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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 // Since ShelfLayoutManager queries for mouse location, move the mouse so | 464 // Since ShelfLayoutManager queries for mouse location, move the mouse so |
465 // it isn't over the shelf. | 465 // it isn't over the shelf. |
466 aura::test::EventGenerator generator( | 466 aura::test::EventGenerator generator( |
467 Shell::GetPrimaryRootWindow(), gfx::Point()); | 467 Shell::GetPrimaryRootWindow(), gfx::Point()); |
468 generator.MoveMouseTo(0, 0); | 468 generator.MoveMouseTo(0, 0); |
469 | 469 |
470 // Two windows, w1 normal, w2 maximized. | 470 // Two windows, w1 normal, w2 maximized. |
471 scoped_ptr<Window> w1(CreateTestWindow()); | 471 scoped_ptr<Window> w1(CreateTestWindow()); |
472 const gfx::Rect w1_bounds(0, 1, 101, 102); | 472 const gfx::Rect w1_bounds(0, 1, 101, 102); |
473 ShelfLayoutManager* shelf = Shell::GetInstance()->shelf(); | 473 ShelfLayoutManager* shelf = Shell::GetInstance()->shelf(); |
| 474 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
474 const gfx::Rect touches_shelf_bounds( | 475 const gfx::Rect touches_shelf_bounds( |
475 0, shelf->GetIdealBounds().y() - 10, 101, 102); | 476 0, shelf->GetIdealBounds().y() - 10, 101, 102); |
476 // Move |w1| to overlap the shelf. | 477 // Move |w1| to overlap the shelf. |
477 w1->SetBounds(touches_shelf_bounds); | 478 w1->SetBounds(touches_shelf_bounds); |
478 EXPECT_FALSE(GetWindowOverlapsShelf()); | 479 EXPECT_FALSE(GetWindowOverlapsShelf()); |
479 | 480 |
480 // A visible ignored window should not trigger the overlap. | 481 // A visible ignored window should not trigger the overlap. |
481 scoped_ptr<Window> w_ignored(CreateTestWindow()); | 482 scoped_ptr<Window> w_ignored(CreateTestWindow()); |
482 w_ignored->SetBounds(touches_shelf_bounds); | 483 w_ignored->SetBounds(touches_shelf_bounds); |
483 SetIgnoredByShelf(&(*w_ignored), true); | 484 SetIgnoredByShelf(&(*w_ignored), true); |
484 w_ignored->Show(); | 485 w_ignored->Show(); |
485 EXPECT_FALSE(GetWindowOverlapsShelf()); | 486 EXPECT_FALSE(GetWindowOverlapsShelf()); |
486 | 487 |
487 // Make it visible, since visible shelf overlaps should be true. | 488 // Make it visible, since visible shelf overlaps should be true. |
488 w1->Show(); | 489 w1->Show(); |
489 EXPECT_TRUE(GetWindowOverlapsShelf()); | 490 EXPECT_TRUE(GetWindowOverlapsShelf()); |
490 | 491 |
491 wm::ActivateWindow(w1.get()); | 492 wm::ActivateWindow(w1.get()); |
492 w1->SetBounds(w1_bounds); | 493 w1->SetBounds(w1_bounds); |
493 w1->Show(); | 494 w1->Show(); |
494 wm::ActivateWindow(w1.get()); | 495 wm::ActivateWindow(w1.get()); |
495 | 496 |
496 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 497 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); |
497 | 498 |
498 // Maximize the window. | 499 // Maximize the window. |
499 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 500 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
500 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); | 501 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); |
501 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 502 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
502 | 503 |
503 // Restore. | 504 // Restore. |
504 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 505 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
505 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 506 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); |
506 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); | 507 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); |
507 | 508 |
508 // Fullscreen. | 509 // Fullscreen. |
509 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 510 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
510 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); | 511 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); |
511 | 512 |
512 // Normal. | 513 // Normal. |
513 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 514 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
514 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 515 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); |
515 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); | 516 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); |
516 | 517 |
517 // Maximize again. | 518 // Maximize again. |
518 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 519 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
519 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); | 520 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); |
520 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 521 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
521 | 522 |
522 // Minimize. | 523 // Minimize. |
523 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 524 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
524 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 525 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); |
525 | 526 |
526 // Restore. | 527 // Restore. |
527 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 528 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
528 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 529 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); |
529 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); | 530 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); |
530 | 531 |
531 // Create another window, maximized. | 532 // Create another window, maximized. |
532 scoped_ptr<Window> w2(CreateTestWindow()); | 533 scoped_ptr<Window> w2(CreateTestWindow()); |
533 w2->SetBounds(gfx::Rect(10, 11, 250, 251)); | 534 w2->SetBounds(gfx::Rect(10, 11, 250, 251)); |
534 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 535 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
535 w2->Show(); | 536 w2->Show(); |
536 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); | 537 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); |
537 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 538 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
538 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); | 539 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); |
539 | 540 |
540 // Switch to w1. | 541 // Switch to w1. |
541 w1->Show(); | 542 w1->Show(); |
542 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 543 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); |
543 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); | 544 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); |
544 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(w2.get()).ToString(), | 545 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(w2.get()).ToString(), |
545 w2->bounds().ToString()); | 546 w2->bounds().ToString()); |
546 | 547 |
547 // Switch to w2. | 548 // Switch to w2. |
548 w2->Show(); | 549 w2->Show(); |
549 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); | 550 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); |
550 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 551 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
551 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); | 552 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); |
552 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(w2.get()).ToString(), | 553 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(w2.get()).ToString(), |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 wm::ActivateWindow(w1.get()); | 732 wm::ActivateWindow(w1.get()); |
732 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 733 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
733 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 734 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
734 EXPECT_EQ(ShelfLayoutManager::VISIBLE, | 735 EXPECT_EQ(ShelfLayoutManager::VISIBLE, |
735 Shell::GetInstance()->shelf()->visibility_state()); | 736 Shell::GetInstance()->shelf()->visibility_state()); |
736 EXPECT_FALSE(Shell::GetInstance()->launcher()->paints_background()); | 737 EXPECT_FALSE(Shell::GetInstance()->launcher()->paints_background()); |
737 } | 738 } |
738 | 739 |
739 } // namespace internal | 740 } // namespace internal |
740 } // namespace ash | 741 } // namespace ash |
OLD | NEW |