| 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/common/system/web_notification/web_notification_tray.h" | 5 #include "ash/common/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/shelf_layout_manager.h" | 10 #include "ash/common/shelf/shelf_layout_manager.h" |
| 11 #include "ash/common/shelf/wm_shelf.h" | 11 #include "ash/common/shelf/wm_shelf.h" |
| 12 #include "ash/common/system/status_area_widget.h" | 12 #include "ash/common/system/status_area_widget.h" |
| 13 #include "ash/common/system/tray/system_tray.h" | 13 #include "ash/common/system/tray/system_tray.h" |
| 14 #include "ash/common/system/tray/system_tray_item.h" | 14 #include "ash/common/system/tray/system_tray_item.h" |
| 15 #include "ash/common/system/web_notification/ash_popup_alignment_delegate.h" | 15 #include "ash/common/system/web_notification/ash_popup_alignment_delegate.h" |
| 16 #include "ash/common/test/test_system_tray_delegate.h" | 16 #include "ash/common/test/test_system_tray_delegate.h" |
| 17 #include "ash/common/wm/window_state.h" | 17 #include "ash/common/wm/window_state.h" |
| 18 #include "ash/common/wm_lookup.h" | 18 #include "ash/common/wm_lookup.h" |
| 19 #include "ash/common/wm_shell.h" |
| 19 #include "ash/common/wm_window.h" | 20 #include "ash/common/wm_window.h" |
| 20 #include "ash/public/cpp/shell_window_ids.h" | 21 #include "ash/public/cpp/shell_window_ids.h" |
| 21 #include "ash/shell.h" | 22 #include "ash/shell.h" |
| 22 #include "ash/system/chromeos/screen_layout_observer.h" | 23 #include "ash/system/chromeos/screen_layout_observer.h" |
| 23 #include "ash/test/ash_test_base.h" | 24 #include "ash/test/ash_test_base.h" |
| 24 #include "ash/test/status_area_widget_test_helper.h" | 25 #include "ash/test/status_area_widget_test_helper.h" |
| 25 #include "base/memory/ptr_util.h" | 26 #include "base/memory/ptr_util.h" |
| 26 #include "base/strings/stringprintf.h" | 27 #include "base/strings/stringprintf.h" |
| 27 #include "base/strings/utf_string_conversions.h" | 28 #include "base/strings/utf_string_conversions.h" |
| 28 #include "ui/display/display.h" | 29 #include "ui/display/display.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 default_view->AddChildView(new views::Label(base::UTF8ToUTF16("Default"))); | 79 default_view->AddChildView(new views::Label(base::UTF8ToUTF16("Default"))); |
| 79 return default_view; | 80 return default_view; |
| 80 } | 81 } |
| 81 | 82 |
| 82 private: | 83 private: |
| 83 DISALLOW_COPY_AND_ASSIGN(TestItem); | 84 DISALLOW_COPY_AND_ASSIGN(TestItem); |
| 84 }; | 85 }; |
| 85 | 86 |
| 86 } // namespace | 87 } // namespace |
| 87 | 88 |
| 88 // TODO(jamescook): Move this to //ash/common. http://crbug.com/620955 | |
| 89 class WebNotificationTrayTest : public test::AshTestBase { | 89 class WebNotificationTrayTest : public test::AshTestBase { |
| 90 public: | 90 public: |
| 91 WebNotificationTrayTest() {} | 91 WebNotificationTrayTest() {} |
| 92 ~WebNotificationTrayTest() override {} | 92 ~WebNotificationTrayTest() override {} |
| 93 | 93 |
| 94 void TearDown() override { | 94 void TearDown() override { |
| 95 GetMessageCenter()->RemoveAllNotifications( | 95 GetMessageCenter()->RemoveAllNotifications( |
| 96 false /* by_user */, message_center::MessageCenter::RemoveType::ALL); | 96 false /* by_user */, message_center::MessageCenter::RemoveType::ALL); |
| 97 test::AshTestBase::TearDown(); | 97 test::AshTestBase::TearDown(); |
| 98 } | 98 } |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 GetTray()->ShowPopups(); | 247 GetTray()->ShowPopups(); |
| 248 EXPECT_TRUE(GetTray()->IsPopupVisible()); | 248 EXPECT_TRUE(GetTray()->IsPopupVisible()); |
| 249 EXPECT_EQ(notifications_to_add, GetMessageCenter()->NotificationCount()); | 249 EXPECT_EQ(notifications_to_add, GetMessageCenter()->NotificationCount()); |
| 250 NotificationList::PopupNotifications popups = | 250 NotificationList::PopupNotifications popups = |
| 251 GetMessageCenter()->GetPopupNotifications(); | 251 GetMessageCenter()->GetPopupNotifications(); |
| 252 EXPECT_EQ(message_center::kMaxVisiblePopupNotifications, popups.size()); | 252 EXPECT_EQ(message_center::kMaxVisiblePopupNotifications, popups.size()); |
| 253 } | 253 } |
| 254 | 254 |
| 255 // Verifies if the notification appears on both displays when extended mode. | 255 // Verifies if the notification appears on both displays when extended mode. |
| 256 TEST_F(WebNotificationTrayTest, PopupShownOnBothDisplays) { | 256 TEST_F(WebNotificationTrayTest, PopupShownOnBothDisplays) { |
| 257 // TODO: needs ScreenLayoutObserver, http://crbug.com/696752. |
| 258 if (WmShell::Get()->IsRunningInMash()) |
| 259 return; |
| 260 |
| 257 Shell::GetInstance() | 261 Shell::GetInstance() |
| 258 ->screen_layout_observer() | 262 ->screen_layout_observer() |
| 259 ->set_show_notifications_for_testing(true); | 263 ->set_show_notifications_for_testing(true); |
| 260 UpdateDisplay("400x400,200x200"); | 264 UpdateDisplay("400x400,200x200"); |
| 261 // UpdateDisplay() creates the display notifications, so popup is visible. | 265 // UpdateDisplay() creates the display notifications, so popup is visible. |
| 262 EXPECT_TRUE(GetTray()->IsPopupVisible()); | 266 EXPECT_TRUE(GetTray()->IsPopupVisible()); |
| 263 WebNotificationTray* secondary_tray = GetSecondaryTray(); | 267 WebNotificationTray* secondary_tray = GetSecondaryTray(); |
| 264 ASSERT_TRUE(secondary_tray); | 268 ASSERT_TRUE(secondary_tray); |
| 265 EXPECT_TRUE(secondary_tray->IsPopupVisible()); | 269 EXPECT_TRUE(secondary_tray->IsPopupVisible()); |
| 266 | 270 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 int bottom_second = GetPopupWorkAreaBottomForTray(GetSecondaryTray()); | 392 int bottom_second = GetPopupWorkAreaBottomForTray(GetSecondaryTray()); |
| 389 | 393 |
| 390 // System tray is created on the primary display. The popups in the secondary | 394 // System tray is created on the primary display. The popups in the secondary |
| 391 // tray aren't affected. | 395 // tray aren't affected. |
| 392 GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW); | 396 GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW); |
| 393 EXPECT_GT(bottom, GetPopupWorkAreaBottom()); | 397 EXPECT_GT(bottom, GetPopupWorkAreaBottom()); |
| 394 EXPECT_EQ(bottom_second, GetPopupWorkAreaBottomForTray(GetSecondaryTray())); | 398 EXPECT_EQ(bottom_second, GetPopupWorkAreaBottomForTray(GetSecondaryTray())); |
| 395 } | 399 } |
| 396 | 400 |
| 397 } // namespace ash | 401 } // namespace ash |
| OLD | NEW |