| 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 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); | 877 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); |
| 878 | 878 |
| 879 Instance& service_msg = Instance::Handle(); | 879 Instance& service_msg = Instance::Handle(); |
| 880 service_msg = Eval(h_lib, "[port, ['allocationprofile'], [], []]"); | 880 service_msg = Eval(h_lib, "[port, ['allocationprofile'], [], []]"); |
| 881 Service::HandleIsolateMessage(isolate, service_msg); | 881 Service::HandleIsolateMessage(isolate, service_msg); |
| 882 handler.HandleNextMessage(); | 882 handler.HandleNextMessage(); |
| 883 EXPECT_SUBSTRING("\"type\":\"AllocationProfile\"", handler.msg()); | 883 EXPECT_SUBSTRING("\"type\":\"AllocationProfile\"", handler.msg()); |
| 884 } | 884 } |
| 885 | 885 |
| 886 | 886 |
| 887 TEST_CASE(Service_HeapMap) { |
| 888 const char* kScript = |
| 889 "var port;\n" // Set to our mock port by C++. |
| 890 "\n" |
| 891 "main() {\n" |
| 892 "}"; |
| 893 |
| 894 Isolate* isolate = Isolate::Current(); |
| 895 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
| 896 EXPECT_VALID(lib); |
| 897 |
| 898 // Build a mock message handler and wrap it in a dart port. |
| 899 ServiceTestMessageHandler handler; |
| 900 Dart_Port port_id = PortMap::CreatePort(&handler); |
| 901 Dart_Handle port = |
| 902 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id)); |
| 903 EXPECT_VALID(port); |
| 904 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); |
| 905 |
| 906 Instance& service_msg = Instance::Handle(); |
| 907 service_msg = Eval(lib, "[port, ['heapmap'], [], []]"); |
| 908 Service::HandleIsolateMessage(isolate, service_msg); |
| 909 handler.HandleNextMessage(); |
| 910 EXPECT_SUBSTRING("\"type\":\"HeapMap\"", handler.msg()); |
| 911 EXPECT_SUBSTRING("\"pages\":[[", handler.msg()); |
| 912 EXPECT_SUBSTRING("]]", handler.msg()); |
| 913 } |
| 914 |
| 915 |
| 887 static const char* alpha_callback( | 916 static const char* alpha_callback( |
| 888 const char* name, | 917 const char* name, |
| 889 const char** arguments, | 918 const char** arguments, |
| 890 intptr_t num_arguments, | 919 intptr_t num_arguments, |
| 891 const char** option_keys, | 920 const char** option_keys, |
| 892 const char** option_values, | 921 const char** option_values, |
| 893 intptr_t num_options, | 922 intptr_t num_options, |
| 894 void* user_data) { | 923 void* user_data) { |
| 895 return strdup("alpha"); | 924 return strdup("alpha"); |
| 896 } | 925 } |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 979 Service::HandleIsolateMessage(isolate, service_msg); | 1008 Service::HandleIsolateMessage(isolate, service_msg); |
| 980 handler.HandleNextMessage(); | 1009 handler.HandleNextMessage(); |
| 981 EXPECT_STREQ("alpha", handler.msg()); | 1010 EXPECT_STREQ("alpha", handler.msg()); |
| 982 service_msg = Eval(lib, "[port, ['beta'], [], []]"); | 1011 service_msg = Eval(lib, "[port, ['beta'], [], []]"); |
| 983 Service::HandleIsolateMessage(isolate, service_msg); | 1012 Service::HandleIsolateMessage(isolate, service_msg); |
| 984 handler.HandleNextMessage(); | 1013 handler.HandleNextMessage(); |
| 985 EXPECT_STREQ("beta", handler.msg()); | 1014 EXPECT_STREQ("beta", handler.msg()); |
| 986 } | 1015 } |
| 987 | 1016 |
| 988 } // namespace dart | 1017 } // namespace dart |
| OLD | NEW |