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

Side by Side Diff: chrome/browser/chromeos/kiosk_mode/kiosk_mode_idle_logout_unittest.cc

Issue 10832035: Switch from SignedSettings to DeviceSettingsService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
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"
13 #include "chrome/common/chrome_notification_types.h" 14 #include "chrome/common/chrome_notification_types.h"
14 #include "chromeos/dbus/dbus_thread_manager.h" 15 #include "chromeos/dbus/dbus_thread_manager.h"
15 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
16 #include "content/public/browser/notification_registrar.h" 17 #include "content/public/browser/notification_registrar.h"
17 #include "content/public/browser/notification_service.h" 18 #include "content/public/browser/notification_service.h"
18 #include "content/public/test/test_browser_thread.h" 19 #include "content/public/test/test_browser_thread.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 21
21 using content::BrowserThread; 22 using content::BrowserThread;
22 23
(...skipping 26 matching lines...) Expand all
49 } 50 }
50 51
51 bool PowerManagerObserverRegistered() { 52 bool PowerManagerObserverRegistered() {
52 chromeos::PowerManagerClient* power_manager = 53 chromeos::PowerManagerClient* power_manager =
53 chromeos::DBusThreadManager::Get()->GetPowerManagerClient(); 54 chromeos::DBusThreadManager::Get()->GetPowerManagerClient();
54 return power_manager->HasObserver(idle_logout_); 55 return power_manager->HasObserver(idle_logout_);
55 } 56 }
56 57
57 content::TestBrowserThread ui_thread_; 58 content::TestBrowserThread ui_thread_;
58 59
60 ScopedDeviceSettingsTestHelper device_settings_test_helper_;
61
59 KioskModeIdleLogout* idle_logout_; 62 KioskModeIdleLogout* idle_logout_;
60 content::NotificationRegistrar registrar_; 63 content::NotificationRegistrar registrar_;
61 }; 64 };
62 65
63 TEST_F(KioskModeIdleLogoutTest, CheckObserversBeforeUserLogin) { 66 TEST_F(KioskModeIdleLogoutTest, CheckObserversBeforeUserLogin) {
64 EXPECT_TRUE(LoginUserObserverRegistered()); 67 EXPECT_TRUE(LoginUserObserverRegistered());
65 EXPECT_FALSE(PowerManagerObserverRegistered()); 68 EXPECT_FALSE(PowerManagerObserverRegistered());
66 } 69 }
67 70
68 TEST_F(KioskModeIdleLogoutTest, CheckObserversAfterUserLogin) { 71 TEST_F(KioskModeIdleLogoutTest, CheckObserversAfterUserLogin) {
69 content::NotificationService::current()->Notify( 72 content::NotificationService::current()->Notify(
70 chrome::NOTIFICATION_LOGIN_USER_CHANGED, 73 chrome::NOTIFICATION_LOGIN_USER_CHANGED,
71 content::Source<UserManager>(UserManager::Get()), 74 content::Source<UserManager>(UserManager::Get()),
72 // Ideally this should be the user logged in, but since we won't really be 75 // Ideally this should be the user logged in, but since we won't really be
73 // checking for the current logged in user in our observer anyway, giving 76 // checking for the current logged in user in our observer anyway, giving
74 // NoDetails here is fine. 77 // NoDetails here is fine.
75 content::NotificationService::NoDetails()); 78 content::NotificationService::NoDetails());
76 79
77 RunAllPendingInMessageLoop(); 80 RunAllPendingInMessageLoop();
78 EXPECT_FALSE(LoginUserObserverRegistered()); 81 EXPECT_FALSE(LoginUserObserverRegistered());
79 EXPECT_TRUE(PowerManagerObserverRegistered()); 82 EXPECT_TRUE(PowerManagerObserverRegistered());
80 } 83 }
81 84
82 } // namespace chromeos 85 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698