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

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

Issue 8774035: Revert "chromeos: move screen lock handling to power manager client" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reverted 3 patches in correct order, without conflict Created 9 years 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
« no previous file with comments | « chrome/browser/chromeos/login/screen_locker.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "chrome/browser/automation/ui_controls.h" 8 #include "chrome/browser/automation/ui_controls.h"
9 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" 9 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h"
10 #include "chrome/browser/chromeos/dbus/mock_power_manager_client.h" 10 #include "chrome/browser/chromeos/cros/mock_screen_lock_library.h"
11 #include "chrome/browser/chromeos/login/mock_authenticator.h" 11 #include "chrome/browser/chromeos/login/mock_authenticator.h"
12 #include "chrome/browser/chromeos/login/screen_locker.h" 12 #include "chrome/browser/chromeos/login/screen_locker.h"
13 #include "chrome/browser/chromeos/login/screen_locker_tester.h" 13 #include "chrome/browser/chromeos/login/screen_locker_tester.h"
14 #include "chrome/browser/chromeos/login/user_manager.h" 14 #include "chrome/browser/chromeos/login/user_manager.h"
15 #include "chrome/browser/profiles/profile_manager.h" 15 #include "chrome/browser/profiles/profile_manager.h"
16 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/browser_window.h" 17 #include "chrome/browser/ui/browser_window.h"
18 #include "chrome/browser/ui/views/browser_dialogs.h" 18 #include "chrome/browser/ui/views/browser_dialogs.h"
19 #include "chrome/common/chrome_notification_types.h" 19 #include "chrome/common/chrome_notification_types.h"
20 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 MessageLoop::current()->Quit(); 90 MessageLoop::current()->Quit();
91 return false; 91 return false;
92 } 92 }
93 93
94 } // namespace 94 } // namespace
95 95
96 namespace chromeos { 96 namespace chromeos {
97 97
98 class ScreenLockerTest : public CrosInProcessBrowserTest { 98 class ScreenLockerTest : public CrosInProcessBrowserTest {
99 public: 99 public:
100 ScreenLockerTest() { 100 ScreenLockerTest() : mock_screen_lock_library_(NULL) {
101 } 101 }
102 102
103 protected: 103 protected:
104 MockPowerManagerClient mock_power_manager_client_; 104 MockScreenLockLibrary *mock_screen_lock_library_;
105 105
106 // Test the no password mode with different unlock scheme given by 106 // Test the no password mode with different unlock scheme given by
107 // |unlock| function. 107 // |unlock| function.
108 void TestNoPassword(void (unlock)(views::Widget*)) { 108 void TestNoPassword(void (unlock)(views::Widget*)) {
109 EXPECT_CALL(mock_power_manager_client_, NotifyScreenUnlockRequested()) 109 EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenUnlockRequested())
110 .Times(1) 110 .Times(1)
111 .RetiresOnSaturation(); 111 .RetiresOnSaturation();
112 EXPECT_CALL(mock_power_manager_client_, NotifyScreenLockCompleted()) 112 EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenLockCompleted())
113 .Times(1) 113 .Times(1)
114 .RetiresOnSaturation(); 114 .RetiresOnSaturation();
115 UserManager::Get()->GuestUserLoggedIn(); 115 UserManager::Get()->GuestUserLoggedIn();
116 ScreenLocker::Show(); 116 ScreenLocker::Show();
117 scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester()); 117 scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester());
118 tester->EmulateWindowManagerReady(); 118 tester->EmulateWindowManagerReady();
119 ui_test_utils::WindowedNotificationObserver lock_state_observer( 119 ui_test_utils::WindowedNotificationObserver lock_state_observer(
120 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, 120 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED,
121 content::NotificationService::AllSources()); 121 content::NotificationService::AllSources());
122 if (!chromeos::ScreenLocker::GetTester()->IsLocked()) 122 if (!chromeos::ScreenLocker::GetTester()->IsLocked())
(...skipping 21 matching lines...) Expand all
144 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, 144 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED,
145 content::NotificationService::AllSources()); 145 content::NotificationService::AllSources());
146 if (!tester->IsLocked()) 146 if (!tester->IsLocked())
147 lock_state_observer.Wait(); 147 lock_state_observer.Wait();
148 EXPECT_TRUE(tester->IsLocked()); 148 EXPECT_TRUE(tester->IsLocked());
149 } 149 }
150 150
151 private: 151 private:
152 virtual void SetUpInProcessBrowserTestFixture() { 152 virtual void SetUpInProcessBrowserTestFixture() {
153 cros_mock_->InitStatusAreaMocks(); 153 cros_mock_->InitStatusAreaMocks();
154 EXPECT_CALL(mock_power_manager_client_, AddObserver(testing::_)) 154 cros_mock_->InitMockScreenLockLibrary();
155 mock_screen_lock_library_ = cros_mock_->mock_screen_lock_library();
156 EXPECT_CALL(*mock_screen_lock_library_, AddObserver(testing::_))
155 .Times(1) 157 .Times(1)
156 .RetiresOnSaturation(); 158 .RetiresOnSaturation();
157 EXPECT_CALL(mock_power_manager_client_, NotifyScreenUnlockCompleted()) 159 EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenUnlockCompleted())
158 .Times(1) 160 .Times(1)
159 .RetiresOnSaturation(); 161 .RetiresOnSaturation();
160 // Expectations for the status are on the screen lock window. 162 // Expectations for the status are on the screen lock window.
161 cros_mock_->SetStatusAreaMocksExpectations(); 163 cros_mock_->SetStatusAreaMocksExpectations();
162 // Expectations for the status area on the browser window. 164 // Expectations for the status area on the browser window.
163 cros_mock_->SetStatusAreaMocksExpectations(); 165 cros_mock_->SetStatusAreaMocksExpectations();
164 } 166 }
165 167
166 virtual void SetUpCommandLine(CommandLine* command_line) { 168 virtual void SetUpCommandLine(CommandLine* command_line) {
167 command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); 169 command_line->AppendSwitchASCII(switches::kLoginProfile, "user");
168 command_line->AppendSwitch(switches::kNoFirstRun); 170 command_line->AppendSwitch(switches::kNoFirstRun);
169 } 171 }
170 172
171 DISALLOW_COPY_AND_ASSIGN(ScreenLockerTest); 173 DISALLOW_COPY_AND_ASSIGN(ScreenLockerTest);
172 }; 174 };
173 175
174 // Temporarily disabling all screen locker tests while investigating the 176 // Temporarily disabling all screen locker tests while investigating the
175 // issue crbug.com/78764. 177 // issue crbug.com/78764.
176 IN_PROC_BROWSER_TEST_F(ScreenLockerTest, DISABLED_TestBasic) { 178 IN_PROC_BROWSER_TEST_F(ScreenLockerTest, DISABLED_TestBasic) {
177 EXPECT_CALL(mock_power_manager_client_, NotifyScreenUnlockRequested()) 179 EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenUnlockRequested())
178 .Times(1) 180 .Times(1)
179 .RetiresOnSaturation(); 181 .RetiresOnSaturation();
180 EXPECT_CALL(mock_power_manager_client_, NotifyScreenLockCompleted()) 182 EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenLockCompleted())
181 .Times(1) 183 .Times(1)
182 .RetiresOnSaturation(); 184 .RetiresOnSaturation();
183 UserManager::Get()->UserLoggedIn("user"); 185 UserManager::Get()->UserLoggedIn("user");
184 ScreenLocker::Show(); 186 ScreenLocker::Show();
185 scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester()); 187 scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester());
186 tester->EmulateWindowManagerReady(); 188 tester->EmulateWindowManagerReady();
187 ui_test_utils::WindowedNotificationObserver lock_state_observer( 189 ui_test_utils::WindowedNotificationObserver lock_state_observer(
188 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, 190 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED,
189 content::NotificationService::AllSources()); 191 content::NotificationService::AllSources());
190 if (!chromeos::ScreenLocker::GetTester()->IsLocked()) 192 if (!chromeos::ScreenLocker::GetTester()->IsLocked())
(...skipping 17 matching lines...) Expand all
208 EXPECT_TRUE(tester->IsLocked()); 210 EXPECT_TRUE(tester->IsLocked());
209 211
210 // Emulate LockScreen request from PowerManager (via SessionManager). 212 // Emulate LockScreen request from PowerManager (via SessionManager).
211 // TODO(oshima): Find out better way to handle this in mock. 213 // TODO(oshima): Find out better way to handle this in mock.
212 ScreenLocker::Hide(); 214 ScreenLocker::Hide();
213 ui_test_utils::RunAllPendingInMessageLoop(); 215 ui_test_utils::RunAllPendingInMessageLoop();
214 EXPECT_FALSE(tester->IsLocked()); 216 EXPECT_FALSE(tester->IsLocked());
215 } 217 }
216 218
217 IN_PROC_BROWSER_TEST_F(ScreenLockerTest, DISABLED_TestFullscreenExit) { 219 IN_PROC_BROWSER_TEST_F(ScreenLockerTest, DISABLED_TestFullscreenExit) {
218 EXPECT_CALL(mock_power_manager_client_, NotifyScreenUnlockRequested()) 220 EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenUnlockRequested())
219 .Times(1) 221 .Times(1)
220 .RetiresOnSaturation(); 222 .RetiresOnSaturation();
221 EXPECT_CALL(mock_power_manager_client_, NotifyScreenLockCompleted()) 223 EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenLockCompleted())
222 .Times(1) 224 .Times(1)
223 .RetiresOnSaturation(); 225 .RetiresOnSaturation();
224 scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester()); 226 scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester());
225 { 227 {
226 Waiter waiter(browser()); 228 Waiter waiter(browser());
227 browser()->ToggleFullscreenMode(false); 229 browser()->ToggleFullscreenMode(false);
228 waiter.Wait(false /* not locked */, true /* full screen */); 230 waiter.Wait(false /* not locked */, true /* full screen */);
229 EXPECT_TRUE(browser()->window()->IsFullscreen()); 231 EXPECT_TRUE(browser()->window()->IsFullscreen());
230 EXPECT_FALSE(tester->IsLocked()); 232 EXPECT_FALSE(tester->IsLocked());
231 } 233 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 void KeyPress(views::Widget* widget) { 269 void KeyPress(views::Widget* widget) {
268 ui_controls::SendKeyPress(GTK_WINDOW(widget->GetNativeView()), 270 ui_controls::SendKeyPress(GTK_WINDOW(widget->GetNativeView()),
269 ui::VKEY_SPACE, false, false, false, false); 271 ui::VKEY_SPACE, false, false, false, false);
270 } 272 }
271 273
272 IN_PROC_BROWSER_TEST_F(ScreenLockerTest, DISABLED_TestNoPasswordWithKeyPress) { 274 IN_PROC_BROWSER_TEST_F(ScreenLockerTest, DISABLED_TestNoPasswordWithKeyPress) {
273 TestNoPassword(KeyPress); 275 TestNoPassword(KeyPress);
274 } 276 }
275 277
276 IN_PROC_BROWSER_TEST_F(ScreenLockerTest, DISABLED_TestShowTwice) { 278 IN_PROC_BROWSER_TEST_F(ScreenLockerTest, DISABLED_TestShowTwice) {
277 EXPECT_CALL(mock_power_manager_client_, NotifyScreenLockCompleted()) 279 EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenLockCompleted())
278 .Times(2) 280 .Times(2)
279 .RetiresOnSaturation(); 281 .RetiresOnSaturation();
280 scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester()); 282 scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester());
281 LockScreenWithUser(tester.get(), "user"); 283 LockScreenWithUser(tester.get(), "user");
282 284
283 // Ensure there's a profile or this test crashes. 285 // Ensure there's a profile or this test crashes.
284 ProfileManager::GetDefaultProfile(); 286 ProfileManager::GetDefaultProfile();
285 287
286 // Calling Show again simply send LockCompleted signal. 288 // Calling Show again simply send LockCompleted signal.
287 ScreenLocker::Show(); 289 ScreenLocker::Show();
288 EXPECT_TRUE(tester->IsLocked()); 290 EXPECT_TRUE(tester->IsLocked());
289 291
290 // Close the locker to match expectations. 292 // Close the locker to match expectations.
291 ScreenLocker::Hide(); 293 ScreenLocker::Hide();
292 ui_test_utils::RunAllPendingInMessageLoop(); 294 ui_test_utils::RunAllPendingInMessageLoop();
293 EXPECT_FALSE(tester->IsLocked()); 295 EXPECT_FALSE(tester->IsLocked());
294 } 296 }
295 297
296 IN_PROC_BROWSER_TEST_F(ScreenLockerTest, DISABLED_TestEscape) { 298 IN_PROC_BROWSER_TEST_F(ScreenLockerTest, DISABLED_TestEscape) {
297 EXPECT_CALL(mock_power_manager_client_, NotifyScreenLockCompleted()) 299 EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenLockCompleted())
298 .Times(1) 300 .Times(1)
299 .RetiresOnSaturation(); 301 .RetiresOnSaturation();
300 scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester()); 302 scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester());
301 LockScreenWithUser(tester.get(), "user"); 303 LockScreenWithUser(tester.get(), "user");
302 304
303 // Ensure there's a profile or this test crashes. 305 // Ensure there's a profile or this test crashes.
304 ProfileManager::GetDefaultProfile(); 306 ProfileManager::GetDefaultProfile();
305 307
306 tester->SetPassword("password"); 308 tester->SetPassword("password");
307 EXPECT_EQ("password", tester->GetPassword()); 309 EXPECT_EQ("password", tester->GetPassword());
308 // Escape clears the password. 310 // Escape clears the password.
309 ui_controls::SendKeyPress(GTK_WINDOW(tester->GetWidget()->GetNativeView()), 311 ui_controls::SendKeyPress(GTK_WINDOW(tester->GetWidget()->GetNativeView()),
310 ui::VKEY_ESCAPE, false, false, false, false); 312 ui::VKEY_ESCAPE, false, false, false, false);
311 ui_test_utils::RunAllPendingInMessageLoop(); 313 ui_test_utils::RunAllPendingInMessageLoop();
312 EXPECT_EQ("", tester->GetPassword()); 314 EXPECT_EQ("", tester->GetPassword());
313 315
314 // Close the locker to match expectations. 316 // Close the locker to match expectations.
315 ScreenLocker::Hide(); 317 ScreenLocker::Hide();
316 ui_test_utils::RunAllPendingInMessageLoop(); 318 ui_test_utils::RunAllPendingInMessageLoop();
317 EXPECT_FALSE(tester->IsLocked()); 319 EXPECT_FALSE(tester->IsLocked());
318 } 320 }
319 321
320 } // namespace chromeos 322 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/screen_locker.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698