Chromium Code Reviews| Index: chrome/browser/chromeos/login/enterprise_enrollment_browsertest.cc |
| diff --git a/chrome/browser/chromeos/login/enterprise_enrollment_browsertest.cc b/chrome/browser/chromeos/login/enterprise_enrollment_browsertest.cc |
| index 7b602e29762fd6cf9e4778bb9954ccf38a0729d4..11d38bbceec3bc53c5aa845635e0263b55e9e0b1 100644 |
| --- a/chrome/browser/chromeos/login/enterprise_enrollment_browsertest.cc |
| +++ b/chrome/browser/chromeos/login/enterprise_enrollment_browsertest.cc |
| @@ -16,6 +16,7 @@ |
| #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h" |
| #include "chromeos/dbus/dbus_thread_manager.h" |
| #include "chromeos/dbus/upstart_client.h" |
| +#include "content/public/test/browser_test_utils.h" |
| #include "content/public/test/test_utils.h" |
| using testing::_; |
| @@ -155,6 +156,34 @@ class EnterpriseEnrollmentTest : public LoginManagerTest { |
| }); |
| } |
| + void SetupActiveDirectoryJSNotifications() { |
| + js_checker().Evaluate( |
| + "var testShowStep = login.OAuthEnrollmentScreen.showStep;" |
| + "login.OAuthEnrollmentScreen.showStep = function(step) {" |
| + " testShowStep(step);" |
| + " if (step == 'working') {" |
| + " window.domAutomationController.setAutomationId(0);" |
| + " window.domAutomationController.send('ShowSpinnerScreen');" |
| + " }" |
| + "}"); |
| + js_checker().Evaluate( |
| + "var testInvalidateAd = login.OAuthEnrollmentScreen.invalidateAd;" |
| + "login.OAuthEnrollmentScreen.invalidateAd = function(machineName, " |
| + "user, errorState) {" |
| + " testInvalidateAd(machineName, user, errorState);" |
| + " window.domAutomationController.setAutomationId(0);" |
| + " window.domAutomationController.send('ShowJoinDomainError');" |
| + "}"); |
| + } |
| + |
| + void WaitForMessage(const std::string& expected_message) { |
| + content::DOMMessageQueue message_queue; |
|
xiyuan
2017/04/07 15:04:24
This impl pattern would cause test flakes. This ha
Roman Sorokin (ftl)
2017/04/10 16:09:00
Done.
|
| + std::string message; |
| + do { |
| + ASSERT_TRUE(message_queue.WaitForMessage(&message)); |
| + } while (message != expected_message); |
| + } |
| + |
| // Fills out the UI with device attribute information and submits it. |
| void SubmitAttributePromptUpdate() { |
| // Fill out the attribute prompt info and submit it. |
| @@ -297,7 +326,9 @@ IN_PROC_BROWSER_TEST_F(EnterpriseEnrollmentTest, |
| ->GetUpstartClient() |
| ->StartAuthPolicyService(); |
| + SetupActiveDirectoryJSNotifications(); |
| SubmitActiveDirectoryCredentials("machine_name", kAdTestUser, "password"); |
| + WaitForMessage("\"ShowSpinnerScreen\""); |
| EXPECT_FALSE(IsStepDisplayed("ad-join")); |
| CompleteEnrollment(); |
| @@ -326,6 +357,7 @@ IN_PROC_BROWSER_TEST_F(EnterpriseEnrollmentTest, |
| // Checking error in case of empty password. Whether password is not empty |
| // being checked in the UI. Machine name length is checked after that in the |
| // authpolicyd. |
| + SetupActiveDirectoryJSNotifications(); |
| SubmitActiveDirectoryCredentials("too_long_machine_name", kAdTestUser, ""); |
| EXPECT_TRUE(IsStepDisplayed("ad-join")); |
| js_checker().ExpectFalse(std::string(kAdMachineNameInput) + ".isInvalid"); |
| @@ -335,6 +367,7 @@ IN_PROC_BROWSER_TEST_F(EnterpriseEnrollmentTest, |
| // Checking error in case of too long machine name. |
| SubmitActiveDirectoryCredentials("too_long_machine_name", kAdTestUser, |
| "password"); |
| + WaitForMessage("\"ShowJoinDomainError\""); |
| EXPECT_TRUE(IsStepDisplayed("ad-join")); |
| js_checker().ExpectTrue(std::string(kAdMachineNameInput) + ".isInvalid"); |
| js_checker().ExpectFalse(std::string(kAdUsernameInput) + ".isInvalid"); |
| @@ -342,6 +375,7 @@ IN_PROC_BROWSER_TEST_F(EnterpriseEnrollmentTest, |
| // Checking error in case of bad username (without realm). |
| SubmitActiveDirectoryCredentials("machine_name", "test_user", "password"); |
| + WaitForMessage("\"ShowJoinDomainError\""); |
| EXPECT_TRUE(IsStepDisplayed("ad-join")); |
| js_checker().ExpectFalse(std::string(kAdMachineNameInput) + ".isInvalid"); |
| js_checker().ExpectTrue(std::string(kAdUsernameInput) + ".isInvalid"); |