From 129e08c1dff159b1b49484e1f838f0a471273cd7 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Thu, 18 Jan 2024 22:54:24 -0800 Subject: [PATCH] [pigeon] Run swift-format on ungenerated example app Swift files (#5934) Run `swift-format` linter/formatter on Swift files in example apps. This only touches Swift files in example/test code. This also doesn't format any autogenerated Swift files, which would require changed in the pigeon generator: https://github.com/flutter/flutter/issues/141799 Part of turning on swift-format CI formatting https://github.com/flutter/packages/pull/5928 --- packages/pigeon/example/README.md | 10 +- .../example/app/ios/Runner/AppDelegate.swift | 10 +- .../macos/RunnerTests/RunnerTests.swift | 2 +- .../example/ios/Runner/AppDelegate.swift | 2 +- .../ios/RunnerTests/AllDatatypesTests.swift | 83 ++--- .../ios/RunnerTests/AsyncHandlersTest.swift | 23 +- .../ios/RunnerTests/EchoBinaryMessenger.swift | 23 +- .../example/ios/RunnerTests/EnumTests.swift | 13 +- .../RunnerTests/HandlerBinaryMessenger.swift | 18 +- .../example/ios/RunnerTests/ListTests.swift | 15 +- .../ios/RunnerTests/MockBinaryMessenger.swift | 1 + .../ios/RunnerTests/MultipleArityTests.swift | 18 +- .../ios/RunnerTests/NSNullFieldTests.swift | 1 + .../ios/RunnerTests/NonNullFieldsTest.swift | 1 + .../RunnerTests/NullableReturnsTests.swift | 11 +- .../ios/RunnerTests/PrimitiveTests.swift | 75 ++--- .../macos/RunnerTests/BasicCompileTest.swift | 1 + .../test_plugin/ios/Classes/TestPlugin.swift | 287 ++++++++++-------- .../macos/Classes/TestPlugin.swift | 287 ++++++++++-------- 19 files changed, 493 insertions(+), 388 deletions(-) diff --git a/packages/pigeon/example/README.md b/packages/pigeon/example/README.md index 98f9a7596db..b9ff98aca35 100644 --- a/packages/pigeon/example/README.md +++ b/packages/pigeon/example/README.md @@ -127,14 +127,14 @@ private class PigeonApiImplementation: ExampleHostApi { } func add(_ a: Int64, to b: Int64) throws -> Int64 { - if (a < 0 || b < 0) { - throw FlutterError(code: "code", message: "message", details: "details"); + if a < 0 || b < 0 { + throw FlutterError(code: "code", message: "message", details: "details") } return a + b } func sendMessage(message: MessageData, completion: @escaping (Result) -> Void) { - if (message.code == Code.one) { + if message.code == Code.one { completion(.failure(FlutterError(code: "code", message: "message", details: "details"))) return } @@ -237,7 +237,9 @@ private class PigeonFlutterApi { flutterAPI = MessageFlutterApi(binaryMessenger: binaryMessenger) } - func callFlutterMethod(aString aStringArg: String?, completion: @escaping (Result) -> Void) { + func callFlutterMethod( + aString aStringArg: String?, completion: @escaping (Result) -> Void + ) { flutterAPI.flutterMethod(aString: aStringArg) { completion(.success($0)) } diff --git a/packages/pigeon/example/app/ios/Runner/AppDelegate.swift b/packages/pigeon/example/app/ios/Runner/AppDelegate.swift index 3c791312270..f259b759085 100644 --- a/packages/pigeon/example/app/ios/Runner/AppDelegate.swift +++ b/packages/pigeon/example/app/ios/Runner/AppDelegate.swift @@ -15,14 +15,14 @@ private class PigeonApiImplementation: ExampleHostApi { } func add(_ a: Int64, to b: Int64) throws -> Int64 { - if (a < 0 || b < 0) { - throw FlutterError(code: "code", message: "message", details: "details"); + if a < 0 || b < 0 { + throw FlutterError(code: "code", message: "message", details: "details") } return a + b } func sendMessage(message: MessageData, completion: @escaping (Result) -> Void) { - if (message.code == Code.one) { + if message.code == Code.one { completion(.failure(FlutterError(code: "code", message: "message", details: "details"))) return } @@ -39,7 +39,9 @@ private class PigeonFlutterApi { flutterAPI = MessageFlutterApi(binaryMessenger: binaryMessenger) } - func callFlutterMethod(aString aStringArg: String?, completion: @escaping (Result) -> Void) { + func callFlutterMethod( + aString aStringArg: String?, completion: @escaping (Result) -> Void + ) { flutterAPI.flutterMethod(aString: aStringArg) { completion(.success($0)) } diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/example/macos/RunnerTests/RunnerTests.swift b/packages/pigeon/platform_tests/alternate_language_test_plugin/example/macos/RunnerTests/RunnerTests.swift index e332af122ac..46e5239c570 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/example/macos/RunnerTests/RunnerTests.swift +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/example/macos/RunnerTests/RunnerTests.swift @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import FlutterMacOS import Cocoa +import FlutterMacOS import XCTest @testable import alternate_language_test_plugin diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/Runner/AppDelegate.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/Runner/AppDelegate.swift index caf99839333..d83c0ff0bee 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/Runner/AppDelegate.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/Runner/AppDelegate.swift @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import UIKit import Flutter +import UIKit @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/AllDatatypesTests.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/AllDatatypesTests.swift index ed6b5345946..7e7266940f5 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/AllDatatypesTests.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/AllDatatypesTests.swift @@ -4,6 +4,7 @@ import Flutter import XCTest + @testable import test_plugin class AllDatatypesTests: XCTestCase { @@ -17,25 +18,25 @@ class AllDatatypesTests: XCTestCase { api.echoNullable(everything) { result in switch result { - case .success(let res) : - XCTAssertNotNil(res) - XCTAssertNil(res!.aNullableBool) - XCTAssertNil(res!.aNullableInt) - XCTAssertNil(res!.aNullableDouble) - XCTAssertNil(res!.aNullableString) - XCTAssertNil(res!.aNullableByteArray) - XCTAssertNil(res!.aNullable4ByteArray) - XCTAssertNil(res!.aNullable8ByteArray) - XCTAssertNil(res!.aNullableFloatArray) - XCTAssertNil(res!.aNullableList) - XCTAssertNil(res!.aNullableMap) - XCTAssertNil(res!.nullableNestedList) - XCTAssertNil(res!.nullableMapWithAnnotations) - XCTAssertNil(res!.nullableMapWithObject) - expectation.fulfill() - case .failure(_) : - return - + case .success(let res): + XCTAssertNotNil(res) + XCTAssertNil(res!.aNullableBool) + XCTAssertNil(res!.aNullableInt) + XCTAssertNil(res!.aNullableDouble) + XCTAssertNil(res!.aNullableString) + XCTAssertNil(res!.aNullableByteArray) + XCTAssertNil(res!.aNullable4ByteArray) + XCTAssertNil(res!.aNullable8ByteArray) + XCTAssertNil(res!.aNullableFloatArray) + XCTAssertNil(res!.aNullableList) + XCTAssertNil(res!.aNullableMap) + XCTAssertNil(res!.nullableNestedList) + XCTAssertNil(res!.nullableMapWithAnnotations) + XCTAssertNil(res!.nullableMapWithObject) + expectation.fulfill() + case .failure(_): + return + } } @@ -55,36 +56,36 @@ class AllDatatypesTests: XCTestCase { aNullableMap: ["hello": 1234], nullableNestedList: [[true, false], [true]], nullableMapWithAnnotations: ["hello": "world"], - nullableMapWithObject: ["hello": 1234, "goodbye" : "world"], + nullableMapWithObject: ["hello": 1234, "goodbye": "world"], aNullableString: "123" ) - + let binaryMessenger = EchoBinaryMessenger(codec: FlutterIntegrationCoreApiCodec.shared) let api = FlutterIntegrationCoreApi(binaryMessenger: binaryMessenger) let expectation = XCTestExpectation(description: "callback") api.echoNullable(everything) { result in - switch result { - case .success(let res) : - XCTAssertNotNil(res) - XCTAssertEqual(res!.aNullableBool, everything.aNullableBool) - XCTAssertEqual(res!.aNullableInt, everything.aNullableInt) - XCTAssertEqual(res!.aNullableDouble, everything.aNullableDouble) - XCTAssertEqual(res!.aNullableString, everything.aNullableString) - XCTAssertEqual(res!.aNullableByteArray, everything.aNullableByteArray) - XCTAssertEqual(res!.aNullable4ByteArray, everything.aNullable4ByteArray) - XCTAssertEqual(res!.aNullable8ByteArray, everything.aNullable8ByteArray) - XCTAssertEqual(res!.aNullableFloatArray, everything.aNullableFloatArray) - XCTAssert(equalsList(res!.aNullableList, everything.aNullableList)) - XCTAssert(equalsDictionary(res!.aNullableMap, everything.aNullableMap)) - XCTAssertEqual(res!.nullableNestedList, everything.nullableNestedList) - XCTAssertEqual(res!.nullableMapWithAnnotations, everything.nullableMapWithAnnotations) - XCTAssert(equalsDictionary(res!.nullableMapWithObject, everything.nullableMapWithObject)) - expectation.fulfill() - return - case .failure(_) : - return + switch result { + case .success(let res): + XCTAssertNotNil(res) + XCTAssertEqual(res!.aNullableBool, everything.aNullableBool) + XCTAssertEqual(res!.aNullableInt, everything.aNullableInt) + XCTAssertEqual(res!.aNullableDouble, everything.aNullableDouble) + XCTAssertEqual(res!.aNullableString, everything.aNullableString) + XCTAssertEqual(res!.aNullableByteArray, everything.aNullableByteArray) + XCTAssertEqual(res!.aNullable4ByteArray, everything.aNullable4ByteArray) + XCTAssertEqual(res!.aNullable8ByteArray, everything.aNullable8ByteArray) + XCTAssertEqual(res!.aNullableFloatArray, everything.aNullableFloatArray) + XCTAssert(equalsList(res!.aNullableList, everything.aNullableList)) + XCTAssert(equalsDictionary(res!.aNullableMap, everything.aNullableMap)) + XCTAssertEqual(res!.nullableNestedList, everything.nullableNestedList) + XCTAssertEqual(res!.nullableMapWithAnnotations, everything.nullableMapWithAnnotations) + XCTAssert(equalsDictionary(res!.nullableMapWithObject, everything.nullableMapWithObject)) + expectation.fulfill() + return + case .failure(_): + return } } wait(for: [expectation], timeout: 1.0) diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/AsyncHandlersTest.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/AsyncHandlersTest.swift index f5852c47a98..f7e8db59606 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/AsyncHandlersTest.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/AsyncHandlersTest.swift @@ -3,6 +3,7 @@ // found in the LICENSE file. import Flutter import XCTest + @testable import test_plugin class MockHostSmallApi: HostSmallApi { @@ -27,12 +28,12 @@ class AsyncHandlersTest: XCTestCase { let expectation = XCTestExpectation(description: "callback") flutterApi.echo(value) { result in - switch result { - case .success(let res) : - XCTAssertEqual(res, value) - expectation.fulfill() - case .failure(_) : - return + switch result { + case .success(let res): + XCTAssertEqual(res, value) + expectation.fulfill() + case .failure(_): + return } } @@ -40,7 +41,8 @@ class AsyncHandlersTest: XCTestCase { } func testAsyncFlutter2HostVoidVoid() throws { - let binaryMessenger = MockBinaryMessenger(codec: FlutterStandardMessageCodec.sharedInstance()) + let binaryMessenger = MockBinaryMessenger( + codec: FlutterStandardMessageCodec.sharedInstance()) let mockHostSmallApi = MockHostSmallApi() HostSmallApiSetup.setUp(binaryMessenger: binaryMessenger, api: mockHostSmallApi) let channelName = "dev.flutter.pigeon.pigeon_integration_tests.HostSmallApi.voidVoid" @@ -49,14 +51,15 @@ class AsyncHandlersTest: XCTestCase { let expectation = XCTestExpectation(description: "voidvoid callback") binaryMessenger.handlers[channelName]?(nil) { data in let outputList = binaryMessenger.codec.decode(data) as? [Any] - XCTAssertEqual(outputList?.first as! NSNull, NSNull()) + XCTAssertEqual(outputList?.first as! NSNull, NSNull()) expectation.fulfill() } wait(for: [expectation], timeout: 1.0) } func testAsyncFlutter2Host() throws { - let binaryMessenger = MockBinaryMessenger(codec: FlutterStandardMessageCodec.sharedInstance()) + let binaryMessenger = MockBinaryMessenger( + codec: FlutterStandardMessageCodec.sharedInstance()) let mockHostSmallApi = MockHostSmallApi() let value = "Test" mockHostSmallApi.output = value @@ -69,7 +72,7 @@ class AsyncHandlersTest: XCTestCase { let expectation = XCTestExpectation(description: "echo callback") binaryMessenger.handlers[channelName]?(inputEncoded) { data in let outputList = binaryMessenger.codec.decode(data) as? [Any] - let output = outputList?.first as? String + let output = outputList?.first as? String XCTAssertEqual(output, value) expectation.fulfill() } diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/EchoBinaryMessenger.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/EchoBinaryMessenger.swift index a2f524c2bd9..26c4de6eac7 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/EchoBinaryMessenger.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/EchoBinaryMessenger.swift @@ -2,30 +2,30 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import Foundation import Flutter +import Foundation class EchoBinaryMessenger: NSObject, FlutterBinaryMessenger { let codec: FlutterMessageCodec private(set) var count = 0 var defaultReturn: Any? - + init(codec: FlutterMessageCodec) { self.codec = codec super.init() } - + func send(onChannel channel: String, message: Data?) { // Method not implemented because this messenger is just for echoing } - + func send( onChannel channel: String, message: Data?, binaryReply callback: FlutterBinaryReply? = nil ) { guard let callback = callback else { return } - + guard let args = self.codec.decode(message) as? [Any?], let firstArg = args.first, @@ -34,20 +34,21 @@ class EchoBinaryMessenger: NSObject, FlutterBinaryMessenger { callback(self.defaultReturn.flatMap { self.codec.encode([$0]) }) return } - + callback(self.codec.encode([castedFirstArg])) } - + func setMessageHandlerOnChannel( - _ channel: String, binaryMessageHandler handler: - FlutterBinaryMessageHandler? = nil + _ channel: String, + binaryMessageHandler handler: + FlutterBinaryMessageHandler? = nil ) -> FlutterBinaryMessengerConnection { self.count += 1 return FlutterBinaryMessengerConnection(self.count) } - + func cleanUpConnection(_ connection: FlutterBinaryMessengerConnection) { - // Method not implemented because this messenger is just for echoing + // Method not implemented because this messenger is just for echoing } private func nilOrValue(_ value: Any?) -> T? { diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/EnumTests.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/EnumTests.swift index 2c8c0cc4119..391ace5d914 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/EnumTests.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/EnumTests.swift @@ -3,6 +3,7 @@ // found in the LICENSE file. import XCTest + @testable import test_plugin class MockEnumApi2Host: EnumApi2Host { @@ -32,7 +33,7 @@ class EnumTests: XCTestCase { binaryMessenger.handlers[channelName]?(inputEncoded) { data in let outputMap = binaryMessenger.codec.decode(data) as? [Any] XCTAssertNotNil(outputMap) - + let output = outputMap?.first as? DataWithEnum XCTAssertEqual(output, input) XCTAssertTrue(outputMap?.count == 1) @@ -49,11 +50,11 @@ class EnumTests: XCTestCase { let expectation = XCTestExpectation(description: "callback") api.echo(data: data) { result in switch result { - case .success(let res) : - XCTAssertEqual(res.state, res.state) - expectation.fulfill() - case .failure(_) : - return + case .success(let res): + XCTAssertEqual(res.state, res.state) + expectation.fulfill() + case .failure(_): + return } } wait(for: [expectation], timeout: 1.0) diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/HandlerBinaryMessenger.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/HandlerBinaryMessenger.swift index fda20a40da5..7bd4394f9e0 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/HandlerBinaryMessenger.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/HandlerBinaryMessenger.swift @@ -2,42 +2,42 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import Foundation import Flutter +import Foundation -typealias HandlerBinaryMessengerHandler = ([Any?])-> Any +typealias HandlerBinaryMessengerHandler = ([Any?]) -> Any class HandlerBinaryMessenger: NSObject, FlutterBinaryMessenger { let codec: FlutterMessageCodec let handler: HandlerBinaryMessengerHandler private var count = 0 - + init(codec: FlutterMessageCodec, handler: @escaping HandlerBinaryMessengerHandler) { self.codec = codec self.handler = handler super.init() } - + func send(onChannel channel: String, message: Data?) { // Method not implemented because this messenger is just for handling } - + func send( onChannel channel: String, message: Data?, binaryReply callback: FlutterBinaryReply? = nil ) { guard let callback = callback else { return } - + guard let args = self.codec.decode(message) as? [Any?] else { callback(nil) return } - + let result = self.handler(args) callback(self.codec.encode([result])) } - + func setMessageHandlerOnChannel( _ channel: String, binaryMessageHandler handler: FlutterBinaryMessageHandler? = nil @@ -45,7 +45,7 @@ class HandlerBinaryMessenger: NSObject, FlutterBinaryMessenger { self.count += 1 return FlutterBinaryMessengerConnection(self.count) } - + func cleanUpConnection(_ connection: FlutterBinaryMessengerConnection) { // Method not implemented because this messenger is just for handling } diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/ListTests.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/ListTests.swift index b096ed2bc58..4fc7de6b96e 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/ListTests.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/ListTests.swift @@ -3,6 +3,7 @@ // found in the LICENSE file. import XCTest + @testable import test_plugin class ListTests: XCTestCase { @@ -16,13 +17,13 @@ class ListTests: XCTestCase { let expectation = XCTestExpectation(description: "callback") api.echo(top) { result in switch result { - case .success(let res) : - XCTAssertEqual(1, res.testList?.count) - XCTAssertTrue(res.testList?[0] is TestMessage) - XCTAssert(equalsList(inside.testList, (res.testList?[0] as! TestMessage).testList)) - expectation.fulfill() - case .failure(_) : - return + case .success(let res): + XCTAssertEqual(1, res.testList?.count) + XCTAssertTrue(res.testList?[0] is TestMessage) + XCTAssert(equalsList(inside.testList, (res.testList?[0] as! TestMessage).testList)) + expectation.fulfill() + case .failure(_): + return } } wait(for: [expectation], timeout: 1.0) diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/MockBinaryMessenger.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/MockBinaryMessenger.swift index 9f7f9483b1e..23aa9d5b577 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/MockBinaryMessenger.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/MockBinaryMessenger.swift @@ -3,6 +3,7 @@ // found in the LICENSE file. import Flutter + @testable import test_plugin class MockBinaryMessenger: NSObject, FlutterBinaryMessenger { diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/MultipleArityTests.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/MultipleArityTests.swift index 52155f8927a..f42933b2391 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/MultipleArityTests.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/MultipleArityTests.swift @@ -4,6 +4,7 @@ import Flutter import XCTest + @testable import test_plugin class MockMultipleArityHostApi: MultipleArityHostApi { @@ -16,7 +17,8 @@ class MultipleArityTests: XCTestCase { var codec = FlutterStandardMessageCodec.sharedInstance() func testSimpleHost() throws { let binaryMessenger = MockBinaryMessenger(codec: EnumApi2HostCodec.shared) - MultipleArityHostApiSetup.setUp(binaryMessenger: binaryMessenger, api: MockMultipleArityHostApi()) + MultipleArityHostApiSetup.setUp( + binaryMessenger: binaryMessenger, api: MockMultipleArityHostApi()) let channelName = "dev.flutter.pigeon.pigeon_integration_tests.MultipleArityHostApi.subtract" XCTAssertNotNil(binaryMessenger.handlers[channelName]) @@ -28,10 +30,10 @@ class MultipleArityTests: XCTestCase { binaryMessenger.handlers[channelName]?(inputEncoded) { data in let outputList = binaryMessenger.codec.decode(data) as? [Any] XCTAssertNotNil(outputList) - + let output = outputList![0] as? Int64 XCTAssertEqual(3, output) - XCTAssertTrue(outputList?.count == 1) + XCTAssertTrue(outputList?.count == 1) expectation.fulfill() } wait(for: [expectation], timeout: 1.0) @@ -46,11 +48,11 @@ class MultipleArityTests: XCTestCase { let expectation = XCTestExpectation(description: "subtraction") api.subtract(x: 30, y: 10) { result in switch result { - case .success(let res) : - XCTAssertEqual(20, res) - expectation.fulfill() - case .failure(_) : - return + case .success(let res): + XCTAssertEqual(20, res) + expectation.fulfill() + case .failure(_): + return } } wait(for: [expectation], timeout: 1.0) diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/NSNullFieldTests.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/NSNullFieldTests.swift index 036608f2fd8..a10a88d01fa 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/NSNullFieldTests.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/NSNullFieldTests.swift @@ -3,6 +3,7 @@ // found in the LICENSE file. import XCTest + @testable import test_plugin /// Tests NSNull is correctly handled by `nilOrValue` helper, by manually setting nullable fields to NSNull. diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/NonNullFieldsTest.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/NonNullFieldsTest.swift index ce1f4579a88..07ccb6b6c6f 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/NonNullFieldsTest.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/NonNullFieldsTest.swift @@ -3,6 +3,7 @@ // found in the LICENSE file. import XCTest + @testable import test_plugin class NonNullFieldsTests: XCTestCase { diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/NullableReturnsTests.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/NullableReturnsTests.swift index dca9d6e3d6e..cf56bebd58a 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/NullableReturnsTests.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/NullableReturnsTests.swift @@ -4,6 +4,7 @@ import Flutter import XCTest + @testable import test_plugin class MockNullableArgHostApi: NullableArgHostApi { @@ -27,11 +28,11 @@ class NullableReturnsTests: XCTestCase { let expectation = XCTestExpectation(description: "callback") api.doit(x: nil) { result in switch result { - case .success(let res) : - XCTAssertEqual(99, res) - expectation.fulfill() - case .failure(_) : - return + case .success(let res): + XCTAssertEqual(99, res) + expectation.fulfill() + case .failure(_): + return } } wait(for: [expectation], timeout: 1.0) diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/PrimitiveTests.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/PrimitiveTests.swift index 86b118e7f62..2f99f45f1e9 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/PrimitiveTests.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/PrimitiveTests.swift @@ -4,12 +4,13 @@ import Flutter import XCTest + @testable import test_plugin class MockPrimitiveHostApi: PrimitiveHostApi { func anInt(value: Int64) -> Int64 { value } func aBool(value: Bool) -> Bool { value } - func aString(value: String) -> String { value } + func aString(value: String) -> String { value } func aDouble(value: Double) -> Double { value } func aMap(value: [AnyHashable: Any?]) -> [AnyHashable: Any?] { value } func aList(value: [Any?]) -> [Any?] { value } @@ -34,7 +35,7 @@ class PrimitiveTests: XCTestCase { binaryMessenger.handlers[channelName]?(inputEncoded) { data in let outputList = binaryMessenger.codec.decode(data) as? [Any] XCTAssertNotNil(outputList) - + let output = outputList!.first as? Int64 XCTAssertEqual(1, output) XCTAssertTrue(outputList!.count == 1) @@ -50,12 +51,12 @@ class PrimitiveTests: XCTestCase { let expectation = XCTestExpectation(description: "callback") api.anInt(value: 1) { result in switch result { - case .success(let res) : - XCTAssertEqual(1, res) - expectation.fulfill() - case .failure(_) : - return - + case .success(let res): + XCTAssertEqual(1, res) + expectation.fulfill() + case .failure(_): + return + } } wait(for: [expectation], timeout: 1.0) @@ -74,7 +75,7 @@ class PrimitiveTests: XCTestCase { binaryMessenger.handlers[channelName]?(inputEncoded) { data in let outputList = binaryMessenger.codec.decode(data) as? [Any] XCTAssertNotNil(outputList) - + let output = outputList!.first as? Bool XCTAssertEqual(true, output) XCTAssertTrue(outputList!.count == 1) @@ -90,11 +91,11 @@ class PrimitiveTests: XCTestCase { let expectation = XCTestExpectation(description: "callback") api.aBool(value: true) { result in switch result { - case .success(let res) : - XCTAssertEqual(true, res) - expectation.fulfill() - case .failure(_) : - return + case .success(let res): + XCTAssertEqual(true, res) + expectation.fulfill() + case .failure(_): + return } } wait(for: [expectation], timeout: 1.0) @@ -113,7 +114,7 @@ class PrimitiveTests: XCTestCase { binaryMessenger.handlers[channelName]?(inputEncoded) { data in let outputList = binaryMessenger.codec.decode(data) as? [Any] XCTAssertNotNil(outputList) - + let output = outputList!.first as? Double XCTAssertEqual(1.0, output) XCTAssertTrue(outputList!.count == 1) @@ -130,11 +131,11 @@ class PrimitiveTests: XCTestCase { let arg: Double = 1.5 api.aDouble(value: arg) { result in switch result { - case .success(let res) : - XCTAssertEqual(arg, res) - expectation.fulfill() - case .failure(_) : - return + case .success(let res): + XCTAssertEqual(arg, res) + expectation.fulfill() + case .failure(_): + return } } wait(for: [expectation], timeout: 1.0) @@ -153,7 +154,7 @@ class PrimitiveTests: XCTestCase { binaryMessenger.handlers[channelName]?(inputEncoded) { data in let outputList = binaryMessenger.codec.decode(data) as? [Any] XCTAssertNotNil(outputList) - + let output = outputList!.first as? String XCTAssertEqual("hello", output) XCTAssertTrue(outputList!.count == 1) @@ -170,11 +171,11 @@ class PrimitiveTests: XCTestCase { let arg: String = "hello" api.aString(value: arg) { result in switch result { - case .success(let res) : - XCTAssertEqual(arg, res) - expectation.fulfill() - case .failure(_) : - return + case .success(let res): + XCTAssertEqual(arg, res) + expectation.fulfill() + case .failure(_): + return } } wait(for: [expectation], timeout: 1.0) @@ -193,7 +194,7 @@ class PrimitiveTests: XCTestCase { binaryMessenger.handlers[channelName]?(inputEncoded) { data in let outputList = binaryMessenger.codec.decode(data) as? [Any] XCTAssertNotNil(outputList) - + let output = outputList!.first as? [Int] XCTAssertEqual([1, 2, 3], output) XCTAssertTrue(outputList!.count == 1) @@ -210,11 +211,11 @@ class PrimitiveTests: XCTestCase { let arg = ["hello"] api.aList(value: arg) { result in switch result { - case .success(let res) : - XCTAssert(equalsList(arg, res)) - expectation.fulfill() - case .failure(_) : - return + case .success(let res): + XCTAssert(equalsList(arg, res)) + expectation.fulfill() + case .failure(_): + return } } wait(for: [expectation], timeout: 1.0) @@ -250,11 +251,11 @@ class PrimitiveTests: XCTestCase { let arg = ["hello": 1] api.aMap(value: arg) { result in switch result { - case .success(let res) : - XCTAssert(equalsDictionary(arg, res)) - expectation.fulfill() - case .failure(_) : - return + case .success(let res): + XCTAssert(equalsDictionary(arg, res)) + expectation.fulfill() + case .failure(_): + return } } diff --git a/packages/pigeon/platform_tests/test_plugin/example/macos/RunnerTests/BasicCompileTest.swift b/packages/pigeon/platform_tests/test_plugin/example/macos/RunnerTests/BasicCompileTest.swift index a828ca540e8..b3a751166b0 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/macos/RunnerTests/BasicCompileTest.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/macos/RunnerTests/BasicCompileTest.swift @@ -3,6 +3,7 @@ // found in the LICENSE file. import XCTest + @testable import test_plugin class MyApi: HostTrivialApi { diff --git a/packages/pigeon/platform_tests/test_plugin/ios/Classes/TestPlugin.swift b/packages/pigeon/platform_tests/test_plugin/ios/Classes/TestPlugin.swift index 8b4daf5a08e..0d04c9544ca 100644 --- a/packages/pigeon/platform_tests/test_plugin/ios/Classes/TestPlugin.swift +++ b/packages/pigeon/platform_tests/test_plugin/ios/Classes/TestPlugin.swift @@ -7,10 +7,8 @@ import UIKit extension FlutterError: Error {} -/** - * This plugin handles the native side of the integration tests in - * example/integration_test/. - */ +/// This plugin handles the native side of the integration tests in +/// example/integration_test/. public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { var flutterAPI: FlutterIntegrationCoreApi @@ -90,15 +88,18 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { } func extractNestedNullableString(from wrapper: AllClassesWrapper) -> String? { - return wrapper.allNullableTypes.aNullableString; + return wrapper.allNullableTypes.aNullableString } func createNestedObject(with nullableString: String?) -> AllClassesWrapper { return AllClassesWrapper(allNullableTypes: AllNullableTypes(aNullableString: nullableString)) } - func sendMultipleNullableTypes(aBool aNullableBool: Bool?, anInt aNullableInt: Int64?, aString aNullableString: String?) -> AllNullableTypes { - let someThings = AllNullableTypes(aNullableBool: aNullableBool, aNullableInt: aNullableInt, aNullableString: aNullableString) + func sendMultipleNullableTypes( + aBool aNullableBool: Bool?, anInt aNullableInt: Int64?, aString aNullableString: String? + ) -> AllNullableTypes { + let someThings = AllNullableTypes( + aNullableBool: aNullableBool, aNullableInt: aNullableInt, aNullableString: aNullableString) return someThings } @@ -178,7 +179,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { completion(.success(everything)) } - func echoAsync(_ everything: AllNullableTypes?, completion: @escaping (Result) -> Void) { + func echoAsync( + _ everything: AllNullableTypes?, + completion: @escaping (Result) -> Void + ) { completion(.success(everything)) } @@ -198,7 +202,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { completion(.success(aString)) } - func echoAsync(_ aUint8List: FlutterStandardTypedData, completion: @escaping (Result) -> Void) { + func echoAsync( + _ aUint8List: FlutterStandardTypedData, + completion: @escaping (Result) -> Void + ) { completion(.success(aUint8List)) } @@ -210,7 +217,9 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { completion(.success(aList)) } - func echoAsync(_ aMap: [String?: Any?], completion: @escaping (Result<[String?: Any?], Error>) -> Void) { + func echoAsync( + _ aMap: [String?: Any?], completion: @escaping (Result<[String?: Any?], Error>) -> Void + ) { completion(.success(aMap)) } @@ -222,7 +231,8 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { completion(.success(anInt)) } - func echoAsyncNullable(_ aDouble: Double?, completion: @escaping (Result) -> Void) { + func echoAsyncNullable(_ aDouble: Double?, completion: @escaping (Result) -> Void) + { completion(.success(aDouble)) } @@ -230,11 +240,15 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { completion(.success(aBool)) } - func echoAsyncNullable(_ aString: String?, completion: @escaping (Result) -> Void) { + func echoAsyncNullable(_ aString: String?, completion: @escaping (Result) -> Void) + { completion(.success(aString)) } - func echoAsyncNullable(_ aUint8List: FlutterStandardTypedData?, completion: @escaping (Result) -> Void) { + func echoAsyncNullable( + _ aUint8List: FlutterStandardTypedData?, + completion: @escaping (Result) -> Void + ) { completion(.success(aUint8List)) } @@ -246,66 +260,74 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { completion(.success(aList)) } - func echoAsyncNullable(_ aMap: [String?: Any?]?, completion: @escaping (Result<[String?: Any?]?, Error>) -> Void) { + func echoAsyncNullable( + _ aMap: [String?: Any?]?, completion: @escaping (Result<[String?: Any?]?, Error>) -> Void + ) { completion(.success(aMap)) } - func echoAsyncNullable(_ anEnum: AnEnum?, completion: @escaping (Result) -> Void) { + func echoAsyncNullable(_ anEnum: AnEnum?, completion: @escaping (Result) -> Void) + { completion(.success(anEnum)) } func callFlutterNoop(completion: @escaping (Result) -> Void) { - flutterAPI.noop() { response in + flutterAPI.noop { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } func callFlutterThrowError(completion: @escaping (Result) -> Void) { - flutterAPI.throwError() { response in + flutterAPI.throwError { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } func callFlutterThrowErrorFromVoid(completion: @escaping (Result) -> Void) { - flutterAPI.throwErrorFromVoid() { response in + flutterAPI.throwErrorFromVoid { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEcho(_ everything: AllTypes, completion: @escaping (Result) -> Void) { + func callFlutterEcho( + _ everything: AllTypes, completion: @escaping (Result) -> Void + ) { flutterAPI.echo(everything) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) - } + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) + } } } - func callFlutterEcho(_ everything: AllNullableTypes?, completion: @escaping (Result) -> Void) { + func callFlutterEcho( + _ everything: AllNullableTypes?, + completion: @escaping (Result) -> Void + ) { flutterAPI.echoNullable(everything) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) - } + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) + } } } @@ -321,10 +343,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { aString: aNullableString ) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } @@ -332,10 +354,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { func callFlutterEcho(_ aBool: Bool, completion: @escaping (Result) -> Void) { flutterAPI.echo(aBool) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } @@ -343,10 +365,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { func callFlutterEcho(_ anInt: Int64, completion: @escaping (Result) -> Void) { flutterAPI.echo(anInt) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } @@ -354,10 +376,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { func callFlutterEcho(_ aDouble: Double, completion: @escaping (Result) -> Void) { flutterAPI.echo(aDouble) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } @@ -365,21 +387,24 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { func callFlutterEcho(_ aString: String, completion: @escaping (Result) -> Void) { flutterAPI.echo(aString) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEcho(_ aList: FlutterStandardTypedData, completion: @escaping (Result) -> Void) { + func callFlutterEcho( + _ aList: FlutterStandardTypedData, + completion: @escaping (Result) -> Void + ) { flutterAPI.echo(aList) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } @@ -387,21 +412,23 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { func callFlutterEcho(_ aList: [Any?], completion: @escaping (Result<[Any?], Error>) -> Void) { flutterAPI.echo(aList) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEcho(_ aMap: [String? : Any?], completion: @escaping (Result<[String? : Any?], Error>) -> Void) { + func callFlutterEcho( + _ aMap: [String?: Any?], completion: @escaping (Result<[String?: Any?], Error>) -> Void + ) { flutterAPI.echo(aMap) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } @@ -409,99 +436,115 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { func callFlutterEcho(_ anEnum: AnEnum, completion: @escaping (Result) -> Void) { flutterAPI.echo(anEnum) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEchoNullable(_ aBool: Bool?, completion: @escaping (Result) -> Void) { + func callFlutterEchoNullable(_ aBool: Bool?, completion: @escaping (Result) -> Void) + { flutterAPI.echoNullable(aBool) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEchoNullable(_ anInt: Int64?, completion: @escaping (Result) -> Void) { + func callFlutterEchoNullable( + _ anInt: Int64?, completion: @escaping (Result) -> Void + ) { flutterAPI.echoNullable(anInt) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEchoNullable(_ aDouble: Double?, completion: @escaping (Result) -> Void) { + func callFlutterEchoNullable( + _ aDouble: Double?, completion: @escaping (Result) -> Void + ) { flutterAPI.echoNullable(aDouble) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEchoNullable(_ aString: String?, completion: @escaping (Result) -> Void) { + func callFlutterEchoNullable( + _ aString: String?, completion: @escaping (Result) -> Void + ) { flutterAPI.echoNullable(aString) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - - func callFlutterEchoNullable(_ aList: FlutterStandardTypedData?, completion: @escaping (Result) -> Void) { + + func callFlutterEchoNullable( + _ aList: FlutterStandardTypedData?, + completion: @escaping (Result) -> Void + ) { flutterAPI.echoNullable(aList) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEchoNullable(_ aList: [Any?]?, completion: @escaping (Result<[Any?]?, Error>) -> Void) { + func callFlutterEchoNullable( + _ aList: [Any?]?, completion: @escaping (Result<[Any?]?, Error>) -> Void + ) { flutterAPI.echoNullable(aList) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEchoNullable(_ aMap: [String? : Any?]?, completion: @escaping (Result<[String? : Any?]?, Error>) -> Void) { + func callFlutterEchoNullable( + _ aMap: [String?: Any?]?, completion: @escaping (Result<[String?: Any?]?, Error>) -> Void + ) { flutterAPI.echoNullable(aMap) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterNullableEcho(_ anEnum: AnEnum?, completion: @escaping (Result) -> Void) { + func callFlutterNullableEcho( + _ anEnum: AnEnum?, completion: @escaping (Result) -> Void + ) { flutterAPI.echoNullable(anEnum) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } - } + } } } diff --git a/packages/pigeon/platform_tests/test_plugin/macos/Classes/TestPlugin.swift b/packages/pigeon/platform_tests/test_plugin/macos/Classes/TestPlugin.swift index c82f94b1c0b..5da16290c7a 100644 --- a/packages/pigeon/platform_tests/test_plugin/macos/Classes/TestPlugin.swift +++ b/packages/pigeon/platform_tests/test_plugin/macos/Classes/TestPlugin.swift @@ -7,10 +7,8 @@ import FlutterMacOS extension FlutterError: Error {} -/** - * This plugin handles the native side of the integration tests in - * example/integration_test/. - */ +/// This plugin handles the native side of the integration tests in +/// example/integration_test/. public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { var flutterAPI: FlutterIntegrationCoreApi @@ -102,15 +100,18 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { } func extractNestedNullableString(from wrapper: AllClassesWrapper) -> String? { - return wrapper.allNullableTypes.aNullableString; + return wrapper.allNullableTypes.aNullableString } func createNestedObject(with nullableString: String?) -> AllClassesWrapper { return AllClassesWrapper(allNullableTypes: AllNullableTypes(aNullableString: nullableString)) } - func sendMultipleNullableTypes(aBool aNullableBool: Bool?, anInt aNullableInt: Int64?, aString aNullableString: String?) -> AllNullableTypes { - let someThings = AllNullableTypes(aNullableBool: aNullableBool, aNullableInt: aNullableInt, aNullableString: aNullableString) + func sendMultipleNullableTypes( + aBool aNullableBool: Bool?, anInt aNullableInt: Int64?, aString aNullableString: String? + ) -> AllNullableTypes { + let someThings = AllNullableTypes( + aNullableBool: aNullableBool, aNullableInt: aNullableInt, aNullableString: aNullableString) return someThings } @@ -178,7 +179,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { completion(.success(everything)) } - func echoAsync(_ everything: AllNullableTypes?, completion: @escaping (Result) -> Void) { + func echoAsync( + _ everything: AllNullableTypes?, + completion: @escaping (Result) -> Void + ) { completion(.success(everything)) } @@ -198,7 +202,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { completion(.success(aString)) } - func echoAsync(_ aUint8List: FlutterStandardTypedData, completion: @escaping (Result) -> Void) { + func echoAsync( + _ aUint8List: FlutterStandardTypedData, + completion: @escaping (Result) -> Void + ) { completion(.success(aUint8List)) } @@ -210,7 +217,9 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { completion(.success(aList)) } - func echoAsync(_ aMap: [String?: Any?], completion: @escaping (Result<[String?: Any?], Error>) -> Void) { + func echoAsync( + _ aMap: [String?: Any?], completion: @escaping (Result<[String?: Any?], Error>) -> Void + ) { completion(.success(aMap)) } @@ -222,7 +231,8 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { completion(.success(anInt)) } - func echoAsyncNullable(_ aDouble: Double?, completion: @escaping (Result) -> Void) { + func echoAsyncNullable(_ aDouble: Double?, completion: @escaping (Result) -> Void) + { completion(.success(aDouble)) } @@ -230,11 +240,15 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { completion(.success(aBool)) } - func echoAsyncNullable(_ aString: String?, completion: @escaping (Result) -> Void) { + func echoAsyncNullable(_ aString: String?, completion: @escaping (Result) -> Void) + { completion(.success(aString)) } - func echoAsyncNullable(_ aUint8List: FlutterStandardTypedData?, completion: @escaping (Result) -> Void) { + func echoAsyncNullable( + _ aUint8List: FlutterStandardTypedData?, + completion: @escaping (Result) -> Void + ) { completion(.success(aUint8List)) } @@ -246,66 +260,74 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { completion(.success(aList)) } - func echoAsyncNullable(_ aMap: [String?: Any?]?, completion: @escaping (Result<[String?: Any?]?, Error>) -> Void) { + func echoAsyncNullable( + _ aMap: [String?: Any?]?, completion: @escaping (Result<[String?: Any?]?, Error>) -> Void + ) { completion(.success(aMap)) } - func echoAsyncNullable(_ anEnum: AnEnum?, completion: @escaping (Result) -> Void) { + func echoAsyncNullable(_ anEnum: AnEnum?, completion: @escaping (Result) -> Void) + { completion(.success(anEnum)) } func callFlutterNoop(completion: @escaping (Result) -> Void) { - flutterAPI.noop() { response in + flutterAPI.noop { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } func callFlutterThrowError(completion: @escaping (Result) -> Void) { - flutterAPI.throwError() { response in + flutterAPI.throwError { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } func callFlutterThrowErrorFromVoid(completion: @escaping (Result) -> Void) { - flutterAPI.throwErrorFromVoid() { response in + flutterAPI.throwErrorFromVoid { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEcho(_ everything: AllTypes, completion: @escaping (Result) -> Void) { + func callFlutterEcho( + _ everything: AllTypes, completion: @escaping (Result) -> Void + ) { flutterAPI.echo(everything) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) - } + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) + } } } - func callFlutterEcho(_ everything: AllNullableTypes?, completion: @escaping (Result) -> Void) { + func callFlutterEcho( + _ everything: AllNullableTypes?, + completion: @escaping (Result) -> Void + ) { flutterAPI.echoNullable(everything) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) - } + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) + } } } @@ -321,10 +343,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { aString: aNullableString ) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } @@ -332,10 +354,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { func callFlutterEcho(_ aBool: Bool, completion: @escaping (Result) -> Void) { flutterAPI.echo(aBool) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } @@ -343,10 +365,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { func callFlutterEcho(_ anInt: Int64, completion: @escaping (Result) -> Void) { flutterAPI.echo(anInt) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } @@ -354,10 +376,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { func callFlutterEcho(_ aDouble: Double, completion: @escaping (Result) -> Void) { flutterAPI.echo(aDouble) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } @@ -365,21 +387,24 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { func callFlutterEcho(_ aString: String, completion: @escaping (Result) -> Void) { flutterAPI.echo(aString) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEcho(_ aList: FlutterStandardTypedData, completion: @escaping (Result) -> Void) { + func callFlutterEcho( + _ aList: FlutterStandardTypedData, + completion: @escaping (Result) -> Void + ) { flutterAPI.echo(aList) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } @@ -387,21 +412,23 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { func callFlutterEcho(_ aList: [Any?], completion: @escaping (Result<[Any?], Error>) -> Void) { flutterAPI.echo(aList) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEcho(_ aMap: [String? : Any?], completion: @escaping (Result<[String? : Any?], Error>) -> Void) { + func callFlutterEcho( + _ aMap: [String?: Any?], completion: @escaping (Result<[String?: Any?], Error>) -> Void + ) { flutterAPI.echo(aMap) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } @@ -409,99 +436,115 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { func callFlutterEcho(_ anEnum: AnEnum, completion: @escaping (Result) -> Void) { flutterAPI.echo(anEnum) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEchoNullable(_ aBool: Bool?, completion: @escaping (Result) -> Void) { + func callFlutterEchoNullable(_ aBool: Bool?, completion: @escaping (Result) -> Void) + { flutterAPI.echoNullable(aBool) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEchoNullable(_ anInt: Int64?, completion: @escaping (Result) -> Void) { + func callFlutterEchoNullable( + _ anInt: Int64?, completion: @escaping (Result) -> Void + ) { flutterAPI.echoNullable(anInt) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEchoNullable(_ aDouble: Double?, completion: @escaping (Result) -> Void) { + func callFlutterEchoNullable( + _ aDouble: Double?, completion: @escaping (Result) -> Void + ) { flutterAPI.echoNullable(aDouble) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEchoNullable(_ aString: String?, completion: @escaping (Result) -> Void) { + func callFlutterEchoNullable( + _ aString: String?, completion: @escaping (Result) -> Void + ) { flutterAPI.echoNullable(aString) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - - func callFlutterEchoNullable(_ aList: FlutterStandardTypedData?, completion: @escaping (Result) -> Void) { + + func callFlutterEchoNullable( + _ aList: FlutterStandardTypedData?, + completion: @escaping (Result) -> Void + ) { flutterAPI.echoNullable(aList) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEchoNullable(_ aList: [Any?]?, completion: @escaping (Result<[Any?]?, Error>) -> Void) { + func callFlutterEchoNullable( + _ aList: [Any?]?, completion: @escaping (Result<[Any?]?, Error>) -> Void + ) { flutterAPI.echoNullable(aList) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEchoNullable(_ aMap: [String? : Any?]?, completion: @escaping (Result<[String? : Any?]?, Error>) -> Void) { + func callFlutterEchoNullable( + _ aMap: [String?: Any?]?, completion: @escaping (Result<[String?: Any?]?, Error>) -> Void + ) { flutterAPI.echoNullable(aMap) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterNullableEcho(_ anEnum: AnEnum?, completion: @escaping (Result) -> Void) { + func callFlutterNullableEcho( + _ anEnum: AnEnum?, completion: @escaping (Result) -> Void + ) { flutterAPI.echoNullable(anEnum) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } - } + } } }