Skip to content

Commit 6c002a1

Browse files
authored
Merge pull request #18 from bcylin/feature/ui-tests
Reenable UI Tests
2 parents c7747b7 + 1bdf9fb commit 6c002a1

File tree

13 files changed

+457
-668
lines changed

13 files changed

+457
-668
lines changed

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ cache:
77
- Pods
88
before_install:
99
- export LANG=en_US.UTF-8
10+
- xcrun instruments -s devices
11+
- xcrun instruments -w "iPhone 7 (10.3.1) [" || true
1012
install:
1113
- make install
1214
before_script:
1315
- xcodebuild -workspace ICInputAccessory.xcworkspace -list
1416
script:
15-
- bundle exec rake ci:build
17+
- bundle exec rake ci:test
1618
- make -B carthage
1719
- make -B docs
1820
after_script:

Example.xcodeproj/project.pbxproj

Lines changed: 0 additions & 550 deletions
This file was deleted.

Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 0 additions & 7 deletions
This file was deleted.

Example/Info.plist

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
<dict>
55
<key>CFBundleDevelopmentRegion</key>
66
<string>en</string>
7+
<key>CFBundleDisplayName</key>
8+
<string>ICInputAccessoryExample</string>
79
<key>CFBundleExecutable</key>
810
<string>$(EXECUTABLE_NAME)</string>
911
<key>CFBundleIdentifier</key>
@@ -35,7 +37,6 @@
3537
<string>UIInterfaceOrientationPortrait</string>
3638
<string>UIInterfaceOrientationLandscapeLeft</string>
3739
<string>UIInterfaceOrientationLandscapeRight</string>
38-
<string>UIInterfaceOrientationPortraitUpsideDown</string>
3940
</array>
4041
</dict>
4142
</plist>

ICInputAccessory.xcodeproj/project.pbxproj

Lines changed: 412 additions & 0 deletions
Large diffs are not rendered by default.

Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme renamed to ICInputAccessory.xcodeproj/xcshareddata/xcschemes/Example.xcscheme

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0820"
3+
LastUpgradeVersion = "0830"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -14,10 +14,10 @@
1414
buildForAnalyzing = "YES">
1515
<BuildableReference
1616
BuildableIdentifier = "primary"
17-
BlueprintIdentifier = "B5E9F8FA1C8D3B6E00443DC7"
17+
BlueprintIdentifier = "B53376871F4436D000230739"
1818
BuildableName = "Example.app"
1919
BlueprintName = "Example"
20-
ReferencedContainer = "container:Example.xcodeproj">
20+
ReferencedContainer = "container:ICInputAccessory.xcodeproj">
2121
</BuildableReference>
2222
</BuildActionEntry>
2323
</BuildActionEntries>
@@ -32,20 +32,20 @@
3232
skipped = "NO">
3333
<BuildableReference
3434
BuildableIdentifier = "primary"
35-
BlueprintIdentifier = "B548C5C11C8E91B0009D5AEE"
35+
BlueprintIdentifier = "B533769A1F4436D000230739"
3636
BuildableName = "ICInputAccessoryUITests.xctest"
3737
BlueprintName = "ICInputAccessoryUITests"
38-
ReferencedContainer = "container:Example.xcodeproj">
38+
ReferencedContainer = "container:ICInputAccessory.xcodeproj">
3939
</BuildableReference>
4040
</TestableReference>
4141
</Testables>
4242
<MacroExpansion>
4343
<BuildableReference
4444
BuildableIdentifier = "primary"
45-
BlueprintIdentifier = "B5E9F8FA1C8D3B6E00443DC7"
45+
BlueprintIdentifier = "B53376871F4436D000230739"
4646
BuildableName = "Example.app"
4747
BlueprintName = "Example"
48-
ReferencedContainer = "container:Example.xcodeproj">
48+
ReferencedContainer = "container:ICInputAccessory.xcodeproj">
4949
</BuildableReference>
5050
</MacroExpansion>
5151
<AdditionalOptions>
@@ -65,10 +65,10 @@
6565
runnableDebuggingMode = "0">
6666
<BuildableReference
6767
BuildableIdentifier = "primary"
68-
BlueprintIdentifier = "B5E9F8FA1C8D3B6E00443DC7"
68+
BlueprintIdentifier = "B53376871F4436D000230739"
6969
BuildableName = "Example.app"
7070
BlueprintName = "Example"
71-
ReferencedContainer = "container:Example.xcodeproj">
71+
ReferencedContainer = "container:ICInputAccessory.xcodeproj">
7272
</BuildableReference>
7373
</BuildableProductRunnable>
7474
<AdditionalOptions>
@@ -84,10 +84,10 @@
8484
runnableDebuggingMode = "0">
8585
<BuildableReference
8686
BuildableIdentifier = "primary"
87-
BlueprintIdentifier = "B5E9F8FA1C8D3B6E00443DC7"
87+
BlueprintIdentifier = "B53376871F4436D000230739"
8888
BuildableName = "Example.app"
8989
BlueprintName = "Example"
90-
ReferencedContainer = "container:Example.xcodeproj">
90+
ReferencedContainer = "container:ICInputAccessory.xcodeproj">
9191
</BuildableReference>
9292
</BuildableProductRunnable>
9393
</ProfileAction>

