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

Side by Side Diff: runtime/vm/port_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, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/native_message_handler.cc ('k') | runtime/vm/snapshot.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 EXPECT(!PortMapTestPeer::IsActivePort(port)); 114 EXPECT(!PortMapTestPeer::IsActivePort(port));
115 EXPECT(!PortMapTestPeer::IsLivePort(port)); 115 EXPECT(!PortMapTestPeer::IsLivePort(port));
116 } 116 }
117 117
118 118
119 TEST_CASE(PortMap_PostMessage) { 119 TEST_CASE(PortMap_PostMessage) {
120 PortTestMessageHandler handler; 120 PortTestMessageHandler handler;
121 Dart_Port port = PortMap::CreatePort(&handler); 121 Dart_Port port = PortMap::CreatePort(&handler);
122 EXPECT_EQ(0, handler.notify_count); 122 EXPECT_EQ(0, handler.notify_count);
123 123
124 const char* message = "msg";
125 intptr_t message_len = strlen(message) + 1;
126
124 EXPECT(PortMap::PostMessage(new Message( 127 EXPECT(PortMap::PostMessage(new Message(
125 port, 0, reinterpret_cast<uint8_t*>(strdup("msg")), 128 port, 0, reinterpret_cast<uint8_t*>(strdup(message)), message_len,
126 Message::kNormalPriority))); 129 Message::kNormalPriority)));
127 130
128 // Check that the message notify callback was called. 131 // Check that the message notify callback was called.
129 EXPECT_EQ(1, handler.notify_count); 132 EXPECT_EQ(1, handler.notify_count);
130 PortMap::ClosePorts(&handler); 133 PortMap::ClosePorts(&handler);
131 } 134 }
132 135
133 136
134 TEST_CASE(PortMap_PostMessageInvalidPort) { 137 TEST_CASE(PortMap_PostMessageInvalidPort) {
138 const char* message = "msg";
139 intptr_t message_len = strlen(message) + 1;
140
135 EXPECT(!PortMap::PostMessage(new Message( 141 EXPECT(!PortMap::PostMessage(new Message(
136 0, 0, reinterpret_cast<uint8_t*>(strdup("msg")), 142 0, 0, reinterpret_cast<uint8_t*>(strdup(message)), message_len,
137 Message::kNormalPriority))); 143 Message::kNormalPriority)));
138 } 144 }
139 145
140 } // namespace dart 146 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/native_message_handler.cc ('k') | runtime/vm/snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698