5#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterRestorationPlugin.h"
7#import <OCMock/OCMock.h>
8#import <XCTest/XCTest.h>
10#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterChannels.h"
11#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
12#import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h"
13#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h"
25 id restorationChannel;
34 [restorationChannel stopMocking];
44 allowHeadlessExecution:YES
45 restorationEnabled:YES];
51 NSData*
data = [@"testrestortiondata" dataUsingEncoding:NSUTF8StringEncoding];
54 NSKeyedArchiver* archiver = [[NSKeyedArchiver alloc] initRequiringSecureCoding:YES];
59 NSKeyedUnarchiver* unarchiver =
60 [[NSKeyedUnarchiver alloc] initForReadingWithData:archiver.encodedData];
63 XCTAssert([[restorationPlugin restorationData] isEqualToData:
data],
64 "Restoration state data must be equal");
72 __block
id capturedResult;
74 result:^(id _Nullable result) {
75 capturedResult = result;
77 XCTAssertNil(capturedResult);
79 NSData*
data = [@"testrestortiondata" dataUsingEncoding:NSUTF8StringEncoding];
81 XCTAssertEqual([capturedResult
count], 2u);
82 XCTAssertEqual([capturedResult objectForKey:
@"enabled"], @YES);
83 XCTAssertEqualObjects([[capturedResult objectForKey:
@"data"]
data],
data);
91 __block
id capturedResult;
93 result:^(id _Nullable result) {
94 capturedResult = result;
96 XCTAssertEqual([capturedResult
count], 1u);
97 XCTAssertEqual([capturedResult objectForKey:
@"enabled"], @NO);
104 NSData*
data = [@"testrestortiondata" dataUsingEncoding:NSUTF8StringEncoding];
107 __block
id capturedResult;
110 result:^(id _Nullable result) {
111 capturedResult = result;
113 XCTAssertEqual([capturedResult
count], 2u);
114 XCTAssertEqual([capturedResult objectForKey:
@"enabled"], @YES);
115 XCTAssertEqualObjects([[capturedResult objectForKey:
@"data"]
data],
data);
123 __block
id capturedResult;
125 result:^(id _Nullable result) {
126 capturedResult = result;
128 XCTAssertNil(capturedResult);
131 XCTAssertEqual([capturedResult
count], 1u);
132 XCTAssertEqual([capturedResult objectForKey:
@"enabled"], @YES);
141 __block
id capturedResult;
144 result:^(id _Nullable result) {
145 capturedResult = result;
147 XCTAssertEqual([capturedResult
count], 1u);
148 XCTAssertEqual([capturedResult objectForKey:
@"enabled"], @YES);
156 NSData*
data = [@"testrestortiondata" dataUsingEncoding:NSUTF8StringEncoding];
161 result:^(id _Nullable result) {
162 XCTAssertNil(result);
164 XCTAssertEqualObjects([restorationPlugin restorationData],
data);
172 NSData*
data = [@"testrestortiondata" dataUsingEncoding:NSUTF8StringEncoding];
177 result:^(id _Nullable result) {
178 XCTAssertNil(result);
180 XCTAssertEqualObjects([restorationPlugin restorationData],
data);
182 __block
id capturedResult;
185 result:^(id _Nullable result) {
186 capturedResult = result;
188 XCTAssertEqual([capturedResult
count], 2u);
189 XCTAssertEqual([capturedResult objectForKey:
@"enabled"], @YES);
190 XCTAssertEqualObjects([[capturedResult objectForKey:
@"data"]
data],
data);
198 NSData*
data = [@"testrestortiondata" dataUsingEncoding:NSUTF8StringEncoding];
203 result:^(id _Nullable result) {
204 XCTAssertNil(result);
206 XCTAssertEqualObjects([restorationPlugin restorationData],
data);
208 [restorationPlugin
reset];
209 XCTAssertNil([restorationPlugin restorationData]);
211 __block
id capturedResult;
214 result:^(id _Nullable result) {
215 capturedResult = result;
217 XCTAssertEqual([capturedResult
count], 1u);
218 XCTAssertEqual([capturedResult objectForKey:
@"enabled"], @YES);
void(^ FlutterResult)(id _Nullable result)
instancetype methodCallWithMethodName:arguments:(NSString *method,[arguments] id _Nullable arguments)
void testResetClearsData()
void testRestorationEnabledWaitsForData()
void testRestoratonViewControllerEncodeAndDecode()
void testRespondsRightAwayWhenDataIsSet()
void testReturnsDataSetByFramework()
void testRespondsRightAwayWithNoDataWhenRestorationIsCompleted()
void testRespondsWithNoDataWhenRestorationIsCompletedWithoutData()
void testRespondsWithDataSetByFramework()
void testRestorationDisabledRespondsRightAway()
void setRestorationData:(NSData *data)
void markRestorationComplete()
void handleMethodCall:result:(FlutterMethodCall *call, [result] FlutterResult result)
instancetype typedDataWithBytes:(NSData *data)
void decodeRestorableStateWithCoder:(NSCoder *coder)
FlutterRestorationPlugin * restorationPlugin()
void encodeRestorableStateWithCoder:(NSCoder *coder)
std::shared_ptr< const fml::Mapping > data