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

Side by Side Diff: ipc/ipc_message_utils_unittest.cc

Issue 2036003002: Remove ListValue::Append(new {Fundamental,String}Value(...)) pattern in //ipc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 | « no previous file | no next file » | 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 "ipc/ipc_message_utils.h" 5 #include "ipc/ipc_message_utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <memory> 9 #include <memory>
10 10
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 value->SetWithoutPathExpansion("foo", new base::FundamentalValue(42)); 98 value->SetWithoutPathExpansion("foo", new base::FundamentalValue(42));
99 value->SetWithoutPathExpansion("bar", new base::FundamentalValue(3.14)); 99 value->SetWithoutPathExpansion("bar", new base::FundamentalValue(3.14));
100 value->SetWithoutPathExpansion("baz", new base::StringValue("hello")); 100 value->SetWithoutPathExpansion("baz", new base::StringValue("hello"));
101 value->SetWithoutPathExpansion("qux", base::Value::CreateNullValue()); 101 value->SetWithoutPathExpansion("qux", base::Value::CreateNullValue());
102 102
103 std::unique_ptr<base::DictionaryValue> nested_dict(new base::DictionaryValue); 103 std::unique_ptr<base::DictionaryValue> nested_dict(new base::DictionaryValue);
104 nested_dict->SetWithoutPathExpansion("foobar", new base::FundamentalValue(5)); 104 nested_dict->SetWithoutPathExpansion("foobar", new base::FundamentalValue(5));
105 value->SetWithoutPathExpansion("nested", std::move(nested_dict)); 105 value->SetWithoutPathExpansion("nested", std::move(nested_dict));
106 106
107 std::unique_ptr<base::ListValue> list_value(new base::ListValue); 107 std::unique_ptr<base::ListValue> list_value(new base::ListValue);
108 list_value->Append(new base::StringValue("im a string")); 108 list_value->AppendString("im a string");
109 list_value->Append(new base::StringValue("im another string")); 109 list_value->AppendString("im another string");
110 value->SetWithoutPathExpansion("awesome-list", std::move(list_value)); 110 value->SetWithoutPathExpansion("awesome-list", std::move(list_value));
111 111
112 base::Pickle pickle; 112 base::Pickle pickle;
113 IPC::WriteParam(&pickle, *value); 113 IPC::WriteParam(&pickle, *value);
114 114
115 base::PickleSizer sizer; 115 base::PickleSizer sizer;
116 IPC::GetParamSize(&sizer, *value); 116 IPC::GetParamSize(&sizer, *value);
117 117
118 EXPECT_EQ(sizer.payload_size(), pickle.payload_size()); 118 EXPECT_EQ(sizer.payload_size(), pickle.payload_size());
119 } 119 }
120 120
121 TEST(IPCMessageUtilsTest, JsonValueSize) { 121 TEST(IPCMessageUtilsTest, JsonValueSize) {
122 const char kJson[] = "[ { \"foo\": \"bar\", \"baz\": 1234.0 } ]"; 122 const char kJson[] = "[ { \"foo\": \"bar\", \"baz\": 1234.0 } ]";
123 std::unique_ptr<base::Value> json_value = base::JSONReader::Read(kJson); 123 std::unique_ptr<base::Value> json_value = base::JSONReader::Read(kJson);
124 EXPECT_NE(nullptr, json_value); 124 EXPECT_NE(nullptr, json_value);
125 base::ListValue value; 125 base::ListValue value;
126 value.Append(std::move(json_value)); 126 value.Append(std::move(json_value));
127 127
128 base::Pickle pickle; 128 base::Pickle pickle;
129 IPC::WriteParam(&pickle, value); 129 IPC::WriteParam(&pickle, value);
130 130
131 base::PickleSizer sizer; 131 base::PickleSizer sizer;
132 IPC::GetParamSize(&sizer, value); 132 IPC::GetParamSize(&sizer, value);
133 133
134 EXPECT_EQ(sizer.payload_size(), pickle.payload_size()); 134 EXPECT_EQ(sizer.payload_size(), pickle.payload_size());
135 } 135 }
136 136
137 } // namespace 137 } // namespace
138 } // namespace IPC 138 } // namespace IPC
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698