ExtensionSyncService: listen for relevant changes instead of being explicitly called...
[chromium-blink-merge.git] / chrome / browser / chromeos / login / webview_login_browsertest.cc
blob520538ae22fd67889583d8c8513214cd0ed3cd7f
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.
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"
12 namespace chromeos {
14 class WebviewLoginTest : public OobeBaseTest {
15 public:
16 WebviewLoginTest() {}
17 ~WebviewLoginTest() override {}
19 void SetUpCommandLine(base::CommandLine* command_line) override {
20 command_line->AppendSwitch(switches::kOobeSkipPostLogin);
21 OobeBaseTest::SetUpCommandLine(command_line);
24 private:
25 DISALLOW_COPY_AND_ASSIGN(WebviewLoginTest);
28 IN_PROC_BROWSER_TEST_F(WebviewLoginTest, Basic) {
29 WaitForGaiaPageLoad();
31 JsExpect("$('close-button-item').hidden");
33 SetSignFormField("identifier", OobeBaseTest::kFakeUserEmail);
34 ExecuteJsInSigninFrame("document.getElementById('nextButton').click();");
36 JsExpect("$('close-button-item').hidden");
38 content::WindowedNotificationObserver session_start_waiter(
39 chrome::NOTIFICATION_SESSION_STARTED,
40 content::NotificationService::AllSources());
42 SetSignFormField("password", OobeBaseTest::kFakeUserPassword);
43 ExecuteJsInSigninFrame("document.getElementById('nextButton').click();");
45 session_start_waiter.Wait();
48 // Flaky: http://crbug.com/512648.
49 IN_PROC_BROWSER_TEST_F(WebviewLoginTest, DISABLED_BackButton) {
50 WaitForGaiaPageLoad();
52 // Start: no back button, first page.
53 JsExpect("$('back-button-item').hidden");
54 JsExpect("$('signin-frame').src.indexOf('#identifier') != -1");
56 // Next step: back button active, second page.
57 SetSignFormField("identifier", OobeBaseTest::kFakeUserEmail);
58 ExecuteJsInSigninFrame("document.getElementById('nextButton').click();");
59 JsExpect("!$('back-button-item').hidden");
60 JsExpect("$('signin-frame').src.indexOf('#challengepassword') != -1");
62 // One step back: no back button, first page.
63 ASSERT_TRUE(content::ExecuteScript(GetLoginUI()->GetWebContents(),
64 "$('back-button-item').click();"));
65 JsExpect("$('back-button-item').hidden");
66 JsExpect("$('signin-frame').src.indexOf('#identifier') != -1");
68 // Next step (again): back button active, second page, user id remembered.
69 ExecuteJsInSigninFrame("document.getElementById('nextButton').click();");
70 JsExpect("!$('back-button-item').hidden");
71 JsExpect("$('signin-frame').src.indexOf('#challengepassword') != -1");
73 content::WindowedNotificationObserver session_start_waiter(
74 chrome::NOTIFICATION_SESSION_STARTED,
75 content::NotificationService::AllSources());
77 SetSignFormField("password", OobeBaseTest::kFakeUserPassword);
78 ExecuteJsInSigninFrame("document.getElementById('nextButton').click();");
80 session_start_waiter.Wait();
83 IN_PROC_BROWSER_TEST_F(WebviewLoginTest, AllowGuest) {
84 WaitForGaiaPageLoad();
85 JsExpect("!$('guest-user-header-bar-item').hidden");
86 chromeos::CrosSettings::Get()->SetBoolean(kAccountsPrefAllowGuest, false);
87 JsExpect("$('guest-user-header-bar-item').hidden");
90 } // namespace chromeos