| 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/common/shelf/wm_shelf.h" |
| 10 #include "ash/common/shell_window_ids.h" | 11 #include "ash/common/shell_window_ids.h" |
| 11 #include "ash/common/system/tray/system_tray_item.h" | 12 #include "ash/common/system/tray/system_tray_item.h" |
| 12 #include "ash/common/wm/window_state.h" | 13 #include "ash/common/wm/window_state.h" |
| 13 #include "ash/common/wm_lookup.h" | 14 #include "ash/common/wm_lookup.h" |
| 14 #include "ash/common/wm_root_window_controller.h" | 15 #include "ash/common/wm_root_window_controller.h" |
| 15 #include "ash/common/wm_shell.h" | 16 #include "ash/common/wm_shell.h" |
| 16 #include "ash/common/wm_window.h" | 17 #include "ash/common/wm_window.h" |
| 17 #include "ash/display/display_manager.h" | 18 #include "ash/display/display_manager.h" |
| 18 #include "ash/shelf/shelf_layout_manager.h" | |
| 19 #include "ash/shell.h" | 19 #include "ash/shell.h" |
| 20 #include "ash/system/status_area_widget.h" | 20 #include "ash/system/status_area_widget.h" |
| 21 #include "ash/system/tray/system_tray.h" | 21 #include "ash/system/tray/system_tray.h" |
| 22 #include "ash/system/web_notification/ash_popup_alignment_delegate.h" | 22 #include "ash/system/web_notification/ash_popup_alignment_delegate.h" |
| 23 #include "ash/test/ash_test_base.h" | 23 #include "ash/test/ash_test_base.h" |
| 24 #include "ash/test/status_area_widget_test_helper.h" | 24 #include "ash/test/status_area_widget_test_helper.h" |
| 25 #include "ash/test/test_system_tray_delegate.h" | 25 #include "ash/test/test_system_tray_delegate.h" |
| 26 #include "base/strings/stringprintf.h" | 26 #include "base/strings/stringprintf.h" |
| 27 #include "base/strings/utf_string_conversions.h" | 27 #include "base/strings/utf_string_conversions.h" |
| 28 #include "ui/display/display.h" | 28 #include "ui/display/display.h" |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 EXPECT_EQ(bottom, GetPopupWorkAreaBottom()); | 355 EXPECT_EQ(bottom, GetPopupWorkAreaBottom()); |
| 356 } | 356 } |
| 357 | 357 |
| 358 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndAutoHideShelf) { | 358 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndAutoHideShelf) { |
| 359 AddNotification("test_id"); | 359 AddNotification("test_id"); |
| 360 EXPECT_TRUE(GetTray()->IsPopupVisible()); | 360 EXPECT_TRUE(GetTray()->IsPopupVisible()); |
| 361 int bottom = GetPopupWorkAreaBottom(); | 361 int bottom = GetPopupWorkAreaBottom(); |
| 362 | 362 |
| 363 // Shelf's auto-hide state won't be HIDDEN unless window exists. | 363 // Shelf's auto-hide state won't be HIDDEN unless window exists. |
| 364 std::unique_ptr<views::Widget> widget(CreateTestWidget()); | 364 std::unique_ptr<views::Widget> widget(CreateTestWidget()); |
| 365 Shelf* shelf = Shelf::ForPrimaryDisplay(); | 365 WmShelf* shelf = GetPrimaryShelf(); |
| 366 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 366 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 367 | 367 |
| 368 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 368 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| 369 int bottom_auto_hidden = GetPopupWorkAreaBottom(); | 369 int bottom_auto_hidden = GetPopupWorkAreaBottom(); |
| 370 EXPECT_LT(bottom, bottom_auto_hidden); | 370 EXPECT_LT(bottom, bottom_auto_hidden); |
| 371 | 371 |
| 372 // Close the window, which shows the shelf. | 372 // Close the window, which shows the shelf. |
| 373 widget.reset(); | 373 widget.reset(); |
| 374 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | 374 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
| 375 int bottom_auto_shown = GetPopupWorkAreaBottom(); | 375 int bottom_auto_shown = GetPopupWorkAreaBottom(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 387 EXPECT_GT(bottom_auto_shown, bottom_with_tray); | 387 EXPECT_GT(bottom_auto_shown, bottom_with_tray); |
| 388 | 388 |
| 389 // Create tray notification. | 389 // Create tray notification. |
| 390 GetSystemTray()->ShowNotificationView(test_item); | 390 GetSystemTray()->ShowNotificationView(test_item); |
| 391 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | 391 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
| 392 int bottom_with_tray_notification = GetPopupWorkAreaBottom(); | 392 int bottom_with_tray_notification = GetPopupWorkAreaBottom(); |
| 393 EXPECT_GT(bottom_with_tray, bottom_with_tray_notification); | 393 EXPECT_GT(bottom_with_tray, bottom_with_tray_notification); |
| 394 | 394 |
| 395 // Close the system tray. | 395 // Close the system tray. |
| 396 GetSystemTray()->ClickedOutsideBubble(); | 396 GetSystemTray()->ClickedOutsideBubble(); |
| 397 shelf->shelf_layout_manager()->UpdateAutoHideState(); | 397 shelf->UpdateAutoHideState(); |
| 398 RunAllPendingInMessageLoop(); | 398 RunAllPendingInMessageLoop(); |
| 399 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 399 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| 400 int bottom_hidden_with_tray_notification = GetPopupWorkAreaBottom(); | 400 int bottom_hidden_with_tray_notification = GetPopupWorkAreaBottom(); |
| 401 EXPECT_LT(bottom_with_tray_notification, | 401 EXPECT_LT(bottom_with_tray_notification, |
| 402 bottom_hidden_with_tray_notification); | 402 bottom_hidden_with_tray_notification); |
| 403 EXPECT_GT(bottom_auto_hidden, bottom_hidden_with_tray_notification); | 403 EXPECT_GT(bottom_auto_hidden, bottom_hidden_with_tray_notification); |
| 404 | 404 |
| 405 // Close the window again, which shows the shelf. | 405 // Close the window again, which shows the shelf. |
| 406 widget.reset(); | 406 widget.reset(); |
| 407 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | 407 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
| 408 int bottom_shown_with_tray_notification = GetPopupWorkAreaBottom(); | 408 int bottom_shown_with_tray_notification = GetPopupWorkAreaBottom(); |
| 409 EXPECT_GT(bottom_hidden_with_tray_notification, | 409 EXPECT_GT(bottom_hidden_with_tray_notification, |
| 410 bottom_shown_with_tray_notification); | 410 bottom_shown_with_tray_notification); |
| 411 EXPECT_GT(bottom_auto_shown, bottom_shown_with_tray_notification); | 411 EXPECT_GT(bottom_auto_shown, bottom_shown_with_tray_notification); |
| 412 } | 412 } |
| 413 | 413 |
| 414 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndFullscreen) { | 414 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndFullscreen) { |
| 415 AddNotification("test_id"); | 415 AddNotification("test_id"); |
| 416 EXPECT_TRUE(IsPopupVisible()); | 416 EXPECT_TRUE(IsPopupVisible()); |
| 417 int bottom = GetPopupWorkAreaBottom(); | 417 int bottom = GetPopupWorkAreaBottom(); |
| 418 | 418 |
| 419 // Checks the work area for normal auto-hidden state. | 419 // Checks the work area for normal auto-hidden state. |
| 420 std::unique_ptr<views::Widget> widget(CreateTestWidget()); | 420 std::unique_ptr<views::Widget> widget(CreateTestWidget()); |
| 421 Shelf* shelf = Shelf::ForPrimaryDisplay(); | 421 WmShelf* shelf = GetPrimaryShelf(); |
| 422 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 422 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 423 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 423 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| 424 int bottom_auto_hidden = GetPopupWorkAreaBottom(); | 424 int bottom_auto_hidden = GetPopupWorkAreaBottom(); |
| 425 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 425 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 426 | 426 |
| 427 // Put |widget| into fullscreen without forcing the shelf to hide. Currently, | 427 // Put |widget| into fullscreen without forcing the shelf to hide. Currently, |
| 428 // this is used by immersive fullscreen and forces the shelf to be auto | 428 // this is used by immersive fullscreen and forces the shelf to be auto |
| 429 // hidden. | 429 // hidden. |
| 430 WmLookup::Get() | 430 WmLookup::Get() |
| 431 ->GetWindowForWidget(widget.get()) | 431 ->GetWindowForWidget(widget.get()) |
| 432 ->GetWindowState() | 432 ->GetWindowState() |
| 433 ->set_hide_shelf_when_fullscreen(false); | 433 ->set_hide_shelf_when_fullscreen(false); |
| 434 widget->SetFullscreen(true); | 434 widget->SetFullscreen(true); |
| 435 RunAllPendingInMessageLoop(); | 435 RunAllPendingInMessageLoop(); |
| 436 | 436 |
| 437 // The work area for auto-hidden status of fullscreen is a bit larger | 437 // The work area for auto-hidden status of fullscreen is a bit larger |
| 438 // since it doesn't even have the 3-pixel width. | 438 // since it doesn't even have the 3-pixel width. |
| 439 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 439 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| 440 int bottom_fullscreen_hidden = GetPopupWorkAreaBottom(); | 440 int bottom_fullscreen_hidden = GetPopupWorkAreaBottom(); |
| 441 EXPECT_EQ(bottom_auto_hidden, bottom_fullscreen_hidden); | 441 EXPECT_EQ(bottom_auto_hidden, bottom_fullscreen_hidden); |
| 442 | 442 |
| 443 // Move the mouse cursor at the bottom, which shows the shelf. | 443 // Move the mouse cursor at the bottom, which shows the shelf. |
| 444 ui::test::EventGenerator& generator = GetEventGenerator(); | 444 ui::test::EventGenerator& generator = GetEventGenerator(); |
| 445 gfx::Point bottom_right = | 445 gfx::Point bottom_right = |
| 446 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().bottom_right(); | 446 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().bottom_right(); |
| 447 bottom_right.Offset(-1, -1); | 447 bottom_right.Offset(-1, -1); |
| 448 generator.MoveMouseTo(bottom_right); | 448 generator.MoveMouseTo(bottom_right); |
| 449 shelf->shelf_layout_manager()->UpdateAutoHideStateNow(); | 449 shelf->UpdateVisibilityState(); |
| 450 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | 450 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
| 451 EXPECT_EQ(bottom, GetPopupWorkAreaBottom()); | 451 EXPECT_EQ(bottom, GetPopupWorkAreaBottom()); |
| 452 | 452 |
| 453 generator.MoveMouseTo( | 453 generator.MoveMouseTo( |
| 454 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().CenterPoint()); | 454 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().CenterPoint()); |
| 455 shelf->shelf_layout_manager()->UpdateAutoHideStateNow(); | 455 shelf->UpdateVisibilityState(); |
| 456 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 456 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| 457 EXPECT_EQ(bottom_auto_hidden, GetPopupWorkAreaBottom()); | 457 EXPECT_EQ(bottom_auto_hidden, GetPopupWorkAreaBottom()); |
| 458 } | 458 } |
| 459 | 459 |
| 460 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndSystemTrayMultiDisplay) { | 460 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndSystemTrayMultiDisplay) { |
| 461 UpdateDisplay("800x600,600x400"); | 461 UpdateDisplay("800x600,600x400"); |
| 462 | 462 |
| 463 AddNotification("test_id"); | 463 AddNotification("test_id"); |
| 464 int bottom = GetPopupWorkAreaBottom(); | 464 int bottom = GetPopupWorkAreaBottom(); |
| 465 int bottom_second = GetPopupWorkAreaBottomForTray(GetSecondaryTray()); | 465 int bottom_second = GetPopupWorkAreaBottomForTray(GetSecondaryTray()); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 ui::ET_TOUCH_RELEASED, out_of_bounds, touch_id, | 532 ui::ET_TOUCH_RELEASED, out_of_bounds, touch_id, |
| 533 move.time_stamp() + base::TimeDelta::FromMilliseconds(50)); | 533 move.time_stamp() + base::TimeDelta::FromMilliseconds(50)); |
| 534 generator.Dispatch(&release); | 534 generator.Dispatch(&release); |
| 535 EXPECT_FALSE(tray->draw_background_as_active()); | 535 EXPECT_FALSE(tray->draw_background_as_active()); |
| 536 EXPECT_FALSE(tray->IsMessageCenterBubbleVisible()); | 536 EXPECT_FALSE(tray->IsMessageCenterBubbleVisible()); |
| 537 } | 537 } |
| 538 | 538 |
| 539 #endif // OS_CHROMEOS | 539 #endif // OS_CHROMEOS |
| 540 | 540 |
| 541 } // namespace ash | 541 } // namespace ash |
| OLD | NEW |