mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Test saving compilation traces. (flutter/engine#8618)
This commit is contained in:
parent
bc238390cc
commit
24ee83dbde
@ -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 @@ TEST_F(DartIsolateTest, CanRegisterNativeCallback) {
|
||||
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
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:isolate';
|
||||
import 'dart:ui';
|
||||
|
||||
void main() {
|
||||
}
|
||||
@ -26,6 +27,18 @@ void canRegisterNativeCallback() async {
|
||||
|
||||
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";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user