This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +26
-3
lines changed Expand file tree Collapse file tree 4 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -487,6 +487,7 @@ action("robolectric_tests") {
487
487
" test/io/flutter/embedding/engine/systemchannels/PlatformChannelTest.java" ,
488
488
" test/io/flutter/embedding/engine/systemchannels/RestorationChannelTest.java" ,
489
489
" test/io/flutter/external/FlutterLaunchTests.java" ,
490
+ " test/io/flutter/plugin/common/BinaryCodecTest.java" ,
490
491
" test/io/flutter/plugin/common/StandardMessageCodecTest.java" ,
491
492
" test/io/flutter/plugin/common/StandardMethodCodecTest.java" ,
492
493
" test/io/flutter/plugin/editing/InputConnectionAdaptorTest.java" ,
Original file line number Diff line number Diff line change 4
4
5
5
package io .flutter .plugin .common ;
6
6
7
+ import androidx .annotation .Nullable ;
7
8
import java .nio .ByteBuffer ;
8
9
9
10
/**
@@ -45,13 +46,15 @@ private BinaryCodec(boolean returnsDirectByteBufferFromDecoding) {
45
46
}
46
47
47
48
@ Override
48
- public ByteBuffer encodeMessage (ByteBuffer message ) {
49
+ public ByteBuffer encodeMessage (@ Nullable ByteBuffer message ) {
49
50
return message ;
50
51
}
51
52
52
53
@ Override
53
- public ByteBuffer decodeMessage (ByteBuffer message ) {
54
- if (returnsDirectByteBufferFromDecoding ) {
54
+ public ByteBuffer decodeMessage (@ Nullable ByteBuffer message ) {
55
+ if (message == null ) {
56
+ return message ;
57
+ } else if (returnsDirectByteBufferFromDecoding ) {
55
58
return message ;
56
59
} else {
57
60
ByteBuffer result = ByteBuffer .allocate (message .capacity ());
Original file line number Diff line number Diff line change 30
30
import io .flutter .embedding .engine .systemchannels .PlatformChannelTest ;
31
31
import io .flutter .embedding .engine .systemchannels .RestorationChannelTest ;
32
32
import io .flutter .external .FlutterLaunchTests ;
33
+ import io .flutter .plugin .common .BinaryCodecTest ;
33
34
import io .flutter .plugin .common .StandardMessageCodecTest ;
34
35
import io .flutter .plugin .common .StandardMethodCodecTest ;
35
36
import io .flutter .plugin .editing .InputConnectionAdaptorTest ;
53
54
AccessibilityBridgeTest .class ,
54
55
AndroidKeyProcessorTest .class ,
55
56
ApplicationInfoLoaderTest .class ,
57
+ BinaryCodecTest .class ,
56
58
DartExecutorTest .class ,
57
59
DartMessengerTest .class ,
58
60
FlutterActivityAndFragmentDelegateTest .class ,
Original file line number Diff line number Diff line change
1
+ package io .flutter .plugin .common ;
2
+
3
+ import static org .junit .Assert .assertNull ;
4
+
5
+ import org .junit .Test ;
6
+ import org .junit .runner .RunWith ;
7
+ import org .robolectric .RobolectricTestRunner ;
8
+ import org .robolectric .annotation .Config ;
9
+
10
+ @ Config (manifest = Config .NONE )
11
+ @ RunWith (RobolectricTestRunner .class )
12
+ public class BinaryCodecTest {
13
+ @ Test
14
+ public void decodeNull () {
15
+ assertNull (BinaryCodec .INSTANCE .decodeMessage (null ));
16
+ }
17
+ }
You can’t perform that action at this time.
0 commit comments