Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions packages/url_launcher/url_launcher_ios/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 6.1.1

* Migrates iOS plugin to Swift.

## 6.1.0

* Updates minimum Flutter version to 3.3 and iOS 11.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
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 */; };
412154C429928BD30070F8F7 /* URLLauncherTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 412154C329928BD30070F8F7 /* URLLauncherTests.swift */; };
412154C629928CE50070F8F7 /* URLLauncherUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 412154C529928CE50070F8F7 /* URLLauncherUITests.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 */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -54,6 +54,8 @@
2D92223D1EC1DA93007564B0 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GeneratedPluginRegistrant.h; path = Runner/GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
2D92223E1EC1DA93007564B0 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GeneratedPluginRegistrant.m; path = Runner/GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
412154C329928BD30070F8F7 /* URLLauncherTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLLauncherTests.swift; sourceTree = "<group>"; };
412154C529928CE50070F8F7 /* URLLauncherUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLLauncherUITests.swift; sourceTree = "<group>"; };
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 = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
Expand All @@ -72,10 +74,8 @@
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 = "<group>"; };
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 = "<group>"; };
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 = "<group>"; };
F7151F4C26604CFB0028CB91 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
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 = "<group>"; };
F7151F5A26604D060028CB91 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -187,17 +187,17 @@
F7151F4926604CFB0028CB91 /* RunnerTests */ = {
isa = PBXGroup;
children = (
F7151F4A26604CFB0028CB91 /* URLLauncherTests.m */,
F7151F4C26604CFB0028CB91 /* Info.plist */,
412154C329928BD30070F8F7 /* URLLauncherTests.swift */,
);
path = RunnerTests;
sourceTree = "<group>";
};
F7151F5726604D060028CB91 /* RunnerUITests */ = {
isa = PBXGroup;
children = (
F7151F5826604D060028CB91 /* URLLauncherUITests.m */,
F7151F5A26604D060028CB91 /* Info.plist */,
412154C529928CE50070F8F7 /* URLLauncherUITests.swift */,
);
path = RunnerUITests;
sourceTree = "<group>";
Expand Down Expand Up @@ -278,11 +278,13 @@
};
F7151F4726604CFB0028CB91 = {
CreatedOnToolsVersion = 12.5;
LastSwiftMigration = 1420;
ProvisioningStyle = Automatic;
TestTargetID = 97C146ED1CF9000F007C117D;
};
F7151F5526604D060028CB91 = {
CreatedOnToolsVersion = 12.5;
LastSwiftMigration = 1420;
ProvisioningStyle = Automatic;
TestTargetID = 97C146ED1CF9000F007C117D;
};
Expand Down Expand Up @@ -425,15 +427,15 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F7151F4B26604CFB0028CB91 /* URLLauncherTests.m in Sources */,
412154C429928BD30070F8F7 /* URLLauncherTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
F7151F5226604D060028CB91 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F7151F5926604D060028CB91 /* URLLauncherUITests.m in Sources */,
412154C629928CE50070F8F7 /* URLLauncherUITests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -589,7 +591,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",
Expand All @@ -610,7 +615,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",
Expand All @@ -625,12 +633,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;
Expand All @@ -640,38 +655,57 @@
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;
};
F7151F5E26604D060028CB91 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
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)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TEST_TARGET_NAME = Runner;
};
name = Debug;
};
F7151F5F26604D060028CB91 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
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)";
SWIFT_VERSION = 5.0;
TEST_TARGET_NAME = Runner;
};
name = Release;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
// 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 = URLLauncherPlugin()
XCTAssertNotNil(plugin)
}

func testHandleMethodCall_canLaunch() {
let plugin = URLLauncherPlugin()

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 the expected result")
resultExpectation.fulfill()
}

waitForExpectations(timeout: 1)
}
}

func testHandleMethodCall_launch() {
let plugin = URLLauncherPlugin()
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()

XCTAssertNil(plugin.currentSession)
}

waitForExpectations(timeout: 1)
}

func testHandleMethodCall_launchInVC() {
let plugin = URLLauncherPlugin()
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()

XCTAssertNotNil(plugin.currentSession?.safari)
XCTAssertTrue(plugin.currentSession?.safari.isViewLoaded ?? false)
}

waitForExpectations(timeout: 1)
}

func testHandleMethodCall_closeWebView() {
let plugin = URLLauncherPlugin()

// 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()

XCTAssertNotNil(plugin.currentSession?.safari)
}

waitForExpectations(timeout: 1)

// 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()

// test should pass if the safari VC is being dismissed or the
// currentSession has already been updated to nil
XCTAssertFalse(plugin.currentSession?.safari.isBeingDismissed ?? false)
}

waitForExpectations(timeout: 1)
}

func testHandleMethodCall_nonExistentMethod() {
let plugin = URLLauncherPlugin()
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: 1)
}
}

This file was deleted.

Loading