Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: chrome/browser/chromeos/login/existing_user_controller_auto_login_unittest.cc

Issue 14306004: Put Kiosk App parameters into device settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/message_loop.h" 5 #include "base/message_loop.h"
6 #include "chrome/browser/chromeos/login/existing_user_controller.h" 6 #include "chrome/browser/chromeos/login/existing_user_controller.h"
7 #include "chrome/browser/chromeos/login/mock_login_display.h" 7 #include "chrome/browser/chromeos/login/mock_login_display.h"
8 #include "chrome/browser/chromeos/login/mock_login_display_host.h" 8 #include "chrome/browser/chromeos/login/mock_login_display_host.h"
9 #include "chrome/browser/chromeos/login/mock_login_utils.h" 9 #include "chrome/browser/chromeos/login/mock_login_utils.h"
10 #include "chrome/browser/chromeos/login/mock_user_manager.h"
11 #include "chrome/browser/chromeos/login/user_manager.h"
10 #include "chrome/browser/chromeos/settings/cros_settings.h" 12 #include "chrome/browser/chromeos/settings/cros_settings.h"
11 #include "chrome/browser/chromeos/settings/cros_settings_names.h" 13 #include "chrome/browser/chromeos/settings/cros_settings_names.h"
12 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" 14 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h"
13 #include "chrome/test/base/scoped_testing_local_state.h" 15 #include "chrome/test/base/scoped_testing_local_state.h"
14 #include "chrome/test/base/testing_browser_process.h" 16 #include "chrome/test/base/testing_browser_process.h"
15 #include "content/public/test/test_browser_thread.h" 17 #include "content/public/test/test_browser_thread.h"
16 #include "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
18 20
21 using testing::AnyNumber;
19 using testing::Return; 22 using testing::Return;
23 using testing::ReturnNull;
20 using testing::_; 24 using testing::_;
21 25
22 namespace chromeos { 26 namespace chromeos {
23 27
24 namespace { 28 namespace {
25 29
26 const char kAutoLoginUsername[] = "public_session_user@localhost"; 30 const char kAutoLoginUsername[] = "public_session_user@localhost";
27 // These values are only used to test the configuration. They don't 31 // These values are only used to test the configuration. They don't
28 // delay the test. 32 // delay the test.
29 const int kAutoLoginNoDelay = 0; 33 const int kAutoLoginNoDelay = 0;
30 const int kAutoLoginDelay1 = 60000; 34 const int kAutoLoginDelay1 = 60000;
31 const int kAutoLoginDelay2 = 180000; 35 const int kAutoLoginDelay2 = 180000;
32 36
33 } // namespace 37 } // namespace
34 38
35 class ExistingUserControllerAutoLoginTest : public ::testing::Test { 39 class ExistingUserControllerAutoLoginTest : public ::testing::Test {
36 protected: 40 protected:
37 ExistingUserControllerAutoLoginTest() 41 ExistingUserControllerAutoLoginTest()
38 : message_loop_(MessageLoop::TYPE_UI), 42 : message_loop_(MessageLoop::TYPE_UI),
39 ui_thread_(content::BrowserThread::UI, &message_loop_), 43 ui_thread_(content::BrowserThread::UI, &message_loop_),
40 local_state_(TestingBrowserProcess::GetGlobal()) { 44 local_state_(TestingBrowserProcess::GetGlobal()),
45 mock_user_manager_(new MockUserManager()),
46 scoped_user_manager_(mock_user_manager_) {
41 } 47 }
42 48
43 virtual void SetUp() { 49 virtual void SetUp() {
44 mock_login_display_host_.reset(new MockLoginDisplayHost); 50 mock_login_display_host_.reset(new MockLoginDisplayHost);
45 mock_login_display_ = new MockLoginDisplay(); 51 mock_login_display_ = new MockLoginDisplay();
46 mock_login_utils_ = new MockLoginUtils(); 52 mock_login_utils_ = new MockLoginUtils();
47 LoginUtils::Set(mock_login_utils_); 53 LoginUtils::Set(mock_login_utils_);
48 54
49 EXPECT_CALL(*mock_login_display_host_.get(), CreateLoginDisplay(_)) 55 EXPECT_CALL(*mock_login_display_host_.get(), CreateLoginDisplay(_))
50 .Times(1) 56 .Times(1)
51 .WillOnce(Return(mock_login_display_)); 57 .WillOnce(Return(mock_login_display_));
52 58
59 EXPECT_CALL(*mock_login_utils_, DelegateDeleted(_)).Times(AnyNumber());
60
61 EXPECT_CALL(*mock_user_manager_, Shutdown()).Times(AnyNumber());
62 EXPECT_CALL(*mock_user_manager_, FindUser(_))
63 .WillRepeatedly(ReturnNull());
64 EXPECT_CALL(*mock_user_manager_, FindUser(kAutoLoginUsername))
65 .WillRepeatedly(Return(
66 mock_user_manager_->CreatePublicAccountUser(kAutoLoginUsername)));
67
53 existing_user_controller_.reset( 68 existing_user_controller_.reset(
54 new ExistingUserController(mock_login_display_host_.get())); 69 new ExistingUserController(mock_login_display_host_.get()));
55 70
56 // Prevent settings changes from auto-starting the timer. 71 // Prevent settings changes from auto-starting the timer.
57 CrosSettings::Get()->RemoveSettingsObserver( 72 CrosSettings::Get()->RemoveSettingsObserver(
58 kAccountsPrefDeviceLocalAccountAutoLoginId, 73 kAccountsPrefDeviceLocalAccountAutoLoginId,
59 existing_user_controller()); 74 existing_user_controller());
60 CrosSettings::Get()->RemoveSettingsObserver( 75 CrosSettings::Get()->RemoveSettingsObserver(
61 kAccountsPrefDeviceLocalAccountAutoLoginDelay, 76 kAccountsPrefDeviceLocalAccountAutoLoginDelay,
62 existing_user_controller()); 77 existing_user_controller());
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 MockLoginDisplay* mock_login_display_; 133 MockLoginDisplay* mock_login_display_;
119 134
120 scoped_ptr<MockLoginDisplayHost> mock_login_display_host_; 135 scoped_ptr<MockLoginDisplayHost> mock_login_display_host_;
121 MessageLoop message_loop_; 136 MessageLoop message_loop_;
122 content::TestBrowserThread ui_thread_; 137 content::TestBrowserThread ui_thread_;
123 ScopedTestingLocalState local_state_; 138 ScopedTestingLocalState local_state_;
124 139
125 // Required by ExistingUserController: 140 // Required by ExistingUserController:
126 ScopedDeviceSettingsTestHelper device_settings_test_helper_; 141 ScopedDeviceSettingsTestHelper device_settings_test_helper_;
127 ScopedTestCrosSettings test_cros_settings_; 142 ScopedTestCrosSettings test_cros_settings_;
143 MockUserManager* mock_user_manager_;
144 ScopedUserManagerEnabler scoped_user_manager_;
128 145
129 // |existing_user_controller_| must be destroyed before 146 // |existing_user_controller_| must be destroyed before
130 // |device_settings_test_helper_|. 147 // |device_settings_test_helper_|.
131 scoped_ptr<ExistingUserController> existing_user_controller_; 148 scoped_ptr<ExistingUserController> existing_user_controller_;
132 }; 149 };
133 150
134 TEST_F(ExistingUserControllerAutoLoginTest, StartAutoLoginTimer) { 151 TEST_F(ExistingUserControllerAutoLoginTest, StartAutoLoginTimer) {
135 // Timer shouldn't start until signin screen is ready. 152 // Timer shouldn't start until signin screen is ready.
136 set_auto_login_username(kAutoLoginUsername); 153 set_auto_login_username(kAutoLoginUsername);
137 set_auto_login_delay(kAutoLoginDelay2); 154 set_auto_login_delay(kAutoLoginDelay2);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 ConfigureAutoLogin(); 260 ConfigureAutoLogin();
244 ASSERT_TRUE(auto_login_timer()); 261 ASSERT_TRUE(auto_login_timer());
245 EXPECT_FALSE(auto_login_timer()->IsRunning()); 262 EXPECT_FALSE(auto_login_timer()->IsRunning());
246 EXPECT_EQ(auto_login_timer()->GetCurrentDelay().InMilliseconds(), 263 EXPECT_EQ(auto_login_timer()->GetCurrentDelay().InMilliseconds(),
247 kAutoLoginDelay2); 264 kAutoLoginDelay2);
248 EXPECT_EQ(auto_login_username(), ""); 265 EXPECT_EQ(auto_login_username(), "");
249 EXPECT_EQ(auto_login_delay(), kAutoLoginDelay2); 266 EXPECT_EQ(auto_login_delay(), kAutoLoginDelay2);
250 } 267 }
251 268
252 } // namespace chromeos 269 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698