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.h" | 6 #include "vm/message.h" |
7 #include "vm/unit_test.h" | 7 #include "vm/unit_test.h" |
8 | 8 |
9 namespace dart { | 9 namespace dart { |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... |
38 MessageQueueTestPeer queue_peer(&queue); | 38 MessageQueueTestPeer queue_peer(&queue); |
39 EXPECT(!queue_peer.HasMessage()); | 39 EXPECT(!queue_peer.HasMessage()); |
40 | 40 |
41 Dart_Port port = 1; | 41 Dart_Port port = 1; |
42 | 42 |
43 const char* str1 = "msg1"; | 43 const char* str1 = "msg1"; |
44 const char* str2 = "msg2"; | 44 const char* str2 = "msg2"; |
45 | 45 |
46 // Add two messages. | 46 // Add two messages. |
47 Message* msg1 = | 47 Message* msg1 = |
48 new Message(port, 0, AllocMsg(str1), strlen(str1) + 1, | 48 new Message(port, AllocMsg(str1), strlen(str1) + 1, |
49 Message::kNormalPriority); | 49 Message::kNormalPriority); |
50 queue.Enqueue(msg1); | 50 queue.Enqueue(msg1); |
51 EXPECT(queue_peer.HasMessage()); | 51 EXPECT(queue_peer.HasMessage()); |
52 | 52 |
53 Message* msg2 = | 53 Message* msg2 = |
54 new Message(port, 0, AllocMsg(str2), strlen(str2) + 1, | 54 new Message(port, AllocMsg(str2), strlen(str2) + 1, |
55 Message::kNormalPriority); | 55 Message::kNormalPriority); |
56 | 56 |
57 queue.Enqueue(msg2); | 57 queue.Enqueue(msg2); |
58 EXPECT(queue_peer.HasMessage()); | 58 EXPECT(queue_peer.HasMessage()); |
59 | 59 |
60 // Remove two messages. | 60 // Remove two messages. |
61 Message* msg = queue.Dequeue(); | 61 Message* msg = queue.Dequeue(); |
62 EXPECT(msg != NULL); | 62 EXPECT(msg != NULL); |
63 EXPECT_STREQ(str1, reinterpret_cast<char*>(msg->data())); | 63 EXPECT_STREQ(str1, reinterpret_cast<char*>(msg->data())); |
64 EXPECT(queue_peer.HasMessage()); | 64 EXPECT(queue_peer.HasMessage()); |
(...skipping 12 matching lines...) Expand all Loading... |
77 MessageQueue queue; | 77 MessageQueue queue; |
78 MessageQueueTestPeer queue_peer(&queue); | 78 MessageQueueTestPeer queue_peer(&queue); |
79 Dart_Port port1 = 1; | 79 Dart_Port port1 = 1; |
80 Dart_Port port2 = 2; | 80 Dart_Port port2 = 2; |
81 | 81 |
82 const char* str1 = "msg1"; | 82 const char* str1 = "msg1"; |
83 const char* str2 = "msg2"; | 83 const char* str2 = "msg2"; |
84 | 84 |
85 // Add two messages. | 85 // Add two messages. |
86 Message* msg1 = | 86 Message* msg1 = |
87 new Message(port1, 0, AllocMsg(str1), strlen(str1) + 1, | 87 new Message(port1, AllocMsg(str1), strlen(str1) + 1, |
88 Message::kNormalPriority); | 88 Message::kNormalPriority); |
89 queue.Enqueue(msg1); | 89 queue.Enqueue(msg1); |
90 Message* msg2 = | 90 Message* msg2 = |
91 new Message(port2, 0, AllocMsg(str2), strlen(str2) + 1, | 91 new Message(port2, AllocMsg(str2), strlen(str2) + 1, |
92 Message::kNormalPriority); | 92 Message::kNormalPriority); |
93 queue.Enqueue(msg2); | 93 queue.Enqueue(msg2); |
94 | 94 |
95 EXPECT(queue_peer.HasMessage()); | 95 EXPECT(queue_peer.HasMessage()); |
96 queue.Clear(); | 96 queue.Clear(); |
97 EXPECT(!queue_peer.HasMessage()); | 97 EXPECT(!queue_peer.HasMessage()); |
98 | 98 |
99 // msg1 and msg2 already delete by FlushAll. | 99 // msg1 and msg2 already delete by FlushAll. |
100 } | 100 } |
101 | 101 |
102 } // namespace dart | 102 } // namespace dart |
OLD | NEW |