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

Unified Diff: chrome/browser/ui/content_settings/content_setting_bubble_model_browsertest.cc

Issue 2588273002: Add UMA metrics for pop-up blocked page action on desktop (Closed)
Patch Set: format fix, remove #if directive Created 4 years 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/ui/content_settings/content_setting_bubble_model_browsertest.cc
diff --git a/chrome/browser/ui/content_settings/content_setting_bubble_model_browsertest.cc b/chrome/browser/ui/content_settings/content_setting_bubble_model_browsertest.cc
index 84cf40e08028954cf3c5870a7de4f2d755f1536b..acbfd81c9e4f710061e3d2f16f21404e79ada145 100644
--- a/chrome/browser/ui/content_settings/content_setting_bubble_model_browsertest.cc
+++ b/chrome/browser/ui/content_settings/content_setting_bubble_model_browsertest.cc
@@ -228,3 +228,57 @@ IN_PROC_BROWSER_TEST_F(ContentSettingBubbleModelMediaStreamTest,
EXPECT_EQ(GURL("chrome://settings/contentExceptions#media-stream-camera"),
GetActiveTab()->GetLastCommittedURL());
}
+
+class ContentSettingBubbleModelPopupTest : public InProcessBrowserTest {
+ protected:
+ void SetUpInProcessBrowserTestFixture() override {
+ https_server_.reset(
+ new net::EmbeddedTestServer(net::EmbeddedTestServer::TYPE_HTTPS));
+ https_server_->ServeFilesFromSourceDirectory(base::FilePath(kDocRoot));
+ ASSERT_TRUE(https_server_->Start());
+ }
+ std::unique_ptr<net::EmbeddedTestServer> https_server_;
+};
+
+// Tests that each popup action is counted in the right bucket.
Nico 2017/01/03 14:34:07 Nice!
+IN_PROC_BROWSER_TEST_F(ContentSettingBubbleModelPopupTest,
+ PopupsActionsCount){
+ GURL url(https_server_->GetURL("/popup_blocker/popup-many.html"));
+ base::HistogramTester histograms;
+ histograms.ExpectTotalCount("ContentSettings.Popups", 0);
+
+ ui_test_utils::NavigateToURL(browser(), url);
+
+ histograms.ExpectBucketCount(
+ "ContentSettings.Popups",
+ content_settings::POPUPS_ACTION_DISPLAYED_BLOCKED_ICON_IN_OMNIBOX, 1);
+
+ // Creates the ContentSettingPopupBubbleModel in order to emulate clicks.
+ std::unique_ptr<ContentSettingBubbleModel> model(
+ ContentSettingBubbleModel::CreateContentSettingBubbleModel(
+ browser()->content_setting_bubble_model_delegate(),
+ browser()->tab_strip_model()->GetActiveWebContents(),
+ browser()->profile(), CONTENT_SETTINGS_TYPE_POPUPS));
+
+ histograms.ExpectBucketCount(
+ "ContentSettings.Popups",
+ content_settings::POPUPS_ACTION_DISPLAYED_BUBBLE, 1);
+
+ model->OnListItemClicked(0);
+ histograms.ExpectBucketCount(
+ "ContentSettings.Popups",
+ content_settings::POPUPS_ACTION_CLICKED_LIST_ITEM_CLICKED, 1);
+
+ model->OnManageLinkClicked();
+ histograms.ExpectBucketCount(
+ "ContentSettings.Popups",
+ content_settings::POPUPS_ACTION_CLICKED_MANAGE_POPUPS_BLOCKING, 1);
+
+ model->OnRadioClicked(model->kAllowButtonIndex);
+ delete model.release();
+ histograms.ExpectBucketCount(
+ "ContentSettings.Popups",
+ content_settings::POPUPS_ACTION_SELECTED_ALWAYS_ALLOW_POPUPS_FROM, 1);
+
+ histograms.ExpectTotalCount("ContentSettings.Popups", 5);
+}

Powered by Google App Engine
This is Rietveld 408576698