@@ -14,8 +14,9 @@ @interface FWFWebViewHostApiTests : XCTestCase
14
14
@implementation FWFWebViewHostApiTests
15
15
- (void )testCreateWithIdentifier {
16
16
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
17
- FWFWebViewHostApiImpl *hostAPI =
18
- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
17
+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
18
+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
19
+ instanceManager: instanceManager];
19
20
20
21
[instanceManager addDartCreatedInstance: [[WKWebViewConfiguration alloc ] init ] withIdentifier: 0 ];
21
22
@@ -32,8 +33,9 @@ - (void)testLoadRequest {
32
33
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
33
34
[instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
34
35
35
- FWFWebViewHostApiImpl *hostAPI =
36
- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
36
+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
37
+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
38
+ instanceManager: instanceManager];
37
39
38
40
FlutterError *error;
39
41
FWFNSUrlRequestData *requestData = [FWFNSUrlRequestData makeWithUrl: @" https://www.flutter.dev"
@@ -57,8 +59,9 @@ - (void)testLoadRequestWithInvalidUrl {
57
59
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
58
60
[instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
59
61
60
- FWFWebViewHostApiImpl *hostAPI =
61
- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
62
+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
63
+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
64
+ instanceManager: instanceManager];
62
65
63
66
FlutterError *error;
64
67
FWFNSUrlRequestData *requestData = [FWFNSUrlRequestData makeWithUrl: @" %i nvalidUrl%"
@@ -78,8 +81,9 @@ - (void)testSetCustomUserAgent {
78
81
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
79
82
[instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
80
83
81
- FWFWebViewHostApiImpl *hostAPI =
82
- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
84
+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
85
+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
86
+ instanceManager: instanceManager];
83
87
84
88
FlutterError *error;
85
89
[hostAPI setUserAgentForWebViewWithIdentifier: @0 userAgent: @" userA" error: &error];
@@ -94,8 +98,9 @@ - (void)testURL {
94
98
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
95
99
[instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
96
100
97
- FWFWebViewHostApiImpl *hostAPI =
98
- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
101
+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
102
+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
103
+ instanceManager: instanceManager];
99
104
100
105
FlutterError *error;
101
106
XCTAssertEqualObjects ([hostAPI URLForWebViewWithIdentifier: @0 error: &error],
@@ -110,8 +115,9 @@ - (void)testCanGoBack {
110
115
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
111
116
[instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
112
117
113
- FWFWebViewHostApiImpl *hostAPI =
114
- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
118
+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
119
+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
120
+ instanceManager: instanceManager];
115
121
116
122
FlutterError *error;
117
123
XCTAssertEqualObjects ([hostAPI canGoBackForWebViewWithIdentifier: @0 error: &error], @YES );
@@ -124,8 +130,9 @@ - (void)testSetUIDelegate {
124
130
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
125
131
[instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
126
132
127
- FWFWebViewHostApiImpl *hostAPI =
128
- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
133
+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
134
+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
135
+ instanceManager: instanceManager];
129
136
130
137
id <WKUIDelegate > mockDelegate = OCMProtocolMock (@protocol (WKUIDelegate));
131
138
[instanceManager addDartCreatedInstance: mockDelegate withIdentifier: 1 ];
@@ -142,8 +149,9 @@ - (void)testSetNavigationDelegate {
142
149
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
143
150
[instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
144
151
145
- FWFWebViewHostApiImpl *hostAPI =
146
- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
152
+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
153
+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
154
+ instanceManager: instanceManager];
147
155
148
156
id <WKNavigationDelegate > mockDelegate = OCMProtocolMock (@protocol (WKNavigationDelegate));
149
157
[instanceManager addDartCreatedInstance: mockDelegate withIdentifier: 1 ];
@@ -161,8 +169,9 @@ - (void)testEstimatedProgress {
161
169
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
162
170
[instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
163
171
164
- FWFWebViewHostApiImpl *hostAPI =
165
- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
172
+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
173
+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
174
+ instanceManager: instanceManager];
166
175
167
176
FlutterError *error;
168
177
XCTAssertEqualObjects ([hostAPI estimatedProgressForWebViewWithIdentifier: @0 error: &error], @34.0 );
@@ -175,8 +184,9 @@ - (void)testloadHTMLString {
175
184
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
176
185
[instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
177
186
178
- FWFWebViewHostApiImpl *hostAPI =
179
- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
187
+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
188
+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
189
+ instanceManager: instanceManager];
180
190
181
191
FlutterError *error;
182
192
[hostAPI loadHTMLForWebViewWithIdentifier: @0
@@ -193,8 +203,9 @@ - (void)testLoadFileURL {
193
203
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
194
204
[instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
195
205
196
- FWFWebViewHostApiImpl *hostAPI =
197
- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
206
+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
207
+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
208
+ instanceManager: instanceManager];
198
209
199
210
FlutterError *error;
200
211
[hostAPI loadFileForWebViewWithIdentifier: @0
@@ -222,10 +233,11 @@ - (void)testLoadFlutterAsset {
222
233
OCMStub ([mockBundle URLForResource: @" myFolder/assets/index" withExtension: @" html" ])
223
234
.andReturn ([NSURL URLWithString: @" webview_flutter/myFolder/assets/index.html" ]);
224
235
225
- FWFWebViewHostApiImpl *hostAPI =
226
- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager
227
- bundle: mockBundle
228
- assetManager: mockAssetManager];
236
+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
237
+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
238
+ instanceManager: instanceManager
239
+ bundle: mockBundle
240
+ assetManager: mockAssetManager];
229
241
230
242
FlutterError *error;
231
243
[hostAPI loadAssetForWebViewWithIdentifier: @0 assetKey: @" assets/index.html" error: &error];
@@ -243,8 +255,9 @@ - (void)testCanGoForward {
243
255
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
244
256
[instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
245
257
246
- FWFWebViewHostApiImpl *hostAPI =
247
- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
258
+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
259
+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
260
+ instanceManager: instanceManager];
248
261
249
262
FlutterError *error;
250
263
XCTAssertEqualObjects ([hostAPI canGoForwardForWebViewWithIdentifier: @0 error: &error], @NO );
@@ -257,8 +270,9 @@ - (void)testGoBack {
257
270
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
258
271
[instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
259
272
260
- FWFWebViewHostApiImpl *hostAPI =
261
- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
273
+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
274
+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
275
+ instanceManager: instanceManager];
262
276
263
277
FlutterError *error;
264
278
[hostAPI goBackForWebViewWithIdentifier: @0 error: &error];
@@ -272,8 +286,9 @@ - (void)testGoForward {
272
286
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
273
287
[instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
274
288
275
- FWFWebViewHostApiImpl *hostAPI =
276
- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
289
+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
290
+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
291
+ instanceManager: instanceManager];
277
292
278
293
FlutterError *error;
279
294
[hostAPI goForwardForWebViewWithIdentifier: @0 error: &error];
@@ -287,8 +302,9 @@ - (void)testReload {
287
302
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
288
303
[instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
289
304
290
- FWFWebViewHostApiImpl *hostAPI =
291
- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
305
+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
306
+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
307
+ instanceManager: instanceManager];
292
308
293
309
FlutterError *error;
294
310
[hostAPI reloadWebViewWithIdentifier: @0 error: &error];
@@ -303,8 +319,9 @@ - (void)testTitle {
303
319
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
304
320
[instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
305
321
306
- FWFWebViewHostApiImpl *hostAPI =
307
- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
322
+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
323
+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
324
+ instanceManager: instanceManager];
308
325
309
326
FlutterError *error;
310
327
XCTAssertEqualObjects ([hostAPI titleForWebViewWithIdentifier: @0 error: &error], @" myTitle" );
@@ -317,8 +334,9 @@ - (void)testSetAllowsBackForwardNavigationGestures {
317
334
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
318
335
[instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
319
336
320
- FWFWebViewHostApiImpl *hostAPI =
321
- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
337
+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
338
+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
339
+ instanceManager: instanceManager];
322
340
323
341
FlutterError *error;
324
342
[hostAPI setAllowsBackForwardForWebViewWithIdentifier: @0 isAllowed: @YES error: &error];
@@ -336,8 +354,9 @@ - (void)testEvaluateJavaScript {
336
354
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
337
355
[instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
338
356
339
- FWFWebViewHostApiImpl *hostAPI =
340
- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
357
+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
358
+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
359
+ instanceManager: instanceManager];
341
360
342
361
NSString __block *returnValue;
343
362
FlutterError __block *returnError;
@@ -369,8 +388,9 @@ - (void)testEvaluateJavaScriptReturnsNSErrorData {
369
388
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
370
389
[instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
371
390
372
- FWFWebViewHostApiImpl *hostAPI =
373
- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
391
+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
392
+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
393
+ instanceManager: instanceManager];
374
394
375
395
NSString __block *returnValue;
376
396
FlutterError __block *returnError;
0 commit comments