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

Side by Side Diff: content/common/common_param_traits_unittest.cc

Issue 818833004: Remove deprecated methods from Pickle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 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
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 <string.h> 5 #include <string.h>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "content/public/common/common_param_traits.h" 10 #include "content/public/common/common_param_traits.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 EXPECT_EQ(bitmap.getSize(), output.getSize()); 102 EXPECT_EQ(bitmap.getSize(), output.getSize());
103 EXPECT_EQ(memcmp(bitmap.getPixels(), output.getPixels(), bitmap.getSize()), 103 EXPECT_EQ(memcmp(bitmap.getPixels(), output.getPixels(), bitmap.getSize()),
104 0); 104 0);
105 105
106 // Also test the corrupt case. 106 // Also test the corrupt case.
107 IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL); 107 IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL);
108 // Copy the first message block over to |bad_msg|. 108 // Copy the first message block over to |bad_msg|.
109 const char* fixed_data; 109 const char* fixed_data;
110 int fixed_data_size; 110 int fixed_data_size;
111 iter = PickleIterator(msg); 111 iter = PickleIterator(msg);
112 EXPECT_TRUE(msg.ReadData(&iter, &fixed_data, &fixed_data_size)); 112 EXPECT_TRUE(iter.ReadData(&fixed_data, &fixed_data_size));
113 bad_msg.WriteData(fixed_data, fixed_data_size); 113 bad_msg.WriteData(fixed_data, fixed_data_size);
114 // Add some bogus pixel data. 114 // Add some bogus pixel data.
115 const size_t bogus_pixels_size = bitmap.getSize() * 2; 115 const size_t bogus_pixels_size = bitmap.getSize() * 2;
116 scoped_ptr<char[]> bogus_pixels(new char[bogus_pixels_size]); 116 scoped_ptr<char[]> bogus_pixels(new char[bogus_pixels_size]);
117 memset(bogus_pixels.get(), 'B', bogus_pixels_size); 117 memset(bogus_pixels.get(), 'B', bogus_pixels_size);
118 bad_msg.WriteData(bogus_pixels.get(), bogus_pixels_size); 118 bad_msg.WriteData(bogus_pixels.get(), bogus_pixels_size);
119 // Make sure we don't read out the bitmap! 119 // Make sure we don't read out the bitmap!
120 SkBitmap bad_output; 120 SkBitmap bad_output;
121 iter = PickleIterator(bad_msg); 121 iter = PickleIterator(bad_msg);
122 EXPECT_FALSE(IPC::ParamTraits<SkBitmap>::Read(&bad_msg, &iter, &bad_output)); 122 EXPECT_FALSE(IPC::ParamTraits<SkBitmap>::Read(&bad_msg, &iter, &bad_output));
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 184
185 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); 185 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
186 IPC::ParamTraits<net::HostPortPair>::Write(&msg, input); 186 IPC::ParamTraits<net::HostPortPair>::Write(&msg, input);
187 187
188 net::HostPortPair output; 188 net::HostPortPair output;
189 PickleIterator iter(msg); 189 PickleIterator iter(msg);
190 EXPECT_TRUE(IPC::ParamTraits<net::HostPortPair>::Read(&msg, &iter, &output)); 190 EXPECT_TRUE(IPC::ParamTraits<net::HostPortPair>::Read(&msg, &iter, &output));
191 EXPECT_EQ(input.host(), output.host()); 191 EXPECT_EQ(input.host(), output.host());
192 EXPECT_EQ(input.port(), output.port()); 192 EXPECT_EQ(input.port(), output.port());
193 } 193 }
OLDNEW
« no previous file with comments | « content/common/child_process_sandbox_support_impl_linux.cc ('k') | content/common/content_param_traits.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698