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

Side by Side Diff: runtime/vm/port_test.cc

Issue 2481873005: clang-format runtime/vm (Closed)
Patch Set: Merge Created 4 years, 1 month 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
« no previous file with comments | « runtime/vm/port.cc ('k') | runtime/vm/precompiler.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/lockers.h" 6 #include "vm/lockers.h"
7 #include "vm/message_handler.h" 7 #include "vm/message_handler.h"
8 #include "vm/os.h" 8 #include "vm/os.h"
9 #include "vm/port.h" 9 #include "vm/port.h"
10 #include "vm/unit_test.h" 10 #include "vm/unit_test.h"
(...skipping 16 matching lines...) Expand all
27 } 27 }
28 return PortMap::map_[index].state == PortMap::kLivePort; 28 return PortMap::map_[index].state == PortMap::kLivePort;
29 } 29 }
30 }; 30 };
31 31
32 32
33 class PortTestMessageHandler : public MessageHandler { 33 class PortTestMessageHandler : public MessageHandler {
34 public: 34 public:
35 PortTestMessageHandler() : notify_count(0) {} 35 PortTestMessageHandler() : notify_count(0) {}
36 36
37 void MessageNotify(Message::Priority priority) { 37 void MessageNotify(Message::Priority priority) { notify_count++; }
38 notify_count++;
39 }
40 38
41 MessageStatus HandleMessage(Message* message) { return kOK; } 39 MessageStatus HandleMessage(Message* message) { return kOK; }
42 40
43 int notify_count; 41 int notify_count;
44 }; 42 };
45 43
46 44
47 TEST_CASE(PortMap_CreateAndCloseOnePort) { 45 TEST_CASE(PortMap_CreateAndCloseOnePort) {
48 PortTestMessageHandler handler; 46 PortTestMessageHandler handler;
49 Dart_Port port = PortMap::CreatePort(&handler); 47 Dart_Port port = PortMap::CreatePort(&handler);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 132
135 133
136 TEST_CASE(PortMap_PostMessage) { 134 TEST_CASE(PortMap_PostMessage) {
137 PortTestMessageHandler handler; 135 PortTestMessageHandler handler;
138 Dart_Port port = PortMap::CreatePort(&handler); 136 Dart_Port port = PortMap::CreatePort(&handler);
139 EXPECT_EQ(0, handler.notify_count); 137 EXPECT_EQ(0, handler.notify_count);
140 138
141 const char* message = "msg"; 139 const char* message = "msg";
142 intptr_t message_len = strlen(message) + 1; 140 intptr_t message_len = strlen(message) + 1;
143 141
144 EXPECT(PortMap::PostMessage(new Message( 142 EXPECT(PortMap::PostMessage(
145 port, reinterpret_cast<uint8_t*>(strdup(message)), message_len, 143 new Message(port, reinterpret_cast<uint8_t*>(strdup(message)),
146 Message::kNormalPriority))); 144 message_len, Message::kNormalPriority)));
147 145
148 // Check that the message notify callback was called. 146 // Check that the message notify callback was called.
149 EXPECT_EQ(1, handler.notify_count); 147 EXPECT_EQ(1, handler.notify_count);
150 PortMap::ClosePorts(&handler); 148 PortMap::ClosePorts(&handler);
151 } 149 }
152 150
153 151
154 TEST_CASE(PortMap_PostIntegerMessage) { 152 TEST_CASE(PortMap_PostIntegerMessage) {
155 PortTestMessageHandler handler; 153 PortTestMessageHandler handler;
156 Dart_Port port = PortMap::CreatePort(&handler); 154 Dart_Port port = PortMap::CreatePort(&handler);
157 EXPECT_EQ(0, handler.notify_count); 155 EXPECT_EQ(0, handler.notify_count);
158 156
159 EXPECT(PortMap::PostMessage(new Message( 157 EXPECT(PortMap::PostMessage(
160 port, Smi::New(42), Message::kNormalPriority))); 158 new Message(port, Smi::New(42), Message::kNormalPriority)));
161 159
162 // Check that the message notify callback was called. 160 // Check that the message notify callback was called.
163 EXPECT_EQ(1, handler.notify_count); 161 EXPECT_EQ(1, handler.notify_count);
164 PortMap::ClosePorts(&handler); 162 PortMap::ClosePorts(&handler);
165 } 163 }
166 164
167 165
168 TEST_CASE(PortMap_PostNullMessage) { 166 TEST_CASE(PortMap_PostNullMessage) {
169 PortTestMessageHandler handler; 167 PortTestMessageHandler handler;
170 Dart_Port port = PortMap::CreatePort(&handler); 168 Dart_Port port = PortMap::CreatePort(&handler);
171 EXPECT_EQ(0, handler.notify_count); 169 EXPECT_EQ(0, handler.notify_count);
172 170
173 EXPECT(PortMap::PostMessage(new Message( 171 EXPECT(PortMap::PostMessage(
174 port, Object::null(), Message::kNormalPriority))); 172 new Message(port, Object::null(), Message::kNormalPriority)));
175 173
176 // Check that the message notify callback was called. 174 // Check that the message notify callback was called.
177 EXPECT_EQ(1, handler.notify_count); 175 EXPECT_EQ(1, handler.notify_count);
178 PortMap::ClosePorts(&handler); 176 PortMap::ClosePorts(&handler);
179 } 177 }
180 178
181 179
182 TEST_CASE(PortMap_PostMessageClosedPort) { 180 TEST_CASE(PortMap_PostMessageClosedPort) {
183 // Create a port id and make it invalid. 181 // Create a port id and make it invalid.
184 PortTestMessageHandler handler; 182 PortTestMessageHandler handler;
185 Dart_Port port = PortMap::CreatePort(&handler); 183 Dart_Port port = PortMap::CreatePort(&handler);
186 PortMap::ClosePort(port); 184 PortMap::ClosePort(port);
187 185
188 const char* message = "msg"; 186 const char* message = "msg";
189 intptr_t message_len = strlen(message) + 1; 187 intptr_t message_len = strlen(message) + 1;
190 188
191 EXPECT(!PortMap::PostMessage(new Message( 189 EXPECT(!PortMap::PostMessage(
192 port, reinterpret_cast<uint8_t*>(strdup(message)), message_len, 190 new Message(port, reinterpret_cast<uint8_t*>(strdup(message)),
193 Message::kNormalPriority))); 191 message_len, Message::kNormalPriority)));
194 } 192 }
195 193
196 } // namespace dart 194 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/port.cc ('k') | runtime/vm/precompiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698