From 170af2ccf05abe33bbadfcb00fda7e0dfd6b1da6 Mon Sep 17 00:00:00 2001 From: Abhishek Banthia <8280282+n0shake@users.noreply.github.com> Date: Sat, 14 Aug 2021 10:29:57 -0500 Subject: [PATCH 1/4] Update PermissionsTests.swift --- Clocker/ClockerUITests/PermissionsTests.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Clocker/ClockerUITests/PermissionsTests.swift b/Clocker/ClockerUITests/PermissionsTests.swift index 55e1cce..f58d8c9 100644 --- a/Clocker/ClockerUITests/PermissionsTests.swift +++ b/Clocker/ClockerUITests/PermissionsTests.swift @@ -14,6 +14,10 @@ class PermissionsTests: XCTestCase { } func testAcceptingCalendarPermissions() { + if app.tables["FloatingTableView"].exists { + app.buttons["FloatingPin"].click() + } + app.tapMenubarIcon() app/*@START_MENU_TOKEN@*/.buttons["Preferences"]/*[[".dialogs[\"Clocker Panel\"].buttons[\"Preferences\"]",".buttons[\"Preferences\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.click() @@ -52,6 +56,10 @@ class PermissionsTests: XCTestCase { } func testAcceptingRemindersPermissions() { + if app.tables["FloatingTableView"].exists { + app.tapMenubarIcon() + app.buttons["FloatingPin"].click() + } app.tapMenubarIcon() app/*@START_MENU_TOKEN@*/.buttons["Preferences"]/*[[".dialogs[\"Clocker Panel\"].buttons[\"Preferences\"]",".buttons[\"Preferences\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.click() From 4afbe7580cea6bc0dce5adbc37e147bbf9d1413c Mon Sep 17 00:00:00 2001 From: Abhishek Banthia <8280282+n0shake@users.noreply.github.com> Date: Sat, 14 Aug 2021 10:30:05 -0500 Subject: [PATCH 2/4] Update PreferencesTest.swift --- Clocker/ClockerUITests/PreferencesTest.swift | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Clocker/ClockerUITests/PreferencesTest.swift b/Clocker/ClockerUITests/PreferencesTest.swift index e6df749..ef980d2 100644 --- a/Clocker/ClockerUITests/PreferencesTest.swift +++ b/Clocker/ClockerUITests/PreferencesTest.swift @@ -306,15 +306,22 @@ class PreferencesTest: XCTestCase { // Let's make sure we have > 1 timezones first let favourites = preferencesTable.tableRows + + if (favourites.count < 2) { + addAPlace(place: "UTC", to: app) + } + XCTAssertTrue(favourites.count > 1) - + sleep(2) + // Select two timezones let unfavouritedMenubarsQuery = preferencesTable.checkBoxes.matching(NSPredicate(format: "value == 0", "")) if unfavouritedMenubarsQuery.count > 1 { - for _ in 0 ..< 2 { + for _ in 0 ..< unfavouritedMenubarsQuery.count { let checkbox = unfavouritedMenubarsQuery.element(boundBy: 0) checkbox.click() + sleep(2) } } @@ -442,7 +449,7 @@ extension XCTestCase { } private func deleteAtRow(_ rowToDelete: XCUIElement, for _: XCUIApplication, shouldSleep: Bool) { - rowToDelete.coordinate(withNormalizedOffset: CGVector(dx: 0, dy: 0)).click() + rowToDelete.click() rowToDelete.typeKey(XCUIKeyboardKey.delete, modifierFlags: XCUIElement.KeyModifierFlags()) if shouldSleep { sleep(2) From 9c81c64981e98ec4a1f1cf2f115f2e7807f32e6e Mon Sep 17 00:00:00 2001 From: Abhishek Banthia <8280282+n0shake@users.noreply.github.com> Date: Sat, 14 Aug 2021 11:10:03 -0500 Subject: [PATCH 3/4] Fix Tests. --- Clocker/ClockerUnitTests/ClockerUnitTests.swift | 10 +++++----- Clocker/Overall App/Themer.swift | 6 +++++- .../Panel/ParentPanelController+ModernSlider.swift | 11 +++++++++-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Clocker/ClockerUnitTests/ClockerUnitTests.swift b/Clocker/ClockerUnitTests/ClockerUnitTests.swift index 33e3287..1e88a88 100644 --- a/Clocker/ClockerUnitTests/ClockerUnitTests.swift +++ b/Clocker/ClockerUnitTests/ClockerUnitTests.swift @@ -143,11 +143,11 @@ class ClockerUnitTests: XCTestCase { // The below test might fail outside California or if DST is active! // CI is calibrated to be on LA timezone! func testTimeDifference() { - XCTAssertTrue(operations.timeDifference() == ", 9h 30m ahead", "Difference was unexpectedly: \(operations.timeDifference())") - XCTAssertTrue(californiaOperations.timeDifference() == ", 3h behind", "Difference was unexpectedly: \(californiaOperations.timeDifference())") - XCTAssertTrue(floridaOperations.timeDifference() == "", "Difference was unexpectedly: \(floridaOperations.timeDifference())") - XCTAssertTrue(aucklandOperations.timeDifference() == ", 16h ahead", "Difference was unexpectedly: \(aucklandOperations.timeDifference())") - XCTAssertTrue(omahaOperations.timeDifference() == ", an hour behind", "Difference was unexpectedly: \(omahaOperations.timeDifference())") + XCTAssertTrue(operations.timeDifference() == ", 10h 30m ahead", "Difference was unexpectedly: \(operations.timeDifference())") + XCTAssertTrue(californiaOperations.timeDifference() == ", 2h behind", "Difference was unexpectedly: \(californiaOperations.timeDifference())") + XCTAssertTrue(floridaOperations.timeDifference() == ", an hour ahead", "Difference was unexpectedly: \(floridaOperations.timeDifference())") + XCTAssertTrue(aucklandOperations.timeDifference() == ", 17h ahead", "Difference was unexpectedly: \(aucklandOperations.timeDifference())") + XCTAssertTrue(omahaOperations.timeDifference() == "", "Difference was unexpectedly: \(omahaOperations.timeDifference())") } func testSunriseSunset() { diff --git a/Clocker/Overall App/Themer.swift b/Clocker/Overall App/Themer.swift index 688cd54..cf14540 100644 --- a/Clocker/Overall App/Themer.swift +++ b/Clocker/Overall App/Themer.swift @@ -516,7 +516,11 @@ extension Themer { } func resetModernSliderImage() -> NSImage? { - return symbolImage(for: "xmark.circle.fill") + if let xmarkImage = symbolImage(for: "xmark.circle.fill") { + return xmarkImage + } + + return removeImage() } private func symbolImage(for name: String) -> NSImage? { diff --git a/Clocker/Panel/ParentPanelController+ModernSlider.swift b/Clocker/Panel/ParentPanelController+ModernSlider.swift index 2a569b3..90012b9 100644 --- a/Clocker/Panel/ParentPanelController+ModernSlider.swift +++ b/Clocker/Panel/ParentPanelController+ModernSlider.swift @@ -18,8 +18,14 @@ extension ParentPanelController: NSCollectionViewDataSource { extension ParentPanelController { func setupModernSliderIfNeccessary() { if modernSlider != nil { - resetModernSliderButton.image = Themer.shared().resetModernSliderImage() - + if #available(OSX 11.0, *) { + resetModernSliderButton.image = Themer.shared().resetModernSliderImage() + } else { + resetModernSliderButton.layer?.backgroundColor = NSColor.lightGray.cgColor + resetModernSliderButton.layer?.masksToBounds = true + resetModernSliderButton.layer?.cornerRadius = resetModernSliderButton.frame.width / 2 + } + goBackwardsButton.image = Themer.shared().goBackwardsImage() goForwardButton.image = Themer.shared().goForwardsImage() @@ -29,6 +35,7 @@ extension ParentPanelController { goBackwardsButton.toolTip = "Navigate 15 mins back" goForwardButton.toolTip = "Navigate 15 mins forward" + modernSlider.wantsLayer = true // Required for animating reset to center modernSlider.enclosingScrollView?.scrollerInsets = NSEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) modernSlider.enclosingScrollView?.backgroundColor = NSColor.clear modernSlider.setAccessibility("ModernSlider") From f5cbc1f48c9e1ba33c4c55c3fb785447aee663b7 Mon Sep 17 00:00:00 2001 From: Abhishek Banthia <8280282+n0shake@users.noreply.github.com> Date: Sat, 14 Aug 2021 11:57:01 -0500 Subject: [PATCH 4/4] Fix tests. --- Clocker/ClockerUITests/PanelTests.swift | 4 ++-- Clocker/Preferences/General/PreferencesViewController.swift | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Clocker/ClockerUITests/PanelTests.swift b/Clocker/ClockerUITests/PanelTests.swift index ad42cbb..f4c98d7 100644 --- a/Clocker/ClockerUITests/PanelTests.swift +++ b/Clocker/ClockerUITests/PanelTests.swift @@ -69,7 +69,7 @@ class PanelTests: XCTestCase { func testEnablingUpcomingEventView() { app.tapMenubarIcon() - let upcomingView = app.buttons["CalendarAccessory"] + let upcomingView = app.collectionViews["UpcomingEventCollectionView"] let beforeUpcomingEventViewExist = upcomingView.exists app.buttons["Preferences"].click() @@ -101,7 +101,7 @@ class PanelTests: XCTestCase { app.tapMenubarIcon() - let newUpcomingEventView = app.buttons["CalendarAccessory"] + let newUpcomingEventView = app.collectionViews["UpcomingEventCollectionView"] let afterUpcomingEventViewExists = newUpcomingEventView.exists XCTAssertNotEqual(afterUpcomingEventViewExists, beforeUpcomingEventViewExist) diff --git a/Clocker/Preferences/General/PreferencesViewController.swift b/Clocker/Preferences/General/PreferencesViewController.swift index 294e00f..107a6ae 100644 --- a/Clocker/Preferences/General/PreferencesViewController.swift +++ b/Clocker/Preferences/General/PreferencesViewController.swift @@ -45,7 +45,7 @@ class PreferencesViewController: ParentViewController { let dictionary = NSDictionary(contentsOfFile: path), let apiKey = dictionary["GeocodingKey"] as? String else { -// assertionFailure("Unable to find the API key") + assertionFailure("Unable to find the API key") return "" } return apiKey @@ -259,7 +259,7 @@ class PreferencesViewController: ParentViewController { private func setupShortcutObserver() { let defaults = NSUserDefaultsController.shared - + recorderControl.setAccessibility("ShortcutControl") recorderControl.bind(NSBindingName.value, to: defaults, withKeyPath: PreferencesConstants.hotKeyPathIdentifier,