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

Side by Side Diff: chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa_browsertest.mm

Issue 2561673003: Handle per-tab AUTOMATIC_DOWNLOADS setting in DownloadRequestLimiter. (Closed)
Patch Set: Get HostContentSettingsMap directly in DRL 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #import "chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.h " 5 #import "chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.h "
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/mac/scoped_nsautorelease_pool.h" 9 #include "base/mac/scoped_nsautorelease_pool.h"
10 #include "base/mac/scoped_nsobject.h" 10 #include "base/mac/scoped_nsobject.h"
11 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 12 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
13 #include "chrome/browser/download/download_request_limiter.h"
12 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" 14 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h"
13 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
14 #import "chrome/browser/ui/cocoa/test/cocoa_test_helper.h" 16 #import "chrome/browser/ui/cocoa/test/cocoa_test_helper.h"
15 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" 17 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
16 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" 18 #include "chrome/browser/ui/content_settings/content_setting_image_model.h"
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" 19 #include "chrome/browser/ui/tabs/tab_strip_model.h"
18 #include "chrome/grit/generated_resources.h" 20 #include "chrome/grit/generated_resources.h"
19 #include "chrome/test/base/in_process_browser_test.h" 21 #include "chrome/test/base/in_process_browser_test.h"
20 #include "content/public/common/media_stream_request.h" 22 #include "content/public/common/media_stream_request.h"
21 #include "testing/gtest_mac.h" 23 #include "testing/gtest_mac.h"
22 #include "ui/base/l10n/l10n_util.h" 24 #include "ui/base/l10n/l10n_util.h"
23 25
24 namespace {
25
26 class ContentSettingBubbleControllerTest : public InProcessBrowserTest { 26 class ContentSettingBubbleControllerTest : public InProcessBrowserTest {
27 protected: 27 protected:
28 ContentSettingBubbleControllerTest() {} 28 ContentSettingBubbleControllerTest() {}
29 29
30 content::WebContents* web_contents() { 30 content::WebContents* web_contents() {
31 return browser()->tab_strip_model()->GetActiveWebContents(); 31 return browser()->tab_strip_model()->GetActiveWebContents();
32 } 32 }
33 33
34 Profile* profile() { 34 Profile* profile() {
35 return browser()->profile(); 35 return browser()->profile();
(...skipping 29 matching lines...) Expand all
65 EXPECT_TRUE(controller); 65 EXPECT_TRUE(controller);
66 EXPECT_TRUE([[controller window] isVisible]); 66 EXPECT_TRUE([[controller window] isVisible]);
67 67
68 return controller; 68 return controller;
69 } 69 }
70 70
71 // Check that the bubble doesn't crash or leak for any image model. 71 // Check that the bubble doesn't crash or leak for any image model.
72 IN_PROC_BROWSER_TEST_F(ContentSettingBubbleControllerTest, Init) { 72 IN_PROC_BROWSER_TEST_F(ContentSettingBubbleControllerTest, Init) {
73 TabSpecificContentSettings::FromWebContents(web_contents())-> 73 TabSpecificContentSettings::FromWebContents(web_contents())->
74 BlockAllContentForTesting(); 74 BlockAllContentForTesting();
75
76 // Automatic downloads are handled by DownloadRequestLimiter.
77 g_browser_process->download_request_limiter()
78 ->GetDownloadState(web_contents(), web_contents(), true)
79 ->SetDownloadStatusAndNotify(
80 DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED);
81
75 std::vector<std::unique_ptr<ContentSettingImageModel>> models = 82 std::vector<std::unique_ptr<ContentSettingImageModel>> models =
76 ContentSettingImageModel::GenerateContentSettingImageModels(); 83 ContentSettingImageModel::GenerateContentSettingImageModels();
77 for (const auto& model : models) { 84 for (const auto& model : models) {
78 ContentSettingBubbleModel* bubble = 85 ContentSettingBubbleModel* bubble =
79 model->CreateBubbleModel(nullptr, web_contents(), profile()); 86 model->CreateBubbleModel(nullptr, web_contents(), profile());
80 ContentSettingBubbleController* controller = CreateBubbleController(bubble); 87 ContentSettingBubbleController* controller = CreateBubbleController(bubble);
81 // No bubble except the one for media should have media menus. 88 // No bubble except the one for media should have media menus.
82 if (!bubble->AsMediaStreamBubbleModel()) 89 if (!bubble->AsMediaStreamBubbleModel())
83 EXPECT_EQ(0u, [controller mediaMenus]->size()); 90 EXPECT_EQ(0u, [controller mediaMenus]->size());
84 [parent_ close]; 91 [parent_ close];
(...skipping 18 matching lines...) Expand all
103 mediaMenus->begin(); i != mediaMenus->end(); ++i) { 110 mediaMenus->begin(); i != mediaMenus->end(); ++i) {
104 EXPECT_TRUE((content::MEDIA_DEVICE_AUDIO_CAPTURE == i->second->type) || 111 EXPECT_TRUE((content::MEDIA_DEVICE_AUDIO_CAPTURE == i->second->type) ||
105 (content::MEDIA_DEVICE_VIDEO_CAPTURE == i->second->type)); 112 (content::MEDIA_DEVICE_VIDEO_CAPTURE == i->second->type));
106 EXPECT_EQ(0, [i->first numberOfItems]); 113 EXPECT_EQ(0, [i->first numberOfItems]);
107 EXPECT_NSEQ(title, [i->first title]); 114 EXPECT_NSEQ(title, [i->first title]);
108 EXPECT_FALSE([i->first isEnabled]); 115 EXPECT_FALSE([i->first isEnabled]);
109 } 116 }
110 117
111 [parent_ close]; 118 [parent_ close];
112 } 119 }
113
114 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698