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-09 06:55:01 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-09 06:55:01 +0000
commit18e001a7c9575037eda35bed4a0e35984945323d (patch)
tree7536f72a9227e8bc1a53c5b5fad00534a38c6133 /chrome/browser/content_setting_image_model_unittest.cc
parent09a8baca4d9887ff96fae636cc6ed4c6fd2ae992 (diff)
downloadchromium_src-18e001a7c9575037eda35bed4a0e35984945323d.zip
chromium_src-18e001a7c9575037eda35bed4a0e35984945323d.tar.gz
chromium_src-18e001a7c9575037eda35bed4a0e35984945323d.tar.bz2
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 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55382 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());
}