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 "vm/message_handler.h" | 5 #include "vm/message_handler.h" |
6 #include "vm/port.h" | 6 #include "vm/port.h" |
7 #include "vm/unit_test.h" | 7 #include "vm/unit_test.h" |
8 | 8 |
9 namespace dart { | 9 namespace dart { |
10 | 10 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 UNIT_TEST_CASE(MessageHandler_HasOOBMessages) { | 151 UNIT_TEST_CASE(MessageHandler_HasOOBMessages) { |
152 TestMessageHandler handler; | 152 TestMessageHandler handler; |
153 MessageHandlerTestPeer handler_peer(&handler); | 153 MessageHandlerTestPeer handler_peer(&handler); |
154 | 154 |
155 EXPECT(!handler.HasOOBMessages()); | 155 EXPECT(!handler.HasOOBMessages()); |
156 | 156 |
157 // Post a normal message. | 157 // Post a normal message. |
158 Message* message = new Message(1, NULL, 0, Message::kNormalPriority); | 158 Message* message = new Message(1, NULL, 0, Message::kNormalPriority); |
159 handler_peer.PostMessage(message); | 159 handler_peer.PostMessage(message); |
160 EXPECT(!handler.HasOOBMessages()); | 160 EXPECT(!handler.HasOOBMessages()); |
| 161 { |
| 162 // Acquire ownership of message handler queues, verify one regular message. |
| 163 MessageHandler::AcquiredQueues aq; |
| 164 handler.AcquireQueues(&aq); |
| 165 EXPECT(aq.queue()->Length() == 1); |
| 166 } |
161 | 167 |
162 // Post an oob message. | 168 // Post an oob message. |
163 message = new Message(1, NULL, 0, Message::kOOBPriority); | 169 message = new Message(1, NULL, 0, Message::kOOBPriority); |
164 handler_peer.PostMessage(message); | 170 handler_peer.PostMessage(message); |
165 EXPECT(handler.HasOOBMessages()); | 171 EXPECT(handler.HasOOBMessages()); |
| 172 { |
| 173 // Acquire ownership of message handler queues, verify one regular and one |
| 174 // OOB message. |
| 175 MessageHandler::AcquiredQueues aq; |
| 176 handler.AcquireQueues(&aq); |
| 177 EXPECT(aq.queue()->Length() == 1); |
| 178 EXPECT(aq.oob_queue()->Length() == 1); |
| 179 } |
166 | 180 |
167 // Delete all pending messages. | 181 // Delete all pending messages. |
168 handler_peer.CloseAllPorts(); | 182 handler_peer.CloseAllPorts(); |
169 } | 183 } |
170 | 184 |
171 | 185 |
172 UNIT_TEST_CASE(MessageHandler_ClosePort) { | 186 UNIT_TEST_CASE(MessageHandler_ClosePort) { |
173 TestMessageHandler handler; | 187 TestMessageHandler handler; |
174 MessageHandlerTestPeer handler_peer(&handler); | 188 MessageHandlerTestPeer handler_peer(&handler); |
175 Message* message1 = new Message(1, NULL, 0, Message::kNormalPriority); | 189 Message* message1 = new Message(1, NULL, 0, Message::kNormalPriority); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 EXPECT_EQ(port, handler_ports[0]); | 337 EXPECT_EQ(port, handler_ports[0]); |
324 for (int i = 1; i < 11; i++) { | 338 for (int i = 1; i < 11; i++) { |
325 EXPECT_EQ(ports[i - 1], handler_ports[i]); | 339 EXPECT_EQ(ports[i - 1], handler_ports[i]); |
326 } | 340 } |
327 handler_peer.decrement_live_ports(); | 341 handler_peer.decrement_live_ports(); |
328 EXPECT(!handler.HasLivePorts()); | 342 EXPECT(!handler.HasLivePorts()); |
329 PortMap::ClosePorts(&handler); | 343 PortMap::ClosePorts(&handler); |
330 } | 344 } |
331 | 345 |
332 } // namespace dart | 346 } // namespace dart |
OLD | NEW |