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

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

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

Powered by Google App Engine
This is Rietveld 408576698