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

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

Issue 2364873004: Add Precache.CacheStatus.NonPrefetch.FromPrecache. (Closed)
Patch Set: Add const. Created 4 years, 2 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 | « components/precache/core/precache_url_table.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/precache/core/precache_url_table_unittest.cc
diff --git a/components/precache/core/precache_url_table_unittest.cc b/components/precache/core/precache_url_table_unittest.cc
index dbc36a19f5af36cb32f0ae96568cd22bcfb418ce..6a764e30b2f53826b85728712833c0afc9719592 100644
--- a/components/precache/core/precache_url_table_unittest.cc
+++ b/components/precache/core/precache_url_table_unittest.cc
@@ -17,6 +17,11 @@
namespace precache {
+void PrintTo(const PrecacheURLInfo& url_info, ::std::ostream* os) {
+ *os << "{" << url_info.was_precached << ", " << url_info.is_precached << ", "
+ << url_info.was_used << "}";
+}
+
namespace {
class PrecacheURLTableTest : public testing::Test {
@@ -80,17 +85,31 @@ TEST_F(PrecacheURLTableTest, SetURLAsNotPrecached) {
EXPECT_EQ(expected_map, actual_map);
}
-TEST_F(PrecacheURLTableTest, IsURLPrecached) {
- EXPECT_FALSE(precache_url_table_->IsURLPrecached(GURL("http://url.com")));
+TEST_F(PrecacheURLTableTest, GetURLInfo) {
+ const GURL url("http://url.com");
+
+ EXPECT_EQ((PrecacheURLInfo{false, false, false}),
+ precache_url_table_->GetURLInfo(url));
+
+ precache_url_table_->AddURL(url, 1, true, base::Time::FromInternalValue(100));
+
+ EXPECT_EQ((PrecacheURLInfo{true, true, false}),
+ precache_url_table_->GetURLInfo(url));
+
+ precache_url_table_->SetPrecachedURLAsUsed(url);
+
+ EXPECT_EQ((PrecacheURLInfo{true, false, true}),
+ precache_url_table_->GetURLInfo(url));
- precache_url_table_->AddURL(GURL("http://url.com"), 1, true,
- base::Time::FromInternalValue(100));
+ precache_url_table_->AddURL(url, 1, true, base::Time::FromInternalValue(100));
- EXPECT_TRUE(precache_url_table_->IsURLPrecached(GURL("http://url.com")));
+ EXPECT_EQ((PrecacheURLInfo{true, true, false}),
+ precache_url_table_->GetURLInfo(url));
- precache_url_table_->SetURLAsNotPrecached(GURL("http://url.com"));
+ precache_url_table_->SetURLAsNotPrecached(url);
- EXPECT_FALSE(precache_url_table_->IsURLPrecached(GURL("http://url.com")));
+ EXPECT_EQ((PrecacheURLInfo{true, false, false}),
+ precache_url_table_->GetURLInfo(url));
}
TEST_F(PrecacheURLTableTest, DeleteAllPrecachedBefore) {
« no previous file with comments | « components/precache/core/precache_url_table.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698