Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[webview_flutter_wkwebview] Update variable names for changes coming in flutter/plugins#5700 #5829

Merged
merged 7 commits into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from 6 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
Expand Up @@ -14,15 +14,15 @@ @interface FWFHTTPCookieStoreHostApiTests : XCTestCase
@implementation FWFHTTPCookieStoreHostApiTests
- (void)testCreateFromWebsiteDataStoreWithIdentifier API_AVAILABLE(ios(11.0)) {
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init];
FWFHTTPCookieStoreHostApiImpl *hostApi =
FWFHTTPCookieStoreHostApiImpl *hostAPI =
[[FWFHTTPCookieStoreHostApiImpl alloc] initWithInstanceManager:instanceManager];

WKWebsiteDataStore *mockDataStore = OCMClassMock([WKWebsiteDataStore class]);
OCMStub([mockDataStore httpCookieStore]).andReturn(OCMClassMock([WKHTTPCookieStore class]));
[instanceManager addInstance:mockDataStore withIdentifier:0];
[instanceManager addInstanceCreatedFromDart: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 @@ -32,17 +32,17 @@ - (void)testSetCookie API_AVAILABLE(ios(11.0)) {
WKHTTPCookieStore *mockHttpCookieStore = OCMClassMock([WKHTTPCookieStore class]);

FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init];
[instanceManager addInstance:mockHttpCookieStore withIdentifier:0];
[instanceManager addInstanceCreatedFromDart:mockHttpCookieStore withIdentifier:0];

FWFHTTPCookieStoreHostApiImpl *hostApi =
FWFHTTPCookieStoreHostApiImpl *hostAPI =
[[FWFHTTPCookieStoreHostApiImpl alloc] initWithInstanceManager:instanceManager];

FWFNSHttpCookieData *cookieData = [FWFNSHttpCookieData
makeWithPropertyKeys:@[ [FWFNSHttpCookiePropertyKeyEnumData
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 @@ -9,19 +9,19 @@ @interface FWFInstanceManagerTests : XCTestCase
@end

@implementation FWFInstanceManagerTests
- (void)testAddInstance {
- (void)testAddInstanceCreatedFromDart {
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init];
NSObject *object = [[NSObject alloc] init];

[instanceManager addInstance:object withIdentifier:5];
[instanceManager addInstanceCreatedFromDart:object withIdentifier:5];
XCTAssertEqualObjects([instanceManager instanceForIdentifier:5], object);
XCTAssertEqual([instanceManager identifierForInstance:object], 5);
}

- (void)testRemoveInstance {
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init];
NSObject *object = [[NSObject alloc] init];
[instanceManager addInstance:object withIdentifier:5];
[instanceManager addInstanceCreatedFromDart:object withIdentifier:5];

[instanceManager removeInstance:object];
XCTAssertNil([instanceManager instanceForIdentifier:5]);
Expand All @@ -31,7 +31,7 @@ - (void)testRemoveInstance {
- (void)testRemoveInstanceWithIdentifier {
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init];
NSObject *object = [[NSObject alloc] init];
[instanceManager addInstance:object withIdentifier:5];
[instanceManager addInstanceCreatedFromDart:object withIdentifier:5];

[instanceManager removeInstanceWithIdentifier:5];
XCTAssertNil([instanceManager instanceForIdentifier:5]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ @interface FWFNavigationDelegateHostApiTests : XCTestCase
@implementation FWFNavigationDelegateHostApiTests
- (void)testCreateWithIdentifier {
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init];
FWFNavigationDelegateHostApiImpl *hostApi =
FWFNavigationDelegateHostApiImpl *hostAPI =
[[FWFNavigationDelegateHostApiImpl alloc] initWithInstanceManager:instanceManager];

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ - (void)testAddObserver {
NSObject *mockObject = OCMClassMock([NSObject class]);

FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init];
[instanceManager addInstance:mockObject withIdentifier:0];
[instanceManager addInstanceCreatedFromDart:mockObject withIdentifier:0];

FWFObjectHostApiImpl *hostApi =
FWFObjectHostApiImpl *hostAPI =
[[FWFObjectHostApiImpl alloc] initWithInstanceManager:instanceManager];

NSObject *observerObject = [[NSObject alloc] init];
[instanceManager addInstance:observerObject withIdentifier:1];
[instanceManager addInstanceCreatedFromDart:observerObject withIdentifier:1];

FlutterError *error;
[hostApi
[hostAPI
addObserverForObjectWithIdentifier:@0
observerIdentifier:@1
keyPath:@"myKey"
Expand All @@ -48,16 +48,16 @@ - (void)testRemoveObserver {
NSObject *mockObject = OCMClassMock([NSObject class]);

FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init];
[instanceManager addInstance:mockObject withIdentifier:0];
[instanceManager addInstanceCreatedFromDart:mockObject withIdentifier:0];

FWFObjectHostApiImpl *hostApi =
FWFObjectHostApiImpl *hostAPI =
[[FWFObjectHostApiImpl alloc] initWithInstanceManager:instanceManager];

NSObject *observerObject = [[NSObject alloc] init];
[instanceManager addInstance:observerObject withIdentifier:1];
[instanceManager addInstanceCreatedFromDart:observerObject withIdentifier:1];

FlutterError *error;
[hostApi removeObserverForObjectWithIdentifier:@0
[hostAPI removeObserverForObjectWithIdentifier:@0
observerIdentifier:@1
keyPath:@"myKey"
error:&error];
Expand All @@ -69,13 +69,13 @@ - (void)testDispose {
NSObject *object = [[NSObject alloc] init];

FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init];
[instanceManager addInstance:object withIdentifier:0];
[instanceManager addInstanceCreatedFromDart:object withIdentifier:0];

FWFObjectHostApiImpl *hostApi =
FWFObjectHostApiImpl *hostAPI =
[[FWFObjectHostApiImpl alloc] initWithInstanceManager:instanceManager];

FlutterError *error;
[hostApi disposeObjectWithIdentifier:@0 error:&error];
[hostAPI disposeObjectWithIdentifier:@0 error:&error];
XCTAssertEqual([instanceManager identifierForInstance:object], NSNotFound);
XCTAssertNil(error);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ @interface FWFPreferencesHostApiTests : XCTestCase
@implementation FWFPreferencesHostApiTests
- (void)testCreateFromWebViewConfigurationWithIdentifier {
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init];
FWFPreferencesHostApiImpl *hostApi =
FWFPreferencesHostApiImpl *hostAPI =
[[FWFPreferencesHostApiImpl alloc] initWithInstanceManager:instanceManager];

[instanceManager addInstance:[[WKWebViewConfiguration alloc] init] withIdentifier:0];
[instanceManager addInstanceCreatedFromDart:[[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 @@ -30,13 +31,13 @@ - (void)testSetJavaScriptEnabled {
WKPreferences *mockPreferences = OCMClassMock([WKPreferences class]);

FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init];
[instanceManager addInstance:mockPreferences withIdentifier:0];
[instanceManager addInstanceCreatedFromDart:mockPreferences withIdentifier:0];

FWFPreferencesHostApiImpl *hostApi =
FWFPreferencesHostApiImpl *hostAPI =
[[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 @@ -14,11 +14,11 @@ @interface FWFScriptMessageHandlerHostApiTests : XCTestCase
@implementation FWFScriptMessageHandlerHostApiTests
- (void)testCreateWithIdentifier {
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init];
FWFScriptMessageHandlerHostApiImpl *hostApi =
FWFScriptMessageHandlerHostApiImpl *hostAPI =
[[FWFScriptMessageHandlerHostApiImpl alloc] initWithInstanceManager:instanceManager];

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

FWFScriptMessageHandler *scriptMessageHandler =
(FWFScriptMessageHandler *)[instanceManager instanceForIdentifier:0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ - (void)testGetContentOffset {
OCMStub([mockScrollView contentOffset]).andReturn(CGPointMake(1.0, 2.0));

FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init];
[instanceManager addInstance:mockScrollView withIdentifier:0];
[instanceManager addInstanceCreatedFromDart:mockScrollView withIdentifier:0];

FWFScrollViewHostApiImpl *hostApi =
FWFScrollViewHostApiImpl *hostAPI =
[[FWFScrollViewHostApiImpl alloc] initWithInstanceManager:instanceManager];

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 @@ -34,13 +34,13 @@ - (void)testScrollBy {
scrollView.contentOffset = CGPointMake(1, 2);

FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init];
[instanceManager addInstance:scrollView withIdentifier:0];
[instanceManager addInstanceCreatedFromDart:scrollView withIdentifier:0];

FWFScrollViewHostApiImpl *hostApi =
FWFScrollViewHostApiImpl *hostAPI =
[[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 @@ -50,13 +50,13 @@ - (void)testSetContentOffset {
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)];

FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init];
[instanceManager addInstance:scrollView withIdentifier:0];
[instanceManager addInstanceCreatedFromDart:scrollView withIdentifier:0];

FWFScrollViewHostApiImpl *hostApi =
FWFScrollViewHostApiImpl *hostAPI =
[[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 @@ -14,11 +14,11 @@ @interface FWFUIDelegateHostApiTests : XCTestCase
@implementation FWFUIDelegateHostApiTests
- (void)testCreateWithIdentifier {
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init];
FWFUIDelegateHostApiImpl *hostApi =
FWFUIDelegateHostApiImpl *hostAPI =
[[FWFUIDelegateHostApiImpl alloc] initWithInstanceManager: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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ - (void)testSetBackgroundColor {
UIView *mockUIView = OCMClassMock([UIView class]);

FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init];
[instanceManager addInstance:mockUIView withIdentifier:0];
[instanceManager addInstanceCreatedFromDart:mockUIView withIdentifier:0];

FWFUIViewHostApiImpl *hostApi =
FWFUIViewHostApiImpl *hostAPI =
[[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 @@ -35,13 +35,13 @@ - (void)testSetOpaque {
UIView *mockUIView = OCMClassMock([UIView class]);

FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init];
[instanceManager addInstance:mockUIView withIdentifier:0];
[instanceManager addInstanceCreatedFromDart:mockUIView withIdentifier:0];

FWFUIViewHostApiImpl *hostApi =
FWFUIViewHostApiImpl *hostAPI =
[[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
Loading