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

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

Issue 184653003: Support displaying of types in the observatory (back-end only for now): (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/service.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 "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 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 Service::HandleIsolateMessage(isolate, service_msg); 737 Service::HandleIsolateMessage(isolate, service_msg);
738 handler.HandleNextMessage(); 738 handler.HandleNextMessage();
739 ExpectSubstringF(handler.msg(), 739 ExpectSubstringF(handler.msg(),
740 "{\"type\":\"Error\",\"id\":\"\",\"message\":\"Command too long\"," 740 "{\"type\":\"Error\",\"id\":\"\",\"message\":\"Command too long\","
741 "\"request\":" 741 "\"request\":"
742 "{\"arguments\":[\"classes\",\"%" Pd "\",\"functions\",\"9\",\"x\"]," 742 "{\"arguments\":[\"classes\",\"%" Pd "\",\"functions\",\"9\",\"x\"],"
743 "\"option_keys\":[],\"option_values\":[]}}", cid); 743 "\"option_keys\":[],\"option_values\":[]}}", cid);
744 } 744 }
745 745
746 746
747 TEST_CASE(Service_Types) {
748 const char* kScript =
749 "var port;\n" // Set to our mock port by C++.
750 "\n"
751 "class A<T> { }\n"
752 "\n"
753 "main() {\n"
754 " new A<A<bool>>();\n"
755 "}";
756
757 Isolate* isolate = Isolate::Current();
758 Dart_Handle h_lib = TestCase::LoadTestScript(kScript, NULL);
759 EXPECT_VALID(h_lib);
760 Library& lib = Library::Handle();
761 lib ^= Api::UnwrapHandle(h_lib);
762 EXPECT(!lib.IsNull());
763 Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL);
764 EXPECT_VALID(result);
765 const Class& class_a = Class::Handle(GetClass(lib, "A"));
766 EXPECT(!class_a.IsNull());
767 intptr_t cid = class_a.id();
768
769 // Build a mock message handler and wrap it in a dart port.
770 ServiceTestMessageHandler handler;
771 Dart_Port port_id = PortMap::CreatePort(&handler);
772 Dart_Handle port =
773 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id));
774 EXPECT_VALID(port);
775 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port));
776
777 Instance& service_msg = Instance::Handle();
778
779 // Request the class A over the service.
780 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "'], [], []]", cid);
781 Service::HandleIsolateMessage(isolate, service_msg);
782 handler.HandleNextMessage();
783 EXPECT_SUBSTRING("\"type\":\"Class\"", handler.msg());
784 ExpectSubstringF(handler.msg(),
785 "\"id\":\"classes\\/%" Pd "\",\"name\":\"A\",", cid);
786
787 // Request canonical type 0 from class A.
788 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'types', '0'],"
789 "[], []]", cid);
790 Service::HandleIsolateMessage(isolate, service_msg);
791 handler.HandleNextMessage();
792 EXPECT_SUBSTRING("\"type\":\"Type\"", handler.msg());
793 ExpectSubstringF(handler.msg(),
794 "\"id\":\"classes\\/%" Pd "\\/types\\/0\","
795 "\"name\":\"A<bool>\",", cid);
796
797 // Request canonical type 1 from class A.
798 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'types', '1'],"
799 "[], []]", cid);
800 Service::HandleIsolateMessage(isolate, service_msg);
801 handler.HandleNextMessage();
802 EXPECT_SUBSTRING("\"type\":\"Type\"", handler.msg());
803 ExpectSubstringF(handler.msg(),
804 "\"id\":\"classes\\/%" Pd "\\/types\\/1\","
805 "\"name\":\"A<A<bool>>\",", cid);
806
807 // Request for non-existent canonical type from class A.
808 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'types', '42'],"
809 "[], []]", cid);
810 Service::HandleIsolateMessage(isolate, service_msg);
811 handler.HandleNextMessage();
812 ExpectSubstringF(handler.msg(),
813 "{\"type\":\"Error\",\"id\":\"\","
814 "\"message\":\"Canonical type 42 not found\""
815 ",\"request\":"
816 "{\"arguments\":[\"classes\",\"%" Pd "\",\"types\",\"42\"],"
817 "\"option_keys\":[],\"option_values\":[]}}", cid);
818
819 // Request canonical type arguments. Expect <A<bool>> to be listed.
820 service_msg = EvalF(h_lib, "[port, ['typearguments'],"
821 "[], []]");
822 Service::HandleIsolateMessage(isolate, service_msg);
823 handler.HandleNextMessage();
824 EXPECT_SUBSTRING("\"type\":\"TypeArgumentsList\"", handler.msg());
825 ExpectSubstringF(handler.msg(), "\"name\":\"<A<bool>>\",");
826
827 // Request canonical type arguments with instantiations.
828 service_msg = EvalF(h_lib, "[port, ['typearguments', 'withinstantiations'],"
829 "[], []]");
830 Service::HandleIsolateMessage(isolate, service_msg);
831 handler.HandleNextMessage();
832 EXPECT_SUBSTRING("\"type\":\"TypeArgumentsList\"", handler.msg());
833 }
834
835
747 TEST_CASE(Service_Code) { 836 TEST_CASE(Service_Code) {
748 const char* kScript = 837 const char* kScript =
749 "var port;\n" // Set to our mock port by C++. 838 "var port;\n" // Set to our mock port by C++.
750 "\n" 839 "\n"
751 "class A {\n" 840 "class A {\n"
752 " var a;\n" 841 " var a;\n"
753 " dynamic b() {}\n" 842 " dynamic b() {}\n"
754 " dynamic c() {\n" 843 " dynamic c() {\n"
755 " var d = () { b(); };\n" 844 " var d = () { b(); };\n"
756 " return d;\n" 845 " return d;\n"
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 EXPECT_SUBSTRING("\"type\":\"Profile\"", handler.msg()); 1237 EXPECT_SUBSTRING("\"type\":\"Profile\"", handler.msg());
1149 1238
1150 service_msg = Eval(h_lib, "[port, ['profile'], ['tags'], ['hidden']]"); 1239 service_msg = Eval(h_lib, "[port, ['profile'], ['tags'], ['hidden']]");
1151 Service::HandleIsolateMessage(isolate, service_msg); 1240 Service::HandleIsolateMessage(isolate, service_msg);
1152 handler.HandleNextMessage(); 1241 handler.HandleNextMessage();
1153 // Expect error. 1242 // Expect error.
1154 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); 1243 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg());
1155 } 1244 }
1156 1245
1157 } // namespace dart 1246 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698