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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 _msg = new_msg; | 82 _msg = new_msg; |
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 RawArray* Eval(Dart_Handle lib, const char* expr) { |
93 Dart_Handle expr_val = Dart_EvaluateExpr(lib, NewString(expr)); | 93 Dart_Handle expr_val = Dart_EvaluateExpr(lib, NewString(expr)); |
94 EXPECT_VALID(expr_val); | 94 EXPECT_VALID(expr_val); |
95 Isolate* isolate = Isolate::Current(); | 95 Isolate* isolate = Isolate::Current(); |
96 const GrowableObjectArray& value = | 96 const GrowableObjectArray& value = |
97 Api::UnwrapGrowableObjectArrayHandle(isolate, expr_val); | 97 Api::UnwrapGrowableObjectArrayHandle(isolate, expr_val); |
98 const Array& result = Array::Handle(Array::MakeArray(value)); | 98 const Array& result = Array::Handle(Array::MakeArray(value)); |
99 GrowableObjectArray& growable = GrowableObjectArray::Handle(); | 99 GrowableObjectArray& growable = GrowableObjectArray::Handle(); |
100 growable ^= result.At(3); | 100 growable ^= result.At(3); |
101 Array& array = Array::Handle(Array::MakeArray(growable)); | 101 Array& array = Array::Handle(Array::MakeArray(growable)); |
102 result.SetAt(3, array); | 102 result.SetAt(3, array); |
103 growable ^= result.At(4); | 103 growable ^= result.At(4); |
104 array = Array::MakeArray(growable); | 104 array = Array::MakeArray(growable); |
105 result.SetAt(4, array); | 105 result.SetAt(4, array); |
106 return result.raw(); | 106 return result.raw(); |
107 } | 107 } |
108 | 108 |
109 | 109 |
110 static RawInstance* EvalF(Dart_Handle lib, const char* fmt, ...) { | 110 static RawArray* EvalF(Dart_Handle lib, const char* fmt, ...) { |
111 Isolate* isolate = Isolate::Current(); | 111 Isolate* isolate = Isolate::Current(); |
112 | 112 |
113 va_list args; | 113 va_list args; |
114 va_start(args, fmt); | 114 va_start(args, fmt); |
115 intptr_t len = OS::VSNPrint(NULL, 0, fmt, args); | 115 intptr_t len = OS::VSNPrint(NULL, 0, fmt, args); |
116 va_end(args); | 116 va_end(args); |
117 | 117 |
118 char* buffer = isolate->current_zone()->Alloc<char>(len + 1); | 118 char* buffer = isolate->current_zone()->Alloc<char>(len + 1); |
119 va_list args2; | 119 va_list args2; |
120 va_start(args2, fmt); | 120 va_start(args2, fmt); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 174 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
175 EXPECT_VALID(lib); | 175 EXPECT_VALID(lib); |
176 | 176 |
177 // 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. |
178 ServiceTestMessageHandler handler; | 178 ServiceTestMessageHandler handler; |
179 Dart_Port port_id = PortMap::CreatePort(&handler); | 179 Dart_Port port_id = PortMap::CreatePort(&handler); |
180 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 180 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
181 EXPECT_VALID(port); | 181 EXPECT_VALID(port); |
182 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); | 182 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); |
183 | 183 |
184 Instance& service_msg = Instance::Handle(); | 184 Array& service_msg = Array::Handle(); |
185 | 185 |
186 // Get the isolate summary. | 186 // Get the isolate summary. |
187 service_msg = Eval(lib, "[0, port, [], [], []]"); | 187 service_msg = Eval(lib, "[0, port, [], [], []]"); |
188 Service::HandleIsolateMessage(isolate, service_msg); | 188 Service::HandleIsolateMessage(isolate, service_msg); |
189 handler.HandleNextMessage(); | 189 handler.HandleNextMessage(); |
190 | 190 |
191 JSONReader reader(handler.msg()); | 191 JSONReader reader(handler.msg()); |
192 | 192 |
193 const int kBufferSize = 128; | 193 const int kBufferSize = 128; |
194 char buffer[kBufferSize]; | 194 char buffer[kBufferSize]; |
(...skipping 30 matching lines...) Expand all Loading... |
225 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 225 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
226 EXPECT_VALID(lib); | 226 EXPECT_VALID(lib); |
227 | 227 |
228 // Build a mock message handler and wrap it in a dart port. | 228 // Build a mock message handler and wrap it in a dart port. |
229 ServiceTestMessageHandler handler; | 229 ServiceTestMessageHandler handler; |
230 Dart_Port port_id = PortMap::CreatePort(&handler); | 230 Dart_Port port_id = PortMap::CreatePort(&handler); |
231 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 231 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
232 EXPECT_VALID(port); | 232 EXPECT_VALID(port); |
233 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); | 233 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); |
234 | 234 |
235 Instance& service_msg = Instance::Handle(); | 235 Array& service_msg = Array::Handle(); |
236 | 236 |
237 // Get the stacktrace. | 237 // Get the stacktrace. |
238 service_msg = Eval(lib, "[0, port, ['stacktrace'], [], []]"); | 238 service_msg = Eval(lib, "[0, port, ['stacktrace'], [], []]"); |
239 Service::HandleIsolateMessage(isolate, service_msg); | 239 Service::HandleIsolateMessage(isolate, service_msg); |
240 handler.HandleNextMessage(); | 240 handler.HandleNextMessage(); |
241 EXPECT_STREQ( | 241 EXPECT_STREQ( |
242 "{\"type\":\"StackTrace\",\"id\":\"stacktrace\",\"members\":[]}", | 242 "{\"type\":\"StackTrace\",\"id\":\"stacktrace\",\"members\":[]}", |
243 handler.msg()); | 243 handler.msg()); |
244 | 244 |
245 // Malformed request. | 245 // Malformed request. |
(...skipping 19 matching lines...) Expand all Loading... |
265 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 265 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
266 EXPECT_VALID(lib); | 266 EXPECT_VALID(lib); |
267 | 267 |
268 // Build a mock message handler and wrap it in a dart port. | 268 // Build a mock message handler and wrap it in a dart port. |
269 ServiceTestMessageHandler handler; | 269 ServiceTestMessageHandler handler; |
270 Dart_Port port_id = PortMap::CreatePort(&handler); | 270 Dart_Port port_id = PortMap::CreatePort(&handler); |
271 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 271 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
272 EXPECT_VALID(port); | 272 EXPECT_VALID(port); |
273 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); | 273 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); |
274 | 274 |
275 Instance& service_msg = Instance::Handle(); | 275 Array& service_msg = Array::Handle(); |
276 | 276 |
277 // Add a breakpoint. | 277 // Add a breakpoint. |
278 const String& url = String::Handle(String::New(TestCase::url())); | 278 const String& url = String::Handle(String::New(TestCase::url())); |
279 isolate->debugger()->SetBreakpointAtLine(url, 3); | 279 isolate->debugger()->SetBreakpointAtLine(url, 3); |
280 | 280 |
281 // Get the breakpoint list. | 281 // Get the breakpoint list. |
282 service_msg = Eval(lib, "[0, port, ['debug', 'breakpoints'], [], []]"); | 282 service_msg = Eval(lib, "[0, port, ['debug', 'breakpoints'], [], []]"); |
283 Service::HandleIsolateMessage(isolate, service_msg); | 283 Service::HandleIsolateMessage(isolate, service_msg); |
284 handler.HandleNextMessage(); | 284 handler.HandleNextMessage(); |
285 EXPECT_STREQ( | 285 EXPECT_STREQ( |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 { | 373 { |
374 HANDLESCOPE(isolate); | 374 HANDLESCOPE(isolate); |
375 const String& str = String::Handle(String::New("value", Heap::kOld)); | 375 const String& str = String::Handle(String::New("value", Heap::kOld)); |
376 arr.SetAt(0, str); | 376 arr.SetAt(0, str); |
377 } | 377 } |
378 intptr_t arr_id = ring->GetIdForObject(arr.raw()); | 378 intptr_t arr_id = ring->GetIdForObject(arr.raw()); |
379 Dart_Handle valid_id = Dart_NewInteger(arr_id); | 379 Dart_Handle valid_id = Dart_NewInteger(arr_id); |
380 EXPECT_VALID(valid_id); | 380 EXPECT_VALID(valid_id); |
381 EXPECT_VALID(Dart_SetField(lib, NewString("validId"), valid_id)); | 381 EXPECT_VALID(Dart_SetField(lib, NewString("validId"), valid_id)); |
382 | 382 |
383 Instance& service_msg = Instance::Handle(); | 383 Array& service_msg = Array::Handle(); |
384 | 384 |
385 // null | 385 // null |
386 service_msg = Eval(lib, "[0, port, ['objects', 'null'], [], []]"); | 386 service_msg = Eval(lib, "[0, port, ['objects', 'null'], [], []]"); |
387 Service::HandleIsolateMessage(isolate, service_msg); | 387 Service::HandleIsolateMessage(isolate, service_msg); |
388 handler.HandleNextMessage(); | 388 handler.HandleNextMessage(); |
389 handler.filterMsg("name"); | 389 handler.filterMsg("name"); |
390 EXPECT_STREQ( | 390 EXPECT_STREQ( |
391 "{\"type\":\"Null\",\"id\":\"objects\\/null\"," | 391 "{\"type\":\"Null\",\"id\":\"objects\\/null\"," |
392 "\"valueAsString\":\"null\"}", | 392 "\"valueAsString\":\"null\"}", |
393 handler.msg()); | 393 handler.msg()); |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 } | 634 } |
635 ASSERT(lib_id > 0); | 635 ASSERT(lib_id > 0); |
636 | 636 |
637 // Build a mock message handler and wrap it in a dart port. | 637 // Build a mock message handler and wrap it in a dart port. |
638 ServiceTestMessageHandler handler; | 638 ServiceTestMessageHandler handler; |
639 Dart_Port port_id = PortMap::CreatePort(&handler); | 639 Dart_Port port_id = PortMap::CreatePort(&handler); |
640 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 640 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
641 EXPECT_VALID(port); | 641 EXPECT_VALID(port); |
642 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); | 642 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); |
643 | 643 |
644 Instance& service_msg = Instance::Handle(); | 644 Array& service_msg = Array::Handle(); |
645 | 645 |
646 // Request library. | 646 // Request library. |
647 service_msg = EvalF(h_lib, | 647 service_msg = EvalF(h_lib, |
648 "[0, port, ['libraries', '%" Pd "'], [], []]", lib_id); | 648 "[0, port, ['libraries', '%" Pd "'], [], []]", lib_id); |
649 Service::HandleIsolateMessage(isolate, service_msg); | 649 Service::HandleIsolateMessage(isolate, service_msg); |
650 handler.HandleNextMessage(); | 650 handler.HandleNextMessage(); |
651 EXPECT_SUBSTRING("\"type\":\"Library\"", handler.msg()); | 651 EXPECT_SUBSTRING("\"type\":\"Library\"", handler.msg()); |
652 EXPECT_SUBSTRING("\"url\":\"test-lib\"", handler.msg()); | 652 EXPECT_SUBSTRING("\"url\":\"test-lib\"", handler.msg()); |
653 | 653 |
654 // Evaluate an expression from a library. | 654 // Evaluate an expression from a library. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 EXPECT(!class_a.IsNull()); | 700 EXPECT(!class_a.IsNull()); |
701 intptr_t cid = class_a.id(); | 701 intptr_t cid = class_a.id(); |
702 | 702 |
703 // Build a mock message handler and wrap it in a dart port. | 703 // Build a mock message handler and wrap it in a dart port. |
704 ServiceTestMessageHandler handler; | 704 ServiceTestMessageHandler handler; |
705 Dart_Port port_id = PortMap::CreatePort(&handler); | 705 Dart_Port port_id = PortMap::CreatePort(&handler); |
706 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 706 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
707 EXPECT_VALID(port); | 707 EXPECT_VALID(port); |
708 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); | 708 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); |
709 | 709 |
710 Instance& service_msg = Instance::Handle(); | 710 Array& service_msg = Array::Handle(); |
711 | 711 |
712 // Request an invalid class id. | 712 // Request an invalid class id. |
713 service_msg = Eval(h_lib, "[0, port, ['classes', '999999'], [], []]"); | 713 service_msg = Eval(h_lib, "[0, port, ['classes', '999999'], [], []]"); |
714 Service::HandleIsolateMessage(isolate, service_msg); | 714 Service::HandleIsolateMessage(isolate, service_msg); |
715 handler.HandleNextMessage(); | 715 handler.HandleNextMessage(); |
716 EXPECT_STREQ( | 716 EXPECT_STREQ( |
717 "{\"type\":\"Error\",\"id\":\"\"," | 717 "{\"type\":\"Error\",\"id\":\"\"," |
718 "\"message\":\"999999 is not a valid class id.\"," | 718 "\"message\":\"999999 is not a valid class id.\"," |
719 "\"request\":{\"arguments\":[\"classes\",\"999999\"]," | 719 "\"request\":{\"arguments\":[\"classes\",\"999999\"]," |
720 "\"option_keys\":[],\"option_values\":[]}}", handler.msg()); | 720 "\"option_keys\":[],\"option_values\":[]}}", handler.msg()); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
883 EXPECT(!class_a.IsNull()); | 883 EXPECT(!class_a.IsNull()); |
884 intptr_t cid = class_a.id(); | 884 intptr_t cid = class_a.id(); |
885 | 885 |
886 // Build a mock message handler and wrap it in a dart port. | 886 // Build a mock message handler and wrap it in a dart port. |
887 ServiceTestMessageHandler handler; | 887 ServiceTestMessageHandler handler; |
888 Dart_Port port_id = PortMap::CreatePort(&handler); | 888 Dart_Port port_id = PortMap::CreatePort(&handler); |
889 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 889 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
890 EXPECT_VALID(port); | 890 EXPECT_VALID(port); |
891 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); | 891 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); |
892 | 892 |
893 Instance& service_msg = Instance::Handle(); | 893 Array& service_msg = Array::Handle(); |
894 | 894 |
895 // Request the class A over the service. | 895 // Request the class A over the service. |
896 service_msg = EvalF(h_lib, "[0, port, ['classes', '%" Pd "'], [], []]", cid); | 896 service_msg = EvalF(h_lib, "[0, port, ['classes', '%" Pd "'], [], []]", cid); |
897 Service::HandleIsolateMessage(isolate, service_msg); | 897 Service::HandleIsolateMessage(isolate, service_msg); |
898 handler.HandleNextMessage(); | 898 handler.HandleNextMessage(); |
899 EXPECT_SUBSTRING("\"type\":\"Class\"", handler.msg()); | 899 EXPECT_SUBSTRING("\"type\":\"Class\"", handler.msg()); |
900 EXPECT_SUBSTRING("\"name\":\"A\"", handler.msg()); | 900 EXPECT_SUBSTRING("\"name\":\"A\"", handler.msg()); |
901 ExpectSubstringF(handler.msg(), | 901 ExpectSubstringF(handler.msg(), |
902 "\"id\":\"classes\\/%" Pd "\"", cid); | 902 "\"id\":\"classes\\/%" Pd "\"", cid); |
903 | 903 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
989 EXPECT_GT(code_c.Size(), 16); | 989 EXPECT_GT(code_c.Size(), 16); |
990 uword last = entry + code_c.Size(); | 990 uword last = entry + code_c.Size(); |
991 | 991 |
992 // Build a mock message handler and wrap it in a dart port. | 992 // Build a mock message handler and wrap it in a dart port. |
993 ServiceTestMessageHandler handler; | 993 ServiceTestMessageHandler handler; |
994 Dart_Port port_id = PortMap::CreatePort(&handler); | 994 Dart_Port port_id = PortMap::CreatePort(&handler); |
995 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 995 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
996 EXPECT_VALID(port); | 996 EXPECT_VALID(port); |
997 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); | 997 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); |
998 | 998 |
999 Instance& service_msg = Instance::Handle(); | 999 Array& service_msg = Array::Handle(); |
1000 | 1000 |
1001 // Request an invalid code object. | 1001 // Request an invalid code object. |
1002 service_msg = Eval(h_lib, "[0, port, ['code', '0'], [], []]"); | 1002 service_msg = Eval(h_lib, "[0, port, ['code', '0'], [], []]"); |
1003 Service::HandleIsolateMessage(isolate, service_msg); | 1003 Service::HandleIsolateMessage(isolate, service_msg); |
1004 handler.HandleNextMessage(); | 1004 handler.HandleNextMessage(); |
1005 EXPECT_STREQ( | 1005 EXPECT_STREQ( |
1006 "{\"type\":\"Error\",\"id\":\"\",\"message\":\"Malformed code id: 0\"," | 1006 "{\"type\":\"Error\",\"id\":\"\",\"message\":\"Malformed code id: 0\"," |
1007 "\"request\":{\"arguments\":[\"code\",\"0\"]," | 1007 "\"request\":{\"arguments\":[\"code\",\"0\"]," |
1008 "\"option_keys\":[],\"option_values\":[]}}", handler.msg()); | 1008 "\"option_keys\":[],\"option_values\":[]}}", handler.msg()); |
1009 | 1009 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1093 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 1093 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
1094 EXPECT_VALID(lib); | 1094 EXPECT_VALID(lib); |
1095 | 1095 |
1096 // Build a mock message handler and wrap it in a dart port. | 1096 // Build a mock message handler and wrap it in a dart port. |
1097 ServiceTestMessageHandler handler; | 1097 ServiceTestMessageHandler handler; |
1098 Dart_Port port_id = PortMap::CreatePort(&handler); | 1098 Dart_Port port_id = PortMap::CreatePort(&handler); |
1099 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 1099 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
1100 EXPECT_VALID(port); | 1100 EXPECT_VALID(port); |
1101 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); | 1101 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); |
1102 | 1102 |
1103 Instance& service_msg = Instance::Handle(); | 1103 Array& service_msg = Array::Handle(); |
1104 service_msg = Eval(lib, "[0, port, ['vm'], [], []]"); | 1104 service_msg = Eval(lib, "[0, port, ['vm'], [], []]"); |
1105 | 1105 |
1106 Service::HandleRootMessage(service_msg); | 1106 Service::HandleRootMessage(service_msg); |
1107 handler.HandleNextMessage(); | 1107 handler.HandleNextMessage(); |
1108 EXPECT_SUBSTRING("\"type\":\"VM\",\"id\":\"vm\"", handler.msg()); | 1108 EXPECT_SUBSTRING("\"type\":\"VM\",\"id\":\"vm\"", handler.msg()); |
1109 EXPECT_SUBSTRING("\"targetCPU\"", handler.msg()); | 1109 EXPECT_SUBSTRING("\"targetCPU\"", handler.msg()); |
1110 EXPECT_SUBSTRING("\"hostCPU\"", handler.msg()); | 1110 EXPECT_SUBSTRING("\"hostCPU\"", handler.msg()); |
1111 EXPECT_SUBSTRING("\"version\"", handler.msg()); | 1111 EXPECT_SUBSTRING("\"version\"", handler.msg()); |
1112 EXPECT_SUBSTRING("\"uptime\"", handler.msg()); | 1112 EXPECT_SUBSTRING("\"uptime\"", handler.msg()); |
1113 EXPECT_SUBSTRING("\"isolates\"", handler.msg()); | 1113 EXPECT_SUBSTRING("\"isolates\"", handler.msg()); |
(...skipping 11 matching lines...) Expand all Loading... |
1125 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 1125 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
1126 EXPECT_VALID(lib); | 1126 EXPECT_VALID(lib); |
1127 | 1127 |
1128 // Build a mock message handler and wrap it in a dart port. | 1128 // Build a mock message handler and wrap it in a dart port. |
1129 ServiceTestMessageHandler handler; | 1129 ServiceTestMessageHandler handler; |
1130 Dart_Port port_id = PortMap::CreatePort(&handler); | 1130 Dart_Port port_id = PortMap::CreatePort(&handler); |
1131 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 1131 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
1132 EXPECT_VALID(port); | 1132 EXPECT_VALID(port); |
1133 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); | 1133 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); |
1134 | 1134 |
1135 Instance& service_msg = Instance::Handle(); | 1135 Array& service_msg = Array::Handle(); |
1136 service_msg = Eval(lib, "[0, port, ['flags'], [], []]"); | 1136 service_msg = Eval(lib, "[0, port, ['flags'], [], []]"); |
1137 | 1137 |
1138 // Make sure we can get the FlagList. | 1138 // Make sure we can get the FlagList. |
1139 Service::HandleRootMessage(service_msg); | 1139 Service::HandleRootMessage(service_msg); |
1140 handler.HandleNextMessage(); | 1140 handler.HandleNextMessage(); |
1141 EXPECT_SUBSTRING("\"type\":\"FlagList\",\"id\":\"flags\"", handler.msg()); | 1141 EXPECT_SUBSTRING("\"type\":\"FlagList\",\"id\":\"flags\"", handler.msg()); |
1142 EXPECT_SUBSTRING( | 1142 EXPECT_SUBSTRING( |
1143 "\"name\":\"service_testing_flag\",\"comment\":\"Comment\"," | 1143 "\"name\":\"service_testing_flag\",\"comment\":\"Comment\"," |
1144 "\"flagType\":\"bool\",\"valueAsString\":\"false\"", | 1144 "\"flagType\":\"bool\",\"valueAsString\":\"false\"", |
1145 handler.msg()); | 1145 handler.msg()); |
(...skipping 28 matching lines...) Expand all Loading... |
1174 Dart_Handle h_lib = TestCase::LoadTestScript(kScript, NULL); | 1174 Dart_Handle h_lib = TestCase::LoadTestScript(kScript, NULL); |
1175 EXPECT_VALID(h_lib); | 1175 EXPECT_VALID(h_lib); |
1176 | 1176 |
1177 // Build a mock message handler and wrap it in a dart port. | 1177 // Build a mock message handler and wrap it in a dart port. |
1178 ServiceTestMessageHandler handler; | 1178 ServiceTestMessageHandler handler; |
1179 Dart_Port port_id = PortMap::CreatePort(&handler); | 1179 Dart_Port port_id = PortMap::CreatePort(&handler); |
1180 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 1180 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
1181 EXPECT_VALID(port); | 1181 EXPECT_VALID(port); |
1182 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); | 1182 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); |
1183 | 1183 |
1184 Instance& service_msg = Instance::Handle(); | 1184 Array& service_msg = Array::Handle(); |
1185 service_msg = Eval(h_lib, "[0, port, ['scripts', 'test-lib'], [], []]"); | 1185 service_msg = Eval(h_lib, "[0, port, ['scripts', 'test-lib'], [], []]"); |
1186 Service::HandleIsolateMessage(isolate, service_msg); | 1186 Service::HandleIsolateMessage(isolate, service_msg); |
1187 handler.HandleNextMessage(); | 1187 handler.HandleNextMessage(); |
1188 EXPECT_STREQ( | 1188 EXPECT_STREQ( |
1189 "{\"type\":\"Script\",\"id\":\"scripts\\/test-lib\"," | 1189 "{\"type\":\"Script\",\"id\":\"scripts\\/test-lib\"," |
1190 "\"name\":\"test-lib\",\"user_name\":\"test-lib\"," | 1190 "\"name\":\"test-lib\",\"user_name\":\"test-lib\"," |
1191 "\"kind\":\"script\"," | 1191 "\"kind\":\"script\"," |
1192 "\"source\":\"var port;\\n\\nmain() {\\n}\"," | 1192 "\"source\":\"var port;\\n\\nmain() {\\n}\"," |
1193 "\"tokenPosTable\":[[1,0,1,1,5,2,9],[3,5,1,6,5,7,6,8,8],[4,10,1]]}", | 1193 "\"tokenPosTable\":[[1,0,1,1,5,2,9],[3,5,1,6,5,7,6,8,8],[4,10,1]]}", |
1194 handler.msg()); | 1194 handler.msg()); |
(...skipping 22 matching lines...) Expand all Loading... |
1217 Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL); | 1217 Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL); |
1218 EXPECT_VALID(result); | 1218 EXPECT_VALID(result); |
1219 | 1219 |
1220 // Build a mock message handler and wrap it in a dart port. | 1220 // Build a mock message handler and wrap it in a dart port. |
1221 ServiceTestMessageHandler handler; | 1221 ServiceTestMessageHandler handler; |
1222 Dart_Port port_id = PortMap::CreatePort(&handler); | 1222 Dart_Port port_id = PortMap::CreatePort(&handler); |
1223 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 1223 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
1224 EXPECT_VALID(port); | 1224 EXPECT_VALID(port); |
1225 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); | 1225 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); |
1226 | 1226 |
1227 Instance& service_msg = Instance::Handle(); | 1227 Array& service_msg = Array::Handle(); |
1228 service_msg = Eval(h_lib, "[0, port, ['coverage'], [], []]"); | 1228 service_msg = Eval(h_lib, "[0, port, ['coverage'], [], []]"); |
1229 Service::HandleIsolateMessage(isolate, service_msg); | 1229 Service::HandleIsolateMessage(isolate, service_msg); |
1230 handler.HandleNextMessage(); | 1230 handler.HandleNextMessage(); |
1231 EXPECT_SUBSTRING( | 1231 EXPECT_SUBSTRING( |
1232 "{\"source\":\"test-lib\",\"script\":{" | 1232 "{\"source\":\"test-lib\",\"script\":{" |
1233 "\"type\":\"@Script\",\"id\":\"scripts\\/test-lib\"," | 1233 "\"type\":\"@Script\",\"id\":\"scripts\\/test-lib\"," |
1234 "\"name\":\"test-lib\",\"user_name\":\"test-lib\"," | 1234 "\"name\":\"test-lib\",\"user_name\":\"test-lib\"," |
1235 "\"kind\":\"script\"},\"hits\":" | 1235 "\"kind\":\"script\"},\"hits\":" |
1236 "[5,1,6,1]}", handler.msg()); | 1236 "[5,1,6,1]}", handler.msg()); |
1237 } | 1237 } |
(...skipping 18 matching lines...) Expand all Loading... |
1256 Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL); | 1256 Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL); |
1257 EXPECT_VALID(result); | 1257 EXPECT_VALID(result); |
1258 | 1258 |
1259 // Build a mock message handler and wrap it in a dart port. | 1259 // Build a mock message handler and wrap it in a dart port. |
1260 ServiceTestMessageHandler handler; | 1260 ServiceTestMessageHandler handler; |
1261 Dart_Port port_id = PortMap::CreatePort(&handler); | 1261 Dart_Port port_id = PortMap::CreatePort(&handler); |
1262 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 1262 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
1263 EXPECT_VALID(port); | 1263 EXPECT_VALID(port); |
1264 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); | 1264 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); |
1265 | 1265 |
1266 Instance& service_msg = Instance::Handle(); | 1266 Array& service_msg = Array::Handle(); |
1267 service_msg = Eval( | 1267 service_msg = Eval( |
1268 h_lib, "[0, port, ['scripts', 'test-lib', 'coverage'], [], []]"); | 1268 h_lib, "[0, port, ['scripts', 'test-lib', 'coverage'], [], []]"); |
1269 Service::HandleIsolateMessage(isolate, service_msg); | 1269 Service::HandleIsolateMessage(isolate, service_msg); |
1270 handler.HandleNextMessage(); | 1270 handler.HandleNextMessage(); |
1271 EXPECT_STREQ( | 1271 EXPECT_STREQ( |
1272 "{\"type\":\"CodeCoverage\",\"id\":\"coverage\",\"coverage\":[" | 1272 "{\"type\":\"CodeCoverage\",\"id\":\"coverage\",\"coverage\":[" |
1273 "{\"source\":\"test-lib\",\"script\":{" | 1273 "{\"source\":\"test-lib\",\"script\":{" |
1274 "\"type\":\"@Script\",\"id\":\"scripts\\/test-lib\"," | 1274 "\"type\":\"@Script\",\"id\":\"scripts\\/test-lib\"," |
1275 "\"name\":\"test-lib\",\"user_name\":\"test-lib\"," | 1275 "\"name\":\"test-lib\",\"user_name\":\"test-lib\"," |
1276 "\"kind\":\"script\"},\"hits\":[5,1,6,1]}]}", handler.msg()); | 1276 "\"kind\":\"script\"},\"hits\":[5,1,6,1]}]}", handler.msg()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1310 for (i = 0; i < libs.Length(); i++) { | 1310 for (i = 0; i < libs.Length(); i++) { |
1311 if (libs.At(i) == lib.raw()) { | 1311 if (libs.At(i) == lib.raw()) { |
1312 break; | 1312 break; |
1313 } | 1313 } |
1314 } | 1314 } |
1315 ASSERT(i != libs.Length()); | 1315 ASSERT(i != libs.Length()); |
1316 char buf[1024]; | 1316 char buf[1024]; |
1317 OS::SNPrint(buf, sizeof(buf), | 1317 OS::SNPrint(buf, sizeof(buf), |
1318 "[0, port, ['libraries', '%" Pd "', 'coverage'], [], []]", i); | 1318 "[0, port, ['libraries', '%" Pd "', 'coverage'], [], []]", i); |
1319 | 1319 |
1320 Instance& service_msg = Instance::Handle(); | 1320 Array& service_msg = Array::Handle(); |
1321 service_msg = Eval(h_lib, buf); | 1321 service_msg = Eval(h_lib, buf); |
1322 Service::HandleIsolateMessage(isolate, service_msg); | 1322 Service::HandleIsolateMessage(isolate, service_msg); |
1323 handler.HandleNextMessage(); | 1323 handler.HandleNextMessage(); |
1324 EXPECT_STREQ( | 1324 EXPECT_STREQ( |
1325 "{\"type\":\"CodeCoverage\",\"id\":\"coverage\",\"coverage\":[" | 1325 "{\"type\":\"CodeCoverage\",\"id\":\"coverage\",\"coverage\":[" |
1326 "{\"source\":\"test-lib\",\"script\":{" | 1326 "{\"source\":\"test-lib\",\"script\":{" |
1327 "\"type\":\"@Script\",\"id\":\"scripts\\/test-lib\"," | 1327 "\"type\":\"@Script\",\"id\":\"scripts\\/test-lib\"," |
1328 "\"name\":\"test-lib\",\"user_name\":\"test-lib\"," | 1328 "\"name\":\"test-lib\",\"user_name\":\"test-lib\"," |
1329 "\"kind\":\"script\"},\"hits\":[5,1,6,1]}]}", handler.msg()); | 1329 "\"kind\":\"script\"},\"hits\":[5,1,6,1]}]}", handler.msg()); |
1330 } | 1330 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1372 for (i = 1; i < table->NumCids(); i++) { | 1372 for (i = 1; i < table->NumCids(); i++) { |
1373 if (table->HasValidClassAt(i) && table->At(i) == cls.raw()) { | 1373 if (table->HasValidClassAt(i) && table->At(i) == cls.raw()) { |
1374 break; | 1374 break; |
1375 } | 1375 } |
1376 } | 1376 } |
1377 ASSERT(i != table->NumCids()); | 1377 ASSERT(i != table->NumCids()); |
1378 char buf[1024]; | 1378 char buf[1024]; |
1379 OS::SNPrint(buf, sizeof(buf), | 1379 OS::SNPrint(buf, sizeof(buf), |
1380 "[0, port, ['classes', '%" Pd "', 'coverage'], [], []]", i); | 1380 "[0, port, ['classes', '%" Pd "', 'coverage'], [], []]", i); |
1381 | 1381 |
1382 Instance& service_msg = Instance::Handle(); | 1382 Array& service_msg = Array::Handle(); |
1383 service_msg = Eval(h_lib, buf); | 1383 service_msg = Eval(h_lib, buf); |
1384 Service::HandleIsolateMessage(isolate, service_msg); | 1384 Service::HandleIsolateMessage(isolate, service_msg); |
1385 handler.HandleNextMessage(); | 1385 handler.HandleNextMessage(); |
1386 EXPECT_STREQ( | 1386 EXPECT_STREQ( |
1387 "{\"type\":\"CodeCoverage\",\"id\":\"coverage\",\"coverage\":[" | 1387 "{\"type\":\"CodeCoverage\",\"id\":\"coverage\",\"coverage\":[" |
1388 "{\"source\":\"test-lib\",\"script\":{" | 1388 "{\"source\":\"test-lib\",\"script\":{" |
1389 "\"type\":\"@Script\",\"id\":\"scripts\\/test-lib\"," | 1389 "\"type\":\"@Script\",\"id\":\"scripts\\/test-lib\"," |
1390 "\"name\":\"test-lib\",\"user_name\":\"test-lib\"," | 1390 "\"name\":\"test-lib\",\"user_name\":\"test-lib\"," |
1391 "\"kind\":\"script\"},\"hits\":[5,1,7,4,8,3]}]}", handler.msg()); | 1391 "\"kind\":\"script\"},\"hits\":[5,1,7,4,8,3]}]}", handler.msg()); |
1392 } | 1392 } |
(...skipping 20 matching lines...) Expand all Loading... |
1413 Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL); | 1413 Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL); |
1414 EXPECT_VALID(result); | 1414 EXPECT_VALID(result); |
1415 | 1415 |
1416 // Build a mock message handler and wrap it in a dart port. | 1416 // Build a mock message handler and wrap it in a dart port. |
1417 ServiceTestMessageHandler handler; | 1417 ServiceTestMessageHandler handler; |
1418 Dart_Port port_id = PortMap::CreatePort(&handler); | 1418 Dart_Port port_id = PortMap::CreatePort(&handler); |
1419 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 1419 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
1420 EXPECT_VALID(port); | 1420 EXPECT_VALID(port); |
1421 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); | 1421 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); |
1422 | 1422 |
1423 Instance& service_msg = Instance::Handle(); | 1423 Array& service_msg = Array::Handle(); |
1424 service_msg = Eval(h_lib, "[0, port, ['allocationprofile'], [], []]"); | 1424 service_msg = Eval(h_lib, "[0, port, ['allocationprofile'], [], []]"); |
1425 Service::HandleIsolateMessage(isolate, service_msg); | 1425 Service::HandleIsolateMessage(isolate, service_msg); |
1426 handler.HandleNextMessage(); | 1426 handler.HandleNextMessage(); |
1427 EXPECT_SUBSTRING("\"type\":\"AllocationProfile\"", handler.msg()); | 1427 EXPECT_SUBSTRING("\"type\":\"AllocationProfile\"", handler.msg()); |
1428 | 1428 |
1429 // Too long. | 1429 // Too long. |
1430 service_msg = Eval(h_lib, "[0, port, ['allocationprofile', 'foo'], [], []]"); | 1430 service_msg = Eval(h_lib, "[0, port, ['allocationprofile', 'foo'], [], []]"); |
1431 Service::HandleIsolateMessage(isolate, service_msg); | 1431 Service::HandleIsolateMessage(isolate, service_msg); |
1432 handler.HandleNextMessage(); | 1432 handler.HandleNextMessage(); |
1433 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); | 1433 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1480 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 1480 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
1481 EXPECT_VALID(lib); | 1481 EXPECT_VALID(lib); |
1482 | 1482 |
1483 // Build a mock message handler and wrap it in a dart port. | 1483 // Build a mock message handler and wrap it in a dart port. |
1484 ServiceTestMessageHandler handler; | 1484 ServiceTestMessageHandler handler; |
1485 Dart_Port port_id = PortMap::CreatePort(&handler); | 1485 Dart_Port port_id = PortMap::CreatePort(&handler); |
1486 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 1486 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
1487 EXPECT_VALID(port); | 1487 EXPECT_VALID(port); |
1488 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); | 1488 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); |
1489 | 1489 |
1490 Instance& service_msg = Instance::Handle(); | 1490 Array& service_msg = Array::Handle(); |
1491 service_msg = Eval(lib, "[0, port, ['heapmap'], [], []]"); | 1491 service_msg = Eval(lib, "[0, port, ['heapmap'], [], []]"); |
1492 Service::HandleIsolateMessage(isolate, service_msg); | 1492 Service::HandleIsolateMessage(isolate, service_msg); |
1493 handler.HandleNextMessage(); | 1493 handler.HandleNextMessage(); |
1494 EXPECT_SUBSTRING("\"type\":\"HeapMap\"", handler.msg()); | 1494 EXPECT_SUBSTRING("\"type\":\"HeapMap\"", handler.msg()); |
1495 EXPECT_SUBSTRING("\"pages\":[", handler.msg()); | 1495 EXPECT_SUBSTRING("\"pages\":[", handler.msg()); |
1496 } | 1496 } |
1497 | 1497 |
1498 | 1498 |
1499 TEST_CASE(Service_Address) { | 1499 TEST_CASE(Service_Address) { |
1500 const char* kScript = | 1500 const char* kScript = |
1501 "var port;\n" // Set to our mock port by C++. | 1501 "var port;\n" // Set to our mock port by C++. |
1502 "\n" | 1502 "\n" |
1503 "main() {\n" | 1503 "main() {\n" |
1504 "}"; | 1504 "}"; |
1505 | 1505 |
1506 Isolate* isolate = Isolate::Current(); | 1506 Isolate* isolate = Isolate::Current(); |
1507 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 1507 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
1508 EXPECT_VALID(lib); | 1508 EXPECT_VALID(lib); |
1509 | 1509 |
1510 // Build a mock message handler and wrap it in a dart port. | 1510 // Build a mock message handler and wrap it in a dart port. |
1511 ServiceTestMessageHandler handler; | 1511 ServiceTestMessageHandler handler; |
1512 Dart_Port port_id = PortMap::CreatePort(&handler); | 1512 Dart_Port port_id = PortMap::CreatePort(&handler); |
1513 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 1513 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
1514 EXPECT_VALID(port); | 1514 EXPECT_VALID(port); |
1515 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); | 1515 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); |
1516 | 1516 |
1517 const String& str = String::Handle(String::New("foobar", Heap::kOld)); | 1517 const String& str = String::Handle(String::New("foobar", Heap::kOld)); |
1518 Instance& service_msg = Instance::Handle(); | 1518 Array& service_msg = Array::Handle(); |
1519 // Note: If we ever introduce old space compaction, this test might fail. | 1519 // Note: If we ever introduce old space compaction, this test might fail. |
1520 uword start_addr = RawObject::ToAddr(str.raw()); | 1520 uword start_addr = RawObject::ToAddr(str.raw()); |
1521 // Expect to find 'str', also from internal addresses. | 1521 // Expect to find 'str', also from internal addresses. |
1522 for (int offset = 0; offset < kObjectAlignment; ++offset) { | 1522 for (int offset = 0; offset < kObjectAlignment; ++offset) { |
1523 uword addr = start_addr + offset; | 1523 uword addr = start_addr + offset; |
1524 char buf[1024]; | 1524 char buf[1024]; |
1525 OS::SNPrint(buf, sizeof(buf), | 1525 OS::SNPrint(buf, sizeof(buf), |
1526 "[0, port, ['address', '%" Px "'], [], []]", addr); | 1526 "[0, port, ['address', '%" Px "'], [], []]", addr); |
1527 service_msg = Eval(lib, buf); | 1527 service_msg = Eval(lib, buf); |
1528 Service::HandleIsolateMessage(isolate, service_msg); | 1528 Service::HandleIsolateMessage(isolate, service_msg); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1585 EXPECT_VALID(result); | 1585 EXPECT_VALID(result); |
1586 | 1586 |
1587 // Build a mock message handler and wrap it in a dart port. | 1587 // Build a mock message handler and wrap it in a dart port. |
1588 ServiceTestMessageHandler handler; | 1588 ServiceTestMessageHandler handler; |
1589 Dart_Port port_id = PortMap::CreatePort(&handler); | 1589 Dart_Port port_id = PortMap::CreatePort(&handler); |
1590 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 1590 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
1591 EXPECT_VALID(port); | 1591 EXPECT_VALID(port); |
1592 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); | 1592 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); |
1593 | 1593 |
1594 | 1594 |
1595 Instance& service_msg = Instance::Handle(); | 1595 Array& service_msg = Array::Handle(); |
1596 service_msg = Eval(lib, "[0, port, ['alpha'], [], []]"); | 1596 service_msg = Eval(lib, "[0, port, ['alpha'], [], []]"); |
1597 Service::HandleRootMessage(service_msg); | 1597 Service::HandleRootMessage(service_msg); |
1598 handler.HandleNextMessage(); | 1598 handler.HandleNextMessage(); |
1599 EXPECT_STREQ("alpha", handler.msg()); | 1599 EXPECT_STREQ("alpha", handler.msg()); |
1600 service_msg = Eval(lib, "[0, port, ['beta'], [], []]"); | 1600 service_msg = Eval(lib, "[0, port, ['beta'], [], []]"); |
1601 Service::HandleRootMessage(service_msg); | 1601 Service::HandleRootMessage(service_msg); |
1602 handler.HandleNextMessage(); | 1602 handler.HandleNextMessage(); |
1603 EXPECT_STREQ("beta", handler.msg()); | 1603 EXPECT_STREQ("beta", handler.msg()); |
1604 } | 1604 } |
1605 | 1605 |
(...skipping 16 matching lines...) Expand all Loading... |
1622 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 1622 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
1623 EXPECT_VALID(result); | 1623 EXPECT_VALID(result); |
1624 | 1624 |
1625 // Build a mock message handler and wrap it in a dart port. | 1625 // Build a mock message handler and wrap it in a dart port. |
1626 ServiceTestMessageHandler handler; | 1626 ServiceTestMessageHandler handler; |
1627 Dart_Port port_id = PortMap::CreatePort(&handler); | 1627 Dart_Port port_id = PortMap::CreatePort(&handler); |
1628 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 1628 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
1629 EXPECT_VALID(port); | 1629 EXPECT_VALID(port); |
1630 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); | 1630 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); |
1631 | 1631 |
1632 Instance& service_msg = Instance::Handle(); | 1632 Array& service_msg = Array::Handle(); |
1633 service_msg = Eval(lib, "[0, port, ['alpha'], [], []]"); | 1633 service_msg = Eval(lib, "[0, port, ['alpha'], [], []]"); |
1634 Service::HandleIsolateMessage(isolate, service_msg); | 1634 Service::HandleIsolateMessage(isolate, service_msg); |
1635 handler.HandleNextMessage(); | 1635 handler.HandleNextMessage(); |
1636 EXPECT_STREQ("alpha", handler.msg()); | 1636 EXPECT_STREQ("alpha", handler.msg()); |
1637 service_msg = Eval(lib, "[0, port, ['beta'], [], []]"); | 1637 service_msg = Eval(lib, "[0, port, ['beta'], [], []]"); |
1638 Service::HandleIsolateMessage(isolate, service_msg); | 1638 Service::HandleIsolateMessage(isolate, service_msg); |
1639 handler.HandleNextMessage(); | 1639 handler.HandleNextMessage(); |
1640 EXPECT_STREQ("beta", handler.msg()); | 1640 EXPECT_STREQ("beta", handler.msg()); |
1641 } | 1641 } |
1642 | 1642 |
(...skipping 20 matching lines...) Expand all Loading... |
1663 Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL); | 1663 Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL); |
1664 EXPECT_VALID(result); | 1664 EXPECT_VALID(result); |
1665 | 1665 |
1666 // Build a mock message handler and wrap it in a dart port. | 1666 // Build a mock message handler and wrap it in a dart port. |
1667 ServiceTestMessageHandler handler; | 1667 ServiceTestMessageHandler handler; |
1668 Dart_Port port_id = PortMap::CreatePort(&handler); | 1668 Dart_Port port_id = PortMap::CreatePort(&handler); |
1669 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); | 1669 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); |
1670 EXPECT_VALID(port); | 1670 EXPECT_VALID(port); |
1671 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); | 1671 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); |
1672 | 1672 |
1673 Instance& service_msg = Instance::Handle(); | 1673 Array& service_msg = Array::Handle(); |
1674 service_msg = Eval(h_lib, "[0, port, ['profile'], [], []]"); | 1674 service_msg = Eval(h_lib, "[0, port, ['profile'], [], []]"); |
1675 Service::HandleIsolateMessage(isolate, service_msg); | 1675 Service::HandleIsolateMessage(isolate, service_msg); |
1676 handler.HandleNextMessage(); | 1676 handler.HandleNextMessage(); |
1677 // Expect profile | 1677 // Expect profile |
1678 EXPECT_SUBSTRING("\"type\":\"Profile\"", handler.msg()); | 1678 EXPECT_SUBSTRING("\"type\":\"Profile\"", handler.msg()); |
1679 | 1679 |
1680 service_msg = Eval(h_lib, "[0, port, ['profile'], ['tags'], ['hide']]"); | 1680 service_msg = Eval(h_lib, "[0, port, ['profile'], ['tags'], ['hide']]"); |
1681 Service::HandleIsolateMessage(isolate, service_msg); | 1681 Service::HandleIsolateMessage(isolate, service_msg); |
1682 handler.HandleNextMessage(); | 1682 handler.HandleNextMessage(); |
1683 // Expect profile | 1683 // Expect profile |
1684 EXPECT_SUBSTRING("\"type\":\"Profile\"", handler.msg()); | 1684 EXPECT_SUBSTRING("\"type\":\"Profile\"", handler.msg()); |
1685 | 1685 |
1686 service_msg = Eval(h_lib, "[0, port, ['profile'], ['tags'], ['hidden']]"); | 1686 service_msg = Eval(h_lib, "[0, port, ['profile'], ['tags'], ['hidden']]"); |
1687 Service::HandleIsolateMessage(isolate, service_msg); | 1687 Service::HandleIsolateMessage(isolate, service_msg); |
1688 handler.HandleNextMessage(); | 1688 handler.HandleNextMessage(); |
1689 // Expect error. | 1689 // Expect error. |
1690 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); | 1690 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); |
1691 } | 1691 } |
1692 | 1692 |
1693 #endif // !defined(TARGET_ARCH_ARM64) | 1693 #endif // !defined(TARGET_ARCH_ARM64) |
1694 | 1694 |
1695 } // namespace dart | 1695 } // namespace dart |
OLD | NEW |