OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/webui/settings/site_settings_handler.h" | 5 #include "chrome/browser/ui/webui/settings/site_settings_handler.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/ui/webui/site_settings_helper.h" | 10 #include "chrome/browser/ui/webui/site_settings_helper.h" |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 std::string host; | 196 std::string host; |
197 ASSERT_TRUE(exception->GetString("origin", &host)); | 197 ASSERT_TRUE(exception->GetString("origin", &host)); |
198 ASSERT_EQ(expected_host, host); | 198 ASSERT_EQ(expected_host, host); |
199 | 199 |
200 std::string zoom; | 200 std::string zoom; |
201 ASSERT_TRUE(exception->GetString("zoom", &zoom)); | 201 ASSERT_TRUE(exception->GetString("zoom", &zoom)); |
202 ASSERT_EQ(expected_zoom, zoom); | 202 ASSERT_EQ(expected_zoom, zoom); |
203 } | 203 } |
204 } | 204 } |
205 | 205 |
| 206 void ValidateZoomScope(bool expected_scope, size_t expected_total_calls) { |
| 207 EXPECT_EQ(expected_total_calls, web_ui()->call_data().size()); |
| 208 |
| 209 const content::TestWebUI::CallData& data = *web_ui()->call_data().back(); |
| 210 EXPECT_EQ("cr.webUIListenerCallback", data.function_name()); |
| 211 |
| 212 std::string callback_id; |
| 213 ASSERT_TRUE(data.arg1()->GetAsString(&callback_id)); |
| 214 EXPECT_EQ("onZoomScopeChanged", callback_id); |
| 215 |
| 216 bool is_per_origin; |
| 217 ASSERT_TRUE(data.arg2()->GetAsBoolean(&is_per_origin)); |
| 218 EXPECT_EQ(expected_scope, is_per_origin); |
| 219 } |
| 220 |
206 void CreateIncognitoProfile() { | 221 void CreateIncognitoProfile() { |
207 incognito_profile_ = TestingProfile::Builder().BuildIncognito(&profile_); | 222 incognito_profile_ = TestingProfile::Builder().BuildIncognito(&profile_); |
208 } | 223 } |
209 | 224 |
210 void DestroyIncognitoProfile() { | 225 void DestroyIncognitoProfile() { |
211 content::NotificationService::current()->Notify( | 226 content::NotificationService::current()->Notify( |
212 chrome::NOTIFICATION_PROFILE_DESTROYED, | 227 chrome::NOTIFICATION_PROFILE_DESTROYED, |
213 content::Source<Profile>(static_cast<Profile*>(incognito_profile_)), | 228 content::Source<Profile>(static_cast<Profile*>(incognito_profile_)), |
214 content::NotificationService::NoDetails()); | 229 content::NotificationService::NoDetails()); |
215 profile_.SetOffTheRecordProfile(nullptr); | 230 profile_.SetOffTheRecordProfile(nullptr); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 | 397 |
383 args.AppendString("http://www.google.com"); | 398 args.AppendString("http://www.google.com"); |
384 handler()->HandleRemoveZoomLevel(&args); | 399 handler()->HandleRemoveZoomLevel(&args); |
385 ValidateZoom("", "", 3U); | 400 ValidateZoom("", "", 3U); |
386 | 401 |
387 double default_level = host_zoom_map->GetDefaultZoomLevel(); | 402 double default_level = host_zoom_map->GetDefaultZoomLevel(); |
388 double level = host_zoom_map->GetZoomLevelForHostAndScheme("http", host); | 403 double level = host_zoom_map->GetZoomLevelForHostAndScheme("http", host); |
389 EXPECT_EQ(default_level, level); | 404 EXPECT_EQ(default_level, level); |
390 } | 405 } |
391 | 406 |
| 407 TEST_F(SiteSettingsHandlerTest, ZoomScope) { |
| 408 ChromeZoomLevelPrefs* zoom_level_prefs = profile()->GetZoomLevelPrefs(); |
| 409 ASSERT_TRUE(zoom_level_prefs); |
| 410 EXPECT_TRUE(zoom_level_prefs->GetZoomScopeIsPerOriginPref()); |
| 411 |
| 412 zoom_level_prefs->SetZoomScopeIsPerOriginPref(false); |
| 413 ValidateZoomScope(false, 1U); |
| 414 |
| 415 base::ListValue args; |
| 416 handler()->HandleFetchZoomScope(&args); |
| 417 ValidateZoomScope(false, 2U); |
| 418 |
| 419 args.AppendBoolean(true); |
| 420 handler()->HandleSetZoomScopeIsPerOrigin(&args); |
| 421 ValidateZoomScope(true, 3U); |
| 422 EXPECT_TRUE(zoom_level_prefs->GetZoomScopeIsPerOriginPref()); |
| 423 } |
| 424 |
392 } // namespace settings | 425 } // namespace settings |
OLD | NEW |