Skip to content

[webview] Add macOS support in implementation package #6221

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

Merged
merged 47 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
4903531
Add macOS support to example app
stuartmorgan-g Apr 11, 2023
2d412c0
darwinify
stuartmorgan-g Apr 11, 2023
2f64c9d
Manually change includes; needs Pigeon fix
stuartmorgan-g Apr 11, 2023
f96790c
Add missing entitlements
stuartmorgan-g Apr 12, 2023
ce8c088
Automatic changes from running
stuartmorgan-g Apr 12, 2023
e3e5949
Get minimal PoC running
stuartmorgan-g Apr 13, 2023
c5cd904
Add another TODO with issue reference
stuartmorgan-g Apr 13, 2023
363a6d5
Merge branch 'main' into webview-macos
stuartmorgan-g Jun 13, 2023
ee1f657
Remove the args hack
stuartmorgan-g Jun 13, 2023
18985c5
Update minimum version
stuartmorgan-g Jun 13, 2023
1912347
Update availability annotations
stuartmorgan-g Jun 13, 2023
c70fb10
Merge branch 'main' into webview-macos
stuartmorgan-g Sep 6, 2023
e99093d
Remove the publish workaround
stuartmorgan-g Sep 6, 2023
3969dcc
Remove obsolete stub
stuartmorgan-g Sep 6, 2023
6f703af
Enable valuePublishedByPlugin codepath
stuartmorgan-g Sep 6, 2023
10df466
Comment some ifdefs
stuartmorgan-g Sep 7, 2023
29c5a6e
Change the way UIView removal works
stuartmorgan-g Sep 7, 2023
4c1ff63
Use AppKitView
stuartmorgan-g Sep 11, 2023
56a8e5d
Merge branch 'main' into webview-macos
stuartmorgan-g Dec 1, 2023
6f41e08
Merge branch 'main' into webview-macos
stuartmorgan-g Feb 26, 2024
3c98078
Resolve UIView issue
stuartmorgan-g Feb 26, 2024
aa15792
Add back background color on iOS
stuartmorgan-g Feb 26, 2024
b530bf9
Merge branch 'main' into webview-macos
stuartmorgan-g Feb 28, 2024
ab3169f
Unit test WIP
stuartmorgan-g Feb 29, 2024
aa3987e
Merge branch 'main' into webview-macos
stuartmorgan-g Apr 29, 2024
35769a4
Update Pigeon for enum fix
stuartmorgan-g Apr 29, 2024
6f36af7
Reconstify
stuartmorgan-g Apr 29, 2024
81107c0
Update Dart tests
stuartmorgan-g Apr 29, 2024
f89b1ad
Move privacy manifest
stuartmorgan-g Apr 29, 2024
38eb5ed
Fix analysis warnings
stuartmorgan-g Apr 29, 2024
88415cc
Merge branch 'main' into webview-macos
stuartmorgan-g May 30, 2024
c5bca19
Skip unsupported integration tests
stuartmorgan-g May 30, 2024
8b75132
Missing licenses
stuartmorgan-g May 30, 2024
5b7bc0f
Move and add native unit tests
stuartmorgan-g May 30, 2024
3aaac0c
Version bump
stuartmorgan-g May 30, 2024
3b27394
Fix unused function error
stuartmorgan-g May 30, 2024
c14d5db
Disable unit test parallelization
stuartmorgan-g Jun 3, 2024
ec9a0ea
Skip ogg tests
stuartmorgan-g Jun 3, 2024
128a326
Skip legacy version of ogg tests as well
stuartmorgan-g Jun 4, 2024
8317f1b
Merge branch 'main' into webview-macos
stuartmorgan-g Aug 6, 2024
bfb5fdd
Switch OCMock dependency to SPM
stuartmorgan-g Aug 6, 2024
1007b4c
Fix doc comment
stuartmorgan-g Aug 6, 2024
2b2e697
Re-bump version for merge
stuartmorgan-g Aug 6, 2024
c59ee3d
Merge branch 'main' into webview-macos
stuartmorgan-g Aug 7, 2024
ad794b4
Require 3.24
stuartmorgan-g Aug 7, 2024
df24e12
Merge branch 'main' into webview-macos
stuartmorgan-g Aug 19, 2024
68d4f1d
Merge branch 'main' into webview-macos
stuartmorgan-g Aug 20, 2024
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,6 +1,6 @@
## NEXT
## 3.15.0

