Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
1d5609f
converting url_launcher from objc to swift
chrisdlangham Aug 18, 2023
d5727dd
converting tests to swift
chrisdlangham Aug 22, 2023
c4e55fb
converting tests to swift
chrisdlangham Aug 22, 2023
050d6b3
fixing issue where pigeon and method channels were not setup right
chrisdlangham Aug 22, 2023
5278199
formatting
chrisdlangham Aug 22, 2023
55a345b
reverting unintentional local changes
chrisdlangham Aug 22, 2023
8356d7a
fixing issues with Ui tests
chrisdlangham Aug 22, 2023
120b2d4
formating
chrisdlangham Aug 22, 2023
1316f3c
Merge branch 'main' into coverting-objc-to-swift
chrisdlangham Aug 22, 2023
7bd3553
updating version and change log
chrisdlangham Aug 22, 2023
2741de4
converting tests to swift
chrisdlangham Aug 22, 2023
495de26
converting unit tests to swift
chrisdlangham Aug 23, 2023
c898698
Merge branch 'main' into converting-url-launcher-ios-tests-to-swift
chrisdlangham Aug 23, 2023
6a6c8d5
updating change log
chrisdlangham Aug 23, 2023
254b9af
resolving merge conflicts
chrisdlangham Aug 23, 2023
869f18f
formatting
chrisdlangham Aug 23, 2023
1120baa
making test class final and private
chrisdlangham Aug 29, 2023
1429244
adding example app for platform
chrisdlangham Sep 2, 2023
a4a6683
formatting and addressing linting errors
chrisdlangham Sep 2, 2023
30a95d5
updating version and change log
chrisdlangham Sep 2, 2023
52623eb
Merge branch 'main' into platform-example-app
chrisdlangham Sep 12, 2023
8a6442d
cleaning up example pubspec
chrisdlangham Sep 12, 2023
2f05893
renaming org in example app and removing web
chrisdlangham Sep 12, 2023
167353a
updating change log
chrisdlangham Sep 12, 2023
8152b72
adds comments
chrisdlangham Sep 12, 2023
dc4de8a
addresses validation steps
chrisdlangham Sep 12, 2023
0c1651e
adds platform example android app to dependabot
chrisdlangham Sep 13, 2023
9f591e3
resolving merge conflicts
chrisdlangham Sep 13, 2023
13cd002
updated tests and formated pigeon file
chrisdlangham Sep 13, 2023
7e486d7
updates test name
chrisdlangham Sep 13, 2023
f8f5f0b
updates changelog
chrisdlangham Sep 13, 2023
827204a
Update CHANGELOG.md
chrisdlangham Sep 14, 2023
30568fd
Merge branch 'main' into coverting-objc-to-swift
chrisdlangham Sep 14, 2023
2360fc7
Merge branch 'main' into platform-example-app
chrisdlangham Sep 14, 2023
d320c35
deletes unknown file
chrisdlangham Sep 14, 2023
6b5e4cd
uses latest version of pigeon
chrisdlangham Sep 15, 2023
3651a97
updates change log
chrisdlangham Sep 15, 2023
257b7cc
moves setting up the pigeon api to the register function instead of t…
chrisdlangham Sep 15, 2023
3a1190e
Merge branch 'coverting-objc-to-swift' into platform-example-app
chrisdlangham Sep 28, 2023
1fb2d10
Revert "Merge branch 'coverting-objc-to-swift' into platform-example-…
chrisdlangham Sep 28, 2023
f71e763
Merge branch 'main' into platform-example-app
chrisdlangham Sep 28, 2023
7b0e411
attempt to fix linux web tests
chrisdlangham Sep 30, 2023
6f86e64
cleans up comments and boilerplate code
chrisdlangham Sep 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
converting tests to swift
  • Loading branch information
