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

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

Issue 263803009: Retained size for instance in Observatory. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/service.cc ('k') | no next file » | 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) 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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 EXPECT_VALID(lib); 353 EXPECT_VALID(lib);
354 354
355 // Build a mock message handler and wrap it in a dart port. 355 // Build a mock message handler and wrap it in a dart port.
356 ServiceTestMessageHandler handler; 356 ServiceTestMessageHandler handler;
357 Dart_Port port_id = PortMap::CreatePort(&handler); 357 Dart_Port port_id = PortMap::CreatePort(&handler);
358 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); 358 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id));
359 EXPECT_VALID(port); 359 EXPECT_VALID(port);
360 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); 360 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port));
361 361
362 ObjectIdRing* ring = isolate->object_id_ring(); 362 ObjectIdRing* ring = isolate->object_id_ring();
363 const String& str = String::Handle(String::New("value")); 363 const Array& arr = Array::Handle(Array::New(1, Heap::kOld));
364 intptr_t str_id = ring->GetIdForObject(str.raw()); 364 {
365 Dart_Handle valid_id = Dart_NewInteger(str_id); 365 HANDLESCOPE(isolate);
366 const String& str = String::Handle(String::New("value", Heap::kOld));
367 arr.SetAt(0, str);
368 }
369 intptr_t arr_id = ring->GetIdForObject(arr.raw());
370 Dart_Handle valid_id = Dart_NewInteger(arr_id);
366 EXPECT_VALID(valid_id); 371 EXPECT_VALID(valid_id);
367 EXPECT_VALID(Dart_SetField(lib, NewString("validId"), valid_id)); 372 EXPECT_VALID(Dart_SetField(lib, NewString("validId"), valid_id));
368 373
369 Instance& service_msg = Instance::Handle(); 374 Instance& service_msg = Instance::Handle();
370 375
371 // null 376 // null
372 service_msg = Eval(lib, "[port, ['objects', 'null'], [], []]"); 377 service_msg = Eval(lib, "[port, ['objects', 'null'], [], []]");
373 Service::HandleIsolateMessage(isolate, service_msg); 378 Service::HandleIsolateMessage(isolate, service_msg);
374 handler.HandleNextMessage(); 379 handler.HandleNextMessage();
375 handler.filterMsg("name"); 380 handler.filterMsg("name");
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 handler.msg()); 459 handler.msg());
455 460
456 // object id ring / valid 461 // object id ring / valid
457 service_msg = Eval(lib, "[port, ['objects', '$validId'], [], []]"); 462 service_msg = Eval(lib, "[port, ['objects', '$validId'], [], []]");
458 Service::HandleIsolateMessage(isolate, service_msg); 463 Service::HandleIsolateMessage(isolate, service_msg);
459 handler.HandleNextMessage(); 464 handler.HandleNextMessage();
460 handler.filterMsg("name"); 465 handler.filterMsg("name");
461 handler.filterMsg("size"); 466 handler.filterMsg("size");
462 handler.filterMsg("id"); 467 handler.filterMsg("id");
463 EXPECT_STREQ( 468 EXPECT_STREQ(
464 "{\"type\":\"String\"," 469 "{\"type\":\"Array\","
465 "\"class\":{\"type\":\"@Class\"," 470 "\"class\":{\"type\":\"@Class\",\"user_name\":\"_List\"},"
466 "\"user_name\":\"_OneByteString\"},\"fields\":[]," 471 "\"fields\":[],"
467 "\"valueAsString\":\"\\\"value\\\"\"}", 472 "\"length\":1,"
473 "\"elements\":[{"
474 "\"index\":0,"
475 "\"value\":{\"type\":\"@String\","
476 "\"class\":{\"type\":\"@Class\",\"user_name\":\"_OneByteString\"},"
477 "\"valueAsString\":\"\\\"value\\\"\"}}]}",
468 handler.msg()); 478 handler.msg());
469 479
470 // object id ring / invalid => expired 480 // object id ring / invalid => expired
471 service_msg = Eval(lib, "[port, ['objects', '99999999'], [], []]"); 481 service_msg = Eval(lib, "[port, ['objects', '99999999'], [], []]");
472 Service::HandleIsolateMessage(isolate, service_msg); 482 Service::HandleIsolateMessage(isolate, service_msg);
473 handler.HandleNextMessage(); 483 handler.HandleNextMessage();
474 handler.filterMsg("name"); 484 handler.filterMsg("name");
475 EXPECT_STREQ( 485 EXPECT_STREQ(
476 "{\"type\":\"Null\",\"id\":\"objects\\/expired\"," 486 "{\"type\":\"Null\",\"id\":\"objects\\/expired\","
477 "\"valueAsString\":\"<expired>\"}", 487 "\"valueAsString\":\"<expired>\"}",
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 "['expr'], ['this+99']]"); 545 "['expr'], ['this+99']]");
536 Service::HandleIsolateMessage(isolate, service_msg); 546 Service::HandleIsolateMessage(isolate, service_msg);
537 handler.HandleNextMessage(); 547 handler.HandleNextMessage();
538 handler.filterMsg("name"); 548 handler.filterMsg("name");
539 EXPECT_STREQ( 549 EXPECT_STREQ(
540 "{\"type\":\"Error\",\"id\":\"\"," 550 "{\"type\":\"Error\",\"id\":\"\","
541 "\"message\":\"expected at most 3 arguments but found 4\\n\"," 551 "\"message\":\"expected at most 3 arguments but found 4\\n\","
542 "\"request\":{\"arguments\":[\"objects\",\"int-123\",\"eval\",\"foo\"]," 552 "\"request\":{\"arguments\":[\"objects\",\"int-123\",\"eval\",\"foo\"],"
543 "\"option_keys\":[\"expr\"],\"option_values\":[\"this+99\"]}}", 553 "\"option_keys\":[\"expr\"],\"option_values\":[\"this+99\"]}}",
544 handler.msg()); 554 handler.msg());
555
556 // Retained by single instance.
557 service_msg = Eval(lib,
558 "[port, ['objects', '$validId', 'retained'], [], []]");
559 Service::HandleIsolateMessage(isolate, service_msg);
560 handler.HandleNextMessage();
561 handler.filterMsg("name");
562 ExpectSubstringF(handler.msg(),
563 "\"id\":\"objects\\/int-%" Pd "\"",
564 arr.raw()->Size() + arr.At(0)->Size());
545 } 565 }
546 566
547 567
548 TEST_CASE(Service_Libraries) { 568 TEST_CASE(Service_Libraries) {
549 const char* kScript = 569 const char* kScript =
550 "var port;\n" // Set to our mock port by C++. 570 "var port;\n" // Set to our mock port by C++.
551 "var libVar = 54321;\n" 571 "var libVar = 54321;\n"
552 "\n" 572 "\n"
553 "main() {\n" 573 "main() {\n"
554 "}"; 574 "}";
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 service_msg = Eval(h_lib, "[port, ['profile'], ['tags'], ['hidden']]"); 1390 service_msg = Eval(h_lib, "[port, ['profile'], ['tags'], ['hidden']]");
1371 Service::HandleIsolateMessage(isolate, service_msg); 1391 Service::HandleIsolateMessage(isolate, service_msg);
1372 handler.HandleNextMessage(); 1392 handler.HandleNextMessage();
1373 // Expect error. 1393 // Expect error.
1374 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); 1394 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg());
1375 } 1395 }
1376 1396
1377 #endif // !defined(TARGET_ARCH_ARM64) 1397 #endif // !defined(TARGET_ARCH_ARM64)
1378 1398
1379 } // namespace dart 1399 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698