summaryrefslogtreecommitdiffstats
path: root/chrome/browser/host_zoom_map_unittest.cc
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-23 07:17:54 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-23 07:17:54 +0000
commit9d797f394f319b754ed91a981dab566d764d2c2e (patch)
treeaee695b1c2af9d540e3fe99d834de015f70665cf /chrome/browser/host_zoom_map_unittest.cc
parent97c9e77b34099c518f85571f6d36e178d7695b23 (diff)
downloadchromium_src-9d797f394f319b754ed91a981dab566d764d2c2e.zip
chromium_src-9d797f394f319b754ed91a981dab566d764d2c2e.tar.gz
chromium_src-9d797f394f319b754ed91a981dab566d764d2c2e.tar.bz2
Send content settings based on the URL to the renderer instead of just the host.
BUG=36025 TEST=manual Review URL: http://codereview.chromium.org/1744003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45424 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/host_zoom_map_unittest.cc')
-rw-r--r--chrome/browser/host_zoom_map_unittest.cc45
1 files changed, 29 insertions, 16 deletions
diff --git a/chrome/browser/host_zoom_map_unittest.cc b/chrome/browser/host_zoom_map_unittest.cc
index fb7b52d..a59a142 100644
--- a/chrome/browser/host_zoom_map_unittest.cc
+++ b/chrome/browser/host_zoom_map_unittest.cc
@@ -16,6 +16,7 @@
#include "chrome/common/notification_type.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/testing_profile.h"
+#include "googleurl/src/gurl.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -30,7 +31,8 @@ class HostZoomMapTest : public testing::Test {
: ui_thread_(ChromeThread::UI, &message_loop_),
prefs_(profile_.GetPrefs()),
per_host_zoom_levels_pref_(prefs::kPerHostZoomLevels),
- host_name_("http://example/com/") {}
+ url_("http://example.com/test"),
+ host_("example.com") {}
protected:
void SetPrefObserverExpectation() {
@@ -47,64 +49,75 @@ class HostZoomMapTest : public testing::Test {
TestingProfile profile_;
PrefService* prefs_;
std::wstring per_host_zoom_levels_pref_; // For the observe matcher.
- std::string host_name_;
+ GURL url_;
+ std::string host_;
NotificationObserverMock pref_observer_;
};
const int HostZoomMapTest::kZoomLevel = 42;
TEST_F(HostZoomMapTest, LoadNoPrefs) {
scoped_refptr<HostZoomMap> map(new HostZoomMap(&profile_));
- EXPECT_EQ(0, map->GetZoomLevel(host_name_));
+ EXPECT_EQ(0, map->GetZoomLevel(url_));
}
TEST_F(HostZoomMapTest, Load) {
DictionaryValue* dict =
prefs_->GetMutableDictionary(prefs::kPerHostZoomLevels);
- dict->SetWithoutPathExpansion(UTF8ToWide(host_name_),
+ dict->SetWithoutPathExpansion(UTF8ToWide(host_),
Value::CreateIntegerValue(kZoomLevel));
scoped_refptr<HostZoomMap> map(new HostZoomMap(&profile_));
- EXPECT_EQ(kZoomLevel, map->GetZoomLevel(host_name_));
+ EXPECT_EQ(kZoomLevel, map->GetZoomLevel(url_));
}
TEST_F(HostZoomMapTest, SetZoomLevel) {
scoped_refptr<HostZoomMap> map(new HostZoomMap(&profile_));
prefs_->AddPrefObserver(prefs::kPerHostZoomLevels, &pref_observer_);
SetPrefObserverExpectation();
- map->SetZoomLevel(host_name_, kZoomLevel);
- EXPECT_EQ(kZoomLevel, map->GetZoomLevel(host_name_));
+ map->SetZoomLevel(url_, kZoomLevel);
+ EXPECT_EQ(kZoomLevel, map->GetZoomLevel(url_));
const DictionaryValue* dict =
prefs_->GetDictionary(prefs::kPerHostZoomLevels);
int zoom_level = 0;
- EXPECT_TRUE(dict->GetIntegerWithoutPathExpansion(UTF8ToWide(host_name_),
+ EXPECT_TRUE(dict->GetIntegerWithoutPathExpansion(UTF8ToWide(host_),
&zoom_level));
EXPECT_EQ(kZoomLevel, zoom_level);
SetPrefObserverExpectation();
- map->SetZoomLevel(host_name_, 0);
- EXPECT_EQ(0, map->GetZoomLevel(host_name_));
- EXPECT_FALSE(dict->HasKey(UTF8ToWide(host_name_)));
+ map->SetZoomLevel(url_, 0);
+ EXPECT_EQ(0, map->GetZoomLevel(url_));
+ EXPECT_FALSE(dict->HasKey(UTF8ToWide(host_)));
prefs_->RemovePrefObserver(prefs::kPerHostZoomLevels, &pref_observer_);
}
TEST_F(HostZoomMapTest, ResetToDefaults) {
scoped_refptr<HostZoomMap> map(new HostZoomMap(&profile_));
- map->SetZoomLevel(host_name_, kZoomLevel);
+ map->SetZoomLevel(url_, kZoomLevel);
prefs_->AddPrefObserver(prefs::kPerHostZoomLevels, &pref_observer_);
SetPrefObserverExpectation();
map->ResetToDefaults();
- EXPECT_EQ(0, map->GetZoomLevel(host_name_));
+ EXPECT_EQ(0, map->GetZoomLevel(url_));
EXPECT_EQ(NULL, prefs_->GetDictionary(prefs::kPerHostZoomLevels));
prefs_->RemovePrefObserver(prefs::kPerHostZoomLevels, &pref_observer_);
}
TEST_F(HostZoomMapTest, ReloadOnPrefChange) {
scoped_refptr<HostZoomMap> map(new HostZoomMap(&profile_));
- map->SetZoomLevel(host_name_, kZoomLevel);
+ map->SetZoomLevel(url_, kZoomLevel);
DictionaryValue dict;
- dict.SetWithoutPathExpansion(UTF8ToWide(host_name_),
+ dict.SetWithoutPathExpansion(UTF8ToWide(host_),
Value::CreateIntegerValue(0));
prefs_->Set(prefs::kPerHostZoomLevels, dict);
- EXPECT_EQ(0, map->GetZoomLevel(host_name_));
+ EXPECT_EQ(0, map->GetZoomLevel(url_));
+}
+
+TEST_F(HostZoomMapTest, NoHost) {
+ scoped_refptr<HostZoomMap> map(new HostZoomMap(&profile_));
+ GURL file_url1_("file:///tmp/test.html");
+ GURL file_url2_("file:///tmp/other.html");
+ map->SetZoomLevel(file_url1_, kZoomLevel);
+
+ EXPECT_EQ(kZoomLevel, map->GetZoomLevel(file_url1_));
+ EXPECT_EQ(0, map->GetZoomLevel(file_url2_));
}