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

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

Issue 6312160: Map Views to Profiles directly from their window, eliminating the need... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "base/scoped_ptr.h" 7 #include "base/scoped_ptr.h"
8 #include "chrome/browser/automation/ui_controls.h" 8 #include "chrome/browser/automation/ui_controls.h"
9 #include "chrome/browser/browser_window.h" 9 #include "chrome/browser/browser_window.h"
10 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" 10 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h"
11 #include "chrome/browser/chromeos/cros/mock_input_method_library.h" 11 #include "chrome/browser/chromeos/cros/mock_input_method_library.h"
12 #include "chrome/browser/chromeos/cros/mock_screen_lock_library.h" 12 #include "chrome/browser/chromeos/cros/mock_screen_lock_library.h"
13 #include "chrome/browser/chromeos/login/mock_authenticator.h" 13 #include "chrome/browser/chromeos/login/mock_authenticator.h"
14 #include "chrome/browser/chromeos/login/screen_locker.h" 14 #include "chrome/browser/chromeos/login/screen_locker.h"
15 #include "chrome/browser/chromeos/login/screen_locker_tester.h" 15 #include "chrome/browser/chromeos/login/screen_locker_tester.h"
16 #include "chrome/browser/chromeos/login/user_manager.h" 16 #include "chrome/browser/chromeos/login/user_manager.h"
17 #include "chrome/browser/profiles/profile_manager.h"
17 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/views/browser_dialogs.h" 19 #include "chrome/browser/ui/views/browser_dialogs.h"
19 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
20 #include "chrome/common/notification_service.h" 21 #include "chrome/common/notification_service.h"
21 #include "chrome/common/notification_type.h" 22 #include "chrome/common/notification_type.h"
22 #include "chrome/test/ui_test_utils.h" 23 #include "chrome/test/ui_test_utils.h"
23 #include "testing/gmock/include/gmock/gmock.h" 24 #include "testing/gmock/include/gmock/gmock.h"
24 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
25 #include "views/controls/textfield/textfield.h" 26 #include "views/controls/textfield/textfield.h"
26 #include "views/window/window_gtk.h" 27 #include "views/window/window_gtk.h"
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 TestNoPassword(KeyPress); 276 TestNoPassword(KeyPress);
276 } 277 }
277 278
278 IN_PROC_BROWSER_TEST_F(ScreenLockerTest, TestShowTwice) { 279 IN_PROC_BROWSER_TEST_F(ScreenLockerTest, TestShowTwice) {
279 EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenLockCompleted()) 280 EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenLockCompleted())
280 .Times(2) 281 .Times(2)
281 .RetiresOnSaturation(); 282 .RetiresOnSaturation();
282 scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester()); 283 scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester());
283 LockScreenWithUser(tester.get(), "user"); 284 LockScreenWithUser(tester.get(), "user");
284 285
286 // Ensure there's a profile or this test crashes.
287 ProfileManager::GetDefaultProfile();
288
285 // Calling Show again simply send LockCompleted signal. 289 // Calling Show again simply send LockCompleted signal.
286 ScreenLocker::Show(); 290 ScreenLocker::Show();
287 EXPECT_TRUE(tester->IsLocked()); 291 EXPECT_TRUE(tester->IsLocked());
288 292
289 // Close the locker to match expectations. 293 // Close the locker to match expectations.
290 ScreenLocker::Hide(); 294 ScreenLocker::Hide();
291 ui_test_utils::RunAllPendingInMessageLoop(); 295 ui_test_utils::RunAllPendingInMessageLoop();
292 EXPECT_FALSE(tester->IsLocked()); 296 EXPECT_FALSE(tester->IsLocked());
293 } 297 }
294 298
295 IN_PROC_BROWSER_TEST_F(ScreenLockerTest, TestEscape) { 299 IN_PROC_BROWSER_TEST_F(ScreenLockerTest, TestEscape) {
296 EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenLockCompleted()) 300 EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenLockCompleted())
297 .Times(1) 301 .Times(1)
298 .RetiresOnSaturation(); 302 .RetiresOnSaturation();
299 scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester()); 303 scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester());
300 LockScreenWithUser(tester.get(), "user"); 304 LockScreenWithUser(tester.get(), "user");
301 305
306 // Ensure there's a profile or this test crashes.
307 ProfileManager::GetDefaultProfile();
308
302 tester->SetPassword("password"); 309 tester->SetPassword("password");
303 EXPECT_EQ("password", tester->GetPassword()); 310 EXPECT_EQ("password", tester->GetPassword());
304 // Escape clears the password. 311 // Escape clears the password.
305 ui_controls::SendKeyPress(GTK_WINDOW(tester->GetWidget()->GetNativeView()), 312 ui_controls::SendKeyPress(GTK_WINDOW(tester->GetWidget()->GetNativeView()),
306 ui::VKEY_ESCAPE, false, false, false, false); 313 ui::VKEY_ESCAPE, false, false, false, false);
307 ui_test_utils::RunAllPendingInMessageLoop(); 314 ui_test_utils::RunAllPendingInMessageLoop();
308 EXPECT_EQ("", tester->GetPassword()); 315 EXPECT_EQ("", tester->GetPassword());
309 316
310 // Close the locker to match expectations. 317 // Close the locker to match expectations.
311 ScreenLocker::Hide(); 318 ScreenLocker::Hide();
312 ui_test_utils::RunAllPendingInMessageLoop(); 319 ui_test_utils::RunAllPendingInMessageLoop();
313 EXPECT_FALSE(tester->IsLocked()); 320 EXPECT_FALSE(tester->IsLocked());
314 } 321 }
315 322
316 } // namespace chromeos 323 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/screen_lock_view.cc ('k') | chrome/browser/chromeos/login/update_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698