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

Side by Side Diff: chrome/browser/ui/content_settings/content_setting_image_model_browsertest.cc

Issue 2561673003: Handle per-tab AUTOMATIC_DOWNLOADS setting in DownloadRequestLimiter. (Closed)
Patch Set: Handle absent DownloadRequestLimiter in tests Created 3 years, 9 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
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 "chrome/browser/ui/content_settings/content_setting_image_model.h" 5 #include "chrome/browser/ui/content_settings/content_setting_image_model.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/download/download_request_limiter.h"
8 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" 12 #include "chrome/browser/ui/tabs/tab_strip_model.h"
11 #include "chrome/test/base/in_process_browser_test.h" 13 #include "chrome/test/base/in_process_browser_test.h"
12 14
13 using content::WebContents; 15 using content::WebContents;
14 16
15 typedef InProcessBrowserTest ContentSettingImageModelBrowserTest; 17 typedef InProcessBrowserTest ContentSettingImageModelBrowserTest;
16 18
17 // Tests that every model creates a valid bubble. 19 // Tests that every model creates a valid bubble.
18 IN_PROC_BROWSER_TEST_F(ContentSettingImageModelBrowserTest, CreateBubbleModel) { 20 IN_PROC_BROWSER_TEST_F(ContentSettingImageModelBrowserTest, CreateBubbleModel) {
19 WebContents* web_contents = 21 WebContents* web_contents =
20 browser()->tab_strip_model()->GetActiveWebContents(); 22 browser()->tab_strip_model()->GetActiveWebContents();
21 TabSpecificContentSettings* content_settings = 23 TabSpecificContentSettings* content_settings =
22 TabSpecificContentSettings::FromWebContents(web_contents); 24 TabSpecificContentSettings::FromWebContents(web_contents);
23 content_settings->BlockAllContentForTesting(); 25 content_settings->BlockAllContentForTesting();
24 26
27 // Automatic downloads are handled by DownloadRequestLimiter.
28 g_browser_process->download_request_limiter()
29 ->GetDownloadState(web_contents, web_contents, true)
30 ->SetDownloadStatusAndNotify(
31 DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED);
32
25 // Test that image models tied to a single content setting create bubbles tied 33 // Test that image models tied to a single content setting create bubbles tied
26 // to the same setting. 34 // to the same setting.
27 static const ContentSettingsType content_settings_to_test[] = { 35 static const ContentSettingsType content_settings_to_test[] = {
28 CONTENT_SETTINGS_TYPE_COOKIES, 36 CONTENT_SETTINGS_TYPE_COOKIES,
29 CONTENT_SETTINGS_TYPE_IMAGES, 37 CONTENT_SETTINGS_TYPE_IMAGES,
30 CONTENT_SETTINGS_TYPE_JAVASCRIPT, 38 CONTENT_SETTINGS_TYPE_JAVASCRIPT,
31 CONTENT_SETTINGS_TYPE_PLUGINS, 39 CONTENT_SETTINGS_TYPE_PLUGINS,
32 CONTENT_SETTINGS_TYPE_POPUPS, 40 CONTENT_SETTINGS_TYPE_POPUPS,
33 CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, 41 CONTENT_SETTINGS_TYPE_MIXEDSCRIPT,
34 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, 42 CONTENT_SETTINGS_TYPE_PPAPI_BROKER,
35 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS,
36 CONTENT_SETTINGS_TYPE_GEOLOCATION, 43 CONTENT_SETTINGS_TYPE_GEOLOCATION,
37 CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, 44 CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS,
38 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, 45 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
39 }; 46 };
40 47
41 Profile* profile = browser()->profile(); 48 Profile* profile = browser()->profile();
42 for (ContentSettingsType type : content_settings_to_test) { 49 for (ContentSettingsType type : content_settings_to_test) {
43 std::unique_ptr<ContentSettingBubbleModel> bubble( 50 std::unique_ptr<ContentSettingBubbleModel> bubble(
44 ContentSettingSimpleImageModel::CreateForContentTypeForTesting(type) 51 ContentSettingSimpleImageModel::CreateForContentTypeForTesting(type)
45 ->CreateBubbleModel(nullptr, web_contents, profile)); 52 ->CreateBubbleModel(nullptr, web_contents, profile));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 EXPECT_FALSE(model->ShouldRunAnimation(web_contents)); 86 EXPECT_FALSE(model->ShouldRunAnimation(web_contents));
80 87
81 // The animation has run for the current WebContents, but not for any other. 88 // The animation has run for the current WebContents, but not for any other.
82 Profile* profile = browser()->profile(); 89 Profile* profile = browser()->profile();
83 WebContents::CreateParams create_params(profile); 90 WebContents::CreateParams create_params(profile);
84 WebContents* other_web_contents = WebContents::Create(create_params); 91 WebContents* other_web_contents = WebContents::Create(create_params);
85 browser()->tab_strip_model()->TabStripModel::AppendWebContents( 92 browser()->tab_strip_model()->TabStripModel::AppendWebContents(
86 other_web_contents, true); 93 other_web_contents, true);
87 EXPECT_TRUE(model->ShouldRunAnimation(other_web_contents)); 94 EXPECT_TRUE(model->ShouldRunAnimation(other_web_contents));
88 } 95 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698