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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "ash/common/shelf/wm_shelf.h" | 7 #include "ash/common/shelf/wm_shelf.h" |
| 8 #include "ash/common/system/tray/system_tray.h" | 8 #include "ash/common/system/tray/system_tray.h" |
| 9 #include "ash/common/wm_window.h" | 9 #include "ash/common/wm_window.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 278 // Sets username and password for the Active Directory login and submits it. | 278 // Sets username and password for the Active Directory login and submits it. |
| 279 void SubmitActiveDirectoryCredentials(const std::string& username, | 279 void SubmitActiveDirectoryCredentials(const std::string& username, |
| 280 const std::string& password) { | 280 const std::string& password) { |
| 281 js_checker().ExecuteAsync(JSElement(kAdUserInput) + ".value='" + username + | 281 js_checker().ExecuteAsync(JSElement(kAdUserInput) + ".value='" + username + |
| 282 "'"); | 282 "'"); |
| 283 js_checker().ExecuteAsync(JSElement(kAdPasswordInput) + ".value='" + | 283 js_checker().ExecuteAsync(JSElement(kAdPasswordInput) + ".value='" + |
| 284 password + "'"); | 284 password + "'"); |
| 285 js_checker().Evaluate(JSElement(kAdButton) + ".fire('tap')"); | 285 js_checker().Evaluate(JSElement(kAdButton) + ".fire('tap')"); |
| 286 } | 286 } |
| 287 | 287 |
| 288 void SetupActiveDirectoryJSNotifications() { | |
| 289 js_checker().Evaluate( | |
| 290 "var testInvalidateAd = login.GaiaSigninScreen.invalidateAd;" | |
| 291 "login.GaiaSigninScreen.invalidateAd = function(user, errorState) {" | |
| 292 " testInvalidateAd(user, errorState);" | |
| 293 " window.domAutomationController.setAutomationId(0);" | |
| 294 " window.domAutomationController.send('ShowAuthError');" | |
| 295 "}"); | |
| 296 } | |
| 297 void WaitForMessage(const std::string& expected_message) { | |
| 298 content::DOMMessageQueue message_queue; | |
|
xiyuan
2017/04/07 15:04:24
ditto
Roman Sorokin (ftl)
2017/04/10 16:09:00
Done.
| |
| 299 std::string message; | |
| 300 do { | |
| 301 ASSERT_TRUE(message_queue.WaitForMessage(&message)); | |
| 302 } while (message != expected_message); | |
| 303 } | |
| 304 | |
| 288 protected: | 305 protected: |
| 289 // Returns string representing element with id=|element_id| inside Active | 306 // Returns string representing element with id=|element_id| inside Active |
| 290 // Directory login element. | 307 // Directory login element. |
| 291 std::string JSElement(const std::string& element_id) { | 308 std::string JSElement(const std::string& element_id) { |
| 292 return "document.querySelector('#offline-ad-auth /deep/ #" + element_id + | 309 return "document.querySelector('#offline-ad-auth /deep/ #" + element_id + |
| 293 "')"; | 310 "')"; |
| 294 } | 311 } |
| 295 FakeAuthPolicyClient* fake_auth_policy_client_ = nullptr; | 312 FakeAuthPolicyClient* fake_auth_policy_client_ = nullptr; |
| 296 | 313 |
| 297 private: | 314 private: |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 427 // TestSystemTrayIsVisible(); | 444 // TestSystemTrayIsVisible(); |
| 428 } | 445 } |
| 429 | 446 |
| 430 // Marks as Active Directory enterprise device and OOBE as completed. | 447 // Marks as Active Directory enterprise device and OOBE as completed. |
| 431 IN_PROC_BROWSER_TEST_F(ActiveDirectoryLoginTest, PRE_LoginErrors) { | 448 IN_PROC_BROWSER_TEST_F(ActiveDirectoryLoginTest, PRE_LoginErrors) { |
| 432 MarkAsActiveDirectoryEnterprise(); | 449 MarkAsActiveDirectoryEnterprise(); |
| 433 } | 450 } |
| 434 | 451 |
| 435 // Test different UI errors for Active Directory login. | 452 // Test different UI errors for Active Directory login. |
| 436 IN_PROC_BROWSER_TEST_F(ActiveDirectoryLoginTest, LoginErrors) { | 453 IN_PROC_BROWSER_TEST_F(ActiveDirectoryLoginTest, LoginErrors) { |
| 454 SetupActiveDirectoryJSNotifications(); | |
| 437 TestLoginVisible(); | 455 TestLoginVisible(); |
| 438 TestDomainVisible(); | 456 TestDomainVisible(); |
| 439 | 457 |
| 440 SubmitActiveDirectoryCredentials("", ""); | 458 SubmitActiveDirectoryCredentials("", ""); |
| 441 TestUserError(); | 459 TestUserError(); |
| 442 TestDomainVisible(); | 460 TestDomainVisible(); |
| 443 | 461 |
| 444 SubmitActiveDirectoryCredentials(kTestActiveDirectoryUser, ""); | 462 SubmitActiveDirectoryCredentials(kTestActiveDirectoryUser, ""); |
| 445 TestPasswordError(); | 463 TestPasswordError(); |
| 446 TestDomainVisible(); | 464 TestDomainVisible(); |
| 447 | 465 |
| 448 fake_auth_policy_client_->set_auth_error(authpolicy::ERROR_BAD_USER_NAME); | |
| 449 SubmitActiveDirectoryCredentials(std::string(kTestActiveDirectoryUser) + "@", | 466 SubmitActiveDirectoryCredentials(std::string(kTestActiveDirectoryUser) + "@", |
| 450 kPassword); | 467 kPassword); |
| 451 TestUserError(); | 468 TestUserError(); |
| 452 TestDomainHidden(); | 469 TestDomainHidden(); |
| 453 | 470 |
| 471 fake_auth_policy_client_->set_auth_error(authpolicy::ERROR_BAD_USER_NAME); | |
| 472 SubmitActiveDirectoryCredentials( | |
| 473 std::string(kTestActiveDirectoryUser) + "@" + kTestRealm, kPassword); | |
| 474 WaitForMessage("\"ShowAuthError\""); | |
| 475 TestUserError(); | |
| 476 TestDomainVisible(); | |
| 477 | |
| 454 fake_auth_policy_client_->set_auth_error(authpolicy::ERROR_BAD_PASSWORD); | 478 fake_auth_policy_client_->set_auth_error(authpolicy::ERROR_BAD_PASSWORD); |
| 455 SubmitActiveDirectoryCredentials(kTestActiveDirectoryUser, kPassword); | 479 SubmitActiveDirectoryCredentials(kTestActiveDirectoryUser, kPassword); |
| 480 WaitForMessage("\"ShowAuthError\""); | |
| 456 TestPasswordError(); | 481 TestPasswordError(); |
| 457 TestDomainVisible(); | 482 TestDomainVisible(); |
| 458 } | 483 } |
| 459 | 484 |
| 460 } // namespace chromeos | 485 } // namespace chromeos |
| OLD | NEW |