You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
2.1 KiB

// Copyright © 2015 Abhishek Banthia
import XCTest
class NetworkDisconnectionTests: XCTestCase {
6 years ago
var app: XCUIApplication!
6 years ago
override func setUp() {
super.setUp()
continueAfterFailure = false
app = XCUIApplication()
}
6 years ago
func precondition() {
app.launch()
6 years ago
if !app.tables["FloatingTableView"].exists {
app.tapMenubarIcon()
app.buttons["Pin"].click()
}
}
func testAddingACity() {
app.launchArguments.append("mockNetworkDown")
precondition()
app.buttons["FloatingPreferences"].click()
6 years ago
if app.sheets.count == 0 {
app.windows["Clocker"].checkBoxes["AddTimezone"].click()
}
6 years ago
XCTAssertFalse(app.sheets.staticTexts["ErrorPlaceholder"].exists)
6 years ago
let searchField = app.searchFields["AvailableSearchField"]
searchField.reset(text: "Uganda")
sleep(1)
XCTAssertTrue(app.sheets.staticTexts["ErrorPlaceholder"].exists)
6 years ago
app.sheets.buttons["Close"].click()
}
6 years ago
func testFetchingATimezone() {
6 years ago
app.launchArguments.append("mockTimezoneDown")
precondition()
app.buttons["FloatingPreferences"].click()
6 years ago
if app.sheets.count == 0 {
app.windows["Clocker"].checkBoxes["AddTimezone"].click()
}
6 years ago
XCTAssertFalse(app.sheets.staticTexts["ErrorPlaceholder"].exists)
6 years ago
let searchField = app.searchFields["AvailableSearchField"]
searchField.reset(text: "Uganda")
let firstResult = app.tables["AvailableTimezoneTableView"].tableRows.firstMatch
6 years ago
let waiter = XCTWaiter()
let isHittable = NSPredicate(format: "exists == true", "")
let addExpectation = expectation(for: isHittable,
evaluatedWith: firstResult,
handler: nil)
waiter.wait(for: [addExpectation], timeout: 5)
app.tables["AvailableTimezoneTableView"].click()
app.buttons["AddAvailableTimezone"].click()
6 years ago
sleep(1)
XCTAssertTrue(app.sheets.staticTexts["ErrorPlaceholder"].exists)
app.sheets.buttons["Close"].click()
}
6 years ago
}