| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/display/display_manager.h" | 9 #include "ash/display/display_manager.h" |
| 10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 namespace ash { | 39 namespace ash { |
| 40 | 40 |
| 41 namespace { | 41 namespace { |
| 42 | 42 |
| 43 WebNotificationTray* GetTray() { | 43 WebNotificationTray* GetTray() { |
| 44 return Shell::GetPrimaryRootWindowController()->shelf()-> | 44 return Shell::GetPrimaryRootWindowController()->shelf()-> |
| 45 status_area_widget()->web_notification_tray(); | 45 status_area_widget()->web_notification_tray(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 WebNotificationTray* GetSecondaryTray() { | 48 WebNotificationTray* GetSecondaryTray() { |
| 49 internal::RootWindowController* primary_controller = | 49 RootWindowController* primary_controller = |
| 50 Shell::GetPrimaryRootWindowController(); | 50 Shell::GetPrimaryRootWindowController(); |
| 51 Shell::RootWindowControllerList controllers = | 51 Shell::RootWindowControllerList controllers = |
| 52 Shell::GetAllRootWindowControllers(); | 52 Shell::GetAllRootWindowControllers(); |
| 53 for (size_t i = 0; i < controllers.size(); ++i) { | 53 for (size_t i = 0; i < controllers.size(); ++i) { |
| 54 if (controllers[i] != primary_controller) { | 54 if (controllers[i] != primary_controller) { |
| 55 return controllers[i]->shelf()-> | 55 return controllers[i]->shelf()-> |
| 56 status_area_widget()->web_notification_tray(); | 56 status_area_widget()->web_notification_tray(); |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 | 59 |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 // UpdateDisplay() creates the display notifications, so popup is visible. | 286 // UpdateDisplay() creates the display notifications, so popup is visible. |
| 287 EXPECT_TRUE(GetTray()->IsPopupVisible()); | 287 EXPECT_TRUE(GetTray()->IsPopupVisible()); |
| 288 WebNotificationTray* secondary_tray = GetSecondaryTray(); | 288 WebNotificationTray* secondary_tray = GetSecondaryTray(); |
| 289 ASSERT_TRUE(secondary_tray); | 289 ASSERT_TRUE(secondary_tray); |
| 290 EXPECT_TRUE(secondary_tray->IsPopupVisible()); | 290 EXPECT_TRUE(secondary_tray->IsPopupVisible()); |
| 291 | 291 |
| 292 // Transition to mirroring and then back to extended display, which recreates | 292 // Transition to mirroring and then back to extended display, which recreates |
| 293 // root window controller and shelf with having notifications. This code | 293 // root window controller and shelf with having notifications. This code |
| 294 // verifies it doesn't cause crash and popups are still visible. See | 294 // verifies it doesn't cause crash and popups are still visible. See |
| 295 // http://crbug.com/263664 | 295 // http://crbug.com/263664 |
| 296 internal::DisplayManager* display_manager = | 296 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 297 Shell::GetInstance()->display_manager(); | |
| 298 | 297 |
| 299 display_manager->SetSecondDisplayMode(internal::DisplayManager::MIRRORING); | 298 display_manager->SetSecondDisplayMode(DisplayManager::MIRRORING); |
| 300 UpdateDisplay("400x400,200x200"); | 299 UpdateDisplay("400x400,200x200"); |
| 301 EXPECT_TRUE(GetTray()->IsPopupVisible()); | 300 EXPECT_TRUE(GetTray()->IsPopupVisible()); |
| 302 EXPECT_FALSE(GetSecondaryTray()); | 301 EXPECT_FALSE(GetSecondaryTray()); |
| 303 | 302 |
| 304 display_manager->SetSecondDisplayMode(internal::DisplayManager::EXTENDED); | 303 display_manager->SetSecondDisplayMode(DisplayManager::EXTENDED); |
| 305 UpdateDisplay("400x400,200x200"); | 304 UpdateDisplay("400x400,200x200"); |
| 306 EXPECT_TRUE(GetTray()->IsPopupVisible()); | 305 EXPECT_TRUE(GetTray()->IsPopupVisible()); |
| 307 secondary_tray = GetSecondaryTray(); | 306 secondary_tray = GetSecondaryTray(); |
| 308 ASSERT_TRUE(secondary_tray); | 307 ASSERT_TRUE(secondary_tray); |
| 309 EXPECT_TRUE(secondary_tray->IsPopupVisible()); | 308 EXPECT_TRUE(secondary_tray->IsPopupVisible()); |
| 310 } | 309 } |
| 311 | 310 |
| 312 #if defined(OS_CHROMEOS) | 311 #if defined(OS_CHROMEOS) |
| 313 // PopupAndSystemTray may fail in platforms other than ChromeOS because the | 312 // PopupAndSystemTray may fail in platforms other than ChromeOS because the |
| 314 // RootWindow's bound can be bigger than gfx::Display's work area so that | 313 // RootWindow's bound can be bigger than gfx::Display's work area so that |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 } | 362 } |
| 364 | 363 |
| 365 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndAutoHideShelf) { | 364 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndAutoHideShelf) { |
| 366 AddNotification("test_id"); | 365 AddNotification("test_id"); |
| 367 EXPECT_TRUE(GetTray()->IsPopupVisible()); | 366 EXPECT_TRUE(GetTray()->IsPopupVisible()); |
| 368 gfx::Rect work_area = GetPopupWorkArea(); | 367 gfx::Rect work_area = GetPopupWorkArea(); |
| 369 | 368 |
| 370 // Shelf's auto-hide state won't be HIDDEN unless window exists. | 369 // Shelf's auto-hide state won't be HIDDEN unless window exists. |
| 371 scoped_ptr<aura::Window> window( | 370 scoped_ptr<aura::Window> window( |
| 372 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4))); | 371 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4))); |
| 373 internal::ShelfLayoutManager* shelf = | 372 ShelfLayoutManager* shelf = |
| 374 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); | 373 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); |
| 375 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 374 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 376 | 375 |
| 377 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 376 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 378 gfx::Rect work_area_auto_hidden = GetPopupWorkArea(); | 377 gfx::Rect work_area_auto_hidden = GetPopupWorkArea(); |
| 379 EXPECT_LT(work_area.size().GetArea(), work_area_auto_hidden.size().GetArea()); | 378 EXPECT_LT(work_area.size().GetArea(), work_area_auto_hidden.size().GetArea()); |
| 380 | 379 |
| 381 // Close the window, which shows the shelf. | 380 // Close the window, which shows the shelf. |
| 382 window.reset(); | 381 window.reset(); |
| 383 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 382 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 } | 424 } |
| 426 | 425 |
| 427 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndFullscreen) { | 426 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndFullscreen) { |
| 428 AddNotification("test_id"); | 427 AddNotification("test_id"); |
| 429 EXPECT_TRUE(IsPopupVisible()); | 428 EXPECT_TRUE(IsPopupVisible()); |
| 430 gfx::Rect work_area = GetPopupWorkArea(); | 429 gfx::Rect work_area = GetPopupWorkArea(); |
| 431 | 430 |
| 432 // Checks the work area for normal auto-hidden state. | 431 // Checks the work area for normal auto-hidden state. |
| 433 scoped_ptr<aura::Window> window( | 432 scoped_ptr<aura::Window> window( |
| 434 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4))); | 433 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4))); |
| 435 internal::ShelfLayoutManager* shelf = | 434 ShelfLayoutManager* shelf = |
| 436 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); | 435 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); |
| 437 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 436 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 438 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 437 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 439 gfx::Rect work_area_auto_hidden = GetPopupWorkArea(); | 438 gfx::Rect work_area_auto_hidden = GetPopupWorkArea(); |
| 440 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 439 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 441 | 440 |
| 442 // Put |window| into fullscreen without forcing the shelf to hide. Currently, | 441 // Put |window| into fullscreen without forcing the shelf to hide. Currently, |
| 443 // this is used by immersive fullscreen and forces the shelf to be auto | 442 // this is used by immersive fullscreen and forces the shelf to be auto |
| 444 // hidden. | 443 // hidden. |
| 445 wm::GetWindowState(window.get())->set_hide_shelf_when_fullscreen(false); | 444 wm::GetWindowState(window.get())->set_hide_shelf_when_fullscreen(false); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 | 477 |
| 479 // System tray is created on the primary display. The popups in the secondary | 478 // System tray is created on the primary display. The popups in the secondary |
| 480 // tray aren't affected. | 479 // tray aren't affected. |
| 481 GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW); | 480 GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW); |
| 482 EXPECT_GT(work_area.size().GetArea(), GetPopupWorkArea().size().GetArea()); | 481 EXPECT_GT(work_area.size().GetArea(), GetPopupWorkArea().size().GetArea()); |
| 483 EXPECT_EQ(work_area_second.ToString(), | 482 EXPECT_EQ(work_area_second.ToString(), |
| 484 GetPopupWorkAreaForTray(GetSecondaryTray()).ToString()); | 483 GetPopupWorkAreaForTray(GetSecondaryTray()).ToString()); |
| 485 } | 484 } |
| 486 | 485 |
| 487 } // namespace ash | 486 } // namespace ash |
| OLD | NEW |