chrisdlangham committed Aug 22, 2023
commit 2741de42e3447fd6cd7cdc124c099059a2949131
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
1D9FF3342A90170000F89C85 /* URLLauncherTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D9FF3332A90170000F89C85 /* URLLauncherTests.swift */; };
1DBE6EDE2A92479000B6525C /* URLLauncherUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1DBE6EDD2A92479000B6525C /* URLLauncherUITests.swift */; };
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 */; };
Expand All @@ -16,8 +18,6 @@
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 @@ -51,6 +51,8 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
1D9FF3332A90170000F89C85 /* URLLauncherTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLLauncherTests.swift; sourceTree = "<group>"; };
1DBE6EDD2A92479000B6525C /* URLLauncherUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLLauncherUITests.swift; sourceTree = "<group>"; };
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>"; };
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 */,
1D9FF3332A90170000F89C85 /* URLLauncherTests.swift */,
);
path = RunnerTests;
sourceTree = "<group>";
};
F7151F5726604D060028CB91 /* RunnerUITests */ = {
isa = PBXGroup;
children = (
F7151F5826604D060028CB91 /* URLLauncherUITests.m */,
F7151F5A26604D060028CB91 /* Info.plist */,
1DBE6EDD2A92479000B6525C /* URLLauncherUITests.swift */,
);
path = RunnerUITests;
sourceTree = "<group>";
Expand Down Expand Up @@ -351,7 +351,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin\n";
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
Expand All @@ -366,7 +366,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build\n";
};
AB1344B0443C71CD721E1BB7 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
Expand Down Expand Up @@ -425,15 +425,15 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F7151F4B26604CFB0028CB91 /* URLLauncherTests.m in Sources */,
1D9FF3342A90170000F89C85 /* URLLauncherTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
F7151F5226604D060028CB91 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F7151F5926604D060028CB91 /* URLLauncherUITests.m in Sources */,
1DBE6EDE2A92479000B6525C /* URLLauncherUITests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
// 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 Flutter
import XCTest

@testable import url_launcher_ios

class URLLauncherTests: XCTestCase {
var plugin: URLLauncherPlugin!
var launcher: FakeLauncher!

override func setUp() {
launcher = FakeLauncher()
plugin = URLLauncherPlugin(launcher: launcher, binaryMessenger: FakeFlutterBinaryMessenger())
}

func testCanLaunchSuccess() {
let result = plugin.canLaunchUrl(url: "good://url")

XCTAssertTrue(result)
}

func testCanLaunchFailure() {
let result = plugin.canLaunchUrl(url: "bad://url")

XCTAssertFalse(result)
}

func testCanLaunchFailureWithInvalidURL() {
let result = plugin.canLaunchUrl(url: "urls can't have spaces")

XCTAssertFalse(result)
}

func testLaunchSuccess() {
let expectation = XCTestExpectation(description: "completion called")
plugin.launchUrl(url: "good://url", universalLinksOnly: false) { result in
switch result {
case .success(let success):
XCTAssertTrue(success)
case .failure(let error):
XCTFail("Unexpected error: \(error)")
}
expectation.fulfill()
}

wait(for: [expectation], timeout: 1)
}

func testLaunchFailure() {
let expectation = XCTestExpectation(description: "completion called")
plugin.launchUrl(url: "bad://url", universalLinksOnly: false) { result in
switch result {
case .success(let success):
XCTAssertFalse(success)
case .failure(let error):
XCTFail("Unexpected error: \(error)")
}
expectation.fulfill()
}

wait(for: [expectation], timeout: 1)
}

func testLaunchFailureWithInvalidURL() {
let expectation = XCTestExpectation(description: "completion called")
plugin.launchUrl(url: "urls can't have spaces", universalLinksOnly: false) { result in
switch result {
case .success(_):
XCTFail("Expected an error")
case .failure(let error):
let generalError = error as! GeneralError
XCTAssertEqual(generalError.code, "argument_error")
XCTAssertEqual(generalError.message, "Unable to parse URL")
XCTAssertEqual(generalError.details, "Provided URL: urls can't have spaces")
}
expectation.fulfill()
}

wait(for: [expectation], timeout: 1)
}

func testLaunchWithoutUniversalLinks() {
let expectation = XCTestExpectation(description: "completion called")
plugin.launchUrl(url: "good://url", universalLinksOnly: false) { result in
switch result {
case .success(let success):
XCTAssertTrue(success)
case .failure(let error):
XCTFail("Unexpected error: \(error)")
}
expectation.fulfill()
}

wait(for: [expectation], timeout: 1)
XCTAssertEqual(launcher.passedOptions?[.universalLinksOnly] as? Bool, false)
}

func testLaunchWithUniversalLinks() {
let expectation = XCTestExpectation(description: "completion called")
plugin.launchUrl(url: "good://url", universalLinksOnly: true) { result in
switch result {
case .success(let success):
XCTAssertTrue(success)
case .failure(let error):
XCTFail("Unexpected error: \(error)")
}
expectation.fulfill()
}

wait(for: [expectation], timeout: 1)
XCTAssertEqual(launcher.passedOptions?[.universalLinksOnly] as? Bool, true)
}

}

class FakeLauncher: Launcher {
var passedOptions: [UIApplication.OpenExternalURLOptionsKey: Any]?

func canOpenURL(_ url: URL) -> Bool {
return url.scheme == "good"
}

func openURL(_ url: URL, options: [UIApplication.OpenExternalURLOptionsKey: Any] = [:], completionHandler: ((Bool) -> Void)? = nil) {
self.passedOptions = options
completionHandler?(url.scheme == "good")
}
}

class FakeFlutterBinaryMessenger: NSObject, FlutterBinaryMessenger {
func send(onChannel channel: String, message: Data?) { }

func send(onChannel channel: String, message: Data?, binaryReply callback: FlutterBinaryReply? = nil) { }

func setMessageHandlerOnChannel(_ channel: String, binaryMessageHandler handler: FlutterBinaryMessageHandler? = nil) -> FlutterBinaryMessengerConnection {
123
}

func cleanUpConnection(_ connection: FlutterBinaryMessengerConnection) { }
}
Loading