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

Side by Side Diff: chrome/common/json_value_serializer_unittest.cc

Issue 9590002: JSONWriter cleanup: integrate pretty print into write options. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix merge conflict 7. Created 8 years, 9 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 | Annotate | Revision Log
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/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/json/json_file_value_serializer.h" 7 #include "base/json/json_file_value_serializer.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/json/json_string_value_serializer.h" 9 #include "base/json/json_string_value_serializer.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 "\\u00E8\\u00E9\\u00EA\\u00EB\\u00EC\\u00ED\\u00EE\\u00EF\\u00F0\\u00F1" 103 "\\u00E8\\u00E9\\u00EA\\u00EB\\u00EC\\u00ED\\u00EE\\u00EF\\u00F0\\u00F1"
104 "\\u00F2\\u00F3\\u00F4\\u00F5\\u00F6\\u00F7\\u00F8\\u00F9\\u00FA\\u00FB" 104 "\\u00F2\\u00F3\\u00F4\\u00F5\\u00F6\\u00F7\\u00F8\\u00F9\\u00FA\\u00FB"
105 "\\u00FC\\u00FD\\u00FE\\u00FF"; 105 "\\u00FC\\u00FD\\u00FE\\u00FF";
106 106
107 std::string expected_output = "{\"all_chars\":\"" + all_chars_expected + 107 std::string expected_output = "{\"all_chars\":\"" + all_chars_expected +
108 "\"}"; 108 "\"}";
109 // Test JSONWriter interface 109 // Test JSONWriter interface
110 std::string output_js; 110 std::string output_js;
111 DictionaryValue valueRoot; 111 DictionaryValue valueRoot;
112 valueRoot.SetString("all_chars", all_chars); 112 valueRoot.SetString("all_chars", all_chars);
113 base::JSONWriter::Write(&valueRoot, false, &output_js); 113 base::JSONWriter::Write(&valueRoot, &output_js);
114 ASSERT_EQ(expected_output, output_js); 114 ASSERT_EQ(expected_output, output_js);
115 115
116 // Test JSONValueSerializer interface (uses JSONWriter). 116 // Test JSONValueSerializer interface (uses JSONWriter).
117 JSONStringValueSerializer serializer(&output_js); 117 JSONStringValueSerializer serializer(&output_js);
118 ASSERT_TRUE(serializer.Serialize(valueRoot)); 118 ASSERT_TRUE(serializer.Serialize(valueRoot));
119 ASSERT_EQ(expected_output, output_js); 119 ASSERT_EQ(expected_output, output_js);
120 } 120 }
121 121
122 TEST(JSONValueSerializerTest, UnicodeStrings) { 122 TEST(JSONValueSerializerTest, UnicodeStrings) {
123 // unicode string json -> escaped ascii text 123 // unicode string json -> escaped ascii text
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 FilePath source_file_path; 330 FilePath source_file_path;
331 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &source_file_path)); 331 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &source_file_path));
332 source_file_path = source_file_path.Append( 332 source_file_path = source_file_path.Append(
333 FILE_PATH_LITERAL("serializer_test_nowhitespace.js")); 333 FILE_PATH_LITERAL("serializer_test_nowhitespace.js"));
334 ASSERT_TRUE(file_util::PathExists(source_file_path)); 334 ASSERT_TRUE(file_util::PathExists(source_file_path));
335 JSONFileValueSerializer serializer(source_file_path); 335 JSONFileValueSerializer serializer(source_file_path);
336 scoped_ptr<Value> root; 336 scoped_ptr<Value> root;
337 root.reset(serializer.Deserialize(NULL, NULL)); 337 root.reset(serializer.Deserialize(NULL, NULL));
338 ASSERT_TRUE(root.get()); 338 ASSERT_TRUE(root.get());
339 } 339 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/workers_ui.cc ('k') | chrome/test/automation/automation_json_requests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698