OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/login/screen_locker.h" | 5 #include "chrome/browser/chromeos/login/screen_locker.h" |
6 | 6 |
| 7 #include "ash/session_state_delegate.h" |
| 8 #include "ash/shell.h" |
7 #include "ash/wm/window_state.h" | 9 #include "ash/wm/window_state.h" |
8 #include "base/command_line.h" | 10 #include "base/command_line.h" |
9 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
11 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
12 #include "chrome/browser/chromeos/login/mock_authenticator.h" | 14 #include "chrome/browser/chromeos/login/mock_authenticator.h" |
13 #include "chrome/browser/chromeos/login/screen_locker_tester.h" | 15 #include "chrome/browser/chromeos/login/screen_locker_tester.h" |
14 #include "chrome/browser/chromeos/login/user_manager.h" | 16 #include "chrome/browser/chromeos/login/user_manager.h" |
15 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
16 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 135 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
134 command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); | 136 command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); |
135 } | 137 } |
136 | 138 |
137 scoped_ptr<ui::ScopedAnimationDurationScaleMode> zero_duration_mode_; | 139 scoped_ptr<ui::ScopedAnimationDurationScaleMode> zero_duration_mode_; |
138 | 140 |
139 DISALLOW_COPY_AND_ASSIGN(ScreenLockerTest); | 141 DISALLOW_COPY_AND_ASSIGN(ScreenLockerTest); |
140 }; | 142 }; |
141 | 143 |
142 IN_PROC_BROWSER_TEST_F(ScreenLockerTest, TestBasic) { | 144 IN_PROC_BROWSER_TEST_F(ScreenLockerTest, TestBasic) { |
| 145 EXPECT_EQ(ash::SessionStateDelegate::STATE_SESSION, |
| 146 ash::Shell::GetInstance()->session_state_delegate()-> |
| 147 GetSessionState()); |
143 ScreenLocker::Show(); | 148 ScreenLocker::Show(); |
| 149 |
144 scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester()); | 150 scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester()); |
145 tester->EmulateWindowManagerReady(); | 151 tester->EmulateWindowManagerReady(); |
146 content::WindowedNotificationObserver lock_state_observer( | 152 content::WindowedNotificationObserver lock_state_observer( |
147 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, | 153 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, |
148 content::NotificationService::AllSources()); | 154 content::NotificationService::AllSources()); |
149 if (!tester->IsLocked()) | 155 if (!tester->IsLocked()) |
150 lock_state_observer.Wait(); | 156 lock_state_observer.Wait(); |
151 | 157 |
| 158 EXPECT_EQ(ash::SessionStateDelegate::STATE_LOCK, |
| 159 ash::Shell::GetInstance()->session_state_delegate()-> |
| 160 GetSessionState()); |
| 161 |
152 // Test to make sure that the widget is actually appearing and is of | 162 // Test to make sure that the widget is actually appearing and is of |
153 // reasonable size, preventing a regression of | 163 // reasonable size, preventing a regression of |
154 // http://code.google.com/p/chromium-os/issues/detail?id=5987 | 164 // http://code.google.com/p/chromium-os/issues/detail?id=5987 |
155 gfx::Rect lock_bounds = tester->GetChildWidget()->GetWindowBoundsInScreen(); | 165 gfx::Rect lock_bounds = tester->GetChildWidget()->GetWindowBoundsInScreen(); |
156 EXPECT_GT(lock_bounds.width(), 10); | 166 EXPECT_GT(lock_bounds.width(), 10); |
157 EXPECT_GT(lock_bounds.height(), 10); | 167 EXPECT_GT(lock_bounds.height(), 10); |
158 | 168 |
159 tester->InjectMockAuthenticator(UserManager::kStubUser, "pass"); | 169 tester->InjectMockAuthenticator(UserManager::kStubUser, "pass"); |
160 EXPECT_TRUE(tester->IsLocked()); | 170 EXPECT_TRUE(tester->IsLocked()); |
161 tester->EnterPassword("fail"); | 171 tester->EnterPassword("fail"); |
162 content::RunAllPendingInMessageLoop(); | 172 content::RunAllPendingInMessageLoop(); |
163 EXPECT_TRUE(tester->IsLocked()); | 173 EXPECT_TRUE(tester->IsLocked()); |
164 tester->EnterPassword("pass"); | 174 tester->EnterPassword("pass"); |
165 content::RunAllPendingInMessageLoop(); | 175 content::RunAllPendingInMessageLoop(); |
| 176 |
166 // Successful authentication clears the lock screen and tells the | 177 // Successful authentication clears the lock screen and tells the |
167 // SessionManager to announce this over DBus. | 178 // SessionManager to announce this over DBus. |
168 EXPECT_FALSE(tester->IsLocked()); | 179 EXPECT_FALSE(tester->IsLocked()); |
169 EXPECT_EQ( | 180 EXPECT_EQ( |
170 1, | 181 1, |
171 fake_session_manager_client_->notify_lock_screen_shown_call_count()); | 182 fake_session_manager_client_->notify_lock_screen_shown_call_count()); |
172 | 183 |
173 EXPECT_TRUE(VerifyLockScreenDismissed()); | 184 EXPECT_TRUE(VerifyLockScreenDismissed()); |
| 185 EXPECT_EQ(ash::SessionStateDelegate::STATE_SESSION, |
| 186 ash::Shell::GetInstance()->session_state_delegate()-> |
| 187 GetSessionState()); |
174 } | 188 } |
175 | 189 |
176 // Test how locking the screen affects an active fullscreen window. | 190 // Test how locking the screen affects an active fullscreen window. |
177 IN_PROC_BROWSER_TEST_F(ScreenLockerTest, TestFullscreenExit) { | 191 IN_PROC_BROWSER_TEST_F(ScreenLockerTest, TestFullscreenExit) { |
178 // 1) If the active browser window is in fullscreen and the fullscreen window | 192 // 1) If the active browser window is in fullscreen and the fullscreen window |
179 // does not have all the pixels (e.g. the shelf is auto hidden instead of | 193 // does not have all the pixels (e.g. the shelf is auto hidden instead of |
180 // hidden), locking the screen should not exit fullscreen. The shelf is | 194 // hidden), locking the screen should not exit fullscreen. The shelf is |
181 // auto hidden when in immersive fullscreen. | 195 // auto hidden when in immersive fullscreen. |
182 scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester()); | 196 scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester()); |
183 BrowserWindow* browser_window = browser()->window(); | 197 BrowserWindow* browser_window = browser()->window(); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 EXPECT_EQ("", tester->GetPassword()); | 307 EXPECT_EQ("", tester->GetPassword()); |
294 | 308 |
295 // Close the locker to match expectations. | 309 // Close the locker to match expectations. |
296 ScreenLocker::Hide(); | 310 ScreenLocker::Hide(); |
297 content::RunAllPendingInMessageLoop(); | 311 content::RunAllPendingInMessageLoop(); |
298 EXPECT_FALSE(tester->IsLocked()); | 312 EXPECT_FALSE(tester->IsLocked()); |
299 EXPECT_TRUE(VerifyLockScreenDismissed()); | 313 EXPECT_TRUE(VerifyLockScreenDismissed()); |
300 } | 314 } |
301 | 315 |
302 } // namespace chromeos | 316 } // namespace chromeos |
OLD | NEW |