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