OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/file_path.h" | 5 #include "base/file_path.h" |
6 #include "ipc/ipc_message.h" | 6 #include "ipc/ipc_message.h" |
7 #include "ipc/ipc_message_utils.h" | 7 #include "ipc/ipc_message_utils.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 using namespace IPC; | 10 using namespace IPC; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 | 48 |
49 // Try reading past the ends for both messages and make sure it fails. | 49 // Try reading past the ends for both messages and make sure it fails. |
50 IPC::Message dummy; | 50 IPC::Message dummy; |
51 ASSERT_FALSE(ParamTraits<Message>::Read(&outer_msg, &iter, &dummy)); | 51 ASSERT_FALSE(ParamTraits<Message>::Read(&outer_msg, &iter, &dummy)); |
52 ASSERT_FALSE(ParamTraits<int>::Read(&nested_msg, &nested_iter, | 52 ASSERT_FALSE(ParamTraits<int>::Read(&nested_msg, &nested_iter, |
53 &result_content)); | 53 &result_content)); |
54 } | 54 } |
55 | 55 |
56 // Tests that detection of various bad parameters is working correctly. | 56 // Tests that detection of various bad parameters is working correctly. |
57 TEST(IPCMessageUtilsTest, ParameterValidation) { | 57 TEST(IPCMessageUtilsTest, ParameterValidation) { |
58 IPC::Message message; | |
59 FilePath::StringType okString(FILE_PATH_LITERAL("hello"), 5); | 58 FilePath::StringType okString(FILE_PATH_LITERAL("hello"), 5); |
60 FilePath::StringType badString(FILE_PATH_LITERAL("hel\0o"), 5); | 59 FilePath::StringType badString(FILE_PATH_LITERAL("hel\0o"), 5); |
61 FilePath okPath(okString); | 60 |
62 FilePath badPath(badString); | 61 // Change this if ParamTraits<FilePath>::Write() changes. |
63 ParamTraits<FilePath>::Write(&message, okPath); | 62 IPC::Message message; |
64 ParamTraits<FilePath>::Write(&message, badPath); | 63 ParamTraits<FilePath::StringType>::Write(&message, okString); |
64 ParamTraits<FilePath::StringType>::Write(&message, badString); | |
65 | 65 |
66 PickleIterator iter(message); | 66 PickleIterator iter(message); |
67 FilePath okPath; | |
brettw
2013/01/25 22:06:03
Style nit: no camelCase, use lowercase_with_unders
| |
68 FilePath badPath; | |
67 ASSERT_TRUE(ParamTraits<FilePath>::Read(&message, &iter, &okPath)); | 69 ASSERT_TRUE(ParamTraits<FilePath>::Read(&message, &iter, &okPath)); |
68 ASSERT_FALSE(ParamTraits<FilePath>::Read(&message, &iter, &badPath)); | 70 ASSERT_FALSE(ParamTraits<FilePath>::Read(&message, &iter, &badPath)); |
69 } | 71 } |
70 | 72 |
71 } // namespace | 73 } // namespace |
OLD | NEW |