| 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 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 handler.HandleNextMessage(); | 608 handler.HandleNextMessage(); |
| 609 EXPECT_SUBSTRING( | 609 EXPECT_SUBSTRING( |
| 610 "{\"source\":\"dart:test-lib\",\"script\":{" | 610 "{\"source\":\"dart:test-lib\",\"script\":{" |
| 611 "\"type\":\"@Script\",\"id\":\"scripts\\/dart%3Atest-lib\"," | 611 "\"type\":\"@Script\",\"id\":\"scripts\\/dart%3Atest-lib\"," |
| 612 "\"name\":\"dart:test-lib\",\"user_name\":\"dart:test-lib\"," | 612 "\"name\":\"dart:test-lib\",\"user_name\":\"dart:test-lib\"," |
| 613 "\"kind\":\"script\"},\"hits\":" | 613 "\"kind\":\"script\"},\"hits\":" |
| 614 "[3,0,3,1,5,1,5,1,5,1,6,1,6,1]}", handler.msg()); | 614 "[3,0,3,1,5,1,5,1,5,1,6,1,6,1]}", handler.msg()); |
| 615 } | 615 } |
| 616 | 616 |
| 617 | 617 |
| 618 TEST_CASE(Service_AllocationProfile) { |
| 619 const char* kScript = |
| 620 "var port;\n" // Set to our mock port by C++. |
| 621 "\n" |
| 622 "var x = 7;\n" |
| 623 "main() {\n" |
| 624 " x = x * x;\n" |
| 625 " x = x / 13;\n" |
| 626 "}"; |
| 627 |
| 628 Isolate* isolate = Isolate::Current(); |
| 629 Dart_Handle h_lib = TestCase::LoadTestScript(kScript, NULL); |
| 630 EXPECT_VALID(h_lib); |
| 631 Library& lib = Library::Handle(); |
| 632 lib ^= Api::UnwrapHandle(h_lib); |
| 633 EXPECT(!lib.IsNull()); |
| 634 Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL); |
| 635 EXPECT_VALID(result); |
| 636 |
| 637 // Build a mock message handler and wrap it in a dart port. |
| 638 ServiceTestMessageHandler handler; |
| 639 Dart_Port port_id = PortMap::CreatePort(&handler); |
| 640 Dart_Handle port = |
| 641 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id)); |
| 642 EXPECT_VALID(port); |
| 643 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); |
| 644 |
| 645 Instance& service_msg = Instance::Handle(); |
| 646 service_msg = Eval(h_lib, "[port, ['allocationprofile'], [], []]"); |
| 647 Service::HandleIsolateMessage(isolate, service_msg); |
| 648 handler.HandleNextMessage(); |
| 649 EXPECT_SUBSTRING("\"type\":\"AllocationProfile\"", handler.msg()); |
| 650 } |
| 651 |
| 652 |
| 618 static const char* alpha_callback( | 653 static const char* alpha_callback( |
| 619 const char* name, | 654 const char* name, |
| 620 const char** arguments, | 655 const char** arguments, |
| 621 intptr_t num_arguments, | 656 intptr_t num_arguments, |
| 622 const char** option_keys, | 657 const char** option_keys, |
| 623 const char** option_values, | 658 const char** option_values, |
| 624 intptr_t num_options, | 659 intptr_t num_options, |
| 625 void* user_data) { | 660 void* user_data) { |
| 626 return strdup("alpha"); | 661 return strdup("alpha"); |
| 627 } | 662 } |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 Service::HandleIsolateMessage(isolate, service_msg); | 745 Service::HandleIsolateMessage(isolate, service_msg); |
| 711 handler.HandleNextMessage(); | 746 handler.HandleNextMessage(); |
| 712 EXPECT_STREQ("alpha", handler.msg()); | 747 EXPECT_STREQ("alpha", handler.msg()); |
| 713 service_msg = Eval(lib, "[port, ['beta'], [], []]"); | 748 service_msg = Eval(lib, "[port, ['beta'], [], []]"); |
| 714 Service::HandleIsolateMessage(isolate, service_msg); | 749 Service::HandleIsolateMessage(isolate, service_msg); |
| 715 handler.HandleNextMessage(); | 750 handler.HandleNextMessage(); |
| 716 EXPECT_STREQ("beta", handler.msg()); | 751 EXPECT_STREQ("beta", handler.msg()); |
| 717 } | 752 } |
| 718 | 753 |
| 719 } // namespace dart | 754 } // namespace dart |
| OLD | NEW |