OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/chrome_notification_types.h" | 5 #include "chrome/browser/chrome_notification_types.h" |
6 #include "chrome/browser/chromeos/login/test/oobe_base_test.h" | 6 #include "chrome/browser/chromeos/login/test/oobe_base_test.h" |
7 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" | 7 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" |
8 #include "chromeos/chromeos_switches.h" | 8 #include "chromeos/chromeos_switches.h" |
9 #include "content/public/test/browser_test_utils.h" | 9 #include "content/public/test/browser_test_utils.h" |
10 #include "content/public/test/test_utils.h" | 10 #include "content/public/test/test_utils.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 kFakeLSIDCookie); | 27 kFakeLSIDCookie); |
28 | 28 |
29 OobeBaseTest::SetUpOnMainThread(); | 29 OobeBaseTest::SetUpOnMainThread(); |
30 } | 30 } |
31 | 31 |
32 void SetUpCommandLine(base::CommandLine* command_line) override { | 32 void SetUpCommandLine(base::CommandLine* command_line) override { |
33 command_line->AppendSwitch(switches::kOobeSkipPostLogin); | 33 command_line->AppendSwitch(switches::kOobeSkipPostLogin); |
34 OobeBaseTest::SetUpCommandLine(command_line); | 34 OobeBaseTest::SetUpCommandLine(command_line); |
35 } | 35 } |
36 | 36 |
37 void WaitForGaiaPageLoaded() { | |
38 WaitForSigninScreen(); | |
39 | |
40 ASSERT_TRUE(content::ExecuteScript( | |
41 GetLoginUI()->GetWebContents(), | |
42 "$('gaia-signin').gaiaAuthHost_.addEventListener('ready'," | |
43 "function() {" | |
44 "window.domAutomationController.setAutomationId(0);" | |
45 "window.domAutomationController.send('GaiaReady');" | |
46 "});")); | |
47 | |
48 content::DOMMessageQueue message_queue; | |
49 std::string message; | |
50 ASSERT_TRUE(message_queue.WaitForMessage(&message)); | |
51 EXPECT_EQ("\"GaiaReady\"", message); | |
52 } | |
53 | |
54 private: | 37 private: |
55 DISALLOW_COPY_AND_ASSIGN(WebviewLoginTest); | 38 DISALLOW_COPY_AND_ASSIGN(WebviewLoginTest); |
56 }; | 39 }; |
57 | 40 |
58 IN_PROC_BROWSER_TEST_F(WebviewLoginTest, Basic) { | 41 IN_PROC_BROWSER_TEST_F(WebviewLoginTest, Basic) { |
59 WaitForGaiaPageLoaded(); | 42 WaitForGaiaPageLoad(); |
60 | 43 |
61 JsExpect("$('close-button-item').hidden"); | 44 JsExpect("$('close-button-item').hidden"); |
62 | 45 |
63 SetSignFormField("identifier", kFakeUserEmail); | 46 SetSignFormField("identifier", kFakeUserEmail); |
64 ExecuteJsInSigninFrame("document.getElementById('nextButton').click();"); | 47 ExecuteJsInSigninFrame("document.getElementById('nextButton').click();"); |
65 | 48 |
66 JsExpect("$('close-button-item').hidden"); | 49 JsExpect("$('close-button-item').hidden"); |
67 | 50 |
68 content::WindowedNotificationObserver session_start_waiter( | 51 content::WindowedNotificationObserver session_start_waiter( |
69 chrome::NOTIFICATION_SESSION_STARTED, | 52 chrome::NOTIFICATION_SESSION_STARTED, |
70 content::NotificationService::AllSources()); | 53 content::NotificationService::AllSources()); |
71 | 54 |
72 SetSignFormField("password", kFakeUserPassword); | 55 SetSignFormField("password", kFakeUserPassword); |
73 ExecuteJsInSigninFrame("document.getElementById('nextButton').click();"); | 56 ExecuteJsInSigninFrame("document.getElementById('nextButton').click();"); |
74 | 57 |
75 session_start_waiter.Wait(); | 58 session_start_waiter.Wait(); |
76 } | 59 } |
77 | 60 |
78 IN_PROC_BROWSER_TEST_F(WebviewLoginTest, BackButton) { | 61 IN_PROC_BROWSER_TEST_F(WebviewLoginTest, BackButton) { |
79 WaitForGaiaPageLoaded(); | 62 WaitForGaiaPageLoad(); |
80 | 63 |
81 // Start: no back button, first page. | 64 // Start: no back button, first page. |
82 JsExpect("$('back-button-item').hidden"); | 65 JsExpect("$('back-button-item').hidden"); |
83 JsExpect("$('signin-frame').src.indexOf('#identifier') != -1"); | 66 JsExpect("$('signin-frame').src.indexOf('#identifier') != -1"); |
84 | 67 |
85 // Next step: back button active, second page. | 68 // Next step: back button active, second page. |
86 SetSignFormField("identifier", kFakeUserEmail); | 69 SetSignFormField("identifier", kFakeUserEmail); |
87 ExecuteJsInSigninFrame("document.getElementById('nextButton').click();"); | 70 ExecuteJsInSigninFrame("document.getElementById('nextButton').click();"); |
88 JsExpect("!$('back-button-item').hidden"); | 71 JsExpect("!$('back-button-item').hidden"); |
89 JsExpect("$('signin-frame').src.indexOf('#challengepassword') != -1"); | 72 JsExpect("$('signin-frame').src.indexOf('#challengepassword') != -1"); |
(...skipping 13 matching lines...) Expand all Loading... |
103 chrome::NOTIFICATION_SESSION_STARTED, | 86 chrome::NOTIFICATION_SESSION_STARTED, |
104 content::NotificationService::AllSources()); | 87 content::NotificationService::AllSources()); |
105 | 88 |
106 SetSignFormField("password", kFakeUserPassword); | 89 SetSignFormField("password", kFakeUserPassword); |
107 ExecuteJsInSigninFrame("document.getElementById('nextButton').click();"); | 90 ExecuteJsInSigninFrame("document.getElementById('nextButton').click();"); |
108 | 91 |
109 session_start_waiter.Wait(); | 92 session_start_waiter.Wait(); |
110 } | 93 } |
111 | 94 |
112 } // namespace chromeos | 95 } // namespace chromeos |
OLD | NEW |