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

Unified Diff: components/precache/core/precache_session_table_unittest.cc

Issue 2335913002: Add daily quota for precache (Closed)
Patch Set: Addressed sclittle comments 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
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

Powered by Google App Engine
This is Rietveld 408576698