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

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

Issue 1078873004: Address the TODOs in the PushMessagingBrowserTest for the endpoint merge. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@push-subscriptionId
Patch Set: rebase Created 5 years, 7 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
« no previous file with comments | « no previous file | chrome/test/data/push_messaging/push_test.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <map> 5 #include <map>
6 #include <string> 6 #include <string>
7 7
8 #include "base/barrier_closure.h" 8 #include "base/barrier_closure.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 if (!web_contents) 143 if (!web_contents)
144 web_contents = GetBrowser()->tab_strip_model()->GetActiveWebContents(); 144 web_contents = GetBrowser()->tab_strip_model()->GetActiveWebContents();
145 return content::ExecuteScriptAndExtractString(web_contents->GetMainFrame(), 145 return content::ExecuteScriptAndExtractString(web_contents->GetMainFrame(),
146 script, 146 script,
147 result); 147 result);
148 } 148 }
149 149
150 void TryToSubscribeSuccessfully( 150 void TryToSubscribeSuccessfully(
151 const std::string& expected_push_subscription_id); 151 const std::string& expected_push_subscription_id);
152 152
153 std::string GetEndpointForSubscriptionId(const std::string& subscription_id) {
154 return std::string(kPushMessagingEndpoint) + "/" + subscription_id;
155 }
156
153 PushMessagingApplicationId GetServiceWorkerAppId( 157 PushMessagingApplicationId GetServiceWorkerAppId(
154 int64 service_worker_registration_id); 158 int64 service_worker_registration_id);
155 159
156 void SendMessageAndWaitUntilHandled( 160 void SendMessageAndWaitUntilHandled(
157 const PushMessagingApplicationId& app_id, 161 const PushMessagingApplicationId& app_id,
158 const gcm::GCMClient::IncomingMessage& message); 162 const gcm::GCMClient::IncomingMessage& message);
159 163
160 net::SpawnedTestServer* https_server() const { return https_server_.get(); } 164 net::SpawnedTestServer* https_server() const { return https_server_.get(); }
161 165
162 gcm::FakeGCMProfileService* gcm_service() const { return gcm_service_; } 166 gcm::FakeGCMProfileService* gcm_service() const { return gcm_service_; }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 std::string script_result; 220 std::string script_result;
217 221
218 EXPECT_TRUE(RunScript("registerServiceWorker()", &script_result)); 222 EXPECT_TRUE(RunScript("registerServiceWorker()", &script_result));
219 EXPECT_EQ("ok - service worker registered", script_result); 223 EXPECT_EQ("ok - service worker registered", script_result);
220 224
221 InfoBarResponder accepting_responder(GetInfoBarService(), true); 225 InfoBarResponder accepting_responder(GetInfoBarService(), true);
222 EXPECT_TRUE(RunScript("requestNotificationPermission()", &script_result)); 226 EXPECT_TRUE(RunScript("requestNotificationPermission()", &script_result));
223 EXPECT_EQ("permission status - granted", script_result); 227 EXPECT_EQ("permission status - granted", script_result);
224 228
225 EXPECT_TRUE(RunScript("subscribePush()", &script_result)); 229 EXPECT_TRUE(RunScript("subscribePush()", &script_result));
226 230 EXPECT_EQ(GetEndpointForSubscriptionId(expected_push_subscription_id),
227 // TODO(peter): Add an EXPECT for the given endpoint after the value change 231 script_result);
228 // has gone through.
229 } 232 }
230 233
231 PushMessagingApplicationId PushMessagingBrowserTest::GetServiceWorkerAppId( 234 PushMessagingApplicationId PushMessagingBrowserTest::GetServiceWorkerAppId(
232 int64 service_worker_registration_id) { 235 int64 service_worker_registration_id) {
233 GURL origin = https_server()->GetURL(std::string()).GetOrigin(); 236 GURL origin = https_server()->GetURL(std::string()).GetOrigin();
234 PushMessagingApplicationId application_id = PushMessagingApplicationId::Get( 237 PushMessagingApplicationId application_id = PushMessagingApplicationId::Get(
235 GetBrowser()->profile(), origin, service_worker_registration_id); 238 GetBrowser()->profile(), origin, service_worker_registration_id);
236 EXPECT_TRUE(application_id.IsValid()); 239 EXPECT_TRUE(application_id.IsValid());
237 return application_id; 240 return application_id;
238 } 241 }
(...skipping 18 matching lines...) Expand all
257 260
258 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, 261 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest,
259 SubscribeSuccessNotificationsPrompt) { 262 SubscribeSuccessNotificationsPrompt) {
260 std::string script_result; 263 std::string script_result;
261 264
262 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); 265 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result));
263 ASSERT_EQ("ok - service worker registered", script_result); 266 ASSERT_EQ("ok - service worker registered", script_result);
264 267
265 InfoBarResponder accepting_responder(GetInfoBarService(), true); 268 InfoBarResponder accepting_responder(GetInfoBarService(), true);
266 ASSERT_TRUE(RunScript("subscribePush()", &script_result)); 269 ASSERT_TRUE(RunScript("subscribePush()", &script_result));
267 270 EXPECT_EQ(GetEndpointForSubscriptionId("1-0"),
268 // TODO(peter): Add an EXPECT for the given endpoint after the value change 271 script_result);
269 // has gone through.
270 272
271 PushMessagingApplicationId app_id = GetServiceWorkerAppId(0LL); 273 PushMessagingApplicationId app_id = GetServiceWorkerAppId(0LL);
272 EXPECT_EQ(app_id.app_id_guid(), gcm_service()->last_registered_app_id()); 274 EXPECT_EQ(app_id.app_id_guid(), gcm_service()->last_registered_app_id());
273 EXPECT_EQ("1234567890", gcm_service()->last_registered_sender_ids()[0]); 275 EXPECT_EQ("1234567890", gcm_service()->last_registered_sender_ids()[0]);
274 } 276 }
275 277
276 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, 278 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest,
277 SubscribeFailureNotificationsBlocked) { 279 SubscribeFailureNotificationsBlocked) {
278 std::string script_result; 280 std::string script_result;
279 281
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 std::string script_result; 585 std::string script_result;
584 586
585 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); 587 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result));
586 ASSERT_EQ("ok - service worker registered", script_result); 588 ASSERT_EQ("ok - service worker registered", script_result);
587 589
588 InfoBarResponder accepting_responder(GetInfoBarService(), true); 590 InfoBarResponder accepting_responder(GetInfoBarService(), true);
589 ASSERT_TRUE(RunScript("requestNotificationPermission();", &script_result)); 591 ASSERT_TRUE(RunScript("requestNotificationPermission();", &script_result));
590 EXPECT_EQ("permission status - granted", script_result); 592 EXPECT_EQ("permission status - granted", script_result);
591 593
592 ASSERT_TRUE(RunScript("subscribePush()", &script_result)); 594 ASSERT_TRUE(RunScript("subscribePush()", &script_result));
593 595 EXPECT_EQ(GetEndpointForSubscriptionId("1-0"),
594 // TODO(peter): Add an EXPECT for the given endpoint after the value change 596 script_result);
595 // has gone through.
596 597
597 ASSERT_TRUE(RunScript("permissionState()", &script_result)); 598 ASSERT_TRUE(RunScript("permissionState()", &script_result));
598 EXPECT_EQ("permission status - granted", script_result); 599 EXPECT_EQ("permission status - granted", script_result);
599 } 600 }
600 601
601 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PermissionStateSaysDenied) { 602 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PermissionStateSaysDenied) {
602 std::string script_result; 603 std::string script_result;
603 604
604 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); 605 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result));
605 ASSERT_EQ("ok - service worker registered", script_result); 606 ASSERT_EQ("ok - service worker registered", script_result);
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 std::string script_result; 1019 std::string script_result;
1019 1020
1020 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); 1021 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result));
1021 ASSERT_EQ("ok - service worker registered", script_result); 1022 ASSERT_EQ("ok - service worker registered", script_result);
1022 1023
1023 // In Incognito mode the promise returned by getSubscription should not hang, 1024 // In Incognito mode the promise returned by getSubscription should not hang,
1024 // it should just fulfill with null. 1025 // it should just fulfill with null.
1025 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); 1026 ASSERT_TRUE(RunScript("hasSubscription()", &script_result));
1026 ASSERT_EQ("false - not subscribed", script_result); 1027 ASSERT_EQ("false - not subscribed", script_result);
1027 } 1028 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/push_messaging/push_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698