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

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

Issue 243973002: - Add a minimal implementation of Capability. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 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') | runtime/vm/snapshot.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 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 // TODO(zra): Remove when tests are ready to enable. 5 // TODO(zra): Remove when tests are ready to enable.
6 #include "platform/globals.h" 6 #include "platform/globals.h"
7 #if !defined(TARGET_ARCH_ARM64) 7 #if !defined(TARGET_ARCH_ARM64)
8 8
9 #include "include/dart_debugger_api.h" 9 #include "include/dart_debugger_api.h"
10 #include "vm/dart_api_impl.h" 10 #include "vm/dart_api_impl.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 "main() {\n" 160 "main() {\n"
161 "}"; 161 "}";
162 162
163 Isolate* isolate = Isolate::Current(); 163 Isolate* isolate = Isolate::Current();
164 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); 164 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
165 EXPECT_VALID(lib); 165 EXPECT_VALID(lib);
166 166
167 // Build a mock message handler and wrap it in a dart port. 167 // Build a mock message handler and wrap it in a dart port.
168 ServiceTestMessageHandler handler; 168 ServiceTestMessageHandler handler;
169 Dart_Port port_id = PortMap::CreatePort(&handler); 169 Dart_Port port_id = PortMap::CreatePort(&handler);
170 Dart_Handle port = 170 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id));
171 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id));
172 EXPECT_VALID(port); 171 EXPECT_VALID(port);
173 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); 172 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port));
174 173
175 Instance& service_msg = Instance::Handle(); 174 Instance& service_msg = Instance::Handle();
176 175
177 // Get the isolate summary. 176 // Get the isolate summary.
178 service_msg = Eval(lib, "[port, [], [], []]"); 177 service_msg = Eval(lib, "[port, [], [], []]");
179 Service::HandleIsolateMessage(isolate, service_msg); 178 Service::HandleIsolateMessage(isolate, service_msg);
180 handler.HandleNextMessage(); 179 handler.HandleNextMessage();
181 180
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 "main() {\n" 215 "main() {\n"
217 "}"; 216 "}";
218 217
219 Isolate* isolate = Isolate::Current(); 218 Isolate* isolate = Isolate::Current();
220 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); 219 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
221 EXPECT_VALID(lib); 220 EXPECT_VALID(lib);
222 221
223 // Build a mock message handler and wrap it in a dart port. 222 // Build a mock message handler and wrap it in a dart port.
224 ServiceTestMessageHandler handler; 223 ServiceTestMessageHandler handler;
225 Dart_Port port_id = PortMap::CreatePort(&handler); 224 Dart_Port port_id = PortMap::CreatePort(&handler);
226 Dart_Handle port = 225 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id));
227 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id));
228 EXPECT_VALID(port); 226 EXPECT_VALID(port);
229 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); 227 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port));
230 228
231 Instance& service_msg = Instance::Handle(); 229 Instance& service_msg = Instance::Handle();
232 230
233 // Get the stacktrace. 231 // Get the stacktrace.
234 service_msg = Eval(lib, "[port, ['stacktrace'], [], []]"); 232 service_msg = Eval(lib, "[port, ['stacktrace'], [], []]");
235 Service::HandleIsolateMessage(isolate, service_msg); 233 Service::HandleIsolateMessage(isolate, service_msg);
236 handler.HandleNextMessage(); 234 handler.HandleNextMessage();
237 EXPECT_STREQ( 235 EXPECT_STREQ(
(...skipping 19 matching lines...) Expand all
257 "main() {\n" // We set breakpoint here. 255 "main() {\n" // We set breakpoint here.
258 "}"; 256 "}";
259 257
260 Isolate* isolate = Isolate::Current(); 258 Isolate* isolate = Isolate::Current();
261 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); 259 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
262 EXPECT_VALID(lib); 260 EXPECT_VALID(lib);
263 261
264 // Build a mock message handler and wrap it in a dart port. 262 // Build a mock message handler and wrap it in a dart port.
265 ServiceTestMessageHandler handler; 263 ServiceTestMessageHandler handler;
266 Dart_Port port_id = PortMap::CreatePort(&handler); 264 Dart_Port port_id = PortMap::CreatePort(&handler);
267 Dart_Handle port = 265 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id));
268 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id));
269 EXPECT_VALID(port); 266 EXPECT_VALID(port);
270 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); 267 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port));
271 268
272 Instance& service_msg = Instance::Handle(); 269 Instance& service_msg = Instance::Handle();
273 270
274 // Add a breakpoint. 271 // Add a breakpoint.
275 const String& url = String::Handle(String::New(TestCase::url())); 272 const String& url = String::Handle(String::New(TestCase::url()));
276 isolate->debugger()->SetBreakpointAtLine(url, 3); 273 isolate->debugger()->SetBreakpointAtLine(url, 3);
277 274
278 // Get the breakpoint list. 275 // Get the breakpoint list.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 "main() {\n" 350 "main() {\n"
354 "}"; 351 "}";
355 352
356 Isolate* isolate = Isolate::Current(); 353 Isolate* isolate = Isolate::Current();
357 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); 354 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
358 EXPECT_VALID(lib); 355 EXPECT_VALID(lib);
359 356
360 // Build a mock message handler and wrap it in a dart port. 357 // Build a mock message handler and wrap it in a dart port.
361 ServiceTestMessageHandler handler; 358 ServiceTestMessageHandler handler;
362 Dart_Port port_id = PortMap::CreatePort(&handler); 359 Dart_Port port_id = PortMap::CreatePort(&handler);
363 Dart_Handle port = 360 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id));
364 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id));
365 EXPECT_VALID(port); 361 EXPECT_VALID(port);
366 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); 362 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port));
367 363
368 ObjectIdRing* ring = isolate->object_id_ring(); 364 ObjectIdRing* ring = isolate->object_id_ring();
369 const String& str = String::Handle(String::New("value")); 365 const String& str = String::Handle(String::New("value"));
370 intptr_t str_id = ring->GetIdForObject(str.raw()); 366 intptr_t str_id = ring->GetIdForObject(str.raw());
371 Dart_Handle valid_id = Dart_NewInteger(str_id); 367 Dart_Handle valid_id = Dart_NewInteger(str_id);
372 EXPECT_VALID(valid_id); 368 EXPECT_VALID(valid_id);
373 EXPECT_VALID(Dart_SetField(lib, NewString("validId"), valid_id)); 369 EXPECT_VALID(Dart_SetField(lib, NewString("validId"), valid_id));
374 370
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 for (intptr_t i = 0; i < libs.Length(); i++) { 569 for (intptr_t i = 0; i < libs.Length(); i++) {
574 if (libs.At(i) == lib.raw()) { 570 if (libs.At(i) == lib.raw()) {
575 lib_id = i; 571 lib_id = i;
576 } 572 }
577 } 573 }
578 ASSERT(lib_id > 0); 574 ASSERT(lib_id > 0);
579 575
580 // Build a mock message handler and wrap it in a dart port. 576 // Build a mock message handler and wrap it in a dart port.
581 ServiceTestMessageHandler handler; 577 ServiceTestMessageHandler handler;
582 Dart_Port port_id = PortMap::CreatePort(&handler); 578 Dart_Port port_id = PortMap::CreatePort(&handler);
583 Dart_Handle port = 579 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id));
584 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id));
585 EXPECT_VALID(port); 580 EXPECT_VALID(port);
586 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); 581 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port));
587 582
588 Instance& service_msg = Instance::Handle(); 583 Instance& service_msg = Instance::Handle();
589 584
590 // Request library. 585 // Request library.
591 service_msg = EvalF(h_lib, 586 service_msg = EvalF(h_lib,
592 "[port, ['libraries', '%" Pd "'], [], []]", lib_id); 587 "[port, ['libraries', '%" Pd "'], [], []]", lib_id);
593 Service::HandleIsolateMessage(isolate, service_msg); 588 Service::HandleIsolateMessage(isolate, service_msg);
594 handler.HandleNextMessage(); 589 handler.HandleNextMessage();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 EXPECT(!lib.IsNull()); 633 EXPECT(!lib.IsNull());
639 Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL); 634 Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL);
640 EXPECT_VALID(result); 635 EXPECT_VALID(result);
641 const Class& class_a = Class::Handle(GetClass(lib, "A")); 636 const Class& class_a = Class::Handle(GetClass(lib, "A"));
642 EXPECT(!class_a.IsNull()); 637 EXPECT(!class_a.IsNull());
643 intptr_t cid = class_a.id(); 638 intptr_t cid = class_a.id();
644 639
645 // Build a mock message handler and wrap it in a dart port. 640 // Build a mock message handler and wrap it in a dart port.
646 ServiceTestMessageHandler handler; 641 ServiceTestMessageHandler handler;
647 Dart_Port port_id = PortMap::CreatePort(&handler); 642 Dart_Port port_id = PortMap::CreatePort(&handler);
648 Dart_Handle port = 643 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id));
649 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id));
650 EXPECT_VALID(port); 644 EXPECT_VALID(port);
651 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); 645 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port));
652 646
653 Instance& service_msg = Instance::Handle(); 647 Instance& service_msg = Instance::Handle();
654 648
655 // Request an invalid class id. 649 // Request an invalid class id.
656 service_msg = Eval(h_lib, "[port, ['classes', '999999'], [], []]"); 650 service_msg = Eval(h_lib, "[port, ['classes', '999999'], [], []]");
657 Service::HandleIsolateMessage(isolate, service_msg); 651 Service::HandleIsolateMessage(isolate, service_msg);
658 handler.HandleNextMessage(); 652 handler.HandleNextMessage();
659 EXPECT_STREQ( 653 EXPECT_STREQ(
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 EXPECT(!lib.IsNull()); 773 EXPECT(!lib.IsNull());
780 Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL); 774 Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL);
781 EXPECT_VALID(result); 775 EXPECT_VALID(result);
782 const Class& class_a = Class::Handle(GetClass(lib, "A")); 776 const Class& class_a = Class::Handle(GetClass(lib, "A"));
783 EXPECT(!class_a.IsNull()); 777 EXPECT(!class_a.IsNull());
784 intptr_t cid = class_a.id(); 778 intptr_t cid = class_a.id();
785 779
786 // Build a mock message handler and wrap it in a dart port. 780 // Build a mock message handler and wrap it in a dart port.
787 ServiceTestMessageHandler handler; 781 ServiceTestMessageHandler handler;
788 Dart_Port port_id = PortMap::CreatePort(&handler); 782 Dart_Port port_id = PortMap::CreatePort(&handler);
789 Dart_Handle port = 783 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id));
790 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id));
791 EXPECT_VALID(port); 784 EXPECT_VALID(port);
792 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); 785 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port));
793 786
794 Instance& service_msg = Instance::Handle(); 787 Instance& service_msg = Instance::Handle();
795 788
796 // Request the class A over the service. 789 // Request the class A over the service.
797 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "'], [], []]", cid); 790 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "'], [], []]", cid);
798 Service::HandleIsolateMessage(isolate, service_msg); 791 Service::HandleIsolateMessage(isolate, service_msg);
799 handler.HandleNextMessage(); 792 handler.HandleNextMessage();
800 EXPECT_SUBSTRING("\"type\":\"Class\"", handler.msg()); 793 EXPECT_SUBSTRING("\"type\":\"Class\"", handler.msg());
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 EXPECT(!code_c.IsNull()); 878 EXPECT(!code_c.IsNull());
886 // Use the entry of the code object as it's reference. 879 // Use the entry of the code object as it's reference.
887 uword entry = code_c.EntryPoint(); 880 uword entry = code_c.EntryPoint();
888 int64_t compile_timestamp = code_c.compile_timestamp(); 881 int64_t compile_timestamp = code_c.compile_timestamp();
889 EXPECT_GT(code_c.Size(), 16); 882 EXPECT_GT(code_c.Size(), 16);
890 uword last = entry + code_c.Size(); 883 uword last = entry + code_c.Size();
891 884
892 // Build a mock message handler and wrap it in a dart port. 885 // Build a mock message handler and wrap it in a dart port.
893 ServiceTestMessageHandler handler; 886 ServiceTestMessageHandler handler;
894 Dart_Port port_id = PortMap::CreatePort(&handler); 887 Dart_Port port_id = PortMap::CreatePort(&handler);
895 Dart_Handle port = 888 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id));
896 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id));
897 EXPECT_VALID(port); 889 EXPECT_VALID(port);
898 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); 890 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port));
899 891
900 Instance& service_msg = Instance::Handle(); 892 Instance& service_msg = Instance::Handle();
901 893
902 // Request an invalid code object. 894 // Request an invalid code object.
903 service_msg = Eval(h_lib, "[port, ['code', '0'], [], []]"); 895 service_msg = Eval(h_lib, "[port, ['code', '0'], [], []]");
904 Service::HandleIsolateMessage(isolate, service_msg); 896 Service::HandleIsolateMessage(isolate, service_msg);
905 handler.HandleNextMessage(); 897 handler.HandleNextMessage();
906 EXPECT_STREQ( 898 EXPECT_STREQ(
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 "main() {\n" 980 "main() {\n"
989 "}"; 981 "}";
990 982
991 Isolate* isolate = Isolate::Current(); 983 Isolate* isolate = Isolate::Current();
992 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); 984 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
993 EXPECT_VALID(lib); 985 EXPECT_VALID(lib);
994 986
995 // Build a mock message handler and wrap it in a dart port. 987 // Build a mock message handler and wrap it in a dart port.
996 ServiceTestMessageHandler handler; 988 ServiceTestMessageHandler handler;
997 Dart_Port port_id = PortMap::CreatePort(&handler); 989 Dart_Port port_id = PortMap::CreatePort(&handler);
998 Dart_Handle port = 990 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id));
999 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id));
1000 EXPECT_VALID(port); 991 EXPECT_VALID(port);
1001 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); 992 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port));
1002 993
1003 Instance& service_msg = Instance::Handle(); 994 Instance& service_msg = Instance::Handle();
1004 service_msg = Eval(lib, "[port, ['vm'], [], []]"); 995 service_msg = Eval(lib, "[port, ['vm'], [], []]");
1005 996
1006 Service::HandleRootMessage(service_msg); 997 Service::HandleRootMessage(service_msg);
1007 handler.HandleNextMessage(); 998 handler.HandleNextMessage();
1008 EXPECT_SUBSTRING("\"type\":\"VM\",\"id\":\"vm\"", handler.msg()); 999 EXPECT_SUBSTRING("\"type\":\"VM\",\"id\":\"vm\"", handler.msg());
1009 EXPECT_SUBSTRING("\"architecture\"", handler.msg()); 1000 EXPECT_SUBSTRING("\"architecture\"", handler.msg());
(...skipping 10 matching lines...) Expand all
1020 "main() {\n" 1011 "main() {\n"
1021 "}"; 1012 "}";
1022 1013
1023 Isolate* isolate = Isolate::Current(); 1014 Isolate* isolate = Isolate::Current();
1024 Dart_Handle h_lib = TestCase::LoadTestScript(kScript, NULL); 1015 Dart_Handle h_lib = TestCase::LoadTestScript(kScript, NULL);
1025 EXPECT_VALID(h_lib); 1016 EXPECT_VALID(h_lib);
1026 1017
1027 // Build a mock message handler and wrap it in a dart port. 1018 // Build a mock message handler and wrap it in a dart port.
1028 ServiceTestMessageHandler handler; 1019 ServiceTestMessageHandler handler;
1029 Dart_Port port_id = PortMap::CreatePort(&handler); 1020 Dart_Port port_id = PortMap::CreatePort(&handler);
1030 Dart_Handle port = 1021 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id));
1031 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id));
1032 EXPECT_VALID(port); 1022 EXPECT_VALID(port);
1033 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); 1023 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port));
1034 1024
1035 Instance& service_msg = Instance::Handle(); 1025 Instance& service_msg = Instance::Handle();
1036 service_msg = Eval(h_lib, "[port, ['scripts', 'dart:test-lib'], [], []]"); 1026 service_msg = Eval(h_lib, "[port, ['scripts', 'dart:test-lib'], [], []]");
1037 Service::HandleIsolateMessage(isolate, service_msg); 1027 Service::HandleIsolateMessage(isolate, service_msg);
1038 handler.HandleNextMessage(); 1028 handler.HandleNextMessage();
1039 EXPECT_STREQ( 1029 EXPECT_STREQ(
1040 "{\"type\":\"Script\",\"id\":\"scripts\\/dart%3Atest-lib\"," 1030 "{\"type\":\"Script\",\"id\":\"scripts\\/dart%3Atest-lib\","
1041 "\"name\":\"dart:test-lib\",\"user_name\":\"dart:test-lib\"," 1031 "\"name\":\"dart:test-lib\",\"user_name\":\"dart:test-lib\","
(...skipping 19 matching lines...) Expand all
1061 EXPECT_VALID(h_lib); 1051 EXPECT_VALID(h_lib);
1062 Library& lib = Library::Handle(); 1052 Library& lib = Library::Handle();
1063 lib ^= Api::UnwrapHandle(h_lib); 1053 lib ^= Api::UnwrapHandle(h_lib);
1064 EXPECT(!lib.IsNull()); 1054 EXPECT(!lib.IsNull());
1065 Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL); 1055 Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL);
1066 EXPECT_VALID(result); 1056 EXPECT_VALID(result);
1067 1057
1068 // Build a mock message handler and wrap it in a dart port. 1058 // Build a mock message handler and wrap it in a dart port.
1069 ServiceTestMessageHandler handler; 1059 ServiceTestMessageHandler handler;
1070 Dart_Port port_id = PortMap::CreatePort(&handler); 1060 Dart_Port port_id = PortMap::CreatePort(&handler);
1071 Dart_Handle port = 1061 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id));
1072 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id));
1073 EXPECT_VALID(port); 1062 EXPECT_VALID(port);
1074 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); 1063 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port));
1075 1064
1076 Instance& service_msg = Instance::Handle(); 1065 Instance& service_msg = Instance::Handle();
1077 service_msg = Eval(h_lib, "[port, ['coverage'], [], []]"); 1066 service_msg = Eval(h_lib, "[port, ['coverage'], [], []]");
1078 Service::HandleIsolateMessage(isolate, service_msg); 1067 Service::HandleIsolateMessage(isolate, service_msg);
1079 handler.HandleNextMessage(); 1068 handler.HandleNextMessage();
1080 EXPECT_SUBSTRING( 1069 EXPECT_SUBSTRING(
1081 "{\"source\":\"dart:test-lib\",\"script\":{" 1070 "{\"source\":\"dart:test-lib\",\"script\":{"
1082 "\"type\":\"@Script\",\"id\":\"scripts\\/dart%3Atest-lib\"," 1071 "\"type\":\"@Script\",\"id\":\"scripts\\/dart%3Atest-lib\","
(...skipping 18 matching lines...) Expand all
1101 EXPECT_VALID(h_lib); 1090 EXPECT_VALID(h_lib);
1102 Library& lib = Library::Handle(); 1091 Library& lib = Library::Handle();
1103 lib ^= Api::UnwrapHandle(h_lib); 1092 lib ^= Api::UnwrapHandle(h_lib);
1104 EXPECT(!lib.IsNull()); 1093 EXPECT(!lib.IsNull());
1105 Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL); 1094 Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL);
1106 EXPECT_VALID(result); 1095 EXPECT_VALID(result);
1107 1096
1108 // Build a mock message handler and wrap it in a dart port. 1097 // Build a mock message handler and wrap it in a dart port.
1109 ServiceTestMessageHandler handler; 1098 ServiceTestMessageHandler handler;
1110 Dart_Port port_id = PortMap::CreatePort(&handler); 1099 Dart_Port port_id = PortMap::CreatePort(&handler);
1111 Dart_Handle port = 1100 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id));
1112 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id));
1113 EXPECT_VALID(port); 1101 EXPECT_VALID(port);
1114 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); 1102 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port));
1115 1103
1116 Instance& service_msg = Instance::Handle(); 1104 Instance& service_msg = Instance::Handle();
1117 service_msg = Eval(h_lib, "[port, ['allocationprofile'], [], []]"); 1105 service_msg = Eval(h_lib, "[port, ['allocationprofile'], [], []]");
1118 Service::HandleIsolateMessage(isolate, service_msg); 1106 Service::HandleIsolateMessage(isolate, service_msg);
1119 handler.HandleNextMessage(); 1107 handler.HandleNextMessage();
1120 EXPECT_SUBSTRING("\"type\":\"AllocationProfile\"", handler.msg()); 1108 EXPECT_SUBSTRING("\"type\":\"AllocationProfile\"", handler.msg());
1121 1109
1122 // Too long. 1110 // Too long.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 "main() {\n" 1155 "main() {\n"
1168 "}"; 1156 "}";
1169 1157
1170 Isolate* isolate = Isolate::Current(); 1158 Isolate* isolate = Isolate::Current();
1171 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); 1159 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
1172 EXPECT_VALID(lib); 1160 EXPECT_VALID(lib);
1173 1161
1174 // Build a mock message handler and wrap it in a dart port. 1162 // Build a mock message handler and wrap it in a dart port.
1175 ServiceTestMessageHandler handler; 1163 ServiceTestMessageHandler handler;
1176 Dart_Port port_id = PortMap::CreatePort(&handler); 1164 Dart_Port port_id = PortMap::CreatePort(&handler);
1177 Dart_Handle port = 1165 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id));
1178 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id));
1179 EXPECT_VALID(port); 1166 EXPECT_VALID(port);
1180 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); 1167 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port));
1181 1168
1182 Instance& service_msg = Instance::Handle(); 1169 Instance& service_msg = Instance::Handle();
1183 service_msg = Eval(lib, "[port, ['heapmap'], [], []]"); 1170 service_msg = Eval(lib, "[port, ['heapmap'], [], []]");
1184 Service::HandleIsolateMessage(isolate, service_msg); 1171 Service::HandleIsolateMessage(isolate, service_msg);
1185 handler.HandleNextMessage(); 1172 handler.HandleNextMessage();
1186 EXPECT_SUBSTRING("\"type\":\"HeapMap\"", handler.msg()); 1173 EXPECT_SUBSTRING("\"type\":\"HeapMap\"", handler.msg());
1187 EXPECT_SUBSTRING("\"pages\":[", handler.msg()); 1174 EXPECT_SUBSTRING("\"pages\":[", handler.msg());
1188 } 1175 }
1189 1176
1190 1177
1191 TEST_CASE(Service_Address) { 1178 TEST_CASE(Service_Address) {
1192 const char* kScript = 1179 const char* kScript =
1193 "var port;\n" // Set to our mock port by C++. 1180 "var port;\n" // Set to our mock port by C++.
1194 "\n" 1181 "\n"
1195 "main() {\n" 1182 "main() {\n"
1196 "}"; 1183 "}";
1197 1184
1198 Isolate* isolate = Isolate::Current(); 1185 Isolate* isolate = Isolate::Current();
1199 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); 1186 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
1200 EXPECT_VALID(lib); 1187 EXPECT_VALID(lib);
1201 1188
1202 // Build a mock message handler and wrap it in a dart port. 1189 // Build a mock message handler and wrap it in a dart port.
1203 ServiceTestMessageHandler handler; 1190 ServiceTestMessageHandler handler;
1204 Dart_Port port_id = PortMap::CreatePort(&handler); 1191 Dart_Port port_id = PortMap::CreatePort(&handler);
1205 Dart_Handle port = 1192 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id));
1206 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id));
1207 EXPECT_VALID(port); 1193 EXPECT_VALID(port);
1208 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); 1194 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port));
1209 1195
1210 const String& str = String::Handle(String::New("foobar", Heap::kOld)); 1196 const String& str = String::Handle(String::New("foobar", Heap::kOld));
1211 Instance& service_msg = Instance::Handle(); 1197 Instance& service_msg = Instance::Handle();
1212 // Note: If we ever introduce old space compaction, this test might fail. 1198 // Note: If we ever introduce old space compaction, this test might fail.
1213 uword start_addr = RawObject::ToAddr(str.raw()); 1199 uword start_addr = RawObject::ToAddr(str.raw());
1214 // Expect to find 'str', also from internal addresses. 1200 // Expect to find 'str', also from internal addresses.
1215 for (int offset = 0; offset < kObjectAlignment; ++offset) { 1201 for (int offset = 0; offset < kObjectAlignment; ++offset) {
1216 uword addr = start_addr + offset; 1202 uword addr = start_addr + offset;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 1256
1271 Isolate* isolate = Isolate::Current(); 1257 Isolate* isolate = Isolate::Current();
1272 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); 1258 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
1273 EXPECT_VALID(lib); 1259 EXPECT_VALID(lib);
1274 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); 1260 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL);
1275 EXPECT_VALID(result); 1261 EXPECT_VALID(result);
1276 1262
1277 // Build a mock message handler and wrap it in a dart port. 1263 // Build a mock message handler and wrap it in a dart port.
1278 ServiceTestMessageHandler handler; 1264 ServiceTestMessageHandler handler;
1279 Dart_Port port_id = PortMap::CreatePort(&handler); 1265 Dart_Port port_id = PortMap::CreatePort(&handler);
1280 Dart_Handle port = 1266 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id));
1281 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id));
1282 EXPECT_VALID(port); 1267 EXPECT_VALID(port);
1283 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); 1268 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port));
1284 1269
1285 1270
1286 Instance& service_msg = Instance::Handle(); 1271 Instance& service_msg = Instance::Handle();
1287 service_msg = Eval(lib, "[port, ['alpha'], [], []]"); 1272 service_msg = Eval(lib, "[port, ['alpha'], [], []]");
1288 Service::HandleRootMessage(service_msg); 1273 Service::HandleRootMessage(service_msg);
1289 handler.HandleNextMessage(); 1274 handler.HandleNextMessage();
1290 EXPECT_STREQ("alpha", handler.msg()); 1275 EXPECT_STREQ("alpha", handler.msg());
1291 service_msg = Eval(lib, "[port, ['beta'], [], []]"); 1276 service_msg = Eval(lib, "[port, ['beta'], [], []]");
(...skipping 17 matching lines...) Expand all
1309 1294
1310 Isolate* isolate = Isolate::Current(); 1295 Isolate* isolate = Isolate::Current();
1311 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); 1296 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
1312 EXPECT_VALID(lib); 1297 EXPECT_VALID(lib);
1313 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); 1298 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL);
1314 EXPECT_VALID(result); 1299 EXPECT_VALID(result);
1315 1300
1316 // Build a mock message handler and wrap it in a dart port. 1301 // Build a mock message handler and wrap it in a dart port.
1317 ServiceTestMessageHandler handler; 1302 ServiceTestMessageHandler handler;
1318 Dart_Port port_id = PortMap::CreatePort(&handler); 1303 Dart_Port port_id = PortMap::CreatePort(&handler);
1319 Dart_Handle port = 1304 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id));
1320 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id));
1321 EXPECT_VALID(port); 1305 EXPECT_VALID(port);
1322 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); 1306 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port));
1323 1307
1324 Instance& service_msg = Instance::Handle(); 1308 Instance& service_msg = Instance::Handle();
1325 service_msg = Eval(lib, "[port, ['alpha'], [], []]"); 1309 service_msg = Eval(lib, "[port, ['alpha'], [], []]");
1326 Service::HandleIsolateMessage(isolate, service_msg); 1310 Service::HandleIsolateMessage(isolate, service_msg);
1327 handler.HandleNextMessage(); 1311 handler.HandleNextMessage();
1328 EXPECT_STREQ("alpha", handler.msg()); 1312 EXPECT_STREQ("alpha", handler.msg());
1329 service_msg = Eval(lib, "[port, ['beta'], [], []]"); 1313 service_msg = Eval(lib, "[port, ['beta'], [], []]");
1330 Service::HandleIsolateMessage(isolate, service_msg); 1314 Service::HandleIsolateMessage(isolate, service_msg);
(...skipping 16 matching lines...) Expand all
1347 EXPECT_VALID(h_lib); 1331 EXPECT_VALID(h_lib);
1348 Library& lib = Library::Handle(); 1332 Library& lib = Library::Handle();
1349 lib ^= Api::UnwrapHandle(h_lib); 1333 lib ^= Api::UnwrapHandle(h_lib);
1350 EXPECT(!lib.IsNull()); 1334 EXPECT(!lib.IsNull());
1351 Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL); 1335 Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL);
1352 EXPECT_VALID(result); 1336 EXPECT_VALID(result);
1353 1337
1354 // Build a mock message handler and wrap it in a dart port. 1338 // Build a mock message handler and wrap it in a dart port.
1355 ServiceTestMessageHandler handler; 1339 ServiceTestMessageHandler handler;
1356 Dart_Port port_id = PortMap::CreatePort(&handler); 1340 Dart_Port port_id = PortMap::CreatePort(&handler);
1357 Dart_Handle port = 1341 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id));
1358 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id));
1359 EXPECT_VALID(port); 1342 EXPECT_VALID(port);
1360 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); 1343 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port));
1361 1344
1362 Instance& service_msg = Instance::Handle(); 1345 Instance& service_msg = Instance::Handle();
1363 service_msg = Eval(h_lib, "[port, ['profile'], [], []]"); 1346 service_msg = Eval(h_lib, "[port, ['profile'], [], []]");
1364 Service::HandleIsolateMessage(isolate, service_msg); 1347 Service::HandleIsolateMessage(isolate, service_msg);
1365 handler.HandleNextMessage(); 1348 handler.HandleNextMessage();
1366 // Expect profile 1349 // Expect profile
1367 EXPECT_SUBSTRING("\"type\":\"Profile\"", handler.msg()); 1350 EXPECT_SUBSTRING("\"type\":\"Profile\"", handler.msg());
1368 1351
1369 service_msg = Eval(h_lib, "[port, ['profile'], ['tags'], ['hide']]"); 1352 service_msg = Eval(h_lib, "[port, ['profile'], ['tags'], ['hide']]");
1370 Service::HandleIsolateMessage(isolate, service_msg); 1353 Service::HandleIsolateMessage(isolate, service_msg);
1371 handler.HandleNextMessage(); 1354 handler.HandleNextMessage();
1372 // Expect profile 1355 // Expect profile
1373 EXPECT_SUBSTRING("\"type\":\"Profile\"", handler.msg()); 1356 EXPECT_SUBSTRING("\"type\":\"Profile\"", handler.msg());
1374 1357
1375 service_msg = Eval(h_lib, "[port, ['profile'], ['tags'], ['hidden']]"); 1358 service_msg = Eval(h_lib, "[port, ['profile'], ['tags'], ['hidden']]");
1376 Service::HandleIsolateMessage(isolate, service_msg); 1359 Service::HandleIsolateMessage(isolate, service_msg);
1377 handler.HandleNextMessage(); 1360 handler.HandleNextMessage();
1378 // Expect error. 1361 // Expect error.
1379 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); 1362 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg());
1380 } 1363 }
1381 1364
1382 } // namespace dart 1365 } // namespace dart
1383 1366
1384 #endif // !defined(TARGET_ARCH_ARM64) 1367 #endif // !defined(TARGET_ARCH_ARM64)
OLDNEW
« no previous file with comments | « runtime/vm/service.cc ('k') | runtime/vm/snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698