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