Skip to content

Commit

Permalink
Addressing PR feedback.
Browse files Browse the repository at this point in the history
* Formatting and minor test cleanup
  • Loading branch information
NickalasB committed Oct 27, 2021
1 parent 6672b4f commit 024397a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ static WebView createWebView(
.setWebChromeClient(
webChromeClient) // Always use {@link FlutterWebChromeClient} as web Chrome client.
.setDownloadListener(downloadListener)
.setZoomControlsEnabled(true); //Always use built-in zoom mechanisms.
.setZoomControlsEnabled(true); // Always use built-in zoom mechanisms.

return webViewBuilder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ @interface FLTWKNavigationDelegateTests : XCTestCase

@implementation FLTWKNavigationDelegateTests

NSString *const expectedJavascript =
NSString *const zoomDisablingJavascript =
@"var meta = document.createElement('meta');"
@"meta.name = 'viewport';"
@"meta.content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0,"
Expand All @@ -28,7 +28,6 @@ @implementation FLTWKNavigationDelegateTests

- (void)setUp {
self.mockMethodChannel = OCMClassMock(FlutterMethodChannel.class);
self.navigation = OCMClassMock(WKNavigation.class);
self.navigationDelegate =
[[FLTWKNavigationDelegate alloc] initWithChannel:self.mockMethodChannel];
}
Expand All @@ -49,23 +48,25 @@ - (void)testWebViewWebContentProcessDidTerminateCallsRecourseErrorChannel {

- (void)testWebViewWebEvaluateJavaScriptSourceIsCorrectWhenShouldEnableZoomIsFalse {
WKWebView *webview = OCMClassMock(WKWebView.class);
WKNavigation *navigation = OCMClassMock(WKNavigation.class);
NSURL *testUrl = [[NSURL alloc] initWithString:@"www.example.com"];
OCMStub([webview URL]).andReturn(testUrl);

self.navigationDelegate.shouldEnableZoom = false;
[self.navigationDelegate webView:webview didFinishNavigation:self.navigation];
OCMVerify([webview evaluateJavaScript:expectedJavascript completionHandler:nil]);
[self.navigationDelegate webView:webview didFinishNavigation:navigation];
OCMVerify([webview evaluateJavaScript:zoomDisablingJavascript completionHandler:nil]);
}

- (void)testWebViewWebEvaluateJavaScriptShouldNotBeCalledWhenShouldEnableZoomIsTrue {
WKWebView *webview = OCMClassMock(WKWebView.class);
WKNavigation *navigation = OCMClassMock(WKNavigation.class);
NSURL *testUrl = [[NSURL alloc] initWithString:@"www.example.com"];
OCMStub([webview URL]).andReturn(testUrl);

self.navigationDelegate.shouldEnableZoom = true;

OCMReject([webview evaluateJavaScript:expectedJavascript completionHandler:nil]);
[self.navigationDelegate webView:webview didFinishNavigation:self.navigation];
OCMReject([webview evaluateJavaScript:zoomDisablingJavascript completionHandler:nil]);
[self.navigationDelegate webView:webview didFinishNavigation:navigation];
}

@end

0 comments on commit 024397a

Please sign in to comment.