| 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 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); | 481 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); |
| 482 | 482 |
| 483 Instance& service_msg = Instance::Handle(); | 483 Instance& service_msg = Instance::Handle(); |
| 484 service_msg = Eval(lib, "[port, ['cpu'], [], []]"); | 484 service_msg = Eval(lib, "[port, ['cpu'], [], []]"); |
| 485 | 485 |
| 486 Service::HandleRootMessage(service_msg); | 486 Service::HandleRootMessage(service_msg); |
| 487 handler.HandleNextMessage(); | 487 handler.HandleNextMessage(); |
| 488 EXPECT_SUBSTRING("\"type\":\"CPU\"", handler.msg()); | 488 EXPECT_SUBSTRING("\"type\":\"CPU\"", handler.msg()); |
| 489 } | 489 } |
| 490 | 490 |
| 491 |
| 492 TEST_CASE(Service_Coverage) { |
| 493 const char* kScript = |
| 494 "var port;\n" // Set to our mock port by C++. |
| 495 "\n" |
| 496 "var x = 7;\n" |
| 497 "main() {\n" |
| 498 " x = x * x;\n" |
| 499 " x = x / 13;\n" |
| 500 "}"; |
| 501 |
| 502 Isolate* isolate = Isolate::Current(); |
| 503 Dart_Handle h_lib = TestCase::LoadTestScript(kScript, NULL); |
| 504 EXPECT_VALID(h_lib); |
| 505 Library& lib = Library::Handle(); |
| 506 lib ^= Api::UnwrapHandle(h_lib); |
| 507 EXPECT(!lib.IsNull()); |
| 508 Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL); |
| 509 EXPECT_VALID(result); |
| 510 |
| 511 // Build a mock message handler and wrap it in a dart port. |
| 512 ServiceTestMessageHandler handler; |
| 513 Dart_Port port_id = PortMap::CreatePort(&handler); |
| 514 Dart_Handle port = |
| 515 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id)); |
| 516 EXPECT_VALID(port); |
| 517 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); |
| 518 |
| 519 Instance& service_msg = Instance::Handle(); |
| 520 service_msg = Eval(h_lib, "[port, ['coverage'], [], []]"); |
| 521 Service::HandleIsolateMessage(isolate, service_msg); |
| 522 handler.HandleNextMessage(); |
| 523 EXPECT_SUBSTRING( |
| 524 "{\"source\":\"dart:test-lib\",\"script\":{" |
| 525 "\"type\":\"@Script\",\"id\":\"scripts\\/dart%3Atest-lib\"," |
| 526 "\"name\":\"dart:test-lib\",\"user_name\":\"dart:test-lib\"," |
| 527 "\"kind\":\"script\"},\"hits\":" |
| 528 "[3,0,3,1,5,1,5,1,5,1,6,1,6,1]}", handler.msg()); |
| 529 } |
| 530 |
| 491 } // namespace dart | 531 } // namespace dart |
| OLD | NEW |