OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/budget_service/budget_database.h" | 5 #include "chrome/browser/budget_service/budget_database.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 85 |
86 // Setup a test clock so that the tests can control time. | 86 // Setup a test clock so that the tests can control time. |
87 base::SimpleTestClock* SetClockForTesting() { | 87 base::SimpleTestClock* SetClockForTesting() { |
88 base::SimpleTestClock* clock = new base::SimpleTestClock(); | 88 base::SimpleTestClock* clock = new base::SimpleTestClock(); |
89 db_.SetClockForTesting(base::WrapUnique(clock)); | 89 db_.SetClockForTesting(base::WrapUnique(clock)); |
90 return clock; | 90 return clock; |
91 } | 91 } |
92 | 92 |
93 void SetSiteEngagementScore(double score) { | 93 void SetSiteEngagementScore(double score) { |
94 SiteEngagementService* service = SiteEngagementService::Get(&profile_); | 94 SiteEngagementService* service = SiteEngagementService::Get(&profile_); |
95 service->ResetScoreForURL(GURL(kTestOrigin), score); | 95 service->ResetBaseScoreForURL(GURL(kTestOrigin), score); |
96 } | 96 } |
97 | 97 |
98 protected: | 98 protected: |
99 base::HistogramTester* GetHistogramTester() { return &histogram_tester_; } | 99 base::HistogramTester* GetHistogramTester() { return &histogram_tester_; } |
100 bool success_; | 100 bool success_; |
101 std::vector<blink::mojom::BudgetStatePtr> prediction_; | 101 std::vector<blink::mojom::BudgetStatePtr> prediction_; |
102 | 102 |
103 private: | 103 private: |
104 content::TestBrowserThreadBundle thread_bundle_; | 104 content::TestBrowserThreadBundle thread_bundle_; |
105 std::unique_ptr<budget_service::Budget> budget_; | 105 std::unique_ptr<budget_service::Budget> budget_; |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 | 320 |
321 std::vector<base::Bucket> low_budget_buckets = | 321 std::vector<base::Bucket> low_budget_buckets = |
322 GetHistogramTester()->GetAllSamples( | 322 GetHistogramTester()->GetAllSamples( |
323 "PushMessaging.SESForLowBudgetOrigin"); | 323 "PushMessaging.SESForLowBudgetOrigin"); |
324 ASSERT_EQ(2U, low_budget_buckets.size()); | 324 ASSERT_EQ(2U, low_budget_buckets.size()); |
325 EXPECT_EQ(floor(engagement), low_budget_buckets[0].min); | 325 EXPECT_EQ(floor(engagement), low_budget_buckets[0].min); |
326 EXPECT_EQ(1, low_budget_buckets[0].count); | 326 EXPECT_EQ(1, low_budget_buckets[0].count); |
327 EXPECT_EQ(floor(engagement * 2), low_budget_buckets[1].min); | 327 EXPECT_EQ(floor(engagement * 2), low_budget_buckets[1].min); |
328 EXPECT_EQ(1, low_budget_buckets[1].count); | 328 EXPECT_EQ(1, low_budget_buckets[1].count); |
329 } | 329 } |
OLD | NEW |