44import static org .mockito .Mockito .any ;
55import static org .mockito .Mockito .eq ;
66import static org .mockito .Mockito .mock ;
7- import static org .mockito .Mockito .spy ;
87import static org .mockito .Mockito .times ;
98import static org .mockito .Mockito .verify ;
109import static org .mockito .Mockito .verifyZeroInteractions ;
1110
1211import android .annotation .TargetApi ;
13- import android .view .PointerIcon ;
14- import io .flutter .embedding .android .FlutterView ;
15- import io .flutter .embedding .engine .dart .DartExecutor ;
16- import io .flutter .embedding .engine .systemchannels .RestorationChannel ;
1712import io .flutter .plugin .common .MethodCall ;
1813import io .flutter .plugin .common .MethodChannel ;
19- import java .util .HashMap ;
2014import org .json .JSONException ;
2115import org .junit .Test ;
2216import org .junit .runner .RunWith ;
17+ import org .mockito .ArgumentCaptor ;
2318import org .robolectric .RobolectricTestRunner ;
24- import org .robolectric .RuntimeEnvironment ;
2519import org .robolectric .annotation .Config ;
26- import android .support .annotation .NonNull ;
27- import io .flutter .Log ;
28- import io .flutter .embedding .engine .dart .DartExecutor ;
29- import io .flutter .plugin .common .MethodCall ;
30- import io .flutter .plugin .common .MethodChannel ;
31- import io .flutter .plugin .common .StandardMethodCodec ;
32- import org .mockito .ArgumentCaptor ;
3320
3421@ Config (
3522 manifest = Config .NONE ,
3825@ TargetApi (24 )
3926public class RestorationChannelTest {
4027 @ Test
41- public void itDoesNotDoAnythingWhenRestorationDataIsSetBeforeFrameworkAsks () throws JSONException {
28+ public void itDoesNotDoAnythingWhenRestorationDataIsSetBeforeFrameworkAsks ()
29+ throws JSONException {
4230 MethodChannel rawChannel = mock (MethodChannel .class );
43- RestorationChannel restorationChannel = new RestorationChannel (rawChannel , /*waitForRestorationData=*/ false );
31+ RestorationChannel restorationChannel =
32+ new RestorationChannel (rawChannel , /*waitForRestorationData=*/ false );
4433 restorationChannel .setRestorationData ("Any String you want" .getBytes ());
4534 verify (rawChannel , times (0 )).invokeMethod (any (), any ());
4635 }
@@ -50,8 +39,10 @@ public void itSendsDataOverWhenRequestIsPending() throws JSONException {
5039 byte [] data = "Any String you want" .getBytes ();
5140
5241 MethodChannel rawChannel = mock (MethodChannel .class );
53- RestorationChannel restorationChannel = new RestorationChannel (rawChannel , /*waitForRestorationData=*/ true );
54- ArgumentCaptor <MethodChannel .MethodCallHandler > argumentCaptor = ArgumentCaptor .forClass (MethodChannel .MethodCallHandler .class );
42+ RestorationChannel restorationChannel =
43+ new RestorationChannel (rawChannel , /*waitForRestorationData=*/ true );
44+ ArgumentCaptor <MethodChannel .MethodCallHandler > argumentCaptor =
45+ ArgumentCaptor .forClass (MethodChannel .MethodCallHandler .class );
5546 verify (rawChannel ).setMethodCallHandler (argumentCaptor .capture ());
5647
5748 MethodChannel .Result result = mock (MethodChannel .Result .class );
@@ -73,8 +64,10 @@ public void itPushesNewData() throws JSONException {
7364 byte [] data = "Any String you want" .getBytes ();
7465
7566 MethodChannel rawChannel = mock (MethodChannel .class );
76- RestorationChannel restorationChannel = new RestorationChannel (rawChannel , /*waitForRestorationData=*/ false );
77- ArgumentCaptor <MethodChannel .MethodCallHandler > argumentCaptor = ArgumentCaptor .forClass (MethodChannel .MethodCallHandler .class );
67+ RestorationChannel restorationChannel =
68+ new RestorationChannel (rawChannel , /*waitForRestorationData=*/ false );
69+ ArgumentCaptor <MethodChannel .MethodCallHandler > argumentCaptor =
70+ ArgumentCaptor .forClass (MethodChannel .MethodCallHandler .class );
7871 verify (rawChannel ).setMethodCallHandler (argumentCaptor .capture ());
7972
8073 MethodChannel .Result result = mock (MethodChannel .Result .class );
@@ -84,7 +77,8 @@ public void itPushesNewData() throws JSONException {
8477 restorationChannel .setRestorationData (data );
8578 assertEquals (restorationChannel .getRestorationData (), null );
8679
87- ArgumentCaptor <MethodChannel .Result > resultCapture = ArgumentCaptor .forClass (MethodChannel .Result .class );
80+ ArgumentCaptor <MethodChannel .Result > resultCapture =
81+ ArgumentCaptor .forClass (MethodChannel .Result .class );
8882 verify (rawChannel ).invokeMethod (eq ("push" ), eq (data ), resultCapture .capture ());
8983 resultCapture .getValue ().success (null );
9084 assertEquals (restorationChannel .getRestorationData (), data );
@@ -95,13 +89,14 @@ public void itHoldsOnToDataFromFramework() throws JSONException {
9589 byte [] data = "Any String you want" .getBytes ();
9690
9791 MethodChannel rawChannel = mock (MethodChannel .class );
98- RestorationChannel restorationChannel = new RestorationChannel (rawChannel , /*waitForRestorationData=*/ false );
99- ArgumentCaptor <MethodChannel .MethodCallHandler > argumentCaptor = ArgumentCaptor .forClass (MethodChannel .MethodCallHandler .class );
92+ RestorationChannel restorationChannel =
93+ new RestorationChannel (rawChannel , /*waitForRestorationData=*/ false );
94+ ArgumentCaptor <MethodChannel .MethodCallHandler > argumentCaptor =
95+ ArgumentCaptor .forClass (MethodChannel .MethodCallHandler .class );
10096 verify (rawChannel ).setMethodCallHandler (argumentCaptor .capture ());
10197
10298 MethodChannel .Result result = mock (MethodChannel .Result .class );
10399 argumentCaptor .getValue ().onMethodCall (new MethodCall ("put" , data ), result );
104100 assertEquals (restorationChannel .getRestorationData (), data );
105101 }
106102}
107-
0 commit comments