| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 | 661 |
| 662 EXPECT_TRUE(IsRegisteredKeepAliveEqualTo(false)); | 662 EXPECT_TRUE(IsRegisteredKeepAliveEqualTo(false)); |
| 663 gcm::IncomingMessage message; | 663 gcm::IncomingMessage message; |
| 664 message.sender_id = GetTestApplicationServerKey(); | 664 message.sender_id = GetTestApplicationServerKey(); |
| 665 message.raw_data = "testdata"; | 665 message.raw_data = "testdata"; |
| 666 message.decrypted = true; | 666 message.decrypted = true; |
| 667 push_service()->OnMessage(app_identifier.app_id(), message); | 667 push_service()->OnMessage(app_identifier.app_id(), message); |
| 668 EXPECT_TRUE(IsRegisteredKeepAliveEqualTo(true)); | 668 EXPECT_TRUE(IsRegisteredKeepAliveEqualTo(true)); |
| 669 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result)); | 669 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result)); |
| 670 EXPECT_EQ("testdata", script_result); | 670 EXPECT_EQ("testdata", script_result); |
| 671 |
| 672 // Check that we record this case in UMA. |
| 673 GetHistogramTester()->ExpectUniqueSample( |
| 674 "PushMessaging.DeliveryStatus.FindServiceWorker", |
| 675 0 /* SERVICE_WORKER_OK */, 1); |
| 676 GetHistogramTester()->ExpectUniqueSample( |
| 677 "PushMessaging.DeliveryStatus.ServiceWorkerEvent", |
| 678 0 /* SERVICE_WORKER_OK */, 1); |
| 679 GetHistogramTester()->ExpectUniqueSample( |
| 680 "PushMessaging.DeliveryStatus", |
| 681 content::PUSH_DELIVERY_STATUS_SUCCESS, 1); |
| 671 } | 682 } |
| 672 | 683 |
| 673 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PushEventWithoutPayload) { | 684 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PushEventWithoutPayload) { |
| 674 std::string script_result; | 685 std::string script_result; |
| 675 | 686 |
| 676 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); | 687 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); |
| 677 | 688 |
| 678 PushMessagingAppIdentifier app_identifier = | 689 PushMessagingAppIdentifier app_identifier = |
| 679 GetAppIdentifierForServiceWorkerRegistration(0LL); | 690 GetAppIdentifierForServiceWorkerRegistration(0LL); |
| 680 EXPECT_EQ(app_identifier.app_id(), gcm_service()->last_registered_app_id()); | 691 EXPECT_EQ(app_identifier.app_id(), gcm_service()->last_registered_app_id()); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 message.sender_id = GetTestApplicationServerKey(); | 742 message.sender_id = GetTestApplicationServerKey(); |
| 732 message.raw_data = "testdata"; | 743 message.raw_data = "testdata"; |
| 733 message.decrypted = true; | 744 message.decrypted = true; |
| 734 EXPECT_TRUE(IsRegisteredKeepAliveEqualTo(false)); | 745 EXPECT_TRUE(IsRegisteredKeepAliveEqualTo(false)); |
| 735 push_service()->OnMessage(app_identifier.app_id(), message); | 746 push_service()->OnMessage(app_identifier.app_id(), message); |
| 736 EXPECT_TRUE(IsRegisteredKeepAliveEqualTo(true)); | 747 EXPECT_TRUE(IsRegisteredKeepAliveEqualTo(true)); |
| 737 callback.WaitUntilSatisfied(); | 748 callback.WaitUntilSatisfied(); |
| 738 EXPECT_TRUE(IsRegisteredKeepAliveEqualTo(false)); | 749 EXPECT_TRUE(IsRegisteredKeepAliveEqualTo(false)); |
| 739 EXPECT_EQ(app_identifier.app_id(), callback.app_id()); | 750 EXPECT_EQ(app_identifier.app_id(), callback.app_id()); |
| 740 | 751 |
| 752 // Check that we record this case in UMA. |
| 753 GetHistogramTester()->ExpectUniqueSample( |
| 754 "PushMessaging.DeliveryStatus.FindServiceWorker", |
| 755 5 /* SERVICE_WORKER_ERROR_NOT_FOUND */, 1); |
| 756 GetHistogramTester()->ExpectTotalCount( |
| 757 "PushMessaging.DeliveryStatus.ServiceWorkerEvent", 0); |
| 758 GetHistogramTester()->ExpectUniqueSample( |
| 759 "PushMessaging.DeliveryStatus", |
| 760 content::PUSH_DELIVERY_STATUS_NO_SERVICE_WORKER, 1); |
| 761 |
| 741 // No push data should have been received. | 762 // No push data should have been received. |
| 742 ASSERT_TRUE(RunScript("resultQueue.popImmediately()", &script_result)); | 763 ASSERT_TRUE(RunScript("resultQueue.popImmediately()", &script_result)); |
| 743 EXPECT_EQ("null", script_result); | 764 EXPECT_EQ("null", script_result); |
| 744 } | 765 } |
| 745 | 766 |
| 746 #if defined(ENABLE_NOTIFICATIONS) | 767 #if defined(ENABLE_NOTIFICATIONS) |
| 747 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 768 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
| 748 PushEventEnforcesUserVisibleNotification) { | 769 PushEventEnforcesUserVisibleNotification) { |
| 749 std::string script_result; | 770 std::string script_result; |
| 750 | 771 |
| (...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1573 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 1594 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
| 1574 | 1595 |
| 1575 // After dropping the last subscription background mode is still inactive. | 1596 // After dropping the last subscription background mode is still inactive. |
| 1576 std::string script_result; | 1597 std::string script_result; |
| 1577 gcm_service()->AddExpectedUnregisterResponse(gcm::GCMClient::SUCCESS); | 1598 gcm_service()->AddExpectedUnregisterResponse(gcm::GCMClient::SUCCESS); |
| 1578 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 1599 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
| 1579 EXPECT_EQ("unsubscribe result: true", script_result); | 1600 EXPECT_EQ("unsubscribe result: true", script_result); |
| 1580 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 1601 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
| 1581 } | 1602 } |
| 1582 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) | 1603 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) |
| OLD | NEW |