Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 475 EXPECT_EQ("permission status - denied", script_result); | 475 EXPECT_EQ("permission status - denied", script_result); |
| 476 | 476 |
| 477 ASSERT_TRUE(RunScript("registerPush()", &script_result)); | 477 ASSERT_TRUE(RunScript("registerPush()", &script_result)); |
| 478 EXPECT_EQ("AbortError - Registration failed - permission denied", | 478 EXPECT_EQ("AbortError - Registration failed - permission denied", |
| 479 script_result); | 479 script_result); |
| 480 | 480 |
| 481 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); | 481 ASSERT_TRUE(RunScript("hasPermission()", &script_result)); |
| 482 EXPECT_EQ("permission status - denied", script_result); | 482 EXPECT_EQ("permission status - denied", script_result); |
| 483 } | 483 } |
| 484 | 484 |
| 485 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, UnregisterSuccess) { | |
| 486 std::string script_result; | |
| 487 | |
| 488 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | |
|
Michael van Ouwerkerk
2014/12/16 12:58:41
Sorry for the late notice, I had missed this patch
| |
| 489 ASSERT_EQ("ok - service worker registered", script_result); | |
| 490 | |
| 491 InfoBarResponder accepting_responder(browser(), true); | |
| 492 ASSERT_TRUE(RunScript("requestNotificationPermission();", &script_result)); | |
| 493 EXPECT_EQ("permission status - granted", script_result); | |
| 494 | |
| 495 ASSERT_TRUE(RunScript("registerPush()", &script_result)); | |
| 496 EXPECT_EQ(std::string(kPushMessagingEndpoint) + " - 1-0", script_result); | |
| 497 | |
| 498 gcm_service()->AddExpectedUnregisterResponse(GCMClient::SUCCESS); | |
| 499 | |
| 500 ASSERT_TRUE(RunScript("unregister()", &script_result)); | |
| 501 EXPECT_EQ("unregister result: true", script_result); | |
| 502 } | |
| 503 | |
| 504 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, UnregisterNetworkError) { | |
| 505 std::string script_result; | |
| 506 | |
| 507 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | |
|
Michael van Ouwerkerk
2014/12/16 12:58:41
Same here.
| |
| 508 ASSERT_EQ("ok - service worker registered", script_result); | |
| 509 | |
| 510 InfoBarResponder accepting_responder(browser(), true); | |
| 511 ASSERT_TRUE(RunScript("requestNotificationPermission();", &script_result)); | |
| 512 EXPECT_EQ("permission status - granted", script_result); | |
| 513 | |
| 514 ASSERT_TRUE(RunScript("registerPush()", &script_result)); | |
| 515 EXPECT_EQ(std::string(kPushMessagingEndpoint) + " - 1-0", script_result); | |
| 516 | |
| 517 gcm_service()->AddExpectedUnregisterResponse(GCMClient::NETWORK_ERROR); | |
| 518 | |
| 519 ASSERT_TRUE(RunScript("unregister()", &script_result)); | |
| 520 EXPECT_EQ("unregister error: " | |
| 521 "NetworkError: Failed to connect to the push server.", | |
| 522 script_result); | |
| 523 } | |
| 524 | |
| 525 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, UnregisterUnknownError) { | |
| 526 std::string script_result; | |
| 527 | |
| 528 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | |
|
Michael van Ouwerkerk
2014/12/16 12:58:41
Same here.
| |
| 529 ASSERT_EQ("ok - service worker registered", script_result); | |
| 530 | |
| 531 InfoBarResponder accepting_responder(browser(), true); | |
| 532 ASSERT_TRUE(RunScript("requestNotificationPermission();", &script_result)); | |
| 533 EXPECT_EQ("permission status - granted", script_result); | |
| 534 | |
| 535 ASSERT_TRUE(RunScript("registerPush()", &script_result)); | |
| 536 EXPECT_EQ(std::string(kPushMessagingEndpoint) + " - 1-0", script_result); | |
| 537 | |
| 538 gcm_service()->AddExpectedUnregisterResponse(GCMClient::UNKNOWN_ERROR); | |
| 539 | |
| 540 ASSERT_TRUE(RunScript("unregister()", &script_result)); | |
| 541 EXPECT_EQ("unregister error: " | |
| 542 "UnknownError: Unexpected error while trying to unregister from the" | |
| 543 " push server.", script_result); | |
| 544 } | |
| 545 | |
| 485 } // namespace gcm | 546 } // namespace gcm |
| OLD | NEW |