From dc0f95d653279beabeb9817299e2902918ba123e Mon Sep 17 00:00:00 2001 From: Kristian Monsen Date: Thu, 9 Jun 2011 11:47:42 +0100 Subject: Merge Chromium at r11.0.696.0: Initial merge by git Change-Id: I273dde2843af0839dfc08b419bb443fbd449532d --- chrome/common/common_param_traits_unittest.cc | 54 +++++++++++++++++++-------- 1 file changed, 38 insertions(+), 16 deletions(-) (limited to 'chrome/common/common_param_traits_unittest.cc') diff --git a/chrome/common/common_param_traits_unittest.cc b/chrome/common/common_param_traits_unittest.cc index a11ddd1..186e68e 100644 --- a/chrome/common/common_param_traits_unittest.cc +++ b/chrome/common/common_param_traits_unittest.cc @@ -9,16 +9,22 @@ #include "base/values.h" #include "chrome/common/common_param_traits.h" #include "chrome/common/geoposition.h" +#include "content/common/common_param_traits.h" #include "googleurl/src/gurl.h" #include "ipc/ipc_message.h" #include "ipc/ipc_message_utils.h" +#include "net/base/host_port_pair.h" #include "printing/backend/print_backend.h" -#include "printing/native_metafile.h" #include "printing/page_range.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/rect.h" +#if defined(OS_WIN) +#include "printing/native_metafile_factory.h" +#include "printing/native_metafile.h" +#endif + // Tests that serialize/deserialize correctly understand each other TEST(IPCMessageTest, Serialize) { const char* serialize_cases[] = { @@ -226,42 +232,45 @@ TEST(IPCMessageTest, PageRange) { EXPECT_TRUE(input == output); } -// Tests printing::NativeMetafile serialization. +// Tests printing::Emf serialization. // TODO(sanjeevr): Make this test meaningful for non-Windows platforms. We // need to initialize the metafile using alternate means on the other OSes. #if defined(OS_WIN) TEST(IPCMessageTest, Metafile) { - printing::NativeMetafile metafile; + scoped_ptr metafile( + printing::NativeMetafileFactory::CreateMetafile()); RECT test_rect = {0, 0, 100, 100}; - // Create a metsfile using the screen DC as a reference. - metafile.CreateDc(NULL, NULL); - metafile.CloseDc(); + // Create a metafile using the screen DC as a reference. + metafile->CreateDc(NULL, NULL); + metafile->CloseDc(); IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); - IPC::ParamTraits::Write(&msg, metafile); + IPC::ParamTraits::Write(&msg, *metafile); - printing::NativeMetafile output; + scoped_ptr output( + printing::NativeMetafileFactory::CreateMetafile()); void* iter = NULL; EXPECT_TRUE(IPC::ParamTraits::Read( - &msg, &iter, &output)); + &msg, &iter, output.get())); - EXPECT_EQ(metafile.GetDataSize(), output.GetDataSize()); - EXPECT_EQ(metafile.GetBounds(), output.GetBounds()); - EXPECT_EQ(::GetDeviceCaps(metafile.hdc(), LOGPIXELSX), - ::GetDeviceCaps(output.hdc(), LOGPIXELSX)); + EXPECT_EQ(metafile->GetDataSize(), output->GetDataSize()); + EXPECT_EQ(metafile->GetBounds(), output->GetBounds()); + EXPECT_EQ(::GetDeviceCaps(metafile->hdc(), LOGPIXELSX), + ::GetDeviceCaps(output->hdc(), LOGPIXELSX)); // Also test the corrupt case. IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL); // Write some bogus metafile data. - const size_t bogus_data_size = metafile.GetDataSize() * 2; + const size_t bogus_data_size = metafile->GetDataSize() * 2; scoped_array bogus_data(new char[bogus_data_size]); memset(bogus_data.get(), 'B', bogus_data_size); bad_msg.WriteData(bogus_data.get(), bogus_data_size); // Make sure we don't read out the metafile! - printing::NativeMetafile bad_output; + scoped_ptr bad_output( + printing::NativeMetafileFactory::CreateMetafile()); iter = NULL; EXPECT_FALSE(IPC::ParamTraits::Read( - &bad_msg, &iter, &bad_output)); + &bad_msg, &iter, bad_output.get())); } #endif // defined(OS_WIN) @@ -286,3 +295,16 @@ TEST(IPCMessageTest, PrinterCapsAndDefaults) { EXPECT_TRUE(input.defaults_mime_type == output.defaults_mime_type); } +// Tests net::HostPortPair serialization +TEST(IPCMessageTest, HostPortPair) { + net::HostPortPair input("host.com", 12345); + + IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); + IPC::ParamTraits::Write(&msg, input); + + net::HostPortPair output; + void* iter = NULL; + EXPECT_TRUE(IPC::ParamTraits::Read(&msg, &iter, &output)); + EXPECT_EQ(input.host(), output.host()); + EXPECT_EQ(input.port(), output.port()); +} -- cgit v1.1