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

Side by Side Diff: chrome/browser/budget_service/budget_database_unittest.cc

Issue 2326523003: Connect Mojo budget_service to BudgetManager implementation of Reserve. (Closed)
Patch Set: Fixed issue dependency. 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 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/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/test/histogram_tester.h" 10 #include "base/test/histogram_tester.h"
(...skipping 22 matching lines...) Expand all
33 33
34 class BudgetDatabaseTest : public ::testing::Test { 34 class BudgetDatabaseTest : public ::testing::Test {
35 public: 35 public:
36 BudgetDatabaseTest() 36 BudgetDatabaseTest()
37 : success_(false), 37 : success_(false),
38 db_(&profile_, 38 db_(&profile_,
39 profile_.GetPath().Append(FILE_PATH_LITERAL("BudgetDatabase")), 39 profile_.GetPath().Append(FILE_PATH_LITERAL("BudgetDatabase")),
40 base::ThreadTaskRunnerHandle::Get()), 40 base::ThreadTaskRunnerHandle::Get()),
41 origin_(url::Origin(GURL(kTestOrigin))) {} 41 origin_(url::Origin(GURL(kTestOrigin))) {}
42 42
43 void WriteBudgetComplete(base::Closure run_loop_closure, bool success) { 43 void WriteBudgetComplete(base::Closure run_loop_closure,
44 success_ = success; 44 blink::mojom::BudgetServiceErrorType error,
45 bool success) {
46 success_ = (error == blink::mojom::BudgetServiceErrorType::NONE) && success;
45 run_loop_closure.Run(); 47 run_loop_closure.Run();
46 } 48 }
47 49
48 // Spend budget for the origin. 50 // Spend budget for the origin.
49 bool SpendBudget(double amount) { 51 bool SpendBudget(double amount) {
50 base::RunLoop run_loop; 52 base::RunLoop run_loop;
51 db_.SpendBudget(origin(), amount, 53 db_.SpendBudget(origin(), amount,
52 base::Bind(&BudgetDatabaseTest::WriteBudgetComplete, 54 base::Bind(&BudgetDatabaseTest::WriteBudgetComplete,
53 base::Unretained(this), run_loop.QuitClosure())); 55 base::Unretained(this), run_loop.QuitClosure()));
54 run_loop.Run(); 56 run_loop.Run();
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 305
304 std::vector<base::Bucket> low_budget_buckets = 306 std::vector<base::Bucket> low_budget_buckets =
305 GetHistogramTester()->GetAllSamples( 307 GetHistogramTester()->GetAllSamples(
306 "PushMessaging.SESForLowBudgetOrigin"); 308 "PushMessaging.SESForLowBudgetOrigin");
307 ASSERT_EQ(2U, low_budget_buckets.size()); 309 ASSERT_EQ(2U, low_budget_buckets.size());
308 EXPECT_EQ(engagement, low_budget_buckets[0].min); 310 EXPECT_EQ(engagement, low_budget_buckets[0].min);
309 EXPECT_EQ(1, low_budget_buckets[0].count); 311 EXPECT_EQ(1, low_budget_buckets[0].count);
310 EXPECT_EQ(engagement * 2, low_budget_buckets[1].min); 312 EXPECT_EQ(engagement * 2, low_budget_buckets[1].min);
311 EXPECT_EQ(1, low_budget_buckets[1].count); 313 EXPECT_EQ(1, low_budget_buckets[1].count);
312 } 314 }
OLDNEW
« no previous file with comments | « chrome/browser/budget_service/budget_database.cc ('k') | chrome/browser/budget_service/budget_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698