OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "platform/assert.h" | 5 #include "platform/assert.h" |
6 #include "vm/message_handler.h" | 6 #include "vm/message_handler.h" |
7 #include "vm/os.h" | 7 #include "vm/os.h" |
8 #include "vm/port.h" | 8 #include "vm/port.h" |
9 #include "vm/unit_test.h" | 9 #include "vm/unit_test.h" |
10 | 10 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 EXPECT(PortMap::PostMessage(new Message( | 127 EXPECT(PortMap::PostMessage(new Message( |
128 port, reinterpret_cast<uint8_t*>(strdup(message)), message_len, | 128 port, reinterpret_cast<uint8_t*>(strdup(message)), message_len, |
129 Message::kNormalPriority))); | 129 Message::kNormalPriority))); |
130 | 130 |
131 // Check that the message notify callback was called. | 131 // Check that the message notify callback was called. |
132 EXPECT_EQ(1, handler.notify_count); | 132 EXPECT_EQ(1, handler.notify_count); |
133 PortMap::ClosePorts(&handler); | 133 PortMap::ClosePorts(&handler); |
134 } | 134 } |
135 | 135 |
136 | 136 |
137 TEST_CASE(PortMap_PostMessageInvalidPort) { | 137 TEST_CASE(PortMap_PostMessageClosedPort) { |
| 138 // Create a port id and make it invalid. |
| 139 PortTestMessageHandler handler; |
| 140 Dart_Port port = PortMap::CreatePort(&handler); |
| 141 PortMap::ClosePort(port); |
| 142 |
138 const char* message = "msg"; | 143 const char* message = "msg"; |
139 intptr_t message_len = strlen(message) + 1; | 144 intptr_t message_len = strlen(message) + 1; |
140 | 145 |
141 EXPECT(!PortMap::PostMessage(new Message( | 146 EXPECT(!PortMap::PostMessage(new Message( |
142 0, reinterpret_cast<uint8_t*>(strdup(message)), message_len, | 147 port, reinterpret_cast<uint8_t*>(strdup(message)), message_len, |
143 Message::kNormalPriority))); | 148 Message::kNormalPriority))); |
144 } | 149 } |
145 | 150 |
146 } // namespace dart | 151 } // namespace dart |
OLD | NEW |