Chromium Code Reviews| Index: chrome/browser/chromeos/login/webview_login_browsertest.cc |
| diff --git a/chrome/browser/chromeos/login/webview_login_browsertest.cc b/chrome/browser/chromeos/login/webview_login_browsertest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ce5e0e5d23928956b4f7ab0048dfb21b4b58ac6f |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/login/webview_login_browsertest.cc |
| @@ -0,0 +1,81 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/chrome_notification_types.h" |
| +#include "chrome/browser/chromeos/login/test/oobe_base_test.h" |
| +#include "chrome/browser/chromeos/login/ui/webui_login_display.h" |
| +#include "chromeos/chromeos_switches.h" |
| +#include "content/public/test/browser_test_utils.h" |
| +#include "content/public/test/test_utils.h" |
| + |
| +namespace chromeos { |
| +namespace { |
| +const char kFakeUserEmail[] = "fake-email@gmail.com"; |
| +const char kFakeUserPassword[] = "fake-password"; |
| +const char kFakeSIDCookie[] = "fake-SID-cookie"; |
| +const char kFakeLSIDCookie[] = "fake-LSID-cookie"; |
| +} |
| + |
| +class WebviewLoginTest : public OobeBaseTest { |
| + public: |
| + WebviewLoginTest() { use_webview_ = true; } |
| + ~WebviewLoginTest() override {} |
| + |
| + void SetUpOnMainThread() override { |
| + fake_gaia_->SetFakeMergeSessionParams(kFakeUserEmail, kFakeSIDCookie, |
| + kFakeLSIDCookie); |
| + |
| + OobeBaseTest::SetUpOnMainThread(); |
| + } |
| + |
| + void SetUpCommandLine(base::CommandLine* command_line) override { |
| + command_line->AppendSwitch(switches::kOobeSkipPostLogin); |
| + OobeBaseTest::SetUpCommandLine(command_line); |
| + } |
| + |
| + void WaitForGaiaPageLoaded() { |
| + WaitForSigninScreen(); |
| + |
| + ASSERT_TRUE(content::ExecuteScript( |
| + GetLoginUI()->GetWebContents(), |
| + "$('gaia-signin').gaiaAuthHost_.addEventListener('ready'," |
| + "function() {" |
| + "window.domAutomationController.setAutomationId(0);" |
| + "window.domAutomationController.send('GaiaReady');" |
| + "});")); |
|
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
|
| + |
| + GetLoginDisplay()->ShowSigninUI(std::string()); |
| + |
| + std::string message; |
| + 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.
|
| + ASSERT_TRUE(message_queue.WaitForMessage(&message)); |
| + EXPECT_EQ("\"GaiaReady\"", message); |
| + } |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(WebviewLoginTest); |
| +}; |
| + |
| +IN_PROC_BROWSER_TEST_F(WebviewLoginTest, Basic) { |
| + WaitForGaiaPageLoaded(); |
| + |
| + JsExpect("$('back-button-item').hidden"); |
| + JsExpect("$('close-button-item').hidden"); |
| + |
| + SetSignFormField("identifier", kFakeUserEmail); |
| + ExecuteJsInSigninFrame("document.getElementById('nextButton').click();"); |
| + |
| + JsExpect("!$('back-button-item').hidden"); |
| + JsExpect("$('close-button-item').hidden"); |
| + |
| + SetSignFormField("password", kFakeUserPassword); |
| + ExecuteJsInSigninFrame("document.getElementById('nextButton').click();"); |
| + |
| + 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.
|
| + chrome::NOTIFICATION_SESSION_STARTED, |
| + content::NotificationService::AllSources()); |
| + session_start_waiter.Wait(); |
| +} |
| + |
| +} // namespace chromeos |