forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecated DartExecutor as BinaryMessenger and added a getBinaryMesse…
…nger() method. (flutter#43202) (flutter#13349)
- Loading branch information
1 parent
1c104d4
commit 3ebf006
Showing
4 changed files
with
130 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
shell/platform/android/test/io/flutter/embedding/engine/dart/DartExecutorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package test.io.flutter.embedding.engine.dart; | ||
|
||
import android.content.res.AssetManager; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.robolectric.RobolectricTestRunner; | ||
import org.robolectric.annotation.Config; | ||
|
||
import java.nio.ByteBuffer; | ||
|
||
import io.flutter.embedding.engine.FlutterJNI; | ||
import io.flutter.embedding.engine.dart.DartExecutor; | ||
|
||
import static junit.framework.TestCase.assertNotNull; | ||
import static org.mockito.Matchers.anyInt; | ||
import static org.mockito.Matchers.eq; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.times; | ||
import static org.mockito.Mockito.verify; | ||
|
||
@Config(manifest=Config.NONE) | ||
@RunWith(RobolectricTestRunner.class) | ||
public class DartExecutorTest { | ||
@Test | ||
public void itSendsBinaryMessages() { | ||
// Setup test. | ||
FlutterJNI fakeFlutterJni = mock(FlutterJNI.class); | ||
|
||
// Create object under test. | ||
DartExecutor dartExecutor = new DartExecutor(fakeFlutterJni, mock(AssetManager.class)); | ||
|
||
// Verify a BinaryMessenger exists. | ||
assertNotNull(dartExecutor.getBinaryMessenger()); | ||
|
||
// Execute the behavior under test. | ||
ByteBuffer fakeMessage = mock(ByteBuffer.class); | ||
dartExecutor.getBinaryMessenger().send("fake_channel", fakeMessage); | ||
|
||
// Verify that DartExecutor sent our message to FlutterJNI. | ||
verify(fakeFlutterJni, times(1)).dispatchPlatformMessage( | ||
eq("fake_channel"), | ||
eq(fakeMessage), | ||
anyInt(), | ||
anyInt() | ||
); | ||
} | ||
} |