Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
io.flutter.embedding.engine.systemchannels.PlatformChannelTest Class Reference

Public Member Functions

void platformChannel_hasStringsMessage ()
 
void platformChannel_shareInvokeMessage ()
 

Detailed Description

Definition at line 25 of file PlatformChannelTest.java.

Member Function Documentation

◆ platformChannel_hasStringsMessage()

void io.flutter.embedding.engine.systemchannels.PlatformChannelTest.platformChannel_hasStringsMessage ( )
inline

Definition at line 27 of file PlatformChannelTest.java.

27 {
28 MethodChannel rawChannel = mock(MethodChannel.class);
29 FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);
30 DartExecutor dartExecutor = new DartExecutor(mockFlutterJNI, mock(AssetManager.class));
31 PlatformChannel fakePlatformChannel = new PlatformChannel(dartExecutor);
32 PlatformChannel.PlatformMessageHandler mockMessageHandler =
33 mock(PlatformChannel.PlatformMessageHandler.class);
34 fakePlatformChannel.setPlatformMessageHandler(mockMessageHandler);
35 Boolean returnValue = true;
36 when(mockMessageHandler.clipboardHasStrings()).thenReturn(returnValue);
37 MethodCall methodCall = new MethodCall("Clipboard.hasStrings", null);
38 MethodChannel.Result mockResult = mock(MethodChannel.Result.class);
39 fakePlatformChannel.parsingMethodCallHandler.onMethodCall(methodCall, mockResult);
40
41 JSONObject expected = new JSONObject();
42 try {
43 expected.put("value", returnValue);
44 } catch (JSONException e) {
45 }
46 verify(mockResult).success(refEq(expected));
47 }
static ::testing::Matcher< GBytes * > MethodCall(const std::string &name, ::testing::Matcher< FlValue * > args)

◆ platformChannel_shareInvokeMessage()

void io.flutter.embedding.engine.systemchannels.PlatformChannelTest.platformChannel_shareInvokeMessage ( )
inline

Definition at line 50 of file PlatformChannelTest.java.

50 {
51 MethodChannel rawChannel = mock(MethodChannel.class);
52 FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);
53 DartExecutor dartExecutor = new DartExecutor(mockFlutterJNI, mock(AssetManager.class));
54 PlatformChannel fakePlatformChannel = new PlatformChannel(dartExecutor);
55 PlatformChannel.PlatformMessageHandler mockMessageHandler =
56 mock(PlatformChannel.PlatformMessageHandler.class);
57 fakePlatformChannel.setPlatformMessageHandler(mockMessageHandler);
58
59 ArgumentCaptor<String> valueCapture = ArgumentCaptor.forClass(String.class);
60 doNothing().when(mockMessageHandler).share(valueCapture.capture());
61
62 final String expectedContent = "Flutter";
63 MethodCall methodCall = new MethodCall("Share.invoke", expectedContent);
64 MethodChannel.Result mockResult = mock(MethodChannel.Result.class);
65 fakePlatformChannel.parsingMethodCallHandler.onMethodCall(methodCall, mockResult);
66
67 assertEquals(valueCapture.getValue(), expectedContent);
68 verify(mockResult).success(null);
69 }

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