Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(521)

Side by Side Diff: chrome/browser/chromeos/login/webview_login_browsertest.cc

Issue 1079083002: [cros New-GAIA] Webview login and new GAIA endpoint enabled by default (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix saml test Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 11
12 namespace chromeos { 12 namespace chromeos {
13 namespace {
14 const char kFakeUserEmail[] = "fake-email@gmail.com";
15 const char kFakeUserPassword[] = "fake-password";
16 const char kFakeSIDCookie[] = "fake-SID-cookie";
17 const char kFakeLSIDCookie[] = "fake-LSID-cookie";
18 }
19 13
20 class WebviewLoginTest : public OobeBaseTest { 14 class WebviewLoginTest : public OobeBaseTest {
21 public: 15 public:
22 WebviewLoginTest() { use_webview_ = true; } 16 WebviewLoginTest() { set_use_webview(true); }
23 ~WebviewLoginTest() override {} 17 ~WebviewLoginTest() override {}
24 18
25 void SetUpOnMainThread() override {
26 fake_gaia_->SetFakeMergeSessionParams(kFakeUserEmail, kFakeSIDCookie,
27 kFakeLSIDCookie);
28
29 OobeBaseTest::SetUpOnMainThread();
30 }
31
32 void SetUpCommandLine(base::CommandLine* command_line) override { 19 void SetUpCommandLine(base::CommandLine* command_line) override {
33 command_line->AppendSwitch(switches::kOobeSkipPostLogin); 20 command_line->AppendSwitch(switches::kOobeSkipPostLogin);
34 OobeBaseTest::SetUpCommandLine(command_line); 21 OobeBaseTest::SetUpCommandLine(command_line);
35 } 22 }
36 23
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: 24 private:
55 DISALLOW_COPY_AND_ASSIGN(WebviewLoginTest); 25 DISALLOW_COPY_AND_ASSIGN(WebviewLoginTest);
56 }; 26 };
57 27
58 IN_PROC_BROWSER_TEST_F(WebviewLoginTest, Basic) { 28 IN_PROC_BROWSER_TEST_F(WebviewLoginTest, Basic) {
59 WaitForGaiaPageLoaded(); 29 WaitForGaiaPageLoad();
60 30
61 JsExpect("$('close-button-item').hidden"); 31 JsExpect("$('close-button-item').hidden");
62 32
63 SetSignFormField("identifier", kFakeUserEmail); 33 SetSignFormField("identifier", OobeBaseTest::kFakeUserEmail);
64 ExecuteJsInSigninFrame("document.getElementById('nextButton').click();"); 34 ExecuteJsInSigninFrame("document.getElementById('nextButton').click();");
65 35
66 JsExpect("$('close-button-item').hidden"); 36 JsExpect("$('close-button-item').hidden");
67 37
68 content::WindowedNotificationObserver session_start_waiter( 38 content::WindowedNotificationObserver session_start_waiter(
69 chrome::NOTIFICATION_SESSION_STARTED, 39 chrome::NOTIFICATION_SESSION_STARTED,
70 content::NotificationService::AllSources()); 40 content::NotificationService::AllSources());
71 41
72 SetSignFormField("password", kFakeUserPassword); 42 SetSignFormField("password", OobeBaseTest::kFakeUserPassword);
73 ExecuteJsInSigninFrame("document.getElementById('nextButton').click();"); 43 ExecuteJsInSigninFrame("document.getElementById('nextButton').click();");
74 44
75 session_start_waiter.Wait(); 45 session_start_waiter.Wait();
76 } 46 }
77 47
78 IN_PROC_BROWSER_TEST_F(WebviewLoginTest, BackButton) { 48 IN_PROC_BROWSER_TEST_F(WebviewLoginTest, BackButton) {
79 WaitForGaiaPageLoaded(); 49 WaitForGaiaPageLoad();
80 50
81 // Start: no back button, first page. 51 // Start: no back button, first page.
82 JsExpect("$('back-button-item').hidden"); 52 JsExpect("$('back-button-item').hidden");
83 JsExpect("$('signin-frame').src.indexOf('#identifier') != -1"); 53 JsExpect("$('signin-frame').src.indexOf('#identifier') != -1");
84 54
85 // Next step: back button active, second page. 55 // Next step: back button active, second page.
86 SetSignFormField("identifier", kFakeUserEmail); 56 SetSignFormField("identifier", OobeBaseTest::kFakeUserEmail);
87 ExecuteJsInSigninFrame("document.getElementById('nextButton').click();"); 57 ExecuteJsInSigninFrame("document.getElementById('nextButton').click();");
88 JsExpect("!$('back-button-item').hidden"); 58 JsExpect("!$('back-button-item').hidden");
89 JsExpect("$('signin-frame').src.indexOf('#challengepassword') != -1"); 59 JsExpect("$('signin-frame').src.indexOf('#challengepassword') != -1");
90 60
91 // One step back: no back button, first page. 61 // One step back: no back button, first page.
92 ASSERT_TRUE(content::ExecuteScript(GetLoginUI()->GetWebContents(), 62 ASSERT_TRUE(content::ExecuteScript(GetLoginUI()->GetWebContents(),
93 "$('back-button-item').click();")); 63 "$('back-button-item').click();"));
94 JsExpect("$('back-button-item').hidden"); 64 JsExpect("$('back-button-item').hidden");
95 JsExpect("$('signin-frame').src.indexOf('#identifier') != -1"); 65 JsExpect("$('signin-frame').src.indexOf('#identifier') != -1");
96 66
97 // Next step (again): back button active, second page, user id remembered. 67 // Next step (again): back button active, second page, user id remembered.
98 ExecuteJsInSigninFrame("document.getElementById('nextButton').click();"); 68 ExecuteJsInSigninFrame("document.getElementById('nextButton').click();");
99 JsExpect("!$('back-button-item').hidden"); 69 JsExpect("!$('back-button-item').hidden");
100 JsExpect("$('signin-frame').src.indexOf('#challengepassword') != -1"); 70 JsExpect("$('signin-frame').src.indexOf('#challengepassword') != -1");
101 71
102 content::WindowedNotificationObserver session_start_waiter( 72 content::WindowedNotificationObserver session_start_waiter(
103 chrome::NOTIFICATION_SESSION_STARTED, 73 chrome::NOTIFICATION_SESSION_STARTED,
104 content::NotificationService::AllSources()); 74 content::NotificationService::AllSources());
105 75
106 SetSignFormField("password", kFakeUserPassword); 76 SetSignFormField("password", OobeBaseTest::kFakeUserPassword);
107 ExecuteJsInSigninFrame("document.getElementById('nextButton').click();"); 77 ExecuteJsInSigninFrame("document.getElementById('nextButton').click();");
108 78
109 session_start_waiter.Wait(); 79 session_start_waiter.Wait();
110 } 80 }
111 81
112 } // namespace chromeos 82 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/test/oobe_base_test.cc ('k') | chrome/browser/chromeos/login/wizard_controller_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698