| 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" |
| 11 #include "ash/root_window_controller.h" | 11 #include "ash/root_window_controller.h" |
| 12 #include "ash/shelf/shelf_layout_manager.h" | 12 #include "ash/shelf/shelf_layout_manager.h" |
| 13 #include "ash/shelf/shelf_widget.h" | 13 #include "ash/shelf/shelf_widget.h" |
| 14 #include "ash/shell.h" | 14 #include "ash/shell.h" |
| 15 #include "ash/system/status_area_widget.h" | 15 #include "ash/system/status_area_widget.h" |
| 16 #include "ash/system/tray/system_tray.h" | 16 #include "ash/system/tray/system_tray.h" |
| 17 #include "ash/system/tray/system_tray_item.h" | 17 #include "ash/system/tray/system_tray_item.h" |
| 18 #include "ash/system/web_notification/ash_popup_alignment_delegate.h" | 18 #include "ash/system/web_notification/ash_popup_alignment_delegate.h" |
| 19 #include "ash/test/ash_test_base.h" | 19 #include "ash/test/ash_test_base.h" |
| 20 #include "ash/test/status_area_widget_test_helper.h" | 20 #include "ash/test/status_area_widget_test_helper.h" |
| 21 #include "ash/test/test_system_tray_delegate.h" | 21 #include "ash/test/test_system_tray_delegate.h" |
| 22 #include "ash/wm/common/window_state.h" | 22 #include "ash/wm/common/window_state.h" |
| 23 #include "ash/wm/window_state_aura.h" | 23 #include "ash/wm/window_state_aura.h" |
| 24 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
| 25 #include "base/strings/utf_string_conversions.h" | 25 #include "base/strings/utf_string_conversions.h" |
| 26 #include "ui/aura/client/aura_constants.h" | 26 #include "ui/aura/client/aura_constants.h" |
| 27 #include "ui/aura/window.h" | 27 #include "ui/aura/window.h" |
| 28 #include "ui/display/display.h" |
| 29 #include "ui/display/screen.h" |
| 28 #include "ui/events/event.h" | 30 #include "ui/events/event.h" |
| 29 #include "ui/events/test/event_generator.h" | 31 #include "ui/events/test/event_generator.h" |
| 30 #include "ui/gfx/display.h" | |
| 31 #include "ui/gfx/geometry/point.h" | 32 #include "ui/gfx/geometry/point.h" |
| 32 #include "ui/gfx/geometry/rect.h" | 33 #include "ui/gfx/geometry/rect.h" |
| 33 #include "ui/gfx/screen.h" | |
| 34 #include "ui/message_center/message_center_style.h" | 34 #include "ui/message_center/message_center_style.h" |
| 35 #include "ui/message_center/message_center_tray.h" | 35 #include "ui/message_center/message_center_tray.h" |
| 36 #include "ui/message_center/notification_list.h" | 36 #include "ui/message_center/notification_list.h" |
| 37 #include "ui/message_center/notification_types.h" | 37 #include "ui/message_center/notification_types.h" |
| 38 #include "ui/message_center/views/message_center_bubble.h" | 38 #include "ui/message_center/views/message_center_bubble.h" |
| 39 #include "ui/message_center/views/message_popup_collection.h" | 39 #include "ui/message_center/views/message_popup_collection.h" |
| 40 #include "ui/views/controls/label.h" | 40 #include "ui/views/controls/label.h" |
| 41 #include "ui/views/layout/fill_layout.h" | 41 #include "ui/views/layout/fill_layout.h" |
| 42 #include "ui/views/view.h" | 42 #include "ui/views/view.h" |
| 43 #include "ui/views/widget/widget.h" | 43 #include "ui/views/widget/widget.h" |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 display_manager->SetMultiDisplayMode(DisplayManager::EXTENDED); | 295 display_manager->SetMultiDisplayMode(DisplayManager::EXTENDED); |
| 296 UpdateDisplay("400x400,200x200"); | 296 UpdateDisplay("400x400,200x200"); |
| 297 EXPECT_TRUE(GetTray()->IsPopupVisible()); | 297 EXPECT_TRUE(GetTray()->IsPopupVisible()); |
| 298 secondary_tray = GetSecondaryTray(); | 298 secondary_tray = GetSecondaryTray(); |
| 299 ASSERT_TRUE(secondary_tray); | 299 ASSERT_TRUE(secondary_tray); |
| 300 EXPECT_TRUE(secondary_tray->IsPopupVisible()); | 300 EXPECT_TRUE(secondary_tray->IsPopupVisible()); |
| 301 } | 301 } |
| 302 | 302 |
| 303 #if defined(OS_CHROMEOS) | 303 #if defined(OS_CHROMEOS) |
| 304 // PopupAndSystemTray may fail in platforms other than ChromeOS because the | 304 // PopupAndSystemTray may fail in platforms other than ChromeOS because the |
| 305 // RootWindow's bound can be bigger than gfx::Display's work area so that | 305 // RootWindow's bound can be bigger than display::Display's work area so that |
| 306 // openingsystem tray doesn't affect at all the work area of popups. | 306 // openingsystem tray doesn't affect at all the work area of popups. |
| 307 #define MAYBE_PopupAndSystemTray PopupAndSystemTray | 307 #define MAYBE_PopupAndSystemTray PopupAndSystemTray |
| 308 #define MAYBE_PopupAndAutoHideShelf PopupAndAutoHideShelf | 308 #define MAYBE_PopupAndAutoHideShelf PopupAndAutoHideShelf |
| 309 #define MAYBE_PopupAndFullscreen PopupAndFullscreen | 309 #define MAYBE_PopupAndFullscreen PopupAndFullscreen |
| 310 #else | 310 #else |
| 311 #define MAYBE_PopupAndSystemTray DISABLED_PopupAndSystemTray | 311 #define MAYBE_PopupAndSystemTray DISABLED_PopupAndSystemTray |
| 312 #define MAYBE_PopupAndAutoHideShelf DISABLED_PopupAndAutoHideShelf | 312 #define MAYBE_PopupAndAutoHideShelf DISABLED_PopupAndAutoHideShelf |
| 313 #define MAYBE_PopupAndFullscreen DISABLED_PopupAndFullscreen | 313 #define MAYBE_PopupAndFullscreen DISABLED_PopupAndFullscreen |
| 314 #endif | 314 #endif |
| 315 | 315 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 | 431 |
| 432 // The work area for auto-hidden status of fullscreen is a bit larger | 432 // The work area for auto-hidden status of fullscreen is a bit larger |
| 433 // since it doesn't even have the 3-pixel width. | 433 // since it doesn't even have the 3-pixel width. |
| 434 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 434 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 435 int bottom_fullscreen_hidden = GetPopupWorkAreaBottom(); | 435 int bottom_fullscreen_hidden = GetPopupWorkAreaBottom(); |
| 436 EXPECT_EQ(bottom_auto_hidden, bottom_fullscreen_hidden); | 436 EXPECT_EQ(bottom_auto_hidden, bottom_fullscreen_hidden); |
| 437 | 437 |
| 438 // Move the mouse cursor at the bottom, which shows the shelf. | 438 // Move the mouse cursor at the bottom, which shows the shelf. |
| 439 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 439 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 440 gfx::Point bottom_right = | 440 gfx::Point bottom_right = |
| 441 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds().bottom_right(); | 441 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().bottom_right(); |
| 442 bottom_right.Offset(-1, -1); | 442 bottom_right.Offset(-1, -1); |
| 443 generator.MoveMouseTo(bottom_right); | 443 generator.MoveMouseTo(bottom_right); |
| 444 shelf->UpdateAutoHideStateNow(); | 444 shelf->UpdateAutoHideStateNow(); |
| 445 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 445 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
| 446 EXPECT_EQ(bottom, GetPopupWorkAreaBottom()); | 446 EXPECT_EQ(bottom, GetPopupWorkAreaBottom()); |
| 447 | 447 |
| 448 generator.MoveMouseTo( | 448 generator.MoveMouseTo( |
| 449 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds().CenterPoint()); | 449 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().CenterPoint()); |
| 450 shelf->UpdateAutoHideStateNow(); | 450 shelf->UpdateAutoHideStateNow(); |
| 451 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 451 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 452 EXPECT_EQ(bottom_auto_hidden, GetPopupWorkAreaBottom()); | 452 EXPECT_EQ(bottom_auto_hidden, GetPopupWorkAreaBottom()); |
| 453 } | 453 } |
| 454 | 454 |
| 455 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndSystemTrayMultiDisplay) { | 455 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndSystemTrayMultiDisplay) { |
| 456 UpdateDisplay("800x600,600x400"); | 456 UpdateDisplay("800x600,600x400"); |
| 457 | 457 |
| 458 AddNotification("test_id"); | 458 AddNotification("test_id"); |
| 459 int bottom = GetPopupWorkAreaBottom(); | 459 int bottom = GetPopupWorkAreaBottom(); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, out_of_bounds, touch_id, | 524 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, out_of_bounds, touch_id, |
| 525 move.time_stamp()+base::TimeDelta::FromMilliseconds(50)); | 525 move.time_stamp()+base::TimeDelta::FromMilliseconds(50)); |
| 526 generator.Dispatch(&release); | 526 generator.Dispatch(&release); |
| 527 EXPECT_FALSE(tray->draw_background_as_active()); | 527 EXPECT_FALSE(tray->draw_background_as_active()); |
| 528 EXPECT_FALSE(tray->IsMessageCenterBubbleVisible()); | 528 EXPECT_FALSE(tray->IsMessageCenterBubbleVisible()); |
| 529 } | 529 } |
| 530 | 530 |
| 531 #endif // OS_CHROMEOS | 531 #endif // OS_CHROMEOS |
| 532 | 532 |
| 533 } // namespace ash | 533 } // namespace ash |
| OLD | NEW |