| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_idle_logout.h" | |
| 6 | |
| 7 #include "ash/test/ash_test_base.h" | |
| 8 #include "base/bind.h" | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/message_loop/message_loop.h" | |
| 11 #include "base/synchronization/waitable_event.h" | |
| 12 #include "chrome/browser/chrome_notification_types.h" | |
| 13 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" | |
| 14 #include "components/user_manager/user_manager.h" | |
| 15 #include "content/public/browser/notification_registrar.h" | |
| 16 #include "content/public/browser/notification_service.h" | |
| 17 #include "testing/gtest/include/gtest/gtest.h" | |
| 18 #include "ui/wm/core/user_activity_detector.h" | |
| 19 | |
| 20 namespace chromeos { | |
| 21 | |
| 22 class KioskModeIdleLogoutTest : public ash::test::AshTestBase { | |
| 23 public: | |
| 24 KioskModeIdleLogoutTest() | |
| 25 : idle_logout_(NULL) { | |
| 26 } | |
| 27 | |
| 28 virtual void SetUp() override { | |
| 29 AshTestBase::SetUp(); | |
| 30 idle_logout_ = new KioskModeIdleLogout(); | |
| 31 } | |
| 32 | |
| 33 virtual void TearDown() override { | |
| 34 delete idle_logout_; | |
| 35 AshTestBase::TearDown(); | |
| 36 } | |
| 37 | |
| 38 bool LoginUserObserverRegistered() { | |
| 39 return idle_logout_->registrar_.IsRegistered( | |
| 40 idle_logout_, | |
| 41 chrome::NOTIFICATION_LOGIN_USER_CHANGED, | |
| 42 content::NotificationService::AllSources()); | |
| 43 } | |
| 44 | |
| 45 bool UserActivityObserverRegistered() { | |
| 46 return wm::UserActivityDetector::Get()->HasObserver(idle_logout_); | |
| 47 } | |
| 48 | |
| 49 ScopedDeviceSettingsTestHelper device_settings_test_helper_; | |
| 50 | |
| 51 KioskModeIdleLogout* idle_logout_; | |
| 52 content::NotificationRegistrar registrar_; | |
| 53 }; | |
| 54 | |
| 55 // http://crbug.com/177918 | |
| 56 TEST_F(KioskModeIdleLogoutTest, DISABLED_CheckObserversBeforeUserLogin) { | |
| 57 EXPECT_TRUE(LoginUserObserverRegistered()); | |
| 58 EXPECT_FALSE(UserActivityObserverRegistered()); | |
| 59 } | |
| 60 | |
| 61 // http://crbug.com/177918 | |
| 62 TEST_F(KioskModeIdleLogoutTest, DISABLED_CheckObserversAfterUserLogin) { | |
| 63 content::NotificationService::current()->Notify( | |
| 64 chrome::NOTIFICATION_LOGIN_USER_CHANGED, | |
| 65 content::Source<user_manager::UserManager>( | |
| 66 user_manager::UserManager::Get()), | |
| 67 // Ideally this should be the user logged in, but since we won't really be | |
| 68 // checking for the current logged in user in our observer anyway, giving | |
| 69 // NoDetails here is fine. | |
| 70 content::NotificationService::NoDetails()); | |
| 71 | |
| 72 RunAllPendingInMessageLoop(); | |
| 73 EXPECT_FALSE(LoginUserObserverRegistered()); | |
| 74 EXPECT_TRUE(UserActivityObserverRegistered()); | |
| 75 } | |
| 76 | |
| 77 } // namespace chromeos | |
| OLD | NEW |