Index: runtime/vm/dart_api_impl_test.cc |
diff --git a/runtime/vm/dart_api_impl_test.cc b/runtime/vm/dart_api_impl_test.cc |
index 46653c859cd37d225bd3bd55b8894823b0ef4f89..ee7a0c2b45a414ddca6ea00c4489e0da6e873ab3 100644 |
--- a/runtime/vm/dart_api_impl_test.cc |
+++ b/runtime/vm/dart_api_impl_test.cc |
@@ -9278,4 +9278,39 @@ TEST_CASE(Timeline_Dart_TimelineAsync) { |
EXPECT_SUBSTRING("testAsyncEvent", js.ToCString()); |
} |
+ |
+TEST_CASE(Timeline_Dart_TimelineGetTrace) { |
+ const char* kScriptChars = |
+ "foo() => 'a';\n" |
+ "main() => foo();\n"; |
+ |
+ Dart_Handle lib = |
+ TestCase::LoadTestScript(kScriptChars, NULL); |
+ |
+ const char* buffer = NULL; |
+ intptr_t buffer_length = 0; |
+ bool success = false; |
+ |
+ // Enable recording of all streams. |
+ Dart_TimelineSetRecordedStreams(DART_TIMELINE_STREAM_ALL); |
+ |
+ // Invoke main, which will be compiled resulting in a compiler event in |
+ // the timeline. |
+ Dart_Handle result = Dart_Invoke(lib, |
+ NewString("main"), |
+ 0, |
+ NULL); |
+ EXPECT_VALID(result); |
+ |
+ // Grab the trace. |
+ success = Dart_TimelineGetTrace(&buffer, &buffer_length); |
+ EXPECT(success); |
+ EXPECT(buffer_length > 0); |
+ EXPECT(buffer != NULL); |
+ // Heartbeat test. |
+ EXPECT_SUBSTRING("\"cat\":\"Compiler\"", buffer); |
+ EXPECT_SUBSTRING("\"name\":\"CompileFunction\"", buffer); |
+ EXPECT_SUBSTRING("\"function\":\"main\"", buffer); |
+} |
+ |
} // namespace dart |