summaryrefslogtreecommitdiffstats
path: root/chrome/browser/content_setting_image_model_unittest.cc
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-10 07:13:06 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-10 07:13:06 +0000
commitd0ce4e6276eb30ec7b3957c10d42caacc51ac583 (patch)
treeeeadaa4f34325d6985e21a69babe7a963ea1d2e4 /chrome/browser/content_setting_image_model_unittest.cc
parente8dd1b272971bdf556b84a599fa4edaa33367191 (diff)
downloadchromium_src-d0ce4e6276eb30ec7b3957c10d42caacc51ac583.zip
chromium_src-d0ce4e6276eb30ec7b3957c10d42caacc51ac583.tar.gz
chromium_src-d0ce4e6276eb30ec7b3957c10d42caacc51ac583.tar.bz2
Reland r55382. When blocking cookies, also show an icon in the location bar when cookies are accessed.
If the user choses to block cookies per default, this will grant access to the collected cookies dialog as soon as the page accesses cookies. Right now, the icon is only shown if cookies were actually blocked. BUG=45230 TEST=Canned*.*:ContentSettingImage*.*:TabSpecific*.* Review URL: http://codereview.chromium.org/3014056 Review URL: http://codereview.chromium.org/3146003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55536 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/content_setting_image_model_unittest.cc')
-rw-r--r--chrome/browser/content_setting_image_model_unittest.cc38
1 files changed, 35 insertions, 3 deletions
diff --git a/chrome/browser/content_setting_image_model_unittest.cc b/chrome/browser/content_setting_image_model_unittest.cc
index 02a5af3..32aed3e 100644
--- a/chrome/browser/content_setting_image_model_unittest.cc
+++ b/chrome/browser/content_setting_image_model_unittest.cc
@@ -4,13 +4,25 @@
#include "chrome/browser/content_setting_image_model.h"
+#include "chrome/browser/chrome_thread.h"
+#include "chrome/browser/host_content_settings_map.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/renderer_host/test/test_render_view_host.h"
#include "chrome/browser/tab_contents/test_tab_contents.h"
#include "chrome/test/testing_profile.h"
#include "testing/gtest/include/gtest/gtest.h"
-typedef RenderViewHostTestHarness ContentSettingImageModelTest;
+class ContentSettingImageModelTest : public RenderViewHostTestHarness {
+ public:
+ ContentSettingImageModelTest()
+ : RenderViewHostTestHarness(),
+ ui_thread_(ChromeThread::UI, &message_loop_) {}
+
+ private:
+ ChromeThread ui_thread_;
+
+ DISALLOW_COPY_AND_ASSIGN(ContentSettingImageModelTest);
+};
TEST_F(ContentSettingImageModelTest, UpdateFromTabContents) {
TestTabContents tab_contents(profile_.get(), NULL);
@@ -21,12 +33,32 @@ TEST_F(ContentSettingImageModelTest, UpdateFromTabContents) {
CONTENT_SETTINGS_TYPE_IMAGES));
EXPECT_FALSE(content_setting_image_model->is_visible());
EXPECT_EQ(0, content_setting_image_model->get_icon());
- EXPECT_EQ("", content_setting_image_model->get_tooltip());
+ EXPECT_EQ(std::string(), content_setting_image_model->get_tooltip());
content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES);
content_setting_image_model->UpdateFromTabContents(&tab_contents);
EXPECT_TRUE(content_setting_image_model->is_visible());
EXPECT_NE(0, content_setting_image_model->get_icon());
- EXPECT_NE("", content_setting_image_model->get_tooltip());
+ EXPECT_NE(std::string(), content_setting_image_model->get_tooltip());
+}
+
+TEST_F(ContentSettingImageModelTest, CookieAccessed) {
+ TestTabContents tab_contents(profile_.get(), NULL);
+ TabSpecificContentSettings* content_settings =
+ tab_contents.GetTabSpecificContentSettings();
+ profile_->GetHostContentSettingsMap()->SetDefaultContentSetting(
+ CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_BLOCK);
+ scoped_ptr<ContentSettingImageModel> content_setting_image_model(
+ ContentSettingImageModel::CreateContentSettingImageModel(
+ CONTENT_SETTINGS_TYPE_COOKIES));
+ EXPECT_FALSE(content_setting_image_model->is_visible());
+ EXPECT_EQ(0, content_setting_image_model->get_icon());
+ EXPECT_EQ(std::string(), content_setting_image_model->get_tooltip());
+
+ content_settings->OnCookieAccessed(GURL("http://google.com"), "A=B", false);
+ content_setting_image_model->UpdateFromTabContents(&tab_contents);
+ EXPECT_TRUE(content_setting_image_model->is_visible());
+ EXPECT_NE(0, content_setting_image_model->get_icon());
+ EXPECT_NE(std::string(), content_setting_image_model->get_tooltip());
}