| 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() |
| 25 : login_manager_test_helper_(new LoginManagerTestHelper(false)) { |
| 26 set_exit_when_last_browser_closes(false); |
| 27 } |
| 28 |
| 24 virtual ~LoginUITest() {} | 29 virtual ~LoginUITest() {} |
| 30 |
| 31 virtual void SetUpOnMainThread() OVERRIDE { |
| 32 login_manager_test_helper_->SetUp(); |
| 33 } |
| 34 |
| 35 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 36 login_manager_test_helper_->SetUpCommandLine(command_line); |
| 37 } |
| 38 |
| 39 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 40 login_manager_test_helper_->SetUpLoginUtils(); |
| 41 } |
| 42 |
| 43 virtual void CleanUpOnMainThread() OVERRIDE { |
| 44 login_manager_test_helper_->CleanUp(); |
| 45 } |
| 46 |
| 47 protected: |
| 48 scoped_ptr<LoginManagerTestHelper> login_manager_test_helper_; |
| 25 }; | 49 }; |
| 26 | 50 |
| 27 IN_PROC_BROWSER_TEST_F(LoginUITest, PRE_LoginUIVisible) { | 51 IN_PROC_BROWSER_TEST_F(LoginUITest, PRE_LoginUIVisible) { |
| 28 RegisterUser(kTestUser1); | 52 login_manager_test_helper_->RegisterUser(kTestUser1); |
| 29 RegisterUser(kTestUser2); | 53 login_manager_test_helper_->RegisterUser(kTestUser2); |
| 30 StartupUtils::MarkOobeCompleted(); | 54 StartupUtils::MarkOobeCompleted(); |
| 31 } | 55 } |
| 32 | 56 |
| 33 // Verifies basic login UI properties. | 57 // Verifies basic login UI properties. |
| 34 IN_PROC_BROWSER_TEST_F(LoginUITest, LoginUIVisible) { | 58 IN_PROC_BROWSER_TEST_F(LoginUITest, LoginUIVisible) { |
| 35 JSExpect("!!document.querySelector('#account-picker')"); | 59 login_manager_test_helper_->JSExpect( |
| 36 JSExpect("!!document.querySelector('#pod-row')"); | 60 "!!document.querySelector('#account-picker')"); |
| 37 JSExpect( | 61 login_manager_test_helper_->JSExpect( |
| 62 "!!document.querySelector('#pod-row')"); |
| 63 login_manager_test_helper_->JSExpect( |
| 38 "document.querySelectorAll('.pod:not(#user-pod-template)').length == 2"); | 64 "document.querySelectorAll('.pod:not(#user-pod-template)').length == 2"); |
| 39 | 65 |
| 40 JSExpect("document.querySelectorAll('.pod:not(#user-pod-template)')[0]" | 66 login_manager_test_helper_->JSExpect( |
| 41 ".user.emailAddress == '" + std::string(kTestUser1) + "'"); | 67 "document.querySelectorAll('.pod:not(#user-pod-template)')[0]" |
| 42 JSExpect("document.querySelectorAll('.pod:not(#user-pod-template)')[1]" | 68 ".user.emailAddress == '" + std::string(kTestUser1) + "'"); |
| 43 ".user.emailAddress == '" + std::string(kTestUser2) + "'"); | 69 login_manager_test_helper_->JSExpect( |
| 70 "document.querySelectorAll('.pod:not(#user-pod-template)')[1]" |
| 71 ".user.emailAddress == '" + std::string(kTestUser2) + "'"); |
| 44 } | 72 } |
| 45 | 73 |
| 46 IN_PROC_BROWSER_TEST_F(LoginUITest, PRE_InterruptedAutoStartEnrollment) { | 74 IN_PROC_BROWSER_TEST_F(LoginUITest, PRE_InterruptedAutoStartEnrollment) { |
| 47 StartupUtils::MarkOobeCompleted(); | 75 StartupUtils::MarkOobeCompleted(); |
| 48 | 76 |
| 49 PrefService* prefs = g_browser_process->local_state(); | 77 PrefService* prefs = g_browser_process->local_state(); |
| 50 prefs->SetBoolean(prefs::kDeviceEnrollmentAutoStart, true); | 78 prefs->SetBoolean(prefs::kDeviceEnrollmentAutoStart, true); |
| 51 } | 79 } |
| 52 | 80 |
| 53 // Tests that the default first screen is the network screen after OOBE | 81 // Tests that the default first screen is the network screen after OOBE |
| 54 // when auto enrollment is enabled and device is not yet enrolled. | 82 // when auto enrollment is enabled and device is not yet enrolled. |
| 55 IN_PROC_BROWSER_TEST_F(LoginUITest, InterruptedAutoStartEnrollment) { | 83 IN_PROC_BROWSER_TEST_F(LoginUITest, InterruptedAutoStartEnrollment) { |
| 56 OobeScreenWaiter(OobeDisplay::SCREEN_OOBE_NETWORK).Wait(); | 84 OobeScreenWaiter(OobeDisplay::SCREEN_OOBE_NETWORK).Wait(); |
| 57 } | 85 } |
| 58 | 86 |
| 59 } // namespace chromeos | 87 } // namespace chromeos |
| OLD | NEW |