| 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/system/web_notification/web_notification_tray.h" | 5 #include "ash/system/web_notification/web_notification_tray.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 } | 350 } |
| 351 | 351 |
| 352 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndAutoHideShelf) { | 352 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndAutoHideShelf) { |
| 353 AddNotification("test_id"); | 353 AddNotification("test_id"); |
| 354 EXPECT_TRUE(GetTray()->IsPopupVisible()); | 354 EXPECT_TRUE(GetTray()->IsPopupVisible()); |
| 355 int bottom = GetPopupWorkAreaBottom(); | 355 int bottom = GetPopupWorkAreaBottom(); |
| 356 | 356 |
| 357 // Shelf's auto-hide state won't be HIDDEN unless window exists. | 357 // Shelf's auto-hide state won't be HIDDEN unless window exists. |
| 358 std::unique_ptr<aura::Window> window( | 358 std::unique_ptr<aura::Window> window( |
| 359 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4))); | 359 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4))); |
| 360 ShelfLayoutManager* shelf = | 360 Shelf* shelf = Shelf::ForPrimaryDisplay(); |
| 361 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); | |
| 362 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 361 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 363 | 362 |
| 364 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 363 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| 365 int bottom_auto_hidden = GetPopupWorkAreaBottom(); | 364 int bottom_auto_hidden = GetPopupWorkAreaBottom(); |
| 366 EXPECT_LT(bottom, bottom_auto_hidden); | 365 EXPECT_LT(bottom, bottom_auto_hidden); |
| 367 | 366 |
| 368 // Close the window, which shows the shelf. | 367 // Close the window, which shows the shelf. |
| 369 window.reset(); | 368 window.reset(); |
| 370 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 369 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
| 371 int bottom_auto_shown = GetPopupWorkAreaBottom(); | 370 int bottom_auto_shown = GetPopupWorkAreaBottom(); |
| 372 EXPECT_EQ(bottom, bottom_auto_shown); | 371 EXPECT_EQ(bottom, bottom_auto_shown); |
| 373 | 372 |
| 374 // Create the system tray during auto-hide. | 373 // Create the system tray during auto-hide. |
| 375 window.reset(CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4))); | 374 window.reset(CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4))); |
| 376 TestItem* test_item = new TestItem; | 375 TestItem* test_item = new TestItem; |
| 377 GetSystemTray()->AddTrayItem(test_item); | 376 GetSystemTray()->AddTrayItem(test_item); |
| 378 GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW); | 377 GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW); |
| 379 | 378 |
| 380 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 379 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
| 381 EXPECT_TRUE(GetTray()->IsPopupVisible()); | 380 EXPECT_TRUE(GetTray()->IsPopupVisible()); |
| 382 int bottom_with_tray = GetPopupWorkAreaBottom(); | 381 int bottom_with_tray = GetPopupWorkAreaBottom(); |
| 383 EXPECT_GT(bottom_auto_shown, bottom_with_tray); | 382 EXPECT_GT(bottom_auto_shown, bottom_with_tray); |
| 384 | 383 |
| 385 // Create tray notification. | 384 // Create tray notification. |
| 386 GetSystemTray()->ShowNotificationView(test_item); | 385 GetSystemTray()->ShowNotificationView(test_item); |
| 387 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 386 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
| 388 int bottom_with_tray_notification = GetPopupWorkAreaBottom(); | 387 int bottom_with_tray_notification = GetPopupWorkAreaBottom(); |
| 389 EXPECT_GT(bottom_with_tray, bottom_with_tray_notification); | 388 EXPECT_GT(bottom_with_tray, bottom_with_tray_notification); |
| 390 | 389 |
| 391 // Close the system tray. | 390 // Close the system tray. |
| 392 GetSystemTray()->ClickedOutsideBubble(); | 391 GetSystemTray()->ClickedOutsideBubble(); |
| 393 shelf->UpdateAutoHideState(); | 392 shelf->shelf_layout_manager()->UpdateAutoHideState(); |
| 394 RunAllPendingInMessageLoop(); | 393 RunAllPendingInMessageLoop(); |
| 395 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 394 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| 396 int bottom_hidden_with_tray_notification = GetPopupWorkAreaBottom(); | 395 int bottom_hidden_with_tray_notification = GetPopupWorkAreaBottom(); |
| 397 EXPECT_LT(bottom_with_tray_notification, | 396 EXPECT_LT(bottom_with_tray_notification, |
| 398 bottom_hidden_with_tray_notification); | 397 bottom_hidden_with_tray_notification); |
| 399 EXPECT_GT(bottom_auto_hidden, bottom_hidden_with_tray_notification); | 398 EXPECT_GT(bottom_auto_hidden, bottom_hidden_with_tray_notification); |
| 400 | 399 |
| 401 // Close the window again, which shows the shelf. | 400 // Close the window again, which shows the shelf. |
| 402 window.reset(); | 401 window.reset(); |
| 403 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 402 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
| 404 int bottom_shown_with_tray_notification = GetPopupWorkAreaBottom(); | 403 int bottom_shown_with_tray_notification = GetPopupWorkAreaBottom(); |
| 405 EXPECT_GT(bottom_hidden_with_tray_notification, | 404 EXPECT_GT(bottom_hidden_with_tray_notification, |
| 406 bottom_shown_with_tray_notification); | 405 bottom_shown_with_tray_notification); |
| 407 EXPECT_GT(bottom_auto_shown, bottom_shown_with_tray_notification); | 406 EXPECT_GT(bottom_auto_shown, bottom_shown_with_tray_notification); |
| 408 } | 407 } |
| 409 | 408 |
| 410 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndFullscreen) { | 409 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndFullscreen) { |
| 411 AddNotification("test_id"); | 410 AddNotification("test_id"); |
| 412 EXPECT_TRUE(IsPopupVisible()); | 411 EXPECT_TRUE(IsPopupVisible()); |
| 413 int bottom = GetPopupWorkAreaBottom(); | 412 int bottom = GetPopupWorkAreaBottom(); |
| 414 | 413 |
| 415 // Checks the work area for normal auto-hidden state. | 414 // Checks the work area for normal auto-hidden state. |
| 416 std::unique_ptr<aura::Window> window( | 415 std::unique_ptr<aura::Window> window( |
| 417 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4))); | 416 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4))); |
| 418 ShelfLayoutManager* shelf = | 417 Shelf* shelf = Shelf::ForPrimaryDisplay(); |
| 419 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); | |
| 420 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 418 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 421 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 419 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| 422 int bottom_auto_hidden = GetPopupWorkAreaBottom(); | 420 int bottom_auto_hidden = GetPopupWorkAreaBottom(); |
| 423 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 421 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 424 | 422 |
| 425 // Put |window| into fullscreen without forcing the shelf to hide. Currently, | 423 // Put |window| into fullscreen without forcing the shelf to hide. Currently, |
| 426 // this is used by immersive fullscreen and forces the shelf to be auto | 424 // this is used by immersive fullscreen and forces the shelf to be auto |
| 427 // hidden. | 425 // hidden. |
| 428 wm::GetWindowState(window.get())->set_hide_shelf_when_fullscreen(false); | 426 wm::GetWindowState(window.get())->set_hide_shelf_when_fullscreen(false); |
| 429 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 427 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 430 RunAllPendingInMessageLoop(); | 428 RunAllPendingInMessageLoop(); |
| 431 | 429 |
| 432 // The work area for auto-hidden status of fullscreen is a bit larger | 430 // The work area for auto-hidden status of fullscreen is a bit larger |
| 433 // since it doesn't even have the 3-pixel width. | 431 // since it doesn't even have the 3-pixel width. |
| 434 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 432 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| 435 int bottom_fullscreen_hidden = GetPopupWorkAreaBottom(); | 433 int bottom_fullscreen_hidden = GetPopupWorkAreaBottom(); |
| 436 EXPECT_EQ(bottom_auto_hidden, bottom_fullscreen_hidden); | 434 EXPECT_EQ(bottom_auto_hidden, bottom_fullscreen_hidden); |
| 437 | 435 |
| 438 // Move the mouse cursor at the bottom, which shows the shelf. | 436 // Move the mouse cursor at the bottom, which shows the shelf. |
| 439 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 437 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 440 gfx::Point bottom_right = | 438 gfx::Point bottom_right = |
| 441 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().bottom_right(); | 439 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().bottom_right(); |
| 442 bottom_right.Offset(-1, -1); | 440 bottom_right.Offset(-1, -1); |
| 443 generator.MoveMouseTo(bottom_right); | 441 generator.MoveMouseTo(bottom_right); |
| 444 shelf->UpdateAutoHideStateNow(); | 442 shelf->shelf_layout_manager()->UpdateAutoHideStateNow(); |
| 445 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 443 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
| 446 EXPECT_EQ(bottom, GetPopupWorkAreaBottom()); | 444 EXPECT_EQ(bottom, GetPopupWorkAreaBottom()); |
| 447 | 445 |
| 448 generator.MoveMouseTo( | 446 generator.MoveMouseTo( |
| 449 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().CenterPoint()); | 447 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().CenterPoint()); |
| 450 shelf->UpdateAutoHideStateNow(); | 448 shelf->shelf_layout_manager()->UpdateAutoHideStateNow(); |
| 451 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 449 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| 452 EXPECT_EQ(bottom_auto_hidden, GetPopupWorkAreaBottom()); | 450 EXPECT_EQ(bottom_auto_hidden, GetPopupWorkAreaBottom()); |
| 453 } | 451 } |
| 454 | 452 |
| 455 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndSystemTrayMultiDisplay) { | 453 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndSystemTrayMultiDisplay) { |
| 456 UpdateDisplay("800x600,600x400"); | 454 UpdateDisplay("800x600,600x400"); |
| 457 | 455 |
| 458 AddNotification("test_id"); | 456 AddNotification("test_id"); |
| 459 int bottom = GetPopupWorkAreaBottom(); | 457 int bottom = GetPopupWorkAreaBottom(); |
| 460 int bottom_second = GetPopupWorkAreaBottomForTray(GetSecondaryTray()); | 458 int bottom_second = GetPopupWorkAreaBottomForTray(GetSecondaryTray()); |
| 461 | 459 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, out_of_bounds, touch_id, | 522 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, out_of_bounds, touch_id, |
| 525 move.time_stamp()+base::TimeDelta::FromMilliseconds(50)); | 523 move.time_stamp()+base::TimeDelta::FromMilliseconds(50)); |
| 526 generator.Dispatch(&release); | 524 generator.Dispatch(&release); |
| 527 EXPECT_FALSE(tray->draw_background_as_active()); | 525 EXPECT_FALSE(tray->draw_background_as_active()); |
| 528 EXPECT_FALSE(tray->IsMessageCenterBubbleVisible()); | 526 EXPECT_FALSE(tray->IsMessageCenterBubbleVisible()); |
| 529 } | 527 } |
| 530 | 528 |
| 531 #endif // OS_CHROMEOS | 529 #endif // OS_CHROMEOS |
| 532 | 530 |
| 533 } // namespace ash | 531 } // namespace ash |
| OLD | NEW |