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

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

Issue 2339783003: Make 'Load full site' a button instead of link. (Closed)
Patch Set: . Created 4 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 CONTENT_SETTINGS_TYPE_GEOLOCATION)); 49 CONTENT_SETTINGS_TYPE_GEOLOCATION));
50 const ContentSettingBubbleModel::BubbleContent& bubble_content = 50 const ContentSettingBubbleModel::BubbleContent& bubble_content =
51 content_setting_bubble_model->bubble_content(); 51 content_setting_bubble_model->bubble_content();
52 EXPECT_TRUE(bubble_content.title.empty()); 52 EXPECT_TRUE(bubble_content.title.empty());
53 EXPECT_TRUE(bubble_content.radio_group.radio_items.empty()); 53 EXPECT_TRUE(bubble_content.radio_group.radio_items.empty());
54 EXPECT_TRUE(bubble_content.list_items.empty()); 54 EXPECT_TRUE(bubble_content.list_items.empty());
55 EXPECT_EQ(expected_domains, bubble_content.domain_lists.size()); 55 EXPECT_EQ(expected_domains, bubble_content.domain_lists.size());
56 EXPECT_NE(expect_clear_link || expect_reload_hint, 56 EXPECT_NE(expect_clear_link || expect_reload_hint,
57 bubble_content.custom_link.empty()); 57 bubble_content.custom_link.empty());
58 EXPECT_EQ(expect_clear_link, bubble_content.custom_link_enabled); 58 EXPECT_EQ(expect_clear_link, bubble_content.custom_link_enabled);
59 EXPECT_FALSE(bubble_content.manage_link.empty()); 59 EXPECT_FALSE(bubble_content.manage_text.empty());
60 } 60 }
61 61
62 std::string GetDefaultAudioDevice() { 62 std::string GetDefaultAudioDevice() {
63 PrefService* prefs = profile()->GetPrefs(); 63 PrefService* prefs = profile()->GetPrefs();
64 return prefs->GetString(prefs::kDefaultAudioCaptureDevice); 64 return prefs->GetString(prefs::kDefaultAudioCaptureDevice);
65 } 65 }
66 66
67 std::string GetDefaultVideoDevice() { 67 std::string GetDefaultVideoDevice() {
68 PrefService* prefs = profile()->GetPrefs(); 68 PrefService* prefs = profile()->GetPrefs();
69 return prefs->GetString(prefs::kDefaultVideoCaptureDevice); 69 return prefs->GetString(prefs::kDefaultVideoCaptureDevice);
70 } 70 }
71 }; 71 };
72 72
73 TEST_F(ContentSettingBubbleModelTest, ImageRadios) { 73 TEST_F(ContentSettingBubbleModelTest, ImageRadios) {
74 TabSpecificContentSettings* content_settings = 74 TabSpecificContentSettings* content_settings =
75 TabSpecificContentSettings::FromWebContents(web_contents()); 75 TabSpecificContentSettings::FromWebContents(web_contents());
76 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES); 76 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES);
77 77
78 std::unique_ptr<ContentSettingBubbleModel> content_setting_bubble_model( 78 std::unique_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
79 ContentSettingBubbleModel::CreateContentSettingBubbleModel( 79 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
80 NULL, web_contents(), profile(), CONTENT_SETTINGS_TYPE_IMAGES)); 80 NULL, web_contents(), profile(), CONTENT_SETTINGS_TYPE_IMAGES));
81 const ContentSettingBubbleModel::BubbleContent& bubble_content = 81 const ContentSettingBubbleModel::BubbleContent& bubble_content =
82 content_setting_bubble_model->bubble_content(); 82 content_setting_bubble_model->bubble_content();
83 EXPECT_FALSE(bubble_content.title.empty()); 83 EXPECT_FALSE(bubble_content.title.empty());
84 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size()); 84 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size());
85 EXPECT_EQ(0, bubble_content.radio_group.default_item); 85 EXPECT_EQ(0, bubble_content.radio_group.default_item);
86 EXPECT_TRUE(bubble_content.custom_link.empty()); 86 EXPECT_TRUE(bubble_content.custom_link.empty());
87 EXPECT_FALSE(bubble_content.manage_link.empty()); 87 EXPECT_FALSE(bubble_content.manage_text.empty());
88 } 88 }
89 89
90 TEST_F(ContentSettingBubbleModelTest, Cookies) { 90 TEST_F(ContentSettingBubbleModelTest, Cookies) {
91 TabSpecificContentSettings* content_settings = 91 TabSpecificContentSettings* content_settings =
92 TabSpecificContentSettings::FromWebContents(web_contents()); 92 TabSpecificContentSettings::FromWebContents(web_contents());
93 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES); 93 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES);
94 94
95 std::unique_ptr<ContentSettingBubbleModel> content_setting_bubble_model( 95 std::unique_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
96 ContentSettingBubbleModel::CreateContentSettingBubbleModel( 96 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
97 NULL, web_contents(), profile(), CONTENT_SETTINGS_TYPE_COOKIES)); 97 NULL, web_contents(), profile(), CONTENT_SETTINGS_TYPE_COOKIES));
98 const ContentSettingBubbleModel::BubbleContent& bubble_content = 98 const ContentSettingBubbleModel::BubbleContent& bubble_content =
99 content_setting_bubble_model->bubble_content(); 99 content_setting_bubble_model->bubble_content();
100 base::string16 title = bubble_content.title; 100 base::string16 title = bubble_content.title;
101 EXPECT_FALSE(title.empty()); 101 EXPECT_FALSE(title.empty());
102 ASSERT_EQ(2U, bubble_content.radio_group.radio_items.size()); 102 ASSERT_EQ(2U, bubble_content.radio_group.radio_items.size());
103 EXPECT_FALSE(bubble_content.custom_link.empty()); 103 EXPECT_FALSE(bubble_content.custom_link.empty());
104 EXPECT_TRUE(bubble_content.custom_link_enabled); 104 EXPECT_TRUE(bubble_content.custom_link_enabled);
105 EXPECT_FALSE(bubble_content.manage_link.empty()); 105 EXPECT_FALSE(bubble_content.manage_text.empty());
106 106
107 content_settings->ClearCookieSpecificContentSettings(); 107 content_settings->ClearCookieSpecificContentSettings();
108 content_settings->OnContentAllowed(CONTENT_SETTINGS_TYPE_COOKIES); 108 content_settings->OnContentAllowed(CONTENT_SETTINGS_TYPE_COOKIES);
109 content_setting_bubble_model.reset( 109 content_setting_bubble_model.reset(
110 ContentSettingBubbleModel::CreateContentSettingBubbleModel( 110 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
111 NULL, web_contents(), profile(), CONTENT_SETTINGS_TYPE_COOKIES)); 111 NULL, web_contents(), profile(), CONTENT_SETTINGS_TYPE_COOKIES));
112 const ContentSettingBubbleModel::BubbleContent& bubble_content_2 = 112 const ContentSettingBubbleModel::BubbleContent& bubble_content_2 =
113 content_setting_bubble_model->bubble_content(); 113 content_setting_bubble_model->bubble_content();
114 114
115 EXPECT_FALSE(bubble_content_2.title.empty()); 115 EXPECT_FALSE(bubble_content_2.title.empty());
116 EXPECT_NE(title, bubble_content_2.title); 116 EXPECT_NE(title, bubble_content_2.title);
117 ASSERT_EQ(2U, bubble_content_2.radio_group.radio_items.size()); 117 ASSERT_EQ(2U, bubble_content_2.radio_group.radio_items.size());
118 EXPECT_EQ(bubble_content_2.radio_group.radio_items[0], 118 EXPECT_EQ(bubble_content_2.radio_group.radio_items[0],
119 l10n_util::GetStringUTF8(IDS_ALLOWED_COOKIES_NO_ACTION)); 119 l10n_util::GetStringUTF8(IDS_ALLOWED_COOKIES_NO_ACTION));
120 EXPECT_EQ(bubble_content_2.radio_group.radio_items[1], 120 EXPECT_EQ(bubble_content_2.radio_group.radio_items[1],
121 l10n_util::GetStringFUTF8( 121 l10n_util::GetStringFUTF8(
122 IDS_ALLOWED_COOKIES_BLOCK, 122 IDS_ALLOWED_COOKIES_BLOCK,
123 url_formatter::FormatUrlForSecurityDisplay( 123 url_formatter::FormatUrlForSecurityDisplay(
124 web_contents()->GetURL()))); 124 web_contents()->GetURL())));
125 EXPECT_FALSE(bubble_content_2.custom_link.empty()); 125 EXPECT_FALSE(bubble_content_2.custom_link.empty());
126 EXPECT_TRUE(bubble_content_2.custom_link_enabled); 126 EXPECT_TRUE(bubble_content_2.custom_link_enabled);
127 EXPECT_FALSE(bubble_content_2.manage_link.empty()); 127 EXPECT_FALSE(bubble_content_2.manage_text.empty());
128 } 128 }
129 129
130 TEST_F(ContentSettingBubbleModelTest, MediastreamMicAndCamera) { 130 TEST_F(ContentSettingBubbleModelTest, MediastreamMicAndCamera) {
131 // Required to break dependency on BrowserMainLoop. 131 // Required to break dependency on BrowserMainLoop.
132 MediaCaptureDevicesDispatcher::GetInstance()-> 132 MediaCaptureDevicesDispatcher::GetInstance()->
133 DisableDeviceEnumerationForTesting(); 133 DisableDeviceEnumerationForTesting();
134 134
135 TabSpecificContentSettings* content_settings = 135 TabSpecificContentSettings* content_settings =
136 TabSpecificContentSettings::FromWebContents(web_contents()); 136 TabSpecificContentSettings::FromWebContents(web_contents());
137 std::string request_host = "google.com"; 137 std::string request_host = "google.com";
(...skipping 19 matching lines...) Expand all
157 EXPECT_EQ(bubble_content.radio_group.radio_items[0], 157 EXPECT_EQ(bubble_content.radio_group.radio_items[0],
158 l10n_util::GetStringFUTF8( 158 l10n_util::GetStringFUTF8(
159 IDS_ALLOWED_MEDIASTREAM_MIC_AND_CAMERA_NO_ACTION, 159 IDS_ALLOWED_MEDIASTREAM_MIC_AND_CAMERA_NO_ACTION,
160 url_formatter::FormatUrlForSecurityDisplay(security_origin))); 160 url_formatter::FormatUrlForSecurityDisplay(security_origin)));
161 EXPECT_EQ(bubble_content.radio_group.radio_items[1], 161 EXPECT_EQ(bubble_content.radio_group.radio_items[1],
162 l10n_util::GetStringUTF8( 162 l10n_util::GetStringUTF8(
163 IDS_ALLOWED_MEDIASTREAM_MIC_AND_CAMERA_BLOCK)); 163 IDS_ALLOWED_MEDIASTREAM_MIC_AND_CAMERA_BLOCK));
164 EXPECT_EQ(0, bubble_content.radio_group.default_item); 164 EXPECT_EQ(0, bubble_content.radio_group.default_item);
165 EXPECT_TRUE(bubble_content.custom_link.empty()); 165 EXPECT_TRUE(bubble_content.custom_link.empty());
166 EXPECT_FALSE(bubble_content.custom_link_enabled); 166 EXPECT_FALSE(bubble_content.custom_link_enabled);
167 EXPECT_FALSE(bubble_content.manage_link.empty()); 167 EXPECT_FALSE(bubble_content.manage_text.empty());
168 EXPECT_EQ(2U, bubble_content.media_menus.size()); 168 EXPECT_EQ(2U, bubble_content.media_menus.size());
169 } 169 }
170 170
171 TEST_F(ContentSettingBubbleModelTest, BlockedMediastreamMicAndCamera) { 171 TEST_F(ContentSettingBubbleModelTest, BlockedMediastreamMicAndCamera) {
172 // Required to break dependency on BrowserMainLoop. 172 // Required to break dependency on BrowserMainLoop.
173 MediaCaptureDevicesDispatcher::GetInstance()-> 173 MediaCaptureDevicesDispatcher::GetInstance()->
174 DisableDeviceEnumerationForTesting(); 174 DisableDeviceEnumerationForTesting();
175 175
176 WebContentsTester::For(web_contents())-> 176 WebContentsTester::For(web_contents())->
177 NavigateAndCommit(GURL("https://www.example.com")); 177 NavigateAndCommit(GURL("https://www.example.com"));
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 EXPECT_EQ(bubble_content.radio_group.radio_items[0], 516 EXPECT_EQ(bubble_content.radio_group.radio_items[0],
517 l10n_util::GetStringFUTF8( 517 l10n_util::GetStringFUTF8(
518 IDS_ALLOWED_MEDIASTREAM_MIC_NO_ACTION, 518 IDS_ALLOWED_MEDIASTREAM_MIC_NO_ACTION,
519 url_formatter::FormatUrlForSecurityDisplay(security_origin))); 519 url_formatter::FormatUrlForSecurityDisplay(security_origin)));
520 EXPECT_EQ(bubble_content.radio_group.radio_items[1], 520 EXPECT_EQ(bubble_content.radio_group.radio_items[1],
521 l10n_util::GetStringUTF8( 521 l10n_util::GetStringUTF8(
522 IDS_ALLOWED_MEDIASTREAM_MIC_BLOCK)); 522 IDS_ALLOWED_MEDIASTREAM_MIC_BLOCK));
523 EXPECT_EQ(0, bubble_content.radio_group.default_item); 523 EXPECT_EQ(0, bubble_content.radio_group.default_item);
524 EXPECT_TRUE(bubble_content.custom_link.empty()); 524 EXPECT_TRUE(bubble_content.custom_link.empty());
525 EXPECT_FALSE(bubble_content.custom_link_enabled); 525 EXPECT_FALSE(bubble_content.custom_link_enabled);
526 EXPECT_FALSE(bubble_content.manage_link.empty()); 526 EXPECT_FALSE(bubble_content.manage_text.empty());
527 EXPECT_EQ(1U, bubble_content.media_menus.size()); 527 EXPECT_EQ(1U, bubble_content.media_menus.size());
528 EXPECT_EQ(content::MEDIA_DEVICE_AUDIO_CAPTURE, 528 EXPECT_EQ(content::MEDIA_DEVICE_AUDIO_CAPTURE,
529 bubble_content.media_menus.begin()->first); 529 bubble_content.media_menus.begin()->first);
530 530
531 // Change the microphone access. 531 // Change the microphone access.
532 microphone_camera_state |= TabSpecificContentSettings::MICROPHONE_BLOCKED; 532 microphone_camera_state |= TabSpecificContentSettings::MICROPHONE_BLOCKED;
533 content_settings->OnMediaStreamPermissionSet(security_origin, 533 content_settings->OnMediaStreamPermissionSet(security_origin,
534 microphone_camera_state, 534 microphone_camera_state,
535 GetDefaultAudioDevice(), 535 GetDefaultAudioDevice(),
536 std::string(), 536 std::string(),
(...skipping 10 matching lines...) Expand all
547 EXPECT_EQ(new_bubble_content.radio_group.radio_items[0], 547 EXPECT_EQ(new_bubble_content.radio_group.radio_items[0],
548 l10n_util::GetStringFUTF8( 548 l10n_util::GetStringFUTF8(
549 IDS_BLOCKED_MEDIASTREAM_MIC_ASK, 549 IDS_BLOCKED_MEDIASTREAM_MIC_ASK,
550 url_formatter::FormatUrlForSecurityDisplay(security_origin))); 550 url_formatter::FormatUrlForSecurityDisplay(security_origin)));
551 EXPECT_EQ(new_bubble_content.radio_group.radio_items[1], 551 EXPECT_EQ(new_bubble_content.radio_group.radio_items[1],
552 l10n_util::GetStringUTF8( 552 l10n_util::GetStringUTF8(
553 IDS_BLOCKED_MEDIASTREAM_MIC_NO_ACTION)); 553 IDS_BLOCKED_MEDIASTREAM_MIC_NO_ACTION));
554 EXPECT_EQ(1, new_bubble_content.radio_group.default_item); 554 EXPECT_EQ(1, new_bubble_content.radio_group.default_item);
555 EXPECT_TRUE(new_bubble_content.custom_link.empty()); 555 EXPECT_TRUE(new_bubble_content.custom_link.empty());
556 EXPECT_FALSE(new_bubble_content.custom_link_enabled); 556 EXPECT_FALSE(new_bubble_content.custom_link_enabled);
557 EXPECT_FALSE(new_bubble_content.manage_link.empty()); 557 EXPECT_FALSE(new_bubble_content.manage_text.empty());
558 EXPECT_EQ(1U, new_bubble_content.media_menus.size()); 558 EXPECT_EQ(1U, new_bubble_content.media_menus.size());
559 EXPECT_EQ(content::MEDIA_DEVICE_AUDIO_CAPTURE, 559 EXPECT_EQ(content::MEDIA_DEVICE_AUDIO_CAPTURE,
560 new_bubble_content.media_menus.begin()->first); 560 new_bubble_content.media_menus.begin()->first);
561 } 561 }
562 562
563 TEST_F(ContentSettingBubbleModelTest, MediastreamCamera) { 563 TEST_F(ContentSettingBubbleModelTest, MediastreamCamera) {
564 // Required to break dependency on BrowserMainLoop. 564 // Required to break dependency on BrowserMainLoop.
565 MediaCaptureDevicesDispatcher::GetInstance()-> 565 MediaCaptureDevicesDispatcher::GetInstance()->
566 DisableDeviceEnumerationForTesting(); 566 DisableDeviceEnumerationForTesting();
567 567
(...skipping 21 matching lines...) Expand all
589 EXPECT_EQ(bubble_content.radio_group.radio_items[0], 589 EXPECT_EQ(bubble_content.radio_group.radio_items[0],
590 l10n_util::GetStringFUTF8( 590 l10n_util::GetStringFUTF8(
591 IDS_ALLOWED_MEDIASTREAM_CAMERA_NO_ACTION, 591 IDS_ALLOWED_MEDIASTREAM_CAMERA_NO_ACTION,
592 url_formatter::FormatUrlForSecurityDisplay(security_origin))); 592 url_formatter::FormatUrlForSecurityDisplay(security_origin)));
593 EXPECT_EQ(bubble_content.radio_group.radio_items[1], 593 EXPECT_EQ(bubble_content.radio_group.radio_items[1],
594 l10n_util::GetStringUTF8( 594 l10n_util::GetStringUTF8(
595 IDS_ALLOWED_MEDIASTREAM_CAMERA_BLOCK)); 595 IDS_ALLOWED_MEDIASTREAM_CAMERA_BLOCK));
596 EXPECT_EQ(0, bubble_content.radio_group.default_item); 596 EXPECT_EQ(0, bubble_content.radio_group.default_item);
597 EXPECT_TRUE(bubble_content.custom_link.empty()); 597 EXPECT_TRUE(bubble_content.custom_link.empty());
598 EXPECT_FALSE(bubble_content.custom_link_enabled); 598 EXPECT_FALSE(bubble_content.custom_link_enabled);
599 EXPECT_FALSE(bubble_content.manage_link.empty()); 599 EXPECT_FALSE(bubble_content.manage_text.empty());
600 EXPECT_EQ(1U, bubble_content.media_menus.size()); 600 EXPECT_EQ(1U, bubble_content.media_menus.size());
601 EXPECT_EQ(content::MEDIA_DEVICE_VIDEO_CAPTURE, 601 EXPECT_EQ(content::MEDIA_DEVICE_VIDEO_CAPTURE,
602 bubble_content.media_menus.begin()->first); 602 bubble_content.media_menus.begin()->first);
603 603
604 // Change the camera access. 604 // Change the camera access.
605 microphone_camera_state |= TabSpecificContentSettings::CAMERA_BLOCKED; 605 microphone_camera_state |= TabSpecificContentSettings::CAMERA_BLOCKED;
606 content_settings->OnMediaStreamPermissionSet(security_origin, 606 content_settings->OnMediaStreamPermissionSet(security_origin,
607 microphone_camera_state, 607 microphone_camera_state,
608 std::string(), 608 std::string(),
609 GetDefaultVideoDevice(), 609 GetDefaultVideoDevice(),
(...skipping 10 matching lines...) Expand all
620 EXPECT_EQ(new_bubble_content.radio_group.radio_items[0], 620 EXPECT_EQ(new_bubble_content.radio_group.radio_items[0],
621 l10n_util::GetStringFUTF8( 621 l10n_util::GetStringFUTF8(
622 IDS_BLOCKED_MEDIASTREAM_CAMERA_ASK, 622 IDS_BLOCKED_MEDIASTREAM_CAMERA_ASK,
623 url_formatter::FormatUrlForSecurityDisplay(security_origin))); 623 url_formatter::FormatUrlForSecurityDisplay(security_origin)));
624 EXPECT_EQ(new_bubble_content.radio_group.radio_items[1], 624 EXPECT_EQ(new_bubble_content.radio_group.radio_items[1],
625 l10n_util::GetStringUTF8( 625 l10n_util::GetStringUTF8(
626 IDS_BLOCKED_MEDIASTREAM_CAMERA_NO_ACTION)); 626 IDS_BLOCKED_MEDIASTREAM_CAMERA_NO_ACTION));
627 EXPECT_EQ(1, new_bubble_content.radio_group.default_item); 627 EXPECT_EQ(1, new_bubble_content.radio_group.default_item);
628 EXPECT_TRUE(new_bubble_content.custom_link.empty()); 628 EXPECT_TRUE(new_bubble_content.custom_link.empty());
629 EXPECT_FALSE(new_bubble_content.custom_link_enabled); 629 EXPECT_FALSE(new_bubble_content.custom_link_enabled);
630 EXPECT_FALSE(new_bubble_content.manage_link.empty()); 630 EXPECT_FALSE(new_bubble_content.manage_text.empty());
631 EXPECT_EQ(1U, new_bubble_content.media_menus.size()); 631 EXPECT_EQ(1U, new_bubble_content.media_menus.size());
632 EXPECT_EQ(content::MEDIA_DEVICE_VIDEO_CAPTURE, 632 EXPECT_EQ(content::MEDIA_DEVICE_VIDEO_CAPTURE,
633 new_bubble_content.media_menus.begin()->first); 633 new_bubble_content.media_menus.begin()->first);
634 } 634 }
635 635
636 TEST_F(ContentSettingBubbleModelTest, AccumulateMediastreamMicAndCamera) { 636 TEST_F(ContentSettingBubbleModelTest, AccumulateMediastreamMicAndCamera) {
637 // Required to break dependency on BrowserMainLoop. 637 // Required to break dependency on BrowserMainLoop.
638 MediaCaptureDevicesDispatcher::GetInstance()-> 638 MediaCaptureDevicesDispatcher::GetInstance()->
639 DisableDeviceEnumerationForTesting(); 639 DisableDeviceEnumerationForTesting();
640 640
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 NULL, web_contents(), profile(), CONTENT_SETTINGS_TYPE_PLUGINS)); 714 NULL, web_contents(), profile(), CONTENT_SETTINGS_TYPE_PLUGINS));
715 const ContentSettingBubbleModel::BubbleContent& bubble_content = 715 const ContentSettingBubbleModel::BubbleContent& bubble_content =
716 content_setting_bubble_model->bubble_content(); 716 content_setting_bubble_model->bubble_content();
717 EXPECT_FALSE(bubble_content.title.empty()); 717 EXPECT_FALSE(bubble_content.title.empty());
718 ASSERT_EQ(1U, bubble_content.list_items.size()); 718 ASSERT_EQ(1U, bubble_content.list_items.size());
719 EXPECT_EQ(plugin_name, 719 EXPECT_EQ(plugin_name,
720 base::ASCIIToUTF16(bubble_content.list_items[0].title)); 720 base::ASCIIToUTF16(bubble_content.list_items[0].title));
721 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size()); 721 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size());
722 EXPECT_FALSE(bubble_content.custom_link.empty()); 722 EXPECT_FALSE(bubble_content.custom_link.empty());
723 EXPECT_TRUE(bubble_content.custom_link_enabled); 723 EXPECT_TRUE(bubble_content.custom_link_enabled);
724 EXPECT_FALSE(bubble_content.manage_link.empty()); 724 EXPECT_FALSE(bubble_content.manage_text.empty());
725 EXPECT_FALSE(bubble_content.learn_more_link.empty()); 725 EXPECT_FALSE(bubble_content.learn_more_link.empty());
726 } 726 }
727 727
728 TEST_F(ContentSettingBubbleModelTest, PepperBroker) { 728 TEST_F(ContentSettingBubbleModelTest, PepperBroker) {
729 TabSpecificContentSettings* content_settings = 729 TabSpecificContentSettings* content_settings =
730 TabSpecificContentSettings::FromWebContents(web_contents()); 730 TabSpecificContentSettings::FromWebContents(web_contents());
731 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_PPAPI_BROKER); 731 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_PPAPI_BROKER);
732 732
733 std::unique_ptr<ContentSettingBubbleModel> content_setting_bubble_model( 733 std::unique_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
734 ContentSettingBubbleModel::CreateContentSettingBubbleModel( 734 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
735 NULL, web_contents(), profile(), CONTENT_SETTINGS_TYPE_PPAPI_BROKER)); 735 NULL, web_contents(), profile(), CONTENT_SETTINGS_TYPE_PPAPI_BROKER));
736 const ContentSettingBubbleModel::BubbleContent& bubble_content = 736 const ContentSettingBubbleModel::BubbleContent& bubble_content =
737 content_setting_bubble_model->bubble_content(); 737 content_setting_bubble_model->bubble_content();
738 738
739 base::string16 title = bubble_content.title; 739 base::string16 title = bubble_content.title;
740 EXPECT_FALSE(title.empty()); 740 EXPECT_FALSE(title.empty());
741 ASSERT_EQ(2U, bubble_content.radio_group.radio_items.size()); 741 ASSERT_EQ(2U, bubble_content.radio_group.radio_items.size());
742 std::string radio1 = bubble_content.radio_group.radio_items[0]; 742 std::string radio1 = bubble_content.radio_group.radio_items[0];
743 std::string radio2 = bubble_content.radio_group.radio_items[1]; 743 std::string radio2 = bubble_content.radio_group.radio_items[1];
744 EXPECT_FALSE(bubble_content.custom_link_enabled); 744 EXPECT_FALSE(bubble_content.custom_link_enabled);
745 EXPECT_FALSE(bubble_content.manage_link.empty()); 745 EXPECT_FALSE(bubble_content.manage_text.empty());
746 746
747 content_settings->ClearBlockedContentSettingsExceptForCookies(); 747 content_settings->ClearBlockedContentSettingsExceptForCookies();
748 content_settings->OnContentAllowed(CONTENT_SETTINGS_TYPE_PPAPI_BROKER); 748 content_settings->OnContentAllowed(CONTENT_SETTINGS_TYPE_PPAPI_BROKER);
749 content_setting_bubble_model.reset( 749 content_setting_bubble_model.reset(
750 ContentSettingBubbleModel::CreateContentSettingBubbleModel( 750 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
751 NULL, web_contents(), profile(), 751 NULL, web_contents(), profile(),
752 CONTENT_SETTINGS_TYPE_PPAPI_BROKER)); 752 CONTENT_SETTINGS_TYPE_PPAPI_BROKER));
753 const ContentSettingBubbleModel::BubbleContent& bubble_content_2 = 753 const ContentSettingBubbleModel::BubbleContent& bubble_content_2 =
754 content_setting_bubble_model->bubble_content(); 754 content_setting_bubble_model->bubble_content();
755 755
756 EXPECT_FALSE(bubble_content_2.title.empty()); 756 EXPECT_FALSE(bubble_content_2.title.empty());
757 EXPECT_NE(title, bubble_content_2.title); 757 EXPECT_NE(title, bubble_content_2.title);
758 ASSERT_EQ(2U, bubble_content_2.radio_group.radio_items.size()); 758 ASSERT_EQ(2U, bubble_content_2.radio_group.radio_items.size());
759 EXPECT_NE(radio1, bubble_content_2.radio_group.radio_items[0]); 759 EXPECT_NE(radio1, bubble_content_2.radio_group.radio_items[0]);
760 EXPECT_NE(radio2, bubble_content_2.radio_group.radio_items[1]); 760 EXPECT_NE(radio2, bubble_content_2.radio_group.radio_items[1]);
761 EXPECT_FALSE(bubble_content_2.custom_link_enabled); 761 EXPECT_FALSE(bubble_content_2.custom_link_enabled);
762 EXPECT_FALSE(bubble_content_2.manage_link.empty()); 762 EXPECT_FALSE(bubble_content_2.manage_text.empty());
763 } 763 }
764 764
765 TEST_F(ContentSettingBubbleModelTest, Geolocation) { 765 TEST_F(ContentSettingBubbleModelTest, Geolocation) {
766 const GURL page_url("http://toplevel.example/"); 766 const GURL page_url("http://toplevel.example/");
767 const GURL frame1_url("http://host1.example/"); 767 const GURL frame1_url("http://host1.example/");
768 const GURL frame2_url("http://host2.example:999/"); 768 const GURL frame2_url("http://host2.example:999/");
769 769
770 NavigateAndCommit(page_url); 770 NavigateAndCommit(page_url);
771 TabSpecificContentSettings* content_settings = 771 TabSpecificContentSettings* content_settings =
772 TabSpecificContentSettings::FromWebContents(web_contents()); 772 TabSpecificContentSettings::FromWebContents(web_contents());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 NULL, web_contents(), profile(), NULL); 824 NULL, web_contents(), profile(), NULL);
825 825
826 const ContentSettingBubbleModel::BubbleContent& bubble_content = 826 const ContentSettingBubbleModel::BubbleContent& bubble_content =
827 content_setting_bubble_model.bubble_content(); 827 content_setting_bubble_model.bubble_content();
828 EXPECT_FALSE(bubble_content.title.empty()); 828 EXPECT_FALSE(bubble_content.title.empty());
829 EXPECT_FALSE(bubble_content.radio_group.radio_items.empty()); 829 EXPECT_FALSE(bubble_content.radio_group.radio_items.empty());
830 EXPECT_TRUE(bubble_content.list_items.empty()); 830 EXPECT_TRUE(bubble_content.list_items.empty());
831 EXPECT_TRUE(bubble_content.domain_lists.empty()); 831 EXPECT_TRUE(bubble_content.domain_lists.empty());
832 EXPECT_TRUE(bubble_content.custom_link.empty()); 832 EXPECT_TRUE(bubble_content.custom_link.empty());
833 EXPECT_FALSE(bubble_content.custom_link_enabled); 833 EXPECT_FALSE(bubble_content.custom_link_enabled);
834 EXPECT_FALSE(bubble_content.manage_link.empty()); 834 EXPECT_FALSE(bubble_content.manage_text.empty());
835 } 835 }
836 836
837 class FakeDelegate : public ProtocolHandlerRegistry::Delegate { 837 class FakeDelegate : public ProtocolHandlerRegistry::Delegate {
838 public: 838 public:
839 void RegisterExternalHandler(const std::string& protocol) override { 839 void RegisterExternalHandler(const std::string& protocol) override {
840 // Overrides in order to not register the handler with the 840 // Overrides in order to not register the handler with the
841 // ChildProcessSecurityPolicy. That has persistent and unalterable 841 // ChildProcessSecurityPolicy. That has persistent and unalterable
842 // side effects on other tests. 842 // side effects on other tests.
843 } 843 }
844 844
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 bubble_content.title, 930 bubble_content.title,
931 l10n_util::GetStringUTF16(IDS_FILTERED_DECEPTIVE_CONTENT_PROMPT_TITLE)); 931 l10n_util::GetStringUTF16(IDS_FILTERED_DECEPTIVE_CONTENT_PROMPT_TITLE));
932 EXPECT_EQ(bubble_content.message, 932 EXPECT_EQ(bubble_content.message,
933 l10n_util::GetStringUTF16( 933 l10n_util::GetStringUTF16(
934 IDS_FILTERED_DECEPTIVE_CONTENT_PROMPT_EXPLANATION)); 934 IDS_FILTERED_DECEPTIVE_CONTENT_PROMPT_EXPLANATION));
935 EXPECT_EQ(0U, bubble_content.radio_group.radio_items.size()); 935 EXPECT_EQ(0U, bubble_content.radio_group.radio_items.size());
936 EXPECT_EQ(0, bubble_content.radio_group.default_item); 936 EXPECT_EQ(0, bubble_content.radio_group.default_item);
937 EXPECT_TRUE(bubble_content.custom_link.empty()); 937 EXPECT_TRUE(bubble_content.custom_link.empty());
938 EXPECT_FALSE(bubble_content.custom_link_enabled); 938 EXPECT_FALSE(bubble_content.custom_link_enabled);
939 EXPECT_EQ( 939 EXPECT_EQ(
940 bubble_content.manage_link, 940 bubble_content.manage_text,
941 l10n_util::GetStringUTF8(IDS_FILTERED_DECEPTIVE_CONTENT_PROMPT_RELOAD)); 941 l10n_util::GetStringUTF8(IDS_FILTERED_DECEPTIVE_CONTENT_PROMPT_RELOAD));
942 EXPECT_EQ(0U, bubble_content.media_menus.size()); 942 EXPECT_EQ(0U, bubble_content.media_menus.size());
943 } 943 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698