// Copyright © 2015 Abhishek Banthia import XCTest class FloatingWindowTests: XCTestCase { var app: XCUIApplication! override func setUp() { super.setUp() continueAfterFailure = false app = XCUIApplication() app.launchArguments.append(CLUITestingLaunchArgument) app.launch() if !app.tables["FloatingTableView"].exists { app.tapMenubarIcon() app.buttons["Pin"].click() } } override func tearDown() { super.tearDown() } func testFloatingWindow() { let cell = app.tables["FloatingTableView"].cells.firstMatch let extraOptionButton = cell.buttons.firstMatch extraOptionButton.click() let remindersCheckbox = app.checkBoxes["ReminderCheckbox"] remindersCheckbox.click() sleep(1) XCTAssertTrue(app.popovers.datePickers.firstMatch.isEnabled) remindersCheckbox.click() sleep(1) XCTAssertFalse(app.popovers.datePickers.firstMatch.isEnabled) } func testAddingANote() { let expectedText = "This is a really important note to me and my friends" if app.buttons["Pin"].exists { app.buttons["Pin"].click() } let cell = app.tables["FloatingTableView"].cells.firstMatch let extraOptionButton = cell.buttons.firstMatch extraOptionButton.click() let notesTextView = app.textViews["NotesTextView"] notesTextView.click() app.textViews["NotesTextView"].click(forDuration: 2, thenDragTo: notesTextView) notesTextView.reset(text: "This is a really important note to me and my friends") let saveButton = app.buttons["SaveButton"] saveButton.click() if let noteLabelInCell = cell.staticTexts["This is a really important note to me and my friends"].value as? String { XCTAssert(noteLabelInCell == expectedText) } } func testSettingAReminder() { if app.buttons["Pin"].exists { app.buttons["Pin"].click() } let cell = app.tables["FloatingTableView"].cells.firstMatch let extraOptionButton = cell.buttons.firstMatch extraOptionButton.click() let remindersCheckbox = app.checkBoxes["ReminderCheckbox"] remindersCheckbox.click() app.buttons["SaveButton"].click() app.tapMenubarIcon() } func testMarkingSlider() { if app.buttons["Pin"].exists { app.buttons["Pin"].click() } let floatingSlider = app.sliders["FloatingSlider"].exists app.buttons["FloatingPreferences"].click() let appearanceTab = app.toolbars.buttons.element(boundBy: 1) appearanceTab.click() if floatingSlider { app.radioGroups["FutureSlider"].radioButtons["No"].click() } else { app.radioGroups["FutureSlider"].radioButtons["Yes"].click() } let newFloatingSliderExists = app.sliders["FloatingSlider"].exists XCTAssertNotEqual(floatingSlider, newFloatingSliderExists) } func testHidingMenubarOptions() { if app.buttons["Pin"].exists { app.buttons["Pin"].click() } app.buttons["FloatingPreferences"].click() app.windows["Clocker"].toolbars.buttons["General"].click() let menubarDisplayQuery = app.tables.checkBoxes.matching(NSPredicate(format: "value == 1", "")) let menubarDisplayQueryCount = menubarDisplayQuery.count for index in 0..