| 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 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 service_msg = Eval(lib, "[port, ['alpha'], [], []]"); | 1100 service_msg = Eval(lib, "[port, ['alpha'], [], []]"); |
| 1101 Service::HandleIsolateMessage(isolate, service_msg); | 1101 Service::HandleIsolateMessage(isolate, service_msg); |
| 1102 handler.HandleNextMessage(); | 1102 handler.HandleNextMessage(); |
| 1103 EXPECT_STREQ("alpha", handler.msg()); | 1103 EXPECT_STREQ("alpha", handler.msg()); |
| 1104 service_msg = Eval(lib, "[port, ['beta'], [], []]"); | 1104 service_msg = Eval(lib, "[port, ['beta'], [], []]"); |
| 1105 Service::HandleIsolateMessage(isolate, service_msg); | 1105 Service::HandleIsolateMessage(isolate, service_msg); |
| 1106 handler.HandleNextMessage(); | 1106 handler.HandleNextMessage(); |
| 1107 EXPECT_STREQ("beta", handler.msg()); | 1107 EXPECT_STREQ("beta", handler.msg()); |
| 1108 } | 1108 } |
| 1109 | 1109 |
| 1110 TEST_CASE(Service_Profile) { |
| 1111 const char* kScript = |
| 1112 "var port;\n" // Set to our mock port by C++. |
| 1113 "\n" |
| 1114 "var x = 7;\n" |
| 1115 "main() {\n" |
| 1116 " x = x * x;\n" |
| 1117 " x = x / 13;\n" |
| 1118 "}"; |
| 1119 |
| 1120 Isolate* isolate = Isolate::Current(); |
| 1121 Dart_Handle h_lib = TestCase::LoadTestScript(kScript, NULL); |
| 1122 EXPECT_VALID(h_lib); |
| 1123 Library& lib = Library::Handle(); |
| 1124 lib ^= Api::UnwrapHandle(h_lib); |
| 1125 EXPECT(!lib.IsNull()); |
| 1126 Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL); |
| 1127 EXPECT_VALID(result); |
| 1128 |
| 1129 // Build a mock message handler and wrap it in a dart port. |
| 1130 ServiceTestMessageHandler handler; |
| 1131 Dart_Port port_id = PortMap::CreatePort(&handler); |
| 1132 Dart_Handle port = |
| 1133 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id)); |
| 1134 EXPECT_VALID(port); |
| 1135 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); |
| 1136 |
| 1137 Instance& service_msg = Instance::Handle(); |
| 1138 service_msg = Eval(h_lib, "[port, ['profile'], [], []]"); |
| 1139 Service::HandleIsolateMessage(isolate, service_msg); |
| 1140 handler.HandleNextMessage(); |
| 1141 // Expect profile |
| 1142 EXPECT_SUBSTRING("\"type\":\"Profile\"", handler.msg()); |
| 1143 |
| 1144 service_msg = Eval(h_lib, "[port, ['profile'], ['tags'], ['hide']]"); |
| 1145 Service::HandleIsolateMessage(isolate, service_msg); |
| 1146 handler.HandleNextMessage(); |
| 1147 // Expect profile |
| 1148 EXPECT_SUBSTRING("\"type\":\"Profile\"", handler.msg()); |
| 1149 |
| 1150 service_msg = Eval(h_lib, "[port, ['profile'], ['tags'], ['hidden']]"); |
| 1151 Service::HandleIsolateMessage(isolate, service_msg); |
| 1152 handler.HandleNextMessage(); |
| 1153 // Expect error. |
| 1154 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); |
| 1155 } |
| 1156 |
| 1110 } // namespace dart | 1157 } // namespace dart |
| OLD | NEW |