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

Side by Side Diff: chrome/browser/push_messaging/push_messaging_service_unittest.cc

Issue 2122603007: Move FakeGCMProfileService to components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixup ifndef header guard Created 4 years, 5 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/public/browser/push_messaging_service.h" 5 #include "content/public/browser/push_messaging_service.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "base/threading/thread_task_runner_handle.h" 15 #include "base/threading/thread_task_runner_handle.h"
16 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 16 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
17 #include "chrome/browser/permissions/permission_manager.h" 17 #include "chrome/browser/permissions/permission_manager.h"
18 #include "chrome/browser/permissions/permission_manager_factory.h" 18 #include "chrome/browser/permissions/permission_manager_factory.h"
19 #include "chrome/browser/push_messaging/push_messaging_app_identifier.h" 19 #include "chrome/browser/push_messaging/push_messaging_app_identifier.h"
20 #include "chrome/browser/push_messaging/push_messaging_permission_context.h" 20 #include "chrome/browser/push_messaging/push_messaging_permission_context.h"
21 #include "chrome/browser/push_messaging/push_messaging_service_factory.h" 21 #include "chrome/browser/push_messaging/push_messaging_service_factory.h"
22 #include "chrome/browser/push_messaging/push_messaging_service_impl.h" 22 #include "chrome/browser/push_messaging/push_messaging_service_impl.h"
23 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h"
24 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" 23 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
25 #include "chrome/test/base/testing_profile.h" 24 #include "chrome/test/base/testing_profile.h"
26 #include "components/content_settings/core/browser/host_content_settings_map.h" 25 #include "components/content_settings/core/browser/host_content_settings_map.h"
27 #include "components/gcm_driver/crypto/gcm_crypto_test_helpers.h" 26 #include "components/gcm_driver/crypto/gcm_crypto_test_helpers.h"
28 #include "components/gcm_driver/fake_gcm_client_factory.h" 27 #include "components/gcm_driver/fake_gcm_client_factory.h"
28 #include "components/gcm_driver/fake_gcm_profile_service.h"
29 #include "components/gcm_driver/gcm_profile_service.h" 29 #include "components/gcm_driver/gcm_profile_service.h"
30 #include "content/public/common/push_event_payload.h" 30 #include "content/public/common/push_event_payload.h"
31 #include "content/public/common/push_subscription_options.h" 31 #include "content/public/common/push_subscription_options.h"
32 #include "content/public/test/test_browser_thread_bundle.h" 32 #include "content/public/test/test_browser_thread_bundle.h"
33 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
34 34
35 namespace { 35 namespace {
36 36
37 const char kTestOrigin[] = "https://example.com"; 37 const char kTestOrigin[] = "https://example.com";
38 const char kTestSenderId[] = "1234567890"; 38 const char kTestSenderId[] = "1234567890";
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 PermissionManager* GetPermissionManager() override { 70 PermissionManager* GetPermissionManager() override {
71 return PermissionManagerFactory::GetForProfile(this); 71 return PermissionManagerFactory::GetForProfile(this);
72 } 72 }
73 73
74 private: 74 private:
75 DISALLOW_COPY_AND_ASSIGN(PushMessagingTestingProfile); 75 DISALLOW_COPY_AND_ASSIGN(PushMessagingTestingProfile);
76 }; 76 };
77 77
78 std::unique_ptr<KeyedService> BuildFakeGCMProfileService( 78 std::unique_ptr<KeyedService> BuildFakeGCMProfileService(
79 content::BrowserContext* context) { 79 content::BrowserContext* context) {
80 return gcm::FakeGCMProfileService::Build(static_cast<Profile*>(context)); 80 return gcm::FakeGCMProfileService::Build(context);
81 } 81 }
82 82
83 } // namespace 83 } // namespace
84 84
85 class PushMessagingServiceTest : public ::testing::Test { 85 class PushMessagingServiceTest : public ::testing::Test {
86 public: 86 public:
87 PushMessagingServiceTest() { 87 PushMessagingServiceTest() {
88 // Always allow push notifications in the profile. 88 // Always allow push notifications in the profile.
89 HostContentSettingsMap* host_content_settings_map = 89 HostContentSettingsMap* host_content_settings_map =
90 HostContentSettingsMapFactory::GetForProfile(&profile_); 90 HostContentSettingsMapFactory::GetForProfile(&profile_);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 } 245 }
246 246
247 TEST_F(PushMessagingServiceTest, DifferentEndpoints) { 247 TEST_F(PushMessagingServiceTest, DifferentEndpoints) {
248 PushMessagingServiceImpl* push_service = profile()->GetPushMessagingService(); 248 PushMessagingServiceImpl* push_service = profile()->GetPushMessagingService();
249 ASSERT_TRUE(push_service); 249 ASSERT_TRUE(push_service);
250 250
251 // Verifies that the service returns different endpoints depending on whether 251 // Verifies that the service returns different endpoints depending on whether
252 // support for the standard protocol is requested. 252 // support for the standard protocol is requested.
253 EXPECT_NE(push_service->GetEndpoint(true), push_service->GetEndpoint(false)); 253 EXPECT_NE(push_service->GetEndpoint(true), push_service->GetEndpoint(false));
254 } 254 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698