Test saving compilation traces. (#8618)

diff --git a/runtime/dart_isolate_unittests.cc b/runtime/dart_isolate_unittests.cc
index 1c77bc8..eb12946 100644
--- a/runtime/dart_isolate_unittests.cc
+++ b/runtime/dart_isolate_unittests.cc
@@ -13,6 +13,7 @@
 #include "flutter/runtime/runtime_test.h"
 #include "flutter/testing/testing.h"
 #include "flutter/testing/thread_test.h"
+#include "third_party/tonic/converter/dart_converter.h"
 #include "third_party/tonic/scopes/dart_isolate_scope.h"
 
 namespace flutter {
@@ -320,5 +321,29 @@
   latch.Wait();
 }
 
+TEST_F(DartIsolateTest, CanSaveCompilationTrace) {
+  if (DartVM::IsRunningPrecompiledCode()) {
+    // Can only save compilation traces in JIT modes.
+    GTEST_SKIP();
+    return;
+  }
+  fml::AutoResetWaitableEvent latch;
+  AddNativeCallback("NotifyNative",
+                    CREATE_NATIVE_ENTRY(([&latch](Dart_NativeArguments args) {
+                      ASSERT_TRUE(tonic::DartConverter<bool>::FromDart(
+                          Dart_GetNativeArgument(args, 0)));
+                      latch.Signal();
+                    })));
+
+  const auto settings = CreateSettingsForFixture();
+  auto vm_ref = DartVMRef::Create(settings);
+  auto isolate = RunDartCodeInIsolate(vm_ref, settings, GetThreadTaskRunner(),
+                                      "testCanSaveCompilationTrace");
+  ASSERT_TRUE(isolate);
+  ASSERT_EQ(isolate->get()->GetPhase(), DartIsolate::Phase::Running);
+
+  latch.Wait();
+}
+
 }  // namespace testing
 }  // namespace flutter
diff --git a/runtime/fixtures/simple_main.dart b/runtime/fixtures/simple_main.dart
index bc2d880..f9ba92d 100644
--- a/runtime/fixtures/simple_main.dart
+++ b/runtime/fixtures/simple_main.dart
@@ -3,6 +3,7 @@
 // found in the LICENSE file.
 
 import 'dart:isolate';
+import 'dart:ui';
 
 void main() {
 }
@@ -26,6 +27,18 @@
 
 void NotifyNative() native "NotifyNative";
 
-
 @pragma('vm:entry-point')
 void testIsolateShutdown() {  }
+
+@pragma('vm:entry-point')
+void testCanSaveCompilationTrace() {
+  List<int> trace = null;
+  try {
+    trace = saveCompilationTrace();
+  } catch (exception) {
+    print("Could not save compilation trace: " + exception);
+  }
+  NotifyResult(trace != null && trace.length > 0);
+}
+
+void NotifyResult(bool success) native "NotifyNative";