Update To 11.40.268.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 "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"
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     screenshot_testing_->IgnoreArea(areas::kClockArea);
38     screenshot_testing_->IgnoreArea(areas::kFirstUserpod);
39     screenshot_testing_->IgnoreArea(areas::kSecondUserpod);
40     AddMixin(screenshot_testing_);
41   }
42   virtual ~LoginUITest() {}
43
44  protected:
45   ScreenshotTestingMixin* screenshot_testing_;
46 };
47
48 IN_PROC_BROWSER_TEST_F(LoginUITest, PRE_LoginUIVisible) {
49   RegisterUser(kTestUser1);
50   RegisterUser(kTestUser2);
51   StartupUtils::MarkOobeCompleted();
52 }
53
54 // Verifies basic login UI properties.
55 IN_PROC_BROWSER_TEST_F(LoginUITest, LoginUIVisible) {
56   JSExpect("!!document.querySelector('#account-picker')");
57   JSExpect("!!document.querySelector('#pod-row')");
58   JSExpect(
59       "document.querySelectorAll('.pod:not(#user-pod-template)').length == 2");
60
61   JSExpect("document.querySelectorAll('.pod:not(#user-pod-template)')[0]"
62            ".user.emailAddress == '" + std::string(kTestUser1) + "'");
63   JSExpect("document.querySelectorAll('.pod:not(#user-pod-template)')[1]"
64            ".user.emailAddress == '" + std::string(kTestUser2) + "'");
65   screenshot_testing_->RunScreenshotTesting("LoginUITest-LoginUIVisible");
66 }
67
68 IN_PROC_BROWSER_TEST_F(LoginUITest, PRE_InterruptedAutoStartEnrollment) {
69   StartupUtils::MarkOobeCompleted();
70   PrefService* prefs = g_browser_process->local_state();
71   prefs->SetBoolean(prefs::kDeviceEnrollmentAutoStart, true);
72 }
73
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();
78 }
79
80 }  // namespace chromeos