diff options
Diffstat (limited to 'chrome/common/common_param_traits_unittest.cc')
-rw-r--r-- | chrome/common/common_param_traits_unittest.cc | 39 |
1 files changed, 16 insertions, 23 deletions
diff --git a/chrome/common/common_param_traits_unittest.cc b/chrome/common/common_param_traits_unittest.cc index 1dd62f6..9a95c0f0 100644 --- a/chrome/common/common_param_traits_unittest.cc +++ b/chrome/common/common_param_traits_unittest.cc @@ -14,16 +14,12 @@ #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[] = { @@ -231,45 +227,42 @@ TEST(IPCMessageTest, PageRange) { EXPECT_TRUE(input == output); } -// Tests printing::Emf serialization. +// Tests printing::NativeMetafile 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) { - scoped_ptr<printing::NativeMetafile> metafile( - printing::NativeMetafileFactory::CreateMetafile()); + printing::NativeMetafile metafile; RECT test_rect = {0, 0, 100, 100}; - // Create a metafile using the screen DC as a reference. - metafile->CreateDc(NULL, NULL); - metafile->CloseDc(); + // Create a metsfile using the screen DC as a reference. + metafile.CreateDc(NULL, NULL); + metafile.CloseDc(); IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); - IPC::ParamTraits<printing::NativeMetafile>::Write(&msg, *metafile); + IPC::ParamTraits<printing::NativeMetafile>::Write(&msg, metafile); - scoped_ptr<printing::NativeMetafile> output( - printing::NativeMetafileFactory::CreateMetafile()); + printing::NativeMetafile output; void* iter = NULL; EXPECT_TRUE(IPC::ParamTraits<printing::NativeMetafile>::Read( - &msg, &iter, output.get())); + &msg, &iter, &output)); - 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<char> 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! - scoped_ptr<printing::NativeMetafile> bad_output( - printing::NativeMetafileFactory::CreateMetafile()); + printing::NativeMetafile bad_output; iter = NULL; EXPECT_FALSE(IPC::ParamTraits<printing::NativeMetafile>::Read( - &bad_msg, &iter, bad_output.get())); + &bad_msg, &iter, &bad_output)); } #endif // defined(OS_WIN) |