| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" | 5 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "ash/common/system/date/date_default_view.h" | 9 #include "ash/common/system/date/date_default_view.h" |
| 10 #include "ash/common/system/date/date_view.h" | 10 #include "ash/common/system/date/date_view.h" |
| 11 #include "ash/common/system/date/tray_date.h" | 11 #include "ash/common/system/date/tray_date.h" |
| 12 #include "ash/display/display_manager.h" | |
| 13 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 14 #include "ash/test/display_manager_test_api.h" | |
| 15 #include "base/macros.h" | 13 #include "base/macros.h" |
| 16 #include "chrome/browser/chromeos/login/login_manager_test.h" | 14 #include "chrome/browser/chromeos/login/login_manager_test.h" |
| 17 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | 15 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
| 18 #include "chrome/browser/chromeos/login/startup_utils.h" | 16 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 19 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" | 17 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" |
| 20 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 18 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 21 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 22 #include "chrome/browser/ui/chrome_pages.h" | |
| 23 #include "chrome/browser/ui/tabs/tab_strip_model.h" | |
| 24 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 25 #include "chrome/common/url_constants.h" | |
| 26 #include "chrome/test/base/in_process_browser_test.h" | 21 #include "chrome/test/base/in_process_browser_test.h" |
| 27 #include "chrome/test/base/ui_test_utils.h" | |
| 28 #include "components/prefs/pref_service.h" | 22 #include "components/prefs/pref_service.h" |
| 29 #include "components/user_manager/user_manager.h" | 23 #include "components/user_manager/user_manager.h" |
| 30 #include "content/public/test/test_utils.h" | 24 #include "content/public/test/test_utils.h" |
| 31 #include "ui/message_center/message_center.h" | |
| 32 #include "ui/message_center/notification_list.h" | |
| 33 | 25 |
| 34 namespace chromeos { | 26 namespace chromeos { |
| 35 | 27 |
| 36 namespace { | 28 namespace { |
| 37 | 29 |
| 38 // Because policy is not needed this test it is better to use e-mails that | 30 // Because policy is not needed this test it is better to use e-mails that |
| 39 // are definitely not enterprise. This lets us to avoid faking of policy fetch | 31 // are definitely not enterprise. This lets us to avoid faking of policy fetch |
| 40 // procedure. | 32 // procedure. |
| 41 const char kUser1[] = "user1@gmail.com"; | 33 const char kUser1[] = "user1@gmail.com"; |
| 42 const char kUser2[] = "user2@gmail.com"; | 34 const char kUser2[] = "user2@gmail.com"; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 53 | 45 |
| 54 void CreateDefaultView() { | 46 void CreateDefaultView() { |
| 55 ash::TrayDate* tray_date = ash::Shell::GetInstance() | 47 ash::TrayDate* tray_date = ash::Shell::GetInstance() |
| 56 ->GetPrimarySystemTray() | 48 ->GetPrimarySystemTray() |
| 57 ->GetTrayDateForTesting(); | 49 ->GetTrayDateForTesting(); |
| 58 tray_date->CreateDefaultViewForTesting(ash::LoginStatus::NOT_LOGGED_IN); | 50 tray_date->CreateDefaultViewForTesting(ash::LoginStatus::NOT_LOGGED_IN); |
| 59 } | 51 } |
| 60 | 52 |
| 61 } // namespace | 53 } // namespace |
| 62 | 54 |
| 63 class DisplayNotificationsTest : public InProcessBrowserTest { | |
| 64 public: | |
| 65 DisplayNotificationsTest() {} | |
| 66 ~DisplayNotificationsTest() override {} | |
| 67 | |
| 68 void SetUp() override { InProcessBrowserTest::SetUp(); } | |
| 69 | |
| 70 void UpdateDisplay(const std::string& display_specs) { | |
| 71 ash::test::DisplayManagerTestApi( | |
| 72 ash::Shell::GetInstance()->display_manager()) | |
| 73 .UpdateDisplay(display_specs); | |
| 74 } | |
| 75 | |
| 76 message_center::NotificationList::Notifications GetVisibleNotifications() | |
| 77 const { | |
| 78 return message_center::MessageCenter::Get()->GetVisibleNotifications(); | |
| 79 } | |
| 80 }; | |
| 81 | |
| 82 class SystemTrayDelegateChromeOSTest : public LoginManagerTest { | 55 class SystemTrayDelegateChromeOSTest : public LoginManagerTest { |
| 83 protected: | 56 protected: |
| 84 SystemTrayDelegateChromeOSTest() | 57 SystemTrayDelegateChromeOSTest() |
| 85 : LoginManagerTest(false /* should_launch_browser */), | 58 : LoginManagerTest(false /* should_launch_browser */), |
| 86 account_id1_(AccountId::FromUserEmail(kUser1)), | 59 account_id1_(AccountId::FromUserEmail(kUser1)), |
| 87 account_id2_(AccountId::FromUserEmail(kUser2)) {} | 60 account_id2_(AccountId::FromUserEmail(kUser2)) {} |
| 88 | 61 |
| 89 ~SystemTrayDelegateChromeOSTest() override {} | 62 ~SystemTrayDelegateChromeOSTest() override {} |
| 90 | 63 |
| 91 void SetupUserProfile(const AccountId& account_id, bool use_24_hour_clock) { | 64 void SetupUserProfile(const AccountId& account_id, bool use_24_hour_clock) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 CreateDefaultView(); | 99 CreateDefaultView(); |
| 127 EXPECT_EQ(base::k12HourClock, GetHourType()); | 100 EXPECT_EQ(base::k12HourClock, GetHourType()); |
| 128 | 101 |
| 129 user_manager::UserManager::Get()->SwitchActiveUser(account_id1_); | 102 user_manager::UserManager::Get()->SwitchActiveUser(account_id1_); |
| 130 // Allow clock setting to be sent to ash over mojo. | 103 // Allow clock setting to be sent to ash over mojo. |
| 131 content::RunAllPendingInMessageLoop(); | 104 content::RunAllPendingInMessageLoop(); |
| 132 CreateDefaultView(); | 105 CreateDefaultView(); |
| 133 EXPECT_EQ(base::k24HourClock, GetHourType()); | 106 EXPECT_EQ(base::k24HourClock, GetHourType()); |
| 134 } | 107 } |
| 135 | 108 |
| 136 // Makes sure that no notifications are shown when rotating the | |
| 137 // display on display settings URLs. | |
| 138 IN_PROC_BROWSER_TEST_F(DisplayNotificationsTest, | |
| 139 TestDisplayOrientationChangeNotification) { | |
| 140 // Open the display settings page. | |
| 141 ui_test_utils::NavigateToURL(browser(), | |
| 142 GURL("chrome://settings-frame/display")); | |
| 143 // Rotate the display 90 degrees. | |
| 144 UpdateDisplay("400x400/r"); | |
| 145 // Ensure that no notification was displayed. | |
| 146 EXPECT_TRUE(GetVisibleNotifications().empty()); | |
| 147 | |
| 148 // Reset the display. | |
| 149 UpdateDisplay("400x400"); | |
| 150 | |
| 151 ui_test_utils::NavigateToURL(browser(), GURL("chrome://settings/display")); | |
| 152 UpdateDisplay("400x400/r"); | |
| 153 EXPECT_TRUE(GetVisibleNotifications().empty()); | |
| 154 | |
| 155 UpdateDisplay("400x400"); | |
| 156 | |
| 157 ui_test_utils::NavigateToURL(browser(), | |
| 158 GURL("chrome://settings/displayOverscan")); | |
| 159 UpdateDisplay("400x400/r"); | |
| 160 EXPECT_TRUE(GetVisibleNotifications().empty()); | |
| 161 | |
| 162 UpdateDisplay("400x400"); | |
| 163 | |
| 164 ui_test_utils::NavigateToURL(browser(), GURL("chrome://version")); | |
| 165 UpdateDisplay("400x400/r"); | |
| 166 // Ensure that there is a notification that is shown. | |
| 167 EXPECT_FALSE(GetVisibleNotifications().empty()); | |
| 168 } | |
| 169 | |
| 170 } // namespace chromeos | 109 } // namespace chromeos |
| OLD | NEW |