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

Side by Side Diff: chrome/browser/extensions/api/gcm/gcm_apitest.cc

Issue 184273011: Merge 253787 "[GCM] Make sure GCM checkout logic is invoked when..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1847/src/
Patch Set: Created 6 years, 9 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/run_loop.h" 5 #include "base/run_loop.h"
6 #include "chrome/browser/extensions/api/gcm/gcm_api.h" 6 #include "chrome/browser/extensions/api/gcm/gcm_api.h"
7 #include "chrome/browser/extensions/extension_apitest.h" 7 #include "chrome/browser/extensions/extension_apitest.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h" 9 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h"
10 #include "chrome/browser/services/gcm/gcm_client_factory.h" 10 #include "chrome/browser/services/gcm/gcm_client_factory.h"
11 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" 11 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
12 #include "chrome/common/chrome_switches.h"
12 #include "chrome/common/extensions/features/feature_channel.h" 13 #include "chrome/common/extensions/features/feature_channel.h"
13 #include "chrome/test/base/ui_test_utils.h" 14 #include "chrome/test/base/ui_test_utils.h"
14 15
15 namespace { 16 namespace {
16 17
17 const char kEventsExtension[] = "gcm/events"; 18 const char kEventsExtension[] = "gcm/events";
18 19
19 } // namespace 20 } // namespace
20 21
21 namespace extensions { 22 namespace extensions {
22 23
23 class GcmApiTest : public ExtensionApiTest { 24 class GcmApiTest : public ExtensionApiTest {
24 public: 25 public:
25 GcmApiTest() : fake_gcm_profile_service_(NULL) {} 26 GcmApiTest() : fake_gcm_profile_service_(NULL) {}
26 27
27 protected: 28 protected:
29 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
28 virtual void SetUpOnMainThread() OVERRIDE; 30 virtual void SetUpOnMainThread() OVERRIDE;
29 31
30 void StartCollecting(); 32 void StartCollecting();
31 33
32 const Extension* LoadTestExtension(const std::string& extension_path, 34 const Extension* LoadTestExtension(const std::string& extension_path,
33 const std::string& page_name); 35 const std::string& page_name);
34 gcm::FakeGCMProfileService* service() const; 36 gcm::FakeGCMProfileService* service() const;
35 bool ShouldSkipTest() const; 37 bool ShouldSkipTest() const;
36 38
37 private: 39 private:
38 gcm::FakeGCMProfileService* fake_gcm_profile_service_; 40 gcm::FakeGCMProfileService* fake_gcm_profile_service_;
39 }; 41 };
40 42
43 void GcmApiTest::SetUpCommandLine(CommandLine* command_line) {
44 // We now always create the GCMProfileService instance in
45 // ProfileSyncServiceFactory that is called when a profile is being
46 // initialized. In order to prevent it from being created, we add the switch
47 // to disable the sync logic.
48 command_line->AppendSwitch(switches::kDisableSync);
49
50 ExtensionApiTest::SetUpCommandLine(command_line);
51 }
52
41 void GcmApiTest::SetUpOnMainThread() { 53 void GcmApiTest::SetUpOnMainThread() {
42 gcm::GCMProfileServiceFactory::GetInstance()->SetTestingFactory( 54 gcm::GCMProfileServiceFactory::GetInstance()->SetTestingFactory(
43 browser()->profile(), &gcm::FakeGCMProfileService::Build); 55 browser()->profile(), &gcm::FakeGCMProfileService::Build);
44 fake_gcm_profile_service_ = static_cast<gcm::FakeGCMProfileService*>( 56 fake_gcm_profile_service_ = static_cast<gcm::FakeGCMProfileService*>(
45 gcm::GCMProfileServiceFactory::GetInstance()->GetForProfile( 57 gcm::GCMProfileServiceFactory::GetInstance()->GetForProfile(
46 browser()->profile())); 58 browser()->profile()));
47 gcm::FakeGCMProfileService::EnableGCMForTesting(); 59
60 ExtensionApiTest::SetUpOnMainThread();
48 } 61 }
49 62
50 void GcmApiTest::StartCollecting() { 63 void GcmApiTest::StartCollecting() {
51 service()->set_collect(true); 64 service()->set_collect(true);
52 } 65 }
53 66
54 gcm::FakeGCMProfileService* GcmApiTest::service() const { 67 gcm::FakeGCMProfileService* GcmApiTest::service() const {
55 return fake_gcm_profile_service_; 68 return fake_gcm_profile_service_;
56 } 69 }
57 70
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 ResultCatcher incognito_catcher; 210 ResultCatcher incognito_catcher;
198 incognito_catcher.RestrictToProfile(profile()->GetOffTheRecordProfile()); 211 incognito_catcher.RestrictToProfile(profile()->GetOffTheRecordProfile());
199 212
200 ASSERT_TRUE(RunExtensionTestIncognito("gcm/functions/incognito")); 213 ASSERT_TRUE(RunExtensionTestIncognito("gcm/functions/incognito"));
201 214
202 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 215 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
203 EXPECT_TRUE(incognito_catcher.GetNextResult()) << incognito_catcher.message(); 216 EXPECT_TRUE(incognito_catcher.GetNextResult()) << incognito_catcher.message();
204 } 217 }
205 218
206 } // namespace extensions 219 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/gcm/gcm_api.cc ('k') | chrome/browser/services/gcm/fake_gcm_profile_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698