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