Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Side by Side Diff: runtime/vm/service_test.cc

Issue 1255003003: Make VM service id handling JSON-RPC 2 compliant. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: cr Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/service/service.md ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_tools_api.h" 7 #include "include/dart_tools_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 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 523
524 // Build a mock message handler and wrap it in a dart port. 524 // Build a mock message handler and wrap it in a dart port.
525 ServiceTestMessageHandler handler; 525 ServiceTestMessageHandler handler;
526 Dart_Port port_id = PortMap::CreatePort(&handler); 526 Dart_Port port_id = PortMap::CreatePort(&handler);
527 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); 527 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id));
528 EXPECT_VALID(port); 528 EXPECT_VALID(port);
529 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); 529 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port));
530 530
531 531
532 Array& service_msg = Array::Handle(); 532 Array& service_msg = Array::Handle();
533 service_msg = Eval(lib, "[0, port, '0', 'alpha', [], []]"); 533 service_msg = Eval(lib, "[0, port, '\"', 'alpha', [], []]");
534 Service::HandleRootMessage(service_msg); 534 Service::HandleRootMessage(service_msg);
535 handler.HandleNextMessage(); 535 handler.HandleNextMessage();
536 EXPECT_STREQ("{\"jsonrpc\":\"2.0\", \"result\":alpha, \"id\":\"0\"}", 536 EXPECT_STREQ("{\"jsonrpc\":\"2.0\", \"result\":alpha, \"id\":\"\\\"\"}",
537 handler.msg()); 537 handler.msg());
538 service_msg = Eval(lib, "[0, port, '0', 'beta', [], []]"); 538 service_msg = Eval(lib, "[0, port, 1, 'beta', [], []]");
539 Service::HandleRootMessage(service_msg); 539 Service::HandleRootMessage(service_msg);
540 handler.HandleNextMessage(); 540 handler.HandleNextMessage();
541 EXPECT_STREQ("{\"jsonrpc\":\"2.0\", \"result\":beta, \"id\":\"0\"}", 541 EXPECT_STREQ("{\"jsonrpc\":\"2.0\", \"result\":beta, \"id\":1}",
542 handler.msg()); 542 handler.msg());
543 } 543 }
544 544
545 545
546 TEST_CASE(Service_EmbedderIsolateHandler) { 546 TEST_CASE(Service_EmbedderIsolateHandler) {
547 const char* kScript = 547 const char* kScript =
548 "var port;\n" // Set to our mock port by C++. 548 "var port;\n" // Set to our mock port by C++.
549 "\n" 549 "\n"
550 "var x = 7;\n" 550 "var x = 7;\n"
551 "main() {\n" 551 "main() {\n"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 Eval(lib, "[0, port, '0', '_getCpuProfile', ['tags'], ['Bogus']]"); 626 Eval(lib, "[0, port, '0', '_getCpuProfile', ['tags'], ['Bogus']]");
627 Service::HandleIsolateMessage(isolate, service_msg); 627 Service::HandleIsolateMessage(isolate, service_msg);
628 handler.HandleNextMessage(); 628 handler.HandleNextMessage();
629 // Expect error. 629 // Expect error.
630 EXPECT_SUBSTRING("\"error\"", handler.msg()); 630 EXPECT_SUBSTRING("\"error\"", handler.msg());
631 } 631 }
632 632
633 #endif // !defined(TARGET_ARCH_ARM64) 633 #endif // !defined(TARGET_ARCH_ARM64)
634 634
635 } // namespace dart 635 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/service/service.md ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698