OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/test/histogram_tester.h" | 10 #include "base/test/histogram_tester.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 221 |
222 // In ChromeOS, we do not sanitize chrome://settings-frame to | 222 // In ChromeOS, we do not sanitize chrome://settings-frame to |
223 // chrome://settings for same-document navigations. See crbug.com/416157. For | 223 // chrome://settings for same-document navigations. See crbug.com/416157. For |
224 // this reason, order the tests so no same-document navigation occurs. | 224 // this reason, order the tests so no same-document navigation occurs. |
225 | 225 |
226 // The camera bubble links to camera exceptions. | 226 // The camera bubble links to camera exceptions. |
227 ManageMediaStreamSettings(TabSpecificContentSettings::CAMERA_ACCESSED); | 227 ManageMediaStreamSettings(TabSpecificContentSettings::CAMERA_ACCESSED); |
228 EXPECT_EQ(GURL("chrome://settings/contentExceptions#media-stream-camera"), | 228 EXPECT_EQ(GURL("chrome://settings/contentExceptions#media-stream-camera"), |
229 GetActiveTab()->GetLastCommittedURL()); | 229 GetActiveTab()->GetLastCommittedURL()); |
230 } | 230 } |
| 231 |
| 232 class ContentSettingBubbleModelPopupTest : public InProcessBrowserTest { |
| 233 protected: |
| 234 void SetUpInProcessBrowserTestFixture() override { |
| 235 https_server_.reset( |
| 236 new net::EmbeddedTestServer(net::EmbeddedTestServer::TYPE_HTTPS)); |
| 237 https_server_->ServeFilesFromSourceDirectory(base::FilePath(kDocRoot)); |
| 238 ASSERT_TRUE(https_server_->Start()); |
| 239 } |
| 240 std::unique_ptr<net::EmbeddedTestServer> https_server_; |
| 241 }; |
| 242 |
| 243 // Tests that each popup action is counted in the right bucket. |
| 244 IN_PROC_BROWSER_TEST_F(ContentSettingBubbleModelPopupTest, |
| 245 PopupsActionsCount){ |
| 246 GURL url(https_server_->GetURL("/popup_blocker/popup-many.html")); |
| 247 base::HistogramTester histograms; |
| 248 histograms.ExpectTotalCount("ContentSettings.Popups", 0); |
| 249 |
| 250 ui_test_utils::NavigateToURL(browser(), url); |
| 251 |
| 252 histograms.ExpectBucketCount( |
| 253 "ContentSettings.Popups", |
| 254 content_settings::POPUPS_ACTION_DISPLAYED_BLOCKED_ICON_IN_OMNIBOX, 1); |
| 255 |
| 256 // Creates the ContentSettingPopupBubbleModel in order to emulate clicks. |
| 257 std::unique_ptr<ContentSettingBubbleModel> model( |
| 258 ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
| 259 browser()->content_setting_bubble_model_delegate(), |
| 260 browser()->tab_strip_model()->GetActiveWebContents(), |
| 261 browser()->profile(), CONTENT_SETTINGS_TYPE_POPUPS)); |
| 262 |
| 263 histograms.ExpectBucketCount( |
| 264 "ContentSettings.Popups", |
| 265 content_settings::POPUPS_ACTION_DISPLAYED_BUBBLE, 1); |
| 266 |
| 267 model->OnListItemClicked(0); |
| 268 histograms.ExpectBucketCount( |
| 269 "ContentSettings.Popups", |
| 270 content_settings::POPUPS_ACTION_CLICKED_LIST_ITEM_CLICKED, 1); |
| 271 |
| 272 model->OnManageLinkClicked(); |
| 273 histograms.ExpectBucketCount( |
| 274 "ContentSettings.Popups", |
| 275 content_settings::POPUPS_ACTION_CLICKED_MANAGE_POPUPS_BLOCKING, 1); |
| 276 |
| 277 model->OnRadioClicked(model->kAllowButtonIndex); |
| 278 delete model.release(); |
| 279 histograms.ExpectBucketCount( |
| 280 "ContentSettings.Popups", |
| 281 content_settings::POPUPS_ACTION_SELECTED_ALWAYS_ALLOW_POPUPS_FROM, 1); |
| 282 |
| 283 histograms.ExpectTotalCount("ContentSettings.Popups", 5); |
| 284 } |
OLD | NEW |