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

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

Issue 2281673002: Full hookup of BudgetManager interfaces to BudgetDatabase. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@manager
Patch Set: Fixed hang and cleaned up browsertests Created 4 years, 3 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 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 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 EXPECT_EQ("shownotification", script_result); 841 EXPECT_EQ("shownotification", script_result);
842 842
843 ASSERT_EQ(1u, notification_manager()->GetNotificationCount()); 843 ASSERT_EQ(1u, notification_manager()->GetNotificationCount());
844 { 844 {
845 const Notification& first_notification = 845 const Notification& first_notification =
846 notification_manager()->GetNotificationAt(0); 846 notification_manager()->GetNotificationAt(0);
847 847
848 EXPECT_NE(kPushMessagingForcedNotificationTag, first_notification.tag()); 848 EXPECT_NE(kPushMessagingForcedNotificationTag, first_notification.tag());
849 } 849 }
850 850
851 // Check that the UMA has been recorded correctly. 851 // The BackgroundBudget UMA is recorded when budget is added to the origin.
852 // There should be a total of 7 budget samples, spread across 3 buckets. The 852 // This happens only once per hour, so there should be a single entry for the
853 // first four notifications (before any budget is consumed) have budget of 4, 853 // budget.
854 // which is the starting SES. The next one has 2 (one hidden notification) and
855 // the final two have 0 (two hidden notifications.
856 std::vector<base::Bucket> buckets = 854 std::vector<base::Bucket> buckets =
857 GetHistogramTester()->GetAllSamples("PushMessaging.BackgroundBudget"); 855 GetHistogramTester()->GetAllSamples("PushMessaging.BackgroundBudget");
858 ASSERT_EQ(3.0, buckets.size()); 856 ASSERT_EQ(1.0, buckets.size());
859 // First bucket is for 0 budget, which has 2 samples. 857 // The bucket is for budget of 4 (the engagement score), which has 1 samples.
860 EXPECT_EQ(0, buckets[0].min); 858 EXPECT_EQ(4.0, buckets[0].min);
861 EXPECT_EQ(2, buckets[0].count); 859 EXPECT_EQ(1, buckets[0].count);
Peter Beverloo 2016/09/05 14:39:03 I'm a wee bit hesitant towards testing the impleme
harkness 2016/09/06 13:28:39 I added tests in budget_database_unittest.cc and r
862 // Second bucket is for 2 budget, which has 1 sample.
863 EXPECT_EQ(2, buckets[1].min);
864 EXPECT_EQ(1, buckets[1].count);
865 // Final bucket is for 4 budget, which has 4 samples.
866 EXPECT_EQ(4, buckets[2].min);
867 EXPECT_EQ(4, buckets[2].count);
868 860
861 // There should only be 1 entry for NoBudgetOrigin because we only record the
862 // UMA when there needs to be a notification shown and there isn't one.
869 std::vector<base::Bucket> no_budget_buckets = 863 std::vector<base::Bucket> no_budget_buckets =
870 GetHistogramTester()->GetAllSamples("PushMessaging.SESForNoBudgetOrigin"); 864 GetHistogramTester()->GetAllSamples("PushMessaging.SESForNoBudgetOrigin");
871 ASSERT_EQ(1.0, no_budget_buckets.size()); 865 ASSERT_EQ(1.0, no_budget_buckets.size());
872 EXPECT_EQ(4, no_budget_buckets[0].min); 866 EXPECT_EQ(4, no_budget_buckets[0].min);
873 EXPECT_EQ(2, no_budget_buckets[0].count); 867 EXPECT_EQ(1, no_budget_buckets[0].count);
874 868
869 // There should also be only 1 entry for LowBudgetOrigin.
875 std::vector<base::Bucket> low_budget_buckets = 870 std::vector<base::Bucket> low_budget_buckets =
876 GetHistogramTester()->GetAllSamples( 871 GetHistogramTester()->GetAllSamples(
877 "PushMessaging.SESForLowBudgetOrigin"); 872 "PushMessaging.SESForLowBudgetOrigin");
878 ASSERT_EQ(1.0, low_budget_buckets.size()); 873 ASSERT_EQ(1.0, low_budget_buckets.size());
879 EXPECT_EQ(4, low_budget_buckets[0].min); 874 EXPECT_EQ(4, low_budget_buckets[0].min);
880 EXPECT_EQ(1, low_budget_buckets[0].count); 875 EXPECT_EQ(1, low_budget_buckets[0].count);
881 } 876 }
882 877
883 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, 878 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest,
884 PushEventAllowSilentPushCommandLineFlag) { 879 PushEventAllowSilentPushCommandLineFlag) {
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
1575 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); 1570 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive());
1576 1571
1577 // After dropping the last subscription background mode is still inactive. 1572 // After dropping the last subscription background mode is still inactive.
1578 std::string script_result; 1573 std::string script_result;
1579 gcm_service()->AddExpectedUnregisterResponse(gcm::GCMClient::SUCCESS); 1574 gcm_service()->AddExpectedUnregisterResponse(gcm::GCMClient::SUCCESS);
1580 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); 1575 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result));
1581 EXPECT_EQ("unsubscribe result: true", script_result); 1576 EXPECT_EQ("unsubscribe result: true", script_result);
1582 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); 1577 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive());
1583 } 1578 }
1584 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) 1579 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698