29 {
30
31 FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);
32 FlutterJNI flutterJNI = mock(FlutterJNI.class);
34 when(flutterJNI.isAttached()).thenAnswer(invocation ->
jniAttached);
35 doAnswer(invocation ->
jniAttached =
true).when(flutterJNI).attachToNative();
36
37 FlutterLoader flutterLoader = new FlutterLoader(mockFlutterJNI);
38
39
41 new FlutterEngine(ApplicationProvider.getApplicationContext(), flutterLoader, flutterJNI);
42
43
44
45 PluginThatAccessesAssets plugin = new PluginThatAccessesAssets();
46 flutterEngine.getPlugins().add(plugin);
47
48
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 }