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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "base/test/histogram_tester.h" | 11 #include "base/test/histogram_tester.h" |
12 #include "base/test/simple_test_clock.h" | 12 #include "base/test/simple_test_clock.h" |
13 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
14 #include "chrome/browser/budget_service/budget.pb.h" | 14 #include "chrome/browser/budget_service/budget.pb.h" |
15 #include "chrome/browser/engagement/site_engagement_service.h" | 15 #include "chrome/browser/engagement/site_engagement_service.h" |
16 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
17 #include "components/leveldb_proto/proto_database.h" | 17 #include "components/leveldb_proto/proto_database.h" |
18 #include "components/leveldb_proto/proto_database_impl.h" | 18 #include "components/leveldb_proto/proto_database_impl.h" |
19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
20 #include "content/public/test/test_browser_thread_bundle.h" | 20 #include "content/public/test/test_browser_thread_bundle.h" |
21 #include "mojo/public/cpp/bindings/array.h" | |
22 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
23 #include "url/gurl.h" | 22 #include "url/gurl.h" |
24 #include "url/origin.h" | 23 #include "url/origin.h" |
25 | 24 |
26 namespace { | 25 namespace { |
27 | 26 |
28 const double kDefaultExpirationInHours = 96; | 27 const double kDefaultExpirationInHours = 96; |
29 const double kDefaultEngagement = 30.0; | 28 const double kDefaultEngagement = 30.0; |
30 | 29 |
31 const char kTestOrigin[] = "https://example.com"; | 30 const char kTestOrigin[] = "https://example.com"; |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 | 306 |
308 std::vector<base::Bucket> low_budget_buckets = | 307 std::vector<base::Bucket> low_budget_buckets = |
309 GetHistogramTester()->GetAllSamples( | 308 GetHistogramTester()->GetAllSamples( |
310 "PushMessaging.SESForLowBudgetOrigin"); | 309 "PushMessaging.SESForLowBudgetOrigin"); |
311 ASSERT_EQ(2U, low_budget_buckets.size()); | 310 ASSERT_EQ(2U, low_budget_buckets.size()); |
312 EXPECT_EQ(engagement, low_budget_buckets[0].min); | 311 EXPECT_EQ(engagement, low_budget_buckets[0].min); |
313 EXPECT_EQ(1, low_budget_buckets[0].count); | 312 EXPECT_EQ(1, low_budget_buckets[0].count); |
314 EXPECT_EQ(engagement * 2, low_budget_buckets[1].min); | 313 EXPECT_EQ(engagement * 2, low_budget_buckets[1].min); |
315 EXPECT_EQ(1, low_budget_buckets[1].count); | 314 EXPECT_EQ(1, low_budget_buckets[1].count); |
316 } | 315 } |
OLD | NEW |