Chromium Code Reviews| 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/shelf/shelf_layout_manager.h" | 5 #include "ash/shelf/shelf_layout_manager.h" |
| 6 | 6 |
| 7 #include "ash/accelerators/accelerator_controller.h" | 7 #include "ash/accelerators/accelerator_controller.h" |
| 8 #include "ash/accelerators/accelerator_table.h" | 8 #include "ash/accelerators/accelerator_table.h" |
| 9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
| 10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 #endif | 52 #endif |
| 53 | 53 |
| 54 namespace ash { | 54 namespace ash { |
| 55 namespace { | 55 namespace { |
| 56 | 56 |
| 57 void StepWidgetLayerAnimatorToEnd(views::Widget* widget) { | 57 void StepWidgetLayerAnimatorToEnd(views::Widget* widget) { |
| 58 widget->GetNativeView()->layer()->GetAnimator()->Step( | 58 widget->GetNativeView()->layer()->GetAnimator()->Step( |
| 59 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1)); | 59 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1)); |
| 60 } | 60 } |
| 61 | 61 |
| 62 Shelf* GetShelf() { | |
| 63 return Shelf::ForPrimaryDisplay(); | |
| 64 } | |
| 65 | |
| 62 ShelfWidget* GetShelfWidget() { | 66 ShelfWidget* GetShelfWidget() { |
| 63 return Shell::GetPrimaryRootWindowController()->shelf_widget(); | 67 return Shell::GetPrimaryRootWindowController()->shelf_widget(); |
|
msw
2016/06/01 00:53:24
optional nit: return GetShelf()->shelf_widget();?
James Cook
2016/06/01 15:53:06
Done.
| |
| 64 } | 68 } |
| 65 | 69 |
| 66 ShelfLayoutManager* GetShelfLayoutManager() { | 70 ShelfLayoutManager* GetShelfLayoutManager() { |
| 67 return Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); | 71 return Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); |
| 68 } | 72 } |
| 69 | 73 |
| 70 SystemTray* GetSystemTray() { | 74 SystemTray* GetSystemTray() { |
| 71 return Shell::GetPrimaryRootWindowController()->GetSystemTray(); | 75 return Shell::GetPrimaryRootWindowController()->GetSystemTray(); |
| 72 } | 76 } |
| 73 | 77 |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 313 | 317 |
| 314 DISALLOW_COPY_AND_ASSIGN(TestItem); | 318 DISALLOW_COPY_AND_ASSIGN(TestItem); |
| 315 }; | 319 }; |
| 316 | 320 |
| 317 } // namespace | 321 } // namespace |
| 318 | 322 |
| 319 class ShelfLayoutManagerTest : public ash::test::AshTestBase { | 323 class ShelfLayoutManagerTest : public ash::test::AshTestBase { |
| 320 public: | 324 public: |
| 321 ShelfLayoutManagerTest() {} | 325 ShelfLayoutManagerTest() {} |
| 322 | 326 |
| 323 void SetState(ShelfLayoutManager* shelf, | 327 void SetState(ShelfLayoutManager* layout_manager, |
|
msw
2016/06/01 00:53:24
nit: remove this and inline ShelfLayoutManager::Se
James Cook
2016/06/01 15:53:06
ShelfLayoutManager::SetState() is private, so inli
msw
2016/06/01 17:30:07
Acknowledged.
| |
| 324 ShelfVisibilityState state) { | 328 ShelfVisibilityState state) { |
| 325 shelf->SetState(state); | 329 layout_manager->SetState(state); |
| 326 } | 330 } |
| 327 | 331 |
| 328 void UpdateAutoHideStateNow() { | 332 void UpdateAutoHideStateNow() { |
| 329 GetShelfLayoutManager()->UpdateAutoHideStateNow(); | 333 GetShelfLayoutManager()->UpdateAutoHideStateNow(); |
| 330 } | 334 } |
| 331 | 335 |
| 332 aura::Window* CreateTestWindow() { | 336 aura::Window* CreateTestWindow() { |
| 333 aura::Window* window = new aura::Window(nullptr); | 337 aura::Window* window = new aura::Window(nullptr); |
| 334 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 338 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 335 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 339 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 378 Shell::GetInstance()->session_state_delegate()->UnlockScreen(); | 382 Shell::GetInstance()->session_state_delegate()->UnlockScreen(); |
| 379 // The test session state delegate does not fire the lock state change. | 383 // The test session state delegate does not fire the lock state change. |
| 380 Shell::GetInstance()->OnLockStateChanged(false); | 384 Shell::GetInstance()->OnLockStateChanged(false); |
| 381 } | 385 } |
| 382 | 386 |
| 383 private: | 387 private: |
| 384 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManagerTest); | 388 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManagerTest); |
| 385 }; | 389 }; |
| 386 | 390 |
| 387 void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) { | 391 void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) { |
| 388 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 392 Shelf* shelf = GetShelf(); |
| 389 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 393 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 390 views::Widget* widget = new views::Widget; | 394 views::Widget* widget = new views::Widget; |
| 391 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 395 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 392 params.bounds = gfx::Rect(0, 0, 200, 200); | 396 params.bounds = gfx::Rect(0, 0, 200, 200); |
| 393 params.context = CurrentContext(); | 397 params.context = CurrentContext(); |
| 394 widget->Init(params); | 398 widget->Init(params); |
| 395 widget->Show(); | 399 widget->Show(); |
| 396 widget->Maximize(); | 400 widget->Maximize(); |
| 397 | 401 |
| 398 // The time delta should be large enough to prevent accidental fling creation. | 402 // The time delta should be large enough to prevent accidental fling creation. |
| 399 const base::TimeDelta kTimeDelta = base::TimeDelta::FromMilliseconds(100); | 403 const base::TimeDelta kTimeDelta = base::TimeDelta::FromMilliseconds(100); |
| 400 | 404 |
| 401 aura::Window* window = widget->GetNativeWindow(); | 405 aura::Window* window = widget->GetNativeWindow(); |
| 402 shelf->LayoutShelf(); | 406 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 407 layout_manager->LayoutShelf(); | |
| 403 | 408 |
| 404 gfx::Rect shelf_shown = GetShelfWidget()->GetWindowBoundsInScreen(); | 409 gfx::Rect shelf_shown = GetShelfWidget()->GetWindowBoundsInScreen(); |
| 405 gfx::Rect bounds_shelf = window->bounds(); | 410 gfx::Rect bounds_shelf = window->bounds(); |
| 406 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 411 EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state()); |
| 407 | 412 |
| 408 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 413 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 409 shelf->LayoutShelf(); | 414 layout_manager->LayoutShelf(); |
| 410 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 415 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 411 | 416 |
| 412 gfx::Rect bounds_noshelf = window->bounds(); | 417 gfx::Rect bounds_noshelf = window->bounds(); |
| 413 gfx::Rect shelf_hidden = GetShelfWidget()->GetWindowBoundsInScreen(); | 418 gfx::Rect shelf_hidden = GetShelfWidget()->GetWindowBoundsInScreen(); |
| 414 | 419 |
| 415 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 420 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 416 shelf->LayoutShelf(); | 421 layout_manager->LayoutShelf(); |
| 417 | 422 |
| 418 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 423 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 419 const int kNumScrollSteps = 4; | 424 const int kNumScrollSteps = 4; |
| 420 ShelfDragCallback handler(shelf_hidden, shelf_shown); | 425 ShelfDragCallback handler(shelf_hidden, shelf_shown); |
| 421 | 426 |
| 422 // Swipe up on the shelf. This should not change any state. | 427 // Swipe up on the shelf. This should not change any state. |
| 423 gfx::Point start = GetShelfWidget()->GetWindowBoundsInScreen().CenterPoint(); | 428 gfx::Point start = GetShelfWidget()->GetWindowBoundsInScreen().CenterPoint(); |
| 424 gfx::Point end = start + delta; | 429 gfx::Point end = start + delta; |
| 425 | 430 |
| 426 // Swipe down on the shelf to hide it. | 431 // Swipe down on the shelf to hide it. |
| 427 generator.GestureScrollSequenceWithCallback( | 432 generator.GestureScrollSequenceWithCallback( |
| 428 start, | 433 start, |
| 429 end, | 434 end, |
| 430 kTimeDelta, | 435 kTimeDelta, |
| 431 kNumScrollSteps, | 436 kNumScrollSteps, |
| 432 base::Bind(&ShelfDragCallback::ProcessScroll, | 437 base::Bind(&ShelfDragCallback::ProcessScroll, |
| 433 base::Unretained(&handler))); | 438 base::Unretained(&handler))); |
| 434 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 439 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state()); |
| 435 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 440 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 436 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 441 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
| 437 EXPECT_NE(bounds_shelf.ToString(), window->bounds().ToString()); | 442 EXPECT_NE(bounds_shelf.ToString(), window->bounds().ToString()); |
| 438 EXPECT_NE(shelf_shown.ToString(), | 443 EXPECT_NE(shelf_shown.ToString(), |
| 439 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 444 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 440 | 445 |
| 441 // Swipe up to show the shelf. | 446 // Swipe up to show the shelf. |
| 442 generator.GestureScrollSequenceWithCallback( | 447 generator.GestureScrollSequenceWithCallback( |
| 443 end, | 448 end, |
| 444 start, | 449 start, |
| 445 kTimeDelta, | 450 kTimeDelta, |
| 446 kNumScrollSteps, | 451 kNumScrollSteps, |
| 447 base::Bind(&ShelfDragCallback::ProcessScroll, | 452 base::Bind(&ShelfDragCallback::ProcessScroll, |
| 448 base::Unretained(&handler))); | 453 base::Unretained(&handler))); |
| 449 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 454 EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state()); |
| 450 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); | 455 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); |
| 451 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); | 456 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); |
| 452 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), | 457 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), |
| 453 GetShelfWidget()->GetWindowBoundsInScreen()); | 458 GetShelfWidget()->GetWindowBoundsInScreen()); |
| 454 EXPECT_EQ(shelf_shown.ToString(), | 459 EXPECT_EQ(shelf_shown.ToString(), |
| 455 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 460 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 456 | 461 |
| 457 // Swipe up again. The shelf should hide. | 462 // Swipe up again. The shelf should hide. |
| 458 end = start - delta; | 463 end = start - delta; |
| 459 generator.GestureScrollSequenceWithCallback( | 464 generator.GestureScrollSequenceWithCallback( |
| 460 start, | 465 start, |
| 461 end, | 466 end, |
| 462 kTimeDelta, | 467 kTimeDelta, |
| 463 kNumScrollSteps, | 468 kNumScrollSteps, |
| 464 base::Bind(&ShelfDragCallback::ProcessScroll, | 469 base::Bind(&ShelfDragCallback::ProcessScroll, |
| 465 base::Unretained(&handler))); | 470 base::Unretained(&handler))); |
| 466 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 471 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state()); |
| 467 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 472 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 468 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 473 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
| 469 EXPECT_EQ(shelf_hidden.ToString(), | 474 EXPECT_EQ(shelf_hidden.ToString(), |
| 470 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 475 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 471 | 476 |
| 472 // Swipe up yet again to show it. | 477 // Swipe up yet again to show it. |
| 473 end = start + delta; | 478 end = start + delta; |
| 474 generator.GestureScrollSequenceWithCallback( | 479 generator.GestureScrollSequenceWithCallback( |
| 475 end, | 480 end, |
| 476 start, | 481 start, |
| 477 kTimeDelta, | 482 kTimeDelta, |
| 478 kNumScrollSteps, | 483 kNumScrollSteps, |
| 479 base::Bind(&ShelfDragCallback::ProcessScroll, | 484 base::Bind(&ShelfDragCallback::ProcessScroll, |
| 480 base::Unretained(&handler))); | 485 base::Unretained(&handler))); |
| 481 | 486 |
| 482 // Swipe down very little. It shouldn't change any state. | 487 // Swipe down very little. It shouldn't change any state. |
| 483 if (GetShelfLayoutManager()->IsHorizontalAlignment()) | 488 if (GetShelfLayoutManager()->IsHorizontalAlignment()) |
| 484 end.set_y(start.y() + shelf_shown.height() * 3 / 10); | 489 end.set_y(start.y() + shelf_shown.height() * 3 / 10); |
| 485 else if (wm::SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment()) | 490 else if (wm::SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment()) |
| 486 end.set_x(start.x() - shelf_shown.width() * 3 / 10); | 491 end.set_x(start.x() - shelf_shown.width() * 3 / 10); |
| 487 else if (wm::SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment()) | 492 else if (wm::SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment()) |
| 488 end.set_x(start.x() + shelf_shown.width() * 3 / 10); | 493 end.set_x(start.x() + shelf_shown.width() * 3 / 10); |
| 489 generator.GestureScrollSequence(start, end, kTimeDelta, 5); | 494 generator.GestureScrollSequence(start, end, kTimeDelta, 5); |
| 490 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 495 EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state()); |
| 491 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); | 496 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); |
| 492 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); | 497 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); |
| 493 EXPECT_EQ(shelf_shown.ToString(), | 498 EXPECT_EQ(shelf_shown.ToString(), |
| 494 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 499 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 495 | 500 |
| 496 // Swipe down again to hide. | 501 // Swipe down again to hide. |
| 497 end = start + delta; | 502 end = start + delta; |
| 498 generator.GestureScrollSequenceWithCallback( | 503 generator.GestureScrollSequenceWithCallback( |
| 499 start, | 504 start, |
| 500 end, | 505 end, |
| 501 kTimeDelta, | 506 kTimeDelta, |
| 502 kNumScrollSteps, | 507 kNumScrollSteps, |
| 503 base::Bind(&ShelfDragCallback::ProcessScroll, | 508 base::Bind(&ShelfDragCallback::ProcessScroll, |
| 504 base::Unretained(&handler))); | 509 base::Unretained(&handler))); |
| 505 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 510 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state()); |
| 506 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 511 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 507 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 512 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
| 508 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), gfx::Rect()); | 513 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), gfx::Rect()); |
| 509 EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString()); | 514 EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString()); |
| 510 EXPECT_EQ(shelf_hidden.ToString(), | 515 EXPECT_EQ(shelf_hidden.ToString(), |
| 511 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 516 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 512 | 517 |
| 513 // Swipe up in extended hit region to show it. | 518 // Swipe up in extended hit region to show it. |
| 514 gfx::Point extended_start = start; | 519 gfx::Point extended_start = start; |
| 515 if (GetShelfLayoutManager()->IsHorizontalAlignment()) | 520 if (GetShelfLayoutManager()->IsHorizontalAlignment()) |
| 516 extended_start.set_y(GetShelfWidget()->GetWindowBoundsInScreen().y() -1); | 521 extended_start.set_y(GetShelfWidget()->GetWindowBoundsInScreen().y() -1); |
| 517 else if (wm::SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment()) | 522 else if (wm::SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment()) |
| 518 extended_start.set_x( | 523 extended_start.set_x( |
| 519 GetShelfWidget()->GetWindowBoundsInScreen().right() + 1); | 524 GetShelfWidget()->GetWindowBoundsInScreen().right() + 1); |
| 520 else if (wm::SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment()) | 525 else if (wm::SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment()) |
| 521 extended_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().x() - 1); | 526 extended_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().x() - 1); |
| 522 end = extended_start - delta; | 527 end = extended_start - delta; |
| 523 generator.GestureScrollSequenceWithCallback( | 528 generator.GestureScrollSequenceWithCallback( |
| 524 extended_start, | 529 extended_start, |
| 525 end, | 530 end, |
| 526 kTimeDelta, | 531 kTimeDelta, |
| 527 kNumScrollSteps, | 532 kNumScrollSteps, |
| 528 base::Bind(&ShelfDragCallback::ProcessScroll, | 533 base::Bind(&ShelfDragCallback::ProcessScroll, |
| 529 base::Unretained(&handler))); | 534 base::Unretained(&handler))); |
| 530 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 535 EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state()); |
| 531 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); | 536 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); |
| 532 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); | 537 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); |
| 533 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), | 538 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), |
| 534 GetShelfWidget()->GetWindowBoundsInScreen()); | 539 GetShelfWidget()->GetWindowBoundsInScreen()); |
| 535 EXPECT_EQ(shelf_shown.ToString(), | 540 EXPECT_EQ(shelf_shown.ToString(), |
| 536 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 541 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 537 | 542 |
| 538 // Swipe down again to hide. | 543 // Swipe down again to hide. |
| 539 end = start + delta; | 544 end = start + delta; |
| 540 generator.GestureScrollSequenceWithCallback( | 545 generator.GestureScrollSequenceWithCallback( |
| 541 start, | 546 start, |
| 542 end, | 547 end, |
| 543 kTimeDelta, | 548 kTimeDelta, |
| 544 kNumScrollSteps, | 549 kNumScrollSteps, |
| 545 base::Bind(&ShelfDragCallback::ProcessScroll, | 550 base::Bind(&ShelfDragCallback::ProcessScroll, |
| 546 base::Unretained(&handler))); | 551 base::Unretained(&handler))); |
| 547 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 552 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state()); |
| 548 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 553 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 549 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 554 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
| 550 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), gfx::Rect()); | 555 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), gfx::Rect()); |
| 551 EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString()); | 556 EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString()); |
| 552 EXPECT_EQ(shelf_hidden.ToString(), | 557 EXPECT_EQ(shelf_hidden.ToString(), |
| 553 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 558 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 554 | 559 |
| 555 // Swipe up outside the hit area. This should not change anything. | 560 // Swipe up outside the hit area. This should not change anything. |
| 556 gfx::Point outside_start = gfx::Point( | 561 gfx::Point outside_start = gfx::Point( |
| 557 (GetShelfWidget()->GetWindowBoundsInScreen().x() + | 562 (GetShelfWidget()->GetWindowBoundsInScreen().x() + |
| 558 GetShelfWidget()->GetWindowBoundsInScreen().right())/2, | 563 GetShelfWidget()->GetWindowBoundsInScreen().right())/2, |
| 559 GetShelfWidget()->GetWindowBoundsInScreen().y() - 50); | 564 GetShelfWidget()->GetWindowBoundsInScreen().y() - 50); |
| 560 end = outside_start + delta; | 565 end = outside_start + delta; |
| 561 generator.GestureScrollSequence( | 566 generator.GestureScrollSequence( |
| 562 outside_start, end, kTimeDelta, kNumScrollSteps); | 567 outside_start, end, kTimeDelta, kNumScrollSteps); |
| 563 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 568 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state()); |
| 564 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 569 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 565 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 570 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
| 566 EXPECT_EQ(shelf_hidden.ToString(), | 571 EXPECT_EQ(shelf_hidden.ToString(), |
| 567 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 572 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 568 | 573 |
| 569 // Swipe up from below the shelf where a bezel would be, this should show the | 574 // Swipe up from below the shelf where a bezel would be, this should show the |
| 570 // shelf. | 575 // shelf. |
| 571 gfx::Point below_start = start; | 576 gfx::Point below_start = start; |
| 572 if (GetShelfLayoutManager()->IsHorizontalAlignment()) | 577 if (GetShelfLayoutManager()->IsHorizontalAlignment()) |
| 573 below_start.set_y(GetShelfWidget()->GetWindowBoundsInScreen().bottom() + 1); | 578 below_start.set_y(GetShelfWidget()->GetWindowBoundsInScreen().bottom() + 1); |
| 574 else if (wm::SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment()) | 579 else if (wm::SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment()) |
| 575 below_start.set_x( | 580 below_start.set_x( |
| 576 GetShelfWidget()->GetWindowBoundsInScreen().x() - 1); | 581 GetShelfWidget()->GetWindowBoundsInScreen().x() - 1); |
| 577 else if (wm::SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment()) | 582 else if (wm::SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment()) |
| 578 below_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().right() + 1); | 583 below_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().right() + 1); |
| 579 end = below_start - delta; | 584 end = below_start - delta; |
| 580 generator.GestureScrollSequence( | 585 generator.GestureScrollSequence( |
| 581 below_start, end, kTimeDelta, kNumScrollSteps); | 586 below_start, end, kTimeDelta, kNumScrollSteps); |
| 582 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 587 EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state()); |
| 583 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); | 588 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); |
| 584 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); | 589 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); |
| 585 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), | 590 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), |
| 586 GetShelfWidget()->GetWindowBoundsInScreen()); | 591 GetShelfWidget()->GetWindowBoundsInScreen()); |
| 587 EXPECT_EQ(shelf_shown.ToString(), | 592 EXPECT_EQ(shelf_shown.ToString(), |
| 588 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 593 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 589 | 594 |
| 590 // Swipe down again to hide. | 595 // Swipe down again to hide. |
| 591 end = start + delta; | 596 end = start + delta; |
| 592 generator.GestureScrollSequenceWithCallback( | 597 generator.GestureScrollSequenceWithCallback( |
| 593 start, | 598 start, |
| 594 end, | 599 end, |
| 595 kTimeDelta, | 600 kTimeDelta, |
| 596 kNumScrollSteps, | 601 kNumScrollSteps, |
| 597 base::Bind(&ShelfDragCallback::ProcessScroll, | 602 base::Bind(&ShelfDragCallback::ProcessScroll, |
| 598 base::Unretained(&handler))); | 603 base::Unretained(&handler))); |
| 599 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 604 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state()); |
| 600 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 605 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 601 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 606 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
| 602 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), gfx::Rect()); | 607 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), gfx::Rect()); |
| 603 EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString()); | 608 EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString()); |
| 604 EXPECT_EQ(shelf_hidden.ToString(), | 609 EXPECT_EQ(shelf_hidden.ToString(), |
| 605 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 610 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 606 | 611 |
| 607 // Put |widget| into fullscreen. Set the shelf to be auto hidden when |widget| | 612 // Put |widget| into fullscreen. Set the shelf to be auto hidden when |widget| |
| 608 // is fullscreen. (eg browser immersive fullscreen). | 613 // is fullscreen. (eg browser immersive fullscreen). |
| 609 widget->SetFullscreen(true); | 614 widget->SetFullscreen(true); |
| 610 wm::GetWindowState(window)->set_hide_shelf_when_fullscreen(false); | 615 wm::GetWindowState(window)->set_hide_shelf_when_fullscreen(false); |
| 611 shelf->UpdateVisibilityState(); | 616 layout_manager->UpdateVisibilityState(); |
| 612 | 617 |
| 613 gfx::Rect bounds_fullscreen = window->bounds(); | 618 gfx::Rect bounds_fullscreen = window->bounds(); |
| 614 EXPECT_TRUE(widget->IsFullscreen()); | 619 EXPECT_TRUE(widget->IsFullscreen()); |
| 615 EXPECT_NE(bounds_noshelf.ToString(), bounds_fullscreen.ToString()); | 620 EXPECT_NE(bounds_noshelf.ToString(), bounds_fullscreen.ToString()); |
| 616 | 621 |
| 617 // Swipe up. This should show the shelf. | 622 // Swipe up. This should show the shelf. |
| 618 end = below_start - delta; | 623 end = below_start - delta; |
| 619 generator.GestureScrollSequenceWithCallback( | 624 generator.GestureScrollSequenceWithCallback( |
| 620 below_start, | 625 below_start, |
| 621 end, | 626 end, |
| 622 kTimeDelta, | 627 kTimeDelta, |
| 623 kNumScrollSteps, | 628 kNumScrollSteps, |
| 624 base::Bind(&ShelfDragCallback::ProcessScroll, | 629 base::Bind(&ShelfDragCallback::ProcessScroll, |
| 625 base::Unretained(&handler))); | 630 base::Unretained(&handler))); |
| 626 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 631 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state()); |
| 627 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 632 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state()); |
| 628 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); | 633 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); |
| 629 EXPECT_EQ(shelf_shown.ToString(), | 634 EXPECT_EQ(shelf_shown.ToString(), |
| 630 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 635 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 631 EXPECT_EQ(bounds_fullscreen.ToString(), window->bounds().ToString()); | 636 EXPECT_EQ(bounds_fullscreen.ToString(), window->bounds().ToString()); |
| 632 | 637 |
| 633 // Swipe up again. This should hide the shelf. | 638 // Swipe up again. This should hide the shelf. |
| 634 generator.GestureScrollSequenceWithCallback( | 639 generator.GestureScrollSequenceWithCallback( |
| 635 below_start, | 640 below_start, |
| 636 end, | 641 end, |
| 637 kTimeDelta, | 642 kTimeDelta, |
| 638 kNumScrollSteps, | 643 kNumScrollSteps, |
| 639 base::Bind(&ShelfDragCallback::ProcessScroll, | 644 base::Bind(&ShelfDragCallback::ProcessScroll, |
| 640 base::Unretained(&handler))); | 645 base::Unretained(&handler))); |
| 641 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 646 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state()); |
| 642 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 647 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 643 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 648 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
| 644 EXPECT_EQ(shelf_hidden.ToString(), | 649 EXPECT_EQ(shelf_hidden.ToString(), |
| 645 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 650 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 646 EXPECT_EQ(bounds_fullscreen.ToString(), window->bounds().ToString()); | 651 EXPECT_EQ(bounds_fullscreen.ToString(), window->bounds().ToString()); |
| 647 | 652 |
| 648 // Set the shelf to be hidden when |widget| is fullscreen. (eg tab fullscreen | 653 // Set the shelf to be hidden when |widget| is fullscreen. (eg tab fullscreen |
| 649 // with or without immersive browser fullscreen). | 654 // with or without immersive browser fullscreen). |
| 650 wm::GetWindowState(window)->set_hide_shelf_when_fullscreen(true); | 655 wm::GetWindowState(window)->set_hide_shelf_when_fullscreen(true); |
| 651 shelf->UpdateVisibilityState(); | 656 layout_manager->UpdateVisibilityState(); |
| 652 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); | 657 EXPECT_EQ(SHELF_HIDDEN, layout_manager->visibility_state()); |
| 653 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 658 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
| 654 | 659 |
| 655 // Swipe-up. This should not change anything. | 660 // Swipe-up. This should not change anything. |
| 656 end = start - delta; | 661 end = start - delta; |
| 657 generator.GestureScrollSequenceWithCallback( | 662 generator.GestureScrollSequenceWithCallback( |
| 658 below_start, | 663 below_start, |
| 659 end, | 664 end, |
| 660 kTimeDelta, | 665 kTimeDelta, |
| 661 kNumScrollSteps, | 666 kNumScrollSteps, |
| 662 base::Bind(&ShelfDragCallback::ProcessScroll, | 667 base::Bind(&ShelfDragCallback::ProcessScroll, |
| 663 base::Unretained(&handler))); | 668 base::Unretained(&handler))); |
| 664 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); | 669 EXPECT_EQ(SHELF_HIDDEN, layout_manager->visibility_state()); |
| 665 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 670 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
| 666 EXPECT_EQ(bounds_fullscreen.ToString(), window->bounds().ToString()); | 671 EXPECT_EQ(bounds_fullscreen.ToString(), window->bounds().ToString()); |
| 667 | 672 |
| 668 // Close actually, otherwise further event may be affected since widget | 673 // Close actually, otherwise further event may be affected since widget |
| 669 // is fullscreen status. | 674 // is fullscreen status. |
| 670 widget->Close(); | 675 widget->Close(); |
| 671 RunAllPendingInMessageLoop(); | 676 RunAllPendingInMessageLoop(); |
| 672 | 677 |
| 673 // The shelf should be shown because there are no more visible windows. | 678 // The shelf should be shown because there are no more visible windows. |
| 674 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 679 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state()); |
| 675 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 680 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state()); |
| 676 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 681 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
| 677 | 682 |
| 678 // Swipe-up to hide. This should have no effect because there are no visible | 683 // Swipe-up to hide. This should have no effect because there are no visible |
| 679 // windows. | 684 // windows. |
| 680 end = below_start - delta; | 685 end = below_start - delta; |
| 681 generator.GestureScrollSequenceWithCallback( | 686 generator.GestureScrollSequenceWithCallback( |
| 682 below_start, | 687 below_start, |
| 683 end, | 688 end, |
| 684 kTimeDelta, | 689 kTimeDelta, |
| 685 kNumScrollSteps, | 690 kNumScrollSteps, |
| 686 base::Bind(&ShelfDragCallback::ProcessScroll, | 691 base::Bind(&ShelfDragCallback::ProcessScroll, |
| 687 base::Unretained(&handler))); | 692 base::Unretained(&handler))); |
| 688 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 693 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state()); |
| 689 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 694 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state()); |
| 690 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 695 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
| 691 } | 696 } |
| 692 | 697 |
| 693 // Need to be implemented. http://crbug.com/111279. | 698 // Need to be implemented. http://crbug.com/111279. |
| 694 #if defined(OS_WIN) | 699 #if defined(OS_WIN) |
| 695 #define MAYBE_SetVisible DISABLED_SetVisible | 700 #define MAYBE_SetVisible DISABLED_SetVisible |
| 696 #else | 701 #else |
| 697 #define MAYBE_SetVisible SetVisible | 702 #define MAYBE_SetVisible SetVisible |
| 698 #endif | 703 #endif |
| 699 // Makes sure SetVisible updates work area and widget appropriately. | 704 // Makes sure SetVisible updates work area and widget appropriately. |
| 700 TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) { | 705 TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) { |
| 701 ShelfWidget* shelf = GetShelfWidget(); | 706 ShelfWidget* shelf_widget = GetShelfWidget(); |
| 702 ShelfLayoutManager* manager = shelf->shelf_layout_manager(); | 707 ShelfLayoutManager* manager = shelf_widget->shelf_layout_manager(); |
| 703 // Force an initial layout. | 708 // Force an initial layout. |
| 704 manager->LayoutShelf(); | 709 manager->LayoutShelf(); |
| 705 EXPECT_EQ(SHELF_VISIBLE, manager->visibility_state()); | 710 EXPECT_EQ(SHELF_VISIBLE, manager->visibility_state()); |
| 706 | 711 |
| 707 gfx::Rect status_bounds( | 712 gfx::Rect status_bounds( |
| 708 shelf->status_area_widget()->GetWindowBoundsInScreen()); | 713 shelf_widget->status_area_widget()->GetWindowBoundsInScreen()); |
| 709 gfx::Rect shelf_bounds( | 714 gfx::Rect shelf_bounds(shelf_widget->GetWindowBoundsInScreen()); |
| 710 shelf->GetWindowBoundsInScreen()); | |
| 711 int shelf_height = manager->GetIdealBounds().height(); | 715 int shelf_height = manager->GetIdealBounds().height(); |
| 712 display::Screen* screen = display::Screen::GetScreen(); | 716 display::Screen* screen = display::Screen::GetScreen(); |
| 713 display::Display display = | 717 display::Display display = |
| 714 screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | 718 screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
| 715 ASSERT_NE(-1, display.id()); | 719 ASSERT_NE(-1, display.id()); |
| 716 // Bottom inset should be the max of widget heights. | 720 // Bottom inset should be the max of widget heights. |
| 717 EXPECT_EQ(shelf_height, display.GetWorkAreaInsets().bottom()); | 721 EXPECT_EQ(shelf_height, display.GetWorkAreaInsets().bottom()); |
| 718 | 722 |
| 719 // Hide the shelf. | 723 // Hide the shelf. |
| 720 SetState(manager, SHELF_HIDDEN); | 724 SetState(manager, SHELF_HIDDEN); |
| 721 // Run the animation to completion. | 725 // Run the animation to completion. |
| 722 StepWidgetLayerAnimatorToEnd(shelf); | 726 StepWidgetLayerAnimatorToEnd(shelf_widget); |
| 723 StepWidgetLayerAnimatorToEnd(shelf->status_area_widget()); | 727 StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget()); |
| 724 EXPECT_EQ(SHELF_HIDDEN, manager->visibility_state()); | 728 EXPECT_EQ(SHELF_HIDDEN, manager->visibility_state()); |
| 725 display = screen->GetDisplayNearestWindow( | 729 display = screen->GetDisplayNearestWindow( |
| 726 Shell::GetPrimaryRootWindow()); | 730 Shell::GetPrimaryRootWindow()); |
| 727 | 731 |
| 728 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); | 732 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); |
| 729 | 733 |
| 730 // Make sure the bounds of the two widgets changed. | 734 // Make sure the bounds of the two widgets changed. |
| 731 EXPECT_GE(shelf->GetNativeView()->bounds().y(), | 735 EXPECT_GE(shelf_widget->GetNativeView()->bounds().y(), |
| 732 screen->GetPrimaryDisplay().bounds().bottom()); | 736 screen->GetPrimaryDisplay().bounds().bottom()); |
| 733 EXPECT_GE(shelf->status_area_widget()->GetNativeView()->bounds().y(), | 737 EXPECT_GE(shelf_widget->status_area_widget()->GetNativeView()->bounds().y(), |
| 734 screen->GetPrimaryDisplay().bounds().bottom()); | 738 screen->GetPrimaryDisplay().bounds().bottom()); |
| 735 | 739 |
| 736 // And show it again. | 740 // And show it again. |
| 737 SetState(manager, SHELF_VISIBLE); | 741 SetState(manager, SHELF_VISIBLE); |
| 738 // Run the animation to completion. | 742 // Run the animation to completion. |
| 739 StepWidgetLayerAnimatorToEnd(shelf); | 743 StepWidgetLayerAnimatorToEnd(shelf_widget); |
| 740 StepWidgetLayerAnimatorToEnd(shelf->status_area_widget()); | 744 StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget()); |
| 741 EXPECT_EQ(SHELF_VISIBLE, manager->visibility_state()); | 745 EXPECT_EQ(SHELF_VISIBLE, manager->visibility_state()); |
| 742 display = screen->GetDisplayNearestWindow( | 746 display = screen->GetDisplayNearestWindow( |
| 743 Shell::GetPrimaryRootWindow()); | 747 Shell::GetPrimaryRootWindow()); |
| 744 EXPECT_EQ(shelf_height, display.GetWorkAreaInsets().bottom()); | 748 EXPECT_EQ(shelf_height, display.GetWorkAreaInsets().bottom()); |
| 745 | 749 |
| 746 // Make sure the bounds of the two widgets changed. | 750 // Make sure the bounds of the two widgets changed. |
| 747 shelf_bounds = shelf->GetNativeView()->bounds(); | 751 shelf_bounds = shelf_widget->GetNativeView()->bounds(); |
| 748 EXPECT_LT(shelf_bounds.y(), screen->GetPrimaryDisplay().bounds().bottom()); | 752 EXPECT_LT(shelf_bounds.y(), screen->GetPrimaryDisplay().bounds().bottom()); |
| 749 status_bounds = shelf->status_area_widget()->GetNativeView()->bounds(); | 753 status_bounds = shelf_widget->status_area_widget()->GetNativeView()->bounds(); |
| 750 EXPECT_LT(status_bounds.y(), | 754 EXPECT_LT(status_bounds.y(), |
| 751 screen->GetPrimaryDisplay().bounds().bottom()); | 755 screen->GetPrimaryDisplay().bounds().bottom()); |
| 752 } | 756 } |
| 753 | 757 |
| 754 // Makes sure LayoutShelf invoked while animating cleans things up. | 758 // Makes sure LayoutShelf invoked while animating cleans things up. |
| 755 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { | 759 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { |
| 756 ShelfWidget* shelf = GetShelfWidget(); | 760 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 757 // Force an initial layout. | 761 // Force an initial layout. |
| 758 shelf->shelf_layout_manager()->LayoutShelf(); | 762 layout_manager->LayoutShelf(); |
| 759 EXPECT_EQ(SHELF_VISIBLE, shelf->shelf_layout_manager()->visibility_state()); | 763 EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state()); |
| 760 | 764 |
| 761 // Hide the shelf. | 765 // Hide the shelf. |
| 762 SetState(shelf->shelf_layout_manager(), SHELF_HIDDEN); | 766 SetState(layout_manager, SHELF_HIDDEN); |
| 763 shelf->shelf_layout_manager()->LayoutShelf(); | 767 layout_manager->LayoutShelf(); |
| 764 EXPECT_EQ(SHELF_HIDDEN, shelf->shelf_layout_manager()->visibility_state()); | 768 EXPECT_EQ(SHELF_HIDDEN, layout_manager->visibility_state()); |
| 765 display::Display display = | 769 display::Display display = |
| 766 display::Screen::GetScreen()->GetDisplayNearestWindow( | 770 display::Screen::GetScreen()->GetDisplayNearestWindow( |
| 767 Shell::GetPrimaryRootWindow()); | 771 Shell::GetPrimaryRootWindow()); |
| 768 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); | 772 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); |
| 769 | 773 |
| 770 // Make sure the bounds of the two widgets changed. | 774 // Make sure the bounds of the two widgets changed. |
| 775 ShelfWidget* shelf_widget = GetShelfWidget(); | |
| 771 EXPECT_GE( | 776 EXPECT_GE( |
| 772 shelf->GetNativeView()->bounds().y(), | 777 shelf_widget->GetNativeView()->bounds().y(), |
| 773 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().bottom()); | 778 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().bottom()); |
| 774 EXPECT_GE( | 779 EXPECT_GE( |
| 775 shelf->status_area_widget()->GetNativeView()->bounds().y(), | 780 shelf_widget->status_area_widget()->GetNativeView()->bounds().y(), |
| 776 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().bottom()); | 781 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().bottom()); |
| 777 } | 782 } |
| 778 | 783 |
| 779 // Test that switching to a different visibility state does not restart the | 784 // Test that switching to a different visibility state does not restart the |
| 780 // shelf show / hide animation if it is already running. (crbug.com/250918) | 785 // shelf show / hide animation if it is already running. (crbug.com/250918) |
| 781 TEST_F(ShelfLayoutManagerTest, SetStateWhileAnimating) { | 786 TEST_F(ShelfLayoutManagerTest, SetStateWhileAnimating) { |
| 782 ShelfWidget* shelf = GetShelfWidget(); | 787 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 783 SetState(shelf->shelf_layout_manager(), SHELF_VISIBLE); | 788 SetState(layout_manager, SHELF_VISIBLE); |
| 784 gfx::Rect initial_shelf_bounds = shelf->GetWindowBoundsInScreen(); | 789 ShelfWidget* shelf_widget = GetShelfWidget(); |
| 790 gfx::Rect initial_shelf_bounds = shelf_widget->GetWindowBoundsInScreen(); | |
| 785 gfx::Rect initial_status_bounds = | 791 gfx::Rect initial_status_bounds = |
| 786 shelf->status_area_widget()->GetWindowBoundsInScreen(); | 792 shelf_widget->status_area_widget()->GetWindowBoundsInScreen(); |
| 787 | 793 |
| 788 ui::ScopedAnimationDurationScaleMode normal_animation_duration( | 794 ui::ScopedAnimationDurationScaleMode normal_animation_duration( |
| 789 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION); | 795 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION); |
| 790 SetState(shelf->shelf_layout_manager(), SHELF_HIDDEN); | 796 SetState(layout_manager, SHELF_HIDDEN); |
| 791 SetState(shelf->shelf_layout_manager(), SHELF_VISIBLE); | 797 SetState(layout_manager, SHELF_VISIBLE); |
| 792 | 798 |
| 793 gfx::Rect current_shelf_bounds = shelf->GetWindowBoundsInScreen(); | 799 gfx::Rect current_shelf_bounds = shelf_widget->GetWindowBoundsInScreen(); |
| 794 gfx::Rect current_status_bounds = | 800 gfx::Rect current_status_bounds = |
| 795 shelf->status_area_widget()->GetWindowBoundsInScreen(); | 801 shelf_widget->status_area_widget()->GetWindowBoundsInScreen(); |
| 796 | 802 |
| 797 const int small_change = initial_shelf_bounds.height() / 2; | 803 const int small_change = initial_shelf_bounds.height() / 2; |
| 798 EXPECT_LE( | 804 EXPECT_LE( |
| 799 std::abs(initial_shelf_bounds.height() - current_shelf_bounds.height()), | 805 std::abs(initial_shelf_bounds.height() - current_shelf_bounds.height()), |
| 800 small_change); | 806 small_change); |
| 801 EXPECT_LE( | 807 EXPECT_LE( |
| 802 std::abs(initial_status_bounds.height() - current_status_bounds.height()), | 808 std::abs(initial_status_bounds.height() - current_status_bounds.height()), |
| 803 small_change); | 809 small_change); |
| 804 } | 810 } |
| 805 | 811 |
| 806 // Makes sure the shelf is sized when the status area changes size. | 812 // Makes sure the shelf is sized when the status area changes size. |
| 807 TEST_F(ShelfLayoutManagerTest, ShelfUpdatedWhenStatusAreaChangesSize) { | 813 TEST_F(ShelfLayoutManagerTest, ShelfUpdatedWhenStatusAreaChangesSize) { |
| 808 Shelf* shelf = Shelf::ForPrimaryDisplay(); | 814 Shelf* shelf = GetShelf(); |
| 809 ASSERT_TRUE(shelf); | 815 ASSERT_TRUE(shelf); |
| 810 ShelfWidget* shelf_widget = GetShelfWidget(); | 816 ShelfWidget* shelf_widget = GetShelfWidget(); |
| 811 ASSERT_TRUE(shelf_widget); | 817 ASSERT_TRUE(shelf_widget); |
| 812 ASSERT_TRUE(shelf_widget->status_area_widget()); | 818 ASSERT_TRUE(shelf_widget->status_area_widget()); |
| 813 shelf_widget->status_area_widget()->SetBounds( | 819 shelf_widget->status_area_widget()->SetBounds( |
| 814 gfx::Rect(0, 0, 200, 200)); | 820 gfx::Rect(0, 0, 200, 200)); |
| 815 EXPECT_EQ(200, shelf_widget->GetContentsView()->width() - | 821 EXPECT_EQ(200, shelf_widget->GetContentsView()->width() - |
| 816 test::ShelfTestAPI(shelf).shelf_view()->width()); | 822 test::ShelfTestAPI(shelf).shelf_view()->width()); |
| 817 } | 823 } |
| 818 | 824 |
| 819 | 825 |
| 820 #if defined(OS_WIN) | 826 #if defined(OS_WIN) |
| 821 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 | 827 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 |
| 822 #define MAYBE_AutoHide DISABLED_AutoHide | 828 #define MAYBE_AutoHide DISABLED_AutoHide |
| 823 #else | 829 #else |
| 824 #define MAYBE_AutoHide AutoHide | 830 #define MAYBE_AutoHide AutoHide |
| 825 #endif | 831 #endif |
| 826 | 832 |
| 827 // Various assertions around auto-hide. | 833 // Various assertions around auto-hide. |
| 828 TEST_F(ShelfLayoutManagerTest, MAYBE_AutoHide) { | 834 TEST_F(ShelfLayoutManagerTest, MAYBE_AutoHide) { |
| 829 aura::Window* root = Shell::GetPrimaryRootWindow(); | 835 aura::Window* root = Shell::GetPrimaryRootWindow(); |
| 830 ui::test::EventGenerator generator(root, root); | 836 ui::test::EventGenerator generator(root, root); |
| 831 generator.MoveMouseTo(0, 0); | 837 generator.MoveMouseTo(0, 0); |
| 832 | 838 |
| 833 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 839 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 834 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 840 GetShelf()->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 835 views::Widget* widget = new views::Widget; | 841 views::Widget* widget = new views::Widget; |
| 836 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 842 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 837 params.bounds = gfx::Rect(0, 0, 200, 200); | 843 params.bounds = gfx::Rect(0, 0, 200, 200); |
| 838 params.context = CurrentContext(); | 844 params.context = CurrentContext(); |
| 839 // Widget is now owned by the parent window. | 845 // Widget is now owned by the parent window. |
| 840 widget->Init(params); | 846 widget->Init(params); |
| 841 widget->Maximize(); | 847 widget->Maximize(); |
| 842 widget->Show(); | 848 widget->Show(); |
| 843 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 849 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state()); |
| 844 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 850 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 845 | 851 |
| 846 // LayoutShelf() forces the animation to completion, at which point the | 852 // LayoutShelf() forces the animation to completion, at which point the |
| 847 // shelf should go off the screen. | 853 // shelf should go off the screen. |
| 848 shelf->LayoutShelf(); | 854 layout_manager->LayoutShelf(); |
| 849 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, | 855 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, |
| 850 GetShelfWidget()->GetWindowBoundsInScreen().y()); | 856 GetShelfWidget()->GetWindowBoundsInScreen().y()); |
| 851 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, | 857 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, |
| 852 display::Screen::GetScreen() | 858 display::Screen::GetScreen() |
| 853 ->GetDisplayNearestWindow(root) | 859 ->GetDisplayNearestWindow(root) |
| 854 .work_area() | 860 .work_area() |
| 855 .bottom()); | 861 .bottom()); |
| 856 | 862 |
| 857 // Move the mouse to the bottom of the screen. | 863 // Move the mouse to the bottom of the screen. |
| 858 generator.MoveMouseTo(0, root->bounds().bottom() - 1); | 864 generator.MoveMouseTo(0, root->bounds().bottom() - 1); |
| 859 | 865 |
| 860 // Shelf should be shown again (but it shouldn't have changed the work area). | 866 // Shelf should be shown again (but it shouldn't have changed the work area). |
| 861 SetState(shelf, SHELF_AUTO_HIDE); | 867 SetState(layout_manager, SHELF_AUTO_HIDE); |
| 862 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 868 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state()); |
| 863 shelf->LayoutShelf(); | 869 layout_manager->LayoutShelf(); |
| 864 EXPECT_EQ(root->bounds().bottom() - shelf->GetIdealBounds().height(), | 870 EXPECT_EQ(root->bounds().bottom() - layout_manager->GetIdealBounds().height(), |
| 865 GetShelfWidget()->GetWindowBoundsInScreen().y()); | 871 GetShelfWidget()->GetWindowBoundsInScreen().y()); |
| 866 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, | 872 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, |
| 867 display::Screen::GetScreen() | 873 display::Screen::GetScreen() |
| 868 ->GetDisplayNearestWindow(root) | 874 ->GetDisplayNearestWindow(root) |
| 869 .work_area() | 875 .work_area() |
| 870 .bottom()); | 876 .bottom()); |
| 871 | 877 |
| 872 // Move mouse back up. | 878 // Move mouse back up. |
| 873 generator.MoveMouseTo(0, 0); | 879 generator.MoveMouseTo(0, 0); |
| 874 SetState(shelf, SHELF_AUTO_HIDE); | 880 SetState(layout_manager, SHELF_AUTO_HIDE); |
| 875 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 881 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 876 shelf->LayoutShelf(); | 882 layout_manager->LayoutShelf(); |
| 877 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, | 883 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, |
| 878 GetShelfWidget()->GetWindowBoundsInScreen().y()); | 884 GetShelfWidget()->GetWindowBoundsInScreen().y()); |
| 879 | 885 |
| 880 // Drag mouse to bottom of screen. | 886 // Drag mouse to bottom of screen. |
| 881 generator.PressLeftButton(); | 887 generator.PressLeftButton(); |
| 882 generator.MoveMouseTo(0, root->bounds().bottom() - 1); | 888 generator.MoveMouseTo(0, root->bounds().bottom() - 1); |
| 883 UpdateAutoHideStateNow(); | 889 UpdateAutoHideStateNow(); |
| 884 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 890 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 885 | 891 |
| 886 generator.ReleaseLeftButton(); | 892 generator.ReleaseLeftButton(); |
| 887 generator.MoveMouseTo(1, root->bounds().bottom() - 1); | 893 generator.MoveMouseTo(1, root->bounds().bottom() - 1); |
| 888 UpdateAutoHideStateNow(); | 894 UpdateAutoHideStateNow(); |
| 889 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 895 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state()); |
| 890 generator.PressLeftButton(); | 896 generator.PressLeftButton(); |
| 891 generator.MoveMouseTo(1, root->bounds().bottom() - 1); | 897 generator.MoveMouseTo(1, root->bounds().bottom() - 1); |
| 892 UpdateAutoHideStateNow(); | 898 UpdateAutoHideStateNow(); |
| 893 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 899 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state()); |
| 894 } | 900 } |
| 895 | 901 |
| 896 // Test the behavior of the shelf when it is auto hidden and it is on the | 902 // Test the behavior of the shelf when it is auto hidden and it is on the |
| 897 // boundary between the primary and the secondary display. | 903 // boundary between the primary and the secondary display. |
| 898 TEST_F(ShelfLayoutManagerTest, AutoHideShelfOnScreenBoundary) { | 904 TEST_F(ShelfLayoutManagerTest, AutoHideShelfOnScreenBoundary) { |
| 899 if (!SupportsMultipleDisplays()) | 905 if (!SupportsMultipleDisplays()) |
| 900 return; | 906 return; |
| 901 | 907 |
| 902 UpdateDisplay("800x600,800x600"); | 908 UpdateDisplay("800x600,800x600"); |
| 903 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( | 909 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( |
| 904 test::CreateDisplayLayout(display::DisplayPlacement::RIGHT, 0)); | 910 test::CreateDisplayLayout(display::DisplayPlacement::RIGHT, 0)); |
| 905 // Put the primary monitor's shelf on the display boundary. | 911 // Put the primary monitor's shelf on the display boundary. |
| 906 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 912 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 907 shelf->SetAlignment(wm::SHELF_ALIGNMENT_RIGHT); | 913 GetShelf()->SetAlignment(wm::SHELF_ALIGNMENT_RIGHT); |
| 908 | 914 |
| 909 // Create a window because the shelf is always shown when no windows are | 915 // Create a window because the shelf is always shown when no windows are |
| 910 // visible. | 916 // visible. |
| 911 CreateTestWidget(); | 917 CreateTestWidget(); |
| 912 | 918 |
| 913 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 919 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 914 ASSERT_EQ(root_windows[0], | 920 ASSERT_EQ(root_windows[0], |
| 915 GetShelfWidget()->GetNativeWindow()->GetRootWindow()); | 921 GetShelfWidget()->GetNativeWindow()->GetRootWindow()); |
| 916 | 922 |
| 917 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 923 GetShelf()->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 918 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 924 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state()); |
| 919 | 925 |
| 920 int right_edge = root_windows[0]->GetBoundsInScreen().right() - 1; | 926 int right_edge = root_windows[0]->GetBoundsInScreen().right() - 1; |
| 921 int y = root_windows[0]->GetBoundsInScreen().y(); | 927 int y = root_windows[0]->GetBoundsInScreen().y(); |
| 922 | 928 |
| 923 // Start off the mouse nowhere near the shelf; the shelf should be hidden. | 929 // Start off the mouse nowhere near the shelf; the shelf should be hidden. |
| 924 ui::test::EventGenerator& generator(GetEventGenerator()); | 930 ui::test::EventGenerator& generator(GetEventGenerator()); |
| 925 generator.MoveMouseTo(right_edge - 50, y); | 931 generator.MoveMouseTo(right_edge - 50, y); |
| 926 UpdateAutoHideStateNow(); | 932 UpdateAutoHideStateNow(); |
| 927 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 933 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 928 | 934 |
| 929 // Moving the mouse over the light bar (but not to the edge of the screen) | 935 // Moving the mouse over the light bar (but not to the edge of the screen) |
| 930 // should show the shelf. | 936 // should show the shelf. |
| 931 generator.MoveMouseTo(right_edge - 1, y); | 937 generator.MoveMouseTo(right_edge - 1, y); |
| 932 UpdateAutoHideStateNow(); | 938 UpdateAutoHideStateNow(); |
| 933 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 939 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state()); |
| 934 EXPECT_EQ(right_edge - 1, | 940 EXPECT_EQ(right_edge - 1, |
| 935 display::Screen::GetScreen()->GetCursorScreenPoint().x()); | 941 display::Screen::GetScreen()->GetCursorScreenPoint().x()); |
| 936 | 942 |
| 937 // Moving the mouse off the light bar should hide the shelf. | 943 // Moving the mouse off the light bar should hide the shelf. |
| 938 generator.MoveMouseTo(right_edge - 50, y); | 944 generator.MoveMouseTo(right_edge - 50, y); |
| 939 UpdateAutoHideStateNow(); | 945 UpdateAutoHideStateNow(); |
| 940 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 946 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 941 | 947 |
| 942 // Moving the mouse to the right edge of the screen crossing the light bar | 948 // Moving the mouse to the right edge of the screen crossing the light bar |
| 943 // should show the shelf despite the mouse cursor getting warped to the | 949 // should show the shelf despite the mouse cursor getting warped to the |
| 944 // secondary display. | 950 // secondary display. |
| 945 generator.MoveMouseTo(right_edge - 1, y); | 951 generator.MoveMouseTo(right_edge - 1, y); |
| 946 generator.MoveMouseTo(right_edge, y); | 952 generator.MoveMouseTo(right_edge, y); |
| 947 UpdateAutoHideStateNow(); | 953 UpdateAutoHideStateNow(); |
| 948 EXPECT_NE(right_edge - 1, | 954 EXPECT_NE(right_edge - 1, |
| 949 display::Screen::GetScreen()->GetCursorScreenPoint().x()); | 955 display::Screen::GetScreen()->GetCursorScreenPoint().x()); |
| 950 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 956 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state()); |
| 951 | 957 |
| 952 // Hide the shelf. | 958 // Hide the shelf. |
| 953 generator.MoveMouseTo(right_edge - 50, y); | 959 generator.MoveMouseTo(right_edge - 50, y); |
| 954 UpdateAutoHideStateNow(); | 960 UpdateAutoHideStateNow(); |
| 955 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 961 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 956 | 962 |
| 957 // Moving the mouse to the right edge of the screen crossing the light bar and | 963 // Moving the mouse to the right edge of the screen crossing the light bar and |
| 958 // overshooting by a lot should keep the shelf hidden. | 964 // overshooting by a lot should keep the shelf hidden. |
| 959 generator.MoveMouseTo(right_edge - 1, y); | 965 generator.MoveMouseTo(right_edge - 1, y); |
| 960 generator.MoveMouseTo(right_edge + 50, y); | 966 generator.MoveMouseTo(right_edge + 50, y); |
| 961 UpdateAutoHideStateNow(); | 967 UpdateAutoHideStateNow(); |
| 962 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 968 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 963 | 969 |
| 964 // Moving the mouse to the right edge of the screen crossing the light bar and | 970 // Moving the mouse to the right edge of the screen crossing the light bar and |
| 965 // overshooting a bit should show the shelf. | 971 // overshooting a bit should show the shelf. |
| 966 generator.MoveMouseTo(right_edge - 1, y); | 972 generator.MoveMouseTo(right_edge - 1, y); |
| 967 generator.MoveMouseTo(right_edge + 2, y); | 973 generator.MoveMouseTo(right_edge + 2, y); |
| 968 UpdateAutoHideStateNow(); | 974 UpdateAutoHideStateNow(); |
| 969 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 975 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state()); |
| 970 | 976 |
| 971 // Keeping the mouse close to the left edge of the secondary display after the | 977 // Keeping the mouse close to the left edge of the secondary display after the |
| 972 // shelf is shown should keep the shelf shown. | 978 // shelf is shown should keep the shelf shown. |
| 973 generator.MoveMouseTo(right_edge + 2, y + 1); | 979 generator.MoveMouseTo(right_edge + 2, y + 1); |
| 974 UpdateAutoHideStateNow(); | 980 UpdateAutoHideStateNow(); |
| 975 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 981 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state()); |
| 976 | 982 |
| 977 // Moving the mouse far from the left edge of the secondary display should | 983 // Moving the mouse far from the left edge of the secondary display should |
| 978 // hide the shelf. | 984 // hide the shelf. |
| 979 generator.MoveMouseTo(right_edge + 50, y); | 985 generator.MoveMouseTo(right_edge + 50, y); |
| 980 UpdateAutoHideStateNow(); | 986 UpdateAutoHideStateNow(); |
| 981 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 987 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 982 | 988 |
| 983 // Moving to the left edge of the secondary display without first crossing | 989 // Moving to the left edge of the secondary display without first crossing |
| 984 // the primary display's right aligned shelf first should not show the shelf. | 990 // the primary display's right aligned shelf first should not show the shelf. |
| 985 generator.MoveMouseTo(right_edge + 2, y); | 991 generator.MoveMouseTo(right_edge + 2, y); |
| 986 UpdateAutoHideStateNow(); | 992 UpdateAutoHideStateNow(); |
| 987 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 993 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 988 } | 994 } |
| 989 | 995 |
| 990 // Assertions around the lock screen showing. | 996 // Assertions around the lock screen showing. |
| 991 TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) { | 997 TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) { |
| 992 if (!SupportsHostWindowResize()) | 998 if (!SupportsHostWindowResize()) |
| 993 return; | 999 return; |
| 994 | 1000 |
| 995 // Since ShelfLayoutManager queries for mouse location, move the mouse so | 1001 // Since ShelfLayoutManager queries for mouse location, move the mouse so |
| 996 // it isn't over the shelf. | 1002 // it isn't over the shelf. |
| 997 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 1003 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| 998 gfx::Point()); | 1004 gfx::Point()); |
| 999 generator.MoveMouseTo(0, 0); | 1005 generator.MoveMouseTo(0, 0); |
| 1000 | 1006 |
| 1001 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 1007 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 1002 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1008 GetShelf()->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1003 views::Widget* widget = new views::Widget; | 1009 views::Widget* widget = new views::Widget; |
| 1004 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 1010 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 1005 params.bounds = gfx::Rect(0, 0, 200, 200); | 1011 params.bounds = gfx::Rect(0, 0, 200, 200); |
| 1006 params.context = CurrentContext(); | 1012 params.context = CurrentContext(); |
| 1007 // Widget is now owned by the parent window. | 1013 // Widget is now owned by the parent window. |
| 1008 widget->Init(params); | 1014 widget->Init(params); |
| 1009 widget->Maximize(); | 1015 widget->Maximize(); |
| 1010 widget->Show(); | 1016 widget->Show(); |
| 1011 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 1017 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state()); |
| 1012 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 1018 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 1013 | 1019 |
| 1014 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1020 aura::Window* root = Shell::GetPrimaryRootWindow(); |
| 1015 // LayoutShelf() forces the animation to completion, at which point the | 1021 // LayoutShelf() forces the animation to completion, at which point the |
| 1016 // shelf should go off the screen. | 1022 // shelf should go off the screen. |
| 1017 shelf->LayoutShelf(); | 1023 layout_manager->LayoutShelf(); |
| 1018 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, | 1024 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, |
| 1019 GetShelfWidget()->GetWindowBoundsInScreen().y()); | 1025 GetShelfWidget()->GetWindowBoundsInScreen().y()); |
| 1020 | 1026 |
| 1021 aura::Window* lock_container = Shell::GetContainer( | 1027 aura::Window* lock_container = Shell::GetContainer( |
| 1022 Shell::GetPrimaryRootWindow(), kShellWindowId_LockScreenContainer); | 1028 Shell::GetPrimaryRootWindow(), kShellWindowId_LockScreenContainer); |
| 1023 | 1029 |
| 1024 views::Widget* lock_widget = new views::Widget; | 1030 views::Widget* lock_widget = new views::Widget; |
| 1025 views::Widget::InitParams lock_params( | 1031 views::Widget::InitParams lock_params( |
| 1026 views::Widget::InitParams::TYPE_WINDOW); | 1032 views::Widget::InitParams::TYPE_WINDOW); |
| 1027 lock_params.bounds = gfx::Rect(0, 0, 200, 200); | 1033 lock_params.bounds = gfx::Rect(0, 0, 200, 200); |
| 1028 params.context = CurrentContext(); | 1034 params.context = CurrentContext(); |
| 1029 lock_params.parent = lock_container; | 1035 lock_params.parent = lock_container; |
| 1030 // Widget is now owned by the parent window. | 1036 // Widget is now owned by the parent window. |
| 1031 lock_widget->Init(lock_params); | 1037 lock_widget->Init(lock_params); |
| 1032 lock_widget->Maximize(); | 1038 lock_widget->Maximize(); |
| 1033 lock_widget->Show(); | 1039 lock_widget->Show(); |
| 1034 | 1040 |
| 1035 // Lock the screen. | 1041 // Lock the screen. |
| 1036 LockScreen(); | 1042 LockScreen(); |
| 1037 // Showing a widget in the lock screen should force the shelf to be visibile. | 1043 // Showing a widget in the lock screen should force the shelf to be visibile. |
| 1038 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 1044 EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state()); |
| 1039 | 1045 |
| 1040 UnlockScreen(); | 1046 UnlockScreen(); |
| 1041 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 1047 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state()); |
| 1042 } | 1048 } |
| 1043 | 1049 |
| 1044 // Assertions around SetAutoHideBehavior. | 1050 // Assertions around SetAutoHideBehavior. |
| 1045 TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) { | 1051 TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) { |
| 1046 // Since ShelfLayoutManager queries for mouse location, move the mouse so | 1052 // Since ShelfLayoutManager queries for mouse location, move the mouse so |
| 1047 // it isn't over the shelf. | 1053 // it isn't over the shelf. |
| 1048 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 1054 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| 1049 gfx::Point()); | 1055 gfx::Point()); |
| 1050 generator.MoveMouseTo(0, 0); | 1056 generator.MoveMouseTo(0, 0); |
| 1051 | 1057 |
| 1052 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 1058 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 1053 views::Widget* widget = new views::Widget; | 1059 views::Widget* widget = new views::Widget; |
| 1054 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 1060 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 1055 params.bounds = gfx::Rect(0, 0, 200, 200); | 1061 params.bounds = gfx::Rect(0, 0, 200, 200); |
| 1056 params.context = CurrentContext(); | 1062 params.context = CurrentContext(); |
| 1057 // Widget is now owned by the parent window. | 1063 // Widget is now owned by the parent window. |
| 1058 widget->Init(params); | 1064 widget->Init(params); |
| 1059 widget->Show(); | 1065 widget->Show(); |
| 1060 aura::Window* window = widget->GetNativeWindow(); | 1066 aura::Window* window = widget->GetNativeWindow(); |
| 1061 gfx::Rect display_bounds( | 1067 gfx::Rect display_bounds( |
| 1062 display::Screen::GetScreen()->GetDisplayNearestWindow(window).bounds()); | 1068 display::Screen::GetScreen()->GetDisplayNearestWindow(window).bounds()); |
| 1063 | 1069 |
| 1070 Shelf* shelf = GetShelf(); | |
| 1064 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1071 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1065 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 1072 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state()); |
| 1066 | 1073 |
| 1067 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1074 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1068 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 1075 EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state()); |
| 1069 | 1076 |
| 1070 widget->Maximize(); | 1077 widget->Maximize(); |
| 1071 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 1078 EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state()); |
| 1072 EXPECT_EQ(display::Screen::GetScreen() | 1079 EXPECT_EQ(display::Screen::GetScreen() |
| 1073 ->GetDisplayNearestWindow(window) | 1080 ->GetDisplayNearestWindow(window) |
| 1074 .work_area() | 1081 .work_area() |
| 1075 .bottom(), | 1082 .bottom(), |
| 1076 widget->GetWorkAreaBoundsInScreen().bottom()); | 1083 widget->GetWorkAreaBoundsInScreen().bottom()); |
| 1077 | 1084 |
| 1078 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1085 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1079 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 1086 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state()); |
| 1080 EXPECT_EQ(display::Screen::GetScreen() | 1087 EXPECT_EQ(display::Screen::GetScreen() |
| 1081 ->GetDisplayNearestWindow(window) | 1088 ->GetDisplayNearestWindow(window) |
| 1082 .work_area() | 1089 .work_area() |
| 1083 .bottom(), | 1090 .bottom(), |
| 1084 widget->GetWorkAreaBoundsInScreen().bottom()); | 1091 widget->GetWorkAreaBoundsInScreen().bottom()); |
| 1085 | 1092 |
| 1086 ui::ScopedAnimationDurationScaleMode animation_duration( | 1093 ui::ScopedAnimationDurationScaleMode animation_duration( |
| 1087 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION); | 1094 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION); |
| 1088 | 1095 |
| 1089 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1096 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1090 ShelfWidget* shelf_widget = GetShelfWidget(); | 1097 ShelfWidget* shelf_widget = GetShelfWidget(); |
| 1091 EXPECT_TRUE(shelf_widget->status_area_widget()->IsVisible()); | 1098 EXPECT_TRUE(shelf_widget->status_area_widget()->IsVisible()); |
| 1092 StepWidgetLayerAnimatorToEnd(shelf_widget); | 1099 StepWidgetLayerAnimatorToEnd(shelf_widget); |
| 1093 StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget()); | 1100 StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget()); |
| 1094 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 1101 EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state()); |
| 1095 EXPECT_EQ(display::Screen::GetScreen() | 1102 EXPECT_EQ(display::Screen::GetScreen() |
| 1096 ->GetDisplayNearestWindow(window) | 1103 ->GetDisplayNearestWindow(window) |
| 1097 .work_area() | 1104 .work_area() |
| 1098 .bottom(), | 1105 .bottom(), |
| 1099 widget->GetWorkAreaBoundsInScreen().bottom()); | 1106 widget->GetWorkAreaBoundsInScreen().bottom()); |
| 1100 } | 1107 } |
| 1101 | 1108 |
| 1102 // Basic assertions around the dimming of the shelf. | 1109 // Basic assertions around the dimming of the shelf. |
| 1103 TEST_F(ShelfLayoutManagerTest, DimmingBehavior) { | 1110 TEST_F(ShelfLayoutManagerTest, DimmingBehavior) { |
| 1104 // Since ShelfLayoutManager queries for mouse location, move the mouse so | 1111 // Since ShelfLayoutManager queries for mouse location, move the mouse so |
| 1105 // it isn't over the shelf. | 1112 // it isn't over the shelf. |
| 1106 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 1113 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| 1107 gfx::Point()); | 1114 gfx::Point()); |
| 1108 generator.MoveMouseTo(0, 0); | 1115 generator.MoveMouseTo(0, 0); |
| 1109 | 1116 |
| 1110 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 1117 ShelfWidget* shelf_widget = GetShelfWidget(); |
| 1111 shelf->shelf_widget()->DisableDimmingAnimationsForTest(); | 1118 shelf_widget->DisableDimmingAnimationsForTest(); |
| 1112 | 1119 |
| 1113 views::Widget* widget = new views::Widget; | 1120 views::Widget* widget = new views::Widget; |
| 1114 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 1121 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 1115 params.bounds = gfx::Rect(0, 0, 200, 200); | 1122 params.bounds = gfx::Rect(0, 0, 200, 200); |
| 1116 params.context = CurrentContext(); | 1123 params.context = CurrentContext(); |
| 1117 // Widget is now owned by the parent window. | 1124 // Widget is now owned by the parent window. |
| 1118 widget->Init(params); | 1125 widget->Init(params); |
| 1119 widget->Show(); | 1126 widget->Show(); |
| 1120 aura::Window* window = widget->GetNativeWindow(); | 1127 aura::Window* window = widget->GetNativeWindow(); |
| 1121 gfx::Rect display_bounds( | 1128 gfx::Rect display_bounds( |
| 1122 display::Screen::GetScreen()->GetDisplayNearestWindow(window).bounds()); | 1129 display::Screen::GetScreen()->GetDisplayNearestWindow(window).bounds()); |
| 1123 | 1130 |
| 1124 gfx::Point off_shelf = display_bounds.CenterPoint(); | 1131 gfx::Point off_shelf = display_bounds.CenterPoint(); |
| 1125 gfx::Point on_shelf = | 1132 gfx::Point on_shelf = shelf_widget->GetWindowBoundsInScreen().CenterPoint(); |
| 1126 shelf->shelf_widget()->GetWindowBoundsInScreen().CenterPoint(); | |
| 1127 | 1133 |
| 1128 // Test there is no dimming object active at this point. | 1134 // Test there is no dimming object active at this point. |
| 1129 generator.MoveMouseTo(on_shelf.x(), on_shelf.y()); | 1135 generator.MoveMouseTo(on_shelf.x(), on_shelf.y()); |
| 1130 EXPECT_EQ(-1, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1136 EXPECT_EQ(-1, shelf_widget->GetDimmingAlphaForTest()); |
| 1131 generator.MoveMouseTo(off_shelf.x(), off_shelf.y()); | 1137 generator.MoveMouseTo(off_shelf.x(), off_shelf.y()); |
| 1132 EXPECT_EQ(-1, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1138 EXPECT_EQ(-1, shelf_widget->GetDimmingAlphaForTest()); |
| 1133 | 1139 |
| 1134 // After maximization, the shelf should be visible and the dimmer created. | 1140 // After maximization, the shelf should be visible and the dimmer created. |
| 1135 widget->Maximize(); | 1141 widget->Maximize(); |
| 1136 | 1142 |
| 1137 on_shelf = shelf->shelf_widget()->GetWindowBoundsInScreen().CenterPoint(); | 1143 on_shelf = shelf_widget->GetWindowBoundsInScreen().CenterPoint(); |
| 1138 EXPECT_LT(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1144 EXPECT_LT(0, shelf_widget->GetDimmingAlphaForTest()); |
| 1139 | 1145 |
| 1140 // Moving the mouse off the shelf should dim the bar. | 1146 // Moving the mouse off the shelf should dim the bar. |
| 1141 generator.MoveMouseTo(off_shelf.x(), off_shelf.y()); | 1147 generator.MoveMouseTo(off_shelf.x(), off_shelf.y()); |
| 1142 EXPECT_LT(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1148 EXPECT_LT(0, shelf_widget->GetDimmingAlphaForTest()); |
| 1143 | 1149 |
| 1144 // Adding touch events outside the shelf should still keep the shelf in | 1150 // Adding touch events outside the shelf should still keep the shelf in |
| 1145 // dimmed state. | 1151 // dimmed state. |
| 1146 generator.PressTouch(); | 1152 generator.PressTouch(); |
| 1147 generator.MoveTouch(off_shelf); | 1153 generator.MoveTouch(off_shelf); |
| 1148 EXPECT_LT(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1154 EXPECT_LT(0, shelf_widget->GetDimmingAlphaForTest()); |
| 1149 // Move the touch into the shelf area should undim. | 1155 // Move the touch into the shelf area should undim. |
| 1150 generator.MoveTouch(on_shelf); | 1156 generator.MoveTouch(on_shelf); |
| 1151 EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1157 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); |
| 1152 generator.ReleaseTouch(); | 1158 generator.ReleaseTouch(); |
| 1153 // And a release dims again. | 1159 // And a release dims again. |
| 1154 EXPECT_LT(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1160 EXPECT_LT(0, shelf_widget->GetDimmingAlphaForTest()); |
| 1155 | 1161 |
| 1156 // Moving the mouse on the shelf should undim the bar. | 1162 // Moving the mouse on the shelf should undim the bar. |
| 1157 generator.MoveMouseTo(on_shelf); | 1163 generator.MoveMouseTo(on_shelf); |
| 1158 EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1164 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); |
| 1159 | 1165 |
| 1160 // No matter what the touch events do, the shelf should stay undimmed. | 1166 // No matter what the touch events do, the shelf should stay undimmed. |
| 1161 generator.PressTouch(); | 1167 generator.PressTouch(); |
| 1162 generator.MoveTouch(off_shelf); | 1168 generator.MoveTouch(off_shelf); |
| 1163 EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1169 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); |
| 1164 generator.MoveTouch(on_shelf); | 1170 generator.MoveTouch(on_shelf); |
| 1165 EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1171 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); |
| 1166 generator.MoveTouch(off_shelf); | 1172 generator.MoveTouch(off_shelf); |
| 1167 EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1173 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); |
| 1168 generator.MoveTouch(on_shelf); | 1174 generator.MoveTouch(on_shelf); |
| 1169 generator.ReleaseTouch(); | 1175 generator.ReleaseTouch(); |
| 1170 | 1176 |
| 1171 // After restore, the dimming object should be deleted again. | 1177 // After restore, the dimming object should be deleted again. |
| 1172 widget->Restore(); | 1178 widget->Restore(); |
| 1173 EXPECT_EQ(-1, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1179 EXPECT_EQ(-1, shelf_widget->GetDimmingAlphaForTest()); |
| 1174 } | 1180 } |
| 1175 | 1181 |
| 1176 // Test that dimming works correctly with multiple displays. | 1182 // Test that dimming works correctly with multiple displays. |
| 1177 TEST_F(ShelfLayoutManagerTest, DimmingBehaviorDualDisplay) { | 1183 TEST_F(ShelfLayoutManagerTest, DimmingBehaviorDualDisplay) { |
| 1178 if (!SupportsMultipleDisplays()) | 1184 if (!SupportsMultipleDisplays()) |
| 1179 return; | 1185 return; |
| 1180 | 1186 |
| 1181 // Create two displays. | 1187 // Create two displays. |
| 1182 Shell* shell = Shell::GetInstance(); | 1188 Shell* shell = Shell::GetInstance(); |
| 1183 UpdateDisplay("0+0-200x200,+200+0-100x100"); | 1189 UpdateDisplay("0+0-200x200,+200+0-100x100"); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1231 } | 1237 } |
| 1232 | 1238 |
| 1233 // Assertions around the dimming of the shelf in conjunction with menus. | 1239 // Assertions around the dimming of the shelf in conjunction with menus. |
| 1234 TEST_F(ShelfLayoutManagerTest, DimmingBehaviorWithMenus) { | 1240 TEST_F(ShelfLayoutManagerTest, DimmingBehaviorWithMenus) { |
| 1235 // Since ShelfLayoutManager queries for mouse location, move the mouse so | 1241 // Since ShelfLayoutManager queries for mouse location, move the mouse so |
| 1236 // it isn't over the shelf. | 1242 // it isn't over the shelf. |
| 1237 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 1243 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| 1238 gfx::Point()); | 1244 gfx::Point()); |
| 1239 generator.MoveMouseTo(0, 0); | 1245 generator.MoveMouseTo(0, 0); |
| 1240 | 1246 |
| 1241 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 1247 ShelfWidget* shelf_widget = GetShelfWidget(); |
| 1242 shelf->shelf_widget()->DisableDimmingAnimationsForTest(); | 1248 shelf_widget->DisableDimmingAnimationsForTest(); |
| 1243 | 1249 |
| 1244 views::Widget* widget = new views::Widget; | 1250 views::Widget* widget = new views::Widget; |
| 1245 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 1251 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 1246 params.bounds = gfx::Rect(0, 0, 200, 200); | 1252 params.bounds = gfx::Rect(0, 0, 200, 200); |
| 1247 params.context = CurrentContext(); | 1253 params.context = CurrentContext(); |
| 1248 // Widget is now owned by the parent window. | 1254 // Widget is now owned by the parent window. |
| 1249 widget->Init(params); | 1255 widget->Init(params); |
| 1250 widget->Show(); | 1256 widget->Show(); |
| 1251 aura::Window* window = widget->GetNativeWindow(); | 1257 aura::Window* window = widget->GetNativeWindow(); |
| 1252 gfx::Rect display_bounds( | 1258 gfx::Rect display_bounds( |
| 1253 display::Screen::GetScreen()->GetDisplayNearestWindow(window).bounds()); | 1259 display::Screen::GetScreen()->GetDisplayNearestWindow(window).bounds()); |
| 1254 | 1260 |
| 1255 // After maximization, the shelf should be visible and the dimmer created. | 1261 // After maximization, the shelf should be visible and the dimmer created. |
| 1256 widget->Maximize(); | 1262 widget->Maximize(); |
| 1257 | 1263 |
| 1258 gfx::Point off_shelf = display_bounds.CenterPoint(); | 1264 gfx::Point off_shelf = display_bounds.CenterPoint(); |
| 1259 gfx::Point on_shelf = | 1265 gfx::Point on_shelf = shelf_widget->GetWindowBoundsInScreen().CenterPoint(); |
| 1260 shelf->shelf_widget()->GetWindowBoundsInScreen().CenterPoint(); | |
| 1261 | 1266 |
| 1262 // Moving the mouse on the shelf should undim the bar. | 1267 // Moving the mouse on the shelf should undim the bar. |
| 1263 generator.MoveMouseTo(on_shelf.x(), on_shelf.y()); | 1268 generator.MoveMouseTo(on_shelf.x(), on_shelf.y()); |
| 1264 EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1269 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); |
| 1265 | 1270 |
| 1266 // Simulate a menu opening. | 1271 // Simulate a menu opening. |
| 1267 shelf->shelf_widget()->ForceUndimming(true); | 1272 shelf_widget->ForceUndimming(true); |
| 1268 | 1273 |
| 1269 // Moving the mouse off the shelf should not dim the bar. | 1274 // Moving the mouse off the shelf should not dim the bar. |
| 1270 generator.MoveMouseTo(off_shelf.x(), off_shelf.y()); | 1275 generator.MoveMouseTo(off_shelf.x(), off_shelf.y()); |
| 1271 EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1276 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); |
| 1272 | 1277 |
| 1273 // No matter what the touch events do, the shelf should stay undimmed. | 1278 // No matter what the touch events do, the shelf should stay undimmed. |
| 1274 generator.PressTouch(); | 1279 generator.PressTouch(); |
| 1275 generator.MoveTouch(off_shelf); | 1280 generator.MoveTouch(off_shelf); |
| 1276 EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1281 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); |
| 1277 generator.MoveTouch(on_shelf); | 1282 generator.MoveTouch(on_shelf); |
| 1278 EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1283 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); |
| 1279 generator.MoveTouch(off_shelf); | 1284 generator.MoveTouch(off_shelf); |
| 1280 EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1285 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); |
| 1281 generator.ReleaseTouch(); | 1286 generator.ReleaseTouch(); |
| 1282 EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1287 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); |
| 1283 | 1288 |
| 1284 // "Closing the menu" should now turn off the menu since no event is inside | 1289 // "Closing the menu" should now turn off the menu since no event is inside |
| 1285 // the shelf any longer. | 1290 // the shelf any longer. |
| 1286 shelf->shelf_widget()->ForceUndimming(false); | 1291 shelf_widget->ForceUndimming(false); |
| 1287 EXPECT_LT(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1292 EXPECT_LT(0, shelf_widget->GetDimmingAlphaForTest()); |
| 1288 | 1293 |
| 1289 // Moving the mouse again on the shelf which should undim the bar again. | 1294 // Moving the mouse again on the shelf which should undim the bar again. |
| 1290 // This time we check that the bar stays undimmed when the mouse remains on | 1295 // This time we check that the bar stays undimmed when the mouse remains on |
| 1291 // the bar and the "menu gets closed". | 1296 // the bar and the "menu gets closed". |
| 1292 generator.MoveMouseTo(on_shelf.x(), on_shelf.y()); | 1297 generator.MoveMouseTo(on_shelf.x(), on_shelf.y()); |
| 1293 EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1298 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); |
| 1294 shelf->shelf_widget()->ForceUndimming(true); | 1299 shelf_widget->ForceUndimming(true); |
| 1295 generator.MoveMouseTo(off_shelf.x(), off_shelf.y()); | 1300 generator.MoveMouseTo(off_shelf.x(), off_shelf.y()); |
| 1296 EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1301 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); |
| 1297 generator.MoveMouseTo(on_shelf.x(), on_shelf.y()); | 1302 generator.MoveMouseTo(on_shelf.x(), on_shelf.y()); |
| 1298 EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1303 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); |
| 1299 shelf->shelf_widget()->ForceUndimming(true); | 1304 shelf_widget->ForceUndimming(true); |
| 1300 EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1305 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); |
| 1301 } | 1306 } |
| 1302 | 1307 |
| 1303 // Verifies the shelf is visible when status/shelf is focused. | 1308 // Verifies the shelf is visible when status/shelf is focused. |
| 1304 TEST_F(ShelfLayoutManagerTest, VisibleWhenStatusOrShelfFocused) { | 1309 TEST_F(ShelfLayoutManagerTest, VisibleWhenStatusOrShelfFocused) { |
| 1305 // Since ShelfLayoutManager queries for mouse location, move the mouse so | 1310 // Since ShelfLayoutManager queries for mouse location, move the mouse so |
| 1306 // it isn't over the shelf. | 1311 // it isn't over the shelf. |
| 1307 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 1312 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| 1308 gfx::Point()); | 1313 gfx::Point()); |
| 1309 generator.MoveMouseTo(0, 0); | 1314 generator.MoveMouseTo(0, 0); |
| 1310 | 1315 |
| 1311 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 1316 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 1312 views::Widget* widget = new views::Widget; | 1317 views::Widget* widget = new views::Widget; |
| 1313 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 1318 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 1314 params.bounds = gfx::Rect(0, 0, 200, 200); | 1319 params.bounds = gfx::Rect(0, 0, 200, 200); |
| 1315 params.context = CurrentContext(); | 1320 params.context = CurrentContext(); |
| 1316 // Widget is now owned by the parent window. | 1321 // Widget is now owned by the parent window. |
| 1317 widget->Init(params); | 1322 widget->Init(params); |
| 1318 widget->Show(); | 1323 widget->Show(); |
| 1319 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1324 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1320 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 1325 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state()); |
| 1321 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 1326 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 1322 | 1327 |
| 1323 // Focus the shelf. Have to go through the focus cycler as normal focus | 1328 // Focus the shelf. Have to go through the focus cycler as normal focus |
| 1324 // requests to it do nothing. | 1329 // requests to it do nothing. |
| 1325 GetShelfWidget()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD); | 1330 GetShelfWidget()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD); |
| 1326 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 1331 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state()); |
| 1327 | 1332 |
| 1328 widget->Activate(); | 1333 widget->Activate(); |
| 1329 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 1334 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 1330 | 1335 |
| 1331 // Trying to activate the status should fail, since we only allow activating | 1336 // Trying to activate the status should fail, since we only allow activating |
| 1332 // it when the user is using the keyboard (i.e. through FocusCycler). | 1337 // it when the user is using the keyboard (i.e. through FocusCycler). |
| 1333 GetShelfWidget()->status_area_widget()->Activate(); | 1338 GetShelfWidget()->status_area_widget()->Activate(); |
| 1334 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 1339 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 1335 | 1340 |
| 1336 GetShelfWidget()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD); | 1341 GetShelfWidget()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD); |
| 1337 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 1342 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state()); |
| 1338 } | 1343 } |
| 1339 | 1344 |
| 1340 // Makes sure shelf will be visible when app list opens as shelf is in | 1345 // Makes sure shelf will be visible when app list opens as shelf is in |
| 1341 // SHELF_VISIBLE state,and toggling app list won't change shelf | 1346 // SHELF_VISIBLE state,and toggling app list won't change shelf |
| 1342 // visibility state. | 1347 // visibility state. |
| 1343 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfVisibleState) { | 1348 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfVisibleState) { |
| 1344 Shell* shell = Shell::GetInstance(); | 1349 Shell* shell = Shell::GetInstance(); |
| 1345 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 1350 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 1346 shelf->LayoutShelf(); | 1351 layout_manager->LayoutShelf(); |
| 1347 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1352 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1348 | 1353 |
| 1349 // Create a normal unmaximized windowm shelf should be visible. | 1354 // Create a normal unmaximized windowm shelf should be visible. |
| 1350 aura::Window* window = CreateTestWindow(); | 1355 aura::Window* window = CreateTestWindow(); |
| 1351 window->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1356 window->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1352 window->Show(); | 1357 window->Show(); |
| 1353 EXPECT_FALSE(shell->GetAppListTargetVisibility()); | 1358 EXPECT_FALSE(shell->GetAppListTargetVisibility()); |
| 1354 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 1359 EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state()); |
| 1355 | 1360 |
| 1356 // Show app list and the shelf stays visible. | 1361 // Show app list and the shelf stays visible. |
| 1357 shell->ShowAppList(nullptr); | 1362 shell->ShowAppList(nullptr); |
| 1358 EXPECT_TRUE(shell->GetAppListTargetVisibility()); | 1363 EXPECT_TRUE(shell->GetAppListTargetVisibility()); |
| 1359 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 1364 EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state()); |
| 1360 | 1365 |
| 1361 // Hide app list and the shelf stays visible. | 1366 // Hide app list and the shelf stays visible. |
| 1362 shell->DismissAppList(); | 1367 shell->DismissAppList(); |
| 1363 EXPECT_FALSE(shell->GetAppListTargetVisibility()); | 1368 EXPECT_FALSE(shell->GetAppListTargetVisibility()); |
| 1364 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 1369 EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state()); |
| 1365 } | 1370 } |
| 1366 | 1371 |
| 1367 // Makes sure shelf will be shown with SHELF_AUTO_HIDE_SHOWN state | 1372 // Makes sure shelf will be shown with SHELF_AUTO_HIDE_SHOWN state |
| 1368 // when app list opens as shelf is in SHELF_AUTO_HIDE state, and | 1373 // when app list opens as shelf is in SHELF_AUTO_HIDE state, and |
| 1369 // toggling app list won't change shelf visibility state. | 1374 // toggling app list won't change shelf visibility state. |
| 1370 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) { | 1375 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) { |
| 1371 Shell* shell = Shell::GetInstance(); | 1376 Shell* shell = Shell::GetInstance(); |
| 1372 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 1377 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 1373 shelf->LayoutShelf(); | 1378 layout_manager->LayoutShelf(); |
| 1374 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1379 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1375 | 1380 |
| 1376 // Create a window and show it in maximized state. | 1381 // Create a window and show it in maximized state. |
| 1377 aura::Window* window = CreateTestWindow(); | 1382 aura::Window* window = CreateTestWindow(); |
| 1378 window->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1383 window->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1379 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1384 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 1380 window->Show(); | 1385 window->Show(); |
| 1381 wm::ActivateWindow(window); | 1386 wm::ActivateWindow(window); |
| 1382 | 1387 |
| 1383 EXPECT_FALSE(shell->GetAppListTargetVisibility()); | 1388 EXPECT_FALSE(shell->GetAppListTargetVisibility()); |
| 1384 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 1389 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state()); |
| 1385 | 1390 |
| 1386 // Show app list. | 1391 // Show app list. |
| 1387 shell->ShowAppList(nullptr); | 1392 shell->ShowAppList(nullptr); |
| 1388 // The shelf's auto hide state won't be changed until the timer fires, so | 1393 // The shelf's auto hide state won't be changed until the timer fires, so |
| 1389 // calling shell->UpdateShelfVisibility() is kind of manually helping it to | 1394 // calling shell->UpdateShelfVisibility() is kind of manually helping it to |
| 1390 // update the state. | 1395 // update the state. |
| 1391 shell->UpdateShelfVisibility(); | 1396 shell->UpdateShelfVisibility(); |
| 1392 EXPECT_TRUE(shell->GetAppListTargetVisibility()); | 1397 EXPECT_TRUE(shell->GetAppListTargetVisibility()); |
| 1393 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 1398 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state()); |
| 1394 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 1399 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state()); |
| 1395 | 1400 |
| 1396 // Hide app list. | 1401 // Hide app list. |
| 1397 shell->DismissAppList(); | 1402 shell->DismissAppList(); |
| 1398 EXPECT_FALSE(shell->GetAppListTargetVisibility()); | 1403 EXPECT_FALSE(shell->GetAppListTargetVisibility()); |
| 1399 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 1404 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state()); |
| 1400 } | 1405 } |
| 1401 | 1406 |
| 1402 // Makes sure that when we have dual displays, with one or both shelves are set | 1407 // Makes sure that when we have dual displays, with one or both shelves are set |
| 1403 // to AutoHide, viewing the AppList on one of them doesn't unhide the other | 1408 // to AutoHide, viewing the AppList on one of them doesn't unhide the other |
| 1404 // hidden shelf. | 1409 // hidden shelf. |
| 1405 TEST_F(ShelfLayoutManagerTest, DualDisplayOpenAppListWithShelfAutoHideState) { | 1410 TEST_F(ShelfLayoutManagerTest, DualDisplayOpenAppListWithShelfAutoHideState) { |
| 1406 if (!SupportsMultipleDisplays()) | 1411 if (!SupportsMultipleDisplays()) |
| 1407 return; | 1412 return; |
| 1408 | 1413 |
| 1409 // Create two displays. | 1414 // Create two displays. |
| 1410 Shell* shell = Shell::GetInstance(); | 1415 Shell* shell = Shell::GetInstance(); |
| 1411 DisplayManager* display_manager = shell->display_manager(); | 1416 DisplayManager* display_manager = shell->display_manager(); |
| 1412 EXPECT_EQ(1U, display_manager->GetNumDisplays()); | 1417 EXPECT_EQ(1U, display_manager->GetNumDisplays()); |
| 1413 UpdateDisplay("0+0-200x200,+200+0-100x100"); | 1418 UpdateDisplay("0+0-200x200,+200+0-100x100"); |
| 1414 EXPECT_EQ(2U, display_manager->GetNumDisplays()); | 1419 EXPECT_EQ(2U, display_manager->GetNumDisplays()); |
| 1415 | 1420 |
| 1416 WindowTreeHostManager* window_tree_host_manager = | 1421 WindowTreeHostManager* window_tree_host_manager = |
| 1417 shell->window_tree_host_manager(); | 1422 shell->window_tree_host_manager(); |
| 1418 aura::Window::Windows root_windows = | 1423 aura::Window::Windows root_windows = |
| 1419 window_tree_host_manager->GetAllRootWindows(); | 1424 window_tree_host_manager->GetAllRootWindows(); |
| 1420 EXPECT_EQ(root_windows.size(), 2U); | 1425 EXPECT_EQ(root_windows.size(), 2U); |
| 1421 | 1426 |
| 1422 // Get the shelves in both displays and set them to be 'AutoHide'. | 1427 // Get the shelves in both displays and set them to be 'AutoHide'. |
| 1423 ShelfLayoutManager* shelf_1 = | 1428 ShelfLayoutManager* shelf_1 = |
|
msw
2016/06/01 00:53:24
nit: layout_manager_1 (and layout_manager_2 below)
James Cook
2016/06/01 15:53:06
Changed to Shelf*.
| |
| 1424 GetRootWindowController(root_windows[0])->GetShelfLayoutManager(); | 1429 GetRootWindowController(root_windows[0])->GetShelfLayoutManager(); |
| 1425 ShelfLayoutManager* shelf_2 = | 1430 ShelfLayoutManager* shelf_2 = |
| 1426 GetRootWindowController(root_windows[1])->GetShelfLayoutManager(); | 1431 GetRootWindowController(root_windows[1])->GetShelfLayoutManager(); |
| 1427 EXPECT_NE(shelf_1, shelf_2); | 1432 EXPECT_NE(shelf_1, shelf_2); |
| 1428 EXPECT_NE(shelf_1->shelf_widget()->GetNativeWindow()->GetRootWindow(), | 1433 EXPECT_NE(shelf_1->shelf_widget()->GetNativeWindow()->GetRootWindow(), |
| 1429 shelf_2->shelf_widget()->GetNativeWindow()->GetRootWindow()); | 1434 shelf_2->shelf_widget()->GetNativeWindow()->GetRootWindow()); |
| 1430 shelf_1->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1435 shelf_1->shelf_widget()->shelf()->SetAutoHideBehavior( |
| 1436 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | |
| 1431 shelf_1->LayoutShelf(); | 1437 shelf_1->LayoutShelf(); |
| 1432 shelf_2->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1438 shelf_2->shelf_widget()->shelf()->SetAutoHideBehavior( |
| 1439 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | |
| 1433 shelf_2->LayoutShelf(); | 1440 shelf_2->LayoutShelf(); |
| 1434 | 1441 |
| 1435 // Create a window in each display and show them in maximized state. | 1442 // Create a window in each display and show them in maximized state. |
| 1436 aura::Window* window_1 = CreateTestWindowInParent(root_windows[0]); | 1443 aura::Window* window_1 = CreateTestWindowInParent(root_windows[0]); |
| 1437 window_1->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1444 window_1->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1438 window_1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1445 window_1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 1439 window_1->Show(); | 1446 window_1->Show(); |
| 1440 aura::Window* window_2 = CreateTestWindowInParent(root_windows[1]); | 1447 aura::Window* window_2 = CreateTestWindowInParent(root_windows[1]); |
| 1441 window_2->SetBounds(gfx::Rect(201, 0, 100, 100)); | 1448 window_2->SetBounds(gfx::Rect(201, 0, 100, 100)); |
| 1442 window_2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1449 window_2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1475 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->visibility_state()); | 1482 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->visibility_state()); |
| 1476 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->visibility_state()); | 1483 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->visibility_state()); |
| 1477 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->auto_hide_state()); | 1484 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->auto_hide_state()); |
| 1478 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->auto_hide_state()); | 1485 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->auto_hide_state()); |
| 1479 } | 1486 } |
| 1480 | 1487 |
| 1481 // Makes sure the shelf will be hidden when we have a fullscreen window, and it | 1488 // Makes sure the shelf will be hidden when we have a fullscreen window, and it |
| 1482 // will unhide when we open the app list. | 1489 // will unhide when we open the app list. |
| 1483 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfHiddenState) { | 1490 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfHiddenState) { |
| 1484 Shell* shell = Shell::GetInstance(); | 1491 Shell* shell = Shell::GetInstance(); |
| 1485 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 1492 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 1486 // For shelf to be visible, app list is not open in initial state. | 1493 // For shelf to be visible, app list is not open in initial state. |
| 1487 shelf->LayoutShelf(); | 1494 layout_manager->LayoutShelf(); |
| 1488 | 1495 |
| 1489 // Create a window and make it full screen. | 1496 // Create a window and make it full screen. |
| 1490 aura::Window* window = CreateTestWindow(); | 1497 aura::Window* window = CreateTestWindow(); |
| 1491 window->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1498 window->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1492 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 1499 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 1493 window->Show(); | 1500 window->Show(); |
| 1494 wm::ActivateWindow(window); | 1501 wm::ActivateWindow(window); |
| 1495 | 1502 |
| 1496 // App list and shelf is not shown. | 1503 // App list and shelf is not shown. |
| 1497 EXPECT_FALSE(shell->GetAppListTargetVisibility()); | 1504 EXPECT_FALSE(shell->GetAppListTargetVisibility()); |
| 1498 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); | 1505 EXPECT_EQ(SHELF_HIDDEN, layout_manager->visibility_state()); |
| 1499 | 1506 |
| 1500 // Show app list. | 1507 // Show app list. |
| 1501 shell->ShowAppList(nullptr); | 1508 shell->ShowAppList(nullptr); |
| 1502 EXPECT_TRUE(shell->GetAppListTargetVisibility()); | 1509 EXPECT_TRUE(shell->GetAppListTargetVisibility()); |
| 1503 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 1510 EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state()); |
| 1504 | 1511 |
| 1505 // Hide app list. | 1512 // Hide app list. |
| 1506 shell->DismissAppList(); | 1513 shell->DismissAppList(); |
| 1507 EXPECT_FALSE(shell->GetAppListTargetVisibility()); | 1514 EXPECT_FALSE(shell->GetAppListTargetVisibility()); |
| 1508 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); | 1515 EXPECT_EQ(SHELF_HIDDEN, layout_manager->visibility_state()); |
| 1509 } | 1516 } |
| 1510 | 1517 |
| 1511 // Tests the correct behavior of the shelf when there is a system modal window | 1518 // Tests the correct behavior of the shelf when there is a system modal window |
| 1512 // open when we have a single display. | 1519 // open when we have a single display. |
| 1513 TEST_F(ShelfLayoutManagerTest, ShelfWithSystemModalWindowSingleDisplay) { | 1520 TEST_F(ShelfLayoutManagerTest, ShelfWithSystemModalWindowSingleDisplay) { |
| 1514 Shell* shell = Shell::GetInstance(); | 1521 Shell* shell = Shell::GetInstance(); |
| 1515 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 1522 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 1516 shelf->LayoutShelf(); | 1523 layout_manager->LayoutShelf(); |
| 1517 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1524 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1518 | 1525 |
| 1519 aura::Window* window = CreateTestWindow(); | 1526 aura::Window* window = CreateTestWindow(); |
| 1520 window->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1527 window->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1521 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1528 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 1522 window->Show(); | 1529 window->Show(); |
| 1523 wm::ActivateWindow(window); | 1530 wm::ActivateWindow(window); |
| 1524 | 1531 |
| 1525 // Enable system modal dialog, and make sure shelf is still hidden. | 1532 // Enable system modal dialog, and make sure shelf is still hidden. |
| 1526 shell->SimulateModalWindowOpenForTesting(true); | 1533 shell->SimulateModalWindowOpenForTesting(true); |
| 1527 EXPECT_TRUE(shell->IsSystemModalWindowOpen()); | 1534 EXPECT_TRUE(shell->IsSystemModalWindowOpen()); |
| 1528 EXPECT_FALSE(wm::CanActivateWindow(window)); | 1535 EXPECT_FALSE(wm::CanActivateWindow(window)); |
| 1529 shell->UpdateShelfVisibility(); | 1536 shell->UpdateShelfVisibility(); |
| 1530 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 1537 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state()); |
| 1531 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 1538 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 1532 } | 1539 } |
| 1533 | 1540 |
| 1534 // Tests the correct behavior of the shelf when there is a system modal window | 1541 // Tests the correct behavior of the shelf when there is a system modal window |
| 1535 // open when we have dual display. | 1542 // open when we have dual display. |
| 1536 TEST_F(ShelfLayoutManagerTest, ShelfWithSystemModalWindowDualDisplay) { | 1543 TEST_F(ShelfLayoutManagerTest, ShelfWithSystemModalWindowDualDisplay) { |
| 1537 if (!SupportsMultipleDisplays()) | 1544 if (!SupportsMultipleDisplays()) |
| 1538 return; | 1545 return; |
| 1539 | 1546 |
| 1540 // Create two displays. | 1547 // Create two displays. |
| 1541 Shell* shell = Shell::GetInstance(); | 1548 Shell* shell = Shell::GetInstance(); |
| 1542 DisplayManager* display_manager = shell->display_manager(); | 1549 DisplayManager* display_manager = shell->display_manager(); |
| 1543 UpdateDisplay("200x200,100x100"); | 1550 UpdateDisplay("200x200,100x100"); |
| 1544 EXPECT_EQ(2U, display_manager->GetNumDisplays()); | 1551 EXPECT_EQ(2U, display_manager->GetNumDisplays()); |
| 1545 | 1552 |
| 1546 WindowTreeHostManager* window_tree_host_manager = | 1553 WindowTreeHostManager* window_tree_host_manager = |
| 1547 shell->window_tree_host_manager(); | 1554 shell->window_tree_host_manager(); |
| 1548 aura::Window::Windows root_windows = | 1555 aura::Window::Windows root_windows = |
| 1549 window_tree_host_manager->GetAllRootWindows(); | 1556 window_tree_host_manager->GetAllRootWindows(); |
| 1550 EXPECT_EQ(2U, root_windows.size()); | 1557 EXPECT_EQ(2U, root_windows.size()); |
| 1551 | 1558 |
| 1552 // Get the shelves in both displays and set them to be 'AutoHide'. | 1559 // Get the shelves in both displays and set them to be 'AutoHide'. |
| 1553 ShelfLayoutManager* shelf_1 = | 1560 Shelf* shelf_1 = GetRootWindowController(root_windows[0])->GetShelf(); |
| 1561 Shelf* shelf_2 = GetRootWindowController(root_windows[1])->GetShelf(); | |
| 1562 ShelfLayoutManager* layout_manager_1 = | |
| 1554 GetRootWindowController(root_windows[0])->GetShelfLayoutManager(); | 1563 GetRootWindowController(root_windows[0])->GetShelfLayoutManager(); |
| 1555 ShelfLayoutManager* shelf_2 = | 1564 ShelfLayoutManager* layout_manager_2 = |
| 1556 GetRootWindowController(root_windows[1])->GetShelfLayoutManager(); | 1565 GetRootWindowController(root_windows[1])->GetShelfLayoutManager(); |
| 1557 EXPECT_NE(shelf_1, shelf_2); | 1566 EXPECT_NE(layout_manager_1, layout_manager_2); |
| 1558 EXPECT_NE(shelf_1->shelf_widget()->GetNativeWindow()->GetRootWindow(), | 1567 EXPECT_NE( |
| 1559 shelf_2->shelf_widget()->GetNativeWindow()->GetRootWindow()); | 1568 layout_manager_1->shelf_widget()->GetNativeWindow()->GetRootWindow(), |
| 1569 layout_manager_2->shelf_widget()->GetNativeWindow()->GetRootWindow()); | |
| 1560 shelf_1->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1570 shelf_1->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1561 shelf_1->LayoutShelf(); | 1571 layout_manager_1->LayoutShelf(); |
| 1562 shelf_2->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1572 shelf_2->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1563 shelf_2->LayoutShelf(); | 1573 layout_manager_2->LayoutShelf(); |
| 1564 | 1574 |
| 1565 // Create a window in each display and show them in maximized state. | 1575 // Create a window in each display and show them in maximized state. |
| 1566 aura::Window* window_1 = CreateTestWindowInParent(root_windows[0]); | 1576 aura::Window* window_1 = CreateTestWindowInParent(root_windows[0]); |
| 1567 window_1->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1577 window_1->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1568 window_1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1578 window_1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 1569 window_1->Show(); | 1579 window_1->Show(); |
| 1570 aura::Window* window_2 = CreateTestWindowInParent(root_windows[1]); | 1580 aura::Window* window_2 = CreateTestWindowInParent(root_windows[1]); |
| 1571 window_2->SetBounds(gfx::Rect(201, 0, 100, 100)); | 1581 window_2->SetBounds(gfx::Rect(201, 0, 100, 100)); |
| 1572 window_2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1582 window_2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 1573 window_2->Show(); | 1583 window_2->Show(); |
| 1574 | 1584 |
| 1575 EXPECT_EQ(shelf_1->shelf_widget()->GetNativeWindow()->GetRootWindow(), | 1585 EXPECT_EQ( |
| 1576 window_1->GetRootWindow()); | 1586 layout_manager_1->shelf_widget()->GetNativeWindow()->GetRootWindow(), |
| 1577 EXPECT_EQ(shelf_2->shelf_widget()->GetNativeWindow()->GetRootWindow(), | 1587 window_1->GetRootWindow()); |
| 1578 window_2->GetRootWindow()); | 1588 EXPECT_EQ( |
| 1589 layout_manager_2->shelf_widget()->GetNativeWindow()->GetRootWindow(), | |
| 1590 window_2->GetRootWindow()); | |
| 1579 EXPECT_TRUE(window_1->IsVisible()); | 1591 EXPECT_TRUE(window_1->IsVisible()); |
| 1580 EXPECT_TRUE(window_2->IsVisible()); | 1592 EXPECT_TRUE(window_2->IsVisible()); |
| 1581 | 1593 |
| 1582 // Enable system modal dialog, and make sure both shelves are still hidden. | 1594 // Enable system modal dialog, and make sure both shelves are still hidden. |
| 1583 shell->SimulateModalWindowOpenForTesting(true); | 1595 shell->SimulateModalWindowOpenForTesting(true); |
| 1584 EXPECT_TRUE(shell->IsSystemModalWindowOpen()); | 1596 EXPECT_TRUE(shell->IsSystemModalWindowOpen()); |
| 1585 EXPECT_FALSE(wm::CanActivateWindow(window_1)); | 1597 EXPECT_FALSE(wm::CanActivateWindow(window_1)); |
| 1586 EXPECT_FALSE(wm::CanActivateWindow(window_2)); | 1598 EXPECT_FALSE(wm::CanActivateWindow(window_2)); |
| 1587 shell->UpdateShelfVisibility(); | 1599 shell->UpdateShelfVisibility(); |
| 1588 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->visibility_state()); | 1600 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager_1->visibility_state()); |
| 1589 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->auto_hide_state()); | 1601 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager_1->auto_hide_state()); |
| 1590 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->visibility_state()); | 1602 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager_2->visibility_state()); |
| 1591 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->auto_hide_state()); | 1603 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager_2->auto_hide_state()); |
| 1592 } | 1604 } |
| 1593 | 1605 |
| 1594 // Tests that the shelf is only hidden for a fullscreen window at the front and | 1606 // Tests that the shelf is only hidden for a fullscreen window at the front and |
| 1595 // toggles visibility when another window is activated. | 1607 // toggles visibility when another window is activated. |
| 1596 TEST_F(ShelfLayoutManagerTest, FullscreenWindowInFrontHidesShelf) { | 1608 TEST_F(ShelfLayoutManagerTest, FullscreenWindowInFrontHidesShelf) { |
| 1597 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 1609 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 1598 | 1610 |
| 1599 // Create a window and make it full screen. | 1611 // Create a window and make it full screen. |
| 1600 aura::Window* window1 = CreateTestWindow(); | 1612 aura::Window* window1 = CreateTestWindow(); |
| 1601 window1->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1613 window1->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1602 window1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 1614 window1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 1603 window1->Show(); | 1615 window1->Show(); |
| 1604 | 1616 |
| 1605 aura::Window* window2 = CreateTestWindow(); | 1617 aura::Window* window2 = CreateTestWindow(); |
| 1606 window2->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1618 window2->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1607 window2->Show(); | 1619 window2->Show(); |
| 1608 | 1620 |
| 1609 wm::GetWindowState(window1)->Activate(); | 1621 wm::GetWindowState(window1)->Activate(); |
| 1610 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); | 1622 EXPECT_EQ(SHELF_HIDDEN, layout_manager->visibility_state()); |
| 1611 | 1623 |
| 1612 wm::GetWindowState(window2)->Activate(); | 1624 wm::GetWindowState(window2)->Activate(); |
| 1613 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 1625 EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state()); |
| 1614 | 1626 |
| 1615 wm::GetWindowState(window1)->Activate(); | 1627 wm::GetWindowState(window1)->Activate(); |
| 1616 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); | 1628 EXPECT_EQ(SHELF_HIDDEN, layout_manager->visibility_state()); |
| 1617 } | 1629 } |
| 1618 | 1630 |
| 1619 // Test the behavior of the shelf when a window on one display is fullscreen | 1631 // Test the behavior of the shelf when a window on one display is fullscreen |
| 1620 // but the other display has the active window. | 1632 // but the other display has the active window. |
| 1621 TEST_F(ShelfLayoutManagerTest, FullscreenWindowOnSecondDisplay) { | 1633 TEST_F(ShelfLayoutManagerTest, FullscreenWindowOnSecondDisplay) { |
| 1622 if (!SupportsMultipleDisplays()) | 1634 if (!SupportsMultipleDisplays()) |
| 1623 return; | 1635 return; |
| 1624 | 1636 |
| 1625 UpdateDisplay("800x600,800x600"); | 1637 UpdateDisplay("800x600,800x600"); |
| 1626 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 1638 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 1655 | 1667 |
| 1656 #if defined(OS_WIN) | 1668 #if defined(OS_WIN) |
| 1657 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 | 1669 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 |
| 1658 #define MAYBE_SetAlignment DISABLED_SetAlignment | 1670 #define MAYBE_SetAlignment DISABLED_SetAlignment |
| 1659 #else | 1671 #else |
| 1660 #define MAYBE_SetAlignment SetAlignment | 1672 #define MAYBE_SetAlignment SetAlignment |
| 1661 #endif | 1673 #endif |
| 1662 | 1674 |
| 1663 // Tests wm::SHELF_ALIGNMENT_(LEFT, RIGHT). | 1675 // Tests wm::SHELF_ALIGNMENT_(LEFT, RIGHT). |
| 1664 TEST_F(ShelfLayoutManagerTest, MAYBE_SetAlignment) { | 1676 TEST_F(ShelfLayoutManagerTest, MAYBE_SetAlignment) { |
| 1665 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 1677 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 1666 // Force an initial layout. | 1678 // Force an initial layout. |
| 1667 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1679 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1668 shelf->LayoutShelf(); | 1680 layout_manager->LayoutShelf(); |
| 1669 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 1681 EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state()); |
| 1670 | 1682 |
| 1671 shelf->SetAlignment(wm::SHELF_ALIGNMENT_LEFT); | 1683 GetShelf()->SetAlignment(wm::SHELF_ALIGNMENT_LEFT); |
| 1672 gfx::Rect shelf_bounds( | 1684 gfx::Rect shelf_bounds( |
| 1673 GetShelfWidget()->GetWindowBoundsInScreen()); | 1685 GetShelfWidget()->GetWindowBoundsInScreen()); |
| 1674 const display::Screen* screen = display::Screen::GetScreen(); | 1686 const display::Screen* screen = display::Screen::GetScreen(); |
| 1675 display::Display display = | 1687 display::Display display = |
| 1676 screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | 1688 screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
| 1677 ASSERT_NE(-1, display.id()); | 1689 ASSERT_NE(-1, display.id()); |
| 1678 EXPECT_EQ(shelf->GetIdealBounds().width(), | 1690 EXPECT_EQ(layout_manager->GetIdealBounds().width(), |
| 1679 display.GetWorkAreaInsets().left()); | 1691 display.GetWorkAreaInsets().left()); |
| 1680 EXPECT_GE( | 1692 EXPECT_GE( |
| 1681 shelf_bounds.width(), | 1693 shelf_bounds.width(), |
| 1682 GetShelfWidget()->GetContentsView()->GetPreferredSize().width()); | 1694 GetShelfWidget()->GetContentsView()->GetPreferredSize().width()); |
| 1683 EXPECT_EQ(wm::SHELF_ALIGNMENT_LEFT, GetSystemTray()->shelf_alignment()); | 1695 EXPECT_EQ(wm::SHELF_ALIGNMENT_LEFT, GetSystemTray()->shelf_alignment()); |
| 1684 StatusAreaWidget* status_area_widget = GetShelfWidget()->status_area_widget(); | 1696 StatusAreaWidget* status_area_widget = GetShelfWidget()->status_area_widget(); |
| 1685 gfx::Rect status_bounds(status_area_widget->GetWindowBoundsInScreen()); | 1697 gfx::Rect status_bounds(status_area_widget->GetWindowBoundsInScreen()); |
| 1686 EXPECT_GE(status_bounds.width(), | 1698 EXPECT_GE(status_bounds.width(), |
| 1687 status_area_widget->GetContentsView()->GetPreferredSize().width()); | 1699 status_area_widget->GetContentsView()->GetPreferredSize().width()); |
| 1688 EXPECT_EQ(shelf->GetIdealBounds().width(), | 1700 EXPECT_EQ(layout_manager->GetIdealBounds().width(), |
| 1689 display.GetWorkAreaInsets().left()); | 1701 display.GetWorkAreaInsets().left()); |
| 1690 EXPECT_EQ(0, display.GetWorkAreaInsets().top()); | 1702 EXPECT_EQ(0, display.GetWorkAreaInsets().top()); |
| 1691 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); | 1703 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); |
| 1692 EXPECT_EQ(0, display.GetWorkAreaInsets().right()); | 1704 EXPECT_EQ(0, display.GetWorkAreaInsets().right()); |
| 1693 EXPECT_EQ(display.bounds().x(), shelf_bounds.x()); | 1705 EXPECT_EQ(display.bounds().x(), shelf_bounds.x()); |
| 1694 EXPECT_EQ(display.bounds().y(), shelf_bounds.y()); | 1706 EXPECT_EQ(display.bounds().y(), shelf_bounds.y()); |
| 1695 EXPECT_EQ(display.bounds().height(), shelf_bounds.height()); | 1707 EXPECT_EQ(display.bounds().height(), shelf_bounds.height()); |
| 1696 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1708 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1697 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | 1709 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
| 1698 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, | 1710 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, |
| 1699 display.GetWorkAreaInsets().left()); | 1711 display.GetWorkAreaInsets().left()); |
| 1700 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, display.work_area().x()); | 1712 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, display.work_area().x()); |
| 1701 | 1713 |
| 1702 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1714 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1703 shelf->SetAlignment(wm::SHELF_ALIGNMENT_RIGHT); | 1715 GetShelf()->SetAlignment(wm::SHELF_ALIGNMENT_RIGHT); |
| 1704 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | 1716 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
| 1705 shelf_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); | 1717 shelf_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); |
| 1706 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | 1718 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
| 1707 ASSERT_NE(-1, display.id()); | 1719 ASSERT_NE(-1, display.id()); |
| 1708 EXPECT_EQ(shelf->GetIdealBounds().width(), | 1720 EXPECT_EQ(layout_manager->GetIdealBounds().width(), |
| 1709 display.GetWorkAreaInsets().right()); | 1721 display.GetWorkAreaInsets().right()); |
| 1710 EXPECT_GE(shelf_bounds.width(), | 1722 EXPECT_GE(shelf_bounds.width(), |
| 1711 GetShelfWidget()->GetContentsView()->GetPreferredSize().width()); | 1723 GetShelfWidget()->GetContentsView()->GetPreferredSize().width()); |
| 1712 EXPECT_EQ(wm::SHELF_ALIGNMENT_RIGHT, GetSystemTray()->shelf_alignment()); | 1724 EXPECT_EQ(wm::SHELF_ALIGNMENT_RIGHT, GetSystemTray()->shelf_alignment()); |
| 1713 status_bounds = gfx::Rect(status_area_widget->GetWindowBoundsInScreen()); | 1725 status_bounds = gfx::Rect(status_area_widget->GetWindowBoundsInScreen()); |
| 1714 EXPECT_GE(status_bounds.width(), | 1726 EXPECT_GE(status_bounds.width(), |
| 1715 status_area_widget->GetContentsView()->GetPreferredSize().width()); | 1727 status_area_widget->GetContentsView()->GetPreferredSize().width()); |
| 1716 EXPECT_EQ(shelf->GetIdealBounds().width(), | 1728 EXPECT_EQ(layout_manager->GetIdealBounds().width(), |
| 1717 display.GetWorkAreaInsets().right()); | 1729 display.GetWorkAreaInsets().right()); |
| 1718 EXPECT_EQ(0, display.GetWorkAreaInsets().top()); | 1730 EXPECT_EQ(0, display.GetWorkAreaInsets().top()); |
| 1719 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); | 1731 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); |
| 1720 EXPECT_EQ(0, display.GetWorkAreaInsets().left()); | 1732 EXPECT_EQ(0, display.GetWorkAreaInsets().left()); |
| 1721 EXPECT_EQ(display.work_area().right(), shelf_bounds.x()); | 1733 EXPECT_EQ(display.work_area().right(), shelf_bounds.x()); |
| 1722 EXPECT_EQ(display.bounds().y(), shelf_bounds.y()); | 1734 EXPECT_EQ(display.bounds().y(), shelf_bounds.y()); |
| 1723 EXPECT_EQ(display.bounds().height(), shelf_bounds.height()); | 1735 EXPECT_EQ(display.bounds().height(), shelf_bounds.height()); |
| 1724 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1736 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1725 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | 1737 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
| 1726 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, | 1738 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, |
| 1727 display.GetWorkAreaInsets().right()); | 1739 display.GetWorkAreaInsets().right()); |
| 1728 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, | 1740 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, |
| 1729 display.bounds().right() - display.work_area().right()); | 1741 display.bounds().right() - display.work_area().right()); |
| 1730 } | 1742 } |
| 1731 | 1743 |
| 1732 TEST_F(ShelfLayoutManagerTest, GestureEdgeSwipe) { | 1744 TEST_F(ShelfLayoutManagerTest, GestureEdgeSwipe) { |
| 1733 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 1745 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 1734 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1746 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1735 views::Widget* widget = new views::Widget; | 1747 views::Widget* widget = new views::Widget; |
| 1736 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 1748 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 1737 params.bounds = gfx::Rect(0, 0, 200, 200); | 1749 params.bounds = gfx::Rect(0, 0, 200, 200); |
| 1738 params.context = CurrentContext(); | 1750 params.context = CurrentContext(); |
| 1739 widget->Init(params); | 1751 widget->Init(params); |
| 1740 widget->Show(); | 1752 widget->Show(); |
| 1741 widget->Maximize(); | 1753 widget->Maximize(); |
| 1742 | 1754 |
| 1743 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 1755 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 1744 | 1756 |
| 1745 aura::Window* window = widget->GetNativeWindow(); | 1757 aura::Window* window = widget->GetNativeWindow(); |
| 1746 shelf->LayoutShelf(); | 1758 layout_manager->LayoutShelf(); |
| 1747 | 1759 |
| 1748 gfx::Rect shelf_shown = GetShelfWidget()->GetWindowBoundsInScreen(); | 1760 gfx::Rect shelf_shown = GetShelfWidget()->GetWindowBoundsInScreen(); |
| 1749 gfx::Rect bounds_shelf = window->bounds(); | 1761 gfx::Rect bounds_shelf = window->bounds(); |
| 1750 | 1762 |
| 1751 // Edge swipe when SHELF_VISIBLE should not change visibility state. | 1763 // Edge swipe when SHELF_VISIBLE should not change visibility state. |
| 1752 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 1764 EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state()); |
| 1753 generator.GestureEdgeSwipe(); | 1765 generator.GestureEdgeSwipe(); |
| 1754 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 1766 EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state()); |
| 1755 | 1767 |
| 1756 // Edge swipe when AUTO_HIDE_HIDDEN should change to AUTO_HIDE_SHOWN. | 1768 // Edge swipe when AUTO_HIDE_HIDDEN should change to AUTO_HIDE_SHOWN. |
| 1757 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1769 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1758 shelf->LayoutShelf(); | 1770 layout_manager->LayoutShelf(); |
| 1759 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 1771 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state()); |
| 1760 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 1772 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 1761 generator.GestureEdgeSwipe(); | 1773 generator.GestureEdgeSwipe(); |
| 1762 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 1774 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state()); |
| 1763 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 1775 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state()); |
| 1764 | 1776 |
| 1765 widget->SetFullscreen(true); | 1777 widget->SetFullscreen(true); |
| 1766 wm::GetWindowState(window)->set_hide_shelf_when_fullscreen(false); | 1778 wm::GetWindowState(window)->set_hide_shelf_when_fullscreen(false); |
| 1767 shelf->UpdateVisibilityState(); | 1779 layout_manager->UpdateVisibilityState(); |
| 1768 | 1780 |
| 1769 // Edge swipe in fullscreen + AUTO_HIDE_HIDDEN should show the shelf and | 1781 // Edge swipe in fullscreen + AUTO_HIDE_HIDDEN should show the shelf and |
| 1770 // remain fullscreen. | 1782 // remain fullscreen. |
| 1771 EXPECT_TRUE(widget->IsFullscreen()); | 1783 EXPECT_TRUE(widget->IsFullscreen()); |
| 1772 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 1784 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state()); |
| 1773 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 1785 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 1774 generator.GestureEdgeSwipe(); | 1786 generator.GestureEdgeSwipe(); |
| 1775 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 1787 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state()); |
| 1776 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 1788 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state()); |
| 1777 EXPECT_TRUE(widget->IsFullscreen()); | 1789 EXPECT_TRUE(widget->IsFullscreen()); |
| 1778 } | 1790 } |
| 1779 | 1791 |
| 1780 // Tests that gesture edge swipe events are forwarded to the right shelf on the | 1792 // Tests that gesture edge swipe events are forwarded to the right shelf on the |
| 1781 // right monitor (crbug.com/449851). | 1793 // right monitor (crbug.com/449851). |
| 1782 TEST_F(ShelfLayoutManagerTest, GestureEdgeSwipeMultiMonitor) { | 1794 TEST_F(ShelfLayoutManagerTest, GestureEdgeSwipeMultiMonitor) { |
| 1783 if (!SupportsMultipleDisplays()) | 1795 if (!SupportsMultipleDisplays()) |
| 1784 return; | 1796 return; |
| 1785 | 1797 |
| 1786 // Create two displays. | 1798 // Create two displays. |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 1802 window_1->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1814 window_1->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1803 window_1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1815 window_1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 1804 window_1->Show(); | 1816 window_1->Show(); |
| 1805 aura::Window* window_2 = | 1817 aura::Window* window_2 = |
| 1806 CreateTestWindowInParent(root_window_controllers[1]->GetRootWindow()); | 1818 CreateTestWindowInParent(root_window_controllers[1]->GetRootWindow()); |
| 1807 window_2->SetBounds(gfx::Rect(201, 0, 100, 100)); | 1819 window_2->SetBounds(gfx::Rect(201, 0, 100, 100)); |
| 1808 window_2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1820 window_2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 1809 window_2->Show(); | 1821 window_2->Show(); |
| 1810 | 1822 |
| 1811 // Make sure both are set to auto-hide and both are hidden. | 1823 // Make sure both are set to auto-hide and both are hidden. |
| 1812 shelf_1->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1824 Shelf::ForWindow(window_1)->SetAutoHideBehavior( |
| 1813 shelf_2->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1825 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1826 Shelf::ForWindow(window_2)->SetAutoHideBehavior( | |
| 1827 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | |
| 1814 shelf_1->LayoutShelf(); | 1828 shelf_1->LayoutShelf(); |
| 1815 shelf_2->LayoutShelf(); | 1829 shelf_2->LayoutShelf(); |
| 1816 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->visibility_state()); | 1830 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->visibility_state()); |
| 1817 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->visibility_state()); | 1831 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->visibility_state()); |
| 1818 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->auto_hide_state()); | 1832 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->auto_hide_state()); |
| 1819 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->auto_hide_state()); | 1833 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->auto_hide_state()); |
| 1820 | 1834 |
| 1821 ui::test::EventGenerator monitor_1_generator( | 1835 ui::test::EventGenerator monitor_1_generator( |
| 1822 root_window_controllers[0]->GetRootWindow()); | 1836 root_window_controllers[0]->GetRootWindow()); |
| 1823 ui::test::EventGenerator monitor_2_generator( | 1837 ui::test::EventGenerator monitor_2_generator( |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 1849 #define MAYBE_GestureDrag DISABLED_GestureDrag | 1863 #define MAYBE_GestureDrag DISABLED_GestureDrag |
| 1850 #else | 1864 #else |
| 1851 #define MAYBE_GestureDrag GestureDrag | 1865 #define MAYBE_GestureDrag GestureDrag |
| 1852 #endif | 1866 #endif |
| 1853 | 1867 |
| 1854 TEST_F(ShelfLayoutManagerTest, MAYBE_GestureDrag) { | 1868 TEST_F(ShelfLayoutManagerTest, MAYBE_GestureDrag) { |
| 1855 // Slop is an implementation detail of gesture recognition, and complicates | 1869 // Slop is an implementation detail of gesture recognition, and complicates |
| 1856 // these tests. Ignore it. | 1870 // these tests. Ignore it. |
| 1857 ui::GestureConfiguration::GetInstance() | 1871 ui::GestureConfiguration::GetInstance() |
| 1858 ->set_max_touch_move_in_pixels_for_click(0); | 1872 ->set_max_touch_move_in_pixels_for_click(0); |
| 1859 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | |
| 1860 { | 1873 { |
| 1861 SCOPED_TRACE("BOTTOM"); | 1874 SCOPED_TRACE("BOTTOM"); |
| 1862 RunGestureDragTests(gfx::Vector2d(0, 120)); | 1875 RunGestureDragTests(gfx::Vector2d(0, 120)); |
| 1863 } | 1876 } |
| 1864 | 1877 |
| 1865 { | 1878 { |
| 1866 SCOPED_TRACE("LEFT"); | 1879 SCOPED_TRACE("LEFT"); |
| 1867 shelf->SetAlignment(wm::SHELF_ALIGNMENT_LEFT); | 1880 GetShelf()->SetAlignment(wm::SHELF_ALIGNMENT_LEFT); |
| 1868 RunGestureDragTests(gfx::Vector2d(-120, 0)); | 1881 RunGestureDragTests(gfx::Vector2d(-120, 0)); |
| 1869 } | 1882 } |
| 1870 | 1883 |
| 1871 { | 1884 { |
| 1872 SCOPED_TRACE("RIGHT"); | 1885 SCOPED_TRACE("RIGHT"); |
| 1873 shelf->SetAlignment(wm::SHELF_ALIGNMENT_RIGHT); | 1886 GetShelf()->SetAlignment(wm::SHELF_ALIGNMENT_RIGHT); |
| 1874 RunGestureDragTests(gfx::Vector2d(120, 0)); | 1887 RunGestureDragTests(gfx::Vector2d(120, 0)); |
| 1875 } | 1888 } |
| 1876 } | 1889 } |
| 1877 | 1890 |
| 1878 TEST_F(ShelfLayoutManagerTest, WindowVisibilityDisablesAutoHide) { | 1891 TEST_F(ShelfLayoutManagerTest, WindowVisibilityDisablesAutoHide) { |
| 1879 if (!SupportsMultipleDisplays()) | 1892 if (!SupportsMultipleDisplays()) |
| 1880 return; | 1893 return; |
| 1881 | 1894 |
| 1882 UpdateDisplay("800x600,800x600"); | 1895 UpdateDisplay("800x600,800x600"); |
| 1883 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 1896 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 1884 shelf->LayoutShelf(); | 1897 layout_manager->LayoutShelf(); |
| 1885 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1898 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1886 | 1899 |
| 1887 // Create a visible window so auto-hide behavior is enforced | 1900 // Create a visible window so auto-hide behavior is enforced |
| 1888 views::Widget* dummy = CreateTestWidget(); | 1901 views::Widget* dummy = CreateTestWidget(); |
| 1889 | 1902 |
| 1890 // Window visible => auto hide behaves normally. | 1903 // Window visible => auto hide behaves normally. |
| 1891 shelf->UpdateVisibilityState(); | 1904 layout_manager->UpdateVisibilityState(); |
| 1892 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 1905 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 1893 | 1906 |
| 1894 // Window minimized => auto hide disabled. | 1907 // Window minimized => auto hide disabled. |
| 1895 dummy->Minimize(); | 1908 dummy->Minimize(); |
| 1896 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 1909 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state()); |
| 1897 | 1910 |
| 1898 // Window closed => auto hide disabled. | 1911 // Window closed => auto hide disabled. |
| 1899 dummy->CloseNow(); | 1912 dummy->CloseNow(); |
| 1900 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 1913 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state()); |
| 1901 | 1914 |
| 1902 // Multiple window test | 1915 // Multiple window test |
| 1903 views::Widget* window1 = CreateTestWidget(); | 1916 views::Widget* window1 = CreateTestWidget(); |
| 1904 views::Widget* window2 = CreateTestWidget(); | 1917 views::Widget* window2 = CreateTestWidget(); |
| 1905 | 1918 |
| 1906 // both visible => normal autohide | 1919 // both visible => normal autohide |
| 1907 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 1920 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 1908 | 1921 |
| 1909 // either minimzed => normal autohide | 1922 // either minimzed => normal autohide |
| 1910 window2->Minimize(); | 1923 window2->Minimize(); |
| 1911 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 1924 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 1912 window2->Restore(); | 1925 window2->Restore(); |
| 1913 window1->Minimize(); | 1926 window1->Minimize(); |
| 1914 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 1927 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 1915 | 1928 |
| 1916 // both minimized => disable auto hide | 1929 // both minimized => disable auto hide |
| 1917 window2->Minimize(); | 1930 window2->Minimize(); |
| 1918 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 1931 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state()); |
| 1919 | 1932 |
| 1920 // Test moving windows to/from other display. | 1933 // Test moving windows to/from other display. |
| 1921 window2->Restore(); | 1934 window2->Restore(); |
| 1922 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 1935 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 1923 // Move to second display. | 1936 // Move to second display. |
| 1924 window2->SetBounds(gfx::Rect(850, 50, 50, 50)); | 1937 window2->SetBounds(gfx::Rect(850, 50, 50, 50)); |
| 1925 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 1938 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state()); |
| 1926 // Move back to primary display. | 1939 // Move back to primary display. |
| 1927 window2->SetBounds(gfx::Rect(50, 50, 50, 50)); | 1940 window2->SetBounds(gfx::Rect(50, 50, 50, 50)); |
| 1928 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 1941 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 1929 } | 1942 } |
| 1930 | 1943 |
| 1931 // Test that the shelf animates back to its normal position upon a user | 1944 // Test that the shelf animates back to its normal position upon a user |
| 1932 // completing a gesture drag. | 1945 // completing a gesture drag. |
| 1933 TEST_F(ShelfLayoutManagerTest, ShelfAnimatesWhenGestureComplete) { | 1946 TEST_F(ShelfLayoutManagerTest, ShelfAnimatesWhenGestureComplete) { |
| 1934 if (!SupportsHostWindowResize()) | 1947 if (!SupportsHostWindowResize()) |
| 1935 return; | 1948 return; |
| 1936 | 1949 |
| 1937 // Test the shelf animates back to its original visible bounds when it is | 1950 // Test the shelf animates back to its original visible bounds when it is |
| 1938 // dragged when there are no visible windows. | 1951 // dragged when there are no visible windows. |
| 1939 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 1952 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 1940 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1953 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1941 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 1954 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state()); |
| 1942 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 1955 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state()); |
| 1943 gfx::Rect visible_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); | 1956 gfx::Rect visible_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); |
| 1944 { | 1957 { |
| 1945 // Enable animations so that we can make sure that they occur. | 1958 // Enable animations so that we can make sure that they occur. |
| 1946 ui::ScopedAnimationDurationScaleMode regular_animations( | 1959 ui::ScopedAnimationDurationScaleMode regular_animations( |
| 1947 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); | 1960 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); |
| 1948 | 1961 |
| 1949 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 1962 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 1950 gfx::Rect shelf_bounds_in_screen = | 1963 gfx::Rect shelf_bounds_in_screen = |
| 1951 GetShelfWidget()->GetWindowBoundsInScreen(); | 1964 GetShelfWidget()->GetWindowBoundsInScreen(); |
| 1952 gfx::Point start(shelf_bounds_in_screen.CenterPoint()); | 1965 gfx::Point start(shelf_bounds_in_screen.CenterPoint()); |
| 1953 gfx::Point end(start.x(), shelf_bounds_in_screen.bottom()); | 1966 gfx::Point end(start.x(), shelf_bounds_in_screen.bottom()); |
| 1954 generator.GestureScrollSequence(start, end, | 1967 generator.GestureScrollSequence(start, end, |
| 1955 base::TimeDelta::FromMilliseconds(10), 5); | 1968 base::TimeDelta::FromMilliseconds(10), 5); |
| 1956 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 1969 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state()); |
| 1957 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 1970 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state()); |
| 1958 | 1971 |
| 1959 ShelfAnimationWaiter waiter(visible_bounds); | 1972 ShelfAnimationWaiter waiter(visible_bounds); |
| 1960 // Wait till the animation completes and check that it occurred. | 1973 // Wait till the animation completes and check that it occurred. |
| 1961 waiter.WaitTillDoneAnimating(); | 1974 waiter.WaitTillDoneAnimating(); |
| 1962 EXPECT_TRUE(waiter.WasValidAnimation()); | 1975 EXPECT_TRUE(waiter.WasValidAnimation()); |
| 1963 } | 1976 } |
| 1964 | 1977 |
| 1965 // Create a visible window so auto-hide behavior is enforced. | 1978 // Create a visible window so auto-hide behavior is enforced. |
| 1966 CreateTestWidget(); | 1979 CreateTestWidget(); |
| 1967 | 1980 |
| 1968 // Get the bounds of the shelf when it is hidden. | 1981 // Get the bounds of the shelf when it is hidden. |
| 1969 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 1982 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state()); |
| 1970 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 1983 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 1971 gfx::Rect auto_hidden_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); | 1984 gfx::Rect auto_hidden_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); |
| 1972 | 1985 |
| 1973 { | 1986 { |
| 1974 // Enable the animations so that we can make sure they do occur. | 1987 // Enable the animations so that we can make sure they do occur. |
| 1975 ui::ScopedAnimationDurationScaleMode regular_animations( | 1988 ui::ScopedAnimationDurationScaleMode regular_animations( |
| 1976 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); | 1989 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); |
| 1977 | 1990 |
| 1978 gfx::Point start = | 1991 gfx::Point start = |
| 1979 GetShelfWidget()->GetWindowBoundsInScreen().CenterPoint(); | 1992 GetShelfWidget()->GetWindowBoundsInScreen().CenterPoint(); |
| 1980 gfx::Point end(start.x(), start.y() - 100); | 1993 gfx::Point end(start.x(), start.y() - 100); |
| 1981 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 1994 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 1982 | 1995 |
| 1983 // Test that the shelf animates to the visible bounds after a swipe up on | 1996 // Test that the shelf animates to the visible bounds after a swipe up on |
| 1984 // the auto hidden shelf. | 1997 // the auto hidden shelf. |
| 1985 generator.GestureScrollSequence(start, end, | 1998 generator.GestureScrollSequence(start, end, |
| 1986 base::TimeDelta::FromMilliseconds(10), 1); | 1999 base::TimeDelta::FromMilliseconds(10), 1); |
| 1987 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 2000 EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state()); |
| 1988 ShelfAnimationWaiter waiter1(visible_bounds); | 2001 ShelfAnimationWaiter waiter1(visible_bounds); |
| 1989 waiter1.WaitTillDoneAnimating(); | 2002 waiter1.WaitTillDoneAnimating(); |
| 1990 EXPECT_TRUE(waiter1.WasValidAnimation()); | 2003 EXPECT_TRUE(waiter1.WasValidAnimation()); |
| 1991 | 2004 |
| 1992 // Test that the shelf animates to the auto hidden bounds after a swipe up | 2005 // Test that the shelf animates to the auto hidden bounds after a swipe up |
| 1993 // on the visible shelf. | 2006 // on the visible shelf. |
| 1994 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 2007 EXPECT_EQ(SHELF_VISIBLE, layout_manager->visibility_state()); |
| 1995 generator.GestureScrollSequence(start, end, | 2008 generator.GestureScrollSequence(start, end, |
| 1996 base::TimeDelta::FromMilliseconds(10), 1); | 2009 base::TimeDelta::FromMilliseconds(10), 1); |
| 1997 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 2010 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state()); |
| 1998 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 2011 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 1999 ShelfAnimationWaiter waiter2(auto_hidden_bounds); | 2012 ShelfAnimationWaiter waiter2(auto_hidden_bounds); |
| 2000 waiter2.WaitTillDoneAnimating(); | 2013 waiter2.WaitTillDoneAnimating(); |
| 2001 EXPECT_TRUE(waiter2.WasValidAnimation()); | 2014 EXPECT_TRUE(waiter2.WasValidAnimation()); |
| 2002 } | 2015 } |
| 2003 } | 2016 } |
| 2004 | 2017 |
| 2005 TEST_F(ShelfLayoutManagerTest, ShelfFlickerOnTrayActivation) { | 2018 TEST_F(ShelfLayoutManagerTest, ShelfFlickerOnTrayActivation) { |
| 2006 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 2019 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 2007 | 2020 |
| 2008 // Create a visible window so auto-hide behavior is enforced. | 2021 // Create a visible window so auto-hide behavior is enforced. |
| 2009 CreateTestWidget(); | 2022 CreateTestWidget(); |
| 2010 | 2023 |
| 2011 // Turn on auto-hide for the shelf. | 2024 // Turn on auto-hide for the shelf. |
| 2012 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 2025 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 2013 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 2026 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state()); |
| 2014 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 2027 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, layout_manager->auto_hide_state()); |
| 2015 | 2028 |
| 2016 // Show the status menu. That should make the shelf visible again. | 2029 // Show the status menu. That should make the shelf visible again. |
| 2017 Shell::GetInstance()->accelerator_controller()->PerformActionIfEnabled( | 2030 Shell::GetInstance()->accelerator_controller()->PerformActionIfEnabled( |
| 2018 SHOW_SYSTEM_TRAY_BUBBLE); | 2031 SHOW_SYSTEM_TRAY_BUBBLE); |
| 2019 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 2032 EXPECT_EQ(SHELF_AUTO_HIDE, layout_manager->visibility_state()); |
| 2020 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 2033 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, layout_manager->auto_hide_state()); |
| 2021 EXPECT_TRUE(GetSystemTray()->HasSystemBubble()); | 2034 EXPECT_TRUE(GetSystemTray()->HasSystemBubble()); |
| 2022 } | 2035 } |
| 2023 | 2036 |
| 2024 TEST_F(ShelfLayoutManagerTest, WorkAreaChangeWorkspace) { | 2037 TEST_F(ShelfLayoutManagerTest, WorkAreaChangeWorkspace) { |
| 2025 // Make sure the shelf is always visible. | 2038 // Make sure the shelf is always visible. |
| 2026 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 2039 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 2027 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 2040 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 2028 shelf->LayoutShelf(); | 2041 layout_manager->LayoutShelf(); |
| 2029 | 2042 |
| 2030 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 2043 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 2031 params.bounds = gfx::Rect(0, 0, 200, 200); | 2044 params.bounds = gfx::Rect(0, 0, 200, 200); |
| 2032 params.context = CurrentContext(); | 2045 params.context = CurrentContext(); |
| 2033 views::Widget* widget_one = CreateTestWidgetWithParams(params); | 2046 views::Widget* widget_one = CreateTestWidgetWithParams(params); |
| 2034 widget_one->Maximize(); | 2047 widget_one->Maximize(); |
| 2035 | 2048 |
| 2036 views::Widget* widget_two = CreateTestWidgetWithParams(params); | 2049 views::Widget* widget_two = CreateTestWidgetWithParams(params); |
| 2037 widget_two->Maximize(); | 2050 widget_two->Maximize(); |
| 2038 widget_two->Activate(); | 2051 widget_two->Activate(); |
| 2039 | 2052 |
| 2040 // Both windows are maximized. They should be of the same size. | 2053 // Both windows are maximized. They should be of the same size. |
| 2041 EXPECT_EQ(widget_one->GetNativeWindow()->bounds().ToString(), | 2054 EXPECT_EQ(widget_one->GetNativeWindow()->bounds().ToString(), |
| 2042 widget_two->GetNativeWindow()->bounds().ToString()); | 2055 widget_two->GetNativeWindow()->bounds().ToString()); |
| 2043 int area_when_shelf_shown = | 2056 int area_when_shelf_shown = |
| 2044 widget_one->GetNativeWindow()->bounds().size().GetArea(); | 2057 widget_one->GetNativeWindow()->bounds().size().GetArea(); |
| 2045 | 2058 |
| 2046 // Now hide the shelf. | 2059 // Now hide the shelf. |
| 2047 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 2060 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 2048 | 2061 |
| 2049 // Both windows should be resized according to the shelf status. | 2062 // Both windows should be resized according to the shelf status. |
| 2050 EXPECT_EQ(widget_one->GetNativeWindow()->bounds().ToString(), | 2063 EXPECT_EQ(widget_one->GetNativeWindow()->bounds().ToString(), |
| 2051 widget_two->GetNativeWindow()->bounds().ToString()); | 2064 widget_two->GetNativeWindow()->bounds().ToString()); |
| 2052 // Resized to small. | 2065 // Resized to small. |
| 2053 EXPECT_LT(area_when_shelf_shown, | 2066 EXPECT_LT(area_when_shelf_shown, |
| 2054 widget_one->GetNativeWindow()->bounds().size().GetArea()); | 2067 widget_one->GetNativeWindow()->bounds().size().GetArea()); |
| 2055 | 2068 |
| 2056 // Now show the shelf. | 2069 // Now show the shelf. |
| 2057 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 2070 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 2058 | 2071 |
| 2059 // Again both windows should be of the same size. | 2072 // Again both windows should be of the same size. |
| 2060 EXPECT_EQ(widget_one->GetNativeWindow()->bounds().ToString(), | 2073 EXPECT_EQ(widget_one->GetNativeWindow()->bounds().ToString(), |
| 2061 widget_two->GetNativeWindow()->bounds().ToString()); | 2074 widget_two->GetNativeWindow()->bounds().ToString()); |
| 2062 EXPECT_EQ(area_when_shelf_shown, | 2075 EXPECT_EQ(area_when_shelf_shown, |
| 2063 widget_one->GetNativeWindow()->bounds().size().GetArea()); | 2076 widget_one->GetNativeWindow()->bounds().size().GetArea()); |
| 2064 } | 2077 } |
| 2065 | 2078 |
| 2066 // Confirm that the shelf is dimmed only when content is maximized and | 2079 // Confirm that the shelf is dimmed only when content is maximized and |
| 2067 // shelf is not autohidden. | 2080 // shelf is not autohidden. |
| 2068 TEST_F(ShelfLayoutManagerTest, Dimming) { | 2081 TEST_F(ShelfLayoutManagerTest, Dimming) { |
| 2069 GetShelfLayoutManager()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 2082 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 2070 std::unique_ptr<aura::Window> w1(CreateTestWindow()); | 2083 std::unique_ptr<aura::Window> w1(CreateTestWindow()); |
| 2071 w1->Show(); | 2084 w1->Show(); |
| 2072 wm::ActivateWindow(w1.get()); | 2085 wm::ActivateWindow(w1.get()); |
| 2073 | 2086 |
| 2074 // Normal window doesn't dim shelf. | 2087 // Normal window doesn't dim shelf. |
| 2075 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 2088 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 2076 ShelfWidget* shelf = GetShelfWidget(); | 2089 ShelfWidget* shelf_widget = GetShelfWidget(); |
| 2077 EXPECT_FALSE(shelf->GetDimsShelf()); | 2090 EXPECT_FALSE(shelf_widget->GetDimsShelf()); |
| 2078 | 2091 |
| 2079 // Maximized window does. | 2092 // Maximized window does. |
| 2080 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 2093 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 2081 EXPECT_TRUE(shelf->GetDimsShelf()); | 2094 EXPECT_TRUE(shelf_widget->GetDimsShelf()); |
| 2082 | 2095 |
| 2083 // Change back to normal stops dimming. | 2096 // Change back to normal stops dimming. |
| 2084 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 2097 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 2085 EXPECT_FALSE(shelf->GetDimsShelf()); | 2098 EXPECT_FALSE(shelf_widget->GetDimsShelf()); |
| 2086 | 2099 |
| 2087 // Changing back to maximized dims again. | 2100 // Changing back to maximized dims again. |
| 2088 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 2101 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 2089 EXPECT_TRUE(shelf->GetDimsShelf()); | 2102 EXPECT_TRUE(shelf_widget->GetDimsShelf()); |
| 2090 | 2103 |
| 2091 // Changing shelf to autohide stops dimming. | 2104 // Changing shelf to autohide stops dimming. |
| 2092 GetShelfLayoutManager()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 2105 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 2093 EXPECT_FALSE(shelf->GetDimsShelf()); | 2106 EXPECT_FALSE(shelf_widget->GetDimsShelf()); |
| 2094 } | 2107 } |
| 2095 | 2108 |
| 2096 // Make sure that the shelf will not hide if the mouse is between a bubble and | 2109 // Make sure that the shelf will not hide if the mouse is between a bubble and |
| 2097 // the shelf. | 2110 // the shelf. |
| 2098 TEST_F(ShelfLayoutManagerTest, BubbleEnlargesShelfMouseHitArea) { | 2111 TEST_F(ShelfLayoutManagerTest, BubbleEnlargesShelfMouseHitArea) { |
| 2099 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 2112 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 2100 StatusAreaWidget* status_area_widget = Shell::GetPrimaryRootWindowController() | 2113 StatusAreaWidget* status_area_widget = Shell::GetPrimaryRootWindowController() |
| 2101 ->shelf_widget() | 2114 ->shelf_widget() |
| 2102 ->status_area_widget(); | 2115 ->status_area_widget(); |
| 2103 SystemTray* tray = GetSystemTray(); | 2116 SystemTray* tray = GetSystemTray(); |
| 2104 | 2117 |
| 2105 // Create a visible window so auto-hide behavior is enforced. | 2118 // Create a visible window so auto-hide behavior is enforced. |
| 2106 CreateTestWidget(); | 2119 CreateTestWidget(); |
| 2107 | 2120 |
| 2108 shelf->LayoutShelf(); | 2121 layout_manager->LayoutShelf(); |
| 2109 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 2122 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 2110 | 2123 |
| 2111 // Make two iterations - first without a message bubble which should make | 2124 // Make two iterations - first without a message bubble which should make |
| 2112 // the shelf disappear and then with a message bubble which should keep it | 2125 // the shelf disappear and then with a message bubble which should keep it |
| 2113 // visible. | 2126 // visible. |
| 2114 for (int i = 0; i < 2; i++) { | 2127 for (int i = 0; i < 2; i++) { |
| 2115 // Make sure the shelf is visible and position the mouse over it. Then | 2128 // Make sure the shelf is visible and position the mouse over it. Then |
| 2116 // allow auto hide. | 2129 // allow auto hide. |
| 2117 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 2130 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 2118 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); | 2131 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
| 2119 gfx::Point center = | 2132 gfx::Point center = |
| 2120 status_area_widget->GetWindowBoundsInScreen().CenterPoint(); | 2133 status_area_widget->GetWindowBoundsInScreen().CenterPoint(); |
| 2121 generator.MoveMouseTo(center.x(), center.y()); | 2134 generator.MoveMouseTo(center.x(), center.y()); |
| 2122 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 2135 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 2123 EXPECT_TRUE(shelf->IsVisible()); | 2136 EXPECT_TRUE(layout_manager->IsVisible()); |
| 2124 if (!i) { | 2137 if (!i) { |
| 2125 // In our first iteration we make sure there is no bubble. | 2138 // In our first iteration we make sure there is no bubble. |
| 2126 tray->CloseSystemBubble(); | 2139 tray->CloseSystemBubble(); |
| 2127 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); | 2140 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
| 2128 } else { | 2141 } else { |
| 2129 // In our second iteration we show a bubble. | 2142 // In our second iteration we show a bubble. |
| 2130 TestItem *item = new TestItem; | 2143 TestItem *item = new TestItem; |
| 2131 tray->AddTrayItem(item); | 2144 tray->AddTrayItem(item); |
| 2132 tray->ShowNotificationView(item); | 2145 tray->ShowNotificationView(item); |
| 2133 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); | 2146 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); |
| 2134 } | 2147 } |
| 2135 // Move the pointer over the edge of the shelf. | 2148 // Move the pointer over the edge of the shelf. |
| 2136 generator.MoveMouseTo( | 2149 generator.MoveMouseTo( |
| 2137 center.x(), status_area_widget->GetWindowBoundsInScreen().y() - 8); | 2150 center.x(), status_area_widget->GetWindowBoundsInScreen().y() - 8); |
| 2138 shelf->UpdateVisibilityState(); | 2151 layout_manager->UpdateVisibilityState(); |
| 2139 if (i) { | 2152 if (i) { |
| 2140 EXPECT_TRUE(shelf->IsVisible()); | 2153 EXPECT_TRUE(layout_manager->IsVisible()); |
| 2141 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); | 2154 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); |
| 2142 } else { | 2155 } else { |
| 2143 EXPECT_FALSE(shelf->IsVisible()); | 2156 EXPECT_FALSE(layout_manager->IsVisible()); |
| 2144 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); | 2157 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
| 2145 } | 2158 } |
| 2146 } | 2159 } |
| 2147 } | 2160 } |
| 2148 | 2161 |
| 2149 TEST_F(ShelfLayoutManagerTest, ShelfBackgroundColor) { | 2162 TEST_F(ShelfLayoutManagerTest, ShelfBackgroundColor) { |
| 2150 EXPECT_EQ(wm::SHELF_BACKGROUND_DEFAULT, | 2163 EXPECT_EQ(wm::SHELF_BACKGROUND_DEFAULT, |
| 2151 GetShelfWidget()->GetBackgroundType()); | 2164 GetShelfWidget()->GetBackgroundType()); |
| 2152 | 2165 |
| 2153 std::unique_ptr<aura::Window> w1(CreateTestWindow()); | 2166 std::unique_ptr<aura::Window> w1(CreateTestWindow()); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 2183 EXPECT_EQ(wm::SHELF_BACKGROUND_DEFAULT, | 2196 EXPECT_EQ(wm::SHELF_BACKGROUND_DEFAULT, |
| 2184 GetShelfWidget()->GetBackgroundType()); | 2197 GetShelfWidget()->GetBackgroundType()); |
| 2185 } | 2198 } |
| 2186 | 2199 |
| 2187 // Verify that the shelf doesn't have the opaque background if it's auto-hide | 2200 // Verify that the shelf doesn't have the opaque background if it's auto-hide |
| 2188 // status. | 2201 // status. |
| 2189 TEST_F(ShelfLayoutManagerTest, ShelfBackgroundColorAutoHide) { | 2202 TEST_F(ShelfLayoutManagerTest, ShelfBackgroundColorAutoHide) { |
| 2190 EXPECT_EQ(wm::SHELF_BACKGROUND_DEFAULT, | 2203 EXPECT_EQ(wm::SHELF_BACKGROUND_DEFAULT, |
| 2191 GetShelfWidget()->GetBackgroundType()); | 2204 GetShelfWidget()->GetBackgroundType()); |
| 2192 | 2205 |
| 2193 GetShelfLayoutManager()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 2206 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 2194 std::unique_ptr<aura::Window> w1(CreateTestWindow()); | 2207 std::unique_ptr<aura::Window> w1(CreateTestWindow()); |
| 2195 w1->Show(); | 2208 w1->Show(); |
| 2196 wm::ActivateWindow(w1.get()); | 2209 wm::ActivateWindow(w1.get()); |
| 2197 EXPECT_EQ(wm::SHELF_BACKGROUND_OVERLAP, | 2210 EXPECT_EQ(wm::SHELF_BACKGROUND_OVERLAP, |
| 2198 GetShelfWidget()->GetBackgroundType()); | 2211 GetShelfWidget()->GetBackgroundType()); |
| 2199 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 2212 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 2200 EXPECT_EQ(wm::SHELF_BACKGROUND_OVERLAP, | 2213 EXPECT_EQ(wm::SHELF_BACKGROUND_OVERLAP, |
| 2201 GetShelfWidget()->GetBackgroundType()); | 2214 GetShelfWidget()->GetBackgroundType()); |
| 2202 } | 2215 } |
| 2203 | 2216 |
| 2204 #if defined(OS_CHROMEOS) | 2217 #if defined(OS_CHROMEOS) |
| 2205 #define MAYBE_StatusAreaHitBoxCoversEdge StatusAreaHitBoxCoversEdge | 2218 #define MAYBE_StatusAreaHitBoxCoversEdge StatusAreaHitBoxCoversEdge |
| 2206 #else | 2219 #else |
| 2207 #define MAYBE_StatusAreaHitBoxCoversEdge DISABLED_StatusAreaHitBoxCoversEdge | 2220 #define MAYBE_StatusAreaHitBoxCoversEdge DISABLED_StatusAreaHitBoxCoversEdge |
| 2208 #endif | 2221 #endif |
| 2209 | 2222 |
| 2210 // Verify the hit bounds of the status area extend to the edge of the shelf. | 2223 // Verify the hit bounds of the status area extend to the edge of the shelf. |
| 2211 TEST_F(ShelfLayoutManagerTest, MAYBE_StatusAreaHitBoxCoversEdge) { | 2224 TEST_F(ShelfLayoutManagerTest, MAYBE_StatusAreaHitBoxCoversEdge) { |
| 2212 UpdateDisplay("400x400"); | 2225 UpdateDisplay("400x400"); |
| 2213 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | |
| 2214 StatusAreaWidget* status_area_widget = Shell::GetPrimaryRootWindowController() | 2226 StatusAreaWidget* status_area_widget = Shell::GetPrimaryRootWindowController() |
| 2215 ->shelf_widget() | 2227 ->shelf_widget() |
| 2216 ->status_area_widget(); | 2228 ->status_area_widget(); |
| 2217 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 2229 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 2218 generator.MoveMouseTo(399,399); | 2230 generator.MoveMouseTo(399,399); |
| 2219 | 2231 |
| 2220 // Test bottom right pixel for bottom alignment. | 2232 // Test bottom right pixel for bottom alignment. |
| 2221 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); | 2233 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
| 2222 generator.ClickLeftButton(); | 2234 generator.ClickLeftButton(); |
| 2223 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); | 2235 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); |
| 2224 generator.ClickLeftButton(); | 2236 generator.ClickLeftButton(); |
| 2225 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); | 2237 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
| 2226 | 2238 |
| 2227 // Test bottom right pixel for right alignment. | 2239 // Test bottom right pixel for right alignment. |
| 2240 Shelf* shelf = GetShelf(); | |
|
msw
2016/06/01 00:53:24
nit: it seems random when you choose to cache GetS
James Cook
2016/06/01 15:53:06
Updated to cache GetShelf() everywhere, unless it
| |
| 2228 shelf->SetAlignment(wm::SHELF_ALIGNMENT_RIGHT); | 2241 shelf->SetAlignment(wm::SHELF_ALIGNMENT_RIGHT); |
| 2229 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); | 2242 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
| 2230 generator.ClickLeftButton(); | 2243 generator.ClickLeftButton(); |
| 2231 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); | 2244 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); |
| 2232 generator.ClickLeftButton(); | 2245 generator.ClickLeftButton(); |
| 2233 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); | 2246 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
| 2234 | 2247 |
| 2235 // Test bottom left pixel for left alignment. | 2248 // Test bottom left pixel for left alignment. |
| 2236 generator.MoveMouseTo(0, 399); | 2249 generator.MoveMouseTo(0, 399); |
| 2237 shelf->SetAlignment(wm::SHELF_ALIGNMENT_LEFT); | 2250 shelf->SetAlignment(wm::SHELF_ALIGNMENT_LEFT); |
| 2238 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); | 2251 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
| 2239 generator.ClickLeftButton(); | 2252 generator.ClickLeftButton(); |
| 2240 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); | 2253 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); |
| 2241 generator.ClickLeftButton(); | 2254 generator.ClickLeftButton(); |
| 2242 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); | 2255 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
| 2243 } | 2256 } |
| 2244 | 2257 |
| 2245 // Tests that when the auto-hide behaviour is changed during an animation the | 2258 // Tests that when the auto-hide behaviour is changed during an animation the |
| 2246 // target bounds are updated to reflect the new state. | 2259 // target bounds are updated to reflect the new state. |
| 2247 TEST_F(ShelfLayoutManagerTest, | 2260 TEST_F(ShelfLayoutManagerTest, |
| 2248 ShelfAutoHideToggleDuringAnimationUpdatesBounds) { | 2261 ShelfAutoHideToggleDuringAnimationUpdatesBounds) { |
| 2249 ShelfLayoutManager* shelf_manager = GetShelfLayoutManager(); | 2262 Shelf* shelf = GetShelf(); |
| 2250 aura::Window* status_window = GetShelfWidget()->status_area_widget()-> | 2263 aura::Window* status_window = GetShelfWidget()->status_area_widget()-> |
| 2251 GetNativeView(); | 2264 GetNativeView(); |
| 2252 gfx::Rect initial_bounds = status_window->bounds(); | 2265 gfx::Rect initial_bounds = status_window->bounds(); |
| 2253 | 2266 |
| 2254 ui::ScopedAnimationDurationScaleMode regular_animations( | 2267 ui::ScopedAnimationDurationScaleMode regular_animations( |
| 2255 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION); | 2268 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION); |
| 2256 shelf_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); | 2269 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
| 2257 gfx::Rect hide_target_bounds = status_window->GetTargetBounds(); | 2270 gfx::Rect hide_target_bounds = status_window->GetTargetBounds(); |
| 2258 EXPECT_GT(hide_target_bounds.y(), initial_bounds.y()); | 2271 EXPECT_GT(hide_target_bounds.y(), initial_bounds.y()); |
| 2259 | 2272 |
| 2260 shelf_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 2273 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 2261 gfx::Rect reshow_target_bounds = status_window->GetTargetBounds(); | 2274 gfx::Rect reshow_target_bounds = status_window->GetTargetBounds(); |
| 2262 EXPECT_EQ(initial_bounds, reshow_target_bounds); | 2275 EXPECT_EQ(initial_bounds, reshow_target_bounds); |
| 2263 } | 2276 } |
| 2264 | 2277 |
| 2265 // Tests that during shutdown, that window activation changes are properly | 2278 // Tests that during shutdown, that window activation changes are properly |
| 2266 // handled, and do not crash (crbug.com/458768) | 2279 // handled, and do not crash (crbug.com/458768) |
| 2267 TEST_F(ShelfLayoutManagerTest, ShutdownHandlesWindowActivation) { | 2280 TEST_F(ShelfLayoutManagerTest, ShutdownHandlesWindowActivation) { |
| 2268 ShelfLayoutManager* shelf_manager = GetShelfLayoutManager(); | 2281 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 2269 ShelfWidget* shelf = GetShelfWidget(); | |
| 2270 shelf_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | |
| 2271 | 2282 |
| 2272 aura::Window* window1 = CreateTestWindowInShellWithId(0); | 2283 aura::Window* window1 = CreateTestWindowInShellWithId(0); |
| 2273 window1->SetBounds(gfx::Rect(0, 0, 100, 100)); | 2284 window1->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 2274 window1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 2285 window1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 2275 window1->Show(); | 2286 window1->Show(); |
| 2276 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(0)); | 2287 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(0)); |
| 2277 window2->SetBounds(gfx::Rect(0, 0, 100, 100)); | 2288 window2->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 2278 window2->Show(); | 2289 window2->Show(); |
| 2279 wm::ActivateWindow(window1); | 2290 wm::ActivateWindow(window1); |
| 2280 | 2291 |
| 2281 shelf->Shutdown(); | 2292 GetShelfWidget()->Shutdown(); |
| 2282 | 2293 |
| 2283 // Deleting a focused maximized window will switch focus to |window2|. This | 2294 // Deleting a focused maximized window will switch focus to |window2|. This |
| 2284 // would normally cause the ShelfLayoutManager to update its state. However | 2295 // would normally cause the ShelfLayoutManager to update its state. However |
| 2285 // during shutdown we want to handle this without crashing. | 2296 // during shutdown we want to handle this without crashing. |
| 2286 delete window1; | 2297 delete window1; |
| 2287 } | 2298 } |
| 2288 | 2299 |
| 2289 TEST_F(ShelfLayoutManagerTest, ShelfLayoutInUnifiedDesktop) { | 2300 TEST_F(ShelfLayoutManagerTest, ShelfLayoutInUnifiedDesktop) { |
| 2290 if (!SupportsMultipleDisplays()) | 2301 if (!SupportsMultipleDisplays()) |
| 2291 return; | 2302 return; |
| 2292 Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled(true); | 2303 Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled(true); |
| 2293 | 2304 |
| 2294 UpdateDisplay("500x400, 500x400"); | 2305 UpdateDisplay("500x400, 500x400"); |
| 2295 | 2306 |
| 2296 StatusAreaWidget* status_area_widget = Shell::GetPrimaryRootWindowController() | 2307 StatusAreaWidget* status_area_widget = Shell::GetPrimaryRootWindowController() |
| 2297 ->shelf_widget() | 2308 ->shelf_widget() |
| 2298 ->status_area_widget(); | 2309 ->status_area_widget(); |
| 2299 EXPECT_TRUE(status_area_widget->IsVisible()); | 2310 EXPECT_TRUE(status_area_widget->IsVisible()); |
| 2300 // Shelf should be in the first display's area. | 2311 // Shelf should be in the first display's area. |
| 2301 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); | 2312 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); |
| 2302 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds)); | 2313 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds)); |
| 2303 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right()); | 2314 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right()); |
| 2304 } | 2315 } |
| 2305 | 2316 |
| 2306 } // namespace ash | 2317 } // namespace ash |
| OLD | NEW |