Skip to content

Commit 705b476

Browse files
committed
Migrate from XCTest to Swift Testing
1 parent 1b4dc30 commit 705b476

File tree

7 files changed

+303
-247
lines changed

7 files changed

+303
-247
lines changed

Example/Example.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@
435435
"$(inherited)",
436436
"@executable_path/../Frameworks",
437437
);
438+
MACOSX_DEPLOYMENT_TARGET = 11.0;
438439
PRODUCT_BUNDLE_IDENTIFIER = "com.clipy-app.Example";
439440
PRODUCT_NAME = "$(TARGET_NAME)";
440441
SWIFT_VERSION = 5.0;
@@ -455,6 +456,7 @@
455456
"$(inherited)",
456457
"@executable_path/../Frameworks",
457458
);
459+
MACOSX_DEPLOYMENT_TARGET = 11.0;
458460
PRODUCT_BUNDLE_IDENTIFIER = "com.clipy-app.Example";
459461
PRODUCT_NAME = "$(TARGET_NAME)";
460462
SWIFT_VERSION = 5.0;

Lib/Sauce.xcodeproj/project.pbxproj

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
09CDC68A210F044A007DDFE4 /* TISInputSource+Property.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09CDC689210F044A007DDFE4 /* TISInputSource+Property.swift */; };
1313
50582477261C6F1F00AD2DD8 /* NSMenuItem+Key.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50582476261C6F1F00AD2DD8 /* NSMenuItem+Key.swift */; };
1414
5058247B261C6FA400AD2DD8 /* NSMenuItem+KeyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5058247A261C6FA400AD2DD8 /* NSMenuItem+KeyTests.swift */; };
15+
C57C16682F06CE9B00507D0B /* InputSourceTrait.swift in Sources */ = {isa = PBXBuildFile; fileRef = C57C16672F06CE7A00507D0B /* InputSourceTrait.swift */; };
16+
C57C166B2F06D20B00507D0B /* InputSource+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C57C166A2F06D1FB00507D0B /* InputSource+Extensions.swift */; };
1517
C5FADB892D32779F00F038E3 /* KeyModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5FADB882D32779B00F038E3 /* KeyModifier.swift */; };
1618
FA1E407621107B0A0016D710 /* SpecialKeyCode.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA1E407521107B0A0016D710 /* SpecialKeyCode.swift */; };
1719
FAA4132A210E2C730097D522 /* Sauce.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAA41320210E2C730097D522 /* Sauce.framework */; };
@@ -38,6 +40,8 @@
3840
09CDC689210F044A007DDFE4 /* TISInputSource+Property.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TISInputSource+Property.swift"; sourceTree = "<group>"; };
3941
50582476261C6F1F00AD2DD8 /* NSMenuItem+Key.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSMenuItem+Key.swift"; sourceTree = "<group>"; };
4042
5058247A261C6FA400AD2DD8 /* NSMenuItem+KeyTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSMenuItem+KeyTests.swift"; sourceTree = "<group>"; };
43+
C57C16672F06CE7A00507D0B /* InputSourceTrait.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputSourceTrait.swift; sourceTree = "<group>"; };
44+
C57C166A2F06D1FB00507D0B /* InputSource+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "InputSource+Extensions.swift"; sourceTree = "<group>"; };
4145
C5FADB882D32779B00F038E3 /* KeyModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyModifier.swift; sourceTree = "<group>"; };
4246
FA1E407521107B0A0016D710 /* SpecialKeyCode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpecialKeyCode.swift; sourceTree = "<group>"; };
4347
FAA41320210E2C730097D522 /* Sauce.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Sauce.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -70,6 +74,22 @@
7074
/* End PBXFrameworksBuildPhase section */
7175

7276
/* Begin PBXGroup section */
77+
C57C16662F06CE7700507D0B /* Traits */ = {
78+
isa = PBXGroup;
79+
children = (
80+
C57C16672F06CE7A00507D0B /* InputSourceTrait.swift */,
81+
);
82+
path = Traits;
83+
sourceTree = "<group>";
84+
};
85+
C57C16692F06D1D300507D0B /* Extensions */ = {
86+
isa = PBXGroup;
87+
children = (
88+
C57C166A2F06D1FB00507D0B /* InputSource+Extensions.swift */,
89+
);
90+
path = Extensions;
91+
sourceTree = "<group>";
92+
};
7393
C5FADB8C2D335E1300F038E3 /* Internal */ = {
7494
isa = PBXGroup;
7595
children = (
@@ -117,6 +137,8 @@
117137
FAA4132D210E2C730097D522 /* SauceTests */ = {
118138
isa = PBXGroup;
119139
children = (
140+
C57C16692F06D1D300507D0B /* Extensions */,
141+
C57C16662F06CE7700507D0B /* Traits */,
120142
0909EBCF245D5C9E00ABA339 /* KeyboardLayoutTests.swift */,
121143
5058247A261C6FA400AD2DD8 /* NSMenuItem+KeyTests.swift */,
122144
FAA41330210E2C730097D522 /* Info.plist */,
@@ -250,6 +272,8 @@
250272
isa = PBXSourcesBuildPhase;
251273
buildActionMask = 2147483647;
252274
files = (
275+
C57C16682F06CE9B00507D0B /* InputSourceTrait.swift in Sources */,
276+
C57C166B2F06D20B00507D0B /* InputSource+Extensions.swift in Sources */,
253277
5058247B261C6FA400AD2DD8 /* NSMenuItem+KeyTests.swift in Sources */,
254278
0909EBD0245D5C9E00ABA339 /* KeyboardLayoutTests.swift in Sources */,
255279
);
@@ -406,6 +430,7 @@
406430
"@executable_path/../Frameworks",
407431
"@loader_path/Frameworks",
408432
);
433+
MACOSX_DEPLOYMENT_TARGET = 11.0;
409434
MARKETING_VERSION = 2.4.1;
410435
PRODUCT_BUNDLE_IDENTIFIER = "com.clipy-app.Sauce";
411436
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
@@ -434,6 +459,7 @@
434459
"@executable_path/../Frameworks",
435460
"@loader_path/Frameworks",
436461
);
462+
MACOSX_DEPLOYMENT_TARGET = 11.0;
437463
MARKETING_VERSION = 2.4.1;
438464
PRODUCT_BUNDLE_IDENTIFIER = "com.clipy-app.Sauce";
439465
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
@@ -454,6 +480,7 @@
454480
"@executable_path/../Frameworks",
455481
"@loader_path/../Frameworks",
456482
);
483+
MACOSX_DEPLOYMENT_TARGET = 11.0;
457484
PRODUCT_BUNDLE_IDENTIFIER = "com.clipy-app.SauceTests";
458485
PRODUCT_NAME = "$(TARGET_NAME)";
459486
SWIFT_VERSION = 5.0;
@@ -472,6 +499,7 @@
472499
"@executable_path/../Frameworks",
473500
"@loader_path/../Frameworks",
474501
);
502+
MACOSX_DEPLOYMENT_TARGET = 11.0;
475503
PRODUCT_BUNDLE_IDENTIFIER = "com.clipy-app.SauceTests";
476504
PRODUCT_NAME = "$(TARGET_NAME)";
477505
SWIFT_VERSION = 5.0;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import Carbon
2+
@testable import Sauce
3+
4+
extension InputSource {
5+
static var enabledInputSources: [InputSource] {
6+
let sourceList = TISCreateInputSourceList([:] as CFDictionary, false)
7+
.takeUnretainedValue() as? [TISInputSource]
8+
return sourceList?.map { InputSource(source: $0) } ?? []
9+
}
10+
11+
static var allInputSources: [InputSource] {
12+
let sourceList = TISCreateInputSourceList([:] as CFDictionary, true)
13+
.takeUnretainedValue() as? [TISInputSource]
14+
return sourceList?.map { InputSource(source: $0) } ?? []
15+
}
16+
17+
func enable() -> Bool {
18+
TISEnableInputSource(source) == noErr
19+
}
20+
21+
@discardableResult
22+
func disable() -> Bool {
23+
TISDisableInputSource(source) == noErr
24+
}
25+
26+
@discardableResult
27+
func select() -> Bool {
28+
TISSelectInputSource(source) == noErr
29+
}
30+
}

0 commit comments

Comments
 (0)