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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
362 EXPECT_EQ(bottom, GetPopupWorkAreaBottom()); | 362 EXPECT_EQ(bottom, GetPopupWorkAreaBottom()); |
363 } | 363 } |
364 | 364 |
365 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndAutoHideShelf) { | 365 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndAutoHideShelf) { |
366 AddNotification("test_id"); | 366 AddNotification("test_id"); |
367 EXPECT_TRUE(GetTray()->IsPopupVisible()); | 367 EXPECT_TRUE(GetTray()->IsPopupVisible()); |
368 int bottom = GetPopupWorkAreaBottom(); | 368 int bottom = GetPopupWorkAreaBottom(); |
369 | 369 |
370 // Shelf's auto-hide state won't be HIDDEN unless window exists. | 370 // Shelf's auto-hide state won't be HIDDEN unless window exists. |
371 std::unique_ptr<views::Widget> widget(CreateTestWidget()); | 371 std::unique_ptr<views::Widget> widget(CreateTestWidget()); |
372 Shelf* shelf = Shelf::ForPrimaryDisplay(); | 372 WmShelf* shelf = WmShelf::ForPrimaryDisplay(); |
373 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 373 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
374 | 374 |
375 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 375 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
376 int bottom_auto_hidden = GetPopupWorkAreaBottom(); | 376 int bottom_auto_hidden = GetPopupWorkAreaBottom(); |
377 EXPECT_LT(bottom, bottom_auto_hidden); | 377 EXPECT_LT(bottom, bottom_auto_hidden); |
378 | 378 |
379 // Close the window, which shows the shelf. | 379 // Close the window, which shows the shelf. |
380 widget.reset(); | 380 widget.reset(); |
381 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | 381 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
382 int bottom_auto_shown = GetPopupWorkAreaBottom(); | 382 int bottom_auto_shown = GetPopupWorkAreaBottom(); |
(...skipping 11 matching lines...) Expand all Loading... | |
394 EXPECT_GT(bottom_auto_shown, bottom_with_tray); | 394 EXPECT_GT(bottom_auto_shown, bottom_with_tray); |
395 | 395 |
396 // Create tray notification. | 396 // Create tray notification. |
397 GetSystemTray()->ShowNotificationView(test_item); | 397 GetSystemTray()->ShowNotificationView(test_item); |
398 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | 398 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
399 int bottom_with_tray_notification = GetPopupWorkAreaBottom(); | 399 int bottom_with_tray_notification = GetPopupWorkAreaBottom(); |
400 EXPECT_GT(bottom_with_tray, bottom_with_tray_notification); | 400 EXPECT_GT(bottom_with_tray, bottom_with_tray_notification); |
401 | 401 |
402 // Close the system tray. | 402 // Close the system tray. |
403 GetSystemTray()->ClickedOutsideBubble(); | 403 GetSystemTray()->ClickedOutsideBubble(); |
404 shelf->shelf_layout_manager()->UpdateAutoHideState(); | 404 shelf->UpdateAutoHideState(); |
405 RunAllPendingInMessageLoop(); | 405 RunAllPendingInMessageLoop(); |
406 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 406 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
407 int bottom_hidden_with_tray_notification = GetPopupWorkAreaBottom(); | 407 int bottom_hidden_with_tray_notification = GetPopupWorkAreaBottom(); |
408 EXPECT_LT(bottom_with_tray_notification, | 408 EXPECT_LT(bottom_with_tray_notification, |
409 bottom_hidden_with_tray_notification); | 409 bottom_hidden_with_tray_notification); |
410 EXPECT_GT(bottom_auto_hidden, bottom_hidden_with_tray_notification); | 410 EXPECT_GT(bottom_auto_hidden, bottom_hidden_with_tray_notification); |
411 | 411 |
412 // Close the window again, which shows the shelf. | 412 // Close the window again, which shows the shelf. |
413 widget.reset(); | 413 widget.reset(); |
414 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | 414 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
415 int bottom_shown_with_tray_notification = GetPopupWorkAreaBottom(); | 415 int bottom_shown_with_tray_notification = GetPopupWorkAreaBottom(); |
416 EXPECT_GT(bottom_hidden_with_tray_notification, | 416 EXPECT_GT(bottom_hidden_with_tray_notification, |
417 bottom_shown_with_tray_notification); | 417 bottom_shown_with_tray_notification); |
418 EXPECT_GT(bottom_auto_shown, bottom_shown_with_tray_notification); | 418 EXPECT_GT(bottom_auto_shown, bottom_shown_with_tray_notification); |
419 } | 419 } |
420 | 420 |
421 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndFullscreen) { | 421 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndFullscreen) { |
422 AddNotification("test_id"); | 422 AddNotification("test_id"); |
423 EXPECT_TRUE(IsPopupVisible()); | 423 EXPECT_TRUE(IsPopupVisible()); |
424 int bottom = GetPopupWorkAreaBottom(); | 424 int bottom = GetPopupWorkAreaBottom(); |
425 | 425 |
426 // Checks the work area for normal auto-hidden state. | 426 // Checks the work area for normal auto-hidden state. |
427 std::unique_ptr<views::Widget> widget(CreateTestWidget()); | 427 std::unique_ptr<views::Widget> widget(CreateTestWidget()); |
428 Shelf* shelf = Shelf::ForPrimaryDisplay(); | 428 WmShelf* shelf = WmShelf::ForPrimaryDisplay(); |
429 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 429 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
430 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 430 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
431 int bottom_auto_hidden = GetPopupWorkAreaBottom(); | 431 int bottom_auto_hidden = GetPopupWorkAreaBottom(); |
432 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 432 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
433 | 433 |
434 // Put |widget| into fullscreen without forcing the shelf to hide. Currently, | 434 // Put |widget| into fullscreen without forcing the shelf to hide. Currently, |
435 // this is used by immersive fullscreen and forces the shelf to be auto | 435 // this is used by immersive fullscreen and forces the shelf to be auto |
436 // hidden. | 436 // hidden. |
437 WmLookup::Get() | 437 WmLookup::Get() |
438 ->GetWindowForWidget(widget.get()) | 438 ->GetWindowForWidget(widget.get()) |
439 ->GetWindowState() | 439 ->GetWindowState() |
440 ->set_hide_shelf_when_fullscreen(false); | 440 ->set_hide_shelf_when_fullscreen(false); |
441 widget->SetFullscreen(true); | 441 widget->SetFullscreen(true); |
442 RunAllPendingInMessageLoop(); | 442 RunAllPendingInMessageLoop(); |
443 | 443 |
444 // The work area for auto-hidden status of fullscreen is a bit larger | 444 // The work area for auto-hidden status of fullscreen is a bit larger |
445 // since it doesn't even have the 3-pixel width. | 445 // since it doesn't even have the 3-pixel width. |
446 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 446 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
447 int bottom_fullscreen_hidden = GetPopupWorkAreaBottom(); | 447 int bottom_fullscreen_hidden = GetPopupWorkAreaBottom(); |
448 EXPECT_EQ(bottom_auto_hidden, bottom_fullscreen_hidden); | 448 EXPECT_EQ(bottom_auto_hidden, bottom_fullscreen_hidden); |
449 | 449 |
450 // Move the mouse cursor at the bottom, which shows the shelf. | 450 // Move the mouse cursor at the bottom, which shows the shelf. |
451 ui::test::EventGenerator& generator = GetEventGenerator(); | 451 ui::test::EventGenerator& generator = GetEventGenerator(); |
452 gfx::Point bottom_right = | 452 gfx::Point bottom_right = |
453 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().bottom_right(); | 453 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().bottom_right(); |
454 bottom_right.Offset(-1, -1); | 454 bottom_right.Offset(-1, -1); |
455 generator.MoveMouseTo(bottom_right); | 455 generator.MoveMouseTo(bottom_right); |
456 shelf->shelf_layout_manager()->UpdateAutoHideStateNow(); | 456 shelf->UpdateVisibilityState(); |
msw
2016/06/25 00:18:30
ditto q: Should this be UpdateAutoHideState?
James Cook
2016/06/25 01:20:58
No, these have to be a synchronous update. UpdateA
msw
2016/06/27 18:11:35
This is fine, I was just checking that it was inte
| |
457 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | 457 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
458 EXPECT_EQ(bottom, GetPopupWorkAreaBottom()); | 458 EXPECT_EQ(bottom, GetPopupWorkAreaBottom()); |
459 | 459 |
460 generator.MoveMouseTo( | 460 generator.MoveMouseTo( |
461 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().CenterPoint()); | 461 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().CenterPoint()); |
462 shelf->shelf_layout_manager()->UpdateAutoHideStateNow(); | 462 shelf->UpdateVisibilityState(); |
msw
2016/06/25 00:18:30
ditto q: Should this be UpdateAutoHideState?
| |
463 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 463 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
464 EXPECT_EQ(bottom_auto_hidden, GetPopupWorkAreaBottom()); | 464 EXPECT_EQ(bottom_auto_hidden, GetPopupWorkAreaBottom()); |
465 } | 465 } |
466 | 466 |
467 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndSystemTrayMultiDisplay) { | 467 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndSystemTrayMultiDisplay) { |
468 UpdateDisplay("800x600,600x400"); | 468 UpdateDisplay("800x600,600x400"); |
469 | 469 |
470 AddNotification("test_id"); | 470 AddNotification("test_id"); |
471 int bottom = GetPopupWorkAreaBottom(); | 471 int bottom = GetPopupWorkAreaBottom(); |
472 int bottom_second = GetPopupWorkAreaBottomForTray(GetSecondaryTray()); | 472 int bottom_second = GetPopupWorkAreaBottomForTray(GetSecondaryTray()); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
536 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, out_of_bounds, touch_id, | 536 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, out_of_bounds, touch_id, |
537 move.time_stamp()+base::TimeDelta::FromMilliseconds(50)); | 537 move.time_stamp()+base::TimeDelta::FromMilliseconds(50)); |
538 generator.Dispatch(&release); | 538 generator.Dispatch(&release); |
539 EXPECT_FALSE(tray->draw_background_as_active()); | 539 EXPECT_FALSE(tray->draw_background_as_active()); |
540 EXPECT_FALSE(tray->IsMessageCenterBubbleVisible()); | 540 EXPECT_FALSE(tray->IsMessageCenterBubbleVisible()); |
541 } | 541 } |
542 | 542 |
543 #endif // OS_CHROMEOS | 543 #endif // OS_CHROMEOS |
544 | 544 |
545 } // namespace ash | 545 } // namespace ash |
OLD | NEW |