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

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

Issue 2854055: Send UnlockCompleted signal even if screen lock is already present. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: browsertest fix Created 10 years, 5 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
« 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/message_loop.h" 5 #include "base/message_loop.h"
6 #include "base/scoped_ptr.h" 6 #include "base/scoped_ptr.h"
7 #include "chrome/browser/automation/ui_controls.h" 7 #include "chrome/browser/automation/ui_controls.h"
8 #include "chrome/browser/chrome_thread.h" 8 #include "chrome/browser/chrome_thread.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/cros/mock_screen_lock_library.h" 10 #include "chrome/browser/chromeos/cros/mock_screen_lock_library.h"
(...skipping 14 matching lines...) Expand all
25 25
26 class ScreenLockerTest : public CrosInProcessBrowserTest { 26 class ScreenLockerTest : public CrosInProcessBrowserTest {
27 public: 27 public:
28 ScreenLockerTest() {} 28 ScreenLockerTest() {}
29 29
30 protected: 30 protected:
31 31
32 // Test the no password mode with different unlock scheme given by 32 // Test the no password mode with different unlock scheme given by
33 // |unlock| function. 33 // |unlock| function.
34 void TestNoPassword(void (unlock)(views::Widget*)) { 34 void TestNoPassword(void (unlock)(views::Widget*)) {
35 EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenUnlockRequested())
36 .Times(1)
37 .RetiresOnSaturation();
38 EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenLockCompleted())
39 .Times(1)
40 .RetiresOnSaturation();
35 UserManager::Get()->OffTheRecordUserLoggedIn(); 41 UserManager::Get()->OffTheRecordUserLoggedIn();
36 ScreenLocker::Show(); 42 ScreenLocker::Show();
37 scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester()); 43 scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester());
38 tester->EmulateWindowManagerReady(); 44 tester->EmulateWindowManagerReady();
39 ui_test_utils::WaitForNotification( 45 ui_test_utils::WaitForNotification(
40 NotificationType::SCREEN_LOCK_STATE_CHANGED); 46 NotificationType::SCREEN_LOCK_STATE_CHANGED);
41 EXPECT_TRUE(tester->IsOpen()); 47 EXPECT_TRUE(tester->IsOpen());
42 tester->InjectMockAuthenticator("", ""); 48 tester->InjectMockAuthenticator("", "");
43 49
44 unlock(tester->GetWidget()); 50 unlock(tester->GetWidget());
45 51
46 ui_test_utils::RunAllPendingInMessageLoop(); 52 ui_test_utils::RunAllPendingInMessageLoop();
47 EXPECT_TRUE(tester->IsOpen()); 53 EXPECT_TRUE(tester->IsOpen());
48 54
49 // Emulate LockScreen request from PowerManager (via SessionManager). 55 // Emulate LockScreen request from PowerManager (via SessionManager).
50 ScreenLocker::Hide(); 56 ScreenLocker::Hide();
51 ui_test_utils::RunAllPendingInMessageLoop(); 57 ui_test_utils::RunAllPendingInMessageLoop();
52 EXPECT_FALSE(tester->IsOpen()); 58 EXPECT_FALSE(tester->IsOpen());
53 } 59 }
54 60
55 private: 61 private:
56 virtual void SetUpInProcessBrowserTestFixture() { 62 virtual void SetUpInProcessBrowserTestFixture() {
57 InitStatusAreaMocks(); 63 InitStatusAreaMocks();
58 InitMockScreenLockLibrary(); 64 InitMockScreenLockLibrary();
59 EXPECT_CALL(*mock_screen_lock_library_, AddObserver(testing::_)) 65 EXPECT_CALL(*mock_screen_lock_library_, AddObserver(testing::_))
60 .Times(1) 66 .Times(1)
61 .RetiresOnSaturation(); 67 .RetiresOnSaturation();
62 EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenLockCompleted())
63 .Times(1)
64 .RetiresOnSaturation();
65 EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenUnlockRequested())
66 .Times(1)
67 .RetiresOnSaturation();
68 EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenUnlockCompleted()) 68 EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenUnlockCompleted())
69 .Times(1) 69 .Times(1)
70 .RetiresOnSaturation(); 70 .RetiresOnSaturation();
71 // Expectations for the status are on the screen lock window. 71 // Expectations for the status are on the screen lock window.
72 SetStatusAreaMocksExpectations(); 72 SetStatusAreaMocksExpectations();
73 // Expectations for the status area on the browser window. 73 // Expectations for the status area on the browser window.
74 SetStatusAreaMocksExpectations(); 74 SetStatusAreaMocksExpectations();
75 } 75 }
76 76
77 virtual void SetUpCommandLine(CommandLine* command_line) { 77 virtual void SetUpCommandLine(CommandLine* command_line) {
78 command_line->AppendSwitchWithValue(switches::kLoginProfile, "user"); 78 command_line->AppendSwitchWithValue(switches::kLoginProfile, "user");
79 command_line->AppendSwitch(switches::kNoFirstRun); 79 command_line->AppendSwitch(switches::kNoFirstRun);
80 } 80 }
81 81
82 DISALLOW_COPY_AND_ASSIGN(ScreenLockerTest); 82 DISALLOW_COPY_AND_ASSIGN(ScreenLockerTest);
83 }; 83 };
84 84
85 IN_PROC_BROWSER_TEST_F(ScreenLockerTest, TestBasic) { 85 IN_PROC_BROWSER_TEST_F(ScreenLockerTest, TestBasic) {
86 EXPECT_CALL(*mock_input_method_library_, GetNumActiveInputMethods()) 86 EXPECT_CALL(*mock_input_method_library_, GetNumActiveInputMethods())
87 .Times(1) 87 .Times(1)
88 .WillRepeatedly((testing::Return(0))) 88 .WillRepeatedly((testing::Return(0)))
89 .RetiresOnSaturation(); 89 .RetiresOnSaturation();
90 EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenUnlockRequested())
91 .Times(1)
92 .RetiresOnSaturation();
93 EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenLockCompleted())
94 .Times(1)
95 .RetiresOnSaturation();
90 UserManager::Get()->UserLoggedIn("user"); 96 UserManager::Get()->UserLoggedIn("user");
91 ScreenLocker::Show(); 97 ScreenLocker::Show();
92 scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester()); 98 scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester());
93 tester->EmulateWindowManagerReady(); 99 tester->EmulateWindowManagerReady();
94 ui_test_utils::WaitForNotification( 100 ui_test_utils::WaitForNotification(
95 NotificationType::SCREEN_LOCK_STATE_CHANGED); 101 NotificationType::SCREEN_LOCK_STATE_CHANGED);
96 102
97 tester->InjectMockAuthenticator("user", "pass"); 103 tester->InjectMockAuthenticator("user", "pass");
98 EXPECT_TRUE(tester->IsOpen()); 104 EXPECT_TRUE(tester->IsOpen());
99 tester->EnterPassword("fail"); 105 tester->EnterPassword("fail");
(...skipping 29 matching lines...) Expand all
129 135
130 void KeyPress(views::Widget* widget) { 136 void KeyPress(views::Widget* widget) {
131 ui_controls::SendKeyPress(GTK_WINDOW(widget->GetNativeView()), 137 ui_controls::SendKeyPress(GTK_WINDOW(widget->GetNativeView()),
132 base::VKEY_SPACE, false, false, false, false); 138 base::VKEY_SPACE, false, false, false, false);
133 } 139 }
134 140
135 IN_PROC_BROWSER_TEST_F(ScreenLockerTest, TestNoPasswordWithKeyPress) { 141 IN_PROC_BROWSER_TEST_F(ScreenLockerTest, TestNoPasswordWithKeyPress) {
136 TestNoPassword(KeyPress); 142 TestNoPassword(KeyPress);
137 } 143 }
138 144
145 IN_PROC_BROWSER_TEST_F(ScreenLockerTest, TestShowTwice) {
146 EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenLockCompleted())
147 .Times(2)
148 .RetiresOnSaturation();
149
150 UserManager::Get()->UserLoggedIn("user");
151 ScreenLocker::Show();
152 scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester());
153 tester->EmulateWindowManagerReady();
154 ui_test_utils::WaitForNotification(
155 NotificationType::SCREEN_LOCK_STATE_CHANGED);
156 EXPECT_TRUE(tester->IsOpen());
157
158 // Calling Show again simply send LockCompleted signal.
159 ScreenLocker::Show();
160 EXPECT_TRUE(tester->IsOpen());
161
162 // Close the locker to match expectations.
163 ScreenLocker::Hide();
164 ui_test_utils::RunAllPendingInMessageLoop();
165 EXPECT_FALSE(tester->IsOpen());
166 }
167
139 } // namespace chromeos 168 } // 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