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

Unified Diff: chrome/browser/budget_service/budget_manager_unittest.cc

Issue 2272563005: Start plumbing connections from the BudgetManager to the BudgetDatabase (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix the task runner 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/budget_service/budget_manager_factory.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/budget_service/budget_manager_unittest.cc
diff --git a/chrome/browser/budget_service/budget_manager_unittest.cc b/chrome/browser/budget_service/budget_manager_unittest.cc
index 27f17ac53053f58a09a0646dc4082c5269d49660..83659c34fbfd472183fbc8b80298f3c5e877cf3b 100644
--- a/chrome/browser/budget_service/budget_manager_unittest.cc
+++ b/chrome/browser/budget_service/budget_manager_unittest.cc
@@ -76,8 +76,25 @@ class BudgetManagerTest : public testing::Test {
run_loop.Run();
}
- // Budget for callbacks to set.
+ void StatusCallback(base::Closure run_loop_closure, bool success) {
+ success_ = success;
+ run_loop_closure.Run();
+ }
+
+ bool ReserveBudget(blink::mojom::BudgetOperationType type) {
+ const GURL origin(kTestOrigin);
+ base::RunLoop run_loop;
+ GetManager()->Reserve(
+ origin, type,
+ base::Bind(&BudgetManagerTest::StatusCallback, base::Unretained(this),
+ run_loop.QuitClosure()));
+ run_loop.Run();
+ return success_;
+ }
+
+ // Members for callbacks to set.
double budget_;
+ bool success_;
private:
content::TestBrowserThreadBundle thread_bundle_;
@@ -247,3 +264,8 @@ TEST_F(BudgetManagerTest, GetBudgetNegativeTime) {
clock->SetNow(starting_time - base::TimeDelta::FromDays(1));
EXPECT_NEAR(original_budget, GetBudget(), 0.01);
}
+
+TEST_F(BudgetManagerTest, ReserveBudgetTest) {
+ // Reserve without any budget allocated should fail.
+ ASSERT_FALSE(ReserveBudget(blink::mojom::BudgetOperationType::SILENT_PUSH));
+}
« no previous file with comments | « chrome/browser/budget_service/budget_manager_factory.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698