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

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

Issue 11264017: On active, dismiss the retail mode screensaver immidiately. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed irrelevant test. Created 8 years, 2 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
(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_screensaver.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.h"
11 #include "base/synchronization/waitable_event.h"
12 #include "chrome/browser/chromeos/login/mock_user_manager.h"
13 #include "chrome/common/chrome_notification_types.h"
14 #include "chrome/common/extensions/extension.h"
15 #include "chrome/test/base/testing_browser_process.h"
16 #include "chrome/test/base/testing_profile_manager.h"
17 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/notification_registrar.h"
19 #include "content/public/browser/notification_service.h"
20 #include "content/public/test/test_browser_thread.h"
21 #include "testing/gmock/include/gmock/gmock.h"
22 #include "testing/gtest/include/gtest/gtest.h"
23
24 using content::BrowserThread;
25 using ::testing::_;
26 using ::testing::AnyNumber;
27 using ::testing::Return;
28 using ::testing::SaveArg;
29
30 namespace chromeos {
31
32 class KioskModeScreensaverTest : public ash::test::AshTestBase {
33 public:
34 KioskModeScreensaverTest()
35 : ui_thread_(BrowserThread::UI, message_loop()),
36 file_thread_(BrowserThread::FILE, message_loop()),
37 screensaver_(NULL) {
38 }
39
40 virtual void SetUp() OVERRIDE {
41 // We need this so that the GetDefaultProfile call from within
42 // SetupScreensaver doesn't crash.
43 profile_manager_.reset(new TestingProfileManager(
44 static_cast<TestingBrowserProcess*>(g_browser_process)));
45 ASSERT_TRUE(profile_manager_->SetUp());
46
47 AshTestBase::SetUp();
48 EXPECT_CALL(*mock_user_manager_.user_manager(), IsUserLoggedIn())
49 .Times(AnyNumber())
50 .WillRepeatedly(Return(false));
51
52 screensaver_ = new KioskModeScreensaver();
53 screensaver_->SetupScreensaver(NULL, FilePath());
54 }
55
56 virtual void TearDown() OVERRIDE {
57 delete screensaver_;
58 AshTestBase::TearDown();
59 }
60
61 bool LoginUserObserverRegistered() {
62 return screensaver_->registrar_.IsRegistered(
63 screensaver_,
64 chrome::NOTIFICATION_SESSION_STARTED,
65 content::NotificationService::AllSources());
66 }
67
68 ScopedMockUserManagerEnabler mock_user_manager_;
69
70 content::TestBrowserThread ui_thread_;
71 content::TestBrowserThread file_thread_;
72
73 KioskModeScreensaver* screensaver_;
74 content::NotificationRegistrar registrar_;
75
76 scoped_ptr<TestingProfileManager> profile_manager_;
77 };
78
79 TEST_F(KioskModeScreensaverTest, CheckObservers) {
80 EXPECT_TRUE(LoginUserObserverRegistered());
81 }
82
83 TEST_F(KioskModeScreensaverTest, CheckObserversAfterUserLogin) {
84 content::NotificationService::current()->Notify(
85 chrome::NOTIFICATION_SESSION_STARTED,
86 content::Source<UserManager>(UserManager::Get()),
87 content::NotificationService::NoDetails());
88
89 RunAllPendingInMessageLoop();
90 EXPECT_FALSE(LoginUserObserverRegistered());
91 }
92
93 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698