@@ -14,8 +14,9 @@ @interface FWFWebViewHostApiTests : XCTestCase
1414@implementation FWFWebViewHostApiTests
1515- (void )testCreateWithIdentifier {
1616 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];
1920
2021 [instanceManager addDartCreatedInstance: [[WKWebViewConfiguration alloc ] init ] withIdentifier: 0 ];
2122
@@ -32,8 +33,9 @@ - (void)testLoadRequest {
3233 FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
3334 [instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
3435
35- FWFWebViewHostApiImpl *hostAPI =
36- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
36+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
37+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
38+ instanceManager: instanceManager];
3739
3840 FlutterError *error;
3941 FWFNSUrlRequestData *requestData = [FWFNSUrlRequestData makeWithUrl: @" https://www.flutter.dev"
@@ -57,8 +59,9 @@ - (void)testLoadRequestWithInvalidUrl {
5759 FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
5860 [instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
5961
60- FWFWebViewHostApiImpl *hostAPI =
61- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
62+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
63+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
64+ instanceManager: instanceManager];
6265
6366 FlutterError *error;
6467 FWFNSUrlRequestData *requestData = [FWFNSUrlRequestData makeWithUrl: @" %i nvalidUrl%"
@@ -78,8 +81,9 @@ - (void)testSetCustomUserAgent {
7881 FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
7982 [instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
8083
81- FWFWebViewHostApiImpl *hostAPI =
82- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
84+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
85+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
86+ instanceManager: instanceManager];
8387
8488 FlutterError *error;
8589 [hostAPI setUserAgentForWebViewWithIdentifier: @0 userAgent: @" userA" error: &error];
@@ -94,8 +98,9 @@ - (void)testURL {
9498 FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
9599 [instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
96100
97- FWFWebViewHostApiImpl *hostAPI =
98- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
101+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
102+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
103+ instanceManager: instanceManager];
99104
100105 FlutterError *error;
101106 XCTAssertEqualObjects ([hostAPI URLForWebViewWithIdentifier: @0 error: &error],
@@ -110,8 +115,9 @@ - (void)testCanGoBack {
110115 FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
111116 [instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
112117
113- FWFWebViewHostApiImpl *hostAPI =
114- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
118+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
119+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
120+ instanceManager: instanceManager];
115121
116122 FlutterError *error;
117123 XCTAssertEqualObjects ([hostAPI canGoBackForWebViewWithIdentifier: @0 error: &error], @YES );
@@ -124,8 +130,9 @@ - (void)testSetUIDelegate {
124130 FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
125131 [instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
126132
127- FWFWebViewHostApiImpl *hostAPI =
128- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
133+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
134+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
135+ instanceManager: instanceManager];
129136
130137 id <WKUIDelegate > mockDelegate = OCMProtocolMock (@protocol (WKUIDelegate));
131138 [instanceManager addDartCreatedInstance: mockDelegate withIdentifier: 1 ];
@@ -142,8 +149,9 @@ - (void)testSetNavigationDelegate {
142149 FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
143150 [instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
144151
145- FWFWebViewHostApiImpl *hostAPI =
146- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
152+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
153+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
154+ instanceManager: instanceManager];
147155
148156 id <WKNavigationDelegate > mockDelegate = OCMProtocolMock (@protocol (WKNavigationDelegate));
149157 [instanceManager addDartCreatedInstance: mockDelegate withIdentifier: 1 ];
@@ -161,8 +169,9 @@ - (void)testEstimatedProgress {
161169 FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
162170 [instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
163171
164- FWFWebViewHostApiImpl *hostAPI =
165- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
172+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
173+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
174+ instanceManager: instanceManager];
166175
167176 FlutterError *error;
168177 XCTAssertEqualObjects ([hostAPI estimatedProgressForWebViewWithIdentifier: @0 error: &error], @34.0 );
@@ -175,8 +184,9 @@ - (void)testloadHTMLString {
175184 FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
176185 [instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
177186
178- FWFWebViewHostApiImpl *hostAPI =
179- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
187+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
188+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
189+ instanceManager: instanceManager];
180190
181191 FlutterError *error;
182192 [hostAPI loadHTMLForWebViewWithIdentifier: @0
@@ -193,8 +203,9 @@ - (void)testLoadFileURL {
193203 FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
194204 [instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
195205
196- FWFWebViewHostApiImpl *hostAPI =
197- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
206+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
207+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
208+ instanceManager: instanceManager];
198209
199210 FlutterError *error;
200211 [hostAPI loadFileForWebViewWithIdentifier: @0
@@ -222,10 +233,11 @@ - (void)testLoadFlutterAsset {
222233 OCMStub ([mockBundle URLForResource: @" myFolder/assets/index" withExtension: @" html" ])
223234 .andReturn ([NSURL URLWithString: @" webview_flutter/myFolder/assets/index.html" ]);
224235
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];
229241
230242 FlutterError *error;
231243 [hostAPI loadAssetForWebViewWithIdentifier: @0 assetKey: @" assets/index.html" error: &error];
@@ -243,8 +255,9 @@ - (void)testCanGoForward {
243255 FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
244256 [instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
245257
246- FWFWebViewHostApiImpl *hostAPI =
247- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
258+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
259+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
260+ instanceManager: instanceManager];
248261
249262 FlutterError *error;
250263 XCTAssertEqualObjects ([hostAPI canGoForwardForWebViewWithIdentifier: @0 error: &error], @NO );
@@ -257,8 +270,9 @@ - (void)testGoBack {
257270 FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
258271 [instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
259272
260- FWFWebViewHostApiImpl *hostAPI =
261- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
273+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
274+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
275+ instanceManager: instanceManager];
262276
263277 FlutterError *error;
264278 [hostAPI goBackForWebViewWithIdentifier: @0 error: &error];
@@ -272,8 +286,9 @@ - (void)testGoForward {
272286 FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
273287 [instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
274288
275- FWFWebViewHostApiImpl *hostAPI =
276- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
289+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
290+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
291+ instanceManager: instanceManager];
277292
278293 FlutterError *error;
279294 [hostAPI goForwardForWebViewWithIdentifier: @0 error: &error];
@@ -287,8 +302,9 @@ - (void)testReload {
287302 FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
288303 [instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
289304
290- FWFWebViewHostApiImpl *hostAPI =
291- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
305+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
306+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
307+ instanceManager: instanceManager];
292308
293309 FlutterError *error;
294310 [hostAPI reloadWebViewWithIdentifier: @0 error: &error];
@@ -303,8 +319,9 @@ - (void)testTitle {
303319 FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
304320 [instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
305321
306- FWFWebViewHostApiImpl *hostAPI =
307- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
322+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
323+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
324+ instanceManager: instanceManager];
308325
309326 FlutterError *error;
310327 XCTAssertEqualObjects ([hostAPI titleForWebViewWithIdentifier: @0 error: &error], @" myTitle" );
@@ -317,8 +334,9 @@ - (void)testSetAllowsBackForwardNavigationGestures {
317334 FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
318335 [instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
319336
320- FWFWebViewHostApiImpl *hostAPI =
321- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
337+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
338+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
339+ instanceManager: instanceManager];
322340
323341 FlutterError *error;
324342 [hostAPI setAllowsBackForwardForWebViewWithIdentifier: @0 isAllowed: @YES error: &error];
@@ -336,8 +354,9 @@ - (void)testEvaluateJavaScript {
336354 FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
337355 [instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
338356
339- FWFWebViewHostApiImpl *hostAPI =
340- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
357+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
358+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
359+ instanceManager: instanceManager];
341360
342361 NSString __block *returnValue;
343362 FlutterError __block *returnError;
@@ -369,8 +388,9 @@ - (void)testEvaluateJavaScriptReturnsNSErrorData {
369388 FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc ] init ];
370389 [instanceManager addDartCreatedInstance: mockWebView withIdentifier: 0 ];
371390
372- FWFWebViewHostApiImpl *hostAPI =
373- [[FWFWebViewHostApiImpl alloc ] initWithInstanceManager: instanceManager];
391+ FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc ]
392+ initWithBinaryMessenger: OCMProtocolMock (@protocol (FlutterBinaryMessenger))
393+ instanceManager: instanceManager];
374394
375395 NSString __block *returnValue;
376396 FlutterError __block *returnError;
0 commit comments