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

Side by Side Diff: ipc/ipc_message_utils_unittest.cc

Issue 1866633002: Make IPC::ParamTraits<>GetSize work with base::Value as a result of JSON parsing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « ipc/ipc_message_utils.cc ('k') | 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 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/json/json_reader.h"
11 #include "ipc/ipc_message.h" 12 #include "ipc/ipc_message.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 14
14 namespace IPC { 15 namespace IPC {
15 namespace { 16 namespace {
16 17
17 // Tests nesting of messages as parameters to other messages. 18 // Tests nesting of messages as parameters to other messages.
18 TEST(IPCMessageUtilsTest, NestedMessages) { 19 TEST(IPCMessageUtilsTest, NestedMessages) {
19 int32_t nested_routing = 12; 20 int32_t nested_routing = 12;
20 uint32_t nested_type = 78; 21 uint32_t nested_type = 78;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 110
110 base::Pickle pickle; 111 base::Pickle pickle;
111 IPC::WriteParam(&pickle, *value); 112 IPC::WriteParam(&pickle, *value);
112 113
113 base::PickleSizer sizer; 114 base::PickleSizer sizer;
114 IPC::GetParamSize(&sizer, *value); 115 IPC::GetParamSize(&sizer, *value);
115 116
116 EXPECT_EQ(sizer.payload_size(), pickle.payload_size()); 117 EXPECT_EQ(sizer.payload_size(), pickle.payload_size());
117 } 118 }
118 119
120 TEST(IPCMessageUtilsTest, JsonValueSize) {
121 const char kJson[] = "[ { \"foo\": \"bar\", \"baz\": 1234.0 } ]";
122 std::unique_ptr<base::Value> json_value = base::JSONReader::Read(kJson);
123 EXPECT_NE(nullptr, json_value);
124 base::ListValue value;
125 value.Append(std::move(json_value));
126
127 base::Pickle pickle;
128 IPC::WriteParam(&pickle, value);
129
130 base::PickleSizer sizer;
131 IPC::GetParamSize(&sizer, value);
132
133 EXPECT_EQ(sizer.payload_size(), pickle.payload_size());
134 }
135
119 } // namespace 136 } // namespace
120 } // namespace IPC 137 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/ipc_message_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698