Chromium Code Reviews| Index: chrome/browser/budget_service/budget_database_unittest.cc |
| diff --git a/chrome/browser/budget_service/budget_database_unittest.cc b/chrome/browser/budget_service/budget_database_unittest.cc |
| index 25a646e231a91035dc1500e43c58a2db9049d8da..2d2cf0ac47fb188864442011badda031791a7e34 100644 |
| --- a/chrome/browser/budget_service/budget_database_unittest.cc |
| +++ b/chrome/browser/budget_service/budget_database_unittest.cc |
| @@ -101,6 +101,7 @@ TEST_F(BudgetDatabaseTest, ReadAndWriteTest) { |
| base::SimpleTestClock* clock = SetClockForTesting(); |
| base::TimeDelta expiration( |
| base::TimeDelta::FromHours(kDefaultExpirationInHours)); |
| + base::Time starting_time = clock->Now(); |
| base::Time expiration_time = clock->Now() + expiration; |
| // Add two budget chunks with different expirations (default expiration and |
| @@ -122,9 +123,7 @@ TEST_F(BudgetDatabaseTest, ReadAndWriteTest) { |
| // First value should be [total_budget, now] |
| EXPECT_EQ(kDefaultBudget1 + kDefaultBudget2, iter->first); |
| - // TODO(harkness): This will be "now" in the final version. For now, it's |
| - // just 0. |
| - EXPECT_EQ(0, iter->second); |
| + EXPECT_EQ(clock->Now().ToInternalValue(), iter->second); |
| // The next value should be the budget after the first chunk expires. |
| iter++; |
| @@ -136,4 +135,24 @@ TEST_F(BudgetDatabaseTest, ReadAndWriteTest) { |
| iter++; |
| EXPECT_EQ(0, iter->first); |
| EXPECT_EQ(expiration_time.ToInternalValue(), iter->second); |
| + |
| + // Advance the time until the first chunk of budget should be expired. |
| + clock->SetNow(starting_time + |
| + base::TimeDelta::FromHours(kDefaultExpirationInHours)); |
| + |
| + // Get the new budget and check that kDefaultBudget1 has been removed. |
| + GetBudgetDetails(); |
| + iter = expectation().begin(); |
|
Peter Beverloo
2016/08/01 17:35:28
Please ASSERT() something before this line, if beg
harkness
2016/08/08 14:42:43
Done.
|
| + EXPECT_EQ(kDefaultBudget2, iter->first); |
| + iter++; |
| + EXPECT_EQ(0, iter->first); |
| + |
| + // Advace the time until both chunks of budget should be expired. |
| + clock->SetNow(starting_time + |
| + base::TimeDelta::FromHours(kDefaultExpirationInHours) + |
| + base::TimeDelta::FromDays(1)); |
| + |
| + GetBudgetDetails(); |
| + iter = expectation().begin(); |
| + EXPECT_EQ(0, iter->first); |
| } |