Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[webview_flutter] Update iOS to Pigeon 13 #5271

Merged
merged 5 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.9.4

* Updates to Pigeon 13.

## 3.9.3

* Fixes `use_build_context_synchronously` lint violations in the example app.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ - (void)testFWFWKUserScriptFromScriptData {
makeWithSource:@"mySource"
injectionTime:[FWFWKUserScriptInjectionTimeEnumData
makeWithValue:FWFWKUserScriptInjectionTimeEnumAtDocumentStart]
isMainFrameOnly:@NO]);
isMainFrameOnly:NO]);

XCTAssertEqualObjects(userScript.source, @"mySource");
XCTAssertEqual(userScript.injectionTime, WKUserScriptInjectionTimeAtDocumentStart);
Expand Down Expand Up @@ -94,7 +94,7 @@ - (void)testFWFWKFrameInfoDataFromWKFrameInfo {
OCMStub([mockFrameInfo isMainFrame]).andReturn(YES);

FWFWKFrameInfoData *targetFrameData = FWFWKFrameInfoDataFromNativeWKFrameInfo(mockFrameInfo);
XCTAssertEqualObjects(targetFrameData.isMainFrame, @YES);
XCTAssertEqual(targetFrameData.isMainFrame, YES);
}

- (void)testFWFNSErrorDataFromNSError {
Expand All @@ -104,7 +104,7 @@ - (void)testFWFNSErrorDataFromNSError {
userInfo:@{@"a" : @"b", @"c" : unsupportedType}];

FWFNSErrorData *data = FWFNSErrorDataFromNativeNSError(error);
XCTAssertEqualObjects(data.code, @23);
XCTAssertEqual(data.code, 23);
XCTAssertEqualObjects(data.domain, @"domain");

NSDictionary *userInfo = @{
Expand Down Expand Up @@ -133,7 +133,7 @@ - (void)testFWFWKSecurityOriginDataFromWKSecurityOrigin {
FWFWKSecurityOriginData *data =
FWFWKSecurityOriginDataFromNativeWKSecurityOrigin(mockSecurityOrigin);
XCTAssertEqualObjects(data.host, @"host");
XCTAssertEqualObjects(data.port, @(2));
XCTAssertEqual(data.port, 2);
XCTAssertEqualObjects(data.protocol, @"protocol");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ - (void)testCreateFromWebsiteDataStoreWithIdentifier {
[instanceManager addDartCreatedInstance:mockDataStore withIdentifier:0];

FlutterError *error;
[hostAPI createFromWebsiteDataStoreWithIdentifier:@1 dataStoreIdentifier:@0 error:&error];
[hostAPI createFromWebsiteDataStoreWithIdentifier:1 dataStoreIdentifier:0 error:&error];
WKHTTPCookieStore *cookieStore = (WKHTTPCookieStore *)[instanceManager instanceForIdentifier:1];
XCTAssertTrue([cookieStore isKindOfClass:[WKHTTPCookieStore class]]);
XCTAssertNil(error);
Expand All @@ -42,7 +42,7 @@ - (void)testSetCookie {
makeWithValue:FWFNSHttpCookiePropertyKeyEnumName] ]
propertyValues:@[ @"hello" ]];
FlutterError *__block blockError;
[hostAPI setCookieForStoreWithIdentifier:@0
[hostAPI setCookieForStoreWithIdentifier:0
cookie:cookieData
completion:^(FlutterError *error) {
blockError = error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ - (void)testCreateWithIdentifier {
instanceManager:instanceManager];

FlutterError *error;
[hostAPI createWithIdentifier:@0 error:&error];
[hostAPI createWithIdentifier:0 error:&error];
FWFNavigationDelegate *navigationDelegate =
(FWFNavigationDelegate *)[instanceManager instanceForIdentifier:0];

Expand All @@ -74,8 +74,8 @@ - (void)testDidFinishNavigation {
[instanceManager addDartCreatedInstance:mockWebView withIdentifier:1];

[mockDelegate webView:mockWebView didFinishNavigation:OCMClassMock([WKNavigation class])];
OCMVerify([mockFlutterAPI didFinishNavigationForDelegateWithIdentifier:@0
webViewIdentifier:@1
OCMVerify([mockFlutterAPI didFinishNavigationForDelegateWithIdentifier:0
webViewIdentifier:1
URL:@"https://flutter.dev/"
completion:OCMOCK_ANY]);
}
Expand All @@ -97,8 +97,8 @@ - (void)testDidStartProvisionalNavigation {
[mockDelegate webView:mockWebView
didStartProvisionalNavigation:OCMClassMock([WKNavigation class])];
OCMVerify([mockFlutterAPI
didStartProvisionalNavigationForDelegateWithIdentifier:@0
webViewIdentifier:@1
didStartProvisionalNavigationForDelegateWithIdentifier:0
webViewIdentifier:1
URL:@"https://flutter.dev/"
completion:OCMOCK_ANY]);
}
Expand All @@ -125,8 +125,8 @@ - (void)testDecidePolicyForNavigationAction {
OCMStub([mockNavigationAction targetFrame]).andReturn(mockFrameInfo);

OCMStub([mockFlutterAPI
decidePolicyForNavigationActionForDelegateWithIdentifier:@0
webViewIdentifier:@1
decidePolicyForNavigationActionForDelegateWithIdentifier:0
webViewIdentifier:1
navigationAction:
[OCMArg isKindOfClass:[FWFWKNavigationActionData
class]]
Expand Down Expand Up @@ -164,8 +164,8 @@ - (void)testDidFailNavigation {
didFailNavigation:OCMClassMock([WKNavigation class])
withError:[NSError errorWithDomain:@"domain" code:0 userInfo:nil]];
OCMVerify([mockFlutterAPI
didFailNavigationForDelegateWithIdentifier:@0
webViewIdentifier:@1
didFailNavigationForDelegateWithIdentifier:0
webViewIdentifier:1
error:[OCMArg isKindOfClass:[FWFNSErrorData class]]
completion:OCMOCK_ANY]);
}
Expand All @@ -187,8 +187,8 @@ - (void)testDidFailProvisionalNavigation {
didFailProvisionalNavigation:OCMClassMock([WKNavigation class])
withError:[NSError errorWithDomain:@"domain" code:0 userInfo:nil]];
OCMVerify([mockFlutterAPI
didFailProvisionalNavigationForDelegateWithIdentifier:@0
webViewIdentifier:@1
didFailProvisionalNavigationForDelegateWithIdentifier:0
webViewIdentifier:1
error:[OCMArg isKindOfClass:[FWFNSErrorData
class]]
completion:OCMOCK_ANY]);
Expand All @@ -209,8 +209,8 @@ - (void)testWebViewWebContentProcessDidTerminate {

[mockDelegate webViewWebContentProcessDidTerminate:mockWebView];
OCMVerify([mockFlutterAPI
webViewWebContentProcessDidTerminateForDelegateWithIdentifier:@0
webViewIdentifier:@1
webViewWebContentProcessDidTerminateForDelegateWithIdentifier:0
webViewIdentifier:1
completion:OCMOCK_ANY]);
}
@end
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ - (void)testAddObserver {

FlutterError *error;
[hostAPI
addObserverForObjectWithIdentifier:@0
observerIdentifier:@1
addObserverForObjectWithIdentifier:0
observerIdentifier:1
keyPath:@"myKey"
options:@[
[FWFNSKeyValueObservingOptionsEnumData
Expand Down Expand Up @@ -88,8 +88,8 @@ - (void)testRemoveObserver {
[instanceManager addDartCreatedInstance:observerObject withIdentifier:1];

FlutterError *error;
[hostAPI removeObserverForObjectWithIdentifier:@0
observerIdentifier:@1
[hostAPI removeObserverForObjectWithIdentifier:0
observerIdentifier:1
keyPath:@"myKey"
error:&error];
OCMVerify([mockObject removeObserver:observerObject forKeyPath:@"myKey"]);
Expand All @@ -106,7 +106,7 @@ - (void)testDispose {
[[FWFObjectHostApiImpl alloc] initWithInstanceManager:instanceManager];

FlutterError *error;
[hostAPI disposeObjectWithIdentifier:@0 error:&error];
[hostAPI disposeObjectWithIdentifier:0 error:&error];
// Only the strong reference is removed, so the weak reference will remain until object is set to
// nil.
object = nil;
Expand All @@ -130,18 +130,17 @@ - (void)testObserveValueForKeyPath {
change:@{NSKeyValueChangeOldKey : @"key"}
context:nil];
OCMVerify([mockFlutterAPI
observeValueForObjectWithIdentifier:@0
observeValueForObjectWithIdentifier:0
keyPath:@"keyPath"
objectIdentifier:@1
objectIdentifier:1
changeKeys:[OCMArg checkWithBlock:^BOOL(
NSArray<FWFNSKeyValueChangeKeyEnumData *>
*value) {
return value[0].value == FWFNSKeyValueChangeKeyEnumOldValue;
}]
changeValues:[OCMArg checkWithBlock:^BOOL(id value) {
FWFObjectOrIdentifier *object = (FWFObjectOrIdentifier *)value[0];
return !object.isIdentifier.boolValue &&
[@"key" isEqual:object.value];
return !object.isIdentifier && [@"key" isEqual:object.value];
}]
completion:OCMOCK_ANY]);
}
Expand All @@ -165,17 +164,17 @@ - (void)testObserveValueForKeyPathWithIdentifier {
change:@{NSKeyValueChangeOldKey : returnedObject}
context:nil];
OCMVerify([mockFlutterAPI
observeValueForObjectWithIdentifier:@0
observeValueForObjectWithIdentifier:0
keyPath:@"keyPath"
objectIdentifier:@1
objectIdentifier:1
changeKeys:[OCMArg checkWithBlock:^BOOL(
NSArray<FWFNSKeyValueChangeKeyEnumData *>
*value) {
return value[0].value == FWFNSKeyValueChangeKeyEnumOldValue;
}]
changeValues:[OCMArg checkWithBlock:^BOOL(id value) {
FWFObjectOrIdentifier *object = (FWFObjectOrIdentifier *)value[0];
return object.isIdentifier.boolValue && [@(2) isEqual:object.value];
return object.isIdentifier && [@(2) isEqual:object.value];
}]
completion:OCMOCK_ANY]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ - (void)testCreateFromWebViewConfigurationWithIdentifier {
[instanceManager addDartCreatedInstance:[[WKWebViewConfiguration alloc] init] withIdentifier:0];

FlutterError *error;
[hostAPI createFromWebViewConfigurationWithIdentifier:@1 configurationIdentifier:@0 error:&error];
[hostAPI createFromWebViewConfigurationWithIdentifier:1 configurationIdentifier:0 error:&error];
WKPreferences *preferences = (WKPreferences *)[instanceManager instanceForIdentifier:1];
XCTAssertTrue([preferences isKindOfClass:[WKPreferences class]]);
XCTAssertNil(error);
Expand All @@ -36,7 +36,7 @@ - (void)testSetJavaScriptEnabled {
[[FWFPreferencesHostApiImpl alloc] initWithInstanceManager:instanceManager];

FlutterError *error;
[hostAPI setJavaScriptEnabledForPreferencesWithIdentifier:@0 isEnabled:@YES error:&error];
[hostAPI setJavaScriptEnabledForPreferencesWithIdentifier:0 isEnabled:YES error:&error];
OCMVerify([mockPreferences setJavaScriptEnabled:YES]);
XCTAssertNil(error);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ - (void)testCreateWithIdentifier {
instanceManager:instanceManager];

FlutterError *error;
[hostAPI createWithIdentifier:@0 error:&error];
[hostAPI createWithIdentifier:0 error:&error];

FWFScriptMessageHandler *scriptMessageHandler =
(FWFScriptMessageHandler *)[instanceManager instanceForIdentifier:0];
Expand Down Expand Up @@ -78,8 +78,8 @@ - (void)testDidReceiveScriptMessageForHandler {
[mockHandler userContentController:userContentController
didReceiveScriptMessage:mockScriptMessage];
OCMVerify([mockFlutterAPI
didReceiveScriptMessageForHandlerWithIdentifier:@0
userContentControllerIdentifier:@1
didReceiveScriptMessageForHandlerWithIdentifier:0
userContentControllerIdentifier:1
message:[OCMArg isKindOfClass:[FWFWKScriptMessageData
class]]
completion:OCMOCK_ANY]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ - (void)testGetContentOffset {

FlutterError *error;
NSArray<NSNumber *> *expectedValue = @[ @1.0, @2.0 ];
XCTAssertEqualObjects([hostAPI contentOffsetForScrollViewWithIdentifier:@0 error:&error],
XCTAssertEqualObjects([hostAPI contentOffsetForScrollViewWithIdentifier:0 error:&error],
expectedValue);
XCTAssertNil(error);
}
Expand All @@ -40,7 +40,7 @@ - (void)testScrollBy {
[[FWFScrollViewHostApiImpl alloc] initWithInstanceManager:instanceManager];

FlutterError *error;
[hostAPI scrollByForScrollViewWithIdentifier:@0 x:@1 y:@2 error:&error];
[hostAPI scrollByForScrollViewWithIdentifier:0 x:1 y:2 error:&error];
XCTAssertEqual(scrollView.contentOffset.x, 2);
XCTAssertEqual(scrollView.contentOffset.y, 4);
XCTAssertNil(error);
Expand All @@ -56,7 +56,7 @@ - (void)testSetContentOffset {
[[FWFScrollViewHostApiImpl alloc] initWithInstanceManager:instanceManager];

FlutterError *error;
[hostAPI setContentOffsetForScrollViewWithIdentifier:@0 toX:@1 y:@2 error:&error];
[hostAPI setContentOffsetForScrollViewWithIdentifier:0 toX:1 y:2 error:&error];
XCTAssertEqual(scrollView.contentOffset.x, 1);
XCTAssertEqual(scrollView.contentOffset.y, 2);
XCTAssertNil(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@import Flutter;
@import XCTest;
@import webview_flutter_wkwebview;
@import webview_flutter_wkwebview.Test;

#import <OCMock/OCMock.h>

Expand Down Expand Up @@ -50,7 +51,7 @@ - (void)testCreateWithIdentifier {
instanceManager:instanceManager];

FlutterError *error;
[hostAPI createWithIdentifier:@0 error:&error];
[hostAPI createWithIdentifier:0 error:&error];
FWFUIDelegate *delegate = (FWFUIDelegate *)[instanceManager instanceForIdentifier:0];

XCTAssertTrue([delegate conformsToProtocol:@protocol(WKUIDelegate)]);
Expand All @@ -70,12 +71,8 @@ - (void)testOnCreateWebViewForDelegateWithIdentifier {

WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
id mockConfigurationFlutterApi = OCMPartialMock(mockFlutterAPI.webViewConfigurationFlutterApi);
NSNumber *__block configurationIdentifier;
OCMStub([mockConfigurationFlutterApi createWithIdentifier:[OCMArg checkWithBlock:^BOOL(id value) {
configurationIdentifier = value;
return YES;
}]
completion:OCMOCK_ANY]);
OCMStub([mockConfigurationFlutterApi createWithIdentifier:0 completion:OCMOCK_ANY])
.ignoringNonObjectArgs();

WKNavigationAction *mockNavigationAction = OCMClassMock([WKNavigationAction class]);
OCMStub([mockNavigationAction request])
Expand All @@ -85,13 +82,16 @@ - (void)testOnCreateWebViewForDelegateWithIdentifier {
OCMStub([mockFrameInfo isMainFrame]).andReturn(YES);
OCMStub([mockNavigationAction targetFrame]).andReturn(mockFrameInfo);

// Creating the webview will create a configuration on the host side, using the next available
// identifier, so save that for checking against later.
NSInteger configurationIdentifier = instanceManager.nextIdentifier;
[mockDelegate webView:mockWebView
createWebViewWithConfiguration:configuration
forNavigationAction:mockNavigationAction
windowFeatures:OCMClassMock([WKWindowFeatures class])];
OCMVerify([mockFlutterAPI
onCreateWebViewForDelegateWithIdentifier:@0
webViewIdentifier:@1
onCreateWebViewForDelegateWithIdentifier:0
webViewIdentifier:1
configurationIdentifier:configurationIdentifier
navigationAction:[OCMArg
isKindOfClass:[FWFWKNavigationActionData class]]
Expand Down Expand Up @@ -125,8 +125,8 @@ - (void)testRequestMediaCapturePermissionForOrigin API_AVAILABLE(ios(15.0)) {
}];

OCMVerify([mockFlutterAPI
requestMediaCapturePermissionForDelegateWithIdentifier:@0
webViewIdentifier:@1
requestMediaCapturePermissionForDelegateWithIdentifier:0
webViewIdentifier:1
origin:[OCMArg isKindOfClass:
[FWFWKSecurityOriginData
class]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ - (void)testSetBackgroundColor {
[[FWFUIViewHostApiImpl alloc] initWithInstanceManager:instanceManager];

FlutterError *error;
[hostAPI setBackgroundColorForViewWithIdentifier:@0 toValue:@123 error:&error];
[hostAPI setBackgroundColorForViewWithIdentifier:0 toValue:@123 error:&error];

OCMVerify([mockUIView setBackgroundColor:[UIColor colorWithRed:(123 >> 16 & 0xff) / 255.0
green:(123 >> 8 & 0xff) / 255.0
Expand All @@ -41,7 +41,7 @@ - (void)testSetOpaque {
[[FWFUIViewHostApiImpl alloc] initWithInstanceManager:instanceManager];

FlutterError *error;
[hostAPI setOpaqueForViewWithIdentifier:@0 isOpaque:@YES error:&error];
[hostAPI setOpaqueForViewWithIdentifier:0 isOpaque:YES error:&error];
OCMVerify([mockUIView setOpaque:YES]);
XCTAssertNil(error);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ - (void)testAbsoluteString {
instanceManager:instanceManager];

FlutterError *error;
XCTAssertEqualObjects([hostApi absoluteStringForNSURLWithIdentifier:@(0) error:&error],
XCTAssertEqualObjects([hostApi absoluteStringForNSURLWithIdentifier:0 error:&error],
@"https://www.google.com");
XCTAssertNil(error);
}
Expand All @@ -43,6 +43,6 @@ - (void)testFlutterApiCreate {
}];

long identifier = [instanceManager identifierWithStrongReferenceForInstance:url];
OCMVerify([flutterApi.api createWithIdentifier:@(identifier) completion:OCMOCK_ANY]);
OCMVerify([flutterApi.api createWithIdentifier:identifier completion:OCMOCK_ANY]);
}
@end
Loading