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" | |
10 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
11 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
12 #include "chrome/browser/chromeos/login/login_manager_test.h" | 10 #include "chrome/browser/chromeos/login/login_manager_test.h" |
13 #include "chrome/browser/chromeos/login/login_wizard.h" | 11 #include "chrome/browser/chromeos/login/login_wizard.h" |
14 #include "chrome/browser/chromeos/login/startup_utils.h" | 12 #include "chrome/browser/chromeos/login/startup_utils.h" |
15 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 13 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
16 #include "chrome/browser/chromeos/login/wizard_controller.h" | 14 #include "chrome/browser/chromeos/login/wizard_controller.h" |
17 #include "chrome/browser/chromeos/settings/cros_settings.h" | 15 #include "chrome/browser/chromeos/settings/cros_settings.h" |
18 #include "chrome/browser/profiles/profile_manager.h" | 16 #include "chrome/browser/profiles/profile_manager.h" |
19 #include "chrome/browser/profiles/profiles_state.h" | 17 #include "chrome/browser/profiles/profiles_state.h" |
20 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
21 #include "chrome/common/chrome_constants.h" | 19 #include "chrome/common/chrome_constants.h" |
22 #include "chrome/common/chrome_paths.h" | |
23 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
24 #include "chrome/common/pref_names.h" | |
25 #include "chrome/test/base/in_process_browser_test.h" | 21 #include "chrome/test/base/in_process_browser_test.h" |
26 #include "chrome/test/base/interactive_test_utils.h" | 22 #include "chrome/test/base/interactive_test_utils.h" |
27 #include "chrome/test/base/tracing.h" | 23 #include "chrome/test/base/tracing.h" |
28 #include "chrome/test/base/ui_test_utils.h" | 24 #include "chrome/test/base/ui_test_utils.h" |
29 #include "chromeos/chromeos_switches.h" | 25 #include "chromeos/chromeos_switches.h" |
30 #include "chromeos/login/user_names.h" | 26 #include "chromeos/login/user_names.h" |
31 #include "chromeos/settings/cros_settings_names.h" | 27 #include "chromeos/settings/cros_settings_names.h" |
32 #include "content/public/browser/render_frame_host.h" | 28 #include "content/public/browser/render_frame_host.h" |
33 #include "content/public/test/browser_test_utils.h" | 29 #include "content/public/test/browser_test_utils.h" |
34 #include "content/public/test/test_utils.h" | 30 #include "content/public/test/test_utils.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 "document.getElementsByName('email')[0].value = '$Email';" | 136 "document.getElementsByName('email')[0].value = '$Email';" |
141 "document.getElementsByName('password')[0].value = '$Password';" | 137 "document.getElementsByName('password')[0].value = '$Password';" |
142 "document.getElementById('submit-button').click();" | 138 "document.getElementById('submit-button').click();" |
143 "})();"; | 139 "})();"; |
144 ReplaceSubstringsAfterOffset(&js, 0, "$Email", user_email); | 140 ReplaceSubstringsAfterOffset(&js, 0, "$Email", user_email); |
145 ReplaceSubstringsAfterOffset(&js, 0, "$Password", password); | 141 ReplaceSubstringsAfterOffset(&js, 0, "$Password", password); |
146 ExecuteJsInGaiaAuthFrame(js); | 142 ExecuteJsInGaiaAuthFrame(js); |
147 } | 143 } |
148 }; | 144 }; |
149 | 145 |
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 | |
177 // Used to make sure that the system tray is visible and within the screen | 146 // Used to make sure that the system tray is visible and within the screen |
178 // bounds after login. | 147 // bounds after login. |
179 void TestSystemTrayIsVisible() { | 148 void TestSystemTrayIsVisible() { |
180 ash::SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray(); | 149 ash::SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray(); |
181 aura::Window* primary_win = ash::Shell::GetPrimaryRootWindow(); | 150 aura::Window* primary_win = ash::Shell::GetPrimaryRootWindow(); |
182 EXPECT_TRUE(tray->visible()); | 151 EXPECT_TRUE(tray->visible()); |
183 EXPECT_TRUE(primary_win->bounds().Contains(tray->GetBoundsInScreen())); | 152 EXPECT_TRUE(primary_win->bounds().Contains(tray->GetBoundsInScreen())); |
184 } | 153 } |
185 | 154 |
186 // After a chrome crash, the session manager will restart chrome with | 155 // After a chrome crash, the session manager will restart chrome with |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 } | 208 } |
240 | 209 |
241 // Verifies that the webui for login comes up successfully. | 210 // Verifies that the webui for login comes up successfully. |
242 IN_PROC_BROWSER_TEST_F(LoginSigninTest, WebUIVisible) { | 211 IN_PROC_BROWSER_TEST_F(LoginSigninTest, WebUIVisible) { |
243 base::TimeDelta no_timeout; | 212 base::TimeDelta no_timeout; |
244 EXPECT_TRUE(tracing::WaitForWatchEvent(no_timeout)); | 213 EXPECT_TRUE(tracing::WaitForWatchEvent(no_timeout)); |
245 std::string json_events; | 214 std::string json_events; |
246 ASSERT_TRUE(tracing::EndTracing(&json_events)); | 215 ASSERT_TRUE(tracing::EndTracing(&json_events)); |
247 } | 216 } |
248 | 217 |
249 IN_PROC_BROWSER_TEST_F(LoginOfflineTest, PRE_GaiaAuthOffline) { | 218 IN_PROC_BROWSER_TEST_F(LoginTest, PRE_GaiaAuthOffline) { |
250 RegisterUser(kTestUser); | 219 RegisterUser(kTestUser); |
251 chromeos::StartupUtils::MarkOobeCompleted(); | 220 chromeos::StartupUtils::MarkOobeCompleted(); |
252 chromeos::CrosSettings::Get()->SetBoolean( | 221 chromeos::CrosSettings::Get()->SetBoolean( |
253 chromeos::kAccountsPrefShowUserNamesOnSignIn, false); | 222 chromeos::kAccountsPrefShowUserNamesOnSignIn, false); |
254 } | 223 } |
255 | 224 |
256 IN_PROC_BROWSER_TEST_F(LoginOfflineTest, GaiaAuthOffline) { | 225 IN_PROC_BROWSER_TEST_F(LoginTest, GaiaAuthOffline) { |
257 bool show_user; | 226 bool show_user; |
258 ASSERT_TRUE(chromeos::CrosSettings::Get()->GetBoolean( | 227 ASSERT_TRUE(chromeos::CrosSettings::Get()->GetBoolean( |
259 chromeos::kAccountsPrefShowUserNamesOnSignIn, &show_user)); | 228 chromeos::kAccountsPrefShowUserNamesOnSignIn, &show_user)); |
260 ASSERT_FALSE(show_user); | 229 ASSERT_FALSE(show_user); |
261 | 230 |
262 StartGaiaAuthOffline(); | 231 StartGaiaAuthOffline(); |
263 | 232 |
264 chromeos::UserContext user_context(kTestUser); | 233 chromeos::UserContext user_context(kTestUser); |
265 user_context.SetKey(chromeos::Key(kPassword)); | 234 user_context.SetKey(chromeos::Key(kPassword)); |
266 SetExpectedCredentials(user_context); | 235 SetExpectedCredentials(user_context); |
267 | 236 |
268 content::WindowedNotificationObserver session_start_waiter( | 237 content::WindowedNotificationObserver session_start_waiter( |
269 chrome::NOTIFICATION_SESSION_STARTED, | 238 chrome::NOTIFICATION_SESSION_STARTED, |
270 content::NotificationService::AllSources()); | 239 content::NotificationService::AllSources()); |
271 SubmitGaiaAuthOfflineForm(kTestUser, kPassword); | 240 SubmitGaiaAuthOfflineForm(kTestUser, kPassword); |
272 session_start_waiter.Wait(); | 241 session_start_waiter.Wait(); |
273 | 242 |
274 TestSystemTrayIsVisible(); | 243 TestSystemTrayIsVisible(); |
275 } | 244 } |
276 | 245 |
277 } // namespace | 246 } // namespace |
OLD | NEW |