Skip to content

Commit 8a24384

Browse files
committed
Test UI implemented in storyboard
1 parent 4495c51 commit 8a24384

4 files changed

Lines changed: 106 additions & 17 deletions

File tree

Example/Example.xcodeproj/project.pbxproj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111
B52819581C90215C007D01D5 /* CustomizedTokenField.swift in Sources */ = {isa = PBXBuildFile; fileRef = B52819571C90215C007D01D5 /* CustomizedTokenField.swift */; };
1212
B548C5A71C8D55A8009D5AEE /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = B548C5A51C8D55A8009D5AEE /* InfoPlist.strings */; };
1313
B548C5A91C8D6150009D5AEE /* ExampleCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B548C5A81C8D6150009D5AEE /* ExampleCell.swift */; };
14-
B548C5C51C8E91B0009D5AEE /* ICInputAccessoryUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B548C5C41C8E91B0009D5AEE /* ICInputAccessoryUITests.swift */; };
14+
B548C5C51C8E91B0009D5AEE /* ICTokenFieldUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B548C5C41C8E91B0009D5AEE /* ICTokenFieldUITests.swift */; };
1515
B5C53E191C92851400AF3489 /* CustomizedTokenViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5C53E181C92851400AF3489 /* CustomizedTokenViewController.swift */; };
1616
B5D04CFE1C99A7C900174823 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B5D04CFD1C99A7C900174823 /* Main.storyboard */; };
1717
B5D04D001C99AF0700174823 /* StoryboardViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D04CFF1C99AF0700174823 /* StoryboardViewController.swift */; };
1818
B5E9F8FF1C8D3B6E00443DC7 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E9F8FE1C8D3B6E00443DC7 /* AppDelegate.swift */; };
1919
B5E9F9011C8D3B6E00443DC7 /* ExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E9F9001C8D3B6E00443DC7 /* ExampleViewController.swift */; };
2020
B5E9F9061C8D3B6E00443DC7 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B5E9F9051C8D3B6E00443DC7 /* Assets.xcassets */; };
2121
B5E9F9091C8D3B6E00443DC7 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B5E9F9071C8D3B6E00443DC7 /* LaunchScreen.storyboard */; };
22+
B5F62A5D1C9ECBCB003A1231 /* ICKeyboardDismissTextFieldUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5F62A5C1C9ECBCB003A1231 /* ICKeyboardDismissTextFieldUITests.swift */; };
2223
/* End PBXBuildFile section */
2324

