OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/lock/screen_locker.h" | 5 #include "chrome/browser/chromeos/login/lock/screen_locker.h" |
6 | 6 |
7 #include "ash/wm/window_state.h" | 7 #include "ash/wm/window_state.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
12 #include "chrome/browser/chromeos/login/auth/key.h" | |
13 #include "chrome/browser/chromeos/login/auth/mock_authenticator.h" | 12 #include "chrome/browser/chromeos/login/auth/mock_authenticator.h" |
14 #include "chrome/browser/chromeos/login/auth/user_context.h" | |
15 #include "chrome/browser/chromeos/login/lock/screen_locker_tester.h" | 13 #include "chrome/browser/chromeos/login/lock/screen_locker_tester.h" |
16 #include "chrome/browser/chromeos/login/users/user_manager.h" | |
17 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
18 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
19 #include "chrome/browser/ui/browser_window.h" | 16 #include "chrome/browser/ui/browser_window.h" |
20 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" | 17 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" |
21 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
22 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
23 #include "chrome/test/base/in_process_browser_test.h" | 20 #include "chrome/test/base/in_process_browser_test.h" |
24 #include "chrome/test/base/ui_test_utils.h" | 21 #include "chrome/test/base/ui_test_utils.h" |
25 #include "chromeos/chromeos_switches.h" | 22 #include "chromeos/chromeos_switches.h" |
26 #include "chromeos/dbus/fake_dbus_thread_manager.h" | 23 #include "chromeos/dbus/fake_dbus_thread_manager.h" |
27 #include "chromeos/dbus/fake_session_manager_client.h" | 24 #include "chromeos/dbus/fake_session_manager_client.h" |
| 25 #include "chromeos/login/auth/key.h" |
| 26 #include "chromeos/login/auth/user_context.h" |
| 27 #include "chromeos/login/user_names.h" |
28 #include "content/public/browser/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
29 #include "testing/gmock/include/gmock/gmock.h" | 29 #include "testing/gmock/include/gmock/gmock.h" |
30 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
31 #include "ui/base/test/ui_controls.h" | 31 #include "ui/base/test/ui_controls.h" |
32 #include "ui/compositor/layer_animator.h" | 32 #include "ui/compositor/layer_animator.h" |
33 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 33 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
34 #include "ui/views/widget/widget.h" | 34 #include "ui/views/widget/widget.h" |
35 | 35 |
36 using testing::_; | 36 using testing::_; |
37 using testing::AnyNumber; | 37 using testing::AnyNumber; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 if (!tester->IsLocked()) | 151 if (!tester->IsLocked()) |
152 lock_state_observer.Wait(); | 152 lock_state_observer.Wait(); |
153 | 153 |
154 // Test to make sure that the widget is actually appearing and is of | 154 // Test to make sure that the widget is actually appearing and is of |
155 // reasonable size, preventing a regression of | 155 // reasonable size, preventing a regression of |
156 // http://code.google.com/p/chromium-os/issues/detail?id=5987 | 156 // http://code.google.com/p/chromium-os/issues/detail?id=5987 |
157 gfx::Rect lock_bounds = tester->GetChildWidget()->GetWindowBoundsInScreen(); | 157 gfx::Rect lock_bounds = tester->GetChildWidget()->GetWindowBoundsInScreen(); |
158 EXPECT_GT(lock_bounds.width(), 10); | 158 EXPECT_GT(lock_bounds.width(), 10); |
159 EXPECT_GT(lock_bounds.height(), 10); | 159 EXPECT_GT(lock_bounds.height(), 10); |
160 | 160 |
161 UserContext user_context(UserManager::kStubUser); | 161 UserContext user_context(chromeos::login::kStubUser); |
162 user_context.SetKey(Key("pass")); | 162 user_context.SetKey(Key("pass")); |
163 tester->InjectMockAuthenticator(user_context); | 163 tester->InjectMockAuthenticator(user_context); |
164 EXPECT_TRUE(tester->IsLocked()); | 164 EXPECT_TRUE(tester->IsLocked()); |
165 tester->EnterPassword("fail"); | 165 tester->EnterPassword("fail"); |
166 content::RunAllPendingInMessageLoop(); | 166 content::RunAllPendingInMessageLoop(); |
167 EXPECT_TRUE(tester->IsLocked()); | 167 EXPECT_TRUE(tester->IsLocked()); |
168 tester->EnterPassword("pass"); | 168 tester->EnterPassword("pass"); |
169 content::RunAllPendingInMessageLoop(); | 169 content::RunAllPendingInMessageLoop(); |
170 // Successful authentication clears the lock screen and tells the | 170 // Successful authentication clears the lock screen and tells the |
171 // SessionManager to announce this over DBus. | 171 // SessionManager to announce this over DBus. |
(...skipping 25 matching lines...) Expand all Loading... |
197 } | 197 } |
198 { | 198 { |
199 Waiter waiter(browser()); | 199 Waiter waiter(browser()); |
200 ScreenLocker::Show(); | 200 ScreenLocker::Show(); |
201 tester->EmulateWindowManagerReady(); | 201 tester->EmulateWindowManagerReady(); |
202 waiter.Wait(true /* locked */, true /* full screen */); | 202 waiter.Wait(true /* locked */, true /* full screen */); |
203 EXPECT_TRUE(browser_window->IsFullscreen()); | 203 EXPECT_TRUE(browser_window->IsFullscreen()); |
204 EXPECT_FALSE(window_state->hide_shelf_when_fullscreen()); | 204 EXPECT_FALSE(window_state->hide_shelf_when_fullscreen()); |
205 EXPECT_TRUE(tester->IsLocked()); | 205 EXPECT_TRUE(tester->IsLocked()); |
206 } | 206 } |
207 UserContext user_context(UserManager::kStubUser); | 207 UserContext user_context(chromeos::login::kStubUser); |
208 user_context.SetKey(Key("pass")); | 208 user_context.SetKey(Key("pass")); |
209 tester->InjectMockAuthenticator(user_context); | 209 tester->InjectMockAuthenticator(user_context); |
210 tester->EnterPassword("pass"); | 210 tester->EnterPassword("pass"); |
211 content::RunAllPendingInMessageLoop(); | 211 content::RunAllPendingInMessageLoop(); |
212 EXPECT_FALSE(tester->IsLocked()); | 212 EXPECT_FALSE(tester->IsLocked()); |
213 { | 213 { |
214 Waiter waiter(browser()); | 214 Waiter waiter(browser()); |
215 browser()->fullscreen_controller()->ToggleBrowserFullscreenMode(); | 215 browser()->fullscreen_controller()->ToggleBrowserFullscreenMode(); |
216 waiter.Wait(false /* not locked */, false /* fullscreen */); | 216 waiter.Wait(false /* not locked */, false /* fullscreen */); |
217 EXPECT_FALSE(browser_window->IsFullscreen()); | 217 EXPECT_FALSE(browser_window->IsFullscreen()); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 EXPECT_EQ("", tester->GetPassword()); | 298 EXPECT_EQ("", tester->GetPassword()); |
299 | 299 |
300 // Close the locker to match expectations. | 300 // Close the locker to match expectations. |
301 ScreenLocker::Hide(); | 301 ScreenLocker::Hide(); |
302 content::RunAllPendingInMessageLoop(); | 302 content::RunAllPendingInMessageLoop(); |
303 EXPECT_FALSE(tester->IsLocked()); | 303 EXPECT_FALSE(tester->IsLocked()); |
304 EXPECT_TRUE(VerifyLockScreenDismissed()); | 304 EXPECT_TRUE(VerifyLockScreenDismissed()); |
305 } | 305 } |
306 | 306 |
307 } // namespace chromeos | 307 } // namespace chromeos |
OLD | NEW |