Index: components/precache/core/precache_session_table_unittest.cc |
diff --git a/components/precache/core/precache_session_table_unittest.cc b/components/precache/core/precache_session_table_unittest.cc |
index a354032a5574613e459d4fab2e024c2533b4b938..13dbe0305bd7e339de3047948a623c26083f9615 100644 |
--- a/components/precache/core/precache_session_table_unittest.cc |
+++ b/components/precache/core/precache_session_table_unittest.cc |
@@ -7,6 +7,7 @@ |
#include "base/compiler_specific.h" |
#include "base/time/time.h" |
#include "components/precache/core/precache_session_table.h" |
+#include "components/precache/core/proto/quota.pb.h" |
#include "components/precache/core/proto/unfinished_work.pb.h" |
#include "sql/connection.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -153,6 +154,25 @@ TEST_F(PrecacheSessionTableTest, SaveDeleteGet) { |
EXPECT_EQ(0, unfinished_work2->top_host_size()); |
} |
+TEST_F(PrecacheSessionTableTest, SaveAndGetQuota) { |
+ // Initial quota, should have expired. |
+ EXPECT_LT(base::Time::FromInternalValue( |
+ precache_session_table_->GetQuota().expiry_time()), |
+ base::Time::Now()); |
+ |
+ PrecacheQuota quota; |
+ quota.set_expiry_time( |
+ (base::Time::Now() + base::TimeDelta::FromHours(1)).ToInternalValue()); |
+ quota.set_remaining(1000U); |
+ |
+ PrecacheQuota expected_quota = quota; |
+ precache_session_table_->SaveQuota(quota); |
+ EXPECT_EQ(expected_quota.expiry_time(), |
+ precache_session_table_->GetQuota().expiry_time()); |
+ EXPECT_EQ(expected_quota.remaining(), |
+ precache_session_table_->GetQuota().remaining()); |
+} |
+ |
} // namespace |
} // namespace precache |