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

Unified Diff: runtime/vm/debugger_test.cc

Issue 381383010: Add breakpoints and single-stepping to Observatory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix bugs, gen js Created 6 years, 5 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
Index: runtime/vm/debugger_test.cc
diff --git a/runtime/vm/debugger_test.cc b/runtime/vm/debugger_test.cc
index d9c508b23bf3dcb8dae7be5a2db9530fc10bb300..e53f291120dbf6522dfc1c22768d03cd5084418b 100644
--- a/runtime/vm/debugger_test.cc
+++ b/runtime/vm/debugger_test.cc
@@ -2,11 +2,34 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+#include "vm/dart_api_impl.h"
#include "vm/debugger.h"
#include "vm/unit_test.h"
namespace dart {
+// Search for the formatted string in buffer.
+//
+// TODO(turnidge): This function obscures the line number of failing
+// EXPECTs. Rework this.
+static void ExpectSubstringF(const char* buff, const char* fmt, ...) {
+ Isolate* isolate = Isolate::Current();
+
+ va_list args;
+ va_start(args, fmt);
+ intptr_t len = OS::VSNPrint(NULL, 0, fmt, args);
+ va_end(args);
+
+ char* buffer = isolate->current_zone()->Alloc<char>(len + 1);
+ va_list args2;
+ va_start(args2, fmt);
+ OS::VSNPrint(buffer, (len + 1), fmt, args2);
+ va_end(args2);
+
+ EXPECT_SUBSTRING(buffer, buff);
+}
+
+
TEST_CASE(Debugger_PrintBreakpointsToJSONArray) {
const char* kScriptChars =
"main() {\n"
@@ -17,6 +40,9 @@ TEST_CASE(Debugger_PrintBreakpointsToJSONArray) {
"}\n";
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
EXPECT_VALID(lib);
+ Library& vmlib = Library::Handle();
+ vmlib ^= Api::UnwrapHandle(lib);
+ EXPECT(!vmlib.IsNull());
Isolate* isolate = Isolate::Current();
Debugger* debugger = isolate->debugger();
@@ -41,16 +67,23 @@ TEST_CASE(Debugger_PrintBreakpointsToJSONArray) {
JSONArray jsarr(&js);
debugger->PrintBreakpointsToJSONArray(&jsarr);
}
- EXPECT_STREQ(
- "[{\"type\":\"Breakpoint\",\"id\":2,"
- "\"enabled\":true,\"resolved\":false,"
- "\"location\":{\"type\":\"Location\","
- "\"script\":\"test-lib\",\"tokenPos\":14}},"
- "{\"type\":\"Breakpoint\",\"id\":1,"
- "\"enabled\":true,\"resolved\":false,"
- "\"location\":{\"type\":\"Location\","
- "\"script\":\"test-lib\",\"tokenPos\":5}}]",
- js.ToCString());
+ ExpectSubstringF(
+ js.ToCString(),
+ "[{\"type\":\"Breakpoint\",\"id\":\"debug\\/breakpoints\\/2\","
+ "\"breakpointNumber\":2,\"enabled\":true,\"resolved\":false,"
+ "\"location\":{\"type\":\"Location\","
+ "\"script\":{\"type\":\"@Script\","
+ "\"id\":\"libraries\\/%" Pd "\\/scripts\\/test-lib\","
+ "\"name\":\"test-lib\",\"user_name\":\"test-lib\","
+ "\"kind\":\"script\"},\"tokenPos\":14}},"
+ "{\"type\":\"Breakpoint\",\"id\":\"debug\\/breakpoints\\/1\","
+ "\"breakpointNumber\":1,\"enabled\":true,\"resolved\":false,"
+ "\"location\":{\"type\":\"Location\","
+ "\"script\":{\"type\":\"@Script\","
+ "\"id\":\"libraries\\/%" Pd "\\/scripts\\/test-lib\","
+ "\"name\":\"test-lib\",\"user_name\":\"test-lib\","
+ "\"kind\":\"script\"},\"tokenPos\":5}}]",
+ vmlib.index(), vmlib.index());
}
}

Powered by Google App Engine
This is Rietveld 408576698