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

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

Issue 1147913004: Emit json-rpc version in service protocol responses. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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/json_stream.cc ('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_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 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 Dart_Port port_id = PortMap::CreatePort(&handler); 528 Dart_Port port_id = PortMap::CreatePort(&handler);
529 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); 529 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id));
530 EXPECT_VALID(port); 530 EXPECT_VALID(port);
531 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); 531 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port));
532 532
533 533
534 Array& service_msg = Array::Handle(); 534 Array& service_msg = Array::Handle();
535 service_msg = Eval(lib, "[0, port, '0', 'alpha', [], []]"); 535 service_msg = Eval(lib, "[0, port, '0', 'alpha', [], []]");
536 Service::HandleRootMessage(service_msg); 536 Service::HandleRootMessage(service_msg);
537 handler.HandleNextMessage(); 537 handler.HandleNextMessage();
538 EXPECT_STREQ("{\"result\":alpha, \"id\":\"0\"}", handler.msg()); 538 EXPECT_STREQ("{\"json-rpc\":\"2.0\", \"result\":alpha, \"id\":\"0\"}",
539 handler.msg());
539 service_msg = Eval(lib, "[0, port, '0', 'beta', [], []]"); 540 service_msg = Eval(lib, "[0, port, '0', 'beta', [], []]");
540 Service::HandleRootMessage(service_msg); 541 Service::HandleRootMessage(service_msg);
541 handler.HandleNextMessage(); 542 handler.HandleNextMessage();
542 EXPECT_STREQ("{\"result\":beta, \"id\":\"0\"}", handler.msg()); 543 EXPECT_STREQ("{\"json-rpc\":\"2.0\", \"result\":beta, \"id\":\"0\"}",
544 handler.msg());
543 } 545 }
544 546
545 547
546 TEST_CASE(Service_EmbedderIsolateHandler) { 548 TEST_CASE(Service_EmbedderIsolateHandler) {
547 const char* kScript = 549 const char* kScript =
548 "var port;\n" // Set to our mock port by C++. 550 "var port;\n" // Set to our mock port by C++.
549 "\n" 551 "\n"
550 "var x = 7;\n" 552 "var x = 7;\n"
551 "main() {\n" 553 "main() {\n"
552 " x = x * x;\n" 554 " x = x * x;\n"
(...skipping 13 matching lines...) Expand all
566 ServiceTestMessageHandler handler; 568 ServiceTestMessageHandler handler;
567 Dart_Port port_id = PortMap::CreatePort(&handler); 569 Dart_Port port_id = PortMap::CreatePort(&handler);
568 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); 570 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id));
569 EXPECT_VALID(port); 571 EXPECT_VALID(port);
570 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); 572 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port));
571 573
572 Array& service_msg = Array::Handle(); 574 Array& service_msg = Array::Handle();
573 service_msg = Eval(lib, "[0, port, '0', 'alpha', [], []]"); 575 service_msg = Eval(lib, "[0, port, '0', 'alpha', [], []]");
574 Service::HandleIsolateMessage(isolate, service_msg); 576 Service::HandleIsolateMessage(isolate, service_msg);
575 handler.HandleNextMessage(); 577 handler.HandleNextMessage();
576 EXPECT_STREQ("{\"result\":alpha, \"id\":\"0\"}", handler.msg()); 578 EXPECT_STREQ("{\"json-rpc\":\"2.0\", \"result\":alpha, \"id\":\"0\"}",
579 handler.msg());
577 service_msg = Eval(lib, "[0, port, '0', 'beta', [], []]"); 580 service_msg = Eval(lib, "[0, port, '0', 'beta', [], []]");
578 Service::HandleIsolateMessage(isolate, service_msg); 581 Service::HandleIsolateMessage(isolate, service_msg);
579 handler.HandleNextMessage(); 582 handler.HandleNextMessage();
580 EXPECT_STREQ("{\"result\":beta, \"id\":\"0\"}", handler.msg()); 583 EXPECT_STREQ("{\"json-rpc\":\"2.0\", \"result\":beta, \"id\":\"0\"}",
584 handler.msg());
581 } 585 }
582 586
583 // TODO(zra): Remove when tests are ready to enable. 587 // TODO(zra): Remove when tests are ready to enable.
584 #if !defined(TARGET_ARCH_ARM64) 588 #if !defined(TARGET_ARCH_ARM64)
585 589
586 TEST_CASE(Service_Profile) { 590 TEST_CASE(Service_Profile) {
587 const char* kScript = 591 const char* kScript =
588 "var port;\n" // Set to our mock port by C++. 592 "var port;\n" // Set to our mock port by C++.
589 "\n" 593 "\n"
590 "var x = 7;\n" 594 "var x = 7;\n"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 Eval(lib, "[0, port, '0', 'getCpuProfile', ['tags'], ['Bogus']]"); 628 Eval(lib, "[0, port, '0', 'getCpuProfile', ['tags'], ['Bogus']]");
625 Service::HandleIsolateMessage(isolate, service_msg); 629 Service::HandleIsolateMessage(isolate, service_msg);
626 handler.HandleNextMessage(); 630 handler.HandleNextMessage();
627 // Expect error. 631 // Expect error.
628 EXPECT_SUBSTRING("\"error\"", handler.msg()); 632 EXPECT_SUBSTRING("\"error\"", handler.msg());
629 } 633 }
630 634
631 #endif // !defined(TARGET_ARCH_ARM64) 635 #endif // !defined(TARGET_ARCH_ARM64)
632 636
633 } // namespace dart 637 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/json_stream.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698