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

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

Issue 10969076: Revert of AutoHide Behavior (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);
465 const gfx::Rect touches_shelf_bounds( 464 const gfx::Rect touches_shelf_bounds(
466 0, shelf->GetIdealBounds().y() - 10, 101, 102); 465 0, shelf->GetIdealBounds().y() - 10, 101, 102);
467 // Move |w1| to overlap the shelf. 466 // Move |w1| to overlap the shelf.
468 w1->SetBounds(touches_shelf_bounds); 467 w1->SetBounds(touches_shelf_bounds);
469 EXPECT_FALSE(GetWindowOverlapsShelf()); 468 EXPECT_FALSE(GetWindowOverlapsShelf());
470 469
471 // A visible ignored window should not trigger the overlap. 470 // A visible ignored window should not trigger the overlap.
472 scoped_ptr<Window> w_ignored(CreateTestWindow()); 471 scoped_ptr<Window> w_ignored(CreateTestWindow());
473 w_ignored->SetBounds(touches_shelf_bounds); 472 w_ignored->SetBounds(touches_shelf_bounds);
474 SetIgnoredByShelf(&(*w_ignored), true); 473 SetIgnoredByShelf(&(*w_ignored), true);
475 w_ignored->Show(); 474 w_ignored->Show();
476 EXPECT_FALSE(GetWindowOverlapsShelf()); 475 EXPECT_FALSE(GetWindowOverlapsShelf());
477 476
478 // Make it visible, since visible shelf overlaps should be true. 477 // Make it visible, since visible shelf overlaps should be true.
479 w1->Show(); 478 w1->Show();
480 EXPECT_TRUE(GetWindowOverlapsShelf()); 479 EXPECT_TRUE(GetWindowOverlapsShelf());
481 480
482 wm::ActivateWindow(w1.get()); 481 wm::ActivateWindow(w1.get());
483 w1->SetBounds(w1_bounds); 482 w1->SetBounds(w1_bounds);
484 w1->Show(); 483 w1->Show();
485 wm::ActivateWindow(w1.get()); 484 wm::ActivateWindow(w1.get());
486 485
487 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 486 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
488 487
489 // Maximize the window. 488 // Maximize the window.
490 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 489 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
491 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 490 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
492 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 491 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
493 492
494 // Restore. 493 // Restore.
495 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 494 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
496 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 495 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
497 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); 496 EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
498 497
499 // Fullscreen. 498 // Fullscreen.
500 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 499 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
501 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); 500 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
502 501
503 // Normal. 502 // Normal.
504 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 503 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
505 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 504 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
506 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); 505 EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
507 EXPECT_FALSE(GetWindowOverlapsShelf()); 506 EXPECT_FALSE(GetWindowOverlapsShelf());
508 507
509 // Move window so it obscures shelf. 508 // Move window so it obscures shelf.
510 w1->SetBounds(touches_shelf_bounds); 509 w1->SetBounds(touches_shelf_bounds);
511 EXPECT_TRUE(GetWindowOverlapsShelf()); 510 EXPECT_TRUE(GetWindowOverlapsShelf());
512 511
513 // Move it back. 512 // Move it back.
514 w1->SetBounds(w1_bounds); 513 w1->SetBounds(w1_bounds);
515 EXPECT_FALSE(GetWindowOverlapsShelf()); 514 EXPECT_FALSE(GetWindowOverlapsShelf());
516 515
517 // Maximize again. 516 // Maximize again.
518 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 517 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
519 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 518 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
520 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 519 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
521 520
522 // Minimize. 521 // Minimize.
523 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); 522 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
524 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 523 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
525 524
526 // Since the restore from minimize will restore to the pre-minimize 525 // Since the restore from minimize will restore to the pre-minimize
527 // state (tested elsewhere), we abandon the current size and restore 526 // state (tested elsewhere), we abandon the current size and restore
528 // rect and set them to the window. 527 // rect and set them to the window.
529 gfx::Rect restore = *GetRestoreBoundsInScreen(w1.get()); 528 gfx::Rect restore = *GetRestoreBoundsInScreen(w1.get());
530 EXPECT_EQ("0,0 800x597", w1->bounds().ToString()); 529 EXPECT_EQ("0,0 800x597", w1->bounds().ToString());
531 EXPECT_EQ("0,1 101x102", restore.ToString()); 530 EXPECT_EQ("0,1 101x102", restore.ToString());
532 ClearRestoreBounds(w1.get()); 531 ClearRestoreBounds(w1.get());
533 w1->SetBounds(restore); 532 w1->SetBounds(restore);
534 533
535 // Restore. 534 // Restore.
536 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 535 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
537 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 536 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
538 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); 537 EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
539 538
540 // Create another window, maximized. 539 // Create another window, maximized.
541 scoped_ptr<Window> w2(CreateTestWindow()); 540 scoped_ptr<Window> w2(CreateTestWindow());
542 w2->SetBounds(gfx::Rect(10, 11, 250, 251)); 541 w2->SetBounds(gfx::Rect(10, 11, 250, 251));
543 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 542 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
544 w2->Show(); 543 w2->Show();
545 wm::ActivateWindow(w2.get()); 544 wm::ActivateWindow(w2.get());
546 EXPECT_EQ(1, active_index()); 545 EXPECT_EQ(1, active_index());
547 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 546 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
548 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 547 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
549 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); 548 EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
550 549
551 // Switch to w1. 550 // Switch to w1.
552 wm::ActivateWindow(w1.get()); 551 wm::ActivateWindow(w1.get());
553 EXPECT_EQ(0, active_index()); 552 EXPECT_EQ(0, active_index());
554 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 553 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
555 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); 554 EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
556 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent( 555 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(
557 w2->parent()).ToString(), 556 w2->parent()).ToString(),
558 w2->bounds().ToString()); 557 w2->bounds().ToString());
559 558
560 // Switch to w2. 559 // Switch to w2.
561 wm::ActivateWindow(w2.get()); 560 wm::ActivateWindow(w2.get());
562 EXPECT_EQ(1, active_index()); 561 EXPECT_EQ(1, active_index());
563 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 562 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
564 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 563 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 w1->Show(); 1031 w1->Show();
1033 wm::ActivateWindow(w1.get()); 1032 wm::ActivateWindow(w1.get());
1034 1033
1035 // The window with the transient parent should get added to the same parent as 1034 // The window with the transient parent should get added to the same parent as
1036 // the normal window. 1035 // the normal window.
1037 EXPECT_EQ(w2->parent(), w1->parent()); 1036 EXPECT_EQ(w2->parent(), w1->parent());
1038 } 1037 }
1039 1038
1040 } // namespace internal 1039 } // namespace internal
1041 } // namespace ash 1040 } // 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