OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/chrome_notification_types.h" | |
6 #include "chrome/browser/chromeos/login/test/oobe_base_test.h" | |
7 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" | |
8 #include "chromeos/chromeos_switches.h" | |
9 #include "content/public/test/browser_test_utils.h" | |
10 #include "content/public/test/test_utils.h" | |
11 | |
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 | |
20 class WebviewLoginTest : public OobeBaseTest { | |
21 public: | |
22 WebviewLoginTest() { use_webview_ = true; } | |
23 ~WebviewLoginTest() override {} | |
24 | |
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 { | |
33 command_line->AppendSwitch(switches::kOobeSkipPostLogin); | |
34 OobeBaseTest::SetUpCommandLine(command_line); | |
35 } | |
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 "});")); | |
xiyuan
2015/04/07 16:04:59
nit: indent properly, i.e. two more spaces on "fun
Dmitry Polukhin
2015/04/08 01:14:02
Done. It was 'git cl format' and I didn't notice i
| |
47 | |
48 GetLoginDisplay()->ShowSigninUI(std::string()); | |
49 | |
50 std::string message; | |
51 content::DOMMessageQueue message_queue; | |
xiyuan
2015/04/07 16:04:59
nit: We might want to move this before ShowSigninU
Dmitry Polukhin
2015/04/08 01:14:02
Done.
| |
52 ASSERT_TRUE(message_queue.WaitForMessage(&message)); | |
53 EXPECT_EQ("\"GaiaReady\"", message); | |
54 } | |
55 | |
56 private: | |
57 DISALLOW_COPY_AND_ASSIGN(WebviewLoginTest); | |
58 }; | |
59 | |
60 IN_PROC_BROWSER_TEST_F(WebviewLoginTest, Basic) { | |
61 WaitForGaiaPageLoaded(); | |
62 | |
63 JsExpect("$('back-button-item').hidden"); | |
64 JsExpect("$('close-button-item').hidden"); | |
65 | |
66 SetSignFormField("identifier", kFakeUserEmail); | |
67 ExecuteJsInSigninFrame("document.getElementById('nextButton').click();"); | |
68 | |
69 JsExpect("!$('back-button-item').hidden"); | |
70 JsExpect("$('close-button-item').hidden"); | |
71 | |
72 SetSignFormField("password", kFakeUserPassword); | |
73 ExecuteJsInSigninFrame("document.getElementById('nextButton').click();"); | |
74 | |
75 content::WindowedNotificationObserver session_start_waiter( | |
xiyuan
2015/04/07 16:04:59
nit: Move this before ExecuteJsInSigninFrame at li
Dmitry Polukhin
2015/04/08 01:14:02
Done.
| |
76 chrome::NOTIFICATION_SESSION_STARTED, | |
77 content::NotificationService::AllSources()); | |
78 session_start_waiter.Wait(); | |
79 } | |
80 | |
81 } // namespace chromeos | |
OLD | NEW |