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

Side by Side Diff: chrome/browser/invalidation/invalidation_service_factory_browsertest.cc

Issue 327243003: Introduce ProfileInvalidationProvider wrapper for InvalidationService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix clang compilation. Created 6 years, 6 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 2014 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 "base/basictypes.h"
6 #include "base/command_line.h"
7 #include "base/compiler_specific.h"
8 #include "chrome/browser/chromeos/login/users/user_manager.h"
9 #include "chrome/browser/chromeos/profiles/profile_helper.h"
10 #include "chrome/browser/invalidation/invalidation_service_factory.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/test/base/in_process_browser_test.h"
14 #include "chromeos/chromeos_switches.h"
15 #include "components/invalidation/invalidation_service.h"
16 #include "testing/gtest/include/gtest/gtest.h"
17
18 namespace invalidation {
19
20 class InvalidationServiceFactoryTestBase : public InProcessBrowserTest {
21 protected:
22 InvalidationServiceFactoryTestBase();
23 virtual ~InvalidationServiceFactoryTestBase();
24
25 InvalidationService* FindInvalidationServiceForProfile(Profile* profile);
26
27 private:
28 DISALLOW_COPY_AND_ASSIGN(InvalidationServiceFactoryTestBase);
29 };
30
31 InvalidationServiceFactoryTestBase::InvalidationServiceFactoryTestBase() {
32 }
33
34 InvalidationServiceFactoryTestBase::~InvalidationServiceFactoryTestBase() {
35 }
36
37 InvalidationService*
38 InvalidationServiceFactoryTestBase::FindInvalidationServiceForProfile(
39 Profile* profile) {
40 return static_cast<InvalidationService*>(
41 InvalidationServiceFactory::GetInstance()->GetServiceForBrowserContext(
42 profile, false));
43 }
44
45 class InvalidationServiceFactoryLoginScreenBrowserTest
46 : public InvalidationServiceFactoryTestBase {
47 protected:
48 InvalidationServiceFactoryLoginScreenBrowserTest();
49 virtual ~InvalidationServiceFactoryLoginScreenBrowserTest();
50
51 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
52
53 private:
54 DISALLOW_COPY_AND_ASSIGN(InvalidationServiceFactoryLoginScreenBrowserTest);
55 };
56
57 InvalidationServiceFactoryLoginScreenBrowserTest::
58 InvalidationServiceFactoryLoginScreenBrowserTest() {
59 }
60
61 InvalidationServiceFactoryLoginScreenBrowserTest::
62 ~InvalidationServiceFactoryLoginScreenBrowserTest() {
63 }
64
65 void InvalidationServiceFactoryLoginScreenBrowserTest::SetUpCommandLine(
66 CommandLine* command_line) {
67 command_line->AppendSwitch(chromeos::switches::kLoginManager);
68 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user");
69 }
70
71 // Verify that no InvalidationService is instantiated for the login profile on
72 // the login screen.
73 IN_PROC_BROWSER_TEST_F(InvalidationServiceFactoryLoginScreenBrowserTest,
74 NoInvalidationService) {
75 Profile* login_profile =
76 chromeos::ProfileHelper::GetSigninProfile()->GetOriginalProfile();
77 EXPECT_FALSE(FindInvalidationServiceForProfile(login_profile));
78 }
79
80 class InvalidationServiceFactoryGuestBrowserTest
81 : public InvalidationServiceFactoryTestBase {
82 protected:
83 InvalidationServiceFactoryGuestBrowserTest();
84 virtual ~InvalidationServiceFactoryGuestBrowserTest();
85
86 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
87
88 private:
89 DISALLOW_COPY_AND_ASSIGN(InvalidationServiceFactoryGuestBrowserTest);
90 };
91
92 InvalidationServiceFactoryGuestBrowserTest::
93 InvalidationServiceFactoryGuestBrowserTest() {
94 }
95
96 InvalidationServiceFactoryGuestBrowserTest::
97 ~InvalidationServiceFactoryGuestBrowserTest() {
98 }
99
100 void InvalidationServiceFactoryGuestBrowserTest::SetUpCommandLine(
101 CommandLine* command_line) {
102 command_line->AppendSwitch(chromeos::switches::kGuestSession);
103 command_line->AppendSwitch(::switches::kIncognito);
104 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user");
105 command_line->AppendSwitchASCII(chromeos::switches::kLoginUser,
106 chromeos::UserManager::kGuestUserName);
107 }
108
109 // Verify that no InvalidationService is instantiated for the login profile or
110 // the guest profile while a guest session is in progress.
111 IN_PROC_BROWSER_TEST_F(InvalidationServiceFactoryGuestBrowserTest,
112 NoInvalidationService) {
113 chromeos::UserManager* user_manager = chromeos::UserManager::Get();
114 EXPECT_TRUE(user_manager->IsLoggedInAsGuest());
115 Profile* guest_profile = user_manager->GetProfileByUser(
116 user_manager->GetActiveUser())->GetOriginalProfile();
117 Profile* login_profile =
118 chromeos::ProfileHelper::GetSigninProfile()->GetOriginalProfile();
119 EXPECT_FALSE(FindInvalidationServiceForProfile(guest_profile));
120 EXPECT_FALSE(FindInvalidationServiceForProfile(login_profile));
121 }
122
123 } // namespace invalidation
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698