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.

61 lines
1.9 KiB

// Copyright © 2015 Abhishek Banthia
import XCTest
class ShortcutTests: XCTestCase {
6 years ago
var app: XCUIApplication!
6 years ago
let randomIndex = Int(arc4random_uniform(26))
6 years ago
override func setUp() {
super.setUp()
continueAfterFailure = false
app = XCUIApplication()
app.launch()
app.tapMenubarIcon()
6 years ago
if !app.tables["mainTableView"].exists {
app.buttons["FloatingPin"].click()
app.tapMenubarIcon()
}
}
6 years ago
func testShortcuts() {
app.tables["mainTableView"].typeKey(",", modifierFlags: .command)
6 years ago
XCTAssertFalse(app.tables["mainTableView"].exists)
6 years ago
let randomAlphabet = randomLetter()
6 years ago
app.windows["Clocker"].buttons["ShortcutControl"].click()
app.windows["Clocker"].buttons["ShortcutControl"].typeKey(randomAlphabet, modifierFlags: [.shift, .command])
6 years ago
// Close the window to really test
app.windows["Clocker"].buttons["_XCUI:CloseWindow"].click()
6 years ago
app.typeKey(randomAlphabet, modifierFlags: [.shift, .command])
XCTAssertTrue(app.tables["mainTableView"].exists)
6 years ago
app.terminate()
app.launch()
6 years ago
app.typeKey(randomAlphabet, modifierFlags: [.shift, .command])
XCTAssertTrue(app.tables["mainTableView"].exists)
6 years ago
// Reset the shortcut
app.tables["mainTableView"].typeKey(",", modifierFlags: .command)
app.windows["Clocker"].buttons["ShortcutControl"].click()
app.windows["Clocker"].typeKey(XCUIKeyboardKey.delete, modifierFlags: [])
app.windows["Clocker"].typeKey(randomAlphabet, modifierFlags: [.shift, .command])
XCTAssertFalse(app.tables["mainTableView"].exists)
}
6 years ago
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]
}
}