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

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

Issue 17127002: Correctly integrate StoragePartition into TestingProfile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix InstantNTP test. Created 7 years, 5 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/shell.h" 7 #include "ash/shell.h"
8 #include "ash/test/ash_test_base.h" 8 #include "ash/test/ash_test_base.h"
9 #include "ash/wm/user_activity_detector.h" 9 #include "ash/wm/user_activity_detector.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/synchronization/waitable_event.h" 13 #include "base/synchronization/waitable_event.h"
14 #include "chrome/browser/chrome_notification_types.h" 14 #include "chrome/browser/chrome_notification_types.h"
15 #include "chrome/browser/chromeos/login/user_manager.h" 15 #include "chrome/browser/chromeos/login/user_manager.h"
16 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" 16 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h"
17 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/notification_registrar.h" 18 #include "content/public/browser/notification_registrar.h"
19 #include "content/public/browser/notification_service.h" 19 #include "content/public/browser/notification_service.h"
20 #include "content/public/test/test_browser_thread.h"
21 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
22 21
23 using content::BrowserThread;
24
25 namespace chromeos { 22 namespace chromeos {
26 23
27 class KioskModeIdleLogoutTest : public ash::test::AshTestBase { 24 class KioskModeIdleLogoutTest : public ash::test::AshTestBase {
28 public: 25 public:
29 KioskModeIdleLogoutTest() 26 KioskModeIdleLogoutTest()
30 : ui_thread_(BrowserThread::UI, message_loop()), 27 : idle_logout_(NULL) {
31 idle_logout_(NULL) {
32 } 28 }
33 29
34 virtual void SetUp() OVERRIDE { 30 virtual void SetUp() OVERRIDE {
35 AshTestBase::SetUp(); 31 AshTestBase::SetUp();
36 idle_logout_ = new KioskModeIdleLogout(); 32 idle_logout_ = new KioskModeIdleLogout();
37 } 33 }
38 34
39 virtual void TearDown() OVERRIDE { 35 virtual void TearDown() OVERRIDE {
40 delete idle_logout_; 36 delete idle_logout_;
41 AshTestBase::TearDown(); 37 AshTestBase::TearDown();
42 } 38 }
43 39
44 bool LoginUserObserverRegistered() { 40 bool LoginUserObserverRegistered() {
45 return idle_logout_->registrar_.IsRegistered( 41 return idle_logout_->registrar_.IsRegistered(
46 idle_logout_, 42 idle_logout_,
47 chrome::NOTIFICATION_LOGIN_USER_CHANGED, 43 chrome::NOTIFICATION_LOGIN_USER_CHANGED,
48 content::NotificationService::AllSources()); 44 content::NotificationService::AllSources());
49 } 45 }
50 46
51 bool UserActivityObserverRegistered() { 47 bool UserActivityObserverRegistered() {
52 return ash::Shell::GetInstance()->user_activity_detector()->HasObserver( 48 return ash::Shell::GetInstance()->user_activity_detector()->HasObserver(
53 idle_logout_); 49 idle_logout_);
54 } 50 }
55 51
56 content::TestBrowserThread ui_thread_;
57
58 ScopedDeviceSettingsTestHelper device_settings_test_helper_; 52 ScopedDeviceSettingsTestHelper device_settings_test_helper_;
59 53
60 KioskModeIdleLogout* idle_logout_; 54 KioskModeIdleLogout* idle_logout_;
61 content::NotificationRegistrar registrar_; 55 content::NotificationRegistrar registrar_;
62 }; 56 };
63 57
64 // http://crbug.com/177918 58 // http://crbug.com/177918
65 TEST_F(KioskModeIdleLogoutTest, DISABLED_CheckObserversBeforeUserLogin) { 59 TEST_F(KioskModeIdleLogoutTest, DISABLED_CheckObserversBeforeUserLogin) {
66 EXPECT_TRUE(LoginUserObserverRegistered()); 60 EXPECT_TRUE(LoginUserObserverRegistered());
67 EXPECT_FALSE(UserActivityObserverRegistered()); 61 EXPECT_FALSE(UserActivityObserverRegistered());
68 } 62 }
69 63
70 // http://crbug.com/177918 64 // http://crbug.com/177918
71 TEST_F(KioskModeIdleLogoutTest, DISABLED_CheckObserversAfterUserLogin) { 65 TEST_F(KioskModeIdleLogoutTest, DISABLED_CheckObserversAfterUserLogin) {
72 content::NotificationService::current()->Notify( 66 content::NotificationService::current()->Notify(
73 chrome::NOTIFICATION_LOGIN_USER_CHANGED, 67 chrome::NOTIFICATION_LOGIN_USER_CHANGED,
74 content::Source<UserManager>(UserManager::Get()), 68 content::Source<UserManager>(UserManager::Get()),
75 // Ideally this should be the user logged in, but since we won't really be 69 // 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 70 // checking for the current logged in user in our observer anyway, giving
77 // NoDetails here is fine. 71 // NoDetails here is fine.
78 content::NotificationService::NoDetails()); 72 content::NotificationService::NoDetails());
79 73
80 RunAllPendingInMessageLoop(); 74 RunAllPendingInMessageLoop();
81 EXPECT_FALSE(LoginUserObserverRegistered()); 75 EXPECT_FALSE(LoginUserObserverRegistered());
82 EXPECT_TRUE(UserActivityObserverRegistered()); 76 EXPECT_TRUE(UserActivityObserverRegistered());
83 } 77 }
84 78
85 } // namespace chromeos 79 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698