7import static org.junit.Assert.assertEquals;
8import static org.junit.Assert.assertNotNull;
9import static org.junit.Assert.assertNull;
10import static org.junit.Assert.assertThrows;
11import static org.junit.Assert.assertTrue;
13import androidx.test.ext.junit.runners.AndroidJUnit4;
14import io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager;
15import io.flutter.embedding.engine.loader.FlutterLoader;
16import java.util.Arrays;
18import java.util.concurrent.Callable;
19import java.util.concurrent.ExecutionException;
20import java.util.concurrent.ExecutorService;
21import java.util.concurrent.Future;
22import org.junit.After;
23import org.junit.Before;
25import org.junit.runner.RunWith;
26import org.mockito.Mock;
27import org.mockito.MockitoAnnotations;
28import org.robolectric.annotation.Config;
31@RunWith(AndroidJUnit4.class)
41 MockitoAnnotations.openMocks(
this);
53 assertNotNull(injector.flutterLoader());
54 assertNull(injector.deferredComponentManager());
55 assertNotNull(injector.executorService());
60 throws InterruptedException, ExecutionException {
67 return Thread.currentThread().getName();
70 return Thread.currentThread().getName();
74 threadNames = injector.executorService().invokeAll(callables);
76 assertEquals(threadNames.size(), 2);
77 for (Future<String>
name : threadNames) {
78 assertTrue(
name.get().startsWith(
"flutter-worker-"));
87 assertEquals(injector.flutterLoader(), mockFlutterLoader);
97 assertEquals(injector.deferredComponentManager(), mockDeferredComponentManager);
105 assertEquals(injector.executorService(), mockExecutorService);
109 public
void cannotBeChangedOnceRead() {
113 IllegalStateException.class,
115 FlutterInjector.setInstance(
116 new FlutterInjector.Builder().setFlutterLoader(mockFlutterLoader).build());
FlutterLoader mockFlutterLoader
void canInjectDeferredComponentManager()
void canInjectExecutorService()
void canPartiallyOverride()
void executorCreatesAndNamesNewThreadsByDefault()
ExecutorService mockExecutorService
PlayStoreDeferredComponentManager mockDeferredComponentManager
void itHasSomeReasonableDefaults()
Builder setFlutterLoader(@NonNull FlutterLoader flutterLoader)
Builder setDeferredComponentManager( @Nullable DeferredComponentManager deferredComponentManager)
Builder setExecutorService(@NonNull ExecutorService executorService)
static void setInstance(@NonNull FlutterInjector injector)
DEF_SWITCHES_START aot vmservice shared library name