| 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" |
| 11 #include "chrome/common/geoposition.h" | 11 #include "chrome/common/geoposition.h" |
| 12 #include "gfx/rect.h" | 12 #include "gfx/rect.h" |
| 13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
| 14 #include "ipc/ipc_message.h" | 14 #include "ipc/ipc_message.h" |
| 15 #include "ipc/ipc_message_utils.h" | 15 #include "ipc/ipc_message_utils.h" |
| 16 #include "printing/backend/print_backend.h" |
| 16 #include "printing/native_metafile.h" | 17 #include "printing/native_metafile.h" |
| 17 #include "printing/page_range.h" | 18 #include "printing/page_range.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "third_party/skia/include/core/SkBitmap.h" | 20 #include "third_party/skia/include/core/SkBitmap.h" |
| 20 | 21 |
| 21 // Tests that serialize/deserialize correctly understand each other | 22 // Tests that serialize/deserialize correctly understand each other |
| 22 TEST(IPCMessageTest, Serialize) { | 23 TEST(IPCMessageTest, Serialize) { |
| 23 const char* serialize_cases[] = { | 24 const char* serialize_cases[] = { |
| 24 "http://www.google.com/", | 25 "http://www.google.com/", |
| 25 "http://user:pass@host.com:888/foo;bar?baz#nop", | 26 "http://user:pass@host.com:888/foo;bar?baz#nop", |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 memset(bogus_data.get(), 'B', bogus_data_size); | 258 memset(bogus_data.get(), 'B', bogus_data_size); |
| 258 bad_msg.WriteData(bogus_data.get(), bogus_data_size); | 259 bad_msg.WriteData(bogus_data.get(), bogus_data_size); |
| 259 // Make sure we don't read out the metafile! | 260 // Make sure we don't read out the metafile! |
| 260 printing::NativeMetafile bad_output; | 261 printing::NativeMetafile bad_output; |
| 261 iter = NULL; | 262 iter = NULL; |
| 262 EXPECT_FALSE(IPC::ParamTraits<printing::NativeMetafile>::Read( | 263 EXPECT_FALSE(IPC::ParamTraits<printing::NativeMetafile>::Read( |
| 263 &bad_msg, &iter, &bad_output)); | 264 &bad_msg, &iter, &bad_output)); |
| 264 } | 265 } |
| 265 #endif // defined(OS_WIN) | 266 #endif // defined(OS_WIN) |
| 266 | 267 |
| 268 // Tests printing::PrinterCapsAndDefaults serialization |
| 269 TEST(IPCMessageTest, PrinterCapsAndDefaults) { |
| 270 printing::PrinterCapsAndDefaults input; |
| 271 input.printer_capabilities = "Test Capabilities"; |
| 272 input.caps_mime_type = "text/plain"; |
| 273 input.printer_defaults = "Test Defaults"; |
| 274 input.defaults_mime_type = "text/plain"; |
| 275 |
| 276 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); |
| 277 IPC::ParamTraits<printing::PrinterCapsAndDefaults>::Write(&msg, input); |
| 278 |
| 279 printing::PrinterCapsAndDefaults output; |
| 280 void* iter = NULL; |
| 281 EXPECT_TRUE(IPC::ParamTraits<printing::PrinterCapsAndDefaults>::Read( |
| 282 &msg, &iter, &output)); |
| 283 EXPECT_TRUE(input.printer_capabilities == output.printer_capabilities); |
| 284 EXPECT_TRUE(input.caps_mime_type == output.caps_mime_type); |
| 285 EXPECT_TRUE(input.printer_defaults == output.printer_defaults); |
| 286 EXPECT_TRUE(input.defaults_mime_type == output.defaults_mime_type); |
| 287 } |
| 288 |
| OLD | NEW |