OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stdlib.h> | 5 #include <stdlib.h> |
6 #include <string.h> | 6 #include <string.h> |
7 | 7 |
8 #include "mojo/public/bindings/lib/bindings_support.h" | 8 #include "mojo/public/bindings/lib/bindings_support.h" |
9 #include "mojo/public/bindings/lib/connector.h" | 9 #include "mojo/public/bindings/lib/connector.h" |
10 #include "mojo/public/bindings/lib/message_queue.h" | 10 #include "mojo/public/bindings/lib/message_queue.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 virtual void TearDown() OVERRIDE { | 50 virtual void TearDown() OVERRIDE { |
51 Close(handle0_); | 51 Close(handle0_); |
52 Close(handle1_); | 52 Close(handle1_); |
53 } | 53 } |
54 | 54 |
55 void AllocMessage(const char* text, Message* message) { | 55 void AllocMessage(const char* text, Message* message) { |
56 size_t payload_size = strlen(text) + 1; // Plus null terminator. | 56 size_t payload_size = strlen(text) + 1; // Plus null terminator. |
57 size_t num_bytes = sizeof(MessageHeader) + payload_size; | 57 size_t num_bytes = sizeof(MessageHeader) + payload_size; |
58 message->data = static_cast<MessageData*>(malloc(num_bytes)); | 58 message->data = static_cast<MessageData*>(malloc(num_bytes)); |
59 message->data->header.num_bytes = num_bytes; | 59 message->data->header.num_bytes = static_cast<uint32_t>(num_bytes); |
60 message->data->header.name = 1; | 60 message->data->header.name = 1; |
61 memcpy(message->data->payload, text, payload_size); | 61 memcpy(message->data->payload, text, payload_size); |
62 } | 62 } |
63 | 63 |
64 void PumpMessages() { | 64 void PumpMessages() { |
65 bindings_support_.Process(); | 65 bindings_support_.Process(); |
66 } | 66 } |
67 | 67 |
68 protected: | 68 protected: |
69 Handle handle0_; | 69 Handle handle0_; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 Close(handle0_); // Close the handle before writing to it. | 166 Close(handle0_); // Close the handle before writing to it. |
167 | 167 |
168 bool ok = connector0.Accept(&message); | 168 bool ok = connector0.Accept(&message); |
169 EXPECT_FALSE(ok); | 169 EXPECT_FALSE(ok); |
170 | 170 |
171 EXPECT_TRUE(connector0.EncounteredError()); | 171 EXPECT_TRUE(connector0.EncounteredError()); |
172 } | 172 } |
173 | 173 |
174 } // namespace test | 174 } // namespace test |
175 } // namespace mojo | 175 } // namespace mojo |
OLD | NEW |