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 "ash/system/tray/system_tray.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/json/json_file_value_serializer.h" |
| 9 #include "base/path_service.h" |
8 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
9 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/chromeos/login/login_manager_test.h" | 12 #include "chrome/browser/chromeos/login/login_manager_test.h" |
11 #include "chrome/browser/chromeos/login/login_wizard.h" | 13 #include "chrome/browser/chromeos/login/login_wizard.h" |
12 #include "chrome/browser/chromeos/login/startup_utils.h" | 14 #include "chrome/browser/chromeos/login/startup_utils.h" |
13 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 15 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
14 #include "chrome/browser/chromeos/login/wizard_controller.h" | 16 #include "chrome/browser/chromeos/login/wizard_controller.h" |
15 #include "chrome/browser/chromeos/settings/cros_settings.h" | 17 #include "chrome/browser/chromeos/settings/cros_settings.h" |
16 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
17 #include "chrome/browser/profiles/profiles_state.h" | 19 #include "chrome/browser/profiles/profiles_state.h" |
18 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
19 #include "chrome/common/chrome_constants.h" | 21 #include "chrome/common/chrome_constants.h" |
| 22 #include "chrome/common/chrome_paths.h" |
20 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
| 24 #include "chrome/common/pref_names.h" |
21 #include "chrome/test/base/in_process_browser_test.h" | 25 #include "chrome/test/base/in_process_browser_test.h" |
22 #include "chrome/test/base/interactive_test_utils.h" | 26 #include "chrome/test/base/interactive_test_utils.h" |
23 #include "chrome/test/base/tracing.h" | 27 #include "chrome/test/base/tracing.h" |
24 #include "chrome/test/base/ui_test_utils.h" | 28 #include "chrome/test/base/ui_test_utils.h" |
25 #include "chromeos/chromeos_switches.h" | 29 #include "chromeos/chromeos_switches.h" |
26 #include "chromeos/login/user_names.h" | 30 #include "chromeos/login/user_names.h" |
27 #include "chromeos/settings/cros_settings_names.h" | 31 #include "chromeos/settings/cros_settings_names.h" |
28 #include "content/public/browser/render_frame_host.h" | 32 #include "content/public/browser/render_frame_host.h" |
29 #include "content/public/test/browser_test_utils.h" | 33 #include "content/public/test/browser_test_utils.h" |
30 #include "content/public/test/test_utils.h" | 34 #include "content/public/test/test_utils.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 "document.getElementsByName('email')[0].value = '$Email';" | 140 "document.getElementsByName('email')[0].value = '$Email';" |
137 "document.getElementsByName('password')[0].value = '$Password';" | 141 "document.getElementsByName('password')[0].value = '$Password';" |
138 "document.getElementById('submit-button').click();" | 142 "document.getElementById('submit-button').click();" |
139 "})();"; | 143 "})();"; |
140 ReplaceSubstringsAfterOffset(&js, 0, "$Email", user_email); | 144 ReplaceSubstringsAfterOffset(&js, 0, "$Email", user_email); |
141 ReplaceSubstringsAfterOffset(&js, 0, "$Password", password); | 145 ReplaceSubstringsAfterOffset(&js, 0, "$Password", password); |
142 ExecuteJsInGaiaAuthFrame(js); | 146 ExecuteJsInGaiaAuthFrame(js); |
143 } | 147 } |
144 }; | 148 }; |
145 | 149 |
| 150 class LoginOfflineTest : public LoginTest { |
| 151 public: |
| 152 LoginOfflineTest() {} |
| 153 ~LoginOfflineTest() override {} |
| 154 |
| 155 bool SetUpUserDataDirectory() override { |
| 156 base::FilePath user_data_dir; |
| 157 CHECK(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)); |
| 158 base::FilePath local_state_path = |
| 159 user_data_dir.Append(chrome::kLocalStateFilename); |
| 160 base::DictionaryValue local_state_dict; |
| 161 |
| 162 // Set webview disabled flag only when local state file does not exist. |
| 163 // Otherwise, we break PRE tests that leave state in it. |
| 164 if (!base::PathExists(local_state_path)) { |
| 165 // TODO(rsorokin): Fix offline test for webview signin. |
| 166 // http://crbug.com/475569 |
| 167 local_state_dict.SetBoolean(prefs::kWebviewSigninDisabled, true); |
| 168 |
| 169 CHECK(JSONFileValueSerializer(local_state_path) |
| 170 .Serialize(local_state_dict)); |
| 171 } |
| 172 |
| 173 return LoginTest::SetUpUserDataDirectory(); |
| 174 } |
| 175 }; |
| 176 |
146 // Used to make sure that the system tray is visible and within the screen | 177 // Used to make sure that the system tray is visible and within the screen |
147 // bounds after login. | 178 // bounds after login. |
148 void TestSystemTrayIsVisible() { | 179 void TestSystemTrayIsVisible() { |
149 ash::SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray(); | 180 ash::SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray(); |
150 aura::Window* primary_win = ash::Shell::GetPrimaryRootWindow(); | 181 aura::Window* primary_win = ash::Shell::GetPrimaryRootWindow(); |
151 EXPECT_TRUE(tray->visible()); | 182 EXPECT_TRUE(tray->visible()); |
152 EXPECT_TRUE(primary_win->bounds().Contains(tray->GetBoundsInScreen())); | 183 EXPECT_TRUE(primary_win->bounds().Contains(tray->GetBoundsInScreen())); |
153 } | 184 } |
154 | 185 |
155 // After a chrome crash, the session manager will restart chrome with | 186 // After a chrome crash, the session manager will restart chrome with |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 } | 239 } |
209 | 240 |
210 // Verifies that the webui for login comes up successfully. | 241 // Verifies that the webui for login comes up successfully. |
211 IN_PROC_BROWSER_TEST_F(LoginSigninTest, WebUIVisible) { | 242 IN_PROC_BROWSER_TEST_F(LoginSigninTest, WebUIVisible) { |
212 base::TimeDelta no_timeout; | 243 base::TimeDelta no_timeout; |
213 EXPECT_TRUE(tracing::WaitForWatchEvent(no_timeout)); | 244 EXPECT_TRUE(tracing::WaitForWatchEvent(no_timeout)); |
214 std::string json_events; | 245 std::string json_events; |
215 ASSERT_TRUE(tracing::EndTracing(&json_events)); | 246 ASSERT_TRUE(tracing::EndTracing(&json_events)); |
216 } | 247 } |
217 | 248 |
218 IN_PROC_BROWSER_TEST_F(LoginTest, PRE_GaiaAuthOffline) { | 249 IN_PROC_BROWSER_TEST_F(LoginOfflineTest, PRE_GaiaAuthOffline) { |
219 RegisterUser(kTestUser); | 250 RegisterUser(kTestUser); |
220 chromeos::StartupUtils::MarkOobeCompleted(); | 251 chromeos::StartupUtils::MarkOobeCompleted(); |
221 chromeos::CrosSettings::Get()->SetBoolean( | 252 chromeos::CrosSettings::Get()->SetBoolean( |
222 chromeos::kAccountsPrefShowUserNamesOnSignIn, false); | 253 chromeos::kAccountsPrefShowUserNamesOnSignIn, false); |
223 } | 254 } |
224 | 255 |
225 IN_PROC_BROWSER_TEST_F(LoginTest, GaiaAuthOffline) { | 256 IN_PROC_BROWSER_TEST_F(LoginOfflineTest, GaiaAuthOffline) { |
226 bool show_user; | 257 bool show_user; |
227 ASSERT_TRUE(chromeos::CrosSettings::Get()->GetBoolean( | 258 ASSERT_TRUE(chromeos::CrosSettings::Get()->GetBoolean( |
228 chromeos::kAccountsPrefShowUserNamesOnSignIn, &show_user)); | 259 chromeos::kAccountsPrefShowUserNamesOnSignIn, &show_user)); |
229 ASSERT_FALSE(show_user); | 260 ASSERT_FALSE(show_user); |
230 | 261 |
231 StartGaiaAuthOffline(); | 262 StartGaiaAuthOffline(); |
232 | 263 |
233 chromeos::UserContext user_context(kTestUser); | 264 chromeos::UserContext user_context(kTestUser); |
234 user_context.SetKey(chromeos::Key(kPassword)); | 265 user_context.SetKey(chromeos::Key(kPassword)); |
235 SetExpectedCredentials(user_context); | 266 SetExpectedCredentials(user_context); |
236 | 267 |
237 content::WindowedNotificationObserver session_start_waiter( | 268 content::WindowedNotificationObserver session_start_waiter( |
238 chrome::NOTIFICATION_SESSION_STARTED, | 269 chrome::NOTIFICATION_SESSION_STARTED, |
239 content::NotificationService::AllSources()); | 270 content::NotificationService::AllSources()); |
240 SubmitGaiaAuthOfflineForm(kTestUser, kPassword); | 271 SubmitGaiaAuthOfflineForm(kTestUser, kPassword); |
241 session_start_waiter.Wait(); | 272 session_start_waiter.Wait(); |
242 | 273 |
243 TestSystemTrayIsVisible(); | 274 TestSystemTrayIsVisible(); |
244 } | 275 } |
245 | 276 |
246 } // namespace | 277 } // namespace |
OLD | NEW |