| OLD | NEW |
| 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/prefs/pref_service.h" | |
| 6 #include "base/run_loop.h" | 5 #include "base/run_loop.h" |
| 7 #include "chrome/browser/extensions/api/gcm/gcm_api.h" | 6 #include "chrome/browser/extensions/api/gcm/gcm_api.h" |
| 8 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
| 9 #include "chrome/browser/extensions/extension_gcm_app_handler.h" | 8 #include "chrome/browser/extensions/extension_gcm_app_handler.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h" | 10 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h" |
| 12 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" | 11 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
| 13 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
| 14 #include "chrome/common/pref_names.h" | |
| 15 #include "chrome/test/base/ui_test_utils.h" | 13 #include "chrome/test/base/ui_test_utils.h" |
| 16 #include "extensions/test/result_catcher.h" | 14 #include "extensions/test/result_catcher.h" |
| 17 | 15 |
| 18 using extensions::ResultCatcher; | 16 using extensions::ResultCatcher; |
| 19 | 17 |
| 20 namespace { | 18 namespace { |
| 21 | 19 |
| 22 const char kEventsExtension[] = "gcm/events"; | 20 const char kEventsExtension[] = "gcm/events"; |
| 23 | 21 |
| 24 gcm::GCMClient::SendErrorDetails CreateErrorDetails( | 22 gcm::GCMClient::SendErrorDetails CreateErrorDetails( |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 // We now always create the GCMProfileService instance in | 76 // We now always create the GCMProfileService instance in |
| 79 // ProfileSyncServiceFactory that is called when a profile is being | 77 // ProfileSyncServiceFactory that is called when a profile is being |
| 80 // initialized. In order to prevent it from being created, we add the switch | 78 // initialized. In order to prevent it from being created, we add the switch |
| 81 // to disable the sync logic. | 79 // to disable the sync logic. |
| 82 command_line->AppendSwitch(switches::kDisableSync); | 80 command_line->AppendSwitch(switches::kDisableSync); |
| 83 | 81 |
| 84 ExtensionApiTest::SetUpCommandLine(command_line); | 82 ExtensionApiTest::SetUpCommandLine(command_line); |
| 85 } | 83 } |
| 86 | 84 |
| 87 void GcmApiTest::SetUpOnMainThread() { | 85 void GcmApiTest::SetUpOnMainThread() { |
| 88 // Enable GCM such that tests could be run on all channels. | |
| 89 browser()->profile()->GetPrefs()->SetBoolean(prefs::kGCMChannelEnabled, true); | |
| 90 | |
| 91 gcm::GCMProfileServiceFactory::GetInstance()->SetTestingFactory( | 86 gcm::GCMProfileServiceFactory::GetInstance()->SetTestingFactory( |
| 92 browser()->profile(), &gcm::FakeGCMProfileService::Build); | 87 browser()->profile(), &gcm::FakeGCMProfileService::Build); |
| 93 fake_gcm_profile_service_ = static_cast<gcm::FakeGCMProfileService*>( | 88 fake_gcm_profile_service_ = static_cast<gcm::FakeGCMProfileService*>( |
| 94 gcm::GCMProfileServiceFactory::GetInstance()->GetForProfile( | 89 gcm::GCMProfileServiceFactory::GetInstance()->GetForProfile( |
| 95 browser()->profile())); | 90 browser()->profile())); |
| 96 | 91 |
| 97 ExtensionApiTest::SetUpOnMainThread(); | 92 ExtensionApiTest::SetUpOnMainThread(); |
| 98 } | 93 } |
| 99 | 94 |
| 100 void GcmApiTest::StartCollecting() { | 95 void GcmApiTest::StartCollecting() { |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 incognito_catcher.RestrictToBrowserContext( | 260 incognito_catcher.RestrictToBrowserContext( |
| 266 profile()->GetOffTheRecordProfile()); | 261 profile()->GetOffTheRecordProfile()); |
| 267 | 262 |
| 268 ASSERT_TRUE(RunExtensionTestIncognito("gcm/functions/incognito")); | 263 ASSERT_TRUE(RunExtensionTestIncognito("gcm/functions/incognito")); |
| 269 | 264 |
| 270 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 265 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 271 EXPECT_TRUE(incognito_catcher.GetNextResult()) << incognito_catcher.message(); | 266 EXPECT_TRUE(incognito_catcher.GetNextResult()) << incognito_catcher.message(); |
| 272 } | 267 } |
| 273 | 268 |
| 274 } // namespace extensions | 269 } // namespace extensions |
| OLD | NEW |