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

Unified Diff: runtime/vm/message_test.cc

Issue 10829444: Avoid trusting the length encoded in the Snapshot if there is an (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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/native_message_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/message_test.cc
===================================================================
--- runtime/vm/message_test.cc (revision 11409)
+++ runtime/vm/message_test.cc (working copy)
@@ -40,14 +40,19 @@
Dart_Port port = 1;
+ const char* str1 = "msg1";
+ const char* str2 = "msg2";
+
// Add two messages.
Message* msg1 =
- new Message(port, 0, AllocMsg("msg1"), Message::kNormalPriority);
+ new Message(port, 0, AllocMsg(str1), strlen(str1) + 1,
+ Message::kNormalPriority);
queue.Enqueue(msg1);
EXPECT(queue_peer.HasMessage());
Message* msg2 =
- new Message(port, 0, AllocMsg("msg2"), Message::kNormalPriority);
+ new Message(port, 0, AllocMsg(str2), strlen(str2) + 1,
+ Message::kNormalPriority);
queue.Enqueue(msg2);
EXPECT(queue_peer.HasMessage());
@@ -55,12 +60,12 @@
// Remove two messages.
Message* msg = queue.Dequeue();
EXPECT(msg != NULL);
- EXPECT_STREQ("msg1", reinterpret_cast<char*>(msg->data()));
+ EXPECT_STREQ(str1, reinterpret_cast<char*>(msg->data()));
EXPECT(queue_peer.HasMessage());
msg = queue.Dequeue();
EXPECT(msg != NULL);
- EXPECT_STREQ("msg2", reinterpret_cast<char*>(msg->data()));
+ EXPECT_STREQ(str2, reinterpret_cast<char*>(msg->data()));
EXPECT(!queue_peer.HasMessage());
delete msg1;
@@ -74,12 +79,17 @@
Dart_Port port1 = 1;
Dart_Port port2 = 2;
+ const char* str1 = "msg1";
+ const char* str2 = "msg2";
+
// Add two messages.
Message* msg1 =
- new Message(port1, 0, AllocMsg("msg1"), Message::kNormalPriority);
+ new Message(port1, 0, AllocMsg(str1), strlen(str1) + 1,
+ Message::kNormalPriority);
queue.Enqueue(msg1);
Message* msg2 =
- new Message(port2, 0, AllocMsg("msg2"), Message::kNormalPriority);
+ new Message(port2, 0, AllocMsg(str2), strlen(str2) + 1,
+ Message::kNormalPriority);
queue.Enqueue(msg2);
EXPECT(queue_peer.HasMessage());
@@ -96,12 +106,17 @@
Dart_Port port1 = 1;
Dart_Port port2 = 2;
+ const char* str1 = "msg1";
+ const char* str2 = "msg2";
+
// Add two messages on different ports.
Message* msg1 =
- new Message(port1, 0, AllocMsg("msg1"), Message::kNormalPriority);
+ new Message(port1, 0, AllocMsg(str1), strlen(str1) + 1,
+ Message::kNormalPriority);
queue.Enqueue(msg1);
Message* msg2 =
- new Message(port2, 0, AllocMsg("msg2"), Message::kNormalPriority);
+ new Message(port2, 0, AllocMsg(str2), strlen(str2) + 1,
+ Message::kNormalPriority);
queue.Enqueue(msg2);
EXPECT(queue_peer.HasMessage());
@@ -111,7 +126,7 @@
EXPECT(queue_peer.HasMessage());
Message* msg = queue.Dequeue();
EXPECT(msg != NULL);
- EXPECT_STREQ("msg2", reinterpret_cast<char*>(msg->data()));
+ EXPECT_STREQ(str2, reinterpret_cast<char*>(msg->data()));
EXPECT(!queue_peer.HasMessage());
@@ -125,11 +140,16 @@
MessageQueueTestPeer queue_peer(&queue);
Dart_Port port1 = 1;
+ const char* str1 = "msg1";
+ const char* str2 = "msg2";
+
Message* msg1 =
- new Message(port1, 0, AllocMsg("msg1"), Message::kNormalPriority);
+ new Message(port1, 0, AllocMsg(str1), strlen(str1) + 1,
+ Message::kNormalPriority);
queue.Enqueue(msg1);
Message* msg2 =
- new Message(port1, 0, AllocMsg("msg2"), Message::kNormalPriority);
+ new Message(port1, 0, AllocMsg(str2), strlen(str2) + 1,
+ Message::kNormalPriority);
queue.Enqueue(msg2);
EXPECT(queue_peer.HasMessage());
« no previous file with comments | « runtime/vm/message_handler_test.cc ('k') | runtime/vm/native_message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698