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 "platform/globals.h" | 5 #include "platform/globals.h" |
6 | 6 |
7 #include "include/dart_debugger_api.h" | 7 #include "include/dart_debugger_api.h" |
8 #include "vm/dart_api_impl.h" | 8 #include "vm/dart_api_impl.h" |
9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
10 #include "vm/debugger.h" | 10 #include "vm/debugger.h" |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
499 service_msg = Eval(lib, "[0, port, '0', 'alpha', [], []]"); | 499 service_msg = Eval(lib, "[0, port, '0', 'alpha', [], []]"); |
500 Service::HandleRootMessage(service_msg); | 500 Service::HandleRootMessage(service_msg); |
501 handler.HandleNextMessage(); | 501 handler.HandleNextMessage(); |
502 EXPECT_STREQ("{\"result\":alpha, \"id\":\"0\"}", handler.msg()); | 502 EXPECT_STREQ("{\"result\":alpha, \"id\":\"0\"}", handler.msg()); |
503 service_msg = Eval(lib, "[0, port, '0', 'beta', [], []]"); | 503 service_msg = Eval(lib, "[0, port, '0', 'beta', [], []]"); |
504 Service::HandleRootMessage(service_msg); | 504 Service::HandleRootMessage(service_msg); |
505 handler.HandleNextMessage(); | 505 handler.HandleNextMessage(); |
506 EXPECT_STREQ("{\"result\":beta, \"id\":\"0\"}", handler.msg()); | 506 EXPECT_STREQ("{\"result\":beta, \"id\":\"0\"}", handler.msg()); |
507 } | 507 } |
508 | 508 |
509 | |
509 TEST_CASE(Service_EmbedderIsolateHandler) { | 510 TEST_CASE(Service_EmbedderIsolateHandler) { |
510 const char* kScript = | 511 const char* kScript = |
511 "var port;\n" // Set to our mock port by C++. | 512 "var port;\n" // Set to our mock port by C++. |
512 "\n" | 513 "\n" |
513 "var x = 7;\n" | 514 "var x = 7;\n" |
514 "main() {\n" | 515 "main() {\n" |
515 " x = x * x;\n" | 516 " x = x * x;\n" |
516 " x = x / 13;\n" | 517 " x = x / 13;\n" |
517 "}"; | 518 "}"; |
518 | 519 |
(...skipping 18 matching lines...) Expand all Loading... | |
537 Service::HandleIsolateMessage(isolate, service_msg); | 538 Service::HandleIsolateMessage(isolate, service_msg); |
538 handler.HandleNextMessage(); | 539 handler.HandleNextMessage(); |
539 EXPECT_STREQ("{\"result\":alpha, \"id\":\"0\"}", handler.msg()); | 540 EXPECT_STREQ("{\"result\":alpha, \"id\":\"0\"}", handler.msg()); |
540 service_msg = Eval(lib, "[0, port, '0', 'beta', [], []]"); | 541 service_msg = Eval(lib, "[0, port, '0', 'beta', [], []]"); |
541 Service::HandleIsolateMessage(isolate, service_msg); | 542 Service::HandleIsolateMessage(isolate, service_msg); |
542 handler.HandleNextMessage(); | 543 handler.HandleNextMessage(); |
543 EXPECT_STREQ("{\"result\":beta, \"id\":\"0\"}", handler.msg()); | 544 EXPECT_STREQ("{\"result\":beta, \"id\":\"0\"}", handler.msg()); |
544 } | 545 } |
545 | 546 |
546 | 547 |
548 static uint8_t* AllocMsg(const char* str) { | |
549 return reinterpret_cast<uint8_t*>(strdup(str)); | |
550 } | |
551 | |
552 | |
553 TEST_CASE(Service_MessageQueue) { | |
554 MessageQueue queue; | |
555 EXPECT(queue.IsEmpty()); | |
556 | |
557 Dart_Port port = 1; | |
558 | |
559 const char* str1 = "msg1"; | |
560 | |
561 // Add a message. | |
562 Message* msg1 = new Message( | |
563 port, AllocMsg(str1), strlen(str1) + 1, Message::kNormalPriority); | |
564 queue.Enqueue(msg1, false); | |
565 EXPECT(queue.Length() == 1); | |
566 EXPECT(!queue.IsEmpty()); | |
567 | |
568 // Print MessageQueue to JSON. | |
569 JSONStream stream; | |
570 queue.PrintJSON(&stream); | |
571 // Expect a @IsolateMessage type. | |
572 EXPECT_SUBSTRING("\"type\":\"IsolateMessage\"", stream.ToCString()); | |
573 } | |
turnidge
2015/05/04 17:47:13
In addition to this test, we should test this code
Cutch
2015/05/04 19:56:52
Acknowledged.
| |
574 | |
547 // TODO(zra): Remove when tests are ready to enable. | 575 // TODO(zra): Remove when tests are ready to enable. |
548 #if !defined(TARGET_ARCH_ARM64) | 576 #if !defined(TARGET_ARCH_ARM64) |
549 | 577 |
550 TEST_CASE(Service_Profile) { | 578 TEST_CASE(Service_Profile) { |
551 const char* kScript = | 579 const char* kScript = |
552 "var port;\n" // Set to our mock port by C++. | 580 "var port;\n" // Set to our mock port by C++. |
553 "\n" | 581 "\n" |
554 "var x = 7;\n" | 582 "var x = 7;\n" |
555 "main() {\n" | 583 "main() {\n" |
556 " x = x * x;\n" | 584 " x = x * x;\n" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
588 Eval(lib, "[0, port, '0', 'getCpuProfile', ['tags'], ['Bogus']]"); | 616 Eval(lib, "[0, port, '0', 'getCpuProfile', ['tags'], ['Bogus']]"); |
589 Service::HandleIsolateMessage(isolate, service_msg); | 617 Service::HandleIsolateMessage(isolate, service_msg); |
590 handler.HandleNextMessage(); | 618 handler.HandleNextMessage(); |
591 // Expect error. | 619 // Expect error. |
592 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); | 620 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); |
593 } | 621 } |
594 | 622 |
595 #endif // !defined(TARGET_ARCH_ARM64) | 623 #endif // !defined(TARGET_ARCH_ARM64) |
596 | 624 |
597 } // namespace dart | 625 } // namespace dart |
OLD | NEW |