Skip to content

Commit eae79fb

Browse files
Test if labels are inbounds
- If this simple test I could see the app doesn’t layout properly for iphone5
1 parent 65f8d3a commit eae79fb

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

SwiftWeatherUITests/SwiftWeatherUITests.swift

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,20 @@ class SwiftWeatherUITests: QuickSpec {
1919
}
2020

2121
describe("a wheather viewcontroller") {
22-
context("when the app orientation is portrait") {
23-
beforeEach {
24-
XCUIDevice.shared().orientation = .portrait
22+
context("location service is enabled") {
23+
context("when in portrait") {
24+
beforeEach {
25+
XCUIDevice.shared().orientation = .portrait
26+
}
27+
itBehavesLike("a properly laidout wheather viewcontroller")
2528
}
26-
itBehavesLike("a regular wheather viewcontroller")
27-
}
2829

29-
context("when the app orientation is landscape") {
30-
beforeEach {
31-
XCUIDevice.shared().orientation = .landscapeLeft
30+
context("when in landscape") {
31+
beforeEach {
32+
XCUIDevice.shared().orientation = .landscapeLeft
33+
}
34+
itBehavesLike("a properly laidout wheather viewcontroller")
3235
}
33-
itBehavesLike("a regular wheather viewcontroller")
3436
}
3537
}
3638
}
@@ -39,18 +41,28 @@ class SwiftWeatherUITests: QuickSpec {
3941
class RegularWheatherViewControllerConfiguration: QuickConfiguration {
4042
override class func configure(_ configuration: Configuration) {
4143
let app = XCUIApplication()
44+
let window = app.windows.element(boundBy: 0)
4245

43-
sharedExamples("a regular wheather viewcontroller") { (context: SharedExampleContext) in
46+
sharedExamples("a properly laidout wheather viewcontroller") { (context: SharedExampleContext) in
4447
it("shows city") {
45-
expect(app.staticTexts["a11y_current_city"].exists).to(beTruthy())
48+
let cityLabel = app.staticTexts["a11y_current_city"]
49+
50+
expect(cityLabel.exists).to(beTruthy())
51+
expect(window.frame.contains(cityLabel.frame)).to(beTruthy())
4652
}
4753

4854
it("shows wheather icon") {
49-
expect(app.staticTexts["a11y_wheather_icon"].exists).to(beTruthy())
55+
let wheatherIconLabel = app.staticTexts["a11y_wheather_icon"]
56+
57+
expect(wheatherIconLabel.exists).to(beTruthy())
58+
expect(window.frame.contains(wheatherIconLabel.frame)).to(beTruthy())
5059
}
5160

5261
it("shows wheather temperature") {
53-
expect(app.staticTexts["a11y_wheather_temperature"].exists).to(beTruthy())
62+
let wheatherTemperatureLabel = app.staticTexts["a11y_wheather_temperature"]
63+
64+
expect(wheatherTemperatureLabel.exists).to(beTruthy())
65+
expect(window.frame.contains(wheatherTemperatureLabel.frame)).to(beTruthy())
5466
}
5567
}
5668
}

0 commit comments

Comments
 (0)