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/display/display_manager.h" | 9 #include "ash/display/display_manager.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 72 |
73 message_center::NotificationList::Notifications GetVisibleNotifications() | 73 message_center::NotificationList::Notifications GetVisibleNotifications() |
74 const { | 74 const { |
75 return message_center::MessageCenter::Get()->GetVisibleNotifications(); | 75 return message_center::MessageCenter::Get()->GetVisibleNotifications(); |
76 } | 76 } |
77 }; | 77 }; |
78 | 78 |
79 class SystemTrayDelegateChromeOSTest : public LoginManagerTest { | 79 class SystemTrayDelegateChromeOSTest : public LoginManagerTest { |
80 protected: | 80 protected: |
81 SystemTrayDelegateChromeOSTest() | 81 SystemTrayDelegateChromeOSTest() |
82 : LoginManagerTest(false /* should_launch_browser */), | 82 : LoginManagerTest(false /* should_launch_browser */) {} |
83 account_id1_(AccountId::FromUserEmail(kUser1)), | |
84 account_id2_(AccountId::FromUserEmail(kUser2)) {} | |
85 | 83 |
86 ~SystemTrayDelegateChromeOSTest() override {} | 84 ~SystemTrayDelegateChromeOSTest() override {} |
87 | 85 |
88 void SetupUserProfile(const AccountId& account_id, bool use_24_hour_clock) { | 86 void SetupUserProfile(const std::string& user_name, bool use_24_hour_clock) { |
89 const user_manager::User* user = | 87 const user_manager::User* user = |
90 user_manager::UserManager::Get()->FindUser(account_id); | 88 user_manager::UserManager::Get()->FindUser(user_name); |
91 Profile* profile = ProfileHelper::Get()->GetProfileByUser(user); | 89 Profile* profile = ProfileHelper::Get()->GetProfileByUser(user); |
92 profile->GetPrefs()->SetBoolean(prefs::kUse24HourClock, use_24_hour_clock); | 90 profile->GetPrefs()->SetBoolean(prefs::kUse24HourClock, use_24_hour_clock); |
93 } | 91 } |
94 | 92 |
95 const AccountId account_id1_; | |
96 const AccountId account_id2_; | |
97 | |
98 private: | 93 private: |
99 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegateChromeOSTest); | 94 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegateChromeOSTest); |
100 }; | 95 }; |
101 | 96 |
102 IN_PROC_BROWSER_TEST_F(SystemTrayDelegateChromeOSTest, | 97 IN_PROC_BROWSER_TEST_F(SystemTrayDelegateChromeOSTest, |
103 PRE_TestMultiProfile24HourClock) { | 98 PRE_TestMultiProfile24HourClock) { |
104 RegisterUser(account_id1_.GetUserEmail()); | 99 RegisterUser(kUser1); |
105 RegisterUser(account_id2_.GetUserEmail()); | 100 RegisterUser(kUser2); |
106 StartupUtils::MarkOobeCompleted(); | 101 StartupUtils::MarkOobeCompleted(); |
107 } | 102 } |
108 | 103 |
109 // Test that clock type is taken from user profile for current active user. | 104 // Test that clock type is taken from user profile for current active user. |
110 IN_PROC_BROWSER_TEST_F(SystemTrayDelegateChromeOSTest, | 105 IN_PROC_BROWSER_TEST_F(SystemTrayDelegateChromeOSTest, |
111 TestMultiProfile24HourClock) { | 106 TestMultiProfile24HourClock) { |
112 LoginUser(account_id1_.GetUserEmail()); | 107 LoginUser(kUser1); |
113 SetupUserProfile(account_id1_, true /* Use_24_hour_clock. */); | 108 SetupUserProfile(kUser1, true /* Use_24_hour_clock. */); |
114 CreateDefaultView(); | 109 CreateDefaultView(); |
115 EXPECT_EQ(base::k24HourClock, GetHourType()); | 110 EXPECT_EQ(base::k24HourClock, GetHourType()); |
116 UserAddingScreen::Get()->Start(); | 111 UserAddingScreen::Get()->Start(); |
117 content::RunAllPendingInMessageLoop(); | 112 content::RunAllPendingInMessageLoop(); |
118 AddUser(account_id2_.GetUserEmail()); | 113 AddUser(kUser2); |
119 SetupUserProfile(account_id2_, false /* Use_24_hour_clock. */); | 114 SetupUserProfile(kUser2, false /* Use_24_hour_clock. */); |
120 CreateDefaultView(); | 115 CreateDefaultView(); |
121 EXPECT_EQ(base::k12HourClock, GetHourType()); | 116 EXPECT_EQ(base::k12HourClock, GetHourType()); |
122 user_manager::UserManager::Get()->SwitchActiveUser(account_id1_); | 117 user_manager::UserManager::Get()->SwitchActiveUser(kUser1); |
123 CreateDefaultView(); | 118 CreateDefaultView(); |
124 EXPECT_EQ(base::k24HourClock, GetHourType()); | 119 EXPECT_EQ(base::k24HourClock, GetHourType()); |
125 } | 120 } |
126 | 121 |
127 // Makes sure that no notifications are shown when rotating the | 122 // Makes sure that no notifications are shown when rotating the |
128 // display on display settings URLs. | 123 // display on display settings URLs. |
129 IN_PROC_BROWSER_TEST_F(DisplayNotificationsTest, | 124 IN_PROC_BROWSER_TEST_F(DisplayNotificationsTest, |
130 TestDisplayOrientationChangeNotification) { | 125 TestDisplayOrientationChangeNotification) { |
131 // Open the display settings page. | 126 // Open the display settings page. |
132 ui_test_utils::NavigateToURL(browser(), | 127 ui_test_utils::NavigateToURL(browser(), |
(...skipping 19 matching lines...) Expand all Loading... |
152 | 147 |
153 UpdateDisplay("400x400"); | 148 UpdateDisplay("400x400"); |
154 | 149 |
155 ui_test_utils::NavigateToURL(browser(), GURL("chrome://version")); | 150 ui_test_utils::NavigateToURL(browser(), GURL("chrome://version")); |
156 UpdateDisplay("400x400/r"); | 151 UpdateDisplay("400x400/r"); |
157 // Ensure that there is a notification that is shown. | 152 // Ensure that there is a notification that is shown. |
158 EXPECT_FALSE(GetVisibleNotifications().empty()); | 153 EXPECT_FALSE(GetVisibleNotifications().empty()); |
159 } | 154 } |
160 | 155 |
161 } // namespace chromeos | 156 } // namespace chromeos |
OLD | NEW |