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

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

Issue 1132323002: Add Service ID zones to service protocol (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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_isolate.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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 102
103 static RawClass* GetClass(const Library& lib, const char* name) { 103 static RawClass* GetClass(const Library& lib, const char* name) {
104 const Class& cls = Class::Handle( 104 const Class& cls = Class::Handle(
105 lib.LookupClass(String::Handle(Symbols::New(name)))); 105 lib.LookupClass(String::Handle(Symbols::New(name))));
106 EXPECT(!cls.IsNull()); // No ambiguity error expected. 106 EXPECT(!cls.IsNull()); // No ambiguity error expected.
107 return cls.raw(); 107 return cls.raw();
108 } 108 }
109 109
110 110
111 TEST_CASE(Service_IdZones) {
112 Isolate* isolate = Isolate::Current();
113 ObjectIdRing* ring = isolate->object_id_ring();
114
115 const String& test_a = String::Handle(isolate, String::New("a"));
116 const String& test_b = String::Handle(isolate, String::New("b"));
117 const String& test_c = String::Handle(isolate, String::New("c"));
118 const String& test_d = String::Handle(isolate, String::New("d"));
119
120 // Both RingServiceIdZones share the same backing store and id space.
121
122 // Always allocate a new id.
123 RingServiceIdZone always_new_zone(ring, ObjectIdRing::kAllocateId);
124 EXPECT_STREQ("objects/0", always_new_zone.GetServiceId(test_a));
125 EXPECT_STREQ("objects/1", always_new_zone.GetServiceId(test_a));
126 EXPECT_STREQ("objects/2", always_new_zone.GetServiceId(test_a));
127 EXPECT_STREQ("objects/3", always_new_zone.GetServiceId(test_b));
128 EXPECT_STREQ("objects/4", always_new_zone.GetServiceId(test_c));
129
130 // Reuse an existing id or allocate a new id.
131 RingServiceIdZone reuse_zone(ring, ObjectIdRing::kReuseId);
132 EXPECT_STREQ("objects/0", reuse_zone.GetServiceId(test_a));
133 EXPECT_STREQ("objects/0", reuse_zone.GetServiceId(test_a));
134 EXPECT_STREQ("objects/3", reuse_zone.GetServiceId(test_b));
135 EXPECT_STREQ("objects/3", reuse_zone.GetServiceId(test_b));
136 EXPECT_STREQ("objects/4", reuse_zone.GetServiceId(test_c));
137 EXPECT_STREQ("objects/4", reuse_zone.GetServiceId(test_c));
138 EXPECT_STREQ("objects/5", reuse_zone.GetServiceId(test_d));
139 EXPECT_STREQ("objects/5", reuse_zone.GetServiceId(test_d));
140 }
141
142
111 TEST_CASE(Service_Code) { 143 TEST_CASE(Service_Code) {
112 const char* kScript = 144 const char* kScript =
113 "var port;\n" // Set to our mock port by C++. 145 "var port;\n" // Set to our mock port by C++.
114 "\n" 146 "\n"
115 "class A {\n" 147 "class A {\n"
116 " var a;\n" 148 " var a;\n"
117 " dynamic b() {}\n" 149 " dynamic b() {}\n"
118 " dynamic c() {\n" 150 " dynamic c() {\n"
119 " var d = () { b(); };\n" 151 " var d = () { b(); };\n"
120 " return d;\n" 152 " return d;\n"
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 Eval(lib, "[0, port, '0', 'getCpuProfile', ['tags'], ['Bogus']]"); 620 Eval(lib, "[0, port, '0', 'getCpuProfile', ['tags'], ['Bogus']]");
589 Service::HandleIsolateMessage(isolate, service_msg); 621 Service::HandleIsolateMessage(isolate, service_msg);
590 handler.HandleNextMessage(); 622 handler.HandleNextMessage();
591 // Expect error. 623 // Expect error.
592 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); 624 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg());
593 } 625 }
594 626
595 #endif // !defined(TARGET_ARCH_ARM64) 627 #endif // !defined(TARGET_ARCH_ARM64)
596 628
597 } // namespace dart 629 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/service_isolate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698