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

Unified Diff: components/offline_pages/core/offline_page_model_query_unittest.cc

Issue 2858803002: [Offline Pages] Adding support for removed-on-cache-reset pages to query. (Closed)
Patch Set: reset offline_page_model.h Created 3 years, 8 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/offline_pages/core/offline_page_model_query.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/offline_pages/core/offline_page_model_query_unittest.cc
diff --git a/components/offline_pages/core/offline_page_model_query_unittest.cc b/components/offline_pages/core/offline_page_model_query_unittest.cc
index 5bd9d00ce90e01fcf964e1fdec68b0e3f18cd799..fad1c62313bdb7fe823d2d418370da6ea563fd79 100644
--- a/components/offline_pages/core/offline_page_model_query_unittest.cc
+++ b/components/offline_pages/core/offline_page_model_query_unittest.cc
@@ -37,6 +37,10 @@ class OfflinePageModelQueryTest : public testing::Test {
ClientPolicyController policy_;
OfflinePageModelQueryBuilder builder_;
+ const OfflinePageItem cache_page() {
+ return OfflinePageItem(GURL("https://download.com"), 3,
+ {kBookmarkNamespace, "id1"}, base::FilePath(), 3);
+ }
const OfflinePageItem download_page() {
return OfflinePageItem(GURL("https://download.com"), 4,
{kDownloadNamespace, "id1"}, base::FilePath(), 4);
@@ -278,6 +282,43 @@ TEST_F(OfflinePageModelQueryTest, UrlsReplace) {
EXPECT_TRUE(query->Matches(kTestItem2));
}
+TEST_F(OfflinePageModelQueryTest, RequireRemovedOnCacheReset_Only) {
+ builder_.RequireRemovedOnCacheReset(Requirement::INCLUDE_MATCHING);
+ std::unique_ptr<OfflinePageModelQuery> query = builder_.Build(&policy_);
+
+ auto restriction = query->GetRestrictedToNamespaces();
+ std::set<std::string> namespaces_allowed = restriction.second;
+ bool restricted_to_namespaces = restriction.first;
+ EXPECT_TRUE(restricted_to_namespaces);
+
+ for (const std::string& name_space : namespaces_allowed) {
+ EXPECT_TRUE(policy_.IsRemovedOnCacheReset(name_space))
+ << "Namespace: " << name_space;
+ }
+ EXPECT_TRUE(query->Matches(kTestItem1));
+ EXPECT_TRUE(query->Matches(cache_page()));
+ EXPECT_FALSE(query->Matches(download_page()));
+}
+
+TEST_F(OfflinePageModelQueryTest, RequireRemovedOnCacheReset_Except) {
+ builder_.RequireRemovedOnCacheReset(Requirement::EXCLUDE_MATCHING);
+ std::unique_ptr<OfflinePageModelQuery> query = builder_.Build(&policy_);
+
+ auto restriction = query->GetRestrictedToNamespaces();
+ std::set<std::string> namespaces_allowed = restriction.second;
+ bool restricted_to_namespaces = restriction.first;
+ EXPECT_TRUE(restricted_to_namespaces);
+
+ for (const std::string& name_space : namespaces_allowed) {
+ EXPECT_FALSE(policy_.IsRemovedOnCacheReset(name_space))
+ << "Namespace: " << name_space;
+ }
+
+ EXPECT_FALSE(query->Matches(kTestItem1));
+ EXPECT_FALSE(query->Matches(cache_page()));
+ EXPECT_TRUE(query->Matches(download_page()));
+}
+
TEST_F(OfflinePageModelQueryTest, RequireSupportedByDownload_Only) {
builder_.RequireSupportedByDownload(Requirement::INCLUDE_MATCHING);
std::unique_ptr<OfflinePageModelQuery> query = builder_.Build(&policy_);
« no previous file with comments | « components/offline_pages/core/offline_page_model_query.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698