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

Side by Side Diff: ipc/ipc_channel_reader_unittest.cc

Issue 1546533002: Switch to standard integer types in ipc/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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_channel_reader.cc ('k') | ipc/ipc_channel_unittest.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include <stddef.h>
8 #include <stdint.h>
9
7 #include <limits> 10 #include <limits>
8 #include <set> 11 #include <set>
9 12
10 #include "base/run_loop.h" 13 #include "base/run_loop.h"
11 #include "ipc/attachment_broker.h" 14 #include "ipc/attachment_broker.h"
12 #include "ipc/brokerable_attachment.h" 15 #include "ipc/brokerable_attachment.h"
13 #include "ipc/ipc_channel_reader.h" 16 #include "ipc/ipc_channel_reader.h"
14 #include "ipc/placeholder_brokerable_attachment.h" 17 #include "ipc/placeholder_brokerable_attachment.h"
15 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
16 19
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 EXPECT_FALSE(reader.TranslateInputData( 212 EXPECT_FALSE(reader.TranslateInputData(
210 reinterpret_cast<const char*>(&header), sizeof(header))); 213 reinterpret_cast<const char*>(&header), sizeof(header)));
211 EXPECT_LE(reader.input_overflow_buf_.capacity(), capacity_before); 214 EXPECT_LE(reader.input_overflow_buf_.capacity(), capacity_before);
212 215
213 // Payload size is negative, overflow is detected by Pickle::PeekNext() 216 // Payload size is negative, overflow is detected by Pickle::PeekNext()
214 header.payload_size = static_cast<uint32_t>(-1); 217 header.payload_size = static_cast<uint32_t>(-1);
215 EXPECT_FALSE(reader.TranslateInputData( 218 EXPECT_FALSE(reader.TranslateInputData(
216 reinterpret_cast<const char*>(&header), sizeof(header))); 219 reinterpret_cast<const char*>(&header), sizeof(header)));
217 EXPECT_LE(reader.input_overflow_buf_.capacity(), capacity_before); 220 EXPECT_LE(reader.input_overflow_buf_.capacity(), capacity_before);
218 221
219 // Payload size is maximum int32 value 222 // Payload size is maximum int32_t value
220 header.payload_size = std::numeric_limits<int32_t>::max(); 223 header.payload_size = std::numeric_limits<int32_t>::max();
221 EXPECT_FALSE(reader.TranslateInputData( 224 EXPECT_FALSE(reader.TranslateInputData(
222 reinterpret_cast<const char*>(&header), sizeof(header))); 225 reinterpret_cast<const char*>(&header), sizeof(header)));
223 EXPECT_LE(reader.input_overflow_buf_.capacity(), capacity_before); 226 EXPECT_LE(reader.input_overflow_buf_.capacity(), capacity_before);
224 } 227 }
225 228
226 #endif // !USE_ATTACHMENT_BROKER 229 #endif // !USE_ATTACHMENT_BROKER
227 230
228 TEST(ChannelReaderTest, TrimBuffer) { 231 TEST(ChannelReaderTest, TrimBuffer) {
229 // ChannelReader uses std::string as a buffer, and calls reserve() 232 // ChannelReader uses std::string as a buffer, and calls reserve()
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 EXPECT_GE(reader.input_overflow_buf_.capacity(), message2.size()); 373 EXPECT_GE(reader.input_overflow_buf_.capacity(), message2.size());
371 #else 374 #else
372 // We couldn't determine size for the second (partial) message, and 375 // We couldn't determine size for the second (partial) message, and
373 // first message was small, so we did nothing. 376 // first message was small, so we did nothing.
374 #endif 377 #endif
375 } 378 }
376 } 379 }
377 380
378 } // namespace internal 381 } // namespace internal
379 } // namespace IPC 382 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/ipc_channel_reader.cc ('k') | ipc/ipc_channel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698