OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/globals.h" | 5 #include "platform/globals.h" |
6 | 6 |
7 #include "include/dart_debugger_api.h" | 7 #include "include/dart_debugger_api.h" |
8 #include "vm/dart_api_impl.h" | 8 #include "vm/dart_api_impl.h" |
9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
10 #include "vm/debugger.h" | 10 #include "vm/debugger.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 } | 83 } |
84 | 84 |
85 const char* msg() const { return _msg; } | 85 const char* msg() const { return _msg; } |
86 | 86 |
87 private: | 87 private: |
88 char* _msg; | 88 char* _msg; |
89 }; | 89 }; |
90 | 90 |
91 | 91 |
92 static RawInstance* Eval(Dart_Handle lib, const char* expr) { | 92 static RawInstance* Eval(Dart_Handle lib, const char* expr) { |
93 Dart_Handle result = Dart_EvaluateExpr(lib, NewString(expr)); | 93 Dart_Handle expr_val = Dart_EvaluateExpr(lib, NewString(expr)); |
94 EXPECT_VALID(result); | 94 EXPECT_VALID(expr_val); |
95 Isolate* isolate = Isolate::Current(); | 95 Isolate* isolate = Isolate::Current(); |
96 const Instance& instance = Api::UnwrapInstanceHandle(isolate, result); | 96 const GrowableObjectArray& value = |
97 return instance.raw(); | 97 Api::UnwrapGrowableObjectArrayHandle(isolate, expr_val); |
| 98 const Array& result = Array::Handle(Array::MakeArray(value)); |
| 99 GrowableObjectArray& growable = GrowableObjectArray::Handle(); |
| 100 growable ^= result.At(3); |
| 101 Array& array = Array::Handle(Array::MakeArray(growable)); |
| 102 result.SetAt(3, array); |
| 103 growable ^= result.At(4); |
| 104 array = Array::MakeArray(growable); |
| 105 result.SetAt(4, array); |
| 106 return result.raw(); |
98 } | 107 } |
99 | 108 |
100 | 109 |
101 static RawInstance* EvalF(Dart_Handle lib, const char* fmt, ...) { | 110 static RawInstance* EvalF(Dart_Handle lib, const char* fmt, ...) { |
102 Isolate* isolate = Isolate::Current(); | 111 Isolate* isolate = Isolate::Current(); |
103 | 112 |
104 va_list args; | 113 va_list args; |
105 va_start(args, fmt); | 114 va_start(args, fmt); |
106 intptr_t len = OS::VSNPrint(NULL, 0, fmt, args); | 115 intptr_t len = OS::VSNPrint(NULL, 0, fmt, args); |
107 va_end(args); | 116 va_end(args); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 // Build a mock message handler and wrap it in a dart port. | 177 // Build a mock message handler and wrap it in a dart port. |
169 ServiceTestMessageHandler handler; | 178 ServiceTestMessageHandler handler; |
170 Dart_Port port_id = PortMap::CreatePort(&handler); | 179 Dart_Port port_id = PortMap::CreatePort(&handler); |
171 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 180 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
172 EXPECT_VALID(port); | 181 EXPECT_VALID(port); |
173 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); | 182 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); |
174 | 183 |
175 Instance& service_msg = Instance::Handle(); | 184 Instance& service_msg = Instance::Handle(); |
176 | 185 |
177 // Get the isolate summary. | 186 // Get the isolate summary. |
178 service_msg = Eval(lib, "[port, [], [], []]"); | 187 service_msg = Eval(lib, "[0, port, [], [], []]"); |
179 Service::HandleIsolateMessage(isolate, service_msg); | 188 Service::HandleIsolateMessage(isolate, service_msg); |
180 handler.HandleNextMessage(); | 189 handler.HandleNextMessage(); |
181 | 190 |
182 JSONReader reader(handler.msg()); | 191 JSONReader reader(handler.msg()); |
183 | 192 |
184 const int kBufferSize = 128; | 193 const int kBufferSize = 128; |
185 char buffer[kBufferSize]; | 194 char buffer[kBufferSize]; |
186 | 195 |
187 // Check that the response string is somewhat sane. | 196 // Check that the response string is somewhat sane. |
188 | 197 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 // Build a mock message handler and wrap it in a dart port. | 232 // Build a mock message handler and wrap it in a dart port. |
224 ServiceTestMessageHandler handler; | 233 ServiceTestMessageHandler handler; |
225 Dart_Port port_id = PortMap::CreatePort(&handler); | 234 Dart_Port port_id = PortMap::CreatePort(&handler); |
226 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 235 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
227 EXPECT_VALID(port); | 236 EXPECT_VALID(port); |
228 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); | 237 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); |
229 | 238 |
230 Instance& service_msg = Instance::Handle(); | 239 Instance& service_msg = Instance::Handle(); |
231 | 240 |
232 // Get the stacktrace. | 241 // Get the stacktrace. |
233 service_msg = Eval(lib, "[port, ['stacktrace'], [], []]"); | 242 service_msg = Eval(lib, "[0, port, ['stacktrace'], [], []]"); |
234 Service::HandleIsolateMessage(isolate, service_msg); | 243 Service::HandleIsolateMessage(isolate, service_msg); |
235 handler.HandleNextMessage(); | 244 handler.HandleNextMessage(); |
236 EXPECT_STREQ( | 245 EXPECT_STREQ( |
237 "{\"type\":\"StackTrace\",\"id\":\"stacktrace\",\"members\":[]}", | 246 "{\"type\":\"StackTrace\",\"id\":\"stacktrace\",\"members\":[]}", |
238 handler.msg()); | 247 handler.msg()); |
239 | 248 |
240 // Malformed request. | 249 // Malformed request. |
241 service_msg = Eval(lib, "[port, ['stacktrace', 'jamboree'], [], []]"); | 250 service_msg = Eval(lib, "[0, port, ['stacktrace', 'jamboree'], [], []]"); |
242 Service::HandleIsolateMessage(isolate, service_msg); | 251 Service::HandleIsolateMessage(isolate, service_msg); |
243 handler.HandleNextMessage(); | 252 handler.HandleNextMessage(); |
244 EXPECT_STREQ( | 253 EXPECT_STREQ( |
245 "{\"type\":\"Error\",\"id\":\"\",\"message\":\"Command too long\"," | 254 "{\"type\":\"Error\",\"id\":\"\",\"message\":\"Command too long\"," |
246 "\"request\":{\"arguments\":[\"stacktrace\",\"jamboree\"]," | 255 "\"request\":{\"arguments\":[\"stacktrace\",\"jamboree\"]," |
247 "\"option_keys\":[],\"option_values\":[]}}", | 256 "\"option_keys\":[],\"option_values\":[]}}", |
248 handler.msg()); | 257 handler.msg()); |
249 } | 258 } |
250 | 259 |
251 | 260 |
(...skipping 15 matching lines...) Expand all Loading... |
267 EXPECT_VALID(port); | 276 EXPECT_VALID(port); |
268 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); | 277 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); |
269 | 278 |
270 Instance& service_msg = Instance::Handle(); | 279 Instance& service_msg = Instance::Handle(); |
271 | 280 |
272 // Add a breakpoint. | 281 // Add a breakpoint. |
273 const String& url = String::Handle(String::New(TestCase::url())); | 282 const String& url = String::Handle(String::New(TestCase::url())); |
274 isolate->debugger()->SetBreakpointAtLine(url, 3); | 283 isolate->debugger()->SetBreakpointAtLine(url, 3); |
275 | 284 |
276 // Get the breakpoint list. | 285 // Get the breakpoint list. |
277 service_msg = Eval(lib, "[port, ['debug', 'breakpoints'], [], []]"); | 286 service_msg = Eval(lib, "[0, port, ['debug', 'breakpoints'], [], []]"); |
278 Service::HandleIsolateMessage(isolate, service_msg); | 287 Service::HandleIsolateMessage(isolate, service_msg); |
279 handler.HandleNextMessage(); | 288 handler.HandleNextMessage(); |
280 EXPECT_STREQ( | 289 EXPECT_STREQ( |
281 "{\"type\":\"BreakpointList\",\"breakpoints\":[{" | 290 "{\"type\":\"BreakpointList\",\"breakpoints\":[{" |
282 "\"type\":\"Breakpoint\",\"id\":1,\"enabled\":true," | 291 "\"type\":\"Breakpoint\",\"id\":1,\"enabled\":true," |
283 "\"resolved\":false," | 292 "\"resolved\":false," |
284 "\"location\":{\"type\":\"Location\"," | 293 "\"location\":{\"type\":\"Location\"," |
285 "\"script\":\"test-lib\",\"tokenPos\":5}}]}", | 294 "\"script\":\"test-lib\",\"tokenPos\":5}}]}", |
286 handler.msg()); | 295 handler.msg()); |
287 | 296 |
288 // Individual breakpoint. | 297 // Individual breakpoint. |
289 service_msg = Eval(lib, "[port, ['debug', 'breakpoints', '1'], [], []]"); | 298 service_msg = Eval(lib, "[0, port, ['debug', 'breakpoints', '1'], [], []]"); |
290 Service::HandleIsolateMessage(isolate, service_msg); | 299 Service::HandleIsolateMessage(isolate, service_msg); |
291 handler.HandleNextMessage(); | 300 handler.HandleNextMessage(); |
292 EXPECT_STREQ( | 301 EXPECT_STREQ( |
293 "{\"type\":\"Breakpoint\",\"id\":1,\"enabled\":true," | 302 "{\"type\":\"Breakpoint\",\"id\":1,\"enabled\":true," |
294 "\"resolved\":false," | 303 "\"resolved\":false," |
295 "\"location\":{\"type\":\"Location\"," | 304 "\"location\":{\"type\":\"Location\"," |
296 "\"script\":\"test-lib\",\"tokenPos\":5}}", | 305 "\"script\":\"test-lib\",\"tokenPos\":5}}", |
297 handler.msg()); | 306 handler.msg()); |
298 | 307 |
299 // Missing sub-command. | 308 // Missing sub-command. |
300 service_msg = Eval(lib, "[port, ['debug'], [], []]"); | 309 service_msg = Eval(lib, "[0, port, ['debug'], [], []]"); |
301 Service::HandleIsolateMessage(isolate, service_msg); | 310 Service::HandleIsolateMessage(isolate, service_msg); |
302 handler.HandleNextMessage(); | 311 handler.HandleNextMessage(); |
303 EXPECT_STREQ( | 312 EXPECT_STREQ( |
304 "{\"type\":\"Error\",\"id\":\"\"," | 313 "{\"type\":\"Error\",\"id\":\"\"," |
305 "\"message\":\"Must specify a subcommand\"," | 314 "\"message\":\"Must specify a subcommand\"," |
306 "\"request\":{\"arguments\":[\"debug\"],\"option_keys\":[]," | 315 "\"request\":{\"arguments\":[\"debug\"],\"option_keys\":[]," |
307 "\"option_values\":[]}}", | 316 "\"option_values\":[]}}", |
308 handler.msg()); | 317 handler.msg()); |
309 | 318 |
310 // Unrecognized breakpoint. | 319 // Unrecognized breakpoint. |
311 service_msg = Eval(lib, "[port, ['debug', 'breakpoints', '1111'], [], []]"); | 320 service_msg = Eval(lib, |
| 321 "[0, port, ['debug', 'breakpoints', '1111'], [], []]"); |
312 Service::HandleIsolateMessage(isolate, service_msg); | 322 Service::HandleIsolateMessage(isolate, service_msg); |
313 handler.HandleNextMessage(); | 323 handler.HandleNextMessage(); |
314 EXPECT_STREQ("{\"type\":\"Error\",\"id\":\"\"," | 324 EXPECT_STREQ("{\"type\":\"Error\",\"id\":\"\"," |
315 "\"message\":\"Unrecognized breakpoint id 1111\"," | 325 "\"message\":\"Unrecognized breakpoint id 1111\"," |
316 "\"request\":{" | 326 "\"request\":{" |
317 "\"arguments\":[\"debug\",\"breakpoints\",\"1111\"]," | 327 "\"arguments\":[\"debug\",\"breakpoints\",\"1111\"]," |
318 "\"option_keys\":[],\"option_values\":[]}}", | 328 "\"option_keys\":[],\"option_values\":[]}}", |
319 handler.msg()); | 329 handler.msg()); |
320 | 330 |
321 // Command too long. | 331 // Command too long. |
322 service_msg = | 332 service_msg = |
323 Eval(lib, "[port, ['debug', 'breakpoints', '1111', 'green'], [], []]"); | 333 Eval(lib, "[0, port, ['debug', 'breakpoints', '1111', 'green'], [], []]"); |
324 Service::HandleIsolateMessage(isolate, service_msg); | 334 Service::HandleIsolateMessage(isolate, service_msg); |
325 handler.HandleNextMessage(); | 335 handler.HandleNextMessage(); |
326 EXPECT_STREQ("{\"type\":\"Error\",\"id\":\"\"," | 336 EXPECT_STREQ("{\"type\":\"Error\",\"id\":\"\"," |
327 "\"message\":\"Command too long\"," | 337 "\"message\":\"Command too long\"," |
328 "\"request\":{\"arguments\":[\"debug\",\"breakpoints\"," | 338 "\"request\":{\"arguments\":[\"debug\",\"breakpoints\"," |
329 "\"1111\",\"green\"]," | 339 "\"1111\",\"green\"]," |
330 "\"option_keys\":[],\"option_values\":[]}}", | 340 "\"option_keys\":[],\"option_values\":[]}}", |
331 handler.msg()); | 341 handler.msg()); |
332 | 342 |
333 // Unrecognized subcommand. | 343 // Unrecognized subcommand. |
334 service_msg = Eval(lib, "[port, ['debug', 'nosferatu'], [], []]"); | 344 service_msg = Eval(lib, "[0, port, ['debug', 'nosferatu'], [], []]"); |
335 Service::HandleIsolateMessage(isolate, service_msg); | 345 Service::HandleIsolateMessage(isolate, service_msg); |
336 handler.HandleNextMessage(); | 346 handler.HandleNextMessage(); |
337 EXPECT_STREQ("{\"type\":\"Error\",\"id\":\"\"," | 347 EXPECT_STREQ("{\"type\":\"Error\",\"id\":\"\"," |
338 "\"message\":\"Unrecognized subcommand 'nosferatu'\"," | 348 "\"message\":\"Unrecognized subcommand 'nosferatu'\"," |
339 "\"request\":{\"arguments\":[\"debug\",\"nosferatu\"]," | 349 "\"request\":{\"arguments\":[\"debug\",\"nosferatu\"]," |
340 "\"option_keys\":[],\"option_values\":[]}}", | 350 "\"option_keys\":[],\"option_values\":[]}}", |
341 handler.msg()); | 351 handler.msg()); |
342 } | 352 } |
343 | 353 |
344 | 354 |
(...skipping 25 matching lines...) Expand all Loading... |
370 arr.SetAt(0, str); | 380 arr.SetAt(0, str); |
371 } | 381 } |
372 intptr_t arr_id = ring->GetIdForObject(arr.raw()); | 382 intptr_t arr_id = ring->GetIdForObject(arr.raw()); |
373 Dart_Handle valid_id = Dart_NewInteger(arr_id); | 383 Dart_Handle valid_id = Dart_NewInteger(arr_id); |
374 EXPECT_VALID(valid_id); | 384 EXPECT_VALID(valid_id); |
375 EXPECT_VALID(Dart_SetField(lib, NewString("validId"), valid_id)); | 385 EXPECT_VALID(Dart_SetField(lib, NewString("validId"), valid_id)); |
376 | 386 |
377 Instance& service_msg = Instance::Handle(); | 387 Instance& service_msg = Instance::Handle(); |
378 | 388 |
379 // null | 389 // null |
380 service_msg = Eval(lib, "[port, ['objects', 'null'], [], []]"); | 390 service_msg = Eval(lib, "[0, port, ['objects', 'null'], [], []]"); |
381 Service::HandleIsolateMessage(isolate, service_msg); | 391 Service::HandleIsolateMessage(isolate, service_msg); |
382 handler.HandleNextMessage(); | 392 handler.HandleNextMessage(); |
383 handler.filterMsg("name"); | 393 handler.filterMsg("name"); |
384 EXPECT_STREQ( | 394 EXPECT_STREQ( |
385 "{\"type\":\"Null\",\"id\":\"objects\\/null\"," | 395 "{\"type\":\"Null\",\"id\":\"objects\\/null\"," |
386 "\"valueAsString\":\"null\"}", | 396 "\"valueAsString\":\"null\"}", |
387 handler.msg()); | 397 handler.msg()); |
388 | 398 |
389 // not initialized | 399 // not initialized |
390 service_msg = Eval(lib, "[port, ['objects', 'not-initialized'], [], []]"); | 400 service_msg = Eval(lib, "[0, port, ['objects', 'not-initialized'], [], []]"); |
391 Service::HandleIsolateMessage(isolate, service_msg); | 401 Service::HandleIsolateMessage(isolate, service_msg); |
392 handler.HandleNextMessage(); | 402 handler.HandleNextMessage(); |
393 handler.filterMsg("name"); | 403 handler.filterMsg("name"); |
394 EXPECT_STREQ( | 404 EXPECT_STREQ( |
395 "{\"type\":\"Null\",\"id\":\"objects\\/not-initialized\"," | 405 "{\"type\":\"Null\",\"id\":\"objects\\/not-initialized\"," |
396 "\"valueAsString\":\"<not initialized>\"}", | 406 "\"valueAsString\":\"<not initialized>\"}", |
397 handler.msg()); | 407 handler.msg()); |
398 | 408 |
399 // being initialized | 409 // being initialized |
400 service_msg = Eval(lib, "[port, ['objects', 'being-initialized'], [], []]"); | 410 service_msg = Eval(lib, |
| 411 "[0, port, ['objects', 'being-initialized'], [], []]"); |
401 Service::HandleIsolateMessage(isolate, service_msg); | 412 Service::HandleIsolateMessage(isolate, service_msg); |
402 handler.HandleNextMessage(); | 413 handler.HandleNextMessage(); |
403 handler.filterMsg("name"); | 414 handler.filterMsg("name"); |
404 EXPECT_STREQ( | 415 EXPECT_STREQ( |
405 "{\"type\":\"Null\",\"id\":\"objects\\/being-initialized\"," | 416 "{\"type\":\"Null\",\"id\":\"objects\\/being-initialized\"," |
406 "\"valueAsString\":\"<being initialized>\"}", | 417 "\"valueAsString\":\"<being initialized>\"}", |
407 handler.msg()); | 418 handler.msg()); |
408 | 419 |
409 // optimized out | 420 // optimized out |
410 service_msg = Eval(lib, "[port, ['objects', 'optimized-out'], [], []]"); | 421 service_msg = Eval(lib, "[0, port, ['objects', 'optimized-out'], [], []]"); |
411 Service::HandleIsolateMessage(isolate, service_msg); | 422 Service::HandleIsolateMessage(isolate, service_msg); |
412 handler.HandleNextMessage(); | 423 handler.HandleNextMessage(); |
413 handler.filterMsg("name"); | 424 handler.filterMsg("name"); |
414 EXPECT_STREQ( | 425 EXPECT_STREQ( |
415 "{\"type\":\"Null\",\"id\":\"objects\\/optimized-out\"," | 426 "{\"type\":\"Null\",\"id\":\"objects\\/optimized-out\"," |
416 "\"valueAsString\":\"<optimized out>\"}", | 427 "\"valueAsString\":\"<optimized out>\"}", |
417 handler.msg()); | 428 handler.msg()); |
418 | 429 |
419 // collected | 430 // collected |
420 service_msg = Eval(lib, "[port, ['objects', 'collected'], [], []]"); | 431 service_msg = Eval(lib, "[0, port, ['objects', 'collected'], [], []]"); |
421 Service::HandleIsolateMessage(isolate, service_msg); | 432 Service::HandleIsolateMessage(isolate, service_msg); |
422 handler.HandleNextMessage(); | 433 handler.HandleNextMessage(); |
423 handler.filterMsg("name"); | 434 handler.filterMsg("name"); |
424 EXPECT_STREQ( | 435 EXPECT_STREQ( |
425 "{\"type\":\"Null\",\"id\":\"objects\\/collected\"," | 436 "{\"type\":\"Null\",\"id\":\"objects\\/collected\"," |
426 "\"valueAsString\":\"<collected>\"}", | 437 "\"valueAsString\":\"<collected>\"}", |
427 handler.msg()); | 438 handler.msg()); |
428 | 439 |
429 // expired | 440 // expired |
430 service_msg = Eval(lib, "[port, ['objects', 'expired'], [], []]"); | 441 service_msg = Eval(lib, "[0, port, ['objects', 'expired'], [], []]"); |
431 Service::HandleIsolateMessage(isolate, service_msg); | 442 Service::HandleIsolateMessage(isolate, service_msg); |
432 handler.HandleNextMessage(); | 443 handler.HandleNextMessage(); |
433 handler.filterMsg("name"); | 444 handler.filterMsg("name"); |
434 EXPECT_STREQ( | 445 EXPECT_STREQ( |
435 "{\"type\":\"Null\",\"id\":\"objects\\/expired\"," | 446 "{\"type\":\"Null\",\"id\":\"objects\\/expired\"," |
436 "\"valueAsString\":\"<expired>\"}", | 447 "\"valueAsString\":\"<expired>\"}", |
437 handler.msg()); | 448 handler.msg()); |
438 | 449 |
439 // bool | 450 // bool |
440 service_msg = Eval(lib, "[port, ['objects', 'bool-true'], [], []]"); | 451 service_msg = Eval(lib, "[0, port, ['objects', 'bool-true'], [], []]"); |
441 Service::HandleIsolateMessage(isolate, service_msg); | 452 Service::HandleIsolateMessage(isolate, service_msg); |
442 handler.HandleNextMessage(); | 453 handler.HandleNextMessage(); |
443 handler.filterMsg("name"); | 454 handler.filterMsg("name"); |
444 EXPECT_STREQ( | 455 EXPECT_STREQ( |
445 "{\"type\":\"Bool\",\"id\":\"objects\\/bool-true\"," | 456 "{\"type\":\"Bool\",\"id\":\"objects\\/bool-true\"," |
446 "\"class\":{\"type\":\"@Class\",\"id\":\"classes\\/46\"," | 457 "\"class\":{\"type\":\"@Class\",\"id\":\"classes\\/46\"," |
447 "\"user_name\":\"bool\"},\"valueAsString\":\"true\"}", | 458 "\"user_name\":\"bool\"},\"valueAsString\":\"true\"}", |
448 handler.msg()); | 459 handler.msg()); |
449 | 460 |
450 // int | 461 // int |
451 service_msg = Eval(lib, "[port, ['objects', 'int-123'], [], []]"); | 462 service_msg = Eval(lib, "[0, port, ['objects', 'int-123'], [], []]"); |
452 Service::HandleIsolateMessage(isolate, service_msg); | 463 Service::HandleIsolateMessage(isolate, service_msg); |
453 handler.HandleNextMessage(); | 464 handler.HandleNextMessage(); |
454 handler.filterMsg("name"); | 465 handler.filterMsg("name"); |
455 EXPECT_STREQ( | 466 EXPECT_STREQ( |
456 "{\"type\":\"Smi\"," | 467 "{\"type\":\"Smi\"," |
457 "\"class\":{\"type\":\"@Class\",\"id\":\"classes\\/42\"," | 468 "\"class\":{\"type\":\"@Class\",\"id\":\"classes\\/42\"," |
458 "\"user_name\":\"_Smi\"}," | 469 "\"user_name\":\"_Smi\"}," |
459 "\"fields\":[]," | 470 "\"fields\":[]," |
460 "\"id\":\"objects\\/int-123\"," | 471 "\"id\":\"objects\\/int-123\"," |
461 "\"valueAsString\":\"123\"}", | 472 "\"valueAsString\":\"123\"}", |
462 handler.msg()); | 473 handler.msg()); |
463 | 474 |
464 // object id ring / valid | 475 // object id ring / valid |
465 service_msg = Eval(lib, "[port, ['objects', '$validId'], [], []]"); | 476 service_msg = Eval(lib, "[0, port, ['objects', '$validId'], [], []]"); |
466 Service::HandleIsolateMessage(isolate, service_msg); | 477 Service::HandleIsolateMessage(isolate, service_msg); |
467 handler.HandleNextMessage(); | 478 handler.HandleNextMessage(); |
468 handler.filterMsg("name"); | 479 handler.filterMsg("name"); |
469 handler.filterMsg("size"); | 480 handler.filterMsg("size"); |
470 handler.filterMsg("id"); | 481 handler.filterMsg("id"); |
471 EXPECT_STREQ( | 482 EXPECT_STREQ( |
472 "{\"type\":\"Array\"," | 483 "{\"type\":\"Array\"," |
473 "\"class\":{\"type\":\"@Class\",\"user_name\":\"_List\"}," | 484 "\"class\":{\"type\":\"@Class\",\"user_name\":\"_List\"}," |
474 "\"fields\":[]," | 485 "\"fields\":[]," |
475 "\"length\":1," | 486 "\"length\":1," |
476 "\"elements\":[{" | 487 "\"elements\":[{" |
477 "\"index\":0," | 488 "\"index\":0," |
478 "\"value\":{\"type\":\"@String\"," | 489 "\"value\":{\"type\":\"@String\"," |
479 "\"class\":{\"type\":\"@Class\",\"user_name\":\"_OneByteString\"}," | 490 "\"class\":{\"type\":\"@Class\",\"user_name\":\"_OneByteString\"}," |
480 "\"valueAsString\":\"\\\"value\\\"\"}}]}", | 491 "\"valueAsString\":\"\\\"value\\\"\"}}]}", |
481 handler.msg()); | 492 handler.msg()); |
482 | 493 |
483 // object id ring / invalid => expired | 494 // object id ring / invalid => expired |
484 service_msg = Eval(lib, "[port, ['objects', '99999999'], [], []]"); | 495 service_msg = Eval(lib, "[0, port, ['objects', '99999999'], [], []]"); |
485 Service::HandleIsolateMessage(isolate, service_msg); | 496 Service::HandleIsolateMessage(isolate, service_msg); |
486 handler.HandleNextMessage(); | 497 handler.HandleNextMessage(); |
487 handler.filterMsg("name"); | 498 handler.filterMsg("name"); |
488 EXPECT_STREQ( | 499 EXPECT_STREQ( |
489 "{\"type\":\"Null\",\"id\":\"objects\\/expired\"," | 500 "{\"type\":\"Null\",\"id\":\"objects\\/expired\"," |
490 "\"valueAsString\":\"<expired>\"}", | 501 "\"valueAsString\":\"<expired>\"}", |
491 handler.msg()); | 502 handler.msg()); |
492 | 503 |
493 // expired/eval => error | 504 // expired/eval => error |
494 service_msg = Eval(lib, "[port, ['objects', 'expired', 'eval'], [], []]"); | 505 service_msg = Eval(lib, "[0, port, ['objects', 'expired', 'eval'], [], []]"); |
495 Service::HandleIsolateMessage(isolate, service_msg); | 506 Service::HandleIsolateMessage(isolate, service_msg); |
496 handler.HandleNextMessage(); | 507 handler.HandleNextMessage(); |
497 handler.filterMsg("name"); | 508 handler.filterMsg("name"); |
498 EXPECT_STREQ( | 509 EXPECT_STREQ( |
499 "{\"type\":\"Error\",\"id\":\"\"," | 510 "{\"type\":\"Error\",\"id\":\"\"," |
500 "\"message\":\"expected at most 2 arguments but found 3\\n\"," | 511 "\"message\":\"expected at most 2 arguments but found 3\\n\"," |
501 "\"request\":{\"arguments\":[\"objects\",\"expired\",\"eval\"]," | 512 "\"request\":{\"arguments\":[\"objects\",\"expired\",\"eval\"]," |
502 "\"option_keys\":[],\"option_values\":[]}}", | 513 "\"option_keys\":[],\"option_values\":[]}}", |
503 handler.msg()); | 514 handler.msg()); |
504 | 515 |
505 // int/eval => good | 516 // int/eval => good |
506 service_msg = Eval(lib, | 517 service_msg = Eval(lib, |
507 "[port, ['objects', 'int-123', 'eval'], " | 518 "[0, port, ['objects', 'int-123', 'eval'], " |
508 "['expr'], ['this+99']]"); | 519 "['expr'], ['this+99']]"); |
509 Service::HandleIsolateMessage(isolate, service_msg); | 520 Service::HandleIsolateMessage(isolate, service_msg); |
510 handler.HandleNextMessage(); | 521 handler.HandleNextMessage(); |
511 handler.filterMsg("name"); | 522 handler.filterMsg("name"); |
512 EXPECT_STREQ( | 523 EXPECT_STREQ( |
513 "{\"type\":\"@Smi\"," | 524 "{\"type\":\"@Smi\"," |
514 "\"class\":{\"type\":\"@Class\",\"id\":\"classes\\/42\"," | 525 "\"class\":{\"type\":\"@Class\",\"id\":\"classes\\/42\"," |
515 "\"user_name\":\"_Smi\"}," | 526 "\"user_name\":\"_Smi\"}," |
516 "\"id\":\"objects\\/int-222\"," | 527 "\"id\":\"objects\\/int-222\"," |
517 "\"valueAsString\":\"222\"}", | 528 "\"valueAsString\":\"222\"}", |
518 handler.msg()); | 529 handler.msg()); |
519 | 530 |
520 // eval returning null works | 531 // eval returning null works |
521 service_msg = Eval(lib, | 532 service_msg = Eval(lib, |
522 "[port, ['objects', 'int-123', 'eval'], " | 533 "[0, port, ['objects', 'int-123', 'eval'], " |
523 "['expr'], ['null']]"); | 534 "['expr'], ['null']]"); |
524 Service::HandleIsolateMessage(isolate, service_msg); | 535 Service::HandleIsolateMessage(isolate, service_msg); |
525 handler.HandleNextMessage(); | 536 handler.HandleNextMessage(); |
526 handler.filterMsg("name"); | 537 handler.filterMsg("name"); |
527 EXPECT_STREQ( | 538 EXPECT_STREQ( |
528 "{\"type\":\"@Null\",\"id\":\"objects\\/null\"," | 539 "{\"type\":\"@Null\",\"id\":\"objects\\/null\"," |
529 "\"valueAsString\":\"null\"}", | 540 "\"valueAsString\":\"null\"}", |
530 handler.msg()); | 541 handler.msg()); |
531 | 542 |
532 // object id ring / invalid => expired | 543 // object id ring / invalid => expired |
533 service_msg = Eval(lib, "[port, ['objects', '99999999', 'eval'], " | 544 service_msg = Eval(lib, "[0, port, ['objects', '99999999', 'eval'], " |
534 "['expr'], ['this']]"); | 545 "['expr'], ['this']]"); |
535 Service::HandleIsolateMessage(isolate, service_msg); | 546 Service::HandleIsolateMessage(isolate, service_msg); |
536 handler.HandleNextMessage(); | 547 handler.HandleNextMessage(); |
537 handler.filterMsg("name"); | 548 handler.filterMsg("name"); |
538 EXPECT_STREQ( | 549 EXPECT_STREQ( |
539 "{\"type\":\"Error\",\"id\":\"\",\"kind\":\"EvalExpired\"," | 550 "{\"type\":\"Error\",\"id\":\"\",\"kind\":\"EvalExpired\"," |
540 "\"message\":\"attempt to evaluate against expired object\\n\"," | 551 "\"message\":\"attempt to evaluate against expired object\\n\"," |
541 "\"request\":{\"arguments\":[\"objects\",\"99999999\",\"eval\"]," | 552 "\"request\":{\"arguments\":[\"objects\",\"99999999\",\"eval\"]," |
542 "\"option_keys\":[\"expr\"],\"option_values\":[\"this\"]}}", | 553 "\"option_keys\":[\"expr\"],\"option_values\":[\"this\"]}}", |
543 handler.msg()); | 554 handler.msg()); |
544 | 555 |
545 // Extra arg to eval. | 556 // Extra arg to eval. |
546 service_msg = Eval(lib, | 557 service_msg = Eval(lib, |
547 "[port, ['objects', 'int-123', 'eval', 'foo'], " | 558 "[0, port, ['objects', 'int-123', 'eval', 'foo'], " |
548 "['expr'], ['this+99']]"); | 559 "['expr'], ['this+99']]"); |
549 Service::HandleIsolateMessage(isolate, service_msg); | 560 Service::HandleIsolateMessage(isolate, service_msg); |
550 handler.HandleNextMessage(); | 561 handler.HandleNextMessage(); |
551 handler.filterMsg("name"); | 562 handler.filterMsg("name"); |
552 EXPECT_STREQ( | 563 EXPECT_STREQ( |
553 "{\"type\":\"Error\",\"id\":\"\"," | 564 "{\"type\":\"Error\",\"id\":\"\"," |
554 "\"message\":\"expected at most 3 arguments but found 4\\n\"," | 565 "\"message\":\"expected at most 3 arguments but found 4\\n\"," |
555 "\"request\":{\"arguments\":[\"objects\",\"int-123\",\"eval\",\"foo\"]," | 566 "\"request\":{\"arguments\":[\"objects\",\"int-123\",\"eval\",\"foo\"]," |
556 "\"option_keys\":[\"expr\"],\"option_values\":[\"this+99\"]}}", | 567 "\"option_keys\":[\"expr\"],\"option_values\":[\"this+99\"]}}", |
557 handler.msg()); | 568 handler.msg()); |
558 | 569 |
559 // Retained by single instance. | 570 // Retained by single instance. |
560 service_msg = Eval(lib, | 571 service_msg = Eval(lib, |
561 "[port, ['objects', '$validId', 'retained'], [], []]"); | 572 "[0, port, ['objects', '$validId', 'retained'], [], []]"); |
562 Service::HandleIsolateMessage(isolate, service_msg); | 573 Service::HandleIsolateMessage(isolate, service_msg); |
563 handler.HandleNextMessage(); | 574 handler.HandleNextMessage(); |
564 handler.filterMsg("name"); | 575 handler.filterMsg("name"); |
565 ExpectSubstringF(handler.msg(), | 576 ExpectSubstringF(handler.msg(), |
566 "\"id\":\"objects\\/int-%" Pd "\"", | 577 "\"id\":\"objects\\/int-%" Pd "\"", |
567 arr.raw()->Size() + arr.At(0)->Size()); | 578 arr.raw()->Size() + arr.At(0)->Size()); |
568 | 579 |
569 // Retaining path to 'arr', limit 1. | 580 // Retaining path to 'arr', limit 1. |
570 service_msg = Eval( | 581 service_msg = Eval( |
571 lib, | 582 lib, |
572 "[port, ['objects', '$validId', 'retaining_path'], ['limit'], ['1']]"); | 583 "[0, port, ['objects', '$validId', 'retaining_path'], ['limit'], ['1']]"); |
573 Service::HandleIsolateMessage(isolate, service_msg); | 584 Service::HandleIsolateMessage(isolate, service_msg); |
574 handler.HandleNextMessage(); | 585 handler.HandleNextMessage(); |
575 ExpectSubstringF( | 586 ExpectSubstringF( |
576 handler.msg(), | 587 handler.msg(), |
577 "{\"type\":\"RetainingPath\",\"id\":\"retaining_path\",\"length\":1," | 588 "{\"type\":\"RetainingPath\",\"id\":\"retaining_path\",\"length\":1," |
578 "\"elements\":[{\"index\":0,\"value\":{\"type\":\"@Array\""); | 589 "\"elements\":[{\"index\":0,\"value\":{\"type\":\"@Array\""); |
579 | 590 |
580 // Retaining path missing limit. | 591 // Retaining path missing limit. |
581 service_msg = Eval( | 592 service_msg = Eval( |
582 lib, | 593 lib, |
583 "[port, ['objects', '$validId', 'retaining_path'], [], []]"); | 594 "[0, port, ['objects', '$validId', 'retaining_path'], [], []]"); |
584 Service::HandleIsolateMessage(isolate, service_msg); | 595 Service::HandleIsolateMessage(isolate, service_msg); |
585 handler.HandleNextMessage(); | 596 handler.HandleNextMessage(); |
586 ExpectSubstringF(handler.msg(), "{\"type\":\"Error\""); | 597 ExpectSubstringF(handler.msg(), "{\"type\":\"Error\""); |
587 | 598 |
588 // eval against list containing an internal object. | 599 // eval against list containing an internal object. |
589 Object& internal_object = Object::Handle(); | 600 Object& internal_object = Object::Handle(); |
590 internal_object = LiteralToken::New(); | 601 internal_object = LiteralToken::New(); |
591 arr.SetAt(0, internal_object); | 602 arr.SetAt(0, internal_object); |
592 service_msg = Eval(lib, | 603 service_msg = Eval(lib, |
593 "[port, ['objects', '$validId', 'eval'], " | 604 "[0, port, ['objects', '$validId', 'eval'], " |
594 "['expr'], ['toString()']]"); | 605 "['expr'], ['toString()']]"); |
595 Service::HandleIsolateMessage(isolate, service_msg); | 606 Service::HandleIsolateMessage(isolate, service_msg); |
596 handler.HandleNextMessage(); | 607 handler.HandleNextMessage(); |
597 ExpectSubstringF(handler.msg(), "\"type\":\"Error\""); | 608 ExpectSubstringF(handler.msg(), "\"type\":\"Error\""); |
598 ExpectSubstringF( | 609 ExpectSubstringF( |
599 handler.msg(), | 610 handler.msg(), |
600 "\"message\":\"attempt to evaluate against internal VM object\\n\""); | 611 "\"message\":\"attempt to evaluate against internal VM object\\n\""); |
601 } | 612 } |
602 | 613 |
603 | 614 |
(...skipping 27 matching lines...) Expand all Loading... |
631 ServiceTestMessageHandler handler; | 642 ServiceTestMessageHandler handler; |
632 Dart_Port port_id = PortMap::CreatePort(&handler); | 643 Dart_Port port_id = PortMap::CreatePort(&handler); |
633 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 644 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
634 EXPECT_VALID(port); | 645 EXPECT_VALID(port); |
635 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); | 646 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); |
636 | 647 |
637 Instance& service_msg = Instance::Handle(); | 648 Instance& service_msg = Instance::Handle(); |
638 | 649 |
639 // Request library. | 650 // Request library. |
640 service_msg = EvalF(h_lib, | 651 service_msg = EvalF(h_lib, |
641 "[port, ['libraries', '%" Pd "'], [], []]", lib_id); | 652 "[0, port, ['libraries', '%" Pd "'], [], []]", lib_id); |
642 Service::HandleIsolateMessage(isolate, service_msg); | 653 Service::HandleIsolateMessage(isolate, service_msg); |
643 handler.HandleNextMessage(); | 654 handler.HandleNextMessage(); |
644 EXPECT_SUBSTRING("\"type\":\"Library\"", handler.msg()); | 655 EXPECT_SUBSTRING("\"type\":\"Library\"", handler.msg()); |
645 EXPECT_SUBSTRING("\"url\":\"test-lib\"", handler.msg()); | 656 EXPECT_SUBSTRING("\"url\":\"test-lib\"", handler.msg()); |
646 | 657 |
647 // Evaluate an expression from a library. | 658 // Evaluate an expression from a library. |
648 service_msg = EvalF(h_lib, | 659 service_msg = EvalF(h_lib, |
649 "[port, ['libraries', '%" Pd "', 'eval'], " | 660 "[0, port, ['libraries', '%" Pd "', 'eval'], " |
650 "['expr'], ['libVar - 1']]", lib_id); | 661 "['expr'], ['libVar - 1']]", lib_id); |
651 Service::HandleIsolateMessage(isolate, service_msg); | 662 Service::HandleIsolateMessage(isolate, service_msg); |
652 handler.HandleNextMessage(); | 663 handler.HandleNextMessage(); |
653 handler.filterMsg("name"); | 664 handler.filterMsg("name"); |
654 EXPECT_STREQ( | 665 EXPECT_STREQ( |
655 "{\"type\":\"@Smi\"," | 666 "{\"type\":\"@Smi\"," |
656 "\"class\":{\"type\":\"@Class\",\"id\":\"classes\\/42\"," | 667 "\"class\":{\"type\":\"@Class\",\"id\":\"classes\\/42\"," |
657 "\"user_name\":\"_Smi\"},\"id\":\"objects\\/int-54320\"," | 668 "\"user_name\":\"_Smi\"},\"id\":\"objects\\/int-54320\"," |
658 "\"valueAsString\":\"54320\"}", | 669 "\"valueAsString\":\"54320\"}", |
659 handler.msg()); | 670 handler.msg()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 // Build a mock message handler and wrap it in a dart port. | 707 // Build a mock message handler and wrap it in a dart port. |
697 ServiceTestMessageHandler handler; | 708 ServiceTestMessageHandler handler; |
698 Dart_Port port_id = PortMap::CreatePort(&handler); | 709 Dart_Port port_id = PortMap::CreatePort(&handler); |
699 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 710 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
700 EXPECT_VALID(port); | 711 EXPECT_VALID(port); |
701 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); | 712 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); |
702 | 713 |
703 Instance& service_msg = Instance::Handle(); | 714 Instance& service_msg = Instance::Handle(); |
704 | 715 |
705 // Request an invalid class id. | 716 // Request an invalid class id. |
706 service_msg = Eval(h_lib, "[port, ['classes', '999999'], [], []]"); | 717 service_msg = Eval(h_lib, "[0, port, ['classes', '999999'], [], []]"); |
707 Service::HandleIsolateMessage(isolate, service_msg); | 718 Service::HandleIsolateMessage(isolate, service_msg); |
708 handler.HandleNextMessage(); | 719 handler.HandleNextMessage(); |
709 EXPECT_STREQ( | 720 EXPECT_STREQ( |
710 "{\"type\":\"Error\",\"id\":\"\"," | 721 "{\"type\":\"Error\",\"id\":\"\"," |
711 "\"message\":\"999999 is not a valid class id.\"," | 722 "\"message\":\"999999 is not a valid class id.\"," |
712 "\"request\":{\"arguments\":[\"classes\",\"999999\"]," | 723 "\"request\":{\"arguments\":[\"classes\",\"999999\"]," |
713 "\"option_keys\":[],\"option_values\":[]}}", handler.msg()); | 724 "\"option_keys\":[],\"option_values\":[]}}", handler.msg()); |
714 | 725 |
715 // Request the class A over the service. | 726 // Request the class A over the service. |
716 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "'], [], []]", cid); | 727 service_msg = EvalF(h_lib, "[0, port, ['classes', '%" Pd "'], [], []]", cid); |
717 Service::HandleIsolateMessage(isolate, service_msg); | 728 Service::HandleIsolateMessage(isolate, service_msg); |
718 handler.HandleNextMessage(); | 729 handler.HandleNextMessage(); |
719 EXPECT_SUBSTRING("\"type\":\"Class\"", handler.msg()); | 730 EXPECT_SUBSTRING("\"type\":\"Class\"", handler.msg()); |
720 ExpectSubstringF(handler.msg(), | 731 ExpectSubstringF(handler.msg(), |
721 "\"id\":\"classes\\/%" Pd "\",\"name\":\"A\",", cid); | 732 "\"id\":\"classes\\/%" Pd "\",\"name\":\"A\",", cid); |
722 | 733 |
723 // Evaluate an expression from class A. | 734 // Evaluate an expression from class A. |
724 service_msg = EvalF(h_lib, | 735 service_msg = EvalF(h_lib, |
725 "[port, ['classes', '%" Pd "', 'eval'], " | 736 "[0, port, ['classes', '%" Pd "', 'eval'], " |
726 "['expr'], ['cobra + 100000']]", cid); | 737 "['expr'], ['cobra + 100000']]", cid); |
727 Service::HandleIsolateMessage(isolate, service_msg); | 738 Service::HandleIsolateMessage(isolate, service_msg); |
728 handler.HandleNextMessage(); | 739 handler.HandleNextMessage(); |
729 handler.filterMsg("name"); | 740 handler.filterMsg("name"); |
730 EXPECT_STREQ( | 741 EXPECT_STREQ( |
731 "{\"type\":\"@Smi\"," | 742 "{\"type\":\"@Smi\"," |
732 "\"class\":{\"type\":\"@Class\",\"id\":\"classes\\/42\"," | 743 "\"class\":{\"type\":\"@Class\",\"id\":\"classes\\/42\"," |
733 "\"user_name\":\"_Smi\"}," | 744 "\"user_name\":\"_Smi\"}," |
734 "\"id\":\"objects\\/int-111235\"," | 745 "\"id\":\"objects\\/int-111235\"," |
735 "\"valueAsString\":\"111235\"}", | 746 "\"valueAsString\":\"111235\"}", |
736 handler.msg()); | 747 handler.msg()); |
737 | 748 |
738 // Request function 0 from class A. | 749 // Request function 0 from class A. |
739 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'functions', '0']," | 750 service_msg = EvalF(h_lib, |
740 "[], []]", cid); | 751 "[0, port, ['classes', '%" Pd "', 'functions', '0']," |
| 752 "[], []]", cid); |
741 Service::HandleIsolateMessage(isolate, service_msg); | 753 Service::HandleIsolateMessage(isolate, service_msg); |
742 handler.HandleNextMessage(); | 754 handler.HandleNextMessage(); |
743 EXPECT_SUBSTRING("\"type\":\"Function\"", handler.msg()); | 755 EXPECT_SUBSTRING("\"type\":\"Function\"", handler.msg()); |
744 ExpectSubstringF(handler.msg(), | 756 ExpectSubstringF(handler.msg(), |
745 "\"id\":\"classes\\/%" Pd "\\/functions\\/0\"," | 757 "\"id\":\"classes\\/%" Pd "\\/functions\\/0\"," |
746 "\"name\":\"get:a\",", cid); | 758 "\"name\":\"get:a\",", cid); |
747 | 759 |
748 // Request field 0 from class A. | 760 // Request field 0 from class A. |
749 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'fields', '0']," | 761 service_msg = EvalF(h_lib, "[0, port, ['classes', '%" Pd "', 'fields', '0']," |
750 "[], []]", cid); | 762 "[], []]", cid); |
751 Service::HandleIsolateMessage(isolate, service_msg); | 763 Service::HandleIsolateMessage(isolate, service_msg); |
752 handler.HandleNextMessage(); | 764 handler.HandleNextMessage(); |
753 EXPECT_SUBSTRING("\"type\":\"Field\"", handler.msg()); | 765 EXPECT_SUBSTRING("\"type\":\"Field\"", handler.msg()); |
754 ExpectSubstringF(handler.msg(), | 766 ExpectSubstringF(handler.msg(), |
755 "\"id\":\"classes\\/%" Pd "\\/fields\\/0\"," | 767 "\"id\":\"classes\\/%" Pd "\\/fields\\/0\"," |
756 "\"name\":\"a\",", cid); | 768 "\"name\":\"a\",", cid); |
757 | 769 |
758 // Invalid sub command. | 770 // Invalid sub command. |
759 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'huh', '0']," | 771 service_msg = EvalF(h_lib, "[0, port, ['classes', '%" Pd "', 'huh', '0']," |
760 "[], []]", cid); | 772 "[], []]", cid); |
761 Service::HandleIsolateMessage(isolate, service_msg); | 773 Service::HandleIsolateMessage(isolate, service_msg); |
762 handler.HandleNextMessage(); | 774 handler.HandleNextMessage(); |
763 ExpectSubstringF(handler.msg(), | 775 ExpectSubstringF(handler.msg(), |
764 "{\"type\":\"Error\",\"id\":\"\",\"message\":\"Invalid sub collection huh\"" | 776 "{\"type\":\"Error\",\"id\":\"\",\"message\":\"Invalid sub collection huh\"" |
765 ",\"request\":" | 777 ",\"request\":" |
766 "{\"arguments\":[\"classes\",\"%" Pd "\",\"huh\",\"0\"],\"option_keys\":[]," | 778 "{\"arguments\":[\"classes\",\"%" Pd "\",\"huh\",\"0\"],\"option_keys\":[]," |
767 "\"option_values\":[]}}", cid); | 779 "\"option_values\":[]}}", cid); |
768 | 780 |
769 // Invalid field request. | 781 // Invalid field request. |
770 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'fields', '9']," | 782 service_msg = EvalF(h_lib, "[0, port, ['classes', '%" Pd "', 'fields', '9']," |
771 "[], []]", cid); | 783 "[], []]", cid); |
772 Service::HandleIsolateMessage(isolate, service_msg); | 784 Service::HandleIsolateMessage(isolate, service_msg); |
773 handler.HandleNextMessage(); | 785 handler.HandleNextMessage(); |
774 ExpectSubstringF(handler.msg(), | 786 ExpectSubstringF(handler.msg(), |
775 "{\"type\":\"Error\",\"id\":\"\",\"message\":\"Field 9 not found\"," | 787 "{\"type\":\"Error\",\"id\":\"\",\"message\":\"Field 9 not found\"," |
776 "\"request\":{\"arguments\":[\"classes\",\"%" Pd "\",\"fields\",\"9\"]," | 788 "\"request\":{\"arguments\":[\"classes\",\"%" Pd "\",\"fields\",\"9\"]," |
777 "\"option_keys\":[],\"option_values\":[]}}", cid); | 789 "\"option_keys\":[],\"option_values\":[]}}", cid); |
778 | 790 |
779 // Invalid function request. | 791 // Invalid function request. |
780 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'functions', '9']," | 792 service_msg = EvalF(h_lib, |
781 "[], []]", cid); | 793 "[0, port, ['classes', '%" Pd "', 'functions', '9']," |
| 794 "[], []]", cid); |
782 Service::HandleIsolateMessage(isolate, service_msg); | 795 Service::HandleIsolateMessage(isolate, service_msg); |
783 handler.HandleNextMessage(); | 796 handler.HandleNextMessage(); |
784 ExpectSubstringF(handler.msg(), | 797 ExpectSubstringF(handler.msg(), |
785 "{\"type\":\"Error\",\"id\":\"\",\"message\":\"Function 9 not found\"," | 798 "{\"type\":\"Error\",\"id\":\"\",\"message\":\"Function 9 not found\"," |
786 "\"request\":{\"arguments\":[\"classes\",\"%" Pd "\",\"functions\",\"9\"]," | 799 "\"request\":{\"arguments\":[\"classes\",\"%" Pd "\",\"functions\",\"9\"]," |
787 "\"option_keys\":[],\"option_values\":[]}}", cid); | 800 "\"option_keys\":[],\"option_values\":[]}}", cid); |
788 | 801 |
789 | 802 |
790 // Invalid field subcommand. | 803 // Invalid field subcommand. |
791 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'fields', '9', 'x']" | 804 service_msg = EvalF(h_lib, |
792 ",[], []]", cid); | 805 "[0, port, ['classes', '%" Pd "', 'fields', '9', 'x']" |
| 806 ",[], []]", cid); |
793 Service::HandleIsolateMessage(isolate, service_msg); | 807 Service::HandleIsolateMessage(isolate, service_msg); |
794 handler.HandleNextMessage(); | 808 handler.HandleNextMessage(); |
795 ExpectSubstringF(handler.msg(), | 809 ExpectSubstringF(handler.msg(), |
796 "{\"type\":\"Error\",\"id\":\"\",\"message\":\"Command too long\"," | 810 "{\"type\":\"Error\",\"id\":\"\",\"message\":\"Command too long\"," |
797 "\"request\":" | 811 "\"request\":" |
798 "{\"arguments\":[\"classes\",\"%" Pd "\",\"fields\",\"9\",\"x\"]," | 812 "{\"arguments\":[\"classes\",\"%" Pd "\",\"fields\",\"9\",\"x\"]," |
799 "\"option_keys\":[],\"option_values\":[]}}", cid); | 813 "\"option_keys\":[],\"option_values\":[]}}", cid); |
800 | 814 |
801 // Invalid function request. | 815 // Invalid function request. |
802 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'functions', '9'," | 816 service_msg = EvalF(h_lib, |
803 "'x'], [], []]", cid); | 817 "[0, port, ['classes', '%" Pd "', 'functions', '9'," |
| 818 "'x'], [], []]", cid); |
804 Service::HandleIsolateMessage(isolate, service_msg); | 819 Service::HandleIsolateMessage(isolate, service_msg); |
805 handler.HandleNextMessage(); | 820 handler.HandleNextMessage(); |
806 ExpectSubstringF(handler.msg(), | 821 ExpectSubstringF(handler.msg(), |
807 "{\"type\":\"Error\",\"id\":\"\",\"message\":\"Command too long\"," | 822 "{\"type\":\"Error\",\"id\":\"\",\"message\":\"Command too long\"," |
808 "\"request\":" | 823 "\"request\":" |
809 "{\"arguments\":[\"classes\",\"%" Pd "\",\"functions\",\"9\",\"x\"]," | 824 "{\"arguments\":[\"classes\",\"%" Pd "\",\"functions\",\"9\",\"x\"]," |
810 "\"option_keys\":[],\"option_values\":[]}}", cid); | 825 "\"option_keys\":[],\"option_values\":[]}}", cid); |
811 | 826 |
812 // Retained size of all instances of class B. | 827 // Retained size of all instances of class B. |
813 const Class& class_b = Class::Handle(GetClass(lib, "B")); | 828 const Class& class_b = Class::Handle(GetClass(lib, "B")); |
814 EXPECT(!class_b.IsNull()); | 829 EXPECT(!class_b.IsNull()); |
815 const Instance& b0 = Instance::Handle(Instance::New(class_b)); | 830 const Instance& b0 = Instance::Handle(Instance::New(class_b)); |
816 const Instance& b1 = Instance::Handle(Instance::New(class_b)); | 831 const Instance& b1 = Instance::Handle(Instance::New(class_b)); |
817 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'retained']," | 832 service_msg = EvalF(h_lib, "[0, port, ['classes', '%" Pd "', 'retained']," |
818 "[], []]", class_b.id()); | 833 "[], []]", class_b.id()); |
819 Service::HandleIsolateMessage(isolate, service_msg); | 834 Service::HandleIsolateMessage(isolate, service_msg); |
820 handler.HandleNextMessage(); | 835 handler.HandleNextMessage(); |
821 ExpectSubstringF(handler.msg(), | 836 ExpectSubstringF(handler.msg(), |
822 "\"id\":\"objects\\/int-%" Pd "\"", | 837 "\"id\":\"objects\\/int-%" Pd "\"", |
823 b0.raw()->Size() + b1.raw()->Size()); | 838 b0.raw()->Size() + b1.raw()->Size()); |
824 } | 839 } |
825 | 840 |
826 | 841 |
827 TEST_CASE(Service_Types) { | 842 TEST_CASE(Service_Types) { |
(...skipping 21 matching lines...) Expand all Loading... |
849 // Build a mock message handler and wrap it in a dart port. | 864 // Build a mock message handler and wrap it in a dart port. |
850 ServiceTestMessageHandler handler; | 865 ServiceTestMessageHandler handler; |
851 Dart_Port port_id = PortMap::CreatePort(&handler); | 866 Dart_Port port_id = PortMap::CreatePort(&handler); |
852 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 867 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
853 EXPECT_VALID(port); | 868 EXPECT_VALID(port); |
854 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); | 869 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); |
855 | 870 |
856 Instance& service_msg = Instance::Handle(); | 871 Instance& service_msg = Instance::Handle(); |
857 | 872 |
858 // Request the class A over the service. | 873 // Request the class A over the service. |
859 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "'], [], []]", cid); | 874 service_msg = EvalF(h_lib, "[0, port, ['classes', '%" Pd "'], [], []]", cid); |
860 Service::HandleIsolateMessage(isolate, service_msg); | 875 Service::HandleIsolateMessage(isolate, service_msg); |
861 handler.HandleNextMessage(); | 876 handler.HandleNextMessage(); |
862 EXPECT_SUBSTRING("\"type\":\"Class\"", handler.msg()); | 877 EXPECT_SUBSTRING("\"type\":\"Class\"", handler.msg()); |
863 EXPECT_SUBSTRING("\"name\":\"A\"", handler.msg()); | 878 EXPECT_SUBSTRING("\"name\":\"A\"", handler.msg()); |
864 ExpectSubstringF(handler.msg(), | 879 ExpectSubstringF(handler.msg(), |
865 "\"id\":\"classes\\/%" Pd "\"", cid); | 880 "\"id\":\"classes\\/%" Pd "\"", cid); |
866 | 881 |
867 // Request canonical type 0 from class A. | 882 // Request canonical type 0 from class A. |
868 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'types', '0']," | 883 service_msg = EvalF(h_lib, "[0, port, ['classes', '%" Pd "', 'types', '0']," |
869 "[], []]", cid); | 884 "[], []]", cid); |
870 Service::HandleIsolateMessage(isolate, service_msg); | 885 Service::HandleIsolateMessage(isolate, service_msg); |
871 handler.HandleNextMessage(); | 886 handler.HandleNextMessage(); |
872 EXPECT_SUBSTRING("\"type\":\"Type\"", handler.msg()); | 887 EXPECT_SUBSTRING("\"type\":\"Type\"", handler.msg()); |
873 EXPECT_SUBSTRING("\"name\":\"A<bool>\"", handler.msg()); | 888 EXPECT_SUBSTRING("\"name\":\"A<bool>\"", handler.msg()); |
874 ExpectSubstringF(handler.msg(), | 889 ExpectSubstringF(handler.msg(), |
875 "\"id\":\"classes\\/%" Pd "\\/types\\/0\"", cid); | 890 "\"id\":\"classes\\/%" Pd "\\/types\\/0\"", cid); |
876 | 891 |
877 // Request canonical type 1 from class A. | 892 // Request canonical type 1 from class A. |
878 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'types', '1']," | 893 service_msg = EvalF(h_lib, "[0, port, ['classes', '%" Pd "', 'types', '1']," |
879 "[], []]", cid); | 894 "[], []]", cid); |
880 Service::HandleIsolateMessage(isolate, service_msg); | 895 Service::HandleIsolateMessage(isolate, service_msg); |
881 handler.HandleNextMessage(); | 896 handler.HandleNextMessage(); |
882 EXPECT_SUBSTRING("\"type\":\"Type\"", handler.msg()); | 897 EXPECT_SUBSTRING("\"type\":\"Type\"", handler.msg()); |
883 EXPECT_SUBSTRING("\"name\":\"A<A<bool>>\"", handler.msg()); | 898 EXPECT_SUBSTRING("\"name\":\"A<A<bool>>\"", handler.msg()); |
884 ExpectSubstringF(handler.msg(), | 899 ExpectSubstringF(handler.msg(), |
885 "\"id\":\"classes\\/%" Pd "\\/types\\/1\"", cid); | 900 "\"id\":\"classes\\/%" Pd "\\/types\\/1\"", cid); |
886 | 901 |
887 // Request for non-existent canonical type from class A. | 902 // Request for non-existent canonical type from class A. |
888 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'types', '42']," | 903 service_msg = EvalF(h_lib, "[0, port, ['classes', '%" Pd "', 'types', '42']," |
889 "[], []]", cid); | 904 "[], []]", cid); |
890 Service::HandleIsolateMessage(isolate, service_msg); | 905 Service::HandleIsolateMessage(isolate, service_msg); |
891 handler.HandleNextMessage(); | 906 handler.HandleNextMessage(); |
892 ExpectSubstringF(handler.msg(), | 907 ExpectSubstringF(handler.msg(), |
893 "{\"type\":\"Error\",\"id\":\"\"," | 908 "{\"type\":\"Error\",\"id\":\"\"," |
894 "\"message\":\"Canonical type 42 not found\"" | 909 "\"message\":\"Canonical type 42 not found\"" |
895 ",\"request\":" | 910 ",\"request\":" |
896 "{\"arguments\":[\"classes\",\"%" Pd "\",\"types\",\"42\"]," | 911 "{\"arguments\":[\"classes\",\"%" Pd "\",\"types\",\"42\"]," |
897 "\"option_keys\":[],\"option_values\":[]}}", cid); | 912 "\"option_keys\":[],\"option_values\":[]}}", cid); |
898 | 913 |
899 // Request canonical type arguments. Expect <A<bool>> to be listed. | 914 // Request canonical type arguments. Expect <A<bool>> to be listed. |
900 service_msg = EvalF(h_lib, "[port, ['typearguments']," | 915 service_msg = EvalF(h_lib, "[0, port, ['typearguments']," |
901 "[], []]"); | 916 "[], []]"); |
902 Service::HandleIsolateMessage(isolate, service_msg); | 917 Service::HandleIsolateMessage(isolate, service_msg); |
903 handler.HandleNextMessage(); | 918 handler.HandleNextMessage(); |
904 EXPECT_SUBSTRING("\"type\":\"TypeArgumentsList\"", handler.msg()); | 919 EXPECT_SUBSTRING("\"type\":\"TypeArgumentsList\"", handler.msg()); |
905 ExpectSubstringF(handler.msg(), "\"name\":\"<A<bool>>\","); | 920 ExpectSubstringF(handler.msg(), "\"name\":\"<A<bool>>\","); |
906 | 921 |
907 // Request canonical type arguments with instantiations. | 922 // Request canonical type arguments with instantiations. |
908 service_msg = EvalF(h_lib, "[port, ['typearguments', 'withinstantiations']," | 923 service_msg = EvalF(h_lib, |
909 "[], []]"); | 924 "[0, port, ['typearguments', 'withinstantiations']," |
| 925 "[], []]"); |
910 Service::HandleIsolateMessage(isolate, service_msg); | 926 Service::HandleIsolateMessage(isolate, service_msg); |
911 handler.HandleNextMessage(); | 927 handler.HandleNextMessage(); |
912 EXPECT_SUBSTRING("\"type\":\"TypeArgumentsList\"", handler.msg()); | 928 EXPECT_SUBSTRING("\"type\":\"TypeArgumentsList\"", handler.msg()); |
913 } | 929 } |
914 | 930 |
915 | 931 |
916 TEST_CASE(Service_Code) { | 932 TEST_CASE(Service_Code) { |
917 const char* kScript = | 933 const char* kScript = |
918 "var port;\n" // Set to our mock port by C++. | 934 "var port;\n" // Set to our mock port by C++. |
919 "\n" | 935 "\n" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 // Build a mock message handler and wrap it in a dart port. | 970 // Build a mock message handler and wrap it in a dart port. |
955 ServiceTestMessageHandler handler; | 971 ServiceTestMessageHandler handler; |
956 Dart_Port port_id = PortMap::CreatePort(&handler); | 972 Dart_Port port_id = PortMap::CreatePort(&handler); |
957 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 973 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
958 EXPECT_VALID(port); | 974 EXPECT_VALID(port); |
959 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); | 975 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); |
960 | 976 |
961 Instance& service_msg = Instance::Handle(); | 977 Instance& service_msg = Instance::Handle(); |
962 | 978 |
963 // Request an invalid code object. | 979 // Request an invalid code object. |
964 service_msg = Eval(h_lib, "[port, ['code', '0'], [], []]"); | 980 service_msg = Eval(h_lib, "[0, port, ['code', '0'], [], []]"); |
965 Service::HandleIsolateMessage(isolate, service_msg); | 981 Service::HandleIsolateMessage(isolate, service_msg); |
966 handler.HandleNextMessage(); | 982 handler.HandleNextMessage(); |
967 EXPECT_STREQ( | 983 EXPECT_STREQ( |
968 "{\"type\":\"Error\",\"id\":\"\",\"message\":\"Malformed code id: 0\"," | 984 "{\"type\":\"Error\",\"id\":\"\",\"message\":\"Malformed code id: 0\"," |
969 "\"request\":{\"arguments\":[\"code\",\"0\"]," | 985 "\"request\":{\"arguments\":[\"code\",\"0\"]," |
970 "\"option_keys\":[],\"option_values\":[]}}", handler.msg()); | 986 "\"option_keys\":[],\"option_values\":[]}}", handler.msg()); |
971 | 987 |
972 // The following test checks that a code object can be found only | 988 // The following test checks that a code object can be found only |
973 // at compile_timestamp()-code.EntryPoint(). | 989 // at compile_timestamp()-code.EntryPoint(). |
974 service_msg = EvalF(h_lib, "[port, ['code', '%" Px64"-%" Px "'], [], []]", | 990 service_msg = EvalF(h_lib, "[0, port, ['code', '%" Px64"-%" Px "'], [], []]", |
975 compile_timestamp, | 991 compile_timestamp, |
976 entry); | 992 entry); |
977 Service::HandleIsolateMessage(isolate, service_msg); | 993 Service::HandleIsolateMessage(isolate, service_msg); |
978 handler.HandleNextMessage(); | 994 handler.HandleNextMessage(); |
979 { | 995 { |
980 // Only perform a partial match. | 996 // Only perform a partial match. |
981 const intptr_t kBufferSize = 512; | 997 const intptr_t kBufferSize = 512; |
982 char buffer[kBufferSize]; | 998 char buffer[kBufferSize]; |
983 OS::SNPrint(buffer, kBufferSize-1, | 999 OS::SNPrint(buffer, kBufferSize-1, |
984 "{\"type\":\"Code\",\"id\":\"code\\/%" Px64 "-%" Px "\",", | 1000 "{\"type\":\"Code\",\"id\":\"code\\/%" Px64 "-%" Px "\",", |
985 compile_timestamp, | 1001 compile_timestamp, |
986 entry); | 1002 entry); |
987 EXPECT_SUBSTRING(buffer, handler.msg()); | 1003 EXPECT_SUBSTRING(buffer, handler.msg()); |
988 } | 1004 } |
989 | 1005 |
990 // Request code object at compile_timestamp-code.EntryPoint() + 16 | 1006 // Request code object at compile_timestamp-code.EntryPoint() + 16 |
991 // Expect this to fail because the address is not the entry point. | 1007 // Expect this to fail because the address is not the entry point. |
992 uintptr_t address = entry + 16; | 1008 uintptr_t address = entry + 16; |
993 service_msg = EvalF(h_lib, "[port, ['code', '%" Px64"-%" Px "'], [], []]", | 1009 service_msg = EvalF(h_lib, "[0, port, ['code', '%" Px64"-%" Px "'], [], []]", |
994 compile_timestamp, | 1010 compile_timestamp, |
995 address); | 1011 address); |
996 Service::HandleIsolateMessage(isolate, service_msg); | 1012 Service::HandleIsolateMessage(isolate, service_msg); |
997 handler.HandleNextMessage(); | 1013 handler.HandleNextMessage(); |
998 { | 1014 { |
999 // Only perform a partial match. | 1015 // Only perform a partial match. |
1000 const intptr_t kBufferSize = 512; | 1016 const intptr_t kBufferSize = 512; |
1001 char buffer[kBufferSize]; | 1017 char buffer[kBufferSize]; |
1002 OS::SNPrint(buffer, kBufferSize-1, | 1018 OS::SNPrint(buffer, kBufferSize-1, |
1003 "Could not find code with id: %" Px64 "-%" Px "", | 1019 "Could not find code with id: %" Px64 "-%" Px "", |
1004 compile_timestamp, | 1020 compile_timestamp, |
1005 address); | 1021 address); |
1006 EXPECT_SUBSTRING(buffer, handler.msg()); | 1022 EXPECT_SUBSTRING(buffer, handler.msg()); |
1007 } | 1023 } |
1008 | 1024 |
1009 // Request code object at (compile_timestamp - 1)-code.EntryPoint() | 1025 // Request code object at (compile_timestamp - 1)-code.EntryPoint() |
1010 // Expect this to fail because the timestamp is wrong. | 1026 // Expect this to fail because the timestamp is wrong. |
1011 address = entry; | 1027 address = entry; |
1012 service_msg = EvalF(h_lib, "[port, ['code', '%" Px64"-%" Px "'], [], []]", | 1028 service_msg = EvalF(h_lib, "[0, port, ['code', '%" Px64"-%" Px "'], [], []]", |
1013 compile_timestamp - 1, | 1029 compile_timestamp - 1, |
1014 address); | 1030 address); |
1015 Service::HandleIsolateMessage(isolate, service_msg); | 1031 Service::HandleIsolateMessage(isolate, service_msg); |
1016 handler.HandleNextMessage(); | 1032 handler.HandleNextMessage(); |
1017 { | 1033 { |
1018 // Only perform a partial match. | 1034 // Only perform a partial match. |
1019 const intptr_t kBufferSize = 512; | 1035 const intptr_t kBufferSize = 512; |
1020 char buffer[kBufferSize]; | 1036 char buffer[kBufferSize]; |
1021 OS::SNPrint(buffer, kBufferSize-1, | 1037 OS::SNPrint(buffer, kBufferSize-1, |
1022 "Could not find code with id: %" Px64 "-%" Px "", | 1038 "Could not find code with id: %" Px64 "-%" Px "", |
1023 compile_timestamp - 1, | 1039 compile_timestamp - 1, |
1024 address); | 1040 address); |
1025 EXPECT_SUBSTRING(buffer, handler.msg()); | 1041 EXPECT_SUBSTRING(buffer, handler.msg()); |
1026 } | 1042 } |
1027 | 1043 |
1028 // Request native code at address. Expect the null code object back. | 1044 // Request native code at address. Expect the null code object back. |
1029 address = last; | 1045 address = last; |
1030 service_msg = EvalF(h_lib, "[port, ['code', 'native-%" Px "'], [], []]", | 1046 service_msg = EvalF(h_lib, "[0, port, ['code', 'native-%" Px "'], [], []]", |
1031 address); | 1047 address); |
1032 Service::HandleIsolateMessage(isolate, service_msg); | 1048 Service::HandleIsolateMessage(isolate, service_msg); |
1033 handler.HandleNextMessage(); | 1049 handler.HandleNextMessage(); |
1034 EXPECT_STREQ("{\"type\":\"Null\",\"id\":\"objects\\/null\"," | 1050 EXPECT_STREQ("{\"type\":\"Null\",\"id\":\"objects\\/null\"," |
1035 "\"valueAsString\":\"null\"}", | 1051 "\"valueAsString\":\"null\"}", |
1036 handler.msg()); | 1052 handler.msg()); |
1037 | 1053 |
1038 // Request malformed native code. | 1054 // Request malformed native code. |
1039 service_msg = EvalF(h_lib, "[port, ['code', 'native%" Px "'], [], []]", | 1055 service_msg = EvalF(h_lib, "[0, port, ['code', 'native%" Px "'], [], []]", |
1040 address); | 1056 address); |
1041 Service::HandleIsolateMessage(isolate, service_msg); | 1057 Service::HandleIsolateMessage(isolate, service_msg); |
1042 handler.HandleNextMessage(); | 1058 handler.HandleNextMessage(); |
1043 EXPECT_SUBSTRING("\"message\":\"Malformed code id:", handler.msg()); | 1059 EXPECT_SUBSTRING("\"message\":\"Malformed code id:", handler.msg()); |
1044 } | 1060 } |
1045 | 1061 |
1046 | 1062 |
1047 TEST_CASE(Service_VM) { | 1063 TEST_CASE(Service_VM) { |
1048 const char* kScript = | 1064 const char* kScript = |
1049 "var port;\n" // Set to our mock port by C++. | 1065 "var port;\n" // Set to our mock port by C++. |
1050 "\n" | 1066 "\n" |
1051 "main() {\n" | 1067 "main() {\n" |
1052 "}"; | 1068 "}"; |
1053 | 1069 |
1054 Isolate* isolate = Isolate::Current(); | 1070 Isolate* isolate = Isolate::Current(); |
1055 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 1071 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
1056 EXPECT_VALID(lib); | 1072 EXPECT_VALID(lib); |
1057 | 1073 |
1058 // Build a mock message handler and wrap it in a dart port. | 1074 // Build a mock message handler and wrap it in a dart port. |
1059 ServiceTestMessageHandler handler; | 1075 ServiceTestMessageHandler handler; |
1060 Dart_Port port_id = PortMap::CreatePort(&handler); | 1076 Dart_Port port_id = PortMap::CreatePort(&handler); |
1061 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 1077 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
1062 EXPECT_VALID(port); | 1078 EXPECT_VALID(port); |
1063 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); | 1079 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); |
1064 | 1080 |
1065 Instance& service_msg = Instance::Handle(); | 1081 Instance& service_msg = Instance::Handle(); |
1066 service_msg = Eval(lib, "[port, ['vm'], [], []]"); | 1082 service_msg = Eval(lib, "[0, port, ['vm'], [], []]"); |
1067 | 1083 |
1068 Service::HandleRootMessage(service_msg); | 1084 Service::HandleRootMessage(service_msg); |
1069 handler.HandleNextMessage(); | 1085 handler.HandleNextMessage(); |
1070 EXPECT_SUBSTRING("\"type\":\"VM\",\"id\":\"vm\"", handler.msg()); | 1086 EXPECT_SUBSTRING("\"type\":\"VM\",\"id\":\"vm\"", handler.msg()); |
1071 EXPECT_SUBSTRING("\"targetCPU\"", handler.msg()); | 1087 EXPECT_SUBSTRING("\"targetCPU\"", handler.msg()); |
1072 EXPECT_SUBSTRING("\"hostCPU\"", handler.msg()); | 1088 EXPECT_SUBSTRING("\"hostCPU\"", handler.msg()); |
1073 EXPECT_SUBSTRING("\"version\"", handler.msg()); | 1089 EXPECT_SUBSTRING("\"version\"", handler.msg()); |
1074 EXPECT_SUBSTRING("\"uptime\"", handler.msg()); | 1090 EXPECT_SUBSTRING("\"uptime\"", handler.msg()); |
1075 EXPECT_SUBSTRING("\"isolates\"", handler.msg()); | 1091 EXPECT_SUBSTRING("\"isolates\"", handler.msg()); |
1076 } | 1092 } |
(...skipping 11 matching lines...) Expand all Loading... |
1088 EXPECT_VALID(lib); | 1104 EXPECT_VALID(lib); |
1089 | 1105 |
1090 // Build a mock message handler and wrap it in a dart port. | 1106 // Build a mock message handler and wrap it in a dart port. |
1091 ServiceTestMessageHandler handler; | 1107 ServiceTestMessageHandler handler; |
1092 Dart_Port port_id = PortMap::CreatePort(&handler); | 1108 Dart_Port port_id = PortMap::CreatePort(&handler); |
1093 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 1109 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
1094 EXPECT_VALID(port); | 1110 EXPECT_VALID(port); |
1095 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); | 1111 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); |
1096 | 1112 |
1097 Instance& service_msg = Instance::Handle(); | 1113 Instance& service_msg = Instance::Handle(); |
1098 service_msg = Eval(lib, "[port, ['flags'], [], []]"); | 1114 service_msg = Eval(lib, "[0, port, ['flags'], [], []]"); |
1099 | 1115 |
1100 // Make sure we can get the FlagList. | 1116 // Make sure we can get the FlagList. |
1101 Service::HandleRootMessage(service_msg); | 1117 Service::HandleRootMessage(service_msg); |
1102 handler.HandleNextMessage(); | 1118 handler.HandleNextMessage(); |
1103 EXPECT_SUBSTRING("\"type\":\"FlagList\",\"id\":\"flags\"", handler.msg()); | 1119 EXPECT_SUBSTRING("\"type\":\"FlagList\",\"id\":\"flags\"", handler.msg()); |
1104 EXPECT_SUBSTRING( | 1120 EXPECT_SUBSTRING( |
1105 "\"name\":\"service_testing_flag\",\"comment\":\"Comment\"," | 1121 "\"name\":\"service_testing_flag\",\"comment\":\"Comment\"," |
1106 "\"flagType\":\"bool\",\"valueAsString\":\"false\"", | 1122 "\"flagType\":\"bool\",\"valueAsString\":\"false\"", |
1107 handler.msg()); | 1123 handler.msg()); |
1108 | 1124 |
1109 // Modify a flag through the vm service. | 1125 // Modify a flag through the vm service. |
1110 service_msg = Eval(lib, | 1126 service_msg = Eval(lib, |
1111 "[port, ['flags', 'set'], " | 1127 "[0, port, ['flags', 'set'], " |
1112 "['name', 'value'], ['service_testing_flag', 'true']]"); | 1128 "['name', 'value'], ['service_testing_flag', 'true']]"); |
1113 Service::HandleRootMessage(service_msg); | 1129 Service::HandleRootMessage(service_msg); |
1114 handler.HandleNextMessage(); | 1130 handler.HandleNextMessage(); |
1115 EXPECT_SUBSTRING("Success", handler.msg()); | 1131 EXPECT_SUBSTRING("Success", handler.msg()); |
1116 | 1132 |
1117 // Make sure that the flag changed. | 1133 // Make sure that the flag changed. |
1118 service_msg = Eval(lib, "[port, ['flags'], [], []]"); | 1134 service_msg = Eval(lib, "[0, port, ['flags'], [], []]"); |
1119 Service::HandleRootMessage(service_msg); | 1135 Service::HandleRootMessage(service_msg); |
1120 handler.HandleNextMessage(); | 1136 handler.HandleNextMessage(); |
1121 EXPECT_SUBSTRING( | 1137 EXPECT_SUBSTRING( |
1122 "\"name\":\"service_testing_flag\",\"comment\":\"Comment\"," | 1138 "\"name\":\"service_testing_flag\",\"comment\":\"Comment\"," |
1123 "\"flagType\":\"bool\",\"valueAsString\":\"true\"", | 1139 "\"flagType\":\"bool\",\"valueAsString\":\"true\"", |
1124 handler.msg()); | 1140 handler.msg()); |
1125 } | 1141 } |
1126 | 1142 |
1127 | 1143 |
1128 TEST_CASE(Service_Scripts) { | 1144 TEST_CASE(Service_Scripts) { |
1129 const char* kScript = | 1145 const char* kScript = |
1130 "var port;\n" // Set to our mock port by C++. | 1146 "var port;\n" // Set to our mock port by C++. |
1131 "\n" | 1147 "\n" |
1132 "main() {\n" | 1148 "main() {\n" |
1133 "}"; | 1149 "}"; |
1134 | 1150 |
1135 Isolate* isolate = Isolate::Current(); | 1151 Isolate* isolate = Isolate::Current(); |
1136 Dart_Handle h_lib = TestCase::LoadTestScript(kScript, NULL); | 1152 Dart_Handle h_lib = TestCase::LoadTestScript(kScript, NULL); |
1137 EXPECT_VALID(h_lib); | 1153 EXPECT_VALID(h_lib); |
1138 | 1154 |
1139 // Build a mock message handler and wrap it in a dart port. | 1155 // Build a mock message handler and wrap it in a dart port. |
1140 ServiceTestMessageHandler handler; | 1156 ServiceTestMessageHandler handler; |
1141 Dart_Port port_id = PortMap::CreatePort(&handler); | 1157 Dart_Port port_id = PortMap::CreatePort(&handler); |
1142 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 1158 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
1143 EXPECT_VALID(port); | 1159 EXPECT_VALID(port); |
1144 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); | 1160 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); |
1145 | 1161 |
1146 Instance& service_msg = Instance::Handle(); | 1162 Instance& service_msg = Instance::Handle(); |
1147 service_msg = Eval(h_lib, "[port, ['scripts', 'test-lib'], [], []]"); | 1163 service_msg = Eval(h_lib, "[0, port, ['scripts', 'test-lib'], [], []]"); |
1148 Service::HandleIsolateMessage(isolate, service_msg); | 1164 Service::HandleIsolateMessage(isolate, service_msg); |
1149 handler.HandleNextMessage(); | 1165 handler.HandleNextMessage(); |
1150 EXPECT_STREQ( | 1166 EXPECT_STREQ( |
1151 "{\"type\":\"Script\",\"id\":\"scripts\\/test-lib\"," | 1167 "{\"type\":\"Script\",\"id\":\"scripts\\/test-lib\"," |
1152 "\"name\":\"test-lib\",\"user_name\":\"test-lib\"," | 1168 "\"name\":\"test-lib\",\"user_name\":\"test-lib\"," |
1153 "\"kind\":\"script\"," | 1169 "\"kind\":\"script\"," |
1154 "\"source\":\"var port;\\n\\nmain() {\\n}\"," | 1170 "\"source\":\"var port;\\n\\nmain() {\\n}\"," |
1155 "\"tokenPosTable\":[[1,0,1,1,5,2,9],[3,5,1,6,5,7,6,8,8],[4,10,1]]}", | 1171 "\"tokenPosTable\":[[1,0,1,1,5,2,9],[3,5,1,6,5,7,6,8,8],[4,10,1]]}", |
1156 handler.msg()); | 1172 handler.msg()); |
1157 } | 1173 } |
(...skipping 22 matching lines...) Expand all Loading... |
1180 EXPECT_VALID(result); | 1196 EXPECT_VALID(result); |
1181 | 1197 |
1182 // Build a mock message handler and wrap it in a dart port. | 1198 // Build a mock message handler and wrap it in a dart port. |
1183 ServiceTestMessageHandler handler; | 1199 ServiceTestMessageHandler handler; |
1184 Dart_Port port_id = PortMap::CreatePort(&handler); | 1200 Dart_Port port_id = PortMap::CreatePort(&handler); |
1185 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 1201 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
1186 EXPECT_VALID(port); | 1202 EXPECT_VALID(port); |
1187 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); | 1203 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); |
1188 | 1204 |
1189 Instance& service_msg = Instance::Handle(); | 1205 Instance& service_msg = Instance::Handle(); |
1190 service_msg = Eval(h_lib, "[port, ['coverage'], [], []]"); | 1206 service_msg = Eval(h_lib, "[0, port, ['coverage'], [], []]"); |
1191 Service::HandleIsolateMessage(isolate, service_msg); | 1207 Service::HandleIsolateMessage(isolate, service_msg); |
1192 handler.HandleNextMessage(); | 1208 handler.HandleNextMessage(); |
1193 EXPECT_SUBSTRING( | 1209 EXPECT_SUBSTRING( |
1194 "{\"source\":\"test-lib\",\"script\":{" | 1210 "{\"source\":\"test-lib\",\"script\":{" |
1195 "\"type\":\"@Script\",\"id\":\"scripts\\/test-lib\"," | 1211 "\"type\":\"@Script\",\"id\":\"scripts\\/test-lib\"," |
1196 "\"name\":\"test-lib\",\"user_name\":\"test-lib\"," | 1212 "\"name\":\"test-lib\",\"user_name\":\"test-lib\"," |
1197 "\"kind\":\"script\"},\"hits\":" | 1213 "\"kind\":\"script\"},\"hits\":" |
1198 "[5,1,6,1]}", handler.msg()); | 1214 "[5,1,6,1]}", handler.msg()); |
1199 } | 1215 } |
1200 | 1216 |
(...skipping 20 matching lines...) Expand all Loading... |
1221 EXPECT_VALID(result); | 1237 EXPECT_VALID(result); |
1222 | 1238 |
1223 // Build a mock message handler and wrap it in a dart port. | 1239 // Build a mock message handler and wrap it in a dart port. |
1224 ServiceTestMessageHandler handler; | 1240 ServiceTestMessageHandler handler; |
1225 Dart_Port port_id = PortMap::CreatePort(&handler); | 1241 Dart_Port port_id = PortMap::CreatePort(&handler); |
1226 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 1242 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
1227 EXPECT_VALID(port); | 1243 EXPECT_VALID(port); |
1228 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); | 1244 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); |
1229 | 1245 |
1230 Instance& service_msg = Instance::Handle(); | 1246 Instance& service_msg = Instance::Handle(); |
1231 service_msg = Eval(h_lib, "[port, ['allocationprofile'], [], []]"); | 1247 service_msg = Eval(h_lib, "[0, port, ['allocationprofile'], [], []]"); |
1232 Service::HandleIsolateMessage(isolate, service_msg); | 1248 Service::HandleIsolateMessage(isolate, service_msg); |
1233 handler.HandleNextMessage(); | 1249 handler.HandleNextMessage(); |
1234 EXPECT_SUBSTRING("\"type\":\"AllocationProfile\"", handler.msg()); | 1250 EXPECT_SUBSTRING("\"type\":\"AllocationProfile\"", handler.msg()); |
1235 | 1251 |
1236 // Too long. | 1252 // Too long. |
1237 service_msg = Eval(h_lib, "[port, ['allocationprofile', 'foo'], [], []]"); | 1253 service_msg = Eval(h_lib, "[0, port, ['allocationprofile', 'foo'], [], []]"); |
1238 Service::HandleIsolateMessage(isolate, service_msg); | 1254 Service::HandleIsolateMessage(isolate, service_msg); |
1239 handler.HandleNextMessage(); | 1255 handler.HandleNextMessage(); |
1240 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); | 1256 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); |
1241 | 1257 |
1242 // Bad gc option. | 1258 // Bad gc option. |
1243 service_msg = Eval(h_lib, "[port, ['allocationprofile'], ['gc'], ['cat']]"); | 1259 service_msg = Eval(h_lib, |
| 1260 "[0, port, ['allocationprofile'], ['gc'], ['cat']]"); |
1244 Service::HandleIsolateMessage(isolate, service_msg); | 1261 Service::HandleIsolateMessage(isolate, service_msg); |
1245 handler.HandleNextMessage(); | 1262 handler.HandleNextMessage(); |
1246 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); | 1263 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); |
1247 | 1264 |
1248 // Bad reset option. | 1265 // Bad reset option. |
1249 service_msg = Eval(h_lib, "[port, ['allocationprofile'], ['reset'], ['ff']]"); | 1266 service_msg = Eval(h_lib, |
| 1267 "[0, port, ['allocationprofile'], ['reset'], ['ff']]"); |
1250 Service::HandleIsolateMessage(isolate, service_msg); | 1268 Service::HandleIsolateMessage(isolate, service_msg); |
1251 handler.HandleNextMessage(); | 1269 handler.HandleNextMessage(); |
1252 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); | 1270 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); |
1253 | 1271 |
1254 // Good reset. | 1272 // Good reset. |
1255 service_msg = | 1273 service_msg = |
1256 Eval(h_lib, "[port, ['allocationprofile'], ['reset'], ['true']]"); | 1274 Eval(h_lib, "[0, port, ['allocationprofile'], ['reset'], ['true']]"); |
1257 Service::HandleIsolateMessage(isolate, service_msg); | 1275 Service::HandleIsolateMessage(isolate, service_msg); |
1258 handler.HandleNextMessage(); | 1276 handler.HandleNextMessage(); |
1259 EXPECT_SUBSTRING("\"type\":\"AllocationProfile\"", handler.msg()); | 1277 EXPECT_SUBSTRING("\"type\":\"AllocationProfile\"", handler.msg()); |
1260 | 1278 |
1261 // Good GC. | 1279 // Good GC. |
1262 service_msg = | 1280 service_msg = |
1263 Eval(h_lib, "[port, ['allocationprofile'], ['gc'], ['full']]"); | 1281 Eval(h_lib, "[0, port, ['allocationprofile'], ['gc'], ['full']]"); |
1264 Service::HandleIsolateMessage(isolate, service_msg); | 1282 Service::HandleIsolateMessage(isolate, service_msg); |
1265 handler.HandleNextMessage(); | 1283 handler.HandleNextMessage(); |
1266 EXPECT_SUBSTRING("\"type\":\"AllocationProfile\"", handler.msg()); | 1284 EXPECT_SUBSTRING("\"type\":\"AllocationProfile\"", handler.msg()); |
1267 | 1285 |
1268 // Good GC and reset. | 1286 // Good GC and reset. |
1269 service_msg = Eval(h_lib, | 1287 service_msg = Eval(h_lib, |
1270 "[port, ['allocationprofile'], ['gc', 'reset'], ['full', 'true']]"); | 1288 "[0, port, ['allocationprofile'], ['gc', 'reset'], ['full', 'true']]"); |
1271 Service::HandleIsolateMessage(isolate, service_msg); | 1289 Service::HandleIsolateMessage(isolate, service_msg); |
1272 handler.HandleNextMessage(); | 1290 handler.HandleNextMessage(); |
1273 EXPECT_SUBSTRING("\"type\":\"AllocationProfile\"", handler.msg()); | 1291 EXPECT_SUBSTRING("\"type\":\"AllocationProfile\"", handler.msg()); |
1274 } | 1292 } |
1275 | 1293 |
1276 | 1294 |
1277 TEST_CASE(Service_HeapMap) { | 1295 TEST_CASE(Service_HeapMap) { |
1278 const char* kScript = | 1296 const char* kScript = |
1279 "var port;\n" // Set to our mock port by C++. | 1297 "var port;\n" // Set to our mock port by C++. |
1280 "\n" | 1298 "\n" |
1281 "main() {\n" | 1299 "main() {\n" |
1282 "}"; | 1300 "}"; |
1283 | 1301 |
1284 Isolate* isolate = Isolate::Current(); | 1302 Isolate* isolate = Isolate::Current(); |
1285 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 1303 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
1286 EXPECT_VALID(lib); | 1304 EXPECT_VALID(lib); |
1287 | 1305 |
1288 // Build a mock message handler and wrap it in a dart port. | 1306 // Build a mock message handler and wrap it in a dart port. |
1289 ServiceTestMessageHandler handler; | 1307 ServiceTestMessageHandler handler; |
1290 Dart_Port port_id = PortMap::CreatePort(&handler); | 1308 Dart_Port port_id = PortMap::CreatePort(&handler); |
1291 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 1309 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
1292 EXPECT_VALID(port); | 1310 EXPECT_VALID(port); |
1293 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); | 1311 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); |
1294 | 1312 |
1295 Instance& service_msg = Instance::Handle(); | 1313 Instance& service_msg = Instance::Handle(); |
1296 service_msg = Eval(lib, "[port, ['heapmap'], [], []]"); | 1314 service_msg = Eval(lib, "[0, port, ['heapmap'], [], []]"); |
1297 Service::HandleIsolateMessage(isolate, service_msg); | 1315 Service::HandleIsolateMessage(isolate, service_msg); |
1298 handler.HandleNextMessage(); | 1316 handler.HandleNextMessage(); |
1299 EXPECT_SUBSTRING("\"type\":\"HeapMap\"", handler.msg()); | 1317 EXPECT_SUBSTRING("\"type\":\"HeapMap\"", handler.msg()); |
1300 EXPECT_SUBSTRING("\"pages\":[", handler.msg()); | 1318 EXPECT_SUBSTRING("\"pages\":[", handler.msg()); |
1301 } | 1319 } |
1302 | 1320 |
1303 | 1321 |
1304 TEST_CASE(Service_Address) { | 1322 TEST_CASE(Service_Address) { |
1305 const char* kScript = | 1323 const char* kScript = |
1306 "var port;\n" // Set to our mock port by C++. | 1324 "var port;\n" // Set to our mock port by C++. |
(...skipping 14 matching lines...) Expand all Loading... |
1321 | 1339 |
1322 const String& str = String::Handle(String::New("foobar", Heap::kOld)); | 1340 const String& str = String::Handle(String::New("foobar", Heap::kOld)); |
1323 Instance& service_msg = Instance::Handle(); | 1341 Instance& service_msg = Instance::Handle(); |
1324 // Note: If we ever introduce old space compaction, this test might fail. | 1342 // Note: If we ever introduce old space compaction, this test might fail. |
1325 uword start_addr = RawObject::ToAddr(str.raw()); | 1343 uword start_addr = RawObject::ToAddr(str.raw()); |
1326 // Expect to find 'str', also from internal addresses. | 1344 // Expect to find 'str', also from internal addresses. |
1327 for (int offset = 0; offset < kObjectAlignment; ++offset) { | 1345 for (int offset = 0; offset < kObjectAlignment; ++offset) { |
1328 uword addr = start_addr + offset; | 1346 uword addr = start_addr + offset; |
1329 char buf[1024]; | 1347 char buf[1024]; |
1330 OS::SNPrint(buf, sizeof(buf), | 1348 OS::SNPrint(buf, sizeof(buf), |
1331 "[port, ['address', '%" Px "'], [], []]", addr); | 1349 "[0, port, ['address', '%" Px "'], [], []]", addr); |
1332 service_msg = Eval(lib, buf); | 1350 service_msg = Eval(lib, buf); |
1333 Service::HandleIsolateMessage(isolate, service_msg); | 1351 Service::HandleIsolateMessage(isolate, service_msg); |
1334 handler.HandleNextMessage(); | 1352 handler.HandleNextMessage(); |
1335 EXPECT_SUBSTRING("\"type\":\"@String\"", handler.msg()); | 1353 EXPECT_SUBSTRING("\"type\":\"@String\"", handler.msg()); |
1336 EXPECT_SUBSTRING("foobar", handler.msg()); | 1354 EXPECT_SUBSTRING("foobar", handler.msg()); |
1337 } | 1355 } |
1338 // Expect null when no object is found. | 1356 // Expect null when no object is found. |
1339 service_msg = Eval(lib, "[port, ['address', '7'], [], []]"); | 1357 service_msg = Eval(lib, "[0, port, ['address', '7'], [], []]"); |
1340 Service::HandleIsolateMessage(isolate, service_msg); | 1358 Service::HandleIsolateMessage(isolate, service_msg); |
1341 handler.HandleNextMessage(); | 1359 handler.HandleNextMessage(); |
1342 // TODO(turnidge): Should this be a ServiceException instead? | 1360 // TODO(turnidge): Should this be a ServiceException instead? |
1343 EXPECT_STREQ("{\"type\":\"@Null\",\"id\":\"objects\\/null\"," | 1361 EXPECT_STREQ("{\"type\":\"@Null\",\"id\":\"objects\\/null\"," |
1344 "\"valueAsString\":\"null\"}", | 1362 "\"valueAsString\":\"null\"}", |
1345 handler.msg()); | 1363 handler.msg()); |
1346 } | 1364 } |
1347 | 1365 |
1348 | 1366 |
1349 static const char* alpha_callback( | 1367 static const char* alpha_callback( |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1391 | 1409 |
1392 // Build a mock message handler and wrap it in a dart port. | 1410 // Build a mock message handler and wrap it in a dart port. |
1393 ServiceTestMessageHandler handler; | 1411 ServiceTestMessageHandler handler; |
1394 Dart_Port port_id = PortMap::CreatePort(&handler); | 1412 Dart_Port port_id = PortMap::CreatePort(&handler); |
1395 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 1413 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
1396 EXPECT_VALID(port); | 1414 EXPECT_VALID(port); |
1397 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); | 1415 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); |
1398 | 1416 |
1399 | 1417 |
1400 Instance& service_msg = Instance::Handle(); | 1418 Instance& service_msg = Instance::Handle(); |
1401 service_msg = Eval(lib, "[port, ['alpha'], [], []]"); | 1419 service_msg = Eval(lib, "[0, port, ['alpha'], [], []]"); |
1402 Service::HandleRootMessage(service_msg); | 1420 Service::HandleRootMessage(service_msg); |
1403 handler.HandleNextMessage(); | 1421 handler.HandleNextMessage(); |
1404 EXPECT_STREQ("alpha", handler.msg()); | 1422 EXPECT_STREQ("alpha", handler.msg()); |
1405 service_msg = Eval(lib, "[port, ['beta'], [], []]"); | 1423 service_msg = Eval(lib, "[0, port, ['beta'], [], []]"); |
1406 Service::HandleRootMessage(service_msg); | 1424 Service::HandleRootMessage(service_msg); |
1407 handler.HandleNextMessage(); | 1425 handler.HandleNextMessage(); |
1408 EXPECT_STREQ("beta", handler.msg()); | 1426 EXPECT_STREQ("beta", handler.msg()); |
1409 } | 1427 } |
1410 | 1428 |
1411 TEST_CASE(Service_EmbedderIsolateHandler) { | 1429 TEST_CASE(Service_EmbedderIsolateHandler) { |
1412 const char* kScript = | 1430 const char* kScript = |
1413 "var port;\n" // Set to our mock port by C++. | 1431 "var port;\n" // Set to our mock port by C++. |
1414 "\n" | 1432 "\n" |
1415 "var x = 7;\n" | 1433 "var x = 7;\n" |
(...skipping 12 matching lines...) Expand all Loading... |
1428 EXPECT_VALID(result); | 1446 EXPECT_VALID(result); |
1429 | 1447 |
1430 // Build a mock message handler and wrap it in a dart port. | 1448 // Build a mock message handler and wrap it in a dart port. |
1431 ServiceTestMessageHandler handler; | 1449 ServiceTestMessageHandler handler; |
1432 Dart_Port port_id = PortMap::CreatePort(&handler); | 1450 Dart_Port port_id = PortMap::CreatePort(&handler); |
1433 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 1451 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
1434 EXPECT_VALID(port); | 1452 EXPECT_VALID(port); |
1435 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); | 1453 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); |
1436 | 1454 |
1437 Instance& service_msg = Instance::Handle(); | 1455 Instance& service_msg = Instance::Handle(); |
1438 service_msg = Eval(lib, "[port, ['alpha'], [], []]"); | 1456 service_msg = Eval(lib, "[0, port, ['alpha'], [], []]"); |
1439 Service::HandleIsolateMessage(isolate, service_msg); | 1457 Service::HandleIsolateMessage(isolate, service_msg); |
1440 handler.HandleNextMessage(); | 1458 handler.HandleNextMessage(); |
1441 EXPECT_STREQ("alpha", handler.msg()); | 1459 EXPECT_STREQ("alpha", handler.msg()); |
1442 service_msg = Eval(lib, "[port, ['beta'], [], []]"); | 1460 service_msg = Eval(lib, "[0, port, ['beta'], [], []]"); |
1443 Service::HandleIsolateMessage(isolate, service_msg); | 1461 Service::HandleIsolateMessage(isolate, service_msg); |
1444 handler.HandleNextMessage(); | 1462 handler.HandleNextMessage(); |
1445 EXPECT_STREQ("beta", handler.msg()); | 1463 EXPECT_STREQ("beta", handler.msg()); |
1446 } | 1464 } |
1447 | 1465 |
1448 | 1466 |
1449 // TODO(zra): Remove when tests are ready to enable. | 1467 // TODO(zra): Remove when tests are ready to enable. |
1450 #if !defined(TARGET_ARCH_ARM64) | 1468 #if !defined(TARGET_ARCH_ARM64) |
1451 | 1469 |
1452 TEST_CASE(Service_Profile) { | 1470 TEST_CASE(Service_Profile) { |
(...skipping 16 matching lines...) Expand all Loading... |
1469 EXPECT_VALID(result); | 1487 EXPECT_VALID(result); |
1470 | 1488 |
1471 // Build a mock message handler and wrap it in a dart port. | 1489 // Build a mock message handler and wrap it in a dart port. |
1472 ServiceTestMessageHandler handler; | 1490 ServiceTestMessageHandler handler; |
1473 Dart_Port port_id = PortMap::CreatePort(&handler); | 1491 Dart_Port port_id = PortMap::CreatePort(&handler); |
1474 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 1492 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
1475 EXPECT_VALID(port); | 1493 EXPECT_VALID(port); |
1476 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); | 1494 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); |
1477 | 1495 |
1478 Instance& service_msg = Instance::Handle(); | 1496 Instance& service_msg = Instance::Handle(); |
1479 service_msg = Eval(h_lib, "[port, ['profile'], [], []]"); | 1497 service_msg = Eval(h_lib, "[0, port, ['profile'], [], []]"); |
1480 Service::HandleIsolateMessage(isolate, service_msg); | 1498 Service::HandleIsolateMessage(isolate, service_msg); |
1481 handler.HandleNextMessage(); | 1499 handler.HandleNextMessage(); |
1482 // Expect profile | 1500 // Expect profile |
1483 EXPECT_SUBSTRING("\"type\":\"Profile\"", handler.msg()); | 1501 EXPECT_SUBSTRING("\"type\":\"Profile\"", handler.msg()); |
1484 | 1502 |
1485 service_msg = Eval(h_lib, "[port, ['profile'], ['tags'], ['hide']]"); | 1503 service_msg = Eval(h_lib, "[0, port, ['profile'], ['tags'], ['hide']]"); |
1486 Service::HandleIsolateMessage(isolate, service_msg); | 1504 Service::HandleIsolateMessage(isolate, service_msg); |
1487 handler.HandleNextMessage(); | 1505 handler.HandleNextMessage(); |
1488 // Expect profile | 1506 // Expect profile |
1489 EXPECT_SUBSTRING("\"type\":\"Profile\"", handler.msg()); | 1507 EXPECT_SUBSTRING("\"type\":\"Profile\"", handler.msg()); |
1490 | 1508 |
1491 service_msg = Eval(h_lib, "[port, ['profile'], ['tags'], ['hidden']]"); | 1509 service_msg = Eval(h_lib, "[0, port, ['profile'], ['tags'], ['hidden']]"); |
1492 Service::HandleIsolateMessage(isolate, service_msg); | 1510 Service::HandleIsolateMessage(isolate, service_msg); |
1493 handler.HandleNextMessage(); | 1511 handler.HandleNextMessage(); |
1494 // Expect error. | 1512 // Expect error. |
1495 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); | 1513 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); |
1496 } | 1514 } |
1497 | 1515 |
1498 #endif // !defined(TARGET_ARCH_ARM64) | 1516 #endif // !defined(TARGET_ARCH_ARM64) |
1499 | 1517 |
1500 } // namespace dart | 1518 } // namespace dart |
OLD | NEW |