OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/common/common_param_traits.h" | 10 #include "chrome/common/common_param_traits.h" |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 // Tests printing::Emf serialization. | 235 // Tests printing::Emf serialization. |
236 // TODO(sanjeevr): Make this test meaningful for non-Windows platforms. We | 236 // TODO(sanjeevr): Make this test meaningful for non-Windows platforms. We |
237 // need to initialize the metafile using alternate means on the other OSes. | 237 // need to initialize the metafile using alternate means on the other OSes. |
238 #if defined(OS_WIN) | 238 #if defined(OS_WIN) |
239 TEST(IPCMessageTest, Metafile) { | 239 TEST(IPCMessageTest, Metafile) { |
240 scoped_ptr<printing::NativeMetafile> metafile( | 240 scoped_ptr<printing::NativeMetafile> metafile( |
241 printing::NativeMetafileFactory::CreateMetafile()); | 241 printing::NativeMetafileFactory::CreateMetafile()); |
242 RECT test_rect = {0, 0, 100, 100}; | 242 RECT test_rect = {0, 0, 100, 100}; |
243 // Create a metafile using the screen DC as a reference. | 243 // Create a metafile using the screen DC as a reference. |
244 metafile->CreateDc(NULL, NULL); | 244 metafile->CreateDc(NULL, NULL); |
245 metafile->CloseDc(); | 245 metafile->Close(); |
246 | 246 |
247 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); | 247 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); |
248 IPC::ParamTraits<printing::NativeMetafile>::Write(&msg, *metafile); | 248 IPC::ParamTraits<printing::NativeMetafile>::Write(&msg, *metafile); |
249 | 249 |
250 scoped_ptr<printing::NativeMetafile> output( | 250 scoped_ptr<printing::NativeMetafile> output( |
251 printing::NativeMetafileFactory::CreateMetafile()); | 251 printing::NativeMetafileFactory::CreateMetafile()); |
252 void* iter = NULL; | 252 void* iter = NULL; |
253 EXPECT_TRUE(IPC::ParamTraits<printing::NativeMetafile>::Read( | 253 EXPECT_TRUE(IPC::ParamTraits<printing::NativeMetafile>::Read( |
254 &msg, &iter, output.get())); | 254 &msg, &iter, output.get())); |
255 | 255 |
256 EXPECT_EQ(metafile->GetDataSize(), output->GetDataSize()); | 256 EXPECT_EQ(metafile->GetDataSize(), output->GetDataSize()); |
257 EXPECT_EQ(metafile->GetBounds(), output->GetBounds()); | 257 EXPECT_EQ(metafile->GetPageBounds(1), output->GetPageBounds(1)); |
258 EXPECT_EQ(::GetDeviceCaps(metafile->hdc(), LOGPIXELSX), | 258 EXPECT_EQ(::GetDeviceCaps(metafile->context(), LOGPIXELSX), |
259 ::GetDeviceCaps(output->hdc(), LOGPIXELSX)); | 259 ::GetDeviceCaps(output->context(), LOGPIXELSX)); |
260 | 260 |
261 // Also test the corrupt case. | 261 // Also test the corrupt case. |
262 IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL); | 262 IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL); |
263 // Write some bogus metafile data. | 263 // Write some bogus metafile data. |
264 const size_t bogus_data_size = metafile->GetDataSize() * 2; | 264 const size_t bogus_data_size = metafile->GetDataSize() * 2; |
265 scoped_array<char> bogus_data(new char[bogus_data_size]); | 265 scoped_array<char> bogus_data(new char[bogus_data_size]); |
266 memset(bogus_data.get(), 'B', bogus_data_size); | 266 memset(bogus_data.get(), 'B', bogus_data_size); |
267 bad_msg.WriteData(bogus_data.get(), bogus_data_size); | 267 bad_msg.WriteData(bogus_data.get(), bogus_data_size); |
268 // Make sure we don't read out the metafile! | 268 // Make sure we don't read out the metafile! |
269 scoped_ptr<printing::NativeMetafile> bad_output( | 269 scoped_ptr<printing::NativeMetafile> bad_output( |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 | 301 |
302 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); | 302 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); |
303 IPC::ParamTraits<net::HostPortPair>::Write(&msg, input); | 303 IPC::ParamTraits<net::HostPortPair>::Write(&msg, input); |
304 | 304 |
305 net::HostPortPair output; | 305 net::HostPortPair output; |
306 void* iter = NULL; | 306 void* iter = NULL; |
307 EXPECT_TRUE(IPC::ParamTraits<net::HostPortPair>::Read(&msg, &iter, &output)); | 307 EXPECT_TRUE(IPC::ParamTraits<net::HostPortPair>::Read(&msg, &iter, &output)); |
308 EXPECT_EQ(input.host(), output.host()); | 308 EXPECT_EQ(input.host(), output.host()); |
309 EXPECT_EQ(input.port(), output.port()); | 309 EXPECT_EQ(input.port(), output.port()); |
310 } | 310 } |
OLD | NEW |