Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
rest of tests
  • Loading branch information
bparrishMines committed Apr 28, 2022
commit 25ce26123c76888deb0f06c871d70c07db923a0b
Original file line number Diff line number Diff line change
Expand Up @@ -312,38 +312,29 @@ - (void)testSetAllowsBackForwardNavigationGestures {
XCTAssertNil(error);
}

//- (void)testevaluateJavaScript {
// FWFWebView *mockWebView = OCMClassMock([FWFWebView class]);
// OCMStub([mockWebView evaluateJavaScript
//
// :aValue
//
//
// ]).andReturn(aValue);
//
// FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init];
// [instanceManager addInstance:mockWebView withIdentifier:0];
//
// FWFWebViewHostApiImpl *hostApi =
// [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager];
//
// FlutterError *error;
// XCTAssertEqualObjects([hostApi evaluateJavaScriptForWebViewWithIdentifier:@0
//
// javaScriptString:aValue
//
// error:&error], @YES);
// [hostApi evaluateJavaScriptForWebViewWithIdentifier:@0
//
// javaScriptString:aValue
//
// error:&error];
// OCMVerify([mockWebView evaluateJavaScript
//
// :aValue
//
//
// ]);
// XCTAssertNil(error);
//}
- (void)testEvaluateJavaScript {
FWFWebView *mockWebView = OCMClassMock([FWFWebView class]);

OCMStub([mockWebView
evaluateJavaScript:@"runJavaScript"
completionHandler:([OCMArg invokeBlockWithArgs:@"result", [NSNull null], nil])]);

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

FWFWebViewHostApiImpl *hostApi =
[[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager];

NSString __block *returnValue;
FlutterError __block *returnError;
[hostApi evaluateJavaScriptForWebViewWithIdentifier:@0
javaScriptString:@"runJavaScript"
completion:^(id result, FlutterError *error) {
returnValue = result;
returnError = error;
}];

XCTAssertEqualObjects(returnValue, @"result");
XCTAssertNil(returnError);
}
@end
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@

NS_ASSUME_NONNULL_BEGIN

/**
* A set of Flutter and Dart assets used by a `FlutterEngine` to initialize execution.
*
* Default implementation delegates methods to FlutterDartProject.
*/
@interface FWFAssetManager : NSObject
- (NSString *)lookupKeyForAsset:(NSString *)asset;
@end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ - (NSString *)lookupKeyForAsset:(NSString *)asset {
@implementation FWFWebView
- (void)setFrame:(CGRect)frame {
[super setFrame:frame];
// Prevents the contentInsets to be adjusted by iOS and gives control to Flutter.
// Prevents the contentInsets from being adjusted by iOS and gives control to Flutter.
self.scrollView.contentInset = UIEdgeInsetsZero;
if (@available(iOS 11, *)) {
// Above iOS 11, adjust contentInset to compensate the adjustedContentInset so the sum will
Expand Down Expand Up @@ -143,14 +143,10 @@ - (void)evaluateJavaScriptForWebViewWithIdentifier:(nonnull NSNumber *)instanceI
returnValue = result;
} else {
NSString *className = NSStringFromClass([result class]);
NSString *message = [NSString
stringWithFormat:
@"Return type not supported: %@. Description of value was added to details.",
className];
flutterError =
[FlutterError errorWithCode:@"FWFEvaluateJavaScriptResultNotSupportedError"
message:message
details:[result description]];
NSLog(@"Return type of evaluateJavaScript is not directly supported: %@. Returned "
@"description of value.",
className);
returnValue = [result description];
}
} else {
flutterError = [FlutterError errorWithCode:@"FWFEvaluateJavaScriptError"
Expand Down