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

Side by Side Diff: chrome/browser/content_settings/host_content_settings_map_unittest.cc

Issue 1131113004: Convert JsonWriter::Write to taking a const ref for the in-param (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: another rebase Created 5 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/auto_reset.h" 5 #include "base/auto_reset.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 713
714 // Set punycode equivalent, with different setting. 714 // Set punycode equivalent, with different setting.
715 scoped_ptr<base::Value> puny_value(base::JSONReader::Read( 715 scoped_ptr<base::Value> puny_value(base::JSONReader::Read(
716 "{\"[*.]xn--ira-ppa.com,*\":{\"images\":2}}")); 716 "{\"[*.]xn--ira-ppa.com,*\":{\"images\":2}}"));
717 profile.GetPrefs()->Set( 717 profile.GetPrefs()->Set(
718 prefs::kContentSettingsPatternPairs, *puny_value); 718 prefs::kContentSettingsPatternPairs, *puny_value);
719 719
720 // Initialize the content map. 720 // Initialize the content map.
721 profile.GetHostContentSettingsMap(); 721 profile.GetHostContentSettingsMap();
722 722
723 const base::DictionaryValue* content_setting_prefs = 723 const base::DictionaryValue& content_setting_prefs =
724 profile.GetPrefs()->GetDictionary( 724 *profile.GetPrefs()->GetDictionary(
725 prefs::kContentSettingsImagesPatternPairs); 725 prefs::kContentSettingsImagesPatternPairs);
726 std::string prefs_as_json; 726 std::string prefs_as_json;
727 base::JSONWriter::Write(content_setting_prefs, &prefs_as_json); 727 base::JSONWriter::Write(content_setting_prefs, &prefs_as_json);
728 EXPECT_STREQ("{\"[*.]xn--ira-ppa.com,*\":{\"setting\":2}}", 728 EXPECT_STREQ("{\"[*.]xn--ira-ppa.com,*\":{\"setting\":2}}",
729 prefs_as_json.c_str()); 729 prefs_as_json.c_str());
730 } 730 }
731 731
732 // If a default-content-setting is managed, the managed value should be used 732 // If a default-content-setting is managed, the managed value should be used
733 // instead of the default value. 733 // instead of the default value.
734 TEST_F(HostContentSettingsMapTest, ManagedDefaultContentSetting) { 734 TEST_F(HostContentSettingsMapTest, ManagedDefaultContentSetting) {
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 CONTENT_SETTINGS_TYPE_IMAGES, true); 1082 CONTENT_SETTINGS_TYPE_IMAGES, true);
1083 EXPECT_EQ(CONTENT_SETTING_ALLOW, 1083 EXPECT_EQ(CONTENT_SETTING_ALLOW,
1084 host_content_settings_map->GetContentSetting( 1084 host_content_settings_map->GetContentSetting(
1085 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); 1085 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string()));
1086 host_content_settings_map->SetDefaultContentSetting( 1086 host_content_settings_map->SetDefaultContentSetting(
1087 CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_BLOCK); 1087 CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_BLOCK);
1088 EXPECT_EQ(CONTENT_SETTING_BLOCK, 1088 EXPECT_EQ(CONTENT_SETTING_BLOCK,
1089 host_content_settings_map->GetContentSetting( 1089 host_content_settings_map->GetContentSetting(
1090 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); 1090 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string()));
1091 } 1091 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698