Chromium Code Reviews| Index: chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc |
| diff --git a/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc b/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc |
| index 9ca8d28fc5fe3c30b46e6a65f13b7c36df506232..508576e6a400e7b94c983177b6366b1e300e7e54 100644 |
| --- a/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc |
| +++ b/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc |
| @@ -4,13 +4,16 @@ |
| #include "base/auto_reset.h" |
| #include "base/command_line.h" |
| +#include "base/utf_string_conversions.h" |
| #include "chrome/browser/content_settings/host_content_settings_map.h" |
| #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| +#include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" |
| #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| #include "chrome/browser/ui/tab_contents/test_tab_contents.h" |
| #include "chrome/common/chrome_switches.h" |
| +#include "chrome/common/content_settings.h" |
| #include "chrome/test/base/testing_profile.h" |
| #include "content/public/browser/web_contents.h" |
| #include "content/public/test/test_browser_thread.h" |
| @@ -220,3 +223,75 @@ TEST_F(ContentSettingBubbleModelTest, FileURL) { |
| content_setting_bubble_model->bubble_content().radio_group.radio_items[0]; |
| ASSERT_NE(std::string::npos, title.find(file_url)); |
| } |
| + |
| +TEST_F(ContentSettingBubbleModelTest, RegisterProtocolHandler) { |
| + const GURL page_url("http://toplevel.example/"); |
| + NavigateAndCommit(page_url); |
| + TabSpecificContentSettings* content_settings = |
| + tab_contents()->content_settings(); |
| + content_settings->SetPendingProtocolHandler( |
| + ProtocolHandler::CreateProtocolHandler( |
| + "mailto", GURL("http://www.toplevel.example/"), |
| + ASCIIToUTF16("Handler"))); |
| + |
| + scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( |
| + ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
| + NULL, tab_contents(), profile(), |
| + CONTENT_SETTINGS_TYPE_REGISTER_PROTOCOL_HANDLER)); |
| + const ContentSettingBubbleModel::BubbleContent& bubble_content = |
| + content_setting_bubble_model->bubble_content(); |
| + EXPECT_FALSE(bubble_content.title.empty()); |
| + EXPECT_FALSE(bubble_content.radio_group.radio_items.empty()); |
| + EXPECT_TRUE(bubble_content.popup_items.empty()); |
| + EXPECT_EQ(0U, bubble_content.domain_lists.size()); |
| + EXPECT_TRUE(bubble_content.custom_link.empty()); |
| + EXPECT_FALSE(bubble_content.custom_link_enabled); |
| + EXPECT_FALSE(bubble_content.manage_link.empty()); |
| +} |
| + |
| +TEST_F(ContentSettingBubbleModelTest, RPHAllow) { |
| + profile()->CreateProtocolHandlerRegistry(); |
| + |
| + const GURL page_url("http://toplevel.example/"); |
| + NavigateAndCommit(page_url); |
| + TabSpecificContentSettings* content_settings = |
| + tab_contents()->content_settings(); |
| + content_settings->SetPendingProtocolHandler( |
| + ProtocolHandler::CreateProtocolHandler( |
| + "mailto", GURL("http://www.toplevel.example/"), |
| + ASCIIToUTF16("Handler"))); |
| + |
| + scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( |
| + ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
| + NULL, tab_contents(), profile(), |
| + CONTENT_SETTINGS_TYPE_REGISTER_PROTOCOL_HANDLER)); |
| + |
| + { |
| + ProtocolHandler handler = |
| + profile()->GetProtocolHandlerRegistry()->GetHandlerFor("mailto"); |
| + EXPECT_TRUE(handler.IsEmpty()); |
| + EXPECT_EQ(CONTENT_SETTING_DEFAULT, |
| + content_settings->GetPendingProtocolHandlerSetting()); |
| + } |
| + |
| + // "0" is the "Allow" radio button. |
| + content_setting_bubble_model->OnRadioClicked(0); |
| + { |
| + ProtocolHandler handler = |
| + profile()->GetProtocolHandlerRegistry()->GetHandlerFor("mailto"); |
| + ASSERT_FALSE(handler.IsEmpty()); |
| + EXPECT_EQ(ASCIIToUTF16("Handler"), handler.title()); |
| + EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| + content_settings->GetPendingProtocolHandlerSetting()); |
| + } |
| + |
| + // "1" is the "Deny" radio button. |
| + content_setting_bubble_model->OnRadioClicked(1); |
|
koz (OOO until 15th September)
2012/06/22 00:41:14
If you make these constants as per my previous com
Greg Billock
2012/06/22 19:45:40
I put them on the hidden class, so I can't get to
|
| + { |
| + ProtocolHandler handler = |
| + profile()->GetProtocolHandlerRegistry()->GetHandlerFor("mailto"); |
| + EXPECT_TRUE(handler.IsEmpty()); |
| + EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| + content_settings->GetPendingProtocolHandlerSetting()); |
| + } |
| +} |