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

Unified Diff: chrome/browser/push_messaging/background_budget_service_unittest.cc

Issue 1887623002: Replace the 1 in 10 grace period with an accumulating budget based on SES. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/push_messaging/background_budget_service_unittest.cc
diff --git a/chrome/browser/push_messaging/background_budget_service_unittest.cc b/chrome/browser/push_messaging/background_budget_service_unittest.cc
index a6e99f941ab65ad32a7fb0880d9fbdd302830c97..9aa17f13b1904eda25e9f2cb8235c2e4455703a4 100644
--- a/chrome/browser/push_messaging/background_budget_service_unittest.cc
+++ b/chrome/browser/push_messaging/background_budget_service_unittest.cc
@@ -5,6 +5,7 @@
#include <stdint.h>
#include <string>
+#include "chrome/browser/engagement/site_engagement_service.h"
#include "chrome/browser/push_messaging/background_budget_service.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/test/test_browser_thread_bundle.h"
@@ -13,7 +14,8 @@
namespace {
const char kTestOrigin[] = "https://example.com";
-const char kTestData[] = "1111101111";
+const double kTestBudget = 10.0;
+const double kTestSES = 24.0;
} // namespace
@@ -24,27 +26,44 @@ class BackgroundBudgetServiceTest : public testing::Test {
TestingProfile* profile() { return &profile_; }
+ void SetSiteEngagementScore(const GURL& url, double score) {
+ SiteEngagementService* service = SiteEngagementService::Get(&profile_);
+ service->ResetScoreForURL(url, score);
+ }
+
private:
content::TestBrowserThreadBundle thread_bundle_;
TestingProfile profile_;
};
-TEST_F(BackgroundBudgetServiceTest, GetBudgetFailure) {
+TEST_F(BackgroundBudgetServiceTest, GetBudgetNoBudgetOrSES) {
const GURL origin(kTestOrigin);
- std::string budget_string =
- BackgroundBudgetService::GetBudget(profile(), origin);
+ double budget = 0.0;
+ BackgroundBudgetService::GetBudget(profile(), origin, budget);
+
+ EXPECT_EQ(budget, 0.0);
Peter Beverloo 2016/04/14 18:02:09 EXPECT_DOUBLE_EQ(), elsewhere too Comparisons are
harkness 2016/04/27 11:21:08 Done, and I changed a lot of them to EXPECT_NEAR w
+}
+
+TEST_F(BackgroundBudgetServiceTest, GetBudgetNoBudgetSESExists) {
+ const GURL origin(kTestOrigin);
+
+ // Set a starting SES for the url but no stored budget info.
+ SetSiteEngagementScore(origin, kTestSES);
+
+ double budget = 0.0;
+ BackgroundBudgetService::GetBudget(profile(), origin, budget);
- EXPECT_EQ(std::string(), budget_string);
+ EXPECT_EQ(budget, kTestSES);
}
-TEST_F(BackgroundBudgetServiceTest, GetBudgetSuccess) {
+TEST_F(BackgroundBudgetServiceTest, GetBudgetNoElapsedTime) {
const GURL origin(kTestOrigin);
- BackgroundBudgetService::StoreBudget(profile(), origin, kTestData);
+ BackgroundBudgetService::StoreBudget(profile(), origin, kTestBudget);
- std::string budget_string =
- BackgroundBudgetService::GetBudget(profile(), origin);
+ double budget = 0.0;
+ BackgroundBudgetService::GetBudget(profile(), origin, budget);
- EXPECT_EQ(kTestData, budget_string);
+ EXPECT_EQ(budget, kTestBudget);
Peter Beverloo 2016/04/14 18:02:09 You probably want to talk to Sami about a thing we
harkness 2016/04/27 11:21:08 Many more tests added, now that I have a clock in
}

Powered by Google App Engine
This is Rietveld 408576698