| OLD | NEW |
| 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 "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/chromeos/cros/cros_in_process_browser_test.h" | 8 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" |
| 9 #include "chrome/browser/chromeos/cros/mock_network_library.h" | 9 #include "chrome/browser/chromeos/cros/mock_network_library.h" |
| 10 #include "chrome/browser/chromeos/login/mock_authenticator.h" | 10 #include "chrome/browser/chromeos/login/mock_authenticator.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 public: | 86 public: |
| 87 ScreenLockerTest() : mock_power_manager_client_(NULL) { | 87 ScreenLockerTest() : mock_power_manager_client_(NULL) { |
| 88 } | 88 } |
| 89 | 89 |
| 90 protected: | 90 protected: |
| 91 MockPowerManagerClient* mock_power_manager_client_; | 91 MockPowerManagerClient* mock_power_manager_client_; |
| 92 | 92 |
| 93 void LockScreen(test::ScreenLockerTester* tester) { | 93 void LockScreen(test::ScreenLockerTester* tester) { |
| 94 ScreenLocker::Show(); | 94 ScreenLocker::Show(); |
| 95 tester->EmulateWindowManagerReady(); | 95 tester->EmulateWindowManagerReady(); |
| 96 ui_test_utils::WindowedNotificationObserver lock_state_observer( | 96 content::WindowedNotificationObserver lock_state_observer( |
| 97 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, | 97 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, |
| 98 content::NotificationService::AllSources()); | 98 content::NotificationService::AllSources()); |
| 99 if (!tester->IsLocked()) | 99 if (!tester->IsLocked()) |
| 100 lock_state_observer.Wait(); | 100 lock_state_observer.Wait(); |
| 101 EXPECT_TRUE(tester->IsLocked()); | 101 EXPECT_TRUE(tester->IsLocked()); |
| 102 } | 102 } |
| 103 | 103 |
| 104 private: | 104 private: |
| 105 virtual void SetUpInProcessBrowserTestFixture() { | 105 virtual void SetUpInProcessBrowserTestFixture() { |
| 106 MockDBusThreadManager* mock_dbus_thread_manager = | 106 MockDBusThreadManager* mock_dbus_thread_manager = |
| (...skipping 25 matching lines...) Expand all Loading... |
| 132 DISALLOW_COPY_AND_ASSIGN(ScreenLockerTest); | 132 DISALLOW_COPY_AND_ASSIGN(ScreenLockerTest); |
| 133 }; | 133 }; |
| 134 | 134 |
| 135 IN_PROC_BROWSER_TEST_F(ScreenLockerTest, TestBasic) { | 135 IN_PROC_BROWSER_TEST_F(ScreenLockerTest, TestBasic) { |
| 136 EXPECT_CALL(*mock_power_manager_client_, NotifyScreenLockCompleted()) | 136 EXPECT_CALL(*mock_power_manager_client_, NotifyScreenLockCompleted()) |
| 137 .Times(1) | 137 .Times(1) |
| 138 .RetiresOnSaturation(); | 138 .RetiresOnSaturation(); |
| 139 ScreenLocker::Show(); | 139 ScreenLocker::Show(); |
| 140 scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester()); | 140 scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester()); |
| 141 tester->EmulateWindowManagerReady(); | 141 tester->EmulateWindowManagerReady(); |
| 142 ui_test_utils::WindowedNotificationObserver lock_state_observer( | 142 content::WindowedNotificationObserver lock_state_observer( |
| 143 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, | 143 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, |
| 144 content::NotificationService::AllSources()); | 144 content::NotificationService::AllSources()); |
| 145 if (!chromeos::ScreenLocker::GetTester()->IsLocked()) | 145 if (!chromeos::ScreenLocker::GetTester()->IsLocked()) |
| 146 lock_state_observer.Wait(); | 146 lock_state_observer.Wait(); |
| 147 | 147 |
| 148 // Test to make sure that the widget is actually appearing and is of | 148 // Test to make sure that the widget is actually appearing and is of |
| 149 // reasonable size, preventing a regression of | 149 // reasonable size, preventing a regression of |
| 150 // http://code.google.com/p/chromium-os/issues/detail?id=5987 | 150 // http://code.google.com/p/chromium-os/issues/detail?id=5987 |
| 151 gfx::Rect lock_bounds = tester->GetChildWidget()->GetWindowBoundsInScreen(); | 151 gfx::Rect lock_bounds = tester->GetChildWidget()->GetWindowBoundsInScreen(); |
| 152 EXPECT_GT(lock_bounds.width(), 10); | 152 EXPECT_GT(lock_bounds.width(), 10); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 ui_test_utils::RunAllPendingInMessageLoop(); | 245 ui_test_utils::RunAllPendingInMessageLoop(); |
| 246 EXPECT_EQ("", tester->GetPassword()); | 246 EXPECT_EQ("", tester->GetPassword()); |
| 247 | 247 |
| 248 // Close the locker to match expectations. | 248 // Close the locker to match expectations. |
| 249 ScreenLocker::Hide(); | 249 ScreenLocker::Hide(); |
| 250 ui_test_utils::RunAllPendingInMessageLoop(); | 250 ui_test_utils::RunAllPendingInMessageLoop(); |
| 251 EXPECT_FALSE(tester->IsLocked()); | 251 EXPECT_FALSE(tester->IsLocked()); |
| 252 } | 252 } |
| 253 | 253 |
| 254 } // namespace chromeos | 254 } // namespace chromeos |
| OLD | NEW |