| 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 146 | 146 | 
| 147   // (1) Make sure that |kExampleOrigin| has access to use Push Messaging. | 147   // (1) Make sure that |kExampleOrigin| has access to use Push Messaging. | 
| 148   ASSERT_EQ(blink::WebPushPermissionStatusGranted, | 148   ASSERT_EQ(blink::WebPushPermissionStatusGranted, | 
| 149             push_service->GetPermissionStatus(origin, true)); | 149             push_service->GetPermissionStatus(origin, true)); | 
| 150 | 150 | 
| 151   std::string subscription_id; | 151   std::string subscription_id; | 
| 152   std::vector<uint8_t> p256dh, auth; | 152   std::vector<uint8_t> p256dh, auth; | 
| 153 | 153 | 
| 154   // (2) Subscribe for Push Messaging, and verify that we've got the required | 154   // (2) Subscribe for Push Messaging, and verify that we've got the required | 
| 155   // information in order to be able to create encrypted messages. | 155   // information in order to be able to create encrypted messages. | 
|  | 156   content::PushSubscriptionOptions options; | 
|  | 157   options.user_visible_only = true; | 
|  | 158   options.sender_info = kTestSenderId; | 
| 156   push_service->SubscribeFromWorker( | 159   push_service->SubscribeFromWorker( | 
| 157       origin, kTestServiceWorkerId, kTestSenderId, true /* user_visible */, | 160       origin, kTestServiceWorkerId, options, | 
| 158       base::Bind(&PushMessagingServiceTest::DidRegister, base::Unretained(this), | 161       base::Bind(&PushMessagingServiceTest::DidRegister, base::Unretained(this), | 
| 159                  &subscription_id, &p256dh, &auth)); | 162                  &subscription_id, &p256dh, &auth)); | 
| 160 | 163 | 
| 161   EXPECT_EQ(0u, subscription_id.size());  // this must be asynchronous | 164   EXPECT_EQ(0u, subscription_id.size());  // this must be asynchronous | 
| 162 | 165 | 
| 163   base::RunLoop().RunUntilIdle(); | 166   base::RunLoop().RunUntilIdle(); | 
| 164 | 167 | 
| 165   ASSERT_GT(subscription_id.size(), 0u); | 168   ASSERT_GT(subscription_id.size(), 0u); | 
| 166   ASSERT_GT(p256dh.size(), 0u); | 169   ASSERT_GT(p256dh.size(), 0u); | 
| 167   ASSERT_GT(auth.size(), 0u); | 170   ASSERT_GT(auth.size(), 0u); | 
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 212   // (6) Verify that the message, as received by the Push Messaging Service, has | 215   // (6) Verify that the message, as received by the Push Messaging Service, has | 
| 213   // indeed been decrypted by the GCM Driver, and has been forwarded to the | 216   // indeed been decrypted by the GCM Driver, and has been forwarded to the | 
| 214   // Service Worker that has been associated with the subscription. | 217   // Service Worker that has been associated with the subscription. | 
| 215   EXPECT_EQ(app_identifier.app_id(), app_id); | 218   EXPECT_EQ(app_identifier.app_id(), app_id); | 
| 216   EXPECT_EQ(origin, dispatched_origin); | 219   EXPECT_EQ(origin, dispatched_origin); | 
| 217   EXPECT_EQ(service_worker_registration_id, kTestServiceWorkerId); | 220   EXPECT_EQ(service_worker_registration_id, kTestServiceWorkerId); | 
| 218 | 221 | 
| 219   EXPECT_FALSE(payload.is_null); | 222   EXPECT_FALSE(payload.is_null); | 
| 220   EXPECT_EQ(kTestPayload, payload.data); | 223   EXPECT_EQ(kTestPayload, payload.data); | 
| 221 } | 224 } | 
| OLD | NEW | 
|---|