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

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

Issue 1701313002: Partial implementation of subscription restrictions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added testing and integrated previous comments. Created 4 years, 10 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>
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 151
152 // (1) Make sure that |kExampleOrigin| has access to use Push Messaging. 152 // (1) Make sure that |kExampleOrigin| has access to use Push Messaging.
153 ASSERT_EQ(blink::WebPushPermissionStatusGranted, 153 ASSERT_EQ(blink::WebPushPermissionStatusGranted,
154 push_service->GetPermissionStatus(origin, origin, true)); 154 push_service->GetPermissionStatus(origin, origin, true));
155 155
156 std::string subscription_id; 156 std::string subscription_id;
157 std::vector<uint8_t> p256dh, auth; 157 std::vector<uint8_t> p256dh, auth;
158 158
159 // (2) Subscribe for Push Messaging, and verify that we've got the required 159 // (2) Subscribe for Push Messaging, and verify that we've got the required
160 // information in order to be able to create encrypted messages. 160 // information in order to be able to create encrypted messages.
161 content::PushSubscriptionOptions options;
162 options.user_visible_only = true;
163 options.sender_info = kTestSenderId;
161 push_service->SubscribeFromWorker( 164 push_service->SubscribeFromWorker(
162 origin, kTestServiceWorkerId, kTestSenderId, true /* user_visible */, 165 origin, kTestServiceWorkerId, options,
163 base::Bind(&PushMessagingServiceTest::DidRegister, base::Unretained(this), 166 base::Bind(&PushMessagingServiceTest::DidRegister, base::Unretained(this),
164 &subscription_id, &p256dh, &auth)); 167 &subscription_id, &p256dh, &auth));
165 168
166 EXPECT_EQ(0u, subscription_id.size()); // this must be asynchronous 169 EXPECT_EQ(0u, subscription_id.size()); // this must be asynchronous
167 170
168 base::RunLoop().RunUntilIdle(); 171 base::RunLoop().RunUntilIdle();
169 172
170 ASSERT_GT(subscription_id.size(), 0u); 173 ASSERT_GT(subscription_id.size(), 0u);
171 ASSERT_GT(p256dh.size(), 0u); 174 ASSERT_GT(p256dh.size(), 0u);
172 ASSERT_GT(auth.size(), 0u); 175 ASSERT_GT(auth.size(), 0u);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 // (6) Verify that the message, as received by the Push Messaging Service, has 220 // (6) Verify that the message, as received by the Push Messaging Service, has
218 // indeed been decrypted by the GCM Driver, and has been forwarded to the 221 // indeed been decrypted by the GCM Driver, and has been forwarded to the
219 // Service Worker that has been associated with the subscription. 222 // Service Worker that has been associated with the subscription.
220 EXPECT_EQ(app_identifier.app_id(), app_id); 223 EXPECT_EQ(app_identifier.app_id(), app_id);
221 EXPECT_EQ(origin, dispatched_origin); 224 EXPECT_EQ(origin, dispatched_origin);
222 EXPECT_EQ(service_worker_registration_id, kTestServiceWorkerId); 225 EXPECT_EQ(service_worker_registration_id, kTestServiceWorkerId);
223 226
224 EXPECT_FALSE(payload.is_null); 227 EXPECT_FALSE(payload.is_null);
225 EXPECT_EQ(kTestPayload, payload.data); 228 EXPECT_EQ(kTestPayload, payload.data);
226 } 229 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698