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/public/cpp/config.h" | 10 #include "ash/public/cpp/config.h" |
11 #include "ash/public/cpp/shell_window_ids.h" | 11 #include "ash/public/cpp/shell_window_ids.h" |
| 12 #include "ash/shelf/shelf.h" |
12 #include "ash/shelf/shelf_layout_manager.h" | 13 #include "ash/shelf/shelf_layout_manager.h" |
13 #include "ash/shelf/wm_shelf.h" | |
14 #include "ash/shell.h" | 14 #include "ash/shell.h" |
15 #include "ash/system/screen_layout_observer.h" | 15 #include "ash/system/screen_layout_observer.h" |
16 #include "ash/system/status_area_widget.h" | 16 #include "ash/system/status_area_widget.h" |
17 #include "ash/system/tray/system_tray.h" | 17 #include "ash/system/tray/system_tray.h" |
18 #include "ash/system/tray/system_tray_item.h" | 18 #include "ash/system/tray/system_tray_item.h" |
19 #include "ash/system/web_notification/ash_popup_alignment_delegate.h" | 19 #include "ash/system/web_notification/ash_popup_alignment_delegate.h" |
20 #include "ash/test/ash_test_base.h" | 20 #include "ash/test/ash_test_base.h" |
21 #include "ash/test/status_area_widget_test_helper.h" | 21 #include "ash/test/status_area_widget_test_helper.h" |
22 #include "ash/test/test_system_tray_delegate.h" | 22 #include "ash/test/test_system_tray_delegate.h" |
23 #include "ash/wm/window_state.h" | 23 #include "ash/wm/window_state.h" |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 EXPECT_GT(bottom, bottom_with_tray); | 302 EXPECT_GT(bottom, bottom_with_tray); |
303 } | 303 } |
304 | 304 |
305 TEST_F(WebNotificationTrayTest, PopupAndAutoHideShelf) { | 305 TEST_F(WebNotificationTrayTest, PopupAndAutoHideShelf) { |
306 AddNotification("test_id"); | 306 AddNotification("test_id"); |
307 EXPECT_TRUE(GetTray()->IsPopupVisible()); | 307 EXPECT_TRUE(GetTray()->IsPopupVisible()); |
308 int bottom = GetPopupWorkAreaBottom(); | 308 int bottom = GetPopupWorkAreaBottom(); |
309 | 309 |
310 // Shelf's auto-hide state won't be HIDDEN unless window exists. | 310 // Shelf's auto-hide state won't be HIDDEN unless window exists. |
311 std::unique_ptr<views::Widget> widget(CreateTestWidget()); | 311 std::unique_ptr<views::Widget> widget(CreateTestWidget()); |
312 WmShelf* shelf = GetPrimaryShelf(); | 312 Shelf* shelf = GetPrimaryShelf(); |
313 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 313 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
314 | 314 |
315 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 315 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
316 int bottom_auto_hidden = GetPopupWorkAreaBottom(); | 316 int bottom_auto_hidden = GetPopupWorkAreaBottom(); |
317 EXPECT_LT(bottom, bottom_auto_hidden); | 317 EXPECT_LT(bottom, bottom_auto_hidden); |
318 | 318 |
319 // Close the window, which shows the shelf. | 319 // Close the window, which shows the shelf. |
320 widget.reset(); | 320 widget.reset(); |
321 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | 321 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
322 int bottom_auto_shown = GetPopupWorkAreaBottom(); | 322 int bottom_auto_shown = GetPopupWorkAreaBottom(); |
(...skipping 12 matching lines...) Expand all Loading... |
335 EXPECT_GT(bottom_auto_shown, bottom_with_tray); | 335 EXPECT_GT(bottom_auto_shown, bottom_with_tray); |
336 } | 336 } |
337 | 337 |
338 TEST_F(WebNotificationTrayTest, PopupAndFullscreen) { | 338 TEST_F(WebNotificationTrayTest, PopupAndFullscreen) { |
339 AddNotification("test_id"); | 339 AddNotification("test_id"); |
340 EXPECT_TRUE(IsPopupVisible()); | 340 EXPECT_TRUE(IsPopupVisible()); |
341 int bottom = GetPopupWorkAreaBottom(); | 341 int bottom = GetPopupWorkAreaBottom(); |
342 | 342 |
343 // Checks the work area for normal auto-hidden state. | 343 // Checks the work area for normal auto-hidden state. |
344 std::unique_ptr<views::Widget> widget(CreateTestWidget()); | 344 std::unique_ptr<views::Widget> widget(CreateTestWidget()); |
345 WmShelf* shelf = GetPrimaryShelf(); | 345 Shelf* shelf = GetPrimaryShelf(); |
346 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 346 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
347 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 347 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
348 int bottom_auto_hidden = GetPopupWorkAreaBottom(); | 348 int bottom_auto_hidden = GetPopupWorkAreaBottom(); |
349 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 349 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
350 | 350 |
351 // Put |widget| into fullscreen without forcing the shelf to hide. Currently, | 351 // Put |widget| into fullscreen without forcing the shelf to hide. Currently, |
352 // this is used by immersive fullscreen and forces the shelf to be auto | 352 // this is used by immersive fullscreen and forces the shelf to be auto |
353 // hidden. | 353 // hidden. |
354 wm::GetWindowState(widget->GetNativeWindow()) | 354 wm::GetWindowState(widget->GetNativeWindow()) |
355 ->set_hide_shelf_when_fullscreen(false); | 355 ->set_hide_shelf_when_fullscreen(false); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 int bottom_second = GetPopupWorkAreaBottomForTray(GetSecondaryTray()); | 387 int bottom_second = GetPopupWorkAreaBottomForTray(GetSecondaryTray()); |
388 | 388 |
389 // System tray is created on the primary display. The popups in the secondary | 389 // System tray is created on the primary display. The popups in the secondary |
390 // tray aren't affected. | 390 // tray aren't affected. |
391 GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW); | 391 GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW); |
392 EXPECT_GT(bottom, GetPopupWorkAreaBottom()); | 392 EXPECT_GT(bottom, GetPopupWorkAreaBottom()); |
393 EXPECT_EQ(bottom_second, GetPopupWorkAreaBottomForTray(GetSecondaryTray())); | 393 EXPECT_EQ(bottom_second, GetPopupWorkAreaBottomForTray(GetSecondaryTray())); |
394 } | 394 } |
395 | 395 |
396 } // namespace ash | 396 } // namespace ash |
OLD | NEW |