From 6e427fdd50a3182c2888b5659c322afaa350cb77 Mon Sep 17 00:00:00 2001 From: Andres Gutierrez Date: Tue, 7 Feb 2023 22:47:27 -0800 Subject: [PATCH 1/3] add unit tests --- .../ios/Runner.xcodeproj/project.pbxproj | 48 +++++-- .../ios/RunnerTests/URLLauncherTests.m | 18 --- .../ios/RunnerTests/URLLauncherTests.swift | 121 ++++++++++++++++++ 3 files changed, 159 insertions(+), 28 deletions(-) delete mode 100644 packages/url_launcher/url_launcher_ios/example/ios/RunnerTests/URLLauncherTests.m create mode 100644 packages/url_launcher/url_launcher_ios/example/ios/RunnerTests/URLLauncherTests.swift diff --git a/packages/url_launcher/url_launcher_ios/example/ios/Runner.xcodeproj/project.pbxproj b/packages/url_launcher/url_launcher_ios/example/ios/Runner.xcodeproj/project.pbxproj index d61abc724469..682ff0754ae1 100644 --- a/packages/url_launcher/url_launcher_ios/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/url_launcher/url_launcher_ios/example/ios/Runner.xcodeproj/project.pbxproj @@ -10,13 +10,13 @@ 2D92223F1EC1DA93007564B0 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D92223E1EC1DA93007564B0 /* GeneratedPluginRegistrant.m */; }; 2E37D9A274B2EACB147AC51B /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 856D0913184F79C678A42603 /* libPods-Runner.a */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 41EB1F8B29937B550044D319 /* URLLauncherTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41EB1F8A29937B550044D319 /* URLLauncherTests.swift */; }; 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; B8140773523F70A044426500 /* libPods-RunnerTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 487A1B5A2ECB3E406FD62FE3 /* libPods-RunnerTests.a */; }; - F7151F4B26604CFB0028CB91 /* URLLauncherTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F7151F4A26604CFB0028CB91 /* URLLauncherTests.m */; }; F7151F5926604D060028CB91 /* URLLauncherUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = F7151F5826604D060028CB91 /* URLLauncherUITests.m */; }; /* End PBXBuildFile section */ @@ -54,6 +54,7 @@ 2D92223D1EC1DA93007564B0 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GeneratedPluginRegistrant.h; path = Runner/GeneratedPluginRegistrant.h; sourceTree = ""; }; 2D92223E1EC1DA93007564B0 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GeneratedPluginRegistrant.m; path = Runner/GeneratedPluginRegistrant.m; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 41EB1F8A29937B550044D319 /* URLLauncherTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLLauncherTests.swift; sourceTree = ""; }; 487A1B5A2ECB3E406FD62FE3 /* libPods-RunnerTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RunnerTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 666BCD7C181C34F8BE58929B /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; @@ -72,7 +73,6 @@ A84BFEE343F54B983D1B67EB /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; D25C434271ACF6555E002440 /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; F7151F4826604CFB0028CB91 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - F7151F4A26604CFB0028CB91 /* URLLauncherTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = URLLauncherTests.m; sourceTree = ""; }; F7151F4C26604CFB0028CB91 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; F7151F5626604D060028CB91 /* RunnerUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; F7151F5826604D060028CB91 /* URLLauncherUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = URLLauncherUITests.m; sourceTree = ""; }; @@ -187,8 +187,8 @@ F7151F4926604CFB0028CB91 /* RunnerTests */ = { isa = PBXGroup; children = ( - F7151F4A26604CFB0028CB91 /* URLLauncherTests.m */, F7151F4C26604CFB0028CB91 /* Info.plist */, + 41EB1F8A29937B550044D319 /* URLLauncherTests.swift */, ); path = RunnerTests; sourceTree = ""; @@ -278,6 +278,7 @@ }; F7151F4726604CFB0028CB91 = { CreatedOnToolsVersion = 12.5; + LastSwiftMigration = 1420; ProvisioningStyle = Automatic; TestTargetID = 97C146ED1CF9000F007C117D; }; @@ -425,7 +426,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - F7151F4B26604CFB0028CB91 /* URLLauncherTests.m in Sources */, + 41EB1F8B29937B550044D319 /* URLLauncherTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -589,7 +590,10 @@ "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", @@ -610,7 +614,10 @@ "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", @@ -625,12 +632,19 @@ baseConfigurationReference = 666BCD7C181C34F8BE58929B /* Pods-RunnerTests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_ENABLE_MODULES = YES; CODE_SIGN_STYLE = Automatic; INFOPLIST_FILE = RunnerTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/Runner"; }; name = Debug; @@ -640,12 +654,18 @@ baseConfigurationReference = D25C434271ACF6555E002440 /* Pods-RunnerTests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_ENABLE_MODULES = YES; CODE_SIGN_STYLE = Automatic; INFOPLIST_FILE = RunnerTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/Runner"; }; name = Release; @@ -655,7 +675,11 @@ buildSettings = { CODE_SIGN_STYLE = Automatic; INFOPLIST_FILE = RunnerUITests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.RunnerUITests; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -668,7 +692,11 @@ buildSettings = { CODE_SIGN_STYLE = Automatic; INFOPLIST_FILE = RunnerUITests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.RunnerUITests; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/packages/url_launcher/url_launcher_ios/example/ios/RunnerTests/URLLauncherTests.m b/packages/url_launcher/url_launcher_ios/example/ios/RunnerTests/URLLauncherTests.m deleted file mode 100644 index 6507a95a9d07..000000000000 --- a/packages/url_launcher/url_launcher_ios/example/ios/RunnerTests/URLLauncherTests.m +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -@import url_launcher_ios; -@import XCTest; - -@interface URLLauncherTests : XCTestCase -@end - -@implementation URLLauncherTests - -- (void)testPlugin { - FLTURLLauncherPlugin *plugin = [[FLTURLLauncherPlugin alloc] init]; - XCTAssertNotNil(plugin); -} - -@end diff --git a/packages/url_launcher/url_launcher_ios/example/ios/RunnerTests/URLLauncherTests.swift b/packages/url_launcher/url_launcher_ios/example/ios/RunnerTests/URLLauncherTests.swift new file mode 100644 index 000000000000..d6862b3fbefb --- /dev/null +++ b/packages/url_launcher/url_launcher_ios/example/ios/RunnerTests/URLLauncherTests.swift @@ -0,0 +1,121 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import Foundation +import XCTest +import Flutter + +@testable import url_launcher_ios + +class URLLauncherTests: XCTestCase { + override func setUp() { + self.continueAfterFailure = false + } + + func testCreatePlugin() { + let plugin = FLTURLLauncherPlugin() + XCTAssertNotNil(plugin) + } + + func testHandleMethodCall_canLaunch() { + let plugin = FLTURLLauncherPlugin() + + let testCases = [[ + "url": "https://www.flutter.dev", + "expected": true + ], [ + "url": "invalidURL", + "expected": false + ]] + + for testCase in testCases { + let call = FlutterMethodCall(methodName: "canLaunch", arguments: ["url": testCase["url"]]) + let resultExpectation = expectation(description: "result block must be called.") + + plugin.handle(call) { result in + XCTAssertEqual( + result as? Bool, Optional(testCase["expected"]! as! Bool), + "result of canLaunch was not as expected") + resultExpectation.fulfill() + } + + waitForExpectations(timeout: 5) + } + } + + func testHandleMethodCall_launch() { + let plugin = FLTURLLauncherPlugin() + let call = FlutterMethodCall(methodName: "launch", arguments: ["url": "https://flutter.dev"]) + let resultExpectation = expectation(description: "result block must be called.") + + plugin.handle(call) { result in + XCTAssertEqual( + result as? Bool, Optional(true), + "result block should be called with true on successful launch") + resultExpectation.fulfill() + } + + waitForExpectations(timeout: 5) + } + + func testHandleMethodCall_launchInVC() { + let plugin = FLTURLLauncherPlugin() + let call = FlutterMethodCall(methodName: "launch", arguments: ["url": "https://flutter.dev", "useSafariVC": true]) + let resultExpectation = expectation(description: "result block must be called.") + + plugin.handle(call) { result in + XCTAssertEqual( + result as? Bool, Optional(true), + "result block should be called with true on successful launch") + resultExpectation.fulfill() + } + + waitForExpectations(timeout: 5) + } + + func testHandleMethodCall_closeWebView() { + let plugin = FLTURLLauncherPlugin() + + // launch webview in separate VC + var call = FlutterMethodCall(methodName: "launch", arguments: ["url": "https://flutter.dev", "useSafariVC": true]) + var resultExpectation = expectation(description: "result block must be called.") + + plugin.handle(call) { result in + XCTAssertEqual( + result as? Bool, Optional(true), + "result block should be called with true on successful launch") + resultExpectation.fulfill() + } + + waitForExpectations(timeout: 5) + + // close webview + call = FlutterMethodCall(methodName: "close", arguments: nil) + resultExpectation = expectation(description: "result block must be called.") + + plugin.handle(call) { result in + XCTAssertEqual( + result as? Bool, nil, + "result block should be called with nil on close") + resultExpectation.fulfill() + } + + waitForExpectations(timeout: 5) + } + + func testHandleMethodCall_nonExistentMethod() { + let plugin = FLTURLLauncherPlugin() + let call = FlutterMethodCall(methodName: "nonExistent", arguments: nil) + let resultExpectation = expectation(description: "result block must be called.") + + plugin.handle(call) { result in + XCTAssertEqual( + result as? NSObject, FlutterMethodNotImplemented, + "result block must be called with FlutterMethodNotImplemented") + resultExpectation.fulfill() + } + + waitForExpectations(timeout: 5) + } +} From 7a4093e2cdc60b8c29d44f9e3ee884d6ed5a2329 Mon Sep 17 00:00:00 2001 From: Andres Gutierrez Date: Tue, 7 Feb 2023 22:58:35 -0800 Subject: [PATCH 2/3] swift-format --- .../ios/RunnerTests/URLLauncherTests.swift | 189 +++++++++--------- 1 file changed, 97 insertions(+), 92 deletions(-) diff --git a/packages/url_launcher/url_launcher_ios/example/ios/RunnerTests/URLLauncherTests.swift b/packages/url_launcher/url_launcher_ios/example/ios/RunnerTests/URLLauncherTests.swift index d6862b3fbefb..c0ff60f74b07 100644 --- a/packages/url_launcher/url_launcher_ios/example/ios/RunnerTests/URLLauncherTests.swift +++ b/packages/url_launcher/url_launcher_ios/example/ios/RunnerTests/URLLauncherTests.swift @@ -2,120 +2,125 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import Flutter import Foundation import XCTest -import Flutter @testable import url_launcher_ios class URLLauncherTests: XCTestCase { - override func setUp() { - self.continueAfterFailure = false - } - - func testCreatePlugin() { - let plugin = FLTURLLauncherPlugin() - XCTAssertNotNil(plugin) + override func setUp() { + self.continueAfterFailure = false + } + + func testCreatePlugin() { + let plugin = FLTURLLauncherPlugin() + XCTAssertNotNil(plugin) + } + + func testHandleMethodCall_canLaunch() { + let plugin = FLTURLLauncherPlugin() + + let testCases = [ + [ + "url": "https://www.flutter.dev", + "expected": true, + ], + [ + "url": "invalidURL", + "expected": false, + ], + ] + + for testCase in testCases { + let call = FlutterMethodCall(methodName: "canLaunch", arguments: ["url": testCase["url"]]) + let resultExpectation = expectation(description: "result block must be called.") + + plugin.handle(call) { result in + XCTAssertEqual( + result as? Bool, Optional(testCase["expected"]! as! Bool), + "result of canLaunch was not as expected") + resultExpectation.fulfill() + } + + waitForExpectations(timeout: 5) } - - func testHandleMethodCall_canLaunch() { - let plugin = FLTURLLauncherPlugin() - - let testCases = [[ - "url": "https://www.flutter.dev", - "expected": true - ], [ - "url": "invalidURL", - "expected": false - ]] - - for testCase in testCases { - let call = FlutterMethodCall(methodName: "canLaunch", arguments: ["url": testCase["url"]]) - let resultExpectation = expectation(description: "result block must be called.") - - plugin.handle(call) { result in - XCTAssertEqual( - result as? Bool, Optional(testCase["expected"]! as! Bool), - "result of canLaunch was not as expected") - resultExpectation.fulfill() - } - - waitForExpectations(timeout: 5) - } + } + + func testHandleMethodCall_launch() { + let plugin = FLTURLLauncherPlugin() + let call = FlutterMethodCall(methodName: "launch", arguments: ["url": "https://flutter.dev"]) + let resultExpectation = expectation(description: "result block must be called.") + + plugin.handle(call) { result in + XCTAssertEqual( + result as? Bool, Optional(true), + "result block should be called with true on successful launch") + resultExpectation.fulfill() } - func testHandleMethodCall_launch() { - let plugin = FLTURLLauncherPlugin() - let call = FlutterMethodCall(methodName: "launch", arguments: ["url": "https://flutter.dev"]) - let resultExpectation = expectation(description: "result block must be called.") + waitForExpectations(timeout: 5) + } - plugin.handle(call) { result in - XCTAssertEqual( - result as? Bool, Optional(true), - "result block should be called with true on successful launch") - resultExpectation.fulfill() - } + func testHandleMethodCall_launchInVC() { + let plugin = FLTURLLauncherPlugin() + let call = FlutterMethodCall( + methodName: "launch", arguments: ["url": "https://flutter.dev", "useSafariVC": true]) + let resultExpectation = expectation(description: "result block must be called.") - waitForExpectations(timeout: 5) + plugin.handle(call) { result in + XCTAssertEqual( + result as? Bool, Optional(true), + "result block should be called with true on successful launch") + resultExpectation.fulfill() } - func testHandleMethodCall_launchInVC() { - let plugin = FLTURLLauncherPlugin() - let call = FlutterMethodCall(methodName: "launch", arguments: ["url": "https://flutter.dev", "useSafariVC": true]) - let resultExpectation = expectation(description: "result block must be called.") + waitForExpectations(timeout: 5) + } - plugin.handle(call) { result in - XCTAssertEqual( - result as? Bool, Optional(true), - "result block should be called with true on successful launch") - resultExpectation.fulfill() - } + func testHandleMethodCall_closeWebView() { + let plugin = FLTURLLauncherPlugin() - waitForExpectations(timeout: 5) - } + // launch webview in separate VC + var call = FlutterMethodCall( + methodName: "launch", arguments: ["url": "https://flutter.dev", "useSafariVC": true]) + var resultExpectation = expectation(description: "result block must be called.") - func testHandleMethodCall_closeWebView() { - let plugin = FLTURLLauncherPlugin() - - // launch webview in separate VC - var call = FlutterMethodCall(methodName: "launch", arguments: ["url": "https://flutter.dev", "useSafariVC": true]) - var resultExpectation = expectation(description: "result block must be called.") - - plugin.handle(call) { result in - XCTAssertEqual( - result as? Bool, Optional(true), - "result block should be called with true on successful launch") - resultExpectation.fulfill() - } - - waitForExpectations(timeout: 5) + plugin.handle(call) { result in + XCTAssertEqual( + result as? Bool, Optional(true), + "result block should be called with true on successful launch") + resultExpectation.fulfill() + } - // close webview - call = FlutterMethodCall(methodName: "close", arguments: nil) - resultExpectation = expectation(description: "result block must be called.") + waitForExpectations(timeout: 5) - plugin.handle(call) { result in - XCTAssertEqual( - result as? Bool, nil, - "result block should be called with nil on close") - resultExpectation.fulfill() - } + // close webview + call = FlutterMethodCall(methodName: "close", arguments: nil) + resultExpectation = expectation(description: "result block must be called.") - waitForExpectations(timeout: 5) + plugin.handle(call) { result in + XCTAssertEqual( + result as? Bool, nil, + "result block should be called with nil on close") + resultExpectation.fulfill() } - func testHandleMethodCall_nonExistentMethod() { - let plugin = FLTURLLauncherPlugin() - let call = FlutterMethodCall(methodName: "nonExistent", arguments: nil) - let resultExpectation = expectation(description: "result block must be called.") + waitForExpectations(timeout: 5) + } - plugin.handle(call) { result in - XCTAssertEqual( - result as? NSObject, FlutterMethodNotImplemented, - "result block must be called with FlutterMethodNotImplemented") - resultExpectation.fulfill() - } + func testHandleMethodCall_nonExistentMethod() { + let plugin = FLTURLLauncherPlugin() + let call = FlutterMethodCall(methodName: "nonExistent", arguments: nil) + let resultExpectation = expectation(description: "result block must be called.") - waitForExpectations(timeout: 5) + plugin.handle(call) { result in + XCTAssertEqual( + result as? NSObject, FlutterMethodNotImplemented, + "result block must be called with FlutterMethodNotImplemented") + resultExpectation.fulfill() } + + waitForExpectations(timeout: 5) + } } From 3e0d790484988bf48e511ec02ae51bd6c82cca61 Mon Sep 17 00:00:00 2001 From: Andres Gutierrez Date: Tue, 7 Feb 2023 23:13:00 -0800 Subject: [PATCH 3/3] lengthen expect time --- .../example/ios/RunnerTests/URLLauncherTests.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/url_launcher/url_launcher_ios/example/ios/RunnerTests/URLLauncherTests.swift b/packages/url_launcher/url_launcher_ios/example/ios/RunnerTests/URLLauncherTests.swift index c0ff60f74b07..9f93d8fb3fec 100644 --- a/packages/url_launcher/url_launcher_ios/example/ios/RunnerTests/URLLauncherTests.swift +++ b/packages/url_launcher/url_launcher_ios/example/ios/RunnerTests/URLLauncherTests.swift @@ -43,7 +43,7 @@ class URLLauncherTests: XCTestCase { resultExpectation.fulfill() } - waitForExpectations(timeout: 5) + waitForExpectations(timeout: 30) } } @@ -59,7 +59,7 @@ class URLLauncherTests: XCTestCase { resultExpectation.fulfill() } - waitForExpectations(timeout: 5) + waitForExpectations(timeout: 30) } func testHandleMethodCall_launchInVC() { @@ -75,7 +75,7 @@ class URLLauncherTests: XCTestCase { resultExpectation.fulfill() } - waitForExpectations(timeout: 5) + waitForExpectations(timeout: 30) } func testHandleMethodCall_closeWebView() { @@ -93,7 +93,7 @@ class URLLauncherTests: XCTestCase { resultExpectation.fulfill() } - waitForExpectations(timeout: 5) + waitForExpectations(timeout: 30) // close webview call = FlutterMethodCall(methodName: "close", arguments: nil) @@ -106,7 +106,7 @@ class URLLauncherTests: XCTestCase { resultExpectation.fulfill() } - waitForExpectations(timeout: 5) + waitForExpectations(timeout: 30) } func testHandleMethodCall_nonExistentMethod() { @@ -121,6 +121,6 @@ class URLLauncherTests: XCTestCase { resultExpectation.fulfill() } - waitForExpectations(timeout: 5) + waitForExpectations(timeout: 30) } }