| 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 "chrome/browser/chromeos/kiosk_mode/kiosk_mode_idle_logout.h" | 5 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_idle_logout.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
| 11 #include "chrome/browser/chromeos/login/user_manager.h" | 11 #include "chrome/browser/chromeos/login/user_manager.h" |
| 12 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" |
| 12 #include "chrome/common/chrome_notification_types.h" | 13 #include "chrome/common/chrome_notification_types.h" |
| 13 #include "chromeos/dbus/dbus_thread_manager.h" | 14 #include "chromeos/dbus/dbus_thread_manager.h" |
| 14 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 15 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
| 16 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
| 17 #include "content/public/test/test_browser_thread.h" | 18 #include "content/public/test/test_browser_thread.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 20 |
| 20 using content::BrowserThread; | 21 using content::BrowserThread; |
| 21 | 22 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 47 | 48 |
| 48 bool PowerManagerObserverRegistered() { | 49 bool PowerManagerObserverRegistered() { |
| 49 chromeos::PowerManagerClient* power_manager = | 50 chromeos::PowerManagerClient* power_manager = |
| 50 chromeos::DBusThreadManager::Get()->GetPowerManagerClient(); | 51 chromeos::DBusThreadManager::Get()->GetPowerManagerClient(); |
| 51 return power_manager->HasObserver(idle_logout_); | 52 return power_manager->HasObserver(idle_logout_); |
| 52 } | 53 } |
| 53 | 54 |
| 54 MessageLoopForUI message_loop_; | 55 MessageLoopForUI message_loop_; |
| 55 content::TestBrowserThread ui_thread_; | 56 content::TestBrowserThread ui_thread_; |
| 56 | 57 |
| 58 ScopedDeviceSettingsTestHelper device_settings_test_helper_; |
| 59 |
| 57 KioskModeIdleLogout* idle_logout_; | 60 KioskModeIdleLogout* idle_logout_; |
| 58 content::NotificationRegistrar registrar_; | 61 content::NotificationRegistrar registrar_; |
| 59 }; | 62 }; |
| 60 | 63 |
| 61 TEST_F(KioskModeIdleLogoutTest, CheckObserversBeforeUserLogin) { | 64 TEST_F(KioskModeIdleLogoutTest, CheckObserversBeforeUserLogin) { |
| 62 EXPECT_TRUE(LoginUserObserverRegistered()); | 65 EXPECT_TRUE(LoginUserObserverRegistered()); |
| 63 EXPECT_FALSE(PowerManagerObserverRegistered()); | 66 EXPECT_FALSE(PowerManagerObserverRegistered()); |
| 64 } | 67 } |
| 65 | 68 |
| 66 TEST_F(KioskModeIdleLogoutTest, CheckObserversAfterUserLogin) { | 69 TEST_F(KioskModeIdleLogoutTest, CheckObserversAfterUserLogin) { |
| 67 content::NotificationService::current()->Notify( | 70 content::NotificationService::current()->Notify( |
| 68 chrome::NOTIFICATION_LOGIN_USER_CHANGED, | 71 chrome::NOTIFICATION_LOGIN_USER_CHANGED, |
| 69 content::Source<UserManager>(UserManager::Get()), | 72 content::Source<UserManager>(UserManager::Get()), |
| 70 // Ideally this should be the user logged in, but since we won't really be | 73 // Ideally this should be the user logged in, but since we won't really be |
| 71 // checking for the current logged in user in our observer anyway, giving | 74 // checking for the current logged in user in our observer anyway, giving |
| 72 // NoDetails here is fine. | 75 // NoDetails here is fine. |
| 73 content::NotificationService::NoDetails()); | 76 content::NotificationService::NoDetails()); |
| 74 | 77 |
| 75 EXPECT_TRUE(PowerManagerObserverRegistered()); | 78 EXPECT_TRUE(PowerManagerObserverRegistered()); |
| 76 } | 79 } |
| 77 | 80 |
| 78 } // namespace chromeos | 81 } // namespace chromeos |
| OLD | NEW |