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

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

Issue 588153003: Remove MediaSettingChangedInfobar and show latest state in bubble (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 #include "base/auto_reset.h" 5 #include "base/auto_reset.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/content_settings/host_content_settings_map.h" 8 #include "chrome/browser/content_settings/host_content_settings_map.h"
9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 9 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
10 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 10 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 url, 227 url,
228 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, 228 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
229 std::string())); 229 std::string()));
230 EXPECT_EQ(CONTENT_SETTING_ALLOW, 230 EXPECT_EQ(CONTENT_SETTING_ALLOW,
231 host_content_settings_map->GetContentSetting( 231 host_content_settings_map->GetContentSetting(
232 url, 232 url,
233 url, 233 url,
234 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, 234 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
235 std::string())); 235 std::string()));
236 236
237 InfoBarService* infobar_service = 237 {
238 InfoBarService::FromWebContents(web_contents()); 238 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
Peter Kasting 2014/09/22 23:11:23 Nit: Would it make sense to make this added code i
robwu 2014/09/24 00:03:04 Done. I have added two tests. One of them is for t
239 infobar_service->RemoveInfoBar(infobar_service->infobar_at(0)); 239 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
240 NULL, web_contents(), profile(),
241 CONTENT_SETTINGS_TYPE_MEDIASTREAM));
242 const ContentSettingBubbleModel::BubbleContent& bubble_content =
243 content_setting_bubble_model->bubble_content();
244 // Test that the reload hint is displayed.
245 EXPECT_FALSE(bubble_content.custom_link_enabled);
246 EXPECT_EQ(bubble_content.custom_link, l10n_util::GetStringUTF8(
247 IDS_MEDIASTREAM_SETTING_CHANGED_INFOBAR_MESSAGE));
248
249 EXPECT_EQ(0, bubble_content.radio_group.default_item);
250 // Restore the radio setting (to block).
251 content_setting_bubble_model->OnRadioClicked(1);
252 }
253 // Test that the media settings were changed again.
254 EXPECT_EQ(CONTENT_SETTING_BLOCK,
255 host_content_settings_map->GetContentSetting(
256 url,
257 url,
258 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
259 std::string()));
260 EXPECT_EQ(CONTENT_SETTING_BLOCK,
261 host_content_settings_map->GetContentSetting(
262 url,
263 url,
264 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
265 std::string()));
266
267 {
268 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
269 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
270 NULL, web_contents(), profile(),
271 CONTENT_SETTINGS_TYPE_MEDIASTREAM));
272 const ContentSettingBubbleModel::BubbleContent& bubble_content =
273 content_setting_bubble_model->bubble_content();
274 // Test that the reload hint is not displayed any more.
275 EXPECT_FALSE(bubble_content.custom_link_enabled);
276 EXPECT_TRUE(bubble_content.custom_link.empty());
277
278 EXPECT_EQ(1, bubble_content.radio_group.default_item);
279 }
240 } 280 }
241 281
242 TEST_F(ContentSettingBubbleModelTest, MediastreamMic) { 282 TEST_F(ContentSettingBubbleModelTest, MediastreamMic) {
243 // Required to break dependency on BrowserMainLoop. 283 // Required to break dependency on BrowserMainLoop.
244 MediaCaptureDevicesDispatcher::GetInstance()-> 284 MediaCaptureDevicesDispatcher::GetInstance()->
245 DisableDeviceEnumerationForTesting(); 285 DisableDeviceEnumerationForTesting();
246 286
247 TabSpecificContentSettings* content_settings = 287 TabSpecificContentSettings* content_settings =
248 TabSpecificContentSettings::FromWebContents(web_contents()); 288 TabSpecificContentSettings::FromWebContents(web_contents());
249 std::string request_host = "google.com"; 289 std::string request_host = "google.com";
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 { 701 {
662 ProtocolHandler handler = registry.GetHandlerFor("mailto"); 702 ProtocolHandler handler = registry.GetHandlerFor("mailto");
663 ASSERT_FALSE(handler.IsEmpty()); 703 ASSERT_FALSE(handler.IsEmpty());
664 EXPECT_EQ(CONTENT_SETTING_ALLOW, 704 EXPECT_EQ(CONTENT_SETTING_ALLOW,
665 content_settings->pending_protocol_handler_setting()); 705 content_settings->pending_protocol_handler_setting());
666 EXPECT_FALSE(registry.IsIgnored(test_handler)); 706 EXPECT_FALSE(registry.IsIgnored(test_handler));
667 } 707 }
668 708
669 registry.Shutdown(); 709 registry.Shutdown();
670 } 710 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698