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

Unified Diff: dart/runtime/vm/debugger_test.cc

Issue 119673004: Version 1.1.0-dev.5.2 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 11 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 | « dart/runtime/vm/debugger_mips.cc ('k') | dart/runtime/vm/debugger_x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/runtime/vm/debugger_test.cc
===================================================================
--- dart/runtime/vm/debugger_test.cc (revision 31530)
+++ dart/runtime/vm/debugger_test.cc (working copy)
@@ -9,11 +9,11 @@
TEST_CASE(Debugger_PrintBreakpointsToJSONArray) {
const char* kScriptChars =
- "void main() {\n"
- " print('won');\n"
- " print('too');\n"
- " print('free');\n"
- " print('for');\n"
+ "main() {\n"
+ " var x = new StringBuffer();\n"
+ " x.add('won');\n"
+ " x.add('too');\n"
+ " return x.toString();\n"
"}\n";
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
EXPECT_VALID(lib);
@@ -44,14 +44,66 @@
EXPECT_STREQ(
"[{\"type\":\"Breakpoint\",\"id\":2,"
"\"enabled\":true,\"resolved\":false,"
- "\"location\":{\"type\":\"Location\",\"libId\":12,"
- "\"script\":\"dart:test-lib\",\"tokenPos\":12}},"
+ "\"location\":{\"type\":\"Location\","
+ "\"script\":\"dart:test-lib\",\"tokenPos\":14}},"
"{\"type\":\"Breakpoint\",\"id\":1,"
"\"enabled\":true,\"resolved\":false,"
- "\"location\":{\"type\":\"Location\",\"libId\":12,"
- "\"script\":\"dart:test-lib\",\"tokenPos\":6}}]",
+ "\"location\":{\"type\":\"Location\","
+ "\"script\":\"dart:test-lib\",\"tokenPos\":5}}]",
js.ToCString());
}
}
+
+static bool saw_paused_event = false;
+
+static void InspectPausedEvent(Dart_IsolateId isolate_id,
+ intptr_t bp_id,
+ const Dart_CodeLocation& loc) {
+ Isolate* isolate = Isolate::Current();
+ Debugger* debugger = isolate->debugger();
+
+ // The debugger knows that it is paused, and why.
+ EXPECT(debugger->IsPaused());
+ const Debugger::DebuggerEvent* event = debugger->PauseEvent();
+ EXPECT(event != NULL);
+ EXPECT(event->type == Debugger::kBreakpointReached);
+ saw_paused_event = true;
+}
+
+
+TEST_CASE(Debugger_PauseEvent) {
+ const char* kScriptChars =
+ "main() {\n"
+ " var x = new StringBuffer();\n"
+ " x.write('won');\n"
+ " x.write('too');\n"
+ " return x.toString();\n"
+ "}\n";
+ Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
+ EXPECT_VALID(lib);
+
+ Isolate* isolate = Isolate::Current();
+ Debugger* debugger = isolate->debugger();
+ const String& url = String::Handle(String::New(TestCase::url()));
+
+ // No pause event.
+ EXPECT(!debugger->IsPaused());
+ EXPECT(debugger->PauseEvent() == NULL);
+
+ saw_paused_event = false;
+ Dart_SetPausedEventHandler(InspectPausedEvent);
+
+ // Set a breakpoint and run.
+ debugger->SetBreakpointAtLine(url, 2);
+ Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL);
+ EXPECT_VALID(result);
+ EXPECT(Dart_IsString(result));
+
+ // We ran the code in InspectPausedEvent.
+ EXPECT(saw_paused_event);
+}
+
+
+
} // namespace dart
« no previous file with comments | « dart/runtime/vm/debugger_mips.cc ('k') | dart/runtime/vm/debugger_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698