| 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 |
| 298 void WaitForMessage(content::DOMMessageQueue* message_queue, |
| 299 const std::string& expected_message) { |
| 300 std::string message; |
| 301 do { |
| 302 ASSERT_TRUE(message_queue->WaitForMessage(&message)); |
| 303 } while (message != expected_message); |
| 304 } |
| 305 |
| 288 protected: | 306 protected: |
| 289 // Returns string representing element with id=|element_id| inside Active | 307 // Returns string representing element with id=|element_id| inside Active |
| 290 // Directory login element. | 308 // Directory login element. |
| 291 std::string JSElement(const std::string& element_id) { | 309 std::string JSElement(const std::string& element_id) { |
| 292 return "document.querySelector('#offline-ad-auth /deep/ #" + element_id + | 310 return "document.querySelector('#offline-ad-auth /deep/ #" + element_id + |
| 293 "')"; | 311 "')"; |
| 294 } | 312 } |
| 295 FakeAuthPolicyClient* fake_auth_policy_client_ = nullptr; | 313 FakeAuthPolicyClient* fake_auth_policy_client_ = nullptr; |
| 296 | 314 |
| 297 private: | 315 private: |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 // TestSystemTrayIsVisible(); | 445 // TestSystemTrayIsVisible(); |
| 428 } | 446 } |
| 429 | 447 |
| 430 // Marks as Active Directory enterprise device and OOBE as completed. | 448 // Marks as Active Directory enterprise device and OOBE as completed. |
| 431 IN_PROC_BROWSER_TEST_F(ActiveDirectoryLoginTest, PRE_LoginErrors) { | 449 IN_PROC_BROWSER_TEST_F(ActiveDirectoryLoginTest, PRE_LoginErrors) { |
| 432 MarkAsActiveDirectoryEnterprise(); | 450 MarkAsActiveDirectoryEnterprise(); |
| 433 } | 451 } |
| 434 | 452 |
| 435 // Test different UI errors for Active Directory login. | 453 // Test different UI errors for Active Directory login. |
| 436 IN_PROC_BROWSER_TEST_F(ActiveDirectoryLoginTest, LoginErrors) { | 454 IN_PROC_BROWSER_TEST_F(ActiveDirectoryLoginTest, LoginErrors) { |
| 455 SetupActiveDirectoryJSNotifications(); |
| 437 TestLoginVisible(); | 456 TestLoginVisible(); |
| 438 TestDomainVisible(); | 457 TestDomainVisible(); |
| 439 | 458 |
| 459 content::DOMMessageQueue message_queue; |
| 460 |
| 440 SubmitActiveDirectoryCredentials("", ""); | 461 SubmitActiveDirectoryCredentials("", ""); |
| 441 TestUserError(); | 462 TestUserError(); |
| 442 TestDomainVisible(); | 463 TestDomainVisible(); |
| 443 | 464 |
| 444 SubmitActiveDirectoryCredentials(kTestActiveDirectoryUser, ""); | 465 SubmitActiveDirectoryCredentials(kTestActiveDirectoryUser, ""); |
| 445 TestPasswordError(); | 466 TestPasswordError(); |
| 446 TestDomainVisible(); | 467 TestDomainVisible(); |
| 447 | 468 |
| 448 fake_auth_policy_client_->set_auth_error(authpolicy::ERROR_BAD_USER_NAME); | |
| 449 SubmitActiveDirectoryCredentials(std::string(kTestActiveDirectoryUser) + "@", | 469 SubmitActiveDirectoryCredentials(std::string(kTestActiveDirectoryUser) + "@", |
| 450 kPassword); | 470 kPassword); |
| 451 TestUserError(); | 471 TestUserError(); |
| 452 TestDomainHidden(); | 472 TestDomainHidden(); |
| 453 | 473 |
| 474 fake_auth_policy_client_->set_auth_error(authpolicy::ERROR_BAD_USER_NAME); |
| 475 SubmitActiveDirectoryCredentials( |
| 476 std::string(kTestActiveDirectoryUser) + "@" + kTestRealm, kPassword); |
| 477 WaitForMessage(&message_queue, "\"ShowAuthError\""); |
| 478 TestUserError(); |
| 479 TestDomainVisible(); |
| 480 |
| 454 fake_auth_policy_client_->set_auth_error(authpolicy::ERROR_BAD_PASSWORD); | 481 fake_auth_policy_client_->set_auth_error(authpolicy::ERROR_BAD_PASSWORD); |
| 455 SubmitActiveDirectoryCredentials(kTestActiveDirectoryUser, kPassword); | 482 SubmitActiveDirectoryCredentials(kTestActiveDirectoryUser, kPassword); |
| 483 WaitForMessage(&message_queue, "\"ShowAuthError\""); |
| 456 TestPasswordError(); | 484 TestPasswordError(); |
| 457 TestDomainVisible(); | 485 TestDomainVisible(); |
| 458 } | 486 } |
| 459 | 487 |
| 460 } // namespace chromeos | 488 } // namespace chromeos |
| OLD | NEW |