Skip to content

Commit 1f31d7b

Browse files
BartlomiejWlodarczakcongt
authored andcommitted
Add basic SwiftUI typing screen and tests to the host app
1 parent b2b88da commit 1f31d7b

8 files changed

+260
-27
lines changed

KIF.xcodeproj/project.pbxproj

+16-8
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88

99
/* Begin PBXBuildFile section */
1010
06104D1C2D51473B0038697E /* SwiftUIViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06104D1B2D5147370038697E /* SwiftUIViewController.swift */; };
11-
06104D1F2D514E0C0038697E /* SwiftUIBasicView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06104D1E2D514E0C0038697E /* SwiftUIBasicView.swift */; };
11+
06104D1F2D514E0C0038697E /* SwiftUITappingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06104D1E2D514E0C0038697E /* SwiftUITappingView.swift */; };
1212
06104D212D5150D10038697E /* SwiftUIViewControllerFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06104D202D5150D00038697E /* SwiftUIViewControllerFactory.swift */; };
13-
06104D242D5156760038697E /* SwiftUIBasicTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 06104D232D5156690038697E /* SwiftUIBasicTests.m */; };
13+
06104D242D5156760038697E /* SwiftUITappingTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 06104D232D5156690038697E /* SwiftUITappingTests.m */; };
1414
06104D262D516FEB0038697E /* ViewModifiers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06104D252D516FE70038697E /* ViewModifiers.swift */; };
15+
064185B02D5ABADD00A33957 /* SwiftUITypingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 064185AF2D5ABADD00A33957 /* SwiftUITypingView.swift */; };
16+
064185B22D5ABF5E00A33957 /* SwiftUITypingTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 064185B12D5ABF5900A33957 /* SwiftUITypingTests.m */; };
1517
06A507622D5274B800F77047 /* UIView+KIFPrivateAPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 06A507612D5274B800F77047 /* UIView+KIFPrivateAPI.h */; };
1618
0E27A9EE1B45B53D00A6DE6E /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E9AD81F91AA180B900B369FD /* IOKit.framework */; };
1719
2229D59525BEF47D0093296C /* KIFUITestActor-IdentifierTests.h in Headers */ = {isa = PBXBuildFile; fileRef = 2229D53E25BEF47D0093296C /* KIFUITestActor-IdentifierTests.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -219,10 +221,12 @@
219221
/* Begin PBXFileReference section */
220222
06104D1B2D5147370038697E /* SwiftUIViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUIViewController.swift; sourceTree = "<group>"; };
221223
06104D1D2D51473D0038697E /* TestHost-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "TestHost-Bridging-Header.h"; sourceTree = "<group>"; };
222-
06104D1E2D514E0C0038697E /* SwiftUIBasicView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUIBasicView.swift; sourceTree = "<group>"; };
224+
06104D1E2D514E0C0038697E /* SwiftUITappingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUITappingView.swift; sourceTree = "<group>"; };
223225
06104D202D5150D00038697E /* SwiftUIViewControllerFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUIViewControllerFactory.swift; sourceTree = "<group>"; };
224-
06104D232D5156690038697E /* SwiftUIBasicTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SwiftUIBasicTests.m; sourceTree = "<group>"; };
226+
06104D232D5156690038697E /* SwiftUITappingTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SwiftUITappingTests.m; sourceTree = "<group>"; };
225227
06104D252D516FE70038697E /* ViewModifiers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewModifiers.swift; sourceTree = "<group>"; };
228+
064185AF2D5ABADD00A33957 /* SwiftUITypingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUITypingView.swift; sourceTree = "<group>"; };
229+
064185B12D5ABF5900A33957 /* SwiftUITypingTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SwiftUITypingTests.m; sourceTree = "<group>"; };
226230
06A507612D5274B800F77047 /* UIView+KIFPrivateAPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIView+KIFPrivateAPI.h"; sourceTree = "<group>"; };
227231
22191DFA24BF793F004CAA18 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainStoryboard.storyboard; sourceTree = "<group>"; };
228232
221FF9A2252231030058F471 /* TestPlan.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = TestPlan.xctestplan; sourceTree = "<group>"; };
@@ -466,16 +470,18 @@
466470
06104D1D2D51473D0038697E /* TestHost-Bridging-Header.h */,
467471
06104D202D5150D00038697E /* SwiftUIViewControllerFactory.swift */,
468472
06104D1B2D5147370038697E /* SwiftUIViewController.swift */,
469-
06104D1E2D514E0C0038697E /* SwiftUIBasicView.swift */,
473+
06104D1E2D514E0C0038697E /* SwiftUITappingView.swift */,
470474
06104D252D516FE70038697E /* ViewModifiers.swift */,
475+
064185AF2D5ABADD00A33957 /* SwiftUITypingView.swift */,
471476
);
472477
path = SwiftUI;
473478
sourceTree = "<group>";
474479
};
475480
06104D222D51565A0038697E /* SwiftUI Tests */ = {
476481
isa = PBXGroup;
477482
children = (
478-
06104D232D5156690038697E /* SwiftUIBasicTests.m */,
483+
064185B12D5ABF5900A33957 /* SwiftUITypingTests.m */,
484+
06104D232D5156690038697E /* SwiftUITappingTests.m */,
479485
);
480486
path = "SwiftUI Tests";
481487
sourceTree = "<group>";
@@ -1029,11 +1035,12 @@
10291035
files = (
10301036
FA8A3C591A771C5500206350 /* SearchFieldTests_ViewTestActor.m in Sources */,
10311037
FA8A3C551A77157F00206350 /* LongPressTests_ViewTestActor.m in Sources */,
1032-
06104D242D5156760038697E /* SwiftUIBasicTests.m in Sources */,
1038+
06104D242D5156760038697E /* SwiftUITappingTests.m in Sources */,
10331039
FA49155E1A78206E00A78E57 /* CompositionTests_ViewTestActor.m in Sources */,
10341040
FA8A3C5F1A772E6800206350 /* AccessibilityIdentifierTests_ViewTestActor.m in Sources */,
10351041
8E654FC429D79BD8007F7811 /* OffscreenTests_ViewTestActor.m in Sources */,
10361042
FA8A3C5D1A772CD100206350 /* WaitForAbscenceTests_ViewTestActor.m in Sources */,
1043+
064185B22D5ABF5E00A33957 /* SwiftUITypingTests.m in Sources */,
10371044
FA8A3C5B1A77281900206350 /* WebViewTests_ViewTestActor.m in Sources */,
10381045
EABD46B11857A0F300A5F081 /* SearchFieldTests.m in Sources */,
10391046
ACDB726A2CA314A800D9796E /* AccessibilityActivationTests_ViewTestActor.m in Sources */,
@@ -1101,12 +1108,13 @@
11011108
AE62FCD61A1D2447002B10DA /* WebViewController.m in Sources */,
11021109
EB60ECCD177F8C84005A041A /* main.m in Sources */,
11031110
EB60ED00177F9032005A041A /* AppDelegate.m in Sources */,
1104-
06104D1F2D514E0C0038697E /* SwiftUIBasicView.swift in Sources */,
1111+
06104D1F2D514E0C0038697E /* SwiftUITappingView.swift in Sources */,
11051112
D927B9DC18F9DF2D00DAD036 /* TableViewController.m in Sources */,
11061113
EB60ED01177F9032005A041A /* ShowHideViewController.m in Sources */,
11071114
CD19A99F1F46482200BF0325 /* CustomPickerController.m in Sources */,
11081115
EB60ED02177F9032005A041A /* TapViewController.m in Sources */,
11091116
2CDEE1CB181DBED200DF6E63 /* PickerController.m in Sources */,
1117+
064185B02D5ABADD00A33957 /* SwiftUITypingView.swift in Sources */,
11101118
06104D1C2D51473B0038697E /* SwiftUIViewController.swift in Sources */,
11111119
EB60ED03177F9032005A041A /* TestSuiteViewController.m in Sources */,
11121120
06104D262D516FEB0038697E /* ViewModifiers.swift in Sources */,

TestHost/Base.lproj/MainStoryboard.storyboard

+26-8
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,29 @@
356356
<rect key="frame" x="0.0" y="866" width="414" height="44"/>
357357
<autoresizingMask key="autoresizingMask"/>
358358
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="eKK-d9-FQU" id="Qd1-r3-SAP">
359-
<rect key="frame" x="0.0" y="0.0" width="395.5" height="44"/>
359+
<rect key="frame" x="0.0" y="0.0" width="383.5" height="44"/>
360+
<autoresizingMask key="autoresizingMask"/>
361+
<subviews>
362+
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" text="SwiftUI Tapping" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="O9S-7t-0EJ">
363+
<rect key="frame" x="20" y="0.0" width="355.5" height="44"/>
364+
<autoresizingMask key="autoresizingMask"/>
365+
<fontDescription key="fontDescription" type="boldSystem" pointSize="20"/>
366+
<color key="textColor" systemColor="darkTextColor"/>
367+
<color key="highlightedColor" red="1" green="0.99997437" blue="0.99999129769999995" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
368+
</label>
369+
</subviews>
370+
</tableViewCellContentView>
371+
<color key="backgroundColor" red="1" green="0.99997437" blue="0.99999129769999995" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
372+
</tableViewCell>
373+
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="Cell" textLabel="eVC-30-cci" style="IBUITableViewCellStyleDefault" id="UKT-06-bbt">
374+
<rect key="frame" x="0.0" y="910" width="414" height="44"/>
375+
<autoresizingMask key="autoresizingMask"/>
376+
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="UKT-06-bbt" id="Big-K3-piA">
377+
<rect key="frame" x="0.0" y="0.0" width="383.5" height="44"/>
360378
<autoresizingMask key="autoresizingMask"/>
361379
<subviews>
362-
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" text="Basic Views" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="O9S-7t-0EJ">
363-
<rect key="frame" x="8" y="0.0" width="379.5" height="44"/>
380+
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" text="SwiftUI Typing" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="eVC-30-cci">
381+
<rect key="frame" x="20" y="0.0" width="355.5" height="44"/>
364382
<autoresizingMask key="autoresizingMask"/>
365383
<fontDescription key="fontDescription" type="boldSystem" pointSize="20"/>
366384
<color key="textColor" systemColor="darkTextColor"/>
@@ -1469,7 +1487,7 @@
14691487
</connections>
14701488
</button>
14711489
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="IEl-Kv-c0V">
1472-
<rect key="frame" x="71" y="384" width="30" height="29"/>
1490+
<rect key="frame" x="71" y="383" width="30" height="29"/>
14731491
<autoresizingMask key="autoresizingMask" flexibleMinY="YES" flexibleMaxY="YES"/>
14741492
<accessibility key="accessibilityConfiguration" hint="A button for A"/>
14751493
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
@@ -1500,7 +1518,7 @@
15001518
<color key="backgroundColor" red="0.98594832420349121" green="0.0" blue="0.026950567960739136" alpha="0.73999999999999999" colorSpace="custom" customColorSpace="sRGB"/>
15011519
</view>
15021520
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="2dw-1u-nXG">
1503-
<rect key="frame" x="20" y="113" width="165" height="42"/>
1521+
<rect key="frame" x="20" y="112" width="165" height="42"/>
15041522
<autoresizingMask key="autoresizingMask" flexibleMinY="YES" flexibleMaxY="YES"/>
15051523
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
15061524
<state key="normal" title="Delayed Show/Hide">
@@ -1511,7 +1529,7 @@
15111529
</connections>
15121530
</button>
15131531
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" fixedFrame="YES" text="Content" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="FB2-Mi-l7y">
1514-
<rect key="frame" x="239" y="125" width="61" height="18"/>
1532+
<rect key="frame" x="239" y="124" width="61" height="18"/>
15151533
<autoresizingMask key="autoresizingMask" flexibleMinY="YES" flexibleMaxY="YES"/>
15161534
<accessibility key="accessibilityConfiguration">
15171535
<accessibilityTraits key="traits" staticText="YES" updatesFrequently="YES"/>
@@ -2240,10 +2258,10 @@ Line Break
22402258
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
22412259
</systemColor>
22422260
<systemColor name="systemBrownColor">
2243-
<color red="0.63529411759999999" green="0.51764705879999995" blue="0.36862745099999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
2261+
<color red="0.63529411764705879" green="0.51764705882352946" blue="0.36862745098039218" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
22442262
</systemColor>
22452263
<systemColor name="systemPurpleColor">
2246-
<color red="0.68627450980000004" green="0.32156862749999998" blue="0.87058823529999996" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
2264+
<color red="0.68627450980392157" green="0.32156862745098042" blue="0.87058823529411766" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
22472265
</systemColor>
22482266
</resources>
22492267
</document>

TestHost/SwiftUI/SwiftUIBasicView.swift TestHost/SwiftUI/SwiftUITappingView.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
//
2-
// SwiftUIBasicView.swift
2+
// SwiftUITappingView.swift
33
// TestHost
44
//
55
// Created by Bartłomiej Włodarczak on 03/02/2025.
66
//
77

88
import SwiftUI
99

10-
struct SwiftUIBasicView: View {
10+
struct SwiftUITappingView: View {
1111
var body: some View {
1212
List {
1313
TextWithTapCount(text: "Text with tap gesture")
@@ -23,7 +23,7 @@ struct SwiftUIBasicView: View {
2323
}
2424

2525
#Preview {
26-
SwiftUIBasicView()
26+
SwiftUITappingView()
2727
}
2828

2929
private struct ButtonWithTapCount: View {
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//
2+
// SwiftUITypingView.swift
3+
// TestHost
4+
//
5+
// Created by Bartłomiej Włodarczak on 10/02/2025.
6+
//
7+
8+
import SwiftUI
9+
10+
struct SwiftUITypingView: View {
11+
var body: some View {
12+
List {
13+
TextFieldWithMirror()
14+
}
15+
}
16+
}
17+
18+
#Preview {
19+
SwiftUITypingView()
20+
}
21+
22+
private struct TextFieldWithMirror: View {
23+
@State var text = ""
24+
25+
var body: some View {
26+
VStack(alignment: .leading) {
27+
Button(text.isEmpty ? "Fill text field" : "Clear text field") {
28+
if text.isEmpty {
29+
text = "This is some inserted text"
30+
} else {
31+
text = ""
32+
}
33+
}
34+
.buttonStyle(.plain)
35+
.foregroundColor(.blue)
36+
37+
TextField("This is SwiftUI TextField", text: $text)
38+
.withAccessibility(label: "SwiftUI TextField")
39+
.textFieldStyle(.roundedBorder)
40+
41+
Text(text)
42+
}
43+
}
44+
}

TestHost/SwiftUI/SwiftUIViewControllerFactory.swift

+6-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ import UIKit
1010
@MainActor final class SwiftUIViewControllerFactory: NSObject {
1111
private override init() {}
1212

13-
@objc static func makeBasicSwiftUIViewController() -> UIViewController {
14-
SwiftUIViewController(content: SwiftUIBasicView())
13+
@objc static func makeSwiftUITappingViewController() -> UIViewController {
14+
SwiftUIViewController(content: SwiftUITappingView())
15+
}
16+
17+
@objc static func makeSwiftUITypingViewController() -> UIViewController {
18+
SwiftUIViewController(content: SwiftUITypingView())
1519
}
1620
}

TestHost/TestSuiteViewController.m

+7-2
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,13 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
116116
switch (indexPath.row) {
117117
case 0:
118118
{
119-
UIViewController *vc = [SwiftUIViewControllerFactory makeBasicSwiftUIViewController];
120-
[[self navigationController] pushViewController:vc animated:true];
119+
[[self navigationController] pushViewController:[SwiftUIViewControllerFactory makeSwiftUITappingViewController] animated:true];
120+
break;
121+
}
122+
123+
case 1:
124+
{
125+
[[self navigationController] pushViewController:[SwiftUIViewControllerFactory makeSwiftUITypingViewController] animated:true];
121126
break;
122127
}
123128
}

Tests/SwiftUI Tests/SwiftUIBasicTests.m Tests/SwiftUI Tests/SwiftUITappingTests.m

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
//
2-
// SwiftUIBasicTests.m
2+
// SwiftUITappingTests.m
33
// KIF
44
//
55
// Created by Bartłomiej Włodarczak on 03/02/2025.
66
//
77

88
#import <KIF/KIF.h>
99

10-
@interface SwiftUIBasicTests : KIFTestCase
10+
@interface SwiftUITappingTests : KIFTestCase
1111
@end
1212

13-
@implementation SwiftUIBasicTests
13+
@implementation SwiftUITappingTests
1414

1515
- (void)beforeEach
1616
{
17-
[tester tapViewWithAccessibilityLabel:@"Basic Views"];
17+
[tester tapViewWithAccessibilityLabel:@"SwiftUI Tapping"];
1818
}
1919

2020
- (void)afterEach

0 commit comments

Comments
 (0)