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

Unified Diff: chrome/browser/banners/app_banner_manager_browsertest.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: Rebase 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_manager_browsertest.cc
diff --git a/chrome/browser/banners/app_banner_manager_browsertest.cc b/chrome/browser/banners/app_banner_manager_browsertest.cc
index c4a174a8801dc04c8639af6386e00a875bc885be..616d4a4d4f832b90181fa4c6a478ee0696e2ccb4 100644
--- a/chrome/browser/banners/app_banner_manager_browsertest.cc
+++ b/chrome/browser/banners/app_banner_manager_browsertest.cc
@@ -31,7 +31,7 @@ class AppBannerManagerTest : public AppBannerManager {
public:
explicit AppBannerManagerTest(content::WebContents* web_contents)
: AppBannerManager(web_contents) {}
- ~AppBannerManagerTest() override {}
+ ~AppBannerManagerTest() override { }
benwells 2016/08/11 04:47:34 Nit: leave as {}
dominickn 2016/08/11 07:00:19 Done.
bool will_show() { return will_show_.get() && *will_show_; }
@@ -60,6 +60,9 @@ class AppBannerManagerTest : public AppBannerManager {
}
void ShowBanner() override {
+ // Fake the call to TrackInstallableErrorCode here - this is usually called
+ // in platform-specific code which is not exposed here.
+ TrackInstallableErrorCode(SHOWING_WEB_APP_BANNER);
ASSERT_FALSE(will_show_.get());
will_show_.reset(new bool(true));
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure_);
@@ -101,7 +104,6 @@ class AppBannerManagerBrowserTest : public InProcessBrowserTest {
base::RunLoop& run_loop,
ui::PageTransition transition,
bool expected_to_show) {
- base::HistogramTester histograms;
manager->set_page_transition_(transition);
manager->RequestAppBanner(url, false, run_loop.QuitClosure());
run_loop.Run();
@@ -110,14 +112,15 @@ class AppBannerManagerBrowserTest : public InProcessBrowserTest {
ASSERT_FALSE(manager->is_active());
// If showing the banner, ensure that the minutes histogram is recorded.
- histograms.ExpectTotalCount(banners::kMinutesHistogram,
+ histograms_.ExpectTotalCount(banners::kMinutesHistogram,
(manager->will_show() ? 1 : 0));
}
void RunBannerTest(const std::string& url,
ui::PageTransition transition,
unsigned int unshown_repetitions,
- bool expectation) {
+ InstallableErrorCode expected_code_for_histogram,
+ bool expected_to_show) {
std::string valid_page(url);
GURL test_url = embedded_test_server()->GetURL(valid_page);
content::WebContents* web_contents =
@@ -130,6 +133,7 @@ class AppBannerManagerBrowserTest : public InProcessBrowserTest {
base::RunLoop run_loop;
RequestAppBanner(manager.get(), web_contents->GetLastCommittedURL(),
run_loop, transition, false);
+ CheckInstallableErrorCodeHistogram(INSUFFICIENT_ENGAGEMENT, i+1, i+1);
gone 2016/08/10 21:02:51 Should be consistent about the i+1 vs i + 1 below.
dominickn 2016/08/11 07:00:19 Done.
AppBannerManager::SetTimeDeltaForTesting(i + 1);
}
@@ -137,40 +141,55 @@ class AppBannerManagerBrowserTest : public InProcessBrowserTest {
ui_test_utils::NavigateToURL(browser(), test_url);
base::RunLoop run_loop;
RequestAppBanner(manager.get(), web_contents->GetLastCommittedURL(),
- run_loop, transition, expectation);
+ run_loop, transition, expected_to_show);
+ // Navigate to ensure the InstallableErrorCodeHistogram is logged.
+ ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
+ CheckInstallableErrorCodeHistogram(expected_code_for_histogram, 1,
+ unshown_repetitions + 1);
}
+
+ void CheckInstallableErrorCodeHistogram(InstallableErrorCode expected_code,
+ int expected_count, int total_count) {
+ histograms_.ExpectBucketCount(banners::kInstallableErrorCodeHistogram,
+ expected_code, expected_count);
+ histograms_.ExpectTotalCount(banners::kInstallableErrorCodeHistogram,
+ total_count);
+ }
+
+ private:
+ base::HistogramTester histograms_;
};
IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest, WebAppBannerCreatedDirect) {
RunBannerTest("/banners/manifest_test_page.html", ui::PAGE_TRANSITION_TYPED,
- 1, true);
+ 1, SHOWING_WEB_APP_BANNER, true);
}
IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest,
WebAppBannerCreatedDirectLargerTotal) {
AppBannerSettingsHelper::SetTotalEngagementToTrigger(4);
RunBannerTest("/banners/manifest_test_page.html", ui::PAGE_TRANSITION_TYPED,
- 3, true);
+ 3, SHOWING_WEB_APP_BANNER, true);
}
IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest,
WebAppBannerCreatedDirectSmallerTotal) {
AppBannerSettingsHelper::SetTotalEngagementToTrigger(1);
RunBannerTest("/banners/manifest_test_page.html", ui::PAGE_TRANSITION_TYPED,
- 0, true);
+ 0, SHOWING_WEB_APP_BANNER, true);
}
IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest,
WebAppBannerCreatedDirectSingle) {
AppBannerSettingsHelper::SetEngagementWeights(2, 1);
RunBannerTest("/banners/manifest_test_page.html",
- ui::PAGE_TRANSITION_GENERATED, 0, true);
+ ui::PAGE_TRANSITION_GENERATED, 0, SHOWING_WEB_APP_BANNER, true);
}
IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest,
WebAppBannerCreatedDirectMultiple) {
AppBannerSettingsHelper::SetEngagementWeights(0.5, 1);
RunBannerTest("/banners/manifest_test_page.html",
- ui::PAGE_TRANSITION_GENERATED, 3, true);
+ ui::PAGE_TRANSITION_GENERATED, 3, SHOWING_WEB_APP_BANNER, true);
}
IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest,
@@ -178,7 +197,7 @@ IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest,
AppBannerSettingsHelper::SetEngagementWeights(0.5, 1);
AppBannerSettingsHelper::SetTotalEngagementToTrigger(3);
RunBannerTest("/banners/manifest_test_page.html",
- ui::PAGE_TRANSITION_GENERATED, 5, true);
+ ui::PAGE_TRANSITION_GENERATED, 5, SHOWING_WEB_APP_BANNER, true);
}
IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest,
@@ -186,41 +205,41 @@ IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest,
AppBannerSettingsHelper::SetEngagementWeights(0.5, 1);
AppBannerSettingsHelper::SetTotalEngagementToTrigger(1);
RunBannerTest("/banners/manifest_test_page.html",
- ui::PAGE_TRANSITION_GENERATED, 1, true);
+ ui::PAGE_TRANSITION_GENERATED, 1, SHOWING_WEB_APP_BANNER, true);
}
IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest,
WebAppBannerCreatedIndirect) {
RunBannerTest("/banners/manifest_test_page.html", ui::PAGE_TRANSITION_LINK, 1,
- true);
+ SHOWING_WEB_APP_BANNER, true);
}
IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest,
WebAppBannerCreatedIndirectLargerTotal) {
AppBannerSettingsHelper::SetTotalEngagementToTrigger(5);
RunBannerTest("/banners/manifest_test_page.html", ui::PAGE_TRANSITION_LINK, 4,
- true);
+ SHOWING_WEB_APP_BANNER, true);
}
IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest,
WebAppBannerCreatedIndirectSmallerTotal) {
AppBannerSettingsHelper::SetTotalEngagementToTrigger(1);
RunBannerTest("/banners/manifest_test_page.html", ui::PAGE_TRANSITION_LINK, 0,
- true);
+ SHOWING_WEB_APP_BANNER, true);
}
IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest,
WebAppBannerCreatedIndirectSingle) {
AppBannerSettingsHelper::SetEngagementWeights(1, 3);
RunBannerTest("/banners/manifest_test_page.html", ui::PAGE_TRANSITION_RELOAD,
- 0, true);
+ 0, SHOWING_WEB_APP_BANNER, true);
}
IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest,
WebAppBannerCreatedIndirectMultiple) {
AppBannerSettingsHelper::SetEngagementWeights(1, 0.5);
RunBannerTest("/banners/manifest_test_page.html", ui::PAGE_TRANSITION_LINK, 3,
- true);
+ SHOWING_WEB_APP_BANNER, true);
}
IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest,
@@ -228,7 +247,7 @@ IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest,
AppBannerSettingsHelper::SetEngagementWeights(1, 0.5);
AppBannerSettingsHelper::SetTotalEngagementToTrigger(4);
RunBannerTest("/banners/manifest_test_page.html", ui::PAGE_TRANSITION_LINK, 7,
- true);
+ SHOWING_WEB_APP_BANNER, true);
}
IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest,
@@ -249,6 +268,7 @@ IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest,
ui_test_utils::NavigateToURL(browser(), test_url);
RequestAppBanner(manager.get(), web_contents->GetLastCommittedURL(),
run_loop, ui::PAGE_TRANSITION_TYPED, false);
+ CheckInstallableErrorCodeHistogram(INSUFFICIENT_ENGAGEMENT, 1, 1);
}
// Add an indirect nav on day 1 which is ignored.
@@ -257,6 +277,7 @@ IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest,
ui_test_utils::NavigateToURL(browser(), test_url);
RequestAppBanner(manager.get(), web_contents->GetLastCommittedURL(),
run_loop, ui::PAGE_TRANSITION_LINK, false);
+ CheckInstallableErrorCodeHistogram(INSUFFICIENT_ENGAGEMENT, 2, 2);
AppBannerManager::SetTimeDeltaForTesting(1);
}
@@ -266,6 +287,7 @@ IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest,
ui_test_utils::NavigateToURL(browser(), test_url);
RequestAppBanner(manager.get(), web_contents->GetLastCommittedURL(),
run_loop, ui::PAGE_TRANSITION_MANUAL_SUBFRAME, false);
+ CheckInstallableErrorCodeHistogram(INSUFFICIENT_ENGAGEMENT, 3, 3);
}
// Add a direct nav on day 2 which overrides.
@@ -274,6 +296,7 @@ IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest,
ui_test_utils::NavigateToURL(browser(), test_url);
RequestAppBanner(manager.get(), web_contents->GetLastCommittedURL(),
run_loop, ui::PAGE_TRANSITION_GENERATED, false);
+ CheckInstallableErrorCodeHistogram(INSUFFICIENT_ENGAGEMENT, 4, 4);
AppBannerManager::SetTimeDeltaForTesting(2);
}
@@ -283,6 +306,7 @@ IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest,
ui_test_utils::NavigateToURL(browser(), test_url);
RequestAppBanner(manager.get(), web_contents->GetLastCommittedURL(),
run_loop, ui::PAGE_TRANSITION_GENERATED, false);
+ CheckInstallableErrorCodeHistogram(INSUFFICIENT_ENGAGEMENT, 5, 5);
AppBannerManager::SetTimeDeltaForTesting(3);
}
@@ -292,62 +316,65 @@ IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest,
ui_test_utils::NavigateToURL(browser(), test_url);
RequestAppBanner(manager.get(), web_contents->GetLastCommittedURL(),
run_loop, ui::PAGE_TRANSITION_FORM_SUBMIT, false);
+ CheckInstallableErrorCodeHistogram(INSUFFICIENT_ENGAGEMENT, 6, 6);
}
+
// Add a direct nav on day 4 which should trigger the banner.
{
base::RunLoop run_loop;
ui_test_utils::NavigateToURL(browser(), test_url);
RequestAppBanner(manager.get(), web_contents->GetLastCommittedURL(),
run_loop, ui::PAGE_TRANSITION_TYPED, true);
+ CheckInstallableErrorCodeHistogram(SHOWING_WEB_APP_BANNER, 1, 7);
}
}
IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest,
WebAppBannerNoTypeInManifest) {
RunBannerTest("/banners/manifest_no_type_test_page.html",
- ui::PAGE_TRANSITION_TYPED, 1, true);
+ ui::PAGE_TRANSITION_TYPED, 1, SHOWING_WEB_APP_BANNER, true);
}
IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest,
WebAppBannerNoTypeInManifestCapsExtension) {
RunBannerTest("/banners/manifest_no_type_caps_test_page.html",
- ui::PAGE_TRANSITION_TYPED, 1, true);
+ ui::PAGE_TRANSITION_TYPED, 1, SHOWING_WEB_APP_BANNER, true);
}
IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest, NoManifest) {
RunBannerTest("/banners/no_manifest_test_page.html",
- ui::PAGE_TRANSITION_TYPED, 1, false);
+ ui::PAGE_TRANSITION_TYPED, 0, NO_MANIFEST, false);
}
IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest, MissingManifest) {
- RunBannerTest("/banners/manifest_bad_link.html", ui::PAGE_TRANSITION_TYPED, 1,
- false);
+ RunBannerTest("/banners/manifest_bad_link.html", ui::PAGE_TRANSITION_TYPED, 0,
+ MANIFEST_EMPTY, false);
}
IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest, CancelBannerDirect) {
RunBannerTest("/banners/cancel_test_page.html", ui::PAGE_TRANSITION_TYPED, 1,
- false);
+ RENDERER_CANCELLED, false);
}
IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest, CancelBannerIndirect) {
AppBannerSettingsHelper::SetEngagementWeights(1, 0.5);
- RunBannerTest("/banners/cancel_test_page.html", ui::PAGE_TRANSITION_TYPED, 3,
- false);
+ RunBannerTest("/banners/cancel_test_page.html", ui::PAGE_TRANSITION_LINK, 3,
+ RENDERER_CANCELLED, false);
}
IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest, PromptBanner) {
RunBannerTest("/banners/prompt_test_page.html", ui::PAGE_TRANSITION_TYPED, 1,
- true);
+ SHOWING_WEB_APP_BANNER, true);
}
IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest, PromptBannerInHandler) {
RunBannerTest("/banners/prompt_in_handler_test_page.html",
- ui::PAGE_TRANSITION_TYPED, 1, true);
+ ui::PAGE_TRANSITION_TYPED, 1, SHOWING_WEB_APP_BANNER, true);
}
IN_PROC_BROWSER_TEST_F(AppBannerManagerBrowserTest, WebAppBannerInIFrame) {
- RunBannerTest("/banners/iframe_test_page.html", ui::PAGE_TRANSITION_TYPED, 1,
- false);
+ RunBannerTest("/banners/iframe_test_page.html", ui::PAGE_TRANSITION_TYPED, 0,
+ NO_MANIFEST, false);
}
} // namespace banners

Powered by Google App Engine
This is Rietveld 408576698