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

Side by Side Diff: chrome/browser/chromeos/login/lock/screen_locker_browsertest.cc

Issue 296773002: Add a Key class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 6 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 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"
12 #include "chrome/browser/chromeos/login/auth/mock_authenticator.h" 13 #include "chrome/browser/chromeos/login/auth/mock_authenticator.h"
14 #include "chrome/browser/chromeos/login/auth/user_context.h"
13 #include "chrome/browser/chromeos/login/lock/screen_locker_tester.h" 15 #include "chrome/browser/chromeos/login/lock/screen_locker_tester.h"
14 #include "chrome/browser/chromeos/login/users/user_manager.h" 16 #include "chrome/browser/chromeos/login/users/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"
17 #include "chrome/browser/ui/browser_window.h" 19 #include "chrome/browser/ui/browser_window.h"
18 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" 20 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h"
19 #include "chrome/browser/ui/tabs/tab_strip_model.h" 21 #include "chrome/browser/ui/tabs/tab_strip_model.h"
20 #include "chrome/common/chrome_switches.h" 22 #include "chrome/common/chrome_switches.h"
21 #include "chrome/test/base/in_process_browser_test.h" 23 #include "chrome/test/base/in_process_browser_test.h"
22 #include "chrome/test/base/ui_test_utils.h" 24 #include "chrome/test/base/ui_test_utils.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 if (!tester->IsLocked()) 151 if (!tester->IsLocked())
150 lock_state_observer.Wait(); 152 lock_state_observer.Wait();
151 153
152 // 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
153 // reasonable size, preventing a regression of 155 // reasonable size, preventing a regression of
154 // http://code.google.com/p/chromium-os/issues/detail?id=5987 156 // http://code.google.com/p/chromium-os/issues/detail?id=5987
155 gfx::Rect lock_bounds = tester->GetChildWidget()->GetWindowBoundsInScreen(); 157 gfx::Rect lock_bounds = tester->GetChildWidget()->GetWindowBoundsInScreen();
156 EXPECT_GT(lock_bounds.width(), 10); 158 EXPECT_GT(lock_bounds.width(), 10);
157 EXPECT_GT(lock_bounds.height(), 10); 159 EXPECT_GT(lock_bounds.height(), 10);
158 160
159 tester->InjectMockAuthenticator(UserManager::kStubUser, "pass"); 161 UserContext user_context(UserManager::kStubUser);
162 user_context.SetKey(Key("pass"));
163 tester->InjectMockAuthenticator(user_context);
160 EXPECT_TRUE(tester->IsLocked()); 164 EXPECT_TRUE(tester->IsLocked());
161 tester->EnterPassword("fail"); 165 tester->EnterPassword("fail");
162 content::RunAllPendingInMessageLoop(); 166 content::RunAllPendingInMessageLoop();
163 EXPECT_TRUE(tester->IsLocked()); 167 EXPECT_TRUE(tester->IsLocked());
164 tester->EnterPassword("pass"); 168 tester->EnterPassword("pass");
165 content::RunAllPendingInMessageLoop(); 169 content::RunAllPendingInMessageLoop();
166 // Successful authentication clears the lock screen and tells the 170 // Successful authentication clears the lock screen and tells the
167 // SessionManager to announce this over DBus. 171 // SessionManager to announce this over DBus.
168 EXPECT_FALSE(tester->IsLocked()); 172 EXPECT_FALSE(tester->IsLocked());
169 EXPECT_EQ( 173 EXPECT_EQ(
(...skipping 23 matching lines...) Expand all
193 } 197 }
194 { 198 {
195 Waiter waiter(browser()); 199 Waiter waiter(browser());
196 ScreenLocker::Show(); 200 ScreenLocker::Show();
197 tester->EmulateWindowManagerReady(); 201 tester->EmulateWindowManagerReady();
198 waiter.Wait(true /* locked */, true /* full screen */); 202 waiter.Wait(true /* locked */, true /* full screen */);
199 EXPECT_TRUE(browser_window->IsFullscreen()); 203 EXPECT_TRUE(browser_window->IsFullscreen());
200 EXPECT_FALSE(window_state->hide_shelf_when_fullscreen()); 204 EXPECT_FALSE(window_state->hide_shelf_when_fullscreen());
201 EXPECT_TRUE(tester->IsLocked()); 205 EXPECT_TRUE(tester->IsLocked());
202 } 206 }
203 tester->InjectMockAuthenticator(UserManager::kStubUser, "pass"); 207 UserContext user_context(UserManager::kStubUser);
208 user_context.SetKey(Key("pass"));
209 tester->InjectMockAuthenticator(user_context);
204 tester->EnterPassword("pass"); 210 tester->EnterPassword("pass");
205 content::RunAllPendingInMessageLoop(); 211 content::RunAllPendingInMessageLoop();
206 EXPECT_FALSE(tester->IsLocked()); 212 EXPECT_FALSE(tester->IsLocked());
207 { 213 {
208 Waiter waiter(browser()); 214 Waiter waiter(browser());
209 browser()->fullscreen_controller()->ToggleBrowserFullscreenMode(); 215 browser()->fullscreen_controller()->ToggleBrowserFullscreenMode();
210 waiter.Wait(false /* not locked */, false /* fullscreen */); 216 waiter.Wait(false /* not locked */, false /* fullscreen */);
211 EXPECT_FALSE(browser_window->IsFullscreen()); 217 EXPECT_FALSE(browser_window->IsFullscreen());
212 } 218 }
213 219
(...skipping 13 matching lines...) Expand all
227 } 233 }
228 { 234 {
229 Waiter waiter(browser()); 235 Waiter waiter(browser());
230 ScreenLocker::Show(); 236 ScreenLocker::Show();
231 tester->EmulateWindowManagerReady(); 237 tester->EmulateWindowManagerReady();
232 waiter.Wait(true /* locked */, false /* full screen */); 238 waiter.Wait(true /* locked */, false /* full screen */);
233 EXPECT_FALSE(browser_window->IsFullscreen()); 239 EXPECT_FALSE(browser_window->IsFullscreen());
234 EXPECT_TRUE(tester->IsLocked()); 240 EXPECT_TRUE(tester->IsLocked());
235 } 241 }
236 242
237 tester->InjectMockAuthenticator(UserManager::kStubUser, "pass");
238 tester->EnterPassword("pass"); 243 tester->EnterPassword("pass");
239 content::RunAllPendingInMessageLoop(); 244 content::RunAllPendingInMessageLoop();
240 EXPECT_FALSE(tester->IsLocked()); 245 EXPECT_FALSE(tester->IsLocked());
241 246
242 EXPECT_EQ( 247 EXPECT_EQ(
243 2, 248 2,
244 fake_session_manager_client_->notify_lock_screen_shown_call_count()); 249 fake_session_manager_client_->notify_lock_screen_shown_call_count());
245 EXPECT_EQ( 250 EXPECT_EQ(
246 2, 251 2,
247 fake_session_manager_client_->notify_lock_screen_dismissed_call_count()); 252 fake_session_manager_client_->notify_lock_screen_dismissed_call_count());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 EXPECT_EQ("", tester->GetPassword()); 298 EXPECT_EQ("", tester->GetPassword());
294 299
295 // Close the locker to match expectations. 300 // Close the locker to match expectations.
296 ScreenLocker::Hide(); 301 ScreenLocker::Hide();
297 content::RunAllPendingInMessageLoop(); 302 content::RunAllPendingInMessageLoop();
298 EXPECT_FALSE(tester->IsLocked()); 303 EXPECT_FALSE(tester->IsLocked());
299 EXPECT_TRUE(VerifyLockScreenDismissed()); 304 EXPECT_TRUE(VerifyLockScreenDismissed());
300 } 305 }
301 306
302 } // namespace chromeos 307 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/lock/screen_locker.cc ('k') | chrome/browser/chromeos/login/lock/screen_locker_tester.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698