Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
io.flutter.plugin.common.MethodChannelTest Class Reference

Public Member Functions

void resizeChannelBufferMessageIsWellformed ()
 
void overflowChannelBufferMessageIsWellformed ()
 

Detailed Description

Definition at line 22 of file MethodChannelTest.java.

Member Function Documentation

◆ overflowChannelBufferMessageIsWellformed()

void io.flutter.plugin.common.MethodChannelTest.overflowChannelBufferMessageIsWellformed ( )
inline

Definition at line 53 of file MethodChannelTest.java.

53 {
54 FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);
55 DartExecutor dartExecutor = new DartExecutor(mockFlutterJNI, mock(AssetManager.class));
56 String channel = "flutter/test";
57 MethodChannel rawChannel = new MethodChannel(dartExecutor, channel);
58
59 rawChannel.setWarnsOnChannelOverflow(false);
60
61 // Created from the following Dart code:
62 // MethodCall methodCall = const MethodCall('overflow', ['flutter/test', true]);
63 // const StandardMethodCodec().encodeMethodCall(methodCall).buffer.asUint8List();
64 final byte[] expected = {
65 7, 8, 111, 118, 101, 114, 102, 108, 111, 119, 12, 2, 7, 12, 102, 108, 117, 116, 116, 101, 114,
66 47, 116, 101, 115, 116, 1
67 };
68
69 // Verify that the correct message was sent to FlutterJNI.
70 ArgumentMatcher<ByteBuffer> packetMatcher =
71 new ByteBufferContentMatcher(ByteBuffer.wrap(expected));
72 verify(mockFlutterJNI, times(1))
73 .dispatchPlatformMessage(
74 eq(BasicMessageChannel.CHANNEL_BUFFERS_CHANNEL),
75 argThat(packetMatcher),
76 anyInt(),
77 anyInt());
78 }
static SkISize times(const SkISize &size, float factor)
static bool eq(const SkM44 &a, const SkM44 &b, float tol)
Definition M44Test.cpp:18

◆ resizeChannelBufferMessageIsWellformed()

void io.flutter.plugin.common.MethodChannelTest.resizeChannelBufferMessageIsWellformed ( )
inline

Definition at line 24 of file MethodChannelTest.java.

24 {
25 FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);
26 DartExecutor dartExecutor = new DartExecutor(mockFlutterJNI, mock(AssetManager.class));
27 String channel = "flutter/test";
28 MethodChannel rawChannel = new MethodChannel(dartExecutor, channel);
29
30 int newSize = 3;
31 rawChannel.resizeChannelBuffer(newSize);
32
33 // Created from the following Dart code:
34 // MethodCall methodCall = const MethodCall('resize', ['flutter/test', 3]);
35 // const StandardMethodCodec().encodeMethodCall(methodCall).buffer.asUint8List();
36 final byte[] expected = {
37 7, 6, 114, 101, 115, 105, 122, 101, 12, 2, 7, 12, 102, 108, 117, 116, 116, 101, 114, 47, 116,
38 101, 115, 116, 3, 3, 0, 0, 0
39 };
40
41 // Verify that the correct message was sent to FlutterJNI.
42 ArgumentMatcher<ByteBuffer> packetMatcher =
43 new ByteBufferContentMatcher(ByteBuffer.wrap(expected));
44 verify(mockFlutterJNI, times(1))
45 .dispatchPlatformMessage(
46 eq(BasicMessageChannel.CHANNEL_BUFFERS_CHANNEL),
47 argThat(packetMatcher),
48 anyInt(),
49 anyInt());
50 }

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