summaryrefslogtreecommitdiffstats
path: root/chrome/common/common_param_traits_unittest.cc
diff options
context:
space:
mode:
authorKristian Monsen <kristianm@google.com>2011-06-09 11:47:42 +0100
committerKristian Monsen <kristianm@google.com>2011-06-29 14:33:03 +0100
commitdc0f95d653279beabeb9817299e2902918ba123e (patch)
tree32eb121cd532053a5b9cb0c390331349af8d6baa /chrome/common/common_param_traits_unittest.cc
parentba160cd4054d13d0cb0b1b46e61c3bed67095811 (diff)
downloadexternal_chromium-dc0f95d653279beabeb9817299e2902918ba123e.zip
external_chromium-dc0f95d653279beabeb9817299e2902918ba123e.tar.gz
external_chromium-dc0f95d653279beabeb9817299e2902918ba123e.tar.bz2
Merge Chromium at r11.0.696.0: Initial merge by git
Change-Id: I273dde2843af0839dfc08b419bb443fbd449532d
Diffstat (limited to 'chrome/common/common_param_traits_unittest.cc')
-rw-r--r--chrome/common/common_param_traits_unittest.cc54
1 files changed, 38 insertions, 16 deletions
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<printing::NativeMetafile> 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<printing::NativeMetafile>::Write(&msg, metafile);
+ IPC::ParamTraits<printing::NativeMetafile>::Write(&msg, *metafile);
- printing::NativeMetafile output;
+ scoped_ptr<printing::NativeMetafile> output(
+ printing::NativeMetafileFactory::CreateMetafile());
void* iter = NULL;
EXPECT_TRUE(IPC::ParamTraits<printing::NativeMetafile>::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<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!
- printing::NativeMetafile bad_output;
+ scoped_ptr<printing::NativeMetafile> bad_output(
+ printing::NativeMetafileFactory::CreateMetafile());
iter = NULL;
EXPECT_FALSE(IPC::ParamTraits<printing::NativeMetafile>::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<net::HostPortPair>::Write(&msg, input);
+
+ net::HostPortPair output;
+ void* iter = NULL;
+ EXPECT_TRUE(IPC::ParamTraits<net::HostPortPair>::Read(&msg, &iter, &output));
+ EXPECT_EQ(input.host(), output.host());
+ EXPECT_EQ(input.port(), output.port());
+}