Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
io.flutter.embedding.engine.systemchannels.RestorationChannelTest Class Reference

Public Member Functions

void itDoesNotDoAnythingWhenRestorationDataIsSetBeforeFrameworkAsks () throws JSONException
 
void itSendsDataOverWhenRequestIsPending () throws JSONException
 
void itPushesNewData () throws JSONException
 
void itHoldsOnToDataFromFramework () throws JSONException
 

Detailed Description

Definition at line 29 of file RestorationChannelTest.java.

Member Function Documentation

◆ itDoesNotDoAnythingWhenRestorationDataIsSetBeforeFrameworkAsks()

void io.flutter.embedding.engine.systemchannels.RestorationChannelTest.itDoesNotDoAnythingWhenRestorationDataIsSetBeforeFrameworkAsks ( ) throws JSONException
inline

Definition at line 31 of file RestorationChannelTest.java.

32 {
33 MethodChannel rawChannel = mock(MethodChannel.class);
34 RestorationChannel restorationChannel =
35 new RestorationChannel(rawChannel, /*waitForRestorationData=*/ false);
36 restorationChannel.setRestorationData("Any String you want".getBytes());
37 verify(rawChannel, times(0)).invokeMethod(any(), any());
38 }
static SkISize times(const SkISize &size, float factor)
SIT bool any(const Vec< 1, T > &x)
Definition SkVx.h:530

◆ itHoldsOnToDataFromFramework()

void io.flutter.embedding.engine.systemchannels.RestorationChannelTest.itHoldsOnToDataFromFramework ( ) throws JSONException
inline

Definition at line 100 of file RestorationChannelTest.java.

100 {
101 byte[] data = "Any String you want".getBytes();
102
103 MethodChannel rawChannel = mock(MethodChannel.class);
104 RestorationChannel restorationChannel =
105 new RestorationChannel(rawChannel, /*waitForRestorationData=*/ false);
106 ArgumentCaptor<MethodChannel.MethodCallHandler> argumentCaptor =
107 ArgumentCaptor.forClass(MethodChannel.MethodCallHandler.class);
108 verify(rawChannel).setMethodCallHandler(argumentCaptor.capture());
109
110 MethodChannel.Result result = mock(MethodChannel.Result.class);
111 argumentCaptor.getValue().onMethodCall(new MethodCall("put", data), result);
112 assertEquals(restorationChannel.getRestorationData(), data);
113 }
static ::testing::Matcher< GBytes * > MethodCall(const std::string &name, ::testing::Matcher< FlValue * > args)
GAsyncResult * result
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41

◆ itPushesNewData()

void io.flutter.embedding.engine.systemchannels.RestorationChannelTest.itPushesNewData ( ) throws JSONException
inline

Definition at line 69 of file RestorationChannelTest.java.

69 {
70 byte[] data = "Any String you want".getBytes();
71
72 MethodChannel rawChannel = mock(MethodChannel.class);
73 RestorationChannel restorationChannel =
74 new RestorationChannel(rawChannel, /*waitForRestorationData=*/ 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);
80 argumentCaptor.getValue().onMethodCall(new MethodCall("get", null), result);
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)
Definition M44Test.cpp:18

◆ itSendsDataOverWhenRequestIsPending()

void io.flutter.embedding.engine.systemchannels.RestorationChannelTest.itSendsDataOverWhenRequestIsPending ( ) throws JSONException
inline

Definition at line 41 of file RestorationChannelTest.java.

41 {
42 byte[] data = "Any String you want".getBytes();
43
44 MethodChannel rawChannel = mock(MethodChannel.class);
45 RestorationChannel restorationChannel =
46 new RestorationChannel(rawChannel, /*waitForRestorationData=*/ true);
47 ArgumentCaptor<MethodChannel.MethodCallHandler> argumentCaptor =
48 ArgumentCaptor.forClass(MethodChannel.MethodCallHandler.class);
49 verify(rawChannel).setMethodCallHandler(argumentCaptor.capture());
50
51 MethodChannel.Result result = mock(MethodChannel.Result.class);
52 argumentCaptor.getValue().onMethodCall(new MethodCall("get", null), result);
53 verifyNoInteractions(result);
54
55 restorationChannel.setRestorationData(data);
56 verify(rawChannel, times(0)).invokeMethod(any(), any());
57 Map<String, Object> expected = new HashMap<>();
58 expected.put("enabled", true);
59 expected.put("data", data);
60 verify(result).success(expected);
61
62 // Next get request is answered right away.
63 MethodChannel.Result result2 = mock(MethodChannel.Result.class);
64 argumentCaptor.getValue().onMethodCall(new MethodCall("get", null), result2);
65 verify(result2).success(expected);
66 }

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