Make DartExecutor.isExecutingDart account for spawned engines (flutter/engine#25171)
This commit is contained in:
@@ -61,6 +61,11 @@ public class DartExecutor implements BinaryMessenger {
|
||||
this.dartMessenger = new DartMessenger(flutterJNI);
|
||||
dartMessenger.setMessageHandler("flutter/isolate", isolateChannelMessageHandler);
|
||||
this.binaryMessenger = new DefaultBinaryMessenger(dartMessenger);
|
||||
// The JNI might already be attached if coming from a spawned engine. If so, correctly report
|
||||
// that this DartExecutor is already running.
|
||||
if (flutterJNI.isAttached()) {
|
||||
isApplicationRunning = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -232,4 +232,23 @@ public class FlutterEngineTest {
|
||||
|
||||
verify(flutterJNI, never()).attachToNative(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itComesWithARunningDartExecutorIfJNIIsAlreadyAttached() throws NameNotFoundException {
|
||||
Context context = mock(Context.class);
|
||||
Context packageContext = mock(Context.class);
|
||||
|
||||
when(context.createPackageContext(any(), anyInt())).thenReturn(packageContext);
|
||||
when(flutterJNI.isAttached()).thenReturn(true);
|
||||
|
||||
FlutterEngine engineUnderTest =
|
||||
new FlutterEngine(
|
||||
context,
|
||||
mock(FlutterLoader.class),
|
||||
flutterJNI,
|
||||
/*dartVmArgs=*/ new String[] {},
|
||||
/*automaticallyRegisterPlugins=*/ false);
|
||||
|
||||
assertTrue(engineUnderTest.getDartExecutor().isExecutingDart());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user