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

Side by Side Diff: dbus/values_util_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
« no previous file with comments | « dbus/values_util.cc ('k') | extensions/browser/api/cast_channel/cast_channel_api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "dbus/values_util.h" 5 #include "dbus/values_util.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 sub_writer.OpenDictEntry(&entry_writer); 370 sub_writer.OpenDictEntry(&entry_writer);
371 entry_writer.AppendDouble(keys[i]); 371 entry_writer.AppendDouble(keys[i]);
372 entry_writer.AppendInt32(values[i]); 372 entry_writer.AppendInt32(values[i]);
373 sub_writer.CloseContainer(&entry_writer); 373 sub_writer.CloseContainer(&entry_writer);
374 } 374 }
375 writer.CloseContainer(&sub_writer); 375 writer.CloseContainer(&sub_writer);
376 376
377 // Create the expected value. 377 // Create the expected value.
378 base::DictionaryValue dictionary_value; 378 base::DictionaryValue dictionary_value;
379 for (size_t i = 0; i != values.size(); ++i) { 379 for (size_t i = 0; i != values.size(); ++i) {
380 scoped_ptr<base::Value> key_value(new base::FundamentalValue(keys[i]));
381 std::string key_string; 380 std::string key_string;
382 base::JSONWriter::Write(key_value.get(), &key_string); 381 base::JSONWriter::Write(base::FundamentalValue(keys[i]), &key_string);
383 dictionary_value.SetWithoutPathExpansion( 382 dictionary_value.SetIntegerWithoutPathExpansion(key_string, values[i]);
384 key_string, new base::FundamentalValue(values[i]));
385 } 383 }
386 384
387 // Pop a dictionary. 385 // Pop a dictionary.
388 MessageReader reader(response.get()); 386 MessageReader reader(response.get());
389 scoped_ptr<base::Value> value(PopDataAsValue(&reader)); 387 scoped_ptr<base::Value> value(PopDataAsValue(&reader));
390 ASSERT_TRUE(value.get() != NULL); 388 ASSERT_TRUE(value.get() != NULL);
391 EXPECT_TRUE(value->Equals(&dictionary_value)); 389 EXPECT_TRUE(value->Equals(&dictionary_value));
392 } 390 }
393 391
394 TEST(ValuesUtilTest, AppendBasicTypes) { 392 TEST(ValuesUtilTest, AppendBasicTypes) {
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 scoped_ptr<base::Value> value; 679 scoped_ptr<base::Value> value;
682 value.reset(PopDataAsValue(&reader)); 680 value.reset(PopDataAsValue(&reader));
683 ASSERT_TRUE(value.get() != NULL); 681 ASSERT_TRUE(value.get() != NULL);
684 EXPECT_TRUE(value->Equals(&test_list)); 682 EXPECT_TRUE(value->Equals(&test_list));
685 value.reset(PopDataAsValue(&reader)); 683 value.reset(PopDataAsValue(&reader));
686 ASSERT_TRUE(value.get() != NULL); 684 ASSERT_TRUE(value.get() != NULL);
687 EXPECT_TRUE(value->Equals(&int_value)); 685 EXPECT_TRUE(value->Equals(&int_value));
688 } 686 }
689 687
690 } // namespace dbus 688 } // namespace dbus
OLDNEW
« no previous file with comments | « dbus/values_util.cc ('k') | extensions/browser/api/cast_channel/cast_channel_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698