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

Side by Side Diff: ipc/ipc_message_utils_unittest.cc

Issue 1655333002: Add message sizing to basic IPC traits and struct macros. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@with-pickles
Patch Set: include ArrayHeader in size (oops!) and ensure the buffer doesn't relocate Created 4 years, 10 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') | ipc/param_traits_macros.h » ('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 "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"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); 83 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
84 IPC::WriteParam(&msg, stack_vector); 84 IPC::WriteParam(&msg, stack_vector);
85 85
86 base::StackVector<double, stack_capacity> output; 86 base::StackVector<double, stack_capacity> output;
87 base::PickleIterator iter(msg); 87 base::PickleIterator iter(msg);
88 EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output)); 88 EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output));
89 for (size_t i = 0; i < 2 * stack_capacity; i++) 89 for (size_t i = 0; i < 2 * stack_capacity; i++)
90 EXPECT_EQ(stack_vector[i], output[i]); 90 EXPECT_EQ(stack_vector[i], output[i]);
91 } 91 }
92 92
93 // Tests that PickleSizer and Pickle agree on the size of a complex base::Value.
94 TEST(IPCMessageUtilsTest, ValueSize) {
95 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue);
96 value->SetWithoutPathExpansion("foo", new base::FundamentalValue(42));
97 value->SetWithoutPathExpansion("bar", new base::FundamentalValue(3.14));
98 value->SetWithoutPathExpansion("baz", new base::StringValue("hello"));
99 value->SetWithoutPathExpansion("qux", base::Value::CreateNullValue());
100
101 scoped_ptr<base::DictionaryValue> nested_dict(new base::DictionaryValue);
102 nested_dict->SetWithoutPathExpansion("foobar", new base::FundamentalValue(5));
103 value->SetWithoutPathExpansion("nested", std::move(nested_dict));
104
105 scoped_ptr<base::ListValue> list_value(new base::ListValue);
106 list_value->Append(new base::StringValue("im a string"));
107 list_value->Append(new base::StringValue("im another string"));
108 value->SetWithoutPathExpansion("awesome-list", std::move(list_value));
109
110 base::Pickle pickle;
111 IPC::WriteParam(&pickle, *value);
112
113 base::PickleSizer sizer;
114 IPC::GetParamSize(&sizer, *value);
115
116 EXPECT_EQ(sizer.payload_size(), pickle.payload_size());
117 }
118
93 } // namespace 119 } // namespace
94 } // namespace IPC 120 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/ipc_message_utils.cc ('k') | ipc/param_traits_macros.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698