ICInputAccessory.xcworkspace/contents.xcworkspacedata

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ICInputAccessoryUITests/ICKeyboardDismissTextFieldUITests.swift

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,40 +28,24 @@ import XCTest
2828

2929
class ICKeyboardDismissTextFieldUITests: XCTestCase {
3030

31+
private lazy var app = XCUIApplication()
32+
3133
override func setUp() {
3234
super.setUp()
33-
// In UI tests it is usually best to stop immediately when a failure occurs.
3435
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.
3636
XCUIApplication().launch()
3737
}
3838

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-
4439
func testKeyboardDismissing() {
45-
let app = XCUIApplication()
46-
app.tables.cells.textFields["ICKeyboardDismissTextField"].tap()
47-
48-
let keyboardWindow = app.children(matching: .window).element(boundBy: 1)
49-
let accessory = keyboardWindow.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element(boundBy: 0)
50-
accessory.children(matching: .button).element.tap()
40+
app.tables.textFields["ICKeyboardDismissTextField"].tap()
41+
app.buttons["Dismiss Keyboard"].tap()
5142
}
5243

5344
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.children(matching: .window).element(boundBy: 1)
61-
let accessory = keyboardWindow.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element(boundBy: 0)
62-
accessory.children(matching: .button).element.tap()
63-
64-
tablesQuery.buttons["Back to Code"].tap()
45+
app.tables.buttons["Storyboard"].tap()
46+
app.tables.textFields["Storyboard ICKeyboardDismissTextField"].tap()
47+
app.buttons["Dismiss Keyboard"].tap()
48+
app.tables.buttons["Back to Code"].tap()
6549
}
6650

6751
}

ICInputAccessoryUITests/ICTokenFieldUITests.swift

Lines changed: 15 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,15 @@ import XCTest
2828

2929
class ICTokenFieldUITests: XCTestCase {
3030

31+
private lazy var app = XCUIApplication()
32+
3133
override func setUp() {
3234
super.setUp()
33-
// In UI tests it is usually best to stop immediately when a failure occurs.
3435
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()
36+
app.launch()
4237
}
4338

44-
func testTokenField() {
45-
let app = XCUIApplication()
46-
let tablesQuery = app.tables
47-
let textField = tablesQuery.cells.containing(.staticText, identifier:"ICTokenField").children(matching: .textField).element
48-
39+
private func typeTexts(in textField: XCUIElement) {
4940
textField.tap()
5041
textField.typeText("Try")
5142
textField.typeText(" ")
@@ -61,58 +52,25 @@ class ICTokenFieldUITests: XCTestCase {
6152
textField.typeText("TestFlight")
6253
textField.typeText(",")
6354

64-
let searchButton = app.buttons["Search"]
65-
searchButton.tap()
55+
app.buttons["Search"].tap()
56+
}
57+
58+
func testTokenField() {
59+
let textField = app.tables.cells.containing(.staticText, identifier:"ICTokenField").children(matching: .textField).element
60+
typeTexts(in: textField)
6661
}
6762

6863
func testCustomizedTokenField() {
69-
let app = XCUIApplication()
7064
app.tables.staticTexts["CustomizedTokenField"].tap()
71-
7265
let tokenField = app.navigationBars["Example.CustomizedTokenView"].scrollViews.children(matching: .textField).element
73-
tokenField.typeText("Try")
74-
tokenField.typeText(" ")
75-
tokenField.typeText("iCook")
76-
tokenField.typeText(",")
77-
tokenField.typeText("beta")
78-
tokenField.typeText(" ")
79-
80-
let deleteKey = app.keys["delete"]
81-
deleteKey.tap()
82-
deleteKey.tap()
83-
84-
tokenField.typeText("TestFlight")
85-
tokenField.typeText(",")
86-
87-
let searchButton = app.buttons["Search"]
88-
searchButton.tap()
66+
typeTexts(in: tokenField)
8967
}
9068

9169
func testStoryboard() {
92-
let app = XCUIApplication()
93-
let tablesQuery = app.tables
94-
tablesQuery.buttons["Storyboard"].tap()
95-
96-
let tokenField = tablesQuery.cells.containing(.staticText, identifier:"Storyboard ICTokenField").children(matching: .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()
70+
app.tables.buttons["Storyboard"].tap()
71+
let tokenField = app.tables.cells.containing(.staticText, identifier:"Storyboard ICTokenField").children(matching: .textField).element
72+
typeTexts(in: tokenField)
73+
app.tables.buttons["Back to Code"].tap()
11674
}
11775

11876
}

Podfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ platform :ios, "8.0"
22
use_frameworks!
33

44
workspace "ICInputAccessory"
5-
project "Example"
5+
project "ICInputAccessory"
66

77
target "Example" do
8-
pod "ICInputAccessory/KeyboardDismissTextField", path: "./"
9-
pod "ICInputAccessory/TokenField", path: "./"
108
pod "SwiftLint", "0.19.0"
119
end

0 commit comments

Comments
 (0)