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.
 
 
 
 
 

57 lines
1.9 KiB

// Copyright © 2015 Abhishek Banthia
import XCTest
class ShortcutTests: XCTestCase {
var app: XCUIApplication!
let randomIndex = Int(arc4random_uniform(26))
override func setUp() {
super.setUp()
continueAfterFailure = false
app = XCUIApplication()
app.launch()
app.tapMenubarIcon()
if !app.tables["mainTableView"].exists {
app.buttons["FloatingPin"].click()
app.tapMenubarIcon()
}
}
func testShortcuts() {
app.tables["mainTableView"].typeKey(",", modifierFlags: .command)
XCTAssertFalse(app.tables["mainTableView"].exists)
let randomAlphabet = randomLetter()
app.windows["Clocker"].otherElements["ShortcutControl"].click()
app.windows["Clocker"].otherElements["ShortcutControl"].typeKey(randomAlphabet, modifierFlags: [.shift, .command])
// Close the window to really test
app.windows["Clocker"].buttons["_XCUI:CloseWindow"].click()
app.typeKey(randomAlphabet, modifierFlags: [.shift, .command])
XCTAssertTrue(app.tables["mainTableView"].exists)
app.terminate()
app.launch()
app.typeKey(randomAlphabet, modifierFlags: [.shift, .command])
XCTAssertTrue(app.tables["mainTableView"].exists)
// Reset the shortcut
app.tables["mainTableView"].typeKey(",", modifierFlags: .command)
app.windows["Clocker"].otherElements["ShortcutControl"].click()
app.windows["Clocker"].typeKey(XCUIKeyboardKey.delete, modifierFlags: [])
app.windows["Clocker"].typeKey(randomAlphabet, modifierFlags: [.shift, .command])
XCTAssertFalse(app.tables["mainTableView"].exists)
}
private func randomLetter() -> String {
let alphabet: [String] = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
return alphabet[randomIndex]
}
}