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/shell.h" | 5 #include "ash/shell.h" |
| 6 #include "ash/system/tray/system_tray.h" |
6 #include "base/command_line.h" | 7 #include "base/command_line.h" |
7 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
8 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/chromeos/login/login_manager_test.h" | 10 #include "chrome/browser/chromeos/login/login_manager_test.h" |
10 #include "chrome/browser/chromeos/login/login_wizard.h" | 11 #include "chrome/browser/chromeos/login/login_wizard.h" |
11 #include "chrome/browser/chromeos/login/startup_utils.h" | 12 #include "chrome/browser/chromeos/login/startup_utils.h" |
12 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 13 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
13 #include "chrome/browser/chromeos/login/wizard_controller.h" | 14 #include "chrome/browser/chromeos/login/wizard_controller.h" |
14 #include "chrome/browser/chromeos/settings/cros_settings.h" | 15 #include "chrome/browser/chromeos/settings/cros_settings.h" |
15 #include "chrome/browser/profiles/profile_manager.h" | 16 #include "chrome/browser/profiles/profile_manager.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 "document.getElementsByName('email')[0].value = '$Email';" | 136 "document.getElementsByName('email')[0].value = '$Email';" |
136 "document.getElementsByName('password')[0].value = '$Password';" | 137 "document.getElementsByName('password')[0].value = '$Password';" |
137 "document.getElementById('submit-button').click();" | 138 "document.getElementById('submit-button').click();" |
138 "})();"; | 139 "})();"; |
139 ReplaceSubstringsAfterOffset(&js, 0, "$Email", user_email); | 140 ReplaceSubstringsAfterOffset(&js, 0, "$Email", user_email); |
140 ReplaceSubstringsAfterOffset(&js, 0, "$Password", password); | 141 ReplaceSubstringsAfterOffset(&js, 0, "$Password", password); |
141 ExecuteJsInGaiaAuthFrame(js); | 142 ExecuteJsInGaiaAuthFrame(js); |
142 } | 143 } |
143 }; | 144 }; |
144 | 145 |
| 146 // Used to make sure that the system tray is visible and within the screen |
| 147 // bounds after login. |
| 148 void TestSystemTrayIsVisible() { |
| 149 ash::SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray(); |
| 150 aura::Window* primary_win = ash::Shell::GetPrimaryRootWindow(); |
| 151 EXPECT_TRUE(tray->visible()); |
| 152 EXPECT_TRUE(primary_win->bounds().Contains(tray->GetBoundsInScreen())); |
| 153 } |
| 154 |
145 // After a chrome crash, the session manager will restart chrome with | 155 // After a chrome crash, the session manager will restart chrome with |
146 // the -login-user flag indicating that the user is already logged in. | 156 // the -login-user flag indicating that the user is already logged in. |
147 // This profile should NOT be an OTR profile. | 157 // This profile should NOT be an OTR profile. |
148 IN_PROC_BROWSER_TEST_F(LoginUserTest, UserPassed) { | 158 IN_PROC_BROWSER_TEST_F(LoginUserTest, UserPassed) { |
149 Profile* profile = browser()->profile(); | 159 Profile* profile = browser()->profile(); |
150 std::string profile_base_path("hash"); | 160 std::string profile_base_path("hash"); |
151 profile_base_path.insert(0, chrome::kProfileDirPrefix); | 161 profile_base_path.insert(0, chrome::kProfileDirPrefix); |
152 EXPECT_EQ(profile_base_path, profile->GetPath().BaseName().value()); | 162 EXPECT_EQ(profile_base_path, profile->GetPath().BaseName().value()); |
153 EXPECT_FALSE(profile->IsOffTheRecord()); | 163 EXPECT_FALSE(profile->IsOffTheRecord()); |
| 164 |
| 165 TestSystemTrayIsVisible(); |
154 } | 166 } |
155 | 167 |
156 // Verifies the cursor is not hidden at startup when user is logged in. | 168 // Verifies the cursor is not hidden at startup when user is logged in. |
157 IN_PROC_BROWSER_TEST_F(LoginUserTest, CursorShown) { | 169 IN_PROC_BROWSER_TEST_F(LoginUserTest, CursorShown) { |
158 EXPECT_TRUE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); | 170 EXPECT_TRUE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); |
| 171 |
| 172 TestSystemTrayIsVisible(); |
159 } | 173 } |
160 | 174 |
161 // After a guest login, we should get the OTR default profile. | 175 // After a guest login, we should get the OTR default profile. |
162 IN_PROC_BROWSER_TEST_F(LoginGuestTest, GuestIsOTR) { | 176 IN_PROC_BROWSER_TEST_F(LoginGuestTest, GuestIsOTR) { |
163 Profile* profile = browser()->profile(); | 177 Profile* profile = browser()->profile(); |
164 EXPECT_TRUE(profile->IsOffTheRecord()); | 178 EXPECT_TRUE(profile->IsOffTheRecord()); |
165 // Ensure there's extension service for this profile. | 179 // Ensure there's extension service for this profile. |
166 EXPECT_TRUE(extensions::ExtensionSystem::Get(profile)->extension_service()); | 180 EXPECT_TRUE(extensions::ExtensionSystem::Get(profile)->extension_service()); |
| 181 |
| 182 TestSystemTrayIsVisible(); |
167 } | 183 } |
168 | 184 |
169 // Verifies the cursor is not hidden at startup when running guest session. | 185 // Verifies the cursor is not hidden at startup when running guest session. |
170 IN_PROC_BROWSER_TEST_F(LoginGuestTest, CursorShown) { | 186 IN_PROC_BROWSER_TEST_F(LoginGuestTest, CursorShown) { |
171 EXPECT_TRUE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); | 187 EXPECT_TRUE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); |
| 188 |
| 189 TestSystemTrayIsVisible(); |
172 } | 190 } |
173 | 191 |
174 // Verifies the cursor is hidden at startup on login screen. | 192 // Verifies the cursor is hidden at startup on login screen. |
175 IN_PROC_BROWSER_TEST_F(LoginCursorTest, CursorHidden) { | 193 IN_PROC_BROWSER_TEST_F(LoginCursorTest, CursorHidden) { |
176 // Login screen needs to be shown explicitly when running test. | 194 // Login screen needs to be shown explicitly when running test. |
177 chromeos::ShowLoginWizard(chromeos::WizardController::kLoginScreenName); | 195 chromeos::ShowLoginWizard(chromeos::WizardController::kLoginScreenName); |
178 | 196 |
179 // Cursor should be hidden at startup | 197 // Cursor should be hidden at startup |
180 EXPECT_FALSE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); | 198 EXPECT_FALSE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); |
181 | 199 |
182 // Cursor should be shown after cursor is moved. | 200 // Cursor should be shown after cursor is moved. |
183 EXPECT_TRUE(ui_test_utils::SendMouseMoveSync(gfx::Point())); | 201 EXPECT_TRUE(ui_test_utils::SendMouseMoveSync(gfx::Point())); |
184 EXPECT_TRUE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); | 202 EXPECT_TRUE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); |
185 | 203 |
186 base::MessageLoop::current()->DeleteSoon( | 204 base::MessageLoop::current()->DeleteSoon( |
187 FROM_HERE, chromeos::LoginDisplayHostImpl::default_host()); | 205 FROM_HERE, chromeos::LoginDisplayHostImpl::default_host()); |
| 206 |
| 207 TestSystemTrayIsVisible(); |
188 } | 208 } |
189 | 209 |
190 // Verifies that the webui for login comes up successfully. | 210 // Verifies that the webui for login comes up successfully. |
191 IN_PROC_BROWSER_TEST_F(LoginSigninTest, WebUIVisible) { | 211 IN_PROC_BROWSER_TEST_F(LoginSigninTest, WebUIVisible) { |
192 base::TimeDelta no_timeout; | 212 base::TimeDelta no_timeout; |
193 EXPECT_TRUE(tracing::WaitForWatchEvent(no_timeout)); | 213 EXPECT_TRUE(tracing::WaitForWatchEvent(no_timeout)); |
194 std::string json_events; | 214 std::string json_events; |
195 ASSERT_TRUE(tracing::EndTracing(&json_events)); | 215 ASSERT_TRUE(tracing::EndTracing(&json_events)); |
196 } | 216 } |
197 | 217 |
(...skipping 14 matching lines...) Expand all Loading... |
212 | 232 |
213 chromeos::UserContext user_context(kTestUser); | 233 chromeos::UserContext user_context(kTestUser); |
214 user_context.SetKey(chromeos::Key(kPassword)); | 234 user_context.SetKey(chromeos::Key(kPassword)); |
215 SetExpectedCredentials(user_context); | 235 SetExpectedCredentials(user_context); |
216 | 236 |
217 SubmitGaiaAuthOfflineForm(kTestUser, kPassword); | 237 SubmitGaiaAuthOfflineForm(kTestUser, kPassword); |
218 | 238 |
219 content::WindowedNotificationObserver( | 239 content::WindowedNotificationObserver( |
220 chrome::NOTIFICATION_SESSION_STARTED, | 240 chrome::NOTIFICATION_SESSION_STARTED, |
221 content::NotificationService::AllSources()).Wait(); | 241 content::NotificationService::AllSources()).Wait(); |
| 242 |
| 243 TestSystemTrayIsVisible(); |
222 } | 244 } |
223 | 245 |
224 } // namespace | 246 } // namespace |
OLD | NEW |