Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / login / login_ui_browsertest.cc
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.
4
5 #include "base/command_line.h"
6 #include "base/prefs/pref_service.h"
7 #include "base/timer/timer.h"
8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/chromeos/login/login_manager_test.h"
11 #include "chrome/browser/chromeos/login/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"
22
23 namespace chromeos {
24
25 namespace {
26
27 const char kTestUser1[] = "test-user1@gmail.com";
28 const char kTestUser2[] = "test-user2@gmail.com";
29
30 }
31
32 class LoginUITest : public chromeos::LoginManagerTest {
33  public:
34   bool enable_test_screenshots_;
35   LoginUITest() : LoginManagerTest(false) {
36     screenshot_testing_ = new ScreenshotTestingMixin;
37     AddMixin(screenshot_testing_);
38   }
39   virtual ~LoginUITest() {}
40
41  protected:
42   ScreenshotTestingMixin* screenshot_testing_;
43 };
44
45 IN_PROC_BROWSER_TEST_F(LoginUITest, PRE_LoginUIVisible) {
46   RegisterUser(kTestUser1);
47   RegisterUser(kTestUser2);
48   StartupUtils::MarkOobeCompleted();
49 }
50
51 // Verifies basic login UI properties.
52 IN_PROC_BROWSER_TEST_F(LoginUITest, LoginUIVisible) {
53   JSExpect("!!document.querySelector('#account-picker')");
54   JSExpect("!!document.querySelector('#pod-row')");
55   JSExpect(
56       "document.querySelectorAll('.pod:not(#user-pod-template)').length == 2");
57
58   JSExpect("document.querySelectorAll('.pod:not(#user-pod-template)')[0]"
59            ".user.emailAddress == '" + std::string(kTestUser1) + "'");
60   JSExpect("document.querySelectorAll('.pod:not(#user-pod-template)')[1]"
61            ".user.emailAddress == '" + std::string(kTestUser2) + "'");
62   screenshot_testing_->RunScreenshotTesting("LoginUITest-LoginUIVisible");
63 }
64
65 IN_PROC_BROWSER_TEST_F(LoginUITest, PRE_InterruptedAutoStartEnrollment) {
66   StartupUtils::MarkOobeCompleted();
67   PrefService* prefs = g_browser_process->local_state();
68   prefs->SetBoolean(prefs::kDeviceEnrollmentAutoStart, true);
69 }
70
71 // Tests that the default first screen is the network screen after OOBE
72 // when auto enrollment is enabled and device is not yet enrolled.
73 IN_PROC_BROWSER_TEST_F(LoginUITest, InterruptedAutoStartEnrollment) {
74   OobeScreenWaiter(OobeDisplay::SCREEN_OOBE_NETWORK).Wait();
75 }
76
77 }  // namespace chromeos