Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1439)

Unified Diff: runtime/vm/message_test.cc

Issue 1122503003: Display isolate message queue in Observatory debugger (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/message_handler_test.cc ('k') | runtime/vm/service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/message_test.cc
diff --git a/runtime/vm/message_test.cc b/runtime/vm/message_test.cc
index b02df4769b5ffffbf256f04329c3158290da4c66..5250a776042eed4735fceee7b6f951e681d5c1a1 100644
--- a/runtime/vm/message_test.cc
+++ b/runtime/vm/message_test.cc
@@ -17,6 +17,9 @@ static uint8_t* AllocMsg(const char* str) {
TEST_CASE(MessageQueue_BasicOperations) {
MessageQueue queue;
EXPECT(queue.IsEmpty());
+ MessageQueue::Iterator it(&queue);
+ // Queue is empty.
+ EXPECT(!it.HasNext());
Dart_Port port = 1;
@@ -31,19 +34,43 @@ TEST_CASE(MessageQueue_BasicOperations) {
Message* msg1 = new Message(
port, AllocMsg(str1), strlen(str1) + 1, Message::kNormalPriority);
queue.Enqueue(msg1, false);
+ EXPECT(queue.Length() == 1);
EXPECT(!queue.IsEmpty());
+ it.Reset(&queue);
+ EXPECT(it.HasNext());
+ EXPECT(it.Next() == msg1);
+ EXPECT(!it.HasNext());
Message* msg2 = new Message(
port, AllocMsg(str2), strlen(str2) + 1, Message::kNormalPriority);
queue.Enqueue(msg2, false);
+ EXPECT(queue.Length() == 2);
EXPECT(!queue.IsEmpty());
+ it.Reset(&queue);
+ EXPECT(it.HasNext());
+ EXPECT(it.Next() == msg1);
+ EXPECT(it.HasNext());
+ EXPECT(it.Next() == msg2);
+ EXPECT(!it.HasNext());
- // Remove two messages.
+ // Lookup messages by id.
+ EXPECT(queue.FindMessageById(reinterpret_cast<intptr_t>(msg1)) == msg1);
+ EXPECT(queue.FindMessageById(reinterpret_cast<intptr_t>(msg2)) == msg2);
+
+ // Lookup bad id.
+ EXPECT(queue.FindMessageById(0x1) == NULL);
+
+ // Remove message 1
Message* msg = queue.Dequeue();
EXPECT(msg != NULL);
EXPECT_STREQ(str1, reinterpret_cast<char*>(msg->data()));
EXPECT(!queue.IsEmpty());
+ it.Reset(&queue);
+ EXPECT(it.HasNext());
+ EXPECT(it.Next() == msg2);
+
+ // Remove message 2
msg = queue.Dequeue();
EXPECT(msg != NULL);
EXPECT_STREQ(str2, reinterpret_cast<char*>(msg->data()));
« no previous file with comments | « runtime/vm/message_handler_test.cc ('k') | runtime/vm/service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698