Chromium Code Reviews| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 "document.getElementsByName('email')[0].value = '$Email';" | 138 "document.getElementsByName('email')[0].value = '$Email';" |
| 138 "document.getElementsByName('password')[0].value = '$Password';" | 139 "document.getElementsByName('password')[0].value = '$Password';" |
| 139 "document.getElementById('submit-button').click();" | 140 "document.getElementById('submit-button').click();" |
| 140 "})();"; | 141 "})();"; |
| 141 ReplaceSubstringsAfterOffset(&js, 0, "$Email", user_email); | 142 ReplaceSubstringsAfterOffset(&js, 0, "$Email", user_email); |
| 142 ReplaceSubstringsAfterOffset(&js, 0, "$Password", password); | 143 ReplaceSubstringsAfterOffset(&js, 0, "$Password", password); |
| 143 ExecuteJsInGaiaAuthFrame(js); | 144 ExecuteJsInGaiaAuthFrame(js); |
| 144 } | 145 } |
| 145 }; | 146 }; |
| 146 | 147 |
| 148 class LoginManagerTest : public InProcessBrowserTest { | |
|
Nikita (slow)
2015/02/13 12:16:17
Please rename this class to something else since L
| |
| 149 protected: | |
| 150 void SetUpCommandLine(base::CommandLine* command_line) override { | |
| 151 command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests); | |
|
Nikita (slow)
2015/02/13 12:16:17
As discussed over IM you need both kForceLoginMana
afakhry
2015/02/13 16:59:49
I thought you said having kForceLoginManagerInTest
| |
| 152 } | |
| 153 }; | |
| 154 | |
| 155 // Used to make sure that the system tray is visible and within the screen | |
| 156 // bounds after login. | |
| 157 void TestSystemTrayIsVisible() { | |
| 158 ash::SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray(); | |
| 159 aura::Window* primary_win = ash::Shell::GetPrimaryRootWindow(); | |
| 160 EXPECT_TRUE(tray->visible()); | |
| 161 EXPECT_TRUE(primary_win->bounds().Contains(tray->GetBoundsInScreen())); | |
| 162 } | |
| 163 | |
| 147 // After a chrome crash, the session manager will restart chrome with | 164 // After a chrome crash, the session manager will restart chrome with |
| 148 // the -login-user flag indicating that the user is already logged in. | 165 // the -login-user flag indicating that the user is already logged in. |
| 149 // This profile should NOT be an OTR profile. | 166 // This profile should NOT be an OTR profile. |
| 150 IN_PROC_BROWSER_TEST_F(LoginUserTest, UserPassed) { | 167 IN_PROC_BROWSER_TEST_F(LoginUserTest, UserPassed) { |
| 151 Profile* profile = browser()->profile(); | 168 Profile* profile = browser()->profile(); |
| 152 std::string profile_base_path("hash"); | 169 std::string profile_base_path("hash"); |
| 153 profile_base_path.insert(0, chrome::kProfileDirPrefix); | 170 profile_base_path.insert(0, chrome::kProfileDirPrefix); |
| 154 EXPECT_EQ(profile_base_path, profile->GetPath().BaseName().value()); | 171 EXPECT_EQ(profile_base_path, profile->GetPath().BaseName().value()); |
| 155 EXPECT_FALSE(profile->IsOffTheRecord()); | 172 EXPECT_FALSE(profile->IsOffTheRecord()); |
| 173 | |
| 174 TestSystemTrayIsVisible(); | |
| 156 } | 175 } |
| 157 | 176 |
| 158 // Verifies the cursor is not hidden at startup when user is logged in. | 177 // Verifies the cursor is not hidden at startup when user is logged in. |
| 159 IN_PROC_BROWSER_TEST_F(LoginUserTest, CursorShown) { | 178 IN_PROC_BROWSER_TEST_F(LoginUserTest, CursorShown) { |
| 160 EXPECT_TRUE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); | 179 EXPECT_TRUE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); |
| 180 | |
| 181 TestSystemTrayIsVisible(); | |
| 161 } | 182 } |
| 162 | 183 |
| 163 // After a guest login, we should get the OTR default profile. | 184 // After a guest login, we should get the OTR default profile. |
| 164 IN_PROC_BROWSER_TEST_F(LoginGuestTest, GuestIsOTR) { | 185 IN_PROC_BROWSER_TEST_F(LoginGuestTest, GuestIsOTR) { |
| 165 Profile* profile = browser()->profile(); | 186 Profile* profile = browser()->profile(); |
| 166 EXPECT_TRUE(profile->IsOffTheRecord()); | 187 EXPECT_TRUE(profile->IsOffTheRecord()); |
| 167 // Ensure there's extension service for this profile. | 188 // Ensure there's extension service for this profile. |
| 168 EXPECT_TRUE(extensions::ExtensionSystem::Get(profile)->extension_service()); | 189 EXPECT_TRUE(extensions::ExtensionSystem::Get(profile)->extension_service()); |
| 190 | |
| 191 TestSystemTrayIsVisible(); | |
| 169 } | 192 } |
| 170 | 193 |
| 171 // Verifies the cursor is not hidden at startup when running guest session. | 194 // Verifies the cursor is not hidden at startup when running guest session. |
| 172 IN_PROC_BROWSER_TEST_F(LoginGuestTest, CursorShown) { | 195 IN_PROC_BROWSER_TEST_F(LoginGuestTest, CursorShown) { |
| 173 EXPECT_TRUE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); | 196 EXPECT_TRUE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); |
| 197 | |
| 198 TestSystemTrayIsVisible(); | |
| 174 } | 199 } |
| 175 | 200 |
| 176 // Verifies the cursor is hidden at startup on login screen. | 201 // Verifies the cursor is hidden at startup on login screen. |
| 177 IN_PROC_BROWSER_TEST_F(LoginCursorTest, CursorHidden) { | 202 IN_PROC_BROWSER_TEST_F(LoginCursorTest, CursorHidden) { |
| 178 // Login screen needs to be shown explicitly when running test. | 203 // Login screen needs to be shown explicitly when running test. |
| 179 chromeos::ShowLoginWizard(chromeos::WizardController::kLoginScreenName); | 204 chromeos::ShowLoginWizard(chromeos::WizardController::kLoginScreenName); |
| 180 | 205 |
| 181 // Cursor should be hidden at startup | 206 // Cursor should be hidden at startup |
| 182 EXPECT_FALSE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); | 207 EXPECT_FALSE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); |
| 183 | 208 |
| 184 // Cursor should be shown after cursor is moved. | 209 // Cursor should be shown after cursor is moved. |
| 185 EXPECT_TRUE(ui_test_utils::SendMouseMoveSync(gfx::Point())); | 210 EXPECT_TRUE(ui_test_utils::SendMouseMoveSync(gfx::Point())); |
| 186 EXPECT_TRUE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); | 211 EXPECT_TRUE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); |
| 187 | 212 |
| 188 base::MessageLoop::current()->DeleteSoon( | 213 base::MessageLoop::current()->DeleteSoon( |
| 189 FROM_HERE, chromeos::LoginDisplayHostImpl::default_host()); | 214 FROM_HERE, chromeos::LoginDisplayHostImpl::default_host()); |
| 215 | |
| 216 TestSystemTrayIsVisible(); | |
| 190 } | 217 } |
| 191 | 218 |
| 192 // Verifies that the webui for login comes up successfully. | 219 // Verifies that the webui for login comes up successfully. |
| 193 IN_PROC_BROWSER_TEST_F(LoginSigninTest, WebUIVisible) { | 220 IN_PROC_BROWSER_TEST_F(LoginSigninTest, WebUIVisible) { |
| 194 base::TimeDelta no_timeout; | 221 base::TimeDelta no_timeout; |
| 195 EXPECT_TRUE(tracing::WaitForWatchEvent(no_timeout)); | 222 EXPECT_TRUE(tracing::WaitForWatchEvent(no_timeout)); |
| 196 std::string json_events; | 223 std::string json_events; |
| 197 ASSERT_TRUE(tracing::EndTracing(&json_events)); | 224 ASSERT_TRUE(tracing::EndTracing(&json_events)); |
| 198 } | 225 } |
| 199 | 226 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 216 user_context.SetKey(chromeos::Key(kPassword)); | 243 user_context.SetKey(chromeos::Key(kPassword)); |
| 217 SetExpectedCredentials(user_context); | 244 SetExpectedCredentials(user_context); |
| 218 | 245 |
| 219 SubmitGaiaAuthOfflineForm(kTestUser, kPassword); | 246 SubmitGaiaAuthOfflineForm(kTestUser, kPassword); |
| 220 | 247 |
| 221 content::WindowedNotificationObserver( | 248 content::WindowedNotificationObserver( |
| 222 chrome::NOTIFICATION_SESSION_STARTED, | 249 chrome::NOTIFICATION_SESSION_STARTED, |
| 223 content::NotificationService::AllSources()).Wait(); | 250 content::NotificationService::AllSources()).Wait(); |
| 224 } | 251 } |
| 225 | 252 |
| 253 // Verifies that the system tray is visible for login manager. | |
| 254 IN_PROC_BROWSER_TEST_F(LoginManagerTest, SysTrayIsVisible) { | |
| 255 TestSystemTrayIsVisible(); | |
| 256 } | |
| 257 | |
| 226 } // namespace | 258 } // namespace |
| OLD | NEW |