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 "include/dart_debugger_api.h" | 5 #include "include/dart_debugger_api.h" |
6 #include "vm/dart_api_impl.h" | 6 #include "vm/dart_api_impl.h" |
7 #include "vm/dart_entry.h" | 7 #include "vm/dart_entry.h" |
8 #include "vm/debugger.h" | 8 #include "vm/debugger.h" |
9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
10 #include "vm/message_handler.h" | 10 #include "vm/message_handler.h" |
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1097 Dart_Handle port = | 1097 Dart_Handle port = |
1098 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id)); | 1098 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id)); |
1099 EXPECT_VALID(port); | 1099 EXPECT_VALID(port); |
1100 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); | 1100 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); |
1101 | 1101 |
1102 Instance& service_msg = Instance::Handle(); | 1102 Instance& service_msg = Instance::Handle(); |
1103 service_msg = Eval(h_lib, "[port, ['allocationprofile'], [], []]"); | 1103 service_msg = Eval(h_lib, "[port, ['allocationprofile'], [], []]"); |
1104 Service::HandleIsolateMessage(isolate, service_msg); | 1104 Service::HandleIsolateMessage(isolate, service_msg); |
1105 handler.HandleNextMessage(); | 1105 handler.HandleNextMessage(); |
1106 EXPECT_SUBSTRING("\"type\":\"AllocationProfile\"", handler.msg()); | 1106 EXPECT_SUBSTRING("\"type\":\"AllocationProfile\"", handler.msg()); |
| 1107 |
| 1108 // Too long. |
| 1109 service_msg = Eval(h_lib, "[port, ['allocationprofile', 'foo'], [], []]"); |
| 1110 Service::HandleIsolateMessage(isolate, service_msg); |
| 1111 handler.HandleNextMessage(); |
| 1112 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); |
| 1113 |
| 1114 // Bad gc option. |
| 1115 service_msg = Eval(h_lib, "[port, ['allocationprofile'], ['gc'], ['cat']]"); |
| 1116 Service::HandleIsolateMessage(isolate, service_msg); |
| 1117 handler.HandleNextMessage(); |
| 1118 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); |
| 1119 |
| 1120 // Bad reset option. |
| 1121 service_msg = Eval(h_lib, "[port, ['allocationprofile'], ['reset'], ['ff']]"); |
| 1122 Service::HandleIsolateMessage(isolate, service_msg); |
| 1123 handler.HandleNextMessage(); |
| 1124 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); |
| 1125 |
| 1126 // Good reset. |
| 1127 service_msg = |
| 1128 Eval(h_lib, "[port, ['allocationprofile'], ['reset'], ['true']]"); |
| 1129 Service::HandleIsolateMessage(isolate, service_msg); |
| 1130 handler.HandleNextMessage(); |
| 1131 EXPECT_SUBSTRING("\"type\":\"AllocationProfile\"", handler.msg()); |
| 1132 |
| 1133 // Good GC. |
| 1134 service_msg = |
| 1135 Eval(h_lib, "[port, ['allocationprofile'], ['gc'], ['full']]"); |
| 1136 Service::HandleIsolateMessage(isolate, service_msg); |
| 1137 handler.HandleNextMessage(); |
| 1138 EXPECT_SUBSTRING("\"type\":\"AllocationProfile\"", handler.msg()); |
| 1139 |
| 1140 // Good GC and reset. |
| 1141 service_msg = Eval(h_lib, |
| 1142 "[port, ['allocationprofile'], ['gc', 'reset'], ['full', 'true']]"); |
| 1143 Service::HandleIsolateMessage(isolate, service_msg); |
| 1144 handler.HandleNextMessage(); |
| 1145 EXPECT_SUBSTRING("\"type\":\"AllocationProfile\"", handler.msg()); |
1107 } | 1146 } |
1108 | 1147 |
1109 | 1148 |
1110 TEST_CASE(Service_HeapMap) { | 1149 TEST_CASE(Service_HeapMap) { |
1111 const char* kScript = | 1150 const char* kScript = |
1112 "var port;\n" // Set to our mock port by C++. | 1151 "var port;\n" // Set to our mock port by C++. |
1113 "\n" | 1152 "\n" |
1114 "main() {\n" | 1153 "main() {\n" |
1115 "}"; | 1154 "}"; |
1116 | 1155 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1320 EXPECT_SUBSTRING("\"type\":\"Profile\"", handler.msg()); | 1359 EXPECT_SUBSTRING("\"type\":\"Profile\"", handler.msg()); |
1321 | 1360 |
1322 service_msg = Eval(h_lib, "[port, ['profile'], ['tags'], ['hidden']]"); | 1361 service_msg = Eval(h_lib, "[port, ['profile'], ['tags'], ['hidden']]"); |
1323 Service::HandleIsolateMessage(isolate, service_msg); | 1362 Service::HandleIsolateMessage(isolate, service_msg); |
1324 handler.HandleNextMessage(); | 1363 handler.HandleNextMessage(); |
1325 // Expect error. | 1364 // Expect error. |
1326 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); | 1365 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); |
1327 } | 1366 } |
1328 | 1367 |
1329 } // namespace dart | 1368 } // namespace dart |
OLD | NEW |