Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Instance Methods | List of all members
FlutterRestorationPluginTest Class Reference
Inheritance diagram for FlutterRestorationPluginTest:

Instance Methods

(void) - setUp [implementation]
 
(void) - tearDown [implementation]
 
(void) - testRestoratonViewControllerEncodeAndDecode [implementation]
 
(void) - testRestorationEnabledWaitsForData [implementation]
 
(void) - testRestorationDisabledRespondsRightAway [implementation]
 
(void) - testRespondsRightAwayWhenDataIsSet [implementation]
 
(void) - testRespondsWithNoDataWhenRestorationIsCompletedWithoutData [implementation]
 
(void) - testRespondsRightAwayWithNoDataWhenRestorationIsCompleted [implementation]
 
(void) - testReturnsDataSetByFramework [implementation]
 
(void) - testRespondsWithDataSetByFramework [implementation]
 
(void) - testResetClearsData [implementation]
 

Detailed Description

Definition at line 21 of file FlutterRestorationPluginTest.mm.

Method Documentation

◆ setUp

- (void) setUp
implementation

Definition at line 15 of file FlutterRestorationPluginTest.mm.

28 {
29 [super setUp];
30 restorationChannel = OCMClassMock([FlutterMethodChannel class]);
31}

◆ tearDown

- (void) tearDown
implementation

Definition at line 15 of file FlutterRestorationPluginTest.mm.

33 {
34 [restorationChannel stopMocking];
35
36 [super tearDown];
37}

◆ testResetClearsData

- (void) testResetClearsData
implementation

Definition at line 15 of file FlutterRestorationPluginTest.mm.

193 {
194 FlutterRestorationPlugin* restorationPlugin =
195 [[FlutterRestorationPlugin alloc] initWithChannel:restorationChannel restorationEnabled:YES];
196 [restorationPlugin markRestorationComplete];
197
198 NSData* data = [@"testrestortiondata" dataUsingEncoding:NSUTF8StringEncoding];
202 [restorationPlugin handleMethodCall:methodCall
203 result:^(id _Nullable result) {
204 XCTAssertNil(result);
205 }];
206 XCTAssertEqualObjects([restorationPlugin restorationData], data);
207
208 [restorationPlugin reset];
209 XCTAssertNil([restorationPlugin restorationData]);
210
211 __block id capturedResult;
212 methodCall = [FlutterMethodCall methodCallWithMethodName:@"get" arguments:nil];
213 [restorationPlugin handleMethodCall:methodCall
214 result:^(id _Nullable result) {
215 capturedResult = result;
216 }];
217 XCTAssertEqual([capturedResult count], 1u);
218 XCTAssertEqual([capturedResult objectForKey:@"enabled"], @YES);
219}
int count
instancetype methodCallWithMethodName:arguments:(NSString *method,[arguments] id _Nullable arguments)
void handleMethodCall:result:(FlutterMethodCall *call, [result] FlutterResult result)
instancetype typedDataWithBytes:(NSData *data)
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

◆ testRespondsRightAwayWhenDataIsSet

- (void) testRespondsRightAwayWhenDataIsSet
implementation

Definition at line 15 of file FlutterRestorationPluginTest.mm.

100 {
101 FlutterRestorationPlugin* restorationPlugin =
102 [[FlutterRestorationPlugin alloc] initWithChannel:restorationChannel restorationEnabled:YES];
103
104 NSData* data = [@"testrestortiondata" dataUsingEncoding:NSUTF8StringEncoding];
105 [restorationPlugin setRestorationData:data];
106
107 __block id capturedResult;
109 [restorationPlugin handleMethodCall:methodCall
110 result:^(id _Nullable result) {
111 capturedResult = result;
112 }];
113 XCTAssertEqual([capturedResult count], 2u);
114 XCTAssertEqual([capturedResult objectForKey:@"enabled"], @YES);
115 XCTAssertEqualObjects([[capturedResult objectForKey:@"data"] data], data);
116}

◆ testRespondsRightAwayWithNoDataWhenRestorationIsCompleted

- (void) testRespondsRightAwayWithNoDataWhenRestorationIsCompleted
implementation

Definition at line 15 of file FlutterRestorationPluginTest.mm.

135 {
136 FlutterRestorationPlugin* restorationPlugin =
137 [[FlutterRestorationPlugin alloc] initWithChannel:restorationChannel restorationEnabled:YES];
138
139 [restorationPlugin markRestorationComplete];
140
141 __block id capturedResult;
143 [restorationPlugin handleMethodCall:methodCall
144 result:^(id _Nullable result) {
145 capturedResult = result;
146 }];
147 XCTAssertEqual([capturedResult count], 1u);
148 XCTAssertEqual([capturedResult objectForKey:@"enabled"], @YES);
149}

◆ testRespondsWithDataSetByFramework

- (void) testRespondsWithDataSetByFramework
implementation

Definition at line 15 of file FlutterRestorationPluginTest.mm.

167 {
168 FlutterRestorationPlugin* restorationPlugin =
169 [[FlutterRestorationPlugin alloc] initWithChannel:restorationChannel restorationEnabled:YES];
170 [restorationPlugin markRestorationComplete];
171
172 NSData* data = [@"testrestortiondata" dataUsingEncoding:NSUTF8StringEncoding];
176 [restorationPlugin handleMethodCall:methodCall
177 result:^(id _Nullable result) {
178 XCTAssertNil(result);
179 }];
180 XCTAssertEqualObjects([restorationPlugin restorationData], data);
181
182 __block id capturedResult;
183 methodCall = [FlutterMethodCall methodCallWithMethodName:@"get" arguments:nil];
184 [restorationPlugin handleMethodCall:methodCall
185 result:^(id _Nullable result) {
186 capturedResult = result;
187 }];
188 XCTAssertEqual([capturedResult count], 2u);
189 XCTAssertEqual([capturedResult objectForKey:@"enabled"], @YES);
190 XCTAssertEqualObjects([[capturedResult objectForKey:@"data"] data], data);
191}

◆ testRespondsWithNoDataWhenRestorationIsCompletedWithoutData

- (void) testRespondsWithNoDataWhenRestorationIsCompletedWithoutData
implementation

Definition at line 15 of file FlutterRestorationPluginTest.mm.

118 {
119 FlutterRestorationPlugin* restorationPlugin =
120 [[FlutterRestorationPlugin alloc] initWithChannel:restorationChannel restorationEnabled:YES];
121
123 __block id capturedResult;
124 [restorationPlugin handleMethodCall:methodCall
125 result:^(id _Nullable result) {
126 capturedResult = result;
127 }];
128 XCTAssertNil(capturedResult);
129
130 [restorationPlugin markRestorationComplete];
131 XCTAssertEqual([capturedResult count], 1u);
132 XCTAssertEqual([capturedResult objectForKey:@"enabled"], @YES);
133}

◆ testRestorationDisabledRespondsRightAway

- (void) testRestorationDisabledRespondsRightAway
implementation

Definition at line 15 of file FlutterRestorationPluginTest.mm.

86 {
87 FlutterRestorationPlugin* restorationPlugin =
88 [[FlutterRestorationPlugin alloc] initWithChannel:restorationChannel restorationEnabled:NO];
89
91 __block id capturedResult;
92 [restorationPlugin handleMethodCall:methodCall
93 result:^(id _Nullable result) {
94 capturedResult = result;
95 }];
96 XCTAssertEqual([capturedResult count], 1u);
97 XCTAssertEqual([capturedResult objectForKey:@"enabled"], @NO);
98}

◆ testRestorationEnabledWaitsForData

- (void) testRestorationEnabledWaitsForData
implementation

Definition at line 15 of file FlutterRestorationPluginTest.mm.

67 {
68 FlutterRestorationPlugin* restorationPlugin =
69 [[FlutterRestorationPlugin alloc] initWithChannel:restorationChannel restorationEnabled:YES];
70
72 __block id capturedResult;
73 [restorationPlugin handleMethodCall:methodCall
74 result:^(id _Nullable result) {
75 capturedResult = result;
76 }];
77 XCTAssertNil(capturedResult);
78
79 NSData* data = [@"testrestortiondata" dataUsingEncoding:NSUTF8StringEncoding];
80 [restorationPlugin setRestorationData:data];
81 XCTAssertEqual([capturedResult count], 2u);
82 XCTAssertEqual([capturedResult objectForKey:@"enabled"], @YES);
83 XCTAssertEqualObjects([[capturedResult objectForKey:@"data"] data], data);
84}

◆ testRestoratonViewControllerEncodeAndDecode

- (void) testRestoratonViewControllerEncodeAndDecode
implementation

Definition at line 15 of file FlutterRestorationPluginTest.mm.

41 {
42 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test"
43 project:nil
44 allowHeadlessExecution:YES
45 restorationEnabled:YES];
46 [engine run];
47 FlutterViewController* flutterViewController =
48 [[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil];
49 FlutterRestorationPlugin* restorationPlugin = flutterViewController.restorationPlugin;
50
51 NSData* data = [@"testrestortiondata" dataUsingEncoding:NSUTF8StringEncoding];
52 [restorationPlugin setRestorationData:data];
53
54 NSKeyedArchiver* archiver = [[NSKeyedArchiver alloc] initRequiringSecureCoding:YES];
55 [flutterViewController encodeRestorableStateWithCoder:archiver];
56
57 [restorationPlugin setRestorationData:nil];
58
59 NSKeyedUnarchiver* unarchiver =
60 [[NSKeyedUnarchiver alloc] initForReadingWithData:archiver.encodedData];
61 [flutterViewController decodeRestorableStateWithCoder:unarchiver];
62
63 XCTAssert([[restorationPlugin restorationData] isEqualToData:data],
64 "Restoration state data must be equal");
65}
FlutterEngine engine
Definition main.cc:68
void decodeRestorableStateWithCoder:(NSCoder *coder)
FlutterRestorationPlugin * restorationPlugin()
void encodeRestorableStateWithCoder:(NSCoder *coder)

◆ testReturnsDataSetByFramework

- (void) testReturnsDataSetByFramework
implementation

Definition at line 15 of file FlutterRestorationPluginTest.mm.

151 {
152 FlutterRestorationPlugin* restorationPlugin =
153 [[FlutterRestorationPlugin alloc] initWithChannel:restorationChannel restorationEnabled:YES];
154 [restorationPlugin markRestorationComplete];
155
156 NSData* data = [@"testrestortiondata" dataUsingEncoding:NSUTF8StringEncoding];
160 [restorationPlugin handleMethodCall:methodCall
161 result:^(id _Nullable result) {
162 XCTAssertNil(result);
163 }];
164 XCTAssertEqualObjects([restorationPlugin restorationData], data);
165}

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