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

Unified Diff: runtime/vm/service_test.cc

Issue 920813003: Refactor service code and service method parameters (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/service_isolate.cc ('k') | runtime/vm/vm_sources.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/service_test.cc
diff --git a/runtime/vm/service_test.cc b/runtime/vm/service_test.cc
index 17691b415fd2cbb7c552b98546a8153ecd9f82b1..1670e0d649d3fa995d3bdab8a079c1fa38e3a710 100644
--- a/runtime/vm/service_test.cc
+++ b/runtime/vm/service_test.cc
@@ -89,7 +89,26 @@ class ServiceTestMessageHandler : public MessageHandler {
};
+static RawArray* EvalVM(Dart_Handle lib, const char* expr) {
+ Dart_Handle expr_val = Dart_EvaluateExpr(lib, NewString(expr));
+ EXPECT_VALID(expr_val);
+ Isolate* isolate = Isolate::Current();
+ const GrowableObjectArray& value =
+ Api::UnwrapGrowableObjectArrayHandle(isolate, expr_val);
+ const Array& result = Array::Handle(Array::MakeArray(value));
+ GrowableObjectArray& growable = GrowableObjectArray::Handle();
+ growable ^= result.At(3);
+ Array& array = Array::Handle(Array::MakeArray(growable));
+ result.SetAt(3, array);
+ growable ^= result.At(4);
+ array = Array::MakeArray(growable);
+ result.SetAt(4, array);
+ return result.raw();
+}
+
+
static RawArray* Eval(Dart_Handle lib, const char* expr) {
+ const String& dummy_isolate_id = String::Handle(String::New("isolateId"));
Dart_Handle expr_val = Dart_EvaluateExpr(lib, NewString(expr));
EXPECT_VALID(expr_val);
Isolate* isolate = Isolate::Current();
@@ -98,9 +117,13 @@ static RawArray* Eval(Dart_Handle lib, const char* expr) {
const Array& result = Array::Handle(Array::MakeArray(value));
GrowableObjectArray& growable = GrowableObjectArray::Handle();
growable ^= result.At(3);
+ // Append dummy isolate id to parameter values.
+ growable.Add(dummy_isolate_id);
Array& array = Array::Handle(Array::MakeArray(growable));
result.SetAt(3, array);
growable ^= result.At(4);
+ // Append dummy isolate id to parameter values.
+ growable.Add(dummy_isolate_id);
array = Array::MakeArray(growable);
result.SetAt(4, array);
return result.raw();
@@ -1052,7 +1075,7 @@ TEST_CASE(Service_VM) {
EXPECT_VALID(Dart_SetField(lib, NewString("port"), port));
Array& service_msg = Array::Handle();
- service_msg = Eval(lib, "[0, port, 'getVM', [], []]");
+ service_msg = EvalVM(lib, "[0, port, 'getVM', [], []]");
Service::HandleRootMessage(service_msg);
handler.HandleNextMessage();
@@ -1084,7 +1107,7 @@ TEST_CASE(Service_Flags) {
EXPECT_VALID(Dart_SetField(lib, NewString("port"), port));
Array& service_msg = Array::Handle();
- service_msg = Eval(lib, "[0, port, 'getFlagList', [], []]");
+ service_msg = EvalVM(lib, "[0, port, 'getFlagList', [], []]");
// Make sure we can get the FlagList.
Service::HandleRootMessage(service_msg);
@@ -1096,15 +1119,15 @@ TEST_CASE(Service_Flags) {
handler.msg());
// Modify a flag through the vm service.
- service_msg = Eval(lib,
- "[0, port, 'setFlag', "
- "['name', 'value'], ['service_testing_flag', 'true']]");
+ service_msg = EvalVM(lib,
+ "[0, port, 'setFlag', "
+ "['name', 'value'], ['service_testing_flag', 'true']]");
Service::HandleRootMessage(service_msg);
handler.HandleNextMessage();
EXPECT_SUBSTRING("Success", handler.msg());
// Make sure that the flag changed.
- service_msg = Eval(lib, "[0, port, 'getFlagList', [], []]");
+ service_msg = EvalVM(lib, "[0, port, 'getFlagList', [], []]");
Service::HandleRootMessage(service_msg);
handler.HandleNextMessage();
EXPECT_SUBSTRING(
@@ -1435,8 +1458,8 @@ TEST_CASE(Service_Profile) {
service_msg = Eval(lib, "[0, port, 'getCpuProfile', [], []]");
Service::HandleIsolateMessage(isolate, service_msg);
handler.HandleNextMessage();
- // Expect profile
- EXPECT_SUBSTRING("\"type\":\"CpuProfile\"", handler.msg());
+ // Expect error (tags required).
+ EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg());
service_msg =
Eval(lib, "[0, port, 'getCpuProfile', ['tags'], ['None']]");
« no previous file with comments | « runtime/vm/service_isolate.cc ('k') | runtime/vm/vm_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698