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

Unified Diff: chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc

Issue 2323693002: Site Settings Desktop: Implement Zoom Levels category. (Closed)
Patch Set: Fix test Created 4 years, 3 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc
diff --git a/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc b/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc
index 7dea52e16fdeb77b301cd452852f1f422279e0a5..85b4af79192c6926b0fc6c97197d4d7ec731b694 100644
--- a/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc
+++ b/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc
@@ -148,6 +148,37 @@ class SiteSettingsHandlerTest : public testing::Test {
EXPECT_EQ(expected_incognito, incognito);
}
+ void ValidateZoom(const std::string& expected_host,
+ const std::string& expected_zoom, size_t expected_total_calls) {
+ EXPECT_EQ(expected_total_calls, web_ui()->call_data().size());
+
+ const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
+ EXPECT_EQ("cr.webUIListenerCallback", data.function_name());
+
+ std::string callback_id;
+ ASSERT_TRUE(data.arg1()->GetAsString(&callback_id));
+ EXPECT_EQ("onZoomLevelsChanged", callback_id);
+
+ const base::ListValue* exceptions;
+ ASSERT_TRUE(data.arg2()->GetAsList(&exceptions));
+ if (expected_host.empty()) {
+ EXPECT_EQ(0U, exceptions->GetSize());
+ } else {
+ EXPECT_EQ(1U, exceptions->GetSize());
+
+ const base::DictionaryValue* exception;
+ ASSERT_TRUE(exceptions->GetDictionary(0, &exception));
+
+ std::string host;
+ ASSERT_TRUE(exception->GetString("origin", &host));
+ ASSERT_EQ(expected_host, host);
+
+ std::string zoom;
+ ASSERT_TRUE(exception->GetString("zoom", &zoom));
+ ASSERT_EQ(expected_zoom, zoom);
+ }
+ }
+
void CreateIncognitoProfile() {
incognito_profile_ = TestingProfile::Builder().BuildIncognito(&profile_);
}
@@ -253,4 +284,26 @@ TEST_F(SiteSettingsHandlerTest, Incognito) {
ValidateIncognitoExists(false, 3U);
}
+TEST_F(SiteSettingsHandlerTest, ZoomLevels) {
+ std::string host("http://www.google.com");
+ double zoom_level = 1.1;
+
+ content::HostZoomMap* host_zoom_map =
+ content::HostZoomMap::GetDefaultForBrowserContext(profile());
+ host_zoom_map->SetZoomLevelForHost(host, zoom_level);
+ ValidateZoom(host, "122%", 1U);
+
+ base::ListValue args;
+ handler()->HandleFetchZoomLevels(&args);
+ ValidateZoom(host, "122%", 2U);
+
+ args.AppendString("http://www.google.com");
+ handler()->HandleRemoveZoomLevel(&args);
+ ValidateZoom("", "", 3U);
+
+ double default_level = host_zoom_map->GetDefaultZoomLevel();
+ double level = host_zoom_map->GetZoomLevelForHostAndScheme("http", host);
+ EXPECT_EQ(default_level, level);
+}
+
} // namespace settings

Powered by Google App Engine
This is Rietveld 408576698