OLD | NEW |
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> |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 } // namespace | 82 } // namespace |
83 | 83 |
84 class PushMessagingServiceTest : public ::testing::Test { | 84 class PushMessagingServiceTest : public ::testing::Test { |
85 public: | 85 public: |
86 PushMessagingServiceTest() { | 86 PushMessagingServiceTest() { |
87 // Always allow push notifications in the profile. | 87 // Always allow push notifications in the profile. |
88 HostContentSettingsMap* host_content_settings_map = | 88 HostContentSettingsMap* host_content_settings_map = |
89 HostContentSettingsMapFactory::GetForProfile(&profile_); | 89 HostContentSettingsMapFactory::GetForProfile(&profile_); |
90 host_content_settings_map->SetDefaultContentSetting( | 90 host_content_settings_map->SetDefaultContentSetting( |
91 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, CONTENT_SETTING_ALLOW); | 91 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, CONTENT_SETTING_ALLOW); |
92 host_content_settings_map->SetDefaultContentSetting( | |
93 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, CONTENT_SETTING_ALLOW); | |
94 | 92 |
95 // Override the GCM Profile service so that we can send fake messages. | 93 // Override the GCM Profile service so that we can send fake messages. |
96 gcm::GCMProfileServiceFactory::GetInstance()->SetTestingFactory( | 94 gcm::GCMProfileServiceFactory::GetInstance()->SetTestingFactory( |
97 &profile_, &BuildFakeGCMProfileService); | 95 &profile_, &BuildFakeGCMProfileService); |
98 } | 96 } |
99 | 97 |
100 ~PushMessagingServiceTest() override {} | 98 ~PushMessagingServiceTest() override {} |
101 | 99 |
102 // Callback to use when the subscription may have been subscribed. | 100 // Callback to use when the subscription may have been subscribed. |
103 void DidRegister(std::string* subscription_id_out, | 101 void DidRegister(std::string* subscription_id_out, |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 } | 242 } |
245 | 243 |
246 TEST_F(PushMessagingServiceTest, DifferentEndpoints) { | 244 TEST_F(PushMessagingServiceTest, DifferentEndpoints) { |
247 PushMessagingServiceImpl* push_service = profile()->GetPushMessagingService(); | 245 PushMessagingServiceImpl* push_service = profile()->GetPushMessagingService(); |
248 ASSERT_TRUE(push_service); | 246 ASSERT_TRUE(push_service); |
249 | 247 |
250 // Verifies that the service returns different endpoints depending on whether | 248 // Verifies that the service returns different endpoints depending on whether |
251 // support for the standard protocol is requested. | 249 // support for the standard protocol is requested. |
252 EXPECT_NE(push_service->GetEndpoint(true), push_service->GetEndpoint(false)); | 250 EXPECT_NE(push_service->GetEndpoint(true), push_service->GetEndpoint(false)); |
253 } | 251 } |
OLD | NEW |