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

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

Issue 5564007: Update Content Settings Bubbles (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Address additional CR feedback Created 10 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/content_setting_bubble_model.h" 5 #include "chrome/browser/content_setting_bubble_model.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 "chrome/browser/browser_thread.h" 9 #include "chrome/browser/browser_thread.h"
10 #include "chrome/browser/content_settings/host_content_settings_map.h" 10 #include "chrome/browser/content_settings/host_content_settings_map.h"
(...skipping 12 matching lines...) Expand all
23 } 23 }
24 24
25 void CheckGeolocationBubble(size_t expected_domains, 25 void CheckGeolocationBubble(size_t expected_domains,
26 bool expect_clear_link, 26 bool expect_clear_link,
27 bool expect_reload_hint) { 27 bool expect_reload_hint) {
28 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( 28 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
29 ContentSettingBubbleModel::CreateContentSettingBubbleModel( 29 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
30 contents(), profile_.get(), CONTENT_SETTINGS_TYPE_GEOLOCATION)); 30 contents(), profile_.get(), CONTENT_SETTINGS_TYPE_GEOLOCATION));
31 const ContentSettingBubbleModel::BubbleContent& bubble_content = 31 const ContentSettingBubbleModel::BubbleContent& bubble_content =
32 content_setting_bubble_model->bubble_content(); 32 content_setting_bubble_model->bubble_content();
33 EXPECT_EQ(0U, bubble_content.radio_group.radio_items.size()); 33 EXPECT_TRUE(bubble_content.title.empty());
34 EXPECT_EQ(0U, bubble_content.popup_items.size()); 34 EXPECT_TRUE(bubble_content.radio_group.radio_items.empty());
35 // The reload hint is currently implemented as a tacked on domain title, so 35 EXPECT_TRUE(bubble_content.popup_items.empty());
36 // account for this.
37 if (expect_reload_hint)
38 ++expected_domains;
39 EXPECT_EQ(expected_domains, bubble_content.domain_lists.size()); 36 EXPECT_EQ(expected_domains, bubble_content.domain_lists.size());
40 if (expect_clear_link) 37 EXPECT_NE(expect_clear_link || expect_reload_hint,
41 EXPECT_NE(std::string(), bubble_content.clear_link); 38 bubble_content.custom_link.empty());
42 else 39 EXPECT_EQ(expect_clear_link, bubble_content.custom_link_enabled);
43 EXPECT_EQ(std::string(), bubble_content.clear_link); 40 EXPECT_FALSE(bubble_content.manage_link.empty());
44 EXPECT_NE(std::string(), bubble_content.manage_link);
45 EXPECT_EQ(std::string(), bubble_content.info_link);
46 EXPECT_EQ(std::string(), bubble_content.title);
47 EXPECT_EQ(std::string(), bubble_content.load_plugins_link_title);
48 } 41 }
49 42
50 BrowserThread ui_thread_; 43 BrowserThread ui_thread_;
51 }; 44 };
52 45
53 TEST_F(ContentSettingBubbleModelTest, ImageRadios) { 46 TEST_F(ContentSettingBubbleModelTest, ImageRadios) {
54 TabSpecificContentSettings* content_settings = 47 TabSpecificContentSettings* content_settings =
55 contents()->GetTabSpecificContentSettings(); 48 contents()->GetTabSpecificContentSettings();
56 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES, 49 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES,
57 std::string()); 50 std::string());
58 51
59 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( 52 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
60 ContentSettingBubbleModel::CreateContentSettingBubbleModel( 53 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
61 contents(), profile_.get(), CONTENT_SETTINGS_TYPE_IMAGES)); 54 contents(), profile_.get(), CONTENT_SETTINGS_TYPE_IMAGES));
62 const ContentSettingBubbleModel::BubbleContent& bubble_content = 55 const ContentSettingBubbleModel::BubbleContent& bubble_content =
63 content_setting_bubble_model->bubble_content(); 56 content_setting_bubble_model->bubble_content();
57 EXPECT_FALSE(bubble_content.title.empty());
64 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size()); 58 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size());
65 EXPECT_EQ(0, bubble_content.radio_group.default_item); 59 EXPECT_EQ(0, bubble_content.radio_group.default_item);
66 EXPECT_NE(std::string(), bubble_content.manage_link); 60 EXPECT_TRUE(bubble_content.custom_link.empty());
67 EXPECT_EQ(std::string(), bubble_content.info_link); 61 EXPECT_FALSE(bubble_content.manage_link.empty());
68 EXPECT_NE(std::string(), bubble_content.title);
69 EXPECT_EQ(std::string(), bubble_content.load_plugins_link_title);
70 } 62 }
71 63
72 TEST_F(ContentSettingBubbleModelTest, Cookies) { 64 TEST_F(ContentSettingBubbleModelTest, Cookies) {
73 TabSpecificContentSettings* content_settings = 65 TabSpecificContentSettings* content_settings =
74 contents()->GetTabSpecificContentSettings(); 66 contents()->GetTabSpecificContentSettings();
75 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES, 67 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES,
76 std::string()); 68 std::string());
77 69
78 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( 70 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
79 ContentSettingBubbleModel::CreateContentSettingBubbleModel( 71 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
80 contents(), profile_.get(), CONTENT_SETTINGS_TYPE_COOKIES)); 72 contents(), profile_.get(), CONTENT_SETTINGS_TYPE_COOKIES));
81 const ContentSettingBubbleModel::BubbleContent& bubble_content = 73 const ContentSettingBubbleModel::BubbleContent& bubble_content =
82 content_setting_bubble_model->bubble_content(); 74 content_setting_bubble_model->bubble_content();
83 EXPECT_EQ(0U, bubble_content.radio_group.radio_items.size()); 75 EXPECT_FALSE(bubble_content.title.empty());
84 EXPECT_NE(std::string(), bubble_content.manage_link); 76 EXPECT_TRUE(bubble_content.radio_group.radio_items.empty());
85 EXPECT_NE(std::string(), bubble_content.info_link); 77 EXPECT_FALSE(bubble_content.custom_link.empty());
86 EXPECT_NE(std::string(), bubble_content.title); 78 EXPECT_TRUE(bubble_content.custom_link_enabled);
87 EXPECT_EQ(std::string(), bubble_content.load_plugins_link_title); 79 EXPECT_FALSE(bubble_content.manage_link.empty());
88 } 80 }
89 81
90 TEST_F(ContentSettingBubbleModelTest, Plugins) { 82 TEST_F(ContentSettingBubbleModelTest, Plugins) {
91 TabSpecificContentSettings* content_settings = 83 TabSpecificContentSettings* content_settings =
92 contents()->GetTabSpecificContentSettings(); 84 contents()->GetTabSpecificContentSettings();
93 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_PLUGINS, 85 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_PLUGINS,
94 std::string()); 86 std::string());
95 87
96 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( 88 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
97 ContentSettingBubbleModel::CreateContentSettingBubbleModel( 89 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
98 contents(), profile_.get(), CONTENT_SETTINGS_TYPE_PLUGINS)); 90 contents(), profile_.get(), CONTENT_SETTINGS_TYPE_PLUGINS));
99 const ContentSettingBubbleModel::BubbleContent& bubble_content = 91 const ContentSettingBubbleModel::BubbleContent& bubble_content =
100 content_setting_bubble_model->bubble_content(); 92 content_setting_bubble_model->bubble_content();
93 EXPECT_FALSE(bubble_content.title.empty());
101 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size()); 94 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size());
102 EXPECT_NE(std::string(), bubble_content.manage_link); 95 EXPECT_FALSE(bubble_content.custom_link.empty());
103 EXPECT_EQ(std::string(), bubble_content.info_link); 96 EXPECT_TRUE(bubble_content.custom_link_enabled);
104 EXPECT_NE(std::string(), bubble_content.title); 97 EXPECT_FALSE(bubble_content.manage_link.empty());
105 EXPECT_NE(std::string(), bubble_content.load_plugins_link_title);
106 } 98 }
107 99
108 TEST_F(ContentSettingBubbleModelTest, MultiplePlugins) { 100 TEST_F(ContentSettingBubbleModelTest, MultiplePlugins) {
109 CommandLine* cmd = CommandLine::ForCurrentProcess(); 101 CommandLine* cmd = CommandLine::ForCurrentProcess();
110 AutoReset<CommandLine> auto_reset(cmd, *cmd); 102 AutoReset<CommandLine> auto_reset(cmd, *cmd);
111 cmd->AppendSwitch(switches::kEnableResourceContentSettings); 103 cmd->AppendSwitch(switches::kEnableResourceContentSettings);
112 cmd->AppendSwitch(switches::kEnableClickToPlay); 104 cmd->AppendSwitch(switches::kEnableClickToPlay);
113 105
114 HostContentSettingsMap* map = profile_->GetHostContentSettingsMap(); 106 HostContentSettingsMap* map = profile_->GetHostContentSettingsMap();
115 std::string fooPlugin = "foo"; 107 std::string fooPlugin = "foo";
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 CheckGeolocationBubble(1, false, false); 178 CheckGeolocationBubble(1, false, false);
187 179
188 // Second frame denied, but not stored in the content map: requires reload. 180 // Second frame denied, but not stored in the content map: requires reload.
189 content_settings->OnGeolocationPermissionSet(frame2_url, false); 181 content_settings->OnGeolocationPermissionSet(frame2_url, false);
190 CheckGeolocationBubble(2, false, true); 182 CheckGeolocationBubble(2, false, true);
191 183
192 // Change the default to block: offer a clear link for the persisted frame 1. 184 // Change the default to block: offer a clear link for the persisted frame 1.
193 setting_map->SetDefaultContentSetting(CONTENT_SETTING_BLOCK); 185 setting_map->SetDefaultContentSetting(CONTENT_SETTING_BLOCK);
194 CheckGeolocationBubble(2, true, false); 186 CheckGeolocationBubble(2, true, false);
195 } 187 }
OLDNEW
« no previous file with comments | « chrome/browser/content_setting_bubble_model.cc ('k') | chrome/browser/gtk/content_setting_bubble_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698