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

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

Issue 2178833002: Add new app banner metrics using InstallableStatusCode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@banner-integrate-checker-no-refptr
Patch Set: Fix histogram name Created 4 years, 4 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/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 46ed446c7e24c13b1e27b5ae44705140605db931..12bef9b0e11aed806a7523a005b11a1549b186ef 100644
--- a/chrome/browser/banners/app_banner_settings_helper_unittest.cc
+++ b/chrome/browser/banners/app_banner_settings_helper_unittest.cc
@@ -8,6 +8,7 @@
#include "chrome/browser/banners/app_banner_metrics.h"
#include "chrome/browser/banners/app_banner_settings_helper.h"
#include "chrome/browser/engagement/site_engagement_service.h"
+#include "chrome/browser/installable/installable_logging.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chrome/test/base/testing_profile.h"
@@ -513,35 +514,40 @@ TEST_F(AppBannerSettingsHelperTest, IndirectEngagementWithLowerWeight) {
base::Time fourth_day = reference_time + base::TimeDelta::FromDays(3);
// By default the banner should not be shown.
- EXPECT_FALSE(AppBannerSettingsHelper::ShouldShowBanner(
- web_contents(), url, kTestPackageName, reference_time));
+ EXPECT_EQ(INSUFFICIENT_ENGAGEMENT,
+ AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, reference_time));
// It should take four indirect visits with a weight of 0.5 to trigger the
// banner.
AppBannerSettingsHelper::RecordBannerCouldShowEvent(
web_contents(), url, kTestPackageName, reference_time,
ui::PAGE_TRANSITION_LINK);
- EXPECT_FALSE(AppBannerSettingsHelper::ShouldShowBanner(
- web_contents(), url, kTestPackageName, reference_time));
+ EXPECT_EQ(INSUFFICIENT_ENGAGEMENT,
+ AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, reference_time));
AppBannerSettingsHelper::RecordBannerCouldShowEvent(
web_contents(), url, kTestPackageName, second_day,
ui::PAGE_TRANSITION_LINK);
- EXPECT_FALSE(AppBannerSettingsHelper::ShouldShowBanner(
- web_contents(), url, kTestPackageName, second_day));
+ EXPECT_EQ(INSUFFICIENT_ENGAGEMENT,
+ AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, second_day));
AppBannerSettingsHelper::RecordBannerCouldShowEvent(
web_contents(), url, kTestPackageName, third_day,
ui::PAGE_TRANSITION_FORM_SUBMIT);
- EXPECT_FALSE(AppBannerSettingsHelper::ShouldShowBanner(
- web_contents(), url, kTestPackageName, third_day));
+ EXPECT_EQ(INSUFFICIENT_ENGAGEMENT,
+ AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, third_day));
// Visit the site again; now it should be shown.
AppBannerSettingsHelper::RecordBannerCouldShowEvent(
web_contents(), url, kTestPackageName, fourth_day,
ui::PAGE_TRANSITION_MANUAL_SUBFRAME);
- EXPECT_TRUE(AppBannerSettingsHelper::ShouldShowBanner(
- web_contents(), url, kTestPackageName, fourth_day));
+ EXPECT_EQ(NO_ERROR_DETECTED,
+ AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, fourth_day));
}
TEST_F(AppBannerSettingsHelperTest, DirectEngagementWithHigherWeight) {
@@ -552,15 +558,17 @@ TEST_F(AppBannerSettingsHelperTest, DirectEngagementWithHigherWeight) {
base::Time reference_time = GetReferenceTime();
// By default the banner should not be shown.
- EXPECT_FALSE(AppBannerSettingsHelper::ShouldShowBanner(
- web_contents(), url, kTestPackageName, reference_time));
+ EXPECT_EQ(INSUFFICIENT_ENGAGEMENT,
+ AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, reference_time));
// It should take one direct visit with a weight of 2 to trigger the banner.
AppBannerSettingsHelper::RecordBannerCouldShowEvent(
web_contents(), url, kTestPackageName, reference_time,
ui::PAGE_TRANSITION_TYPED);
- EXPECT_TRUE(AppBannerSettingsHelper::ShouldShowBanner(
- web_contents(), url, kTestPackageName, reference_time));
+ EXPECT_EQ(NO_ERROR_DETECTED,
+ AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, reference_time));
}
TEST_F(AppBannerSettingsHelperTest, ShouldShowFromEngagement) {
@@ -572,29 +580,33 @@ TEST_F(AppBannerSettingsHelperTest, ShouldShowFromEngagement) {
base::Time one_year_ago = reference_time - base::TimeDelta::FromDays(366);
// By default the banner should not be shown.
- EXPECT_FALSE(AppBannerSettingsHelper::ShouldShowBanner(
- web_contents(), url, kTestPackageName, reference_time));
+ EXPECT_EQ(INSUFFICIENT_ENGAGEMENT,
+ AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, reference_time));
// Visit the site once, it still should not be shown.
AppBannerSettingsHelper::RecordBannerCouldShowEvent(
web_contents(), url, kTestPackageName, one_year_ago,
ui::PAGE_TRANSITION_TYPED);
- EXPECT_FALSE(AppBannerSettingsHelper::ShouldShowBanner(
- web_contents(), url, kTestPackageName, reference_time));
+ EXPECT_EQ(INSUFFICIENT_ENGAGEMENT,
+ AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, reference_time));
// Visit the site again after a long delay, it still should not be shown.
AppBannerSettingsHelper::RecordBannerCouldShowEvent(
web_contents(), url, kTestPackageName, one_day_ago,
ui::PAGE_TRANSITION_TYPED);
- EXPECT_FALSE(AppBannerSettingsHelper::ShouldShowBanner(
- web_contents(), url, kTestPackageName, reference_time));
+ EXPECT_EQ(INSUFFICIENT_ENGAGEMENT,
+ AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, reference_time));
// Visit the site again; now it should be shown.
AppBannerSettingsHelper::RecordBannerCouldShowEvent(
web_contents(), url, kTestPackageName, reference_time,
ui::PAGE_TRANSITION_TYPED);
- EXPECT_TRUE(AppBannerSettingsHelper::ShouldShowBanner(
- web_contents(), url, kTestPackageName, reference_time));
+ EXPECT_EQ(NO_ERROR_DETECTED,
+ AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, reference_time));
}
TEST_F(AppBannerSettingsHelperTest, ShouldNotShowAfterBlocking) {
@@ -607,8 +619,9 @@ TEST_F(AppBannerSettingsHelperTest, ShouldNotShowAfterBlocking) {
base::Time one_year_ago = reference_time - base::TimeDelta::FromDays(366);
// By default the banner should not be shown.
- EXPECT_FALSE(AppBannerSettingsHelper::ShouldShowBanner(
- web_contents(), url, kTestPackageName, reference_time));
+ EXPECT_EQ(INSUFFICIENT_ENGAGEMENT,
+ AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, reference_time));
// Record events such that the banner should show.
AppBannerSettingsHelper::RecordBannerCouldShowEvent(
@@ -617,22 +630,25 @@ TEST_F(AppBannerSettingsHelperTest, ShouldNotShowAfterBlocking) {
AppBannerSettingsHelper::RecordBannerCouldShowEvent(
web_contents(), url, kTestPackageName, reference_time,
ui::PAGE_TRANSITION_TYPED);
- EXPECT_TRUE(AppBannerSettingsHelper::ShouldShowBanner(
- web_contents(), url, kTestPackageName, reference_time));
+ EXPECT_EQ(NO_ERROR_DETECTED,
+ AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, reference_time));
// Block the site a long time ago. It should still be shown.
AppBannerSettingsHelper::RecordBannerEvent(
web_contents(), url, kTestPackageName,
AppBannerSettingsHelper::APP_BANNER_EVENT_DID_BLOCK, one_year_ago);
- EXPECT_TRUE(AppBannerSettingsHelper::ShouldShowBanner(
- web_contents(), url, kTestPackageName, reference_time));
+ EXPECT_EQ(NO_ERROR_DETECTED,
+ AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, reference_time));
// Block the site more recently. Now it should not be shown.
AppBannerSettingsHelper::RecordBannerEvent(
web_contents(), url, kTestPackageName,
AppBannerSettingsHelper::APP_BANNER_EVENT_DID_BLOCK, two_months_ago);
- EXPECT_FALSE(AppBannerSettingsHelper::ShouldShowBanner(
- web_contents(), url, kTestPackageName, reference_time));
+ EXPECT_EQ(PREVIOUSLY_BLOCKED,
+ AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, reference_time));
}
TEST_F(AppBannerSettingsHelperTest, ShouldNotShowAfterShowing) {
@@ -645,8 +661,9 @@ TEST_F(AppBannerSettingsHelperTest, ShouldNotShowAfterShowing) {
base::Time one_year_ago = reference_time - base::TimeDelta::FromDays(366);
// By default the banner should not be shown.
- EXPECT_FALSE(AppBannerSettingsHelper::ShouldShowBanner(
- web_contents(), url, kTestPackageName, reference_time));
+ EXPECT_EQ(INSUFFICIENT_ENGAGEMENT,
+ AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, reference_time));
// Record events such that the banner should show.
AppBannerSettingsHelper::RecordBannerCouldShowEvent(
@@ -655,22 +672,25 @@ TEST_F(AppBannerSettingsHelperTest, ShouldNotShowAfterShowing) {
AppBannerSettingsHelper::RecordBannerCouldShowEvent(
web_contents(), url, kTestPackageName, reference_time,
ui::PAGE_TRANSITION_TYPED);
- EXPECT_TRUE(AppBannerSettingsHelper::ShouldShowBanner(
- web_contents(), url, kTestPackageName, reference_time));
+ EXPECT_EQ(NO_ERROR_DETECTED,
+ AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, reference_time));
// Show the banner a long time ago. It should still be shown.
AppBannerSettingsHelper::RecordBannerEvent(
web_contents(), url, kTestPackageName,
AppBannerSettingsHelper::APP_BANNER_EVENT_DID_SHOW, one_year_ago);
- EXPECT_TRUE(AppBannerSettingsHelper::ShouldShowBanner(
- web_contents(), url, kTestPackageName, reference_time));
+ EXPECT_EQ(NO_ERROR_DETECTED,
+ AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, reference_time));
// Show the site more recently. Now it should not be shown.
AppBannerSettingsHelper::RecordBannerEvent(
web_contents(), url, kTestPackageName,
AppBannerSettingsHelper::APP_BANNER_EVENT_DID_SHOW, three_weeks_ago);
- EXPECT_FALSE(AppBannerSettingsHelper::ShouldShowBanner(
- web_contents(), url, kTestPackageName, reference_time));
+ EXPECT_EQ(PREVIOUSLY_IGNORED,
+ AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, reference_time));
}
TEST_F(AppBannerSettingsHelperTest, ShouldNotShowAfterAdding) {
@@ -682,8 +702,9 @@ TEST_F(AppBannerSettingsHelperTest, ShouldNotShowAfterAdding) {
base::Time one_year_ago = reference_time - base::TimeDelta::FromDays(366);
// By default the banner should not be shown.
- EXPECT_FALSE(AppBannerSettingsHelper::ShouldShowBanner(
- web_contents(), url, kTestPackageName, reference_time));
+ EXPECT_EQ(INSUFFICIENT_ENGAGEMENT,
+ AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, reference_time));
// Record events such that the banner should show.
AppBannerSettingsHelper::RecordBannerCouldShowEvent(
@@ -692,16 +713,18 @@ TEST_F(AppBannerSettingsHelperTest, ShouldNotShowAfterAdding) {
AppBannerSettingsHelper::RecordBannerCouldShowEvent(
web_contents(), url, kTestPackageName, reference_time,
ui::PAGE_TRANSITION_TYPED);
- EXPECT_TRUE(AppBannerSettingsHelper::ShouldShowBanner(
- web_contents(), url, kTestPackageName, reference_time));
+ EXPECT_EQ(NO_ERROR_DETECTED,
+ AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, reference_time));
// Add the site a long time ago. It should not be shown.
AppBannerSettingsHelper::RecordBannerEvent(
web_contents(), url, kTestPackageName,
AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN,
one_year_ago);
- EXPECT_FALSE(AppBannerSettingsHelper::ShouldShowBanner(
- web_contents(), url, kTestPackageName, reference_time));
+ EXPECT_EQ(ALREADY_INSTALLED,
+ AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, reference_time));
}
TEST_F(AppBannerSettingsHelperTest, OperatesOnOrigins) {
@@ -712,8 +735,9 @@ TEST_F(AppBannerSettingsHelperTest, OperatesOnOrigins) {
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));
+ EXPECT_EQ(INSUFFICIENT_ENGAGEMENT,
+ AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, reference_time));
// Record events such that the banner should show.
AppBannerSettingsHelper::RecordBannerCouldShowEvent(
@@ -728,8 +752,9 @@ TEST_F(AppBannerSettingsHelperTest, OperatesOnOrigins) {
NavigateAndCommit(url);
// The banner should show as settings are per-origin.
- EXPECT_TRUE(AppBannerSettingsHelper::ShouldShowBanner(
- web_contents(), url, kTestPackageName, reference_time));
+ EXPECT_EQ(NO_ERROR_DETECTED,
+ AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, reference_time));
}
TEST_F(AppBannerSettingsHelperTest, ShouldShowWithHigherTotal) {
@@ -743,40 +768,46 @@ TEST_F(AppBannerSettingsHelperTest, ShouldShowWithHigherTotal) {
base::Time fourth_day = reference_time + base::TimeDelta::FromDays(3);
base::Time fifth_day = reference_time + base::TimeDelta::FromDays(4);
- EXPECT_FALSE(AppBannerSettingsHelper::ShouldShowBanner(
- web_contents(), url, kTestPackageName, reference_time));
+ EXPECT_EQ(INSUFFICIENT_ENGAGEMENT,
+ AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, reference_time));
// It should take five visits to trigger the banner.
AppBannerSettingsHelper::RecordBannerCouldShowEvent(
web_contents(), url, kTestPackageName, reference_time,
ui::PAGE_TRANSITION_LINK);
- EXPECT_FALSE(AppBannerSettingsHelper::ShouldShowBanner(
- web_contents(), url, kTestPackageName, reference_time));
+ EXPECT_EQ(INSUFFICIENT_ENGAGEMENT,
+ AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, reference_time));
AppBannerSettingsHelper::RecordBannerCouldShowEvent(
web_contents(), url, kTestPackageName, second_day,
ui::PAGE_TRANSITION_TYPED);
- EXPECT_FALSE(AppBannerSettingsHelper::ShouldShowBanner(
- web_contents(), url, kTestPackageName, second_day));
+ EXPECT_EQ(INSUFFICIENT_ENGAGEMENT,
+ AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, reference_time));
AppBannerSettingsHelper::RecordBannerCouldShowEvent(
web_contents(), url, kTestPackageName, third_day,
ui::PAGE_TRANSITION_GENERATED);
- EXPECT_FALSE(AppBannerSettingsHelper::ShouldShowBanner(
- web_contents(), url, kTestPackageName, third_day));
+ EXPECT_EQ(INSUFFICIENT_ENGAGEMENT,
+ AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, reference_time));
AppBannerSettingsHelper::RecordBannerCouldShowEvent(
web_contents(), url, kTestPackageName, fourth_day,
ui::PAGE_TRANSITION_LINK);
- EXPECT_FALSE(AppBannerSettingsHelper::ShouldShowBanner(
- web_contents(), url, kTestPackageName, fourth_day));
+ EXPECT_EQ(INSUFFICIENT_ENGAGEMENT,
+ AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, reference_time));
// Visit the site again; now it should be shown.
AppBannerSettingsHelper::RecordBannerCouldShowEvent(
web_contents(), url, kTestPackageName, fifth_day,
ui::PAGE_TRANSITION_TYPED);
- EXPECT_TRUE(AppBannerSettingsHelper::ShouldShowBanner(
- web_contents(), url, kTestPackageName, fifth_day));
+ EXPECT_EQ(NO_ERROR_DETECTED,
+ AppBannerSettingsHelper::ShouldShowBanner(
+ web_contents(), url, kTestPackageName, reference_time));
}
TEST_F(AppBannerSettingsHelperTest, WasLaunchedRecently) {
« no previous file with comments | « chrome/browser/banners/app_banner_settings_helper.cc ('k') | chrome/browser/installable/installable_logging.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698