69 {
70 byte[]
data =
"Any String you want".getBytes();
71
72 MethodChannel rawChannel = mock(MethodChannel.class);
73 RestorationChannel restorationChannel =
74 new RestorationChannel(rawChannel, false);
75 ArgumentCaptor<MethodChannel.MethodCallHandler> argumentCaptor =
76 ArgumentCaptor.forClass(MethodChannel.MethodCallHandler.class);
77 verify(rawChannel).setMethodCallHandler(argumentCaptor.capture());
78
79 MethodChannel.Result
result = mock(MethodChannel.Result.class);
81 Map<String, Object> expected = new HashMap<>();
82 expected.put("enabled", true);
83 expected.put("data", null);
84 verify(
result).success(expected);
85
86 restorationChannel.setRestorationData(
data);
87 assertEquals(restorationChannel.getRestorationData(), null);
88
89 ArgumentCaptor<MethodChannel.Result> resultCapture =
90 ArgumentCaptor.forClass(MethodChannel.Result.class);
91 Map<String, Object> expected2 = new HashMap<>();
92 expected2.put("enabled", true);
93 expected2.put(
"data",
data);
94 verify(rawChannel).invokeMethod(
eq(
"push"),
eq(expected2), resultCapture.capture());
95 resultCapture.getValue().success(null);
96 assertEquals(restorationChannel.getRestorationData(),
data);
97 }
static bool eq(const SkM44 &a, const SkM44 &b, float tol)