OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/prefs/pref_service.h" | 5 #include "base/prefs/pref_service.h" |
6 #include "chrome/browser/browser_process.h" | 6 #include "chrome/browser/browser_process.h" |
7 #include "chrome/browser/chromeos/login/login_manager_test.h" | 7 #include "chrome/browser/chromeos/login/login_manager_test_helper.h" |
8 #include "chrome/browser/chromeos/login/startup_utils.h" | 8 #include "chrome/browser/chromeos/login/startup_utils.h" |
9 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" | 9 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" |
10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| 11 #include "chrome/test/base/in_process_browser_test.h" |
11 | 12 |
12 namespace chromeos { | 13 namespace chromeos { |
13 | 14 |
14 namespace { | 15 namespace { |
15 | 16 |
16 const char kTestUser1[] = "test-user1@gmail.com"; | 17 const char kTestUser1[] = "test-user1@gmail.com"; |
17 const char kTestUser2[] = "test-user2@gmail.com"; | 18 const char kTestUser2[] = "test-user2@gmail.com"; |
18 | 19 |
19 } // anonymous namespace | 20 } // anonymous namespace |
20 | 21 |
21 class LoginUITest : public chromeos::LoginManagerTest { | 22 class LoginUITest : public InProcessBrowserTest { |
22 public: | 23 public: |
23 LoginUITest() : LoginManagerTest(false) {} | 24 LoginUITest() : login_manager_test_helper_(new LoginManagerTestHelper) { |
| 25 set_exit_when_last_browser_closes(false); |
| 26 } |
| 27 |
24 virtual ~LoginUITest() {} | 28 virtual ~LoginUITest() {} |
| 29 |
| 30 virtual void SetUpOnMainThread() OVERRIDE { |
| 31 login_manager_test_helper_->SetUp(); |
| 32 } |
| 33 |
| 34 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 35 login_manager_test_helper_->SetUpCommandLine(command_line); |
| 36 } |
| 37 |
| 38 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 39 login_manager_test_helper_->SetUpLoginUtils(false); |
| 40 } |
| 41 |
| 42 virtual void CleanUpOnMainThread() OVERRIDE { |
| 43 login_manager_test_helper_->CleanUp(); |
| 44 } |
| 45 |
| 46 protected: |
| 47 scoped_ptr<LoginManagerTestHelper> login_manager_test_helper_; |
25 }; | 48 }; |
26 | 49 |
27 IN_PROC_BROWSER_TEST_F(LoginUITest, PRE_LoginUIVisible) { | 50 IN_PROC_BROWSER_TEST_F(LoginUITest, PRE_LoginUIVisible) { |
28 RegisterUser(kTestUser1); | 51 login_manager_test_helper_->RegisterUser(kTestUser1); |
29 RegisterUser(kTestUser2); | 52 login_manager_test_helper_->RegisterUser(kTestUser2); |
30 StartupUtils::MarkOobeCompleted(); | 53 StartupUtils::MarkOobeCompleted(); |
31 } | 54 } |
32 | 55 |
33 // Verifies basic login UI properties. | 56 // Verifies basic login UI properties. |
34 IN_PROC_BROWSER_TEST_F(LoginUITest, LoginUIVisible) { | 57 IN_PROC_BROWSER_TEST_F(LoginUITest, LoginUIVisible) { |
35 JSExpect("!!document.querySelector('#account-picker')"); | 58 login_manager_test_helper_->JSExpect( |
36 JSExpect("!!document.querySelector('#pod-row')"); | 59 "!!document.querySelector('#account-picker')"); |
37 JSExpect( | 60 login_manager_test_helper_->JSExpect( |
| 61 "!!document.querySelector('#pod-row')"); |
| 62 login_manager_test_helper_->JSExpect( |
38 "document.querySelectorAll('.pod:not(#user-pod-template)').length == 2"); | 63 "document.querySelectorAll('.pod:not(#user-pod-template)').length == 2"); |
39 | 64 |
40 JSExpect("document.querySelectorAll('.pod:not(#user-pod-template)')[0]" | 65 login_manager_test_helper_->JSExpect( |
41 ".user.emailAddress == '" + std::string(kTestUser1) + "'"); | 66 "document.querySelectorAll('.pod:not(#user-pod-template)')[0]" |
42 JSExpect("document.querySelectorAll('.pod:not(#user-pod-template)')[1]" | 67 ".user.emailAddress == '" + std::string(kTestUser1) + "'"); |
43 ".user.emailAddress == '" + std::string(kTestUser2) + "'"); | 68 login_manager_test_helper_->JSExpect( |
| 69 "document.querySelectorAll('.pod:not(#user-pod-template)')[1]" |
| 70 ".user.emailAddress == '" + std::string(kTestUser2) + "'"); |
44 } | 71 } |
45 | 72 |
46 IN_PROC_BROWSER_TEST_F(LoginUITest, PRE_InterruptedAutoStartEnrollment) { | 73 IN_PROC_BROWSER_TEST_F(LoginUITest, PRE_InterruptedAutoStartEnrollment) { |
47 StartupUtils::MarkOobeCompleted(); | 74 StartupUtils::MarkOobeCompleted(); |
48 | 75 |
49 PrefService* prefs = g_browser_process->local_state(); | 76 PrefService* prefs = g_browser_process->local_state(); |
50 prefs->SetBoolean(prefs::kDeviceEnrollmentAutoStart, true); | 77 prefs->SetBoolean(prefs::kDeviceEnrollmentAutoStart, true); |
51 } | 78 } |
52 | 79 |
53 // Tests that the default first screen is the network screen after OOBE | 80 // Tests that the default first screen is the network screen after OOBE |
54 // when auto enrollment is enabled and device is not yet enrolled. | 81 // when auto enrollment is enabled and device is not yet enrolled. |
55 IN_PROC_BROWSER_TEST_F(LoginUITest, InterruptedAutoStartEnrollment) { | 82 IN_PROC_BROWSER_TEST_F(LoginUITest, InterruptedAutoStartEnrollment) { |
56 OobeScreenWaiter(OobeDisplay::SCREEN_OOBE_NETWORK).Wait(); | 83 OobeScreenWaiter(OobeDisplay::SCREEN_OOBE_NETWORK).Wait(); |
57 } | 84 } |
58 | 85 |
59 } // namespace chromeos | 86 } // namespace chromeos |
OLD | NEW |