Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Side by Side Diff: ash/wm/workspace/workspace_manager2_unittest.cc

Issue 10987005: Autohide behavior simplified to always/never (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/wm/shelf_types.h ('k') | ash/wm/workspace/workspace_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
454 TEST_F(WorkspaceManager2Test, ShelfStateUpdated) { 454 TEST_F(WorkspaceManager2Test, ShelfStateUpdated) {
455 // Since ShelfLayoutManager queries for mouse location, move the mouse so 455 // Since ShelfLayoutManager queries for mouse location, move the mouse so
456 // it isn't over the shelf. 456 // it isn't over the shelf.
457 aura::test::EventGenerator generator( 457 aura::test::EventGenerator generator(
458 Shell::GetPrimaryRootWindow(), gfx::Point()); 458 Shell::GetPrimaryRootWindow(), gfx::Point());
459 generator.MoveMouseTo(0, 0); 459 generator.MoveMouseTo(0, 0);
460 460
461 scoped_ptr<Window> w1(CreateTestWindow()); 461 scoped_ptr<Window> w1(CreateTestWindow());
462 const gfx::Rect w1_bounds(0, 1, 101, 102); 462 const gfx::Rect w1_bounds(0, 1, 101, 102);
463 ShelfLayoutManager* shelf = Shell::GetInstance()->shelf(); 463 ShelfLayoutManager* shelf = Shell::GetInstance()->shelf();
464 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
464 const gfx::Rect touches_shelf_bounds( 465 const gfx::Rect touches_shelf_bounds(
465 0, shelf->GetIdealBounds().y() - 10, 101, 102); 466 0, shelf->GetIdealBounds().y() - 10, 101, 102);
466 // Move |w1| to overlap the shelf. 467 // Move |w1| to overlap the shelf.
467 w1->SetBounds(touches_shelf_bounds); 468 w1->SetBounds(touches_shelf_bounds);
468 EXPECT_FALSE(GetWindowOverlapsShelf()); 469 EXPECT_FALSE(GetWindowOverlapsShelf());
469 470
470 // A visible ignored window should not trigger the overlap. 471 // A visible ignored window should not trigger the overlap.
471 scoped_ptr<Window> w_ignored(CreateTestWindow()); 472 scoped_ptr<Window> w_ignored(CreateTestWindow());
472 w_ignored->SetBounds(touches_shelf_bounds); 473 w_ignored->SetBounds(touches_shelf_bounds);
473 SetIgnoredByShelf(&(*w_ignored), true); 474 SetIgnoredByShelf(&(*w_ignored), true);
474 w_ignored->Show(); 475 w_ignored->Show();
475 EXPECT_FALSE(GetWindowOverlapsShelf()); 476 EXPECT_FALSE(GetWindowOverlapsShelf());
476 477
477 // Make it visible, since visible shelf overlaps should be true. 478 // Make it visible, since visible shelf overlaps should be true.
478 w1->Show(); 479 w1->Show();
479 EXPECT_TRUE(GetWindowOverlapsShelf()); 480 EXPECT_TRUE(GetWindowOverlapsShelf());
480 481
481 wm::ActivateWindow(w1.get()); 482 wm::ActivateWindow(w1.get());
482 w1->SetBounds(w1_bounds); 483 w1->SetBounds(w1_bounds);
483 w1->Show(); 484 w1->Show();
484 wm::ActivateWindow(w1.get()); 485 wm::ActivateWindow(w1.get());
485 486
486 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 487 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
487 488
488 // Maximize the window. 489 // Maximize the window.
489 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 490 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
490 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 491 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
491 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 492 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
492 493
493 // Restore. 494 // Restore.
494 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 495 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
495 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 496 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
496 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); 497 EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
497 498
498 // Fullscreen. 499 // Fullscreen.
499 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 500 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
500 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); 501 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
501 502
502 // Normal. 503 // Normal.
503 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 504 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
504 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 505 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
505 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); 506 EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
506 EXPECT_FALSE(GetWindowOverlapsShelf()); 507 EXPECT_FALSE(GetWindowOverlapsShelf());
507 508
508 // Move window so it obscures shelf. 509 // Move window so it obscures shelf.
509 w1->SetBounds(touches_shelf_bounds); 510 w1->SetBounds(touches_shelf_bounds);
510 EXPECT_TRUE(GetWindowOverlapsShelf()); 511 EXPECT_TRUE(GetWindowOverlapsShelf());
511 512
512 // Move it back. 513 // Move it back.
513 w1->SetBounds(w1_bounds); 514 w1->SetBounds(w1_bounds);
514 EXPECT_FALSE(GetWindowOverlapsShelf()); 515 EXPECT_FALSE(GetWindowOverlapsShelf());
515 516
516 // Maximize again. 517 // Maximize again.
517 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 518 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
518 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 519 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
519 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 520 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
520 521
521 // Minimize. 522 // Minimize.
522 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); 523 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
523 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 524 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
524 525
525 // Since the restore from minimize will restore to the pre-minimize 526 // Since the restore from minimize will restore to the pre-minimize
526 // state (tested elsewhere), we abandon the current size and restore 527 // state (tested elsewhere), we abandon the current size and restore
527 // rect and set them to the window. 528 // rect and set them to the window.
528 gfx::Rect restore = *GetRestoreBoundsInScreen(w1.get()); 529 gfx::Rect restore = *GetRestoreBoundsInScreen(w1.get());
529 EXPECT_EQ("0,0 800x597", w1->bounds().ToString()); 530 EXPECT_EQ("0,0 800x597", w1->bounds().ToString());
530 EXPECT_EQ("0,1 101x102", restore.ToString()); 531 EXPECT_EQ("0,1 101x102", restore.ToString());
531 ClearRestoreBounds(w1.get()); 532 ClearRestoreBounds(w1.get());
532 w1->SetBounds(restore); 533 w1->SetBounds(restore);
533 534
534 // Restore. 535 // Restore.
535 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 536 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
536 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 537 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
537 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); 538 EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
538 539
539 // Create another window, maximized. 540 // Create another window, maximized.
540 scoped_ptr<Window> w2(CreateTestWindow()); 541 scoped_ptr<Window> w2(CreateTestWindow());
541 w2->SetBounds(gfx::Rect(10, 11, 250, 251)); 542 w2->SetBounds(gfx::Rect(10, 11, 250, 251));
542 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 543 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
543 w2->Show(); 544 w2->Show();
544 wm::ActivateWindow(w2.get()); 545 wm::ActivateWindow(w2.get());
545 EXPECT_EQ(1, active_index()); 546 EXPECT_EQ(1, active_index());
546 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 547 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
547 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 548 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
548 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); 549 EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
549 550
550 // Switch to w1. 551 // Switch to w1.
551 wm::ActivateWindow(w1.get()); 552 wm::ActivateWindow(w1.get());
552 EXPECT_EQ(0, active_index()); 553 EXPECT_EQ(0, active_index());
553 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 554 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
554 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); 555 EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
555 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent( 556 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(
556 w2->parent()).ToString(), 557 w2->parent()).ToString(),
557 w2->bounds().ToString()); 558 w2->bounds().ToString());
558 559
559 // Switch to w2. 560 // Switch to w2.
560 wm::ActivateWindow(w2.get()); 561 wm::ActivateWindow(w2.get());
561 EXPECT_EQ(1, active_index()); 562 EXPECT_EQ(1, active_index());
562 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 563 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
563 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 564 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 w1->Show(); 1032 w1->Show();
1032 wm::ActivateWindow(w1.get()); 1033 wm::ActivateWindow(w1.get());
1033 1034
1034 // The window with the transient parent should get added to the same parent as 1035 // The window with the transient parent should get added to the same parent as
1035 // the normal window. 1036 // the normal window.
1036 EXPECT_EQ(w2->parent(), w1->parent()); 1037 EXPECT_EQ(w2->parent(), w1->parent());
1037 } 1038 }
1038 1039
1039 } // namespace internal 1040 } // namespace internal
1040 } // namespace ash 1041 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/shelf_types.h ('k') | ash/wm/workspace/workspace_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698