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

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

Issue 23694025: Remove calls to deprecated session_manager DBus methods (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix use-after-free in tests. Created 7 years, 3 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) 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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 EXPECT_GT(lock_bounds.width(), 10); 152 EXPECT_GT(lock_bounds.width(), 10);
153 EXPECT_GT(lock_bounds.height(), 10); 153 EXPECT_GT(lock_bounds.height(), 10);
154 154
155 tester->InjectMockAuthenticator(UserManager::kStubUser, "pass"); 155 tester->InjectMockAuthenticator(UserManager::kStubUser, "pass");
156 EXPECT_TRUE(tester->IsLocked()); 156 EXPECT_TRUE(tester->IsLocked());
157 tester->EnterPassword("fail"); 157 tester->EnterPassword("fail");
158 content::RunAllPendingInMessageLoop(); 158 content::RunAllPendingInMessageLoop();
159 EXPECT_TRUE(tester->IsLocked()); 159 EXPECT_TRUE(tester->IsLocked());
160 tester->EnterPassword("pass"); 160 tester->EnterPassword("pass");
161 content::RunAllPendingInMessageLoop(); 161 content::RunAllPendingInMessageLoop();
162 // Successful authentication simply send a unlock request to PowerManager. 162 // Successful authentication clears the lock screen and tells the
163 EXPECT_TRUE(tester->IsLocked()); 163 // SessionManager to announce this over DBus.
164 EXPECT_FALSE(tester->IsLocked());
164 EXPECT_EQ( 165 EXPECT_EQ(
165 1, 166 1,
166 fake_session_manager_client_->notify_lock_screen_shown_call_count()); 167 fake_session_manager_client_->notify_lock_screen_shown_call_count());
167 168
168 // Emulate LockScreen request from SessionManager.
169 // TODO(oshima): Find out better way to handle this in mock.
170 ScreenLocker::Hide();
171 content::RunAllPendingInMessageLoop();
172 EXPECT_FALSE(tester->IsLocked());
173 EXPECT_TRUE(VerifyLockScreenDismissed()); 169 EXPECT_TRUE(VerifyLockScreenDismissed());
174 } 170 }
175 171
176 IN_PROC_BROWSER_TEST_F(ScreenLockerTest, TestFullscreenExit) { 172 IN_PROC_BROWSER_TEST_F(ScreenLockerTest, TestFullscreenExit) {
177 scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester()); 173 scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester());
178 { 174 {
179 Waiter waiter(browser()); 175 Waiter waiter(browser());
180 browser()->fullscreen_controller()->ToggleFullscreenMode(); 176 browser()->fullscreen_controller()->ToggleFullscreenMode();
181 waiter.Wait(false /* not locked */, true /* full screen */); 177 waiter.Wait(false /* not locked */, true /* full screen */);
182 EXPECT_TRUE(browser()->window()->IsFullscreen()); 178 EXPECT_TRUE(browser()->window()->IsFullscreen());
183 EXPECT_FALSE(tester->IsLocked()); 179 EXPECT_FALSE(tester->IsLocked());
184 } 180 }
185 { 181 {
186 Waiter waiter(browser()); 182 Waiter waiter(browser());
187 ScreenLocker::Show(); 183 ScreenLocker::Show();
188 tester->EmulateWindowManagerReady(); 184 tester->EmulateWindowManagerReady();
189 waiter.Wait(true /* locked */, false /* full screen */); 185 waiter.Wait(true /* locked */, false /* full screen */);
190 EXPECT_FALSE(browser()->window()->IsFullscreen()); 186 EXPECT_FALSE(browser()->window()->IsFullscreen());
191 EXPECT_TRUE(tester->IsLocked()); 187 EXPECT_TRUE(tester->IsLocked());
192 } 188 }
193 EXPECT_EQ( 189 EXPECT_EQ(
194 1, 190 1,
195 fake_session_manager_client_->notify_lock_screen_shown_call_count()); 191 fake_session_manager_client_->notify_lock_screen_shown_call_count());
196 192
197 tester->InjectMockAuthenticator(UserManager::kStubUser, "pass"); 193 tester->InjectMockAuthenticator(UserManager::kStubUser, "pass");
198 tester->EnterPassword("pass"); 194 tester->EnterPassword("pass");
199 content::RunAllPendingInMessageLoop(); 195 content::RunAllPendingInMessageLoop();
200 ScreenLocker::Hide();
201 content::RunAllPendingInMessageLoop();
202 EXPECT_FALSE(tester->IsLocked()); 196 EXPECT_FALSE(tester->IsLocked());
203 EXPECT_TRUE(VerifyLockScreenDismissed()); 197 EXPECT_TRUE(VerifyLockScreenDismissed());
204 } 198 }
205 199
206 void SimulateKeyPress(views::Widget* widget, ui::KeyboardCode key_code) { 200 void SimulateKeyPress(views::Widget* widget, ui::KeyboardCode key_code) {
207 ui_controls::SendKeyPress(widget->GetNativeWindow(), 201 ui_controls::SendKeyPress(widget->GetNativeWindow(),
208 key_code, false, false, false, false); 202 key_code, false, false, false, false);
209 } 203 }
210 204
211 void UnlockKeyPress(views::Widget* widget) { 205 void UnlockKeyPress(views::Widget* widget) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 EXPECT_EQ("", tester->GetPassword()); 249 EXPECT_EQ("", tester->GetPassword());
256 250
257 // Close the locker to match expectations. 251 // Close the locker to match expectations.
258 ScreenLocker::Hide(); 252 ScreenLocker::Hide();
259 content::RunAllPendingInMessageLoop(); 253 content::RunAllPendingInMessageLoop();
260 EXPECT_FALSE(tester->IsLocked()); 254 EXPECT_FALSE(tester->IsLocked());
261 EXPECT_TRUE(VerifyLockScreenDismissed()); 255 EXPECT_TRUE(VerifyLockScreenDismissed());
262 } 256 }
263 257
264 } // namespace chromeos 258 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/screen_locker.cc ('k') | chrome/browser/chromeos/login/screen_locker_tester.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698