* Updates minimum supported SDK version to Flutter 3.19/Dart 3.3.
* Adds macOS support.

## 3.14.0

Expand Down Expand Up @@ -92,7 +92,7 @@

* Introduces `NSError.toString` for better diagnostics.

## 3.6.2
## 3.6.2

* Fixes unawaited_futures violations.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

@import Flutter;
@import XCTest;
@import webview_flutter_wkwebview;

#if TARGET_OS_OSX
@import FlutterMacOS;
#else
@import Flutter;
#endif

#import <OCMock/OCMock.h>

@interface FWFDataConvertersTests : XCTestCase
Expand Down Expand Up @@ -61,8 +66,8 @@ - (void)testFWFWKNavigationActionDataFromNavigationAction {

OCMStub([mockNavigationAction navigationType]).andReturn(WKNavigationTypeReload);

NSURLRequest *request =
[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://www.flutter.dev/"]];
NSURL *testURL = [NSURL URLWithString:@"https://www.flutter.dev/"];
NSURLRequest *request = [NSURLRequest requestWithURL:testURL];
OCMStub([mockNavigationAction request]).andReturn(request);

WKFrameInfo *mockFrameInfo = OCMClassMock([WKFrameInfo class]);
Expand All @@ -76,8 +81,8 @@ - (void)testFWFWKNavigationActionDataFromNavigationAction {
}

- (void)testFWFNSUrlRequestDataFromNSURLRequest {
NSMutableURLRequest *request =
[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://www.flutter.dev/"]];
NSURL *testURL = [NSURL URLWithString:@"https://www.flutter.dev/"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:testURL];
request.HTTPMethod = @"POST";
request.HTTPBody = [@"aString" dataUsingEncoding:NSUTF8StringEncoding];
request.allHTTPHeaderFields = @{@"a" : @"field"};
Expand Down Expand Up @@ -137,7 +142,7 @@ - (void)testFWFWKSecurityOriginDataFromWKSecurityOrigin {
XCTAssertEqualObjects(data.protocol, @"protocol");
}

- (void)testFWFWKPermissionDecisionFromData API_AVAILABLE(ios(15.0)) {
- (void)testFWFWKPermissionDecisionFromData API_AVAILABLE(ios(15.0), macos(12)) {
XCTAssertEqual(FWFNativeWKPermissionDecisionFromData(
[FWFWKPermissionDecisionData makeWithValue:FWFWKPermissionDecisionDeny]),
WKPermissionDecisionDeny);
Expand All @@ -149,7 +154,7 @@ - (void)testFWFWKPermissionDecisionFromData API_AVAILABLE(ios(15.0)) {
WKPermissionDecisionPrompt);
}

- (void)testFWFWKMediaCaptureTypeDataFromWKMediaCaptureType API_AVAILABLE(ios(15.0)) {
- (void)testFWFWKMediaCaptureTypeDataFromWKMediaCaptureType API_AVAILABLE(ios(15.0), macos(12)) {
XCTAssertEqual(
FWFWKMediaCaptureTypeDataFromNativeWKMediaCaptureType(WKMediaCaptureTypeCamera).value,
FWFWKMediaCaptureTypeCamera);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

@import Flutter;
@import XCTest;
@import webview_flutter_wkwebview;

#if TARGET_OS_OSX
@import FlutterMacOS;
#else
@import Flutter;
#endif

#import <OCMock/OCMock.h>

@interface FWFHTTPCookieStoreHostApiTests : XCTestCase
Expand Down Expand Up @@ -47,9 +52,8 @@ - (void)testSetCookie {
completion:^(FlutterError *error) {
blockError = error;
}];
OCMVerify([mockHttpCookieStore
setCookie:[NSHTTPCookie cookieWithProperties:@{NSHTTPCookieName : @"hello"}]
completionHandler:OCMOCK_ANY]);
NSHTTPCookie *cookie = [NSHTTPCookie cookieWithProperties:@{NSHTTPCookieName : @"hello"}];
OCMVerify([mockHttpCookieStore setCookie:cookie completionHandler:OCMOCK_ANY]);
XCTAssertNil(blockError);
}
@end
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <XCTest/XCTest.h>
@import XCTest;

@import webview_flutter_wkwebview;
#if __has_include(<webview_flutter_wkwebview/webview-umbrella.h>)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

@import Flutter;
@import XCTest;
@import webview_flutter_wkwebview;

#if TARGET_OS_OSX
@import FlutterMacOS;
#else
@import Flutter;
#endif

#import <OCMock/OCMock.h>

@interface FWFNavigationDelegateHostApiTests : XCTestCase
Expand Down Expand Up @@ -117,8 +122,8 @@ - (void)testDecidePolicyForNavigationAction {
[instanceManager addDartCreatedInstance:mockWebView withIdentifier:1];

WKNavigationAction *mockNavigationAction = OCMClassMock([WKNavigationAction class]);
OCMStub([mockNavigationAction request])
.andReturn([NSURLRequest requestWithURL:[NSURL URLWithString:@"https://www.flutter.dev"]]);
NSURL *testURL = [NSURL URLWithString:@"https://www.flutter.dev"];
OCMStub([mockNavigationAction request]).andReturn([NSURLRequest requestWithURL:testURL]);

WKFrameInfo *mockFrameInfo = OCMClassMock([WKFrameInfo class]);
OCMStub([mockFrameInfo isMainFrame]).andReturn(YES);
Expand Down Expand Up @@ -258,10 +263,10 @@ - (void)testDidReceiveAuthenticationChallenge {
NSURLCredential *__block callbackCredential;
[mockDelegate webView:mockWebView
didReceiveAuthenticationChallenge:mockChallenge
completionHandler:^(NSURLSessionAuthChallengeDisposition disposition,
NSURLCredential *credential) {
callbackDisposition = disposition;
callbackCredential = credential;
completionHandler:^(NSURLSessionAuthChallengeDisposition dispositionArg,
NSURLCredential *credentialArg) {
callbackDisposition = dispositionArg;
callbackCredential = credentialArg;
}];

XCTAssertEqual(callbackDisposition, NSURLSessionAuthChallengeCancelAuthenticationChallenge);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

@import Flutter;
@import XCTest;
@import webview_flutter_wkwebview;

#if TARGET_OS_OSX
@import FlutterMacOS;
#else
@import Flutter;
#endif

#import <OCMock/OCMock.h>

@interface FWFObjectHostApiTests : XCTestCase
Expand Down Expand Up @@ -139,8 +144,10 @@ - (void)testObserveValueForKeyPath {
return value[0].value == FWFNSKeyValueChangeKeyEnumOldValue;
}]
changeValues:[OCMArg checkWithBlock:^BOOL(id value) {
FWFObjectOrIdentifier *object = (FWFObjectOrIdentifier *)value[0];
return !object.isIdentifier && [@"key" isEqual:object.value];
FWFObjectOrIdentifier *changeObject =
(FWFObjectOrIdentifier *)value[0];
return !changeObject.isIdentifier &&
[@"key" isEqual:changeObject.value];
}]
completion:OCMOCK_ANY]);
}
Expand Down Expand Up @@ -173,8 +180,10 @@ - (void)testObserveValueForKeyPathWithIdentifier {
return value[0].value == FWFNSKeyValueChangeKeyEnumOldValue;
}]
changeValues:[OCMArg checkWithBlock:^BOOL(id value) {
FWFObjectOrIdentifier *object = (FWFObjectOrIdentifier *)value[0];
return object.isIdentifier && [@(2) isEqual:object.value];
FWFObjectOrIdentifier *changeObject =
(FWFObjectOrIdentifier *)value[0];
return changeObject.isIdentifier &&
[@(2) isEqual:changeObject.value];
}]
completion:OCMOCK_ANY]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

@import Flutter;
@import XCTest;
@import webview_flutter_wkwebview;

#if TARGET_OS_OSX
@import FlutterMacOS;
#else
@import Flutter;
#endif

#import <OCMock/OCMock.h>

@interface FWFPreferencesHostApiTests : XCTestCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

@import Flutter;
@import XCTest;
@import webview_flutter_wkwebview;

#if TARGET_OS_OSX
@import FlutterMacOS;
#else
@import Flutter;
#endif

#import <OCMock/OCMock.h>

@interface FWFScriptMessageHandlerHostApiTests : XCTestCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "TargetConditionals.h"

// The scroll view delegate does not exist on macOS.
#if !TARGET_OS_OSX

@import Flutter;
@import XCTest;
@import webview_flutter_wkwebview;
Expand Down Expand Up @@ -80,3 +85,5 @@ - (void)testOnScrollViewDidScrollForDelegateWithIdentifier {
completion:OCMOCK_ANY]);
}
@end

#endif // !TARGET_OS_OSX
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "TargetConditionals.h"

// Scroll view APIs do not existing on macOS.
#if !TARGET_OS_OSX

@import Flutter;
@import XCTest;
@import webview_flutter_wkwebview;
Expand Down Expand Up @@ -79,3 +84,5 @@ - (void)testSetDelegateForScrollView {
XCTAssertNil(error);
}
@end

#endif // !TARGET_OS_OSX
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

@import Flutter;
@import XCTest;
@import webview_flutter_wkwebview;
#if __has_include(<webview_flutter_wkwebview/webview-umbrella.h>)
@import webview_flutter_wkwebview.Test;
#endif

#if TARGET_OS_OSX
@import FlutterMacOS;
#else
@import Flutter;
#endif

#import <OCMock/OCMock.h>

@interface FWFUIDelegateHostApiTests : XCTestCase
Expand Down Expand Up @@ -77,8 +82,8 @@ - (void)testOnCreateWebViewForDelegateWithIdentifier {
.ignoringNonObjectArgs();

WKNavigationAction *mockNavigationAction = OCMClassMock([WKNavigationAction class]);
OCMStub([mockNavigationAction request])
.andReturn([NSURLRequest requestWithURL:[NSURL URLWithString:@"https://www.flutter.dev"]]);
NSURL *testURL = [NSURL URLWithString:@"https://www.flutter.dev"];
OCMStub([mockNavigationAction request]).andReturn([NSURLRequest requestWithURL:testURL]);

WKFrameInfo *mockFrameInfo = OCMClassMock([WKFrameInfo class]);
OCMStub([mockFrameInfo isMainFrame]).andReturn(YES);
Expand All @@ -100,7 +105,7 @@ - (void)testOnCreateWebViewForDelegateWithIdentifier {
completion:OCMOCK_ANY]);
}

- (void)testRequestMediaCapturePermissionForOrigin API_AVAILABLE(ios(15.0)) {
- (void)testRequestMediaCapturePermissionForOrigin API_AVAILABLE(ios(15.0), macos(12)) {
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init];

FWFUIDelegate *mockDelegate = [self mockDelegateWithManager:instanceManager identifier:0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "TargetConditionals.h"

#if !TARGET_OS_OSX

@import Flutter;
@import XCTest;
@import webview_flutter_wkwebview;
Expand Down Expand Up @@ -47,3 +51,5 @@ - (void)testSetOpaque {
}

@end

#endif // !TARGET_OS_OSX
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

@import Flutter;
@import XCTest;
@import webview_flutter_wkwebview;

#if TARGET_OS_OSX
@import FlutterMacOS;
#else
@import Flutter;
#endif

#import <OCMock/OCMock.h>

@interface FWFURLAuthenticationChallengeHostApiTests : XCTestCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

@import Flutter;
@import XCTest;
@import webview_flutter_wkwebview;

#if TARGET_OS_OSX
@import FlutterMacOS;
#else
@import Flutter;
#endif

#import <OCMock/OCMock.h>

@interface FWFURLCredentialHostApiTests : XCTestCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

@import Flutter;
@import XCTest;
@import webview_flutter_wkwebview;

#if TARGET_OS_OSX
@import FlutterMacOS;
#else
@import Flutter;
#endif

#import <OCMock/OCMock.h>

@interface FWFURLProtectionSpaceHostApiTests : XCTestCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

@import Flutter;
@import XCTest;
@import webview_flutter_wkwebview;

#if TARGET_OS_OSX
@import FlutterMacOS;
#else
@import Flutter;
#endif

#import <OCMock/OCMock.h>

@interface FWFURLTests : XCTestCase
Expand Down
Loading