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

Unified Diff: chrome/browser/banners/app_banner_settings_helper_unittest.cc

Issue 1019763002: Added test to ensure app banner settings are per-origin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/banners/app_banner_settings_helper_unittest.cc
diff --git a/chrome/browser/banners/app_banner_settings_helper_unittest.cc b/chrome/browser/banners/app_banner_settings_helper_unittest.cc
index e744c0eb8fa7343a279fd70c443318708c45491a..95eeda2ddac0463744ce9ad69d14fe35e2b3d39f 100644
--- a/chrome/browser/banners/app_banner_settings_helper_unittest.cc
+++ b/chrome/browser/banners/app_banner_settings_helper_unittest.cc
@@ -10,6 +10,7 @@
namespace {
const char kTestURL[] = "https://www.google.com";
+const char kSameOriginTestURL[] = "https://www.google.com/foo.html";
const char kTestPackageName[] = "test.package";
base::Time GetReferenceTime() {
@@ -290,3 +291,31 @@ TEST_F(AppBannerSettingsHelperTest, ShouldNotShowAfterAdding) {
EXPECT_FALSE(AppBannerSettingsHelper::ShouldShowBanner(
web_contents(), url, kTestPackageName, reference_time));
}
+
+TEST_F(AppBannerSettingsHelperTest, OperatesOnOrigins) {
+ GURL url(kTestURL);
+ NavigateAndCommit(url);
+
+ base::Time reference_time = GetReferenceTime();
+ base::Time one_day_ago = reference_time - base::TimeDelta::FromDays(1);
+
+ // By default the banner should not be shown.
+ EXPECT_FALSE(AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, reference_time));
+
+ // Record events such that the banner should show.
+ AppBannerSettingsHelper::RecordBannerEvent(
+ web_contents(), url, kTestPackageName,
+ AppBannerSettingsHelper::APP_BANNER_EVENT_COULD_SHOW, one_day_ago);
+ AppBannerSettingsHelper::RecordBannerEvent(
+ web_contents(), url, kTestPackageName,
+ AppBannerSettingsHelper::APP_BANNER_EVENT_COULD_SHOW, reference_time);
+
+ // Navigate to another page on the same origin.
+ url = GURL(kSameOriginTestURL);
+ NavigateAndCommit(url);
+
+ // The banner should show as settings are per-origin.
+ EXPECT_TRUE(AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, reference_time));
+}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698