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

Side by Side Diff: chrome/browser/banners/app_banner_settings_helper_unittest.cc

Issue 1017193002: [App banners] Be less strict about navigations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git cl format 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/banners/app_banner_settings_helper.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <vector> 5 #include <vector>
6 6
7 #include "chrome/browser/banners/app_banner_settings_helper.h" 7 #include "chrome/browser/banners/app_banner_settings_helper.h"
8 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 8 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
9 9
10 namespace { 10 namespace {
(...skipping 17 matching lines...) Expand all
28 28
29 bool IsWithinDay(base::Time time1, base::Time time2) { 29 bool IsWithinDay(base::Time time1, base::Time time2) {
30 return time1 - time2 < base::TimeDelta::FromDays(1) || 30 return time1 - time2 < base::TimeDelta::FromDays(1) ||
31 time2 - time1 < base::TimeDelta::FromDays(1); 31 time2 - time1 < base::TimeDelta::FromDays(1);
32 } 32 }
33 33
34 class AppBannerSettingsHelperTest : public ChromeRenderViewHostTestHarness {}; 34 class AppBannerSettingsHelperTest : public ChromeRenderViewHostTestHarness {};
35 35
36 } // namespace 36 } // namespace
37 37
38 TEST_F(AppBannerSettingsHelperTest, Block) {
39 GURL url(kTestURL);
40 NavigateAndCommit(url);
41
42 // Check that by default, showing the banner is allowed.
43 EXPECT_TRUE(AppBannerSettingsHelper::IsAllowed(web_contents(), url,
44 kTestPackageName));
45
46 // Block the banner and test it is no longer allowed.
47 AppBannerSettingsHelper::Block(web_contents(), url, kTestPackageName);
48 EXPECT_FALSE(AppBannerSettingsHelper::IsAllowed(web_contents(), url,
49 kTestPackageName));
50 }
51
52 TEST_F(AppBannerSettingsHelperTest, CouldShowEvents) { 38 TEST_F(AppBannerSettingsHelperTest, CouldShowEvents) {
53 GURL url(kTestURL); 39 GURL url(kTestURL);
54 NavigateAndCommit(url); 40 NavigateAndCommit(url);
55 41
56 // Check that by default, there are no events recorded. 42 // Check that by default, there are no events recorded.
57 std::vector<base::Time> events = 43 std::vector<base::Time> events =
58 AppBannerSettingsHelper::GetCouldShowBannerEvents(web_contents(), url, 44 AppBannerSettingsHelper::GetCouldShowBannerEvents(web_contents(), url,
59 kTestPackageName); 45 kTestPackageName);
60 EXPECT_TRUE(events.empty()); 46 EXPECT_TRUE(events.empty());
61 47
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 web_contents(), url, kTestPackageName, reference_time)); 269 web_contents(), url, kTestPackageName, reference_time));
284 270
285 // Add the site a long time ago. It should not be shown. 271 // Add the site a long time ago. It should not be shown.
286 AppBannerSettingsHelper::RecordBannerEvent( 272 AppBannerSettingsHelper::RecordBannerEvent(
287 web_contents(), url, kTestPackageName, 273 web_contents(), url, kTestPackageName,
288 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN, 274 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN,
289 one_year_ago); 275 one_year_ago);
290 EXPECT_FALSE(AppBannerSettingsHelper::ShouldShowBanner( 276 EXPECT_FALSE(AppBannerSettingsHelper::ShouldShowBanner(
291 web_contents(), url, kTestPackageName, reference_time)); 277 web_contents(), url, kTestPackageName, reference_time));
292 } 278 }
OLDNEW
« no previous file with comments | « chrome/browser/banners/app_banner_settings_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698