2425
/* Begin PBXContainerItemProxy section */
@@ -36,7 +37,7 @@
3637
B548C5A61C8D55A8009D5AEE /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/InfoPlist.strings; sourceTree = "<group>"; };
3738
B548C5A81C8D6150009D5AEE /* ExampleCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExampleCell.swift; sourceTree = "<group>"; };
3839
B548C5C21C8E91B0009D5AEE /* ICInputAccessoryUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ICInputAccessoryUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
39-
B548C5C41C8E91B0009D5AEE /* ICInputAccessoryUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ICInputAccessoryUITests.swift; sourceTree = "<group>"; };
40+
B548C5C41C8E91B0009D5AEE /* ICTokenFieldUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ICTokenFieldUITests.swift; sourceTree = "<group>"; };
4041
B548C5C61C8E91B0009D5AEE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
4142
B5C53E181C92851400AF3489 /* CustomizedTokenViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomizedTokenViewController.swift; sourceTree = "<group>"; };
4243
B5D04CFD1C99A7C900174823 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = "<group>"; };
@@ -47,6 +48,7 @@
4748
B5E9F9051C8D3B6E00443DC7 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
4849
B5E9F9081C8D3B6E00443DC7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
4950
B5E9F90A1C8D3B6E00443DC7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
51+
B5F62A5C1C9ECBCB003A1231 /* ICKeyboardDismissTextFieldUITests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ICKeyboardDismissTextFieldUITests.swift; sourceTree = "<group>"; };
5052
CA708B7D49E7D80A75ED81E3 /* Pods-Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Example.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-Example/Pods-Example.debug.xcconfig"; sourceTree = "<group>"; };
5153
D0DB1D3E89AB75183DB104E0 /* Pods_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
5254
FE1A89C8A77ED0438A206A24 /* Pods-Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Example.release.xcconfig"; path = "../Pods/Target Support Files/Pods-Example/Pods-Example.release.xcconfig"; sourceTree = "<group>"; };
@@ -91,7 +93,8 @@
9193
B548C5C31C8E91B0009D5AEE /* ICInputAccessoryUITests */ = {
9294
isa = PBXGroup;
9395
children = (
94-
B548C5C41C8E91B0009D5AEE /* ICInputAccessoryUITests.swift */,
96+
B5F62A5C1C9ECBCB003A1231 /* ICKeyboardDismissTextFieldUITests.swift */,
97+
B548C5C41C8E91B0009D5AEE /* ICTokenFieldUITests.swift */,
9598
B548C5C61C8E91B0009D5AEE /* Info.plist */,
9699
);
97100
path = ICInputAccessoryUITests;
@@ -303,7 +306,8 @@
303306
isa = PBXSourcesBuildPhase;
304307
buildActionMask = 2147483647;
305308
files = (
306-
B548C5C51C8E91B0009D5AEE /* ICInputAccessoryUITests.swift in Sources */,
309+
B5F62A5D1C9ECBCB003A1231 /* ICKeyboardDismissTextFieldUITests.swift in Sources */,
310+
B548C5C51C8E91B0009D5AEE /* ICTokenFieldUITests.swift in Sources */,
307311
);
308312
runOnlyForDeploymentPostprocessing = 0;
309313
};

Example/Example/Main.storyboard

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<rect key="frame" x="0.0" y="0.0" width="600" height="43.5"/>
3434
<autoresizingMask key="autoresizingMask"/>
3535
<subviews>
36-
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="ICKeyboardDismissTextField" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="qdb-Ab-nYe" customClass="ICKeyboardDismissTextField" customModule="ICInputAccessory">
36+
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Storyboard ICKeyboardDismissTextField" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="qdb-Ab-nYe" customClass="ICKeyboardDismissTextField" customModule="ICInputAccessory">
3737
<rect key="frame" x="18" y="12" width="564" height="20"/>
3838
<fontDescription key="fontDescription" type="system" pointSize="16"/>
3939
<textInputTraits key="textInputTraits"/>
@@ -65,7 +65,7 @@
6565
<color key="backgroundColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
6666
<color key="tintColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
6767
<userDefinedRuntimeAttributes>
68-
<userDefinedRuntimeAttribute type="string" keyPath="placeholder" value="ICTokenFIeld"/>
68+
<userDefinedRuntimeAttribute type="string" keyPath="placeholder" value="Storyboard ICTokenField"/>
6969
<userDefinedRuntimeAttribute type="image" keyPath="icon" value="icook-iphone-input-search"/>
7070
<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
7171
<real key="value" value="0.0"/>
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
//
2+
// ICKeyboardDismissTextFieldUITests.swift
3+
// ICInputAccessoryUITests
4+
//
5+
// Created by Ben on 20/03/2016.
6+
// Copyright © 2016 Polydice, Inc.
7+
//
8+
// Permission is hereby granted, free of charge, to any person obtaining a copy
9+
// of this software and associated documentation files (the "Software"), to deal
10+
// in the Software without restriction, including without limitation the rights
11+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
// copies of the Software, and to permit persons to whom the Software is
13+
// furnished to do so, subject to the following conditions:
14+
//
15+
// The above copyright notice and this permission notice shall be included in all
16+
// copies or substantial portions of the Software.
17+
//
18+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
// SOFTWARE.
25+
//
26+
27+
import XCTest
28+
29+
class ICKeyboardDismissTextFieldUITests: XCTestCase {
30+
31+
override func setUp() {
32+
super.setUp()
33+
// In UI tests it is usually best to stop immediately when a failure occurs.
34+
continueAfterFailure = false
35+
// UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
36+
XCUIApplication().launch()
37+
}
38+
39+
override func tearDown() {
40+
// Put teardown code here. This method is called after the invocation of each test method in the class.
41+
super.tearDown()
42+
}
43+
44+
func testKeyboardDismissing() {
45+
let app = XCUIApplication()
46+
app.tables.cells.textFields["ICKeyboardDismissTextField"].tap()
47+
48+
let keyboardWindow = app.childrenMatchingType(.Window).elementBoundByIndex(1)
49+
let accessory = keyboardWindow.childrenMatchingType(.Other).element.childrenMatchingType(.Other).element.childrenMatchingType(.Other).elementBoundByIndex(0)
50+
accessory.childrenMatchingType(.Button).element.tap()
51+
}
52+
53+
func testStoryboard() {
54+
let app = XCUIApplication()
55+
let tablesQuery = app.tables
56+
57+
tablesQuery.buttons["Storyboard"].tap()
58+
tablesQuery.textFields["Storyboard ICKeyboardDismissTextField"].tap()
59+
60+
let keyboardWindow = app.childrenMatchingType(.Window).elementBoundByIndex(1)
61+
let accessory = keyboardWindow.childrenMatchingType(.Other).element.childrenMatchingType(.Other).element.childrenMatchingType(.Other).elementBoundByIndex(0)
62+
accessory.childrenMatchingType(.Button).element.tap()
63+
64+
tablesQuery.buttons["Back to Code"].tap()
65+
}
66+
67+
}

Example/ICInputAccessoryUITests/ICInputAccessoryUITests.swift renamed to Example/ICInputAccessoryUITests/ICTokenFieldUITests.swift

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// ICInputAccessoryUITests.swift
2+
// ICTokenFieldUITests.swift
33
// ICInputAccessoryUITests
44
//
55
// Created by Ben on 08/03/2016.
@@ -26,7 +26,7 @@
2626

2727
import XCTest
2828

29-
class ICInputAccessoryUITests: XCTestCase {
29+
class ICTokenFieldUITests: XCTestCase {
3030

3131
override func setUp() {
3232
super.setUp()
@@ -41,15 +41,6 @@ class ICInputAccessoryUITests: XCTestCase {
4141
super.tearDown()
4242
}
4343

44-
func testKeyboardDismissing() {
45-
let app = XCUIApplication()
46-
app.tables.cells.textFields["ICKeyboardDismissTextField"].tap()
47-
48-
let keyboardWindow = app.childrenMatchingType(.Window).elementBoundByIndex(1)
49-
let accessory = keyboardWindow.childrenMatchingType(.Other).element.childrenMatchingType(.Other).element.childrenMatchingType(.Other).elementBoundByIndex(0)
50-
accessory.childrenMatchingType(.Button).element.tap()
51-
}
52-
5344
func testTokenField() {
5445
let app = XCUIApplication()
5546
let tablesQuery = app.tables
@@ -97,4 +88,31 @@ class ICInputAccessoryUITests: XCTestCase {
9788
searchButton.tap()
9889
}
9990

91+
func testStoryboard() {
92+
let app = XCUIApplication()
93+
let tablesQuery = app.tables
94+
tablesQuery.buttons["Storyboard"].tap()
95+
96+
let tokenField = tablesQuery.cells.containingType(.StaticText, identifier:"Storyboard ICTokenField").childrenMatchingType(.TextField).element
97+
tokenField.tap()
98+
tokenField.typeText("Try")
99+
tokenField.typeText(" ")
100+
tokenField.typeText("iCook")
101+
tokenField.typeText(",")
102+
tokenField.typeText("beta")
103+
tokenField.typeText(" ")
104+
105+
let deleteKey = app.keys["delete"]
106+
deleteKey.tap()
107+
deleteKey.tap()
108+
109+
tokenField.typeText("TestFlight")
110+
tokenField.typeText(",")
111+
112+
let searchButton = app.buttons["Search"]
113+
searchButton.tap()
114+
115+
tablesQuery.buttons["Back to Code"].tap()
116+
}
117+
100118
}

0 commit comments

Comments
 (0)