Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
io.flutter.embedding.engine.loader.FlutterLoaderTest Class Reference

Public Member Functions

void itReportsUninitializedAfterCreating ()
 
void itReportsInitializedAfterInitializing ()
 
void itDefaultsTheOldGenHeapSizeAppropriately ()
 
void itDefaultsTheResourceCacheMaxBytesThresholdAppropriately ()
 
void itSetsLeakVMToTrueByDefault ()
 
void itSetsTheLeakVMFromMetaData ()
 
void itUsesCorrectExecutorService ()
 
void itDoesNotSetEnableImpellerByDefault ()
 
void itDoesNotSetEnableVulkanValidationByDefault ()
 
void itSetsEnableImpellerFromMetaData ()
 
void itReportsFpsToVsyncWaiterAndroidM ()
 

Detailed Description

Definition at line 41 of file FlutterLoaderTest.java.

Member Function Documentation

◆ itDefaultsTheOldGenHeapSizeAppropriately()

void io.flutter.embedding.engine.loader.FlutterLoaderTest.itDefaultsTheOldGenHeapSizeAppropriately ( )
inline

Definition at line 65 of file FlutterLoaderTest.java.

65 {
66 FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);
67 FlutterLoader flutterLoader = new FlutterLoader(mockFlutterJNI);
68
69 assertFalse(flutterLoader.initialized());
70 flutterLoader.startInitialization(ctx);
71 flutterLoader.ensureInitializationComplete(ctx, null);
72 shadowOf(getMainLooper()).idle();
73
74 ActivityManager activityManager =
75 (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE);
76 ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
77 activityManager.getMemoryInfo(memInfo);
78 int oldGenHeapSizeMegaBytes = (int) (memInfo.totalMem / 1e6 / 2);
79 final String oldGenHeapArg = "--old-gen-heap-size=" + oldGenHeapSizeMegaBytes;
80 ArgumentCaptor<String[]> shellArgsCaptor = ArgumentCaptor.forClass(String[].class);
81 verify(mockFlutterJNI, times(1))
82 .init(eq(ctx), shellArgsCaptor.capture(), anyString(), anyString(), anyString(), anyLong());
83 List<String> arguments = Arrays.asList(shellArgsCaptor.getValue());
84 assertTrue(arguments.contains(oldGenHeapArg));
85 }
static SkISize times(const SkISize &size, float factor)
static bool eq(const SkM44 &a, const SkM44 &b, float tol)
Definition: M44Test.cpp:18

◆ itDefaultsTheResourceCacheMaxBytesThresholdAppropriately()

void io.flutter.embedding.engine.loader.FlutterLoaderTest.itDefaultsTheResourceCacheMaxBytesThresholdAppropriately ( )
inline

Definition at line 88 of file FlutterLoaderTest.java.

88 {
89 FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);
90 FlutterLoader flutterLoader = new FlutterLoader(mockFlutterJNI);
91
92 assertFalse(flutterLoader.initialized());
93 flutterLoader.startInitialization(ctx);
94 flutterLoader.ensureInitializationComplete(ctx, null);
95 shadowOf(getMainLooper()).idle();
96
97 DisplayMetrics displayMetrics = ctx.getResources().getDisplayMetrics();
98 int screenWidth = displayMetrics.widthPixels;
99 int screenHeight = displayMetrics.heightPixels;
100 int resourceCacheMaxBytesThreshold = screenWidth * screenHeight * 12 * 4;
101 final String resourceCacheMaxBytesThresholdArg =
102 "--resource-cache-max-bytes-threshold=" + resourceCacheMaxBytesThreshold;
103 ArgumentCaptor<String[]> shellArgsCaptor = ArgumentCaptor.forClass(String[].class);
104 verify(mockFlutterJNI, times(1))
105 .init(eq(ctx), shellArgsCaptor.capture(), anyString(), anyString(), anyString(), anyLong());
106 List<String> arguments = Arrays.asList(shellArgsCaptor.getValue());
107 assertTrue(arguments.contains(resourceCacheMaxBytesThresholdArg));
108 }

◆ itDoesNotSetEnableImpellerByDefault()

void io.flutter.embedding.engine.loader.FlutterLoaderTest.itDoesNotSetEnableImpellerByDefault ( )
inline

Definition at line 162 of file FlutterLoaderTest.java.

162 {
163 FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);
164 FlutterLoader flutterLoader = new FlutterLoader(mockFlutterJNI);
165
166 assertFalse(flutterLoader.initialized());
167 flutterLoader.startInitialization(ctx);
168 flutterLoader.ensureInitializationComplete(ctx, null);
169 shadowOf(getMainLooper()).idle();
170
171 final String enableImpellerArg = "--enable-impeller";
172 ArgumentCaptor<String[]> shellArgsCaptor = ArgumentCaptor.forClass(String[].class);
173 verify(mockFlutterJNI, times(1))
174 .init(eq(ctx), shellArgsCaptor.capture(), anyString(), anyString(), anyString(), anyLong());
175 List<String> arguments = Arrays.asList(shellArgsCaptor.getValue());
176 assertFalse(arguments.contains(enableImpellerArg));
177 }

◆ itDoesNotSetEnableVulkanValidationByDefault()

void io.flutter.embedding.engine.loader.FlutterLoaderTest.itDoesNotSetEnableVulkanValidationByDefault ( )
inline

Definition at line 180 of file FlutterLoaderTest.java.

180 {
181 FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);
182 FlutterLoader flutterLoader = new FlutterLoader(mockFlutterJNI);
183
184 assertFalse(flutterLoader.initialized());
185 flutterLoader.startInitialization(ctx);
186 flutterLoader.ensureInitializationComplete(ctx, null);
187 shadowOf(getMainLooper()).idle();
188
189 final String enableVulkanValidationArg = "--enable-vulkan-validation";
190 ArgumentCaptor<String[]> shellArgsCaptor = ArgumentCaptor.forClass(String[].class);
191 verify(mockFlutterJNI, times(1))
192 .init(eq(ctx), shellArgsCaptor.capture(), anyString(), anyString(), anyString(), anyLong());
193 List<String> arguments = Arrays.asList(shellArgsCaptor.getValue());
194 assertFalse(arguments.contains(enableVulkanValidationArg));
195 }

◆ itReportsFpsToVsyncWaiterAndroidM()

void io.flutter.embedding.engine.loader.FlutterLoaderTest.itReportsFpsToVsyncWaiterAndroidM ( )
inline

Definition at line 222 of file FlutterLoaderTest.java.

222 {
223 FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);
224 FlutterLoader flutterLoader = new FlutterLoader(mockFlutterJNI);
225
226 Context appContextSpy = spy(ctx);
227
228 assertFalse(flutterLoader.initialized());
229 flutterLoader.startInitialization(appContextSpy);
230 verify(appContextSpy, never()).getSystemService(anyString());
231 }

◆ itReportsInitializedAfterInitializing()

void io.flutter.embedding.engine.loader.FlutterLoaderTest.itReportsInitializedAfterInitializing ( )
inline

Definition at line 51 of file FlutterLoaderTest.java.

51 {
52 FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);
53 FlutterLoader flutterLoader = new FlutterLoader(mockFlutterJNI);
54
55 assertFalse(flutterLoader.initialized());
56 flutterLoader.startInitialization(ctx);
57 flutterLoader.ensureInitializationComplete(ctx, null);
58 shadowOf(getMainLooper()).idle();
59 assertTrue(flutterLoader.initialized());
60 verify(mockFlutterJNI, times(1)).loadLibrary();
61 verify(mockFlutterJNI, times(1)).updateRefreshRate();
62 }

◆ itReportsUninitializedAfterCreating()

void io.flutter.embedding.engine.loader.FlutterLoaderTest.itReportsUninitializedAfterCreating ( )
inline

Definition at line 45 of file FlutterLoaderTest.java.

45 {
46 FlutterLoader flutterLoader = new FlutterLoader();
47 assertFalse(flutterLoader.initialized());
48 }

◆ itSetsEnableImpellerFromMetaData()

void io.flutter.embedding.engine.loader.FlutterLoaderTest.itSetsEnableImpellerFromMetaData ( )
inline

Definition at line 198 of file FlutterLoaderTest.java.

198 {
199 FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);
200 FlutterLoader flutterLoader = new FlutterLoader(mockFlutterJNI);
201 Bundle metaData = new Bundle();
202 metaData.putBoolean("io.flutter.embedding.android.EnableImpeller", true);
203 ctx.getApplicationInfo().metaData = metaData;
204
205 FlutterLoader.Settings settings = new FlutterLoader.Settings();
206 assertFalse(flutterLoader.initialized());
207 flutterLoader.startInitialization(ctx, settings);
208 flutterLoader.ensureInitializationComplete(ctx, null);
209 shadowOf(getMainLooper()).idle();
210
211 final String enableImpellerArg = "--enable-impeller";
212 ArgumentCaptor<String[]> shellArgsCaptor = ArgumentCaptor.forClass(String[].class);
213 verify(mockFlutterJNI, times(1))
214 .init(eq(ctx), shellArgsCaptor.capture(), anyString(), anyString(), anyString(), anyLong());
215 List<String> arguments = Arrays.asList(shellArgsCaptor.getValue());
216 assertTrue(arguments.contains(enableImpellerArg));
217 }

◆ itSetsLeakVMToTrueByDefault()

void io.flutter.embedding.engine.loader.FlutterLoaderTest.itSetsLeakVMToTrueByDefault ( )
inline

Definition at line 111 of file FlutterLoaderTest.java.

111 {
112 FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);
113 FlutterLoader flutterLoader = new FlutterLoader(mockFlutterJNI);
114
115 assertFalse(flutterLoader.initialized());
116 flutterLoader.startInitialization(ctx);
117 flutterLoader.ensureInitializationComplete(ctx, null);
118 shadowOf(getMainLooper()).idle();
119
120 final String leakVMArg = "--leak-vm=true";
121 ArgumentCaptor<String[]> shellArgsCaptor = ArgumentCaptor.forClass(String[].class);
122 verify(mockFlutterJNI, times(1))
123 .init(eq(ctx), shellArgsCaptor.capture(), anyString(), anyString(), anyString(), anyLong());
124 List<String> arguments = Arrays.asList(shellArgsCaptor.getValue());
125 assertTrue(arguments.contains(leakVMArg));
126 }

◆ itSetsTheLeakVMFromMetaData()

void io.flutter.embedding.engine.loader.FlutterLoaderTest.itSetsTheLeakVMFromMetaData ( )
inline

Definition at line 129 of file FlutterLoaderTest.java.

129 {
130 FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);
131 FlutterLoader flutterLoader = new FlutterLoader(mockFlutterJNI);
132 Bundle metaData = new Bundle();
133 metaData.putBoolean("io.flutter.embedding.android.LeakVM", false);
134 ctx.getApplicationInfo().metaData = metaData;
135
136 FlutterLoader.Settings settings = new FlutterLoader.Settings();
137 assertFalse(flutterLoader.initialized());
138 flutterLoader.startInitialization(ctx, settings);
139 flutterLoader.ensureInitializationComplete(ctx, null);
140 shadowOf(getMainLooper()).idle();
141
142 final String leakVMArg = "--leak-vm=false";
143 ArgumentCaptor<String[]> shellArgsCaptor = ArgumentCaptor.forClass(String[].class);
144 verify(mockFlutterJNI, times(1))
145 .init(eq(ctx), shellArgsCaptor.capture(), anyString(), anyString(), anyString(), anyLong());
146 List<String> arguments = Arrays.asList(shellArgsCaptor.getValue());
147 assertTrue(arguments.contains(leakVMArg));
148 }

◆ itUsesCorrectExecutorService()

void io.flutter.embedding.engine.loader.FlutterLoaderTest.itUsesCorrectExecutorService ( )
inline

Definition at line 151 of file FlutterLoaderTest.java.

151 {
152 FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);
153 ExecutorService mockExecutorService = mock(ExecutorService.class);
154 FlutterLoader flutterLoader = new FlutterLoader(mockFlutterJNI, mockExecutorService);
155
156 assertFalse(flutterLoader.initialized());
157 flutterLoader.startInitialization(ctx);
158 verify(mockExecutorService, times(1)).submit(any(Callable.class));
159 }
SIT bool any(const Vec< 1, T > &x)
Definition: SkVx.h:530

The documentation for this class was generated from the following file: