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

Unified Diff: chrome/browser/content_settings/host_content_settings_map_unittest.cc

Issue 2812113004: Write last_modified date to Content Settings in the PrefProvider (Closed)
Patch Set: Fix Android compilation 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
Index: chrome/browser/content_settings/host_content_settings_map_unittest.cc
diff --git a/chrome/browser/content_settings/host_content_settings_map_unittest.cc b/chrome/browser/content_settings/host_content_settings_map_unittest.cc
index 6b07d537d453c8ef6abc7a22aa97ff0c3f727cc6..546163e6f3d80d13eb09cdc54dd386afe57316ed 100644
--- a/chrome/browser/content_settings/host_content_settings_map_unittest.cc
+++ b/chrome/browser/content_settings/host_content_settings_map_unittest.cc
@@ -41,10 +41,18 @@ namespace {
bool MatchPrimaryPattern(const ContentSettingsPattern& expected_primary,
const ContentSettingsPattern& primary_pattern,
- const ContentSettingsPattern& secondary_pattern) {
+ const ContentSettingsPattern& secondary_pattern,
+ base::Time last_modified) {
return expected_primary == primary_pattern;
}
+bool MatchLastModified(base::Time begin_time,
+ const ContentSettingsPattern& primary_pattern,
+ const ContentSettingsPattern& secondary_pattern,
+ base::Time last_modified) {
+ return last_modified >= begin_time;
+}
+
} // namespace
class HostContentSettingsMapTest : public testing::Test {
@@ -1743,6 +1751,47 @@ TEST_F(HostContentSettingsMapTest, ClearSettingsForOneTypeWithPredicate) {
host_settings[0].primary_pattern);
}
+TEST_F(HostContentSettingsMapTest, ClearSettingsForOneTypeWithPredicateTime) {
+ if (!HostContentSettingsMap::kStoreLastModified) {
+ return;
+ }
+ TestingProfile profile;
+ HostContentSettingsMap* host_content_settings_map =
+ HostContentSettingsMapFactory::GetForProfile(&profile);
+ ContentSettingsForOneType host_settings;
+
+ GURL url1("https://www.google.com/");
+ GURL url2("https://maps.google.com/");
+
+ // Add setting for url1.
+ host_content_settings_map->SetContentSettingDefaultScope(
+ url1, GURL(), CONTENT_SETTINGS_TYPE_POPUPS, std::string(),
+ CONTENT_SETTING_BLOCK);
+
+ base::Time t2 = base::Time::Now();
+ // Add setting for url2.
+ host_content_settings_map->SetContentSettingDefaultScope(
+ url2, GURL(), CONTENT_SETTINGS_TYPE_POPUPS, std::string(),
+ CONTENT_SETTING_BLOCK);
+
+ // Verify we have two pattern and the default.
+ host_content_settings_map->GetSettingsForOneType(
+ CONTENT_SETTINGS_TYPE_POPUPS, std::string(), &host_settings);
+ EXPECT_EQ(3u, host_settings.size());
+
+ // Clear all settings since t2.
+ host_content_settings_map->ClearSettingsForOneTypeWithPredicate(
+ CONTENT_SETTINGS_TYPE_POPUPS, base::Bind(&MatchLastModified, t2));
+
+ // Verify we only have one pattern (url1) and the default.
+ host_content_settings_map->GetSettingsForOneType(
+ CONTENT_SETTINGS_TYPE_POPUPS, std::string(), &host_settings);
+ EXPECT_EQ(2u, host_settings.size());
+ EXPECT_EQ("https://www.google.com:443",
+ host_settings[0].primary_pattern.ToString());
+ EXPECT_EQ("*", host_settings[1].primary_pattern.ToString());
+}
msramek 2017/04/19 10:49:16 Please also add a test with resource identifiers.
dullweber 2017/04/19 15:02:45 I added a test and discovered that ClearSettingsFo
+
TEST_F(HostContentSettingsMapTest, CanSetNarrowestSetting) {
TestingProfile profile;
const auto* map = HostContentSettingsMapFactory::GetForProfile(&profile);

Powered by Google App Engine
This is Rietveld 408576698