Flutter Engine
The Flutter Engine
Protected Member Functions | Package Functions | List of all members
io.flutter.embedding.engine.renderer.FlutterEngineRule Class Reference
Inheritance diagram for io.flutter.embedding.engine.renderer.FlutterEngineRule:

Protected Member Functions

void starting (Description description)
 
void finished (Description description)
 

Package Functions

FlutterJNI getFlutterJNI ()
 
FlutterEngine getFlutterEngine ()
 
void setJniIsAttached (boolean isAttached)
 
Intent makeIntent ()
 

Detailed Description

Prepares and returns a FlutterEngine and Intent primed with an engine for tests.

Definition at line 20 of file FlutterEngineRule.java.

Member Function Documentation

◆ finished()

void io.flutter.embedding.engine.renderer.FlutterEngineRule.finished ( Description  description)
inlineprotected

Definition at line 45 of file FlutterEngineRule.java.

45 {
46 FlutterEngineCache.getInstance().clear();
47 }

◆ getFlutterEngine()

FlutterEngine io.flutter.embedding.engine.renderer.FlutterEngineRule.getFlutterEngine ( )
inlinepackage

Returns a pre-configured engine.

Returns
flutter engine using the mock provided by {getFlutterJNI()}.

Definition at line 63 of file FlutterEngineRule.java.

63 {
64 return this.flutterEngine;
65 }

◆ getFlutterJNI()

FlutterJNI io.flutter.embedding.engine.renderer.FlutterEngineRule.getFlutterJNI ( )
inlinepackage

Returns a Mockito-mocked version of FlutterJNI.

Returns
an instance that is already considered attached.

Definition at line 54 of file FlutterEngineRule.java.

54 {
55 return this.flutterJNI;
56 }

◆ makeIntent()

Intent io.flutter.embedding.engine.renderer.FlutterEngineRule.makeIntent ( )
inlinepackage

Creates an intent with FlutterEngine instance already provided.

Returns
intent, i.e. to use with androidx.test.ext.junit.rules.ActivityScenarioRule.

Definition at line 81 of file FlutterEngineRule.java.

81 {
82 return FlutterActivity.withCachedEngine(cachedEngineId).build(ctx);
83 }

◆ setJniIsAttached()

void io.flutter.embedding.engine.renderer.FlutterEngineRule.setJniIsAttached ( boolean  isAttached)
inlinepackage

Sets what FlutterJNI#isAttached() returns. If not invoked, defaults to true.

Parameters
isAttachedwhether to consider JNI attached.

Definition at line 72 of file FlutterEngineRule.java.

72 {
73 this.jniIsAttached = isAttached;
74 }

◆ starting()

void io.flutter.embedding.engine.renderer.FlutterEngineRule.starting ( Description  description)
inlineprotected

Definition at line 28 of file FlutterEngineRule.java.

28 {
29 // Setup mock JNI.
30 flutterJNI = mock(FlutterJNI.class);
31 when(flutterJNI.isAttached()).thenAnswer(i -> jniIsAttached);
32
33 // We will not try to load plugins in these tests.
34 FlutterLoader mockFlutterLoader = mock(FlutterLoader.class);
35 when(mockFlutterLoader.automaticallyRegisterPlugins()).thenReturn(false);
36
37 // Create an engine.
38 flutterEngine = new FlutterEngine(ctx, mockFlutterLoader, flutterJNI);
39
40 // Place it in the engine cache.
41 FlutterEngineCache.getInstance().put(cachedEngineId, flutterEngine);
42 }

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