1 // Copyright 2013 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 "base/command_line.h"
6 #include "base/prefs/pref_service.h"
7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/chromeos/login/login_manager_test.h"
10 #include "chrome/browser/chromeos/login/screenshot_testing/login_screen_areas.h"
11 #include "chrome/browser/chromeos/login/screenshot_testing/screenshot_testing_mixin.h"
12 #include "chrome/browser/chromeos/login/startup_utils.h"
13 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h"
14 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
15 #include "chrome/common/pref_names.h"
16 #include "content/public/browser/browser_thread.h"
17 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h"
19 #include "content/public/browser/notification_service.h"
20 #include "content/public/browser/notification_types.h"
21 #include "ui/compositor/compositor_switches.h"
27 const char kTestUser1
[] = "test-user1@gmail.com";
28 const char kTestUser2
[] = "test-user2@gmail.com";
32 class LoginUITest
: public chromeos::LoginManagerTest
{
34 LoginUITest() : LoginManagerTest(false) {
35 screenshot_testing_
= new ScreenshotTestingMixin
;
36 screenshot_testing_
->IgnoreArea(areas::kClockArea
);
37 screenshot_testing_
->IgnoreArea(areas::kFirstUserpod
);
38 screenshot_testing_
->IgnoreArea(areas::kSecondUserpod
);
39 AddMixin(screenshot_testing_
);
41 ~LoginUITest() override
{}
44 ScreenshotTestingMixin
* screenshot_testing_
;
47 IN_PROC_BROWSER_TEST_F(LoginUITest
, PRE_LoginUIVisible
) {
48 RegisterUser(kTestUser1
);
49 RegisterUser(kTestUser2
);
50 StartupUtils::MarkOobeCompleted();
53 // Verifies basic login UI properties.
54 IN_PROC_BROWSER_TEST_F(LoginUITest
, LoginUIVisible
) {
55 JSExpect("!!document.querySelector('#account-picker')");
56 JSExpect("!!document.querySelector('#pod-row')");
58 "document.querySelectorAll('.pod:not(#user-pod-template)').length == 2");
60 JSExpect("document.querySelectorAll('.pod:not(#user-pod-template)')[0]"
61 ".user.emailAddress == '" + std::string(kTestUser1
) + "'");
62 JSExpect("document.querySelectorAll('.pod:not(#user-pod-template)')[1]"
63 ".user.emailAddress == '" + std::string(kTestUser2
) + "'");
64 screenshot_testing_
->RunScreenshotTesting("LoginUITest-LoginUIVisible");
67 IN_PROC_BROWSER_TEST_F(LoginUITest
, PRE_InterruptedAutoStartEnrollment
) {
68 StartupUtils::MarkOobeCompleted();
69 PrefService
* prefs
= g_browser_process
->local_state();
70 prefs
->SetBoolean(prefs::kDeviceEnrollmentAutoStart
, true);
71 prefs
->SetBoolean(prefs::kDeviceEnrollmentCanExit
, false);
74 // Tests that the default first screen is the network screen after OOBE
75 // when auto enrollment is enabled and device is not yet enrolled.
76 IN_PROC_BROWSER_TEST_F(LoginUITest
, InterruptedAutoStartEnrollment
) {
77 OobeScreenWaiter(OobeDisplay::SCREEN_OOBE_NETWORK
).Wait();
80 IN_PROC_BROWSER_TEST_F(LoginUITest
, OobeNoExceptions
) {
81 JSExpect("cr.ErrorStore.getInstance().length == 0");
84 IN_PROC_BROWSER_TEST_F(LoginUITest
, PRE_LoginNoExceptions
) {
85 RegisterUser(kTestUser1
);
86 RegisterUser(kTestUser2
);
87 StartupUtils::MarkOobeCompleted();
90 IN_PROC_BROWSER_TEST_F(LoginUITest
, LoginNoExceptions
) {
91 OobeScreenWaiter(OobeDisplay::SCREEN_ACCOUNT_PICKER
).Wait();
92 JSExpect("cr.ErrorStore.getInstance().length == 0");
95 IN_PROC_BROWSER_TEST_F(LoginUITest
, OobeCatchException
) {
96 JSExpect("cr.ErrorStore.getInstance().length == 0");
97 js_checker().ExecuteAsync("aelrt('misprint')");
98 JSExpect("cr.ErrorStore.getInstance().length == 1");
99 js_checker().ExecuteAsync("consle.error('Some error')");
100 JSExpect("cr.ErrorStore.getInstance().length == 2");
103 } // namespace chromeos