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);
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 }