1package io.flutter.embedding.engine.dart;
3import static junit.framework.TestCase.assertNotNull;
4import static org.junit.Assert.assertEquals;
5import static org.junit.Assert.assertThrows;
6import static org.mockito.ArgumentMatchers.anyInt;
7import static org.mockito.ArgumentMatchers.eq;
8import static org.mockito.Mockito.mock;
9import static org.mockito.Mockito.times;
10import static org.mockito.Mockito.verify;
11import static org.mockito.Mockito.when;
13import android.content.res.AssetManager;
14import androidx.test.ext.junit.runners.AndroidJUnit4;
15import io.flutter.FlutterInjector;
16import io.flutter.embedding.engine.FlutterJNI;
17import io.flutter.embedding.engine.dart.DartExecutor.DartEntrypoint;
18import io.flutter.embedding.engine.loader.FlutterLoader;
19import java.nio.ByteBuffer;
20import org.junit.Before;
22import org.junit.runner.RunWith;
23import org.mockito.Mock;
24import org.mockito.MockitoAnnotations;
25import org.robolectric.annotation.Config;
28@RunWith(AndroidJUnit4.class)
35 MockitoAnnotations.openMocks(
this);
50 ByteBuffer fakeMessage = mock(ByteBuffer.class);
54 verify(fakeFlutterJni,
times(1))
55 .dispatchPlatformMessage(
eq(
"fake_channel"),
eq(fakeMessage), anyInt(), anyInt());
61 when(mockFlutterJNI.
isAttached()).thenReturn(
true);
65 verify(mockFlutterJNI,
times(1)).notifyLowMemoryWarning();
73 DartEntrypoint.createDefault();
79 when(mockFlutterLoader.initialized()).thenReturn(
true);
80 when(mockFlutterLoader.findAppBundlePath()).thenReturn(
"my/custom/path");
static SkISize times(const SkISize &size, float factor)
static bool eq(const SkM44 &a, const SkM44 &b, float tol)
Builder setFlutterLoader(@NonNull FlutterLoader flutterLoader)
static void setInstance(@NonNull FlutterInjector injector)
FlutterLoader mockFlutterLoader
void itSendsBinaryMessages()
void itNotifiesLowMemoryWarning()
void itThrowsWhenCreatingADefaultDartEntrypointWithAnUninitializedFlutterLoader()
void itHasReasonableDefaultsWhenFlutterLoaderIsInitialized()
static DartEntrypoint createDefault()
final String pathToBundle
final String dartEntrypointFunctionName
void notifyLowMemoryWarning()
BinaryMessenger getBinaryMessenger()
void send(@NonNull String channel, @Nullable ByteBuffer message)