Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Package Attributes | List of all members
test.io.flutter.embedding.engine.PluginComponentTest Class Reference

Public Member Functions

void pluginsCanAccessFlutterAssetPaths ()
 

Package Attributes

boolean jniAttached
 

Detailed Description

Definition at line 25 of file PluginComponentTest.java.

Member Function Documentation

◆ pluginsCanAccessFlutterAssetPaths()

void test.io.flutter.embedding.engine.PluginComponentTest.pluginsCanAccessFlutterAssetPaths ( )
inline

Definition at line 29 of file PluginComponentTest.java.

29 {
30 // Setup test.
31 FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);
32 FlutterJNI flutterJNI = mock(FlutterJNI.class);
33 jniAttached = false;
34 when(flutterJNI.isAttached()).thenAnswer(invocation -> jniAttached);
35 doAnswer(invocation -> jniAttached = true).when(flutterJNI).attachToNative();
36
37 FlutterLoader flutterLoader = new FlutterLoader(mockFlutterJNI);
38
39 // Execute behavior under test.
40 FlutterEngine flutterEngine =
41 new FlutterEngine(ApplicationProvider.getApplicationContext(), flutterLoader, flutterJNI);
42
43 // As soon as our plugin is registered it will look up asset paths and store them
44 // for our verification.
45 PluginThatAccessesAssets plugin = new PluginThatAccessesAssets();
46 flutterEngine.getPlugins().add(plugin);
47
48 // Verify results.
49 assertEquals("flutter_assets/fake_asset.jpg", plugin.getAssetPathBasedOnName());
50 assertEquals(
51 "flutter_assets/packages/fakepackage/fake_asset.jpg",
52 plugin.getAssetPathBasedOnNameAndPackage());
53 assertEquals("flutter_assets/some/path/fake_asset.jpg", plugin.getAssetPathBasedOnSubpath());
54 assertEquals(
55 "flutter_assets/packages/fakepackage/some/path/fake_asset.jpg",
56 plugin.getAssetPathBasedOnSubpathAndPackage());
57 }

Member Data Documentation

◆ jniAttached

boolean test.io.flutter.embedding.engine.PluginComponentTest.jniAttached
package

Definition at line 26 of file PluginComponentTest.java.


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