OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef BLIMP_NET_TEST_COMMON_H_ | 5 #ifndef BLIMP_NET_TEST_COMMON_H_ |
6 #define BLIMP_NET_TEST_COMMON_H_ | 6 #define BLIMP_NET_TEST_COMMON_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 MATCHER_P(BufferEqualsProto, message, "") { | 53 MATCHER_P(BufferEqualsProto, message, "") { |
54 BlimpMessage actual_message; | 54 BlimpMessage actual_message; |
55 actual_message.ParseFromArray(arg->data(), message.ByteSize()); | 55 actual_message.ParseFromArray(arg->data(), message.ByteSize()); |
56 std::string expected_serialized; | 56 std::string expected_serialized; |
57 std::string actual_serialized; | 57 std::string actual_serialized; |
58 message.SerializeToString(&expected_serialized); | 58 message.SerializeToString(&expected_serialized); |
59 actual_message.SerializeToString(&actual_serialized); | 59 actual_message.SerializeToString(&actual_serialized); |
60 return expected_serialized == actual_serialized; | 60 return expected_serialized == actual_serialized; |
61 } | 61 } |
62 | 62 |
| 63 // Checks if the contents of a BlobDataPtr match the string |expected|. |
| 64 MATCHER_P(BlobDataPtrEqualsString, expected, "") { |
| 65 return expected == arg->data; |
| 66 } |
| 67 |
63 // GMock action that writes data from a string to an IOBuffer. | 68 // GMock action that writes data from a string to an IOBuffer. |
64 // | 69 // |
65 // buf_idx (template parameter 0): 0-based index of the IOBuffer arg. | 70 // buf_idx (template parameter 0): 0-based index of the IOBuffer arg. |
66 // str: the string containing data to be written to the IOBuffer. | 71 // str: the string containing data to be written to the IOBuffer. |
67 ACTION_TEMPLATE(FillBufferFromString, | 72 ACTION_TEMPLATE(FillBufferFromString, |
68 HAS_1_TEMPLATE_PARAMS(int, buf_idx), | 73 HAS_1_TEMPLATE_PARAMS(int, buf_idx), |
69 AND_1_VALUE_PARAMS(str)) { | 74 AND_1_VALUE_PARAMS(str)) { |
70 memcpy(testing::get<buf_idx>(args)->data(), str.data(), str.size()); | 75 memcpy(testing::get<buf_idx>(args)->data(), str.data(), str.size()); |
71 } | 76 } |
72 | 77 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 const net::CompletionCallback& callback) override; | 212 const net::CompletionCallback& callback) override; |
208 | 213 |
209 MOCK_METHOD2(MockableProcessMessage, | 214 MOCK_METHOD2(MockableProcessMessage, |
210 void(const BlimpMessage& message, | 215 void(const BlimpMessage& message, |
211 const net::CompletionCallback& callback)); | 216 const net::CompletionCallback& callback)); |
212 }; | 217 }; |
213 | 218 |
214 } // namespace blimp | 219 } // namespace blimp |
215 | 220 |
216 #endif // BLIMP_NET_TEST_COMMON_H_ | 221 #endif // BLIMP_NET_TEST_COMMON_H_ |
OLD | NEW |