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

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

Issue 2379783002: Instant App Banner logic. (Closed)
Patch Set: Fixing tests. 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 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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/browser/banners/app_banner_metrics.h" 8 #include "chrome/browser/banners/app_banner_metrics.h"
9 #include "chrome/browser/banners/app_banner_settings_helper.h" 9 #include "chrome/browser/banners/app_banner_settings_helper.h"
10 #include "chrome/browser/engagement/site_engagement_service.h" 10 #include "chrome/browser/engagement/site_engagement_service.h"
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 AppBannerSettingsHelper::ShouldShowBanner( 650 AppBannerSettingsHelper::ShouldShowBanner(
651 web_contents(), url, kTestPackageName, reference_time)); 651 web_contents(), url, kTestPackageName, reference_time));
652 } 652 }
653 653
654 TEST_F(AppBannerSettingsHelperTest, ShouldNotShowAfterShowing) { 654 TEST_F(AppBannerSettingsHelperTest, ShouldNotShowAfterShowing) {
655 GURL url(kTestURL); 655 GURL url(kTestURL);
656 NavigateAndCommit(url); 656 NavigateAndCommit(url);
657 657
658 base::Time reference_time = GetReferenceTime(); 658 base::Time reference_time = GetReferenceTime();
659 base::Time one_day_ago = reference_time - base::TimeDelta::FromDays(1); 659 base::Time one_day_ago = reference_time - base::TimeDelta::FromDays(1);
660 base::Time three_weeks_ago = reference_time - base::TimeDelta::FromDays(21); 660 base::Time one_week_ago = reference_time - base::TimeDelta::FromDays(7);
661 base::Time one_year_ago = reference_time - base::TimeDelta::FromDays(366); 661 base::Time one_year_ago = reference_time - base::TimeDelta::FromDays(366);
662 662
663 // By default the banner should not be shown. 663 // By default the banner should not be shown.
664 EXPECT_EQ(INSUFFICIENT_ENGAGEMENT, 664 EXPECT_EQ(INSUFFICIENT_ENGAGEMENT,
665 AppBannerSettingsHelper::ShouldShowBanner( 665 AppBannerSettingsHelper::ShouldShowBanner(
666 web_contents(), url, kTestPackageName, reference_time)); 666 web_contents(), url, kTestPackageName, reference_time));
667 667
668 // Record events such that the banner should show. 668 // Record events such that the banner should show.
669 AppBannerSettingsHelper::RecordBannerCouldShowEvent( 669 AppBannerSettingsHelper::RecordBannerCouldShowEvent(
670 web_contents(), url, kTestPackageName, one_day_ago, 670 web_contents(), url, kTestPackageName, one_day_ago,
671 ui::PAGE_TRANSITION_TYPED); 671 ui::PAGE_TRANSITION_TYPED);
672 AppBannerSettingsHelper::RecordBannerCouldShowEvent( 672 AppBannerSettingsHelper::RecordBannerCouldShowEvent(
673 web_contents(), url, kTestPackageName, reference_time, 673 web_contents(), url, kTestPackageName, reference_time,
674 ui::PAGE_TRANSITION_TYPED); 674 ui::PAGE_TRANSITION_TYPED);
675 EXPECT_EQ(NO_ERROR_DETECTED, 675 EXPECT_EQ(NO_ERROR_DETECTED,
676 AppBannerSettingsHelper::ShouldShowBanner( 676 AppBannerSettingsHelper::ShouldShowBanner(
677 web_contents(), url, kTestPackageName, reference_time)); 677 web_contents(), url, kTestPackageName, reference_time));
678 678
679 // Show the banner a long time ago. It should still be shown. 679 // Show the banner a long time ago. It should still be shown.
680 AppBannerSettingsHelper::RecordBannerEvent( 680 AppBannerSettingsHelper::RecordBannerEvent(
681 web_contents(), url, kTestPackageName, 681 web_contents(), url, kTestPackageName,
682 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_SHOW, one_year_ago); 682 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_SHOW, one_year_ago);
683 EXPECT_EQ(NO_ERROR_DETECTED, 683 EXPECT_EQ(NO_ERROR_DETECTED,
684 AppBannerSettingsHelper::ShouldShowBanner( 684 AppBannerSettingsHelper::ShouldShowBanner(
685 web_contents(), url, kTestPackageName, reference_time)); 685 web_contents(), url, kTestPackageName, reference_time));
686 686
687 // Show the site more recently. Now it should not be shown. 687 // Show the site more recently. Now it should not be shown.
688 AppBannerSettingsHelper::RecordBannerEvent( 688 AppBannerSettingsHelper::RecordBannerEvent(
689 web_contents(), url, kTestPackageName, 689 web_contents(), url, kTestPackageName,
690 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_SHOW, three_weeks_ago); 690 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_SHOW, one_week_ago);
691 EXPECT_EQ(PREVIOUSLY_IGNORED, 691 EXPECT_EQ(PREVIOUSLY_IGNORED,
692 AppBannerSettingsHelper::ShouldShowBanner( 692 AppBannerSettingsHelper::ShouldShowBanner(
693 web_contents(), url, kTestPackageName, reference_time)); 693 web_contents(), url, kTestPackageName, reference_time));
694 } 694 }
695 695
696 TEST_F(AppBannerSettingsHelperTest, ShouldNotShowAfterAdding) { 696 TEST_F(AppBannerSettingsHelperTest, ShouldNotShowAfterAdding) {
697 GURL url(kTestURL); 697 GURL url(kTestURL);
698 NavigateAndCommit(url); 698 NavigateAndCommit(url);
699 699
700 base::Time reference_time = GetReferenceTime(); 700 base::Time reference_time = GetReferenceTime();
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 first_day); 871 first_day);
872 EXPECT_TRUE( 872 EXPECT_TRUE(
873 AppBannerSettingsHelper::WasLaunchedRecently(profile(), url, first_day)); 873 AppBannerSettingsHelper::WasLaunchedRecently(profile(), url, first_day));
874 EXPECT_TRUE( 874 EXPECT_TRUE(
875 AppBannerSettingsHelper::WasLaunchedRecently(profile(), url, ninth_day)); 875 AppBannerSettingsHelper::WasLaunchedRecently(profile(), url, ninth_day));
876 EXPECT_TRUE( 876 EXPECT_TRUE(
877 AppBannerSettingsHelper::WasLaunchedRecently(profile(), url, tenth_day)); 877 AppBannerSettingsHelper::WasLaunchedRecently(profile(), url, tenth_day));
878 EXPECT_TRUE(AppBannerSettingsHelper::WasLaunchedRecently(profile(), url, 878 EXPECT_TRUE(AppBannerSettingsHelper::WasLaunchedRecently(profile(), url,
879 eleventh_day)); 879 eleventh_day));
880 } 880 }
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