Browse Source

Swiftformat.

pull/113/head
Abhishek Banthia 3 years ago
parent
commit
4dcd80e4e1
  1. 2
      Clocker/AppDelegate.swift
  2. 2
      Clocker/ClockerUnitTests/ClockerUnitTests.swift
  3. 19
      Clocker/ClockerUnitTests/EventInfoTests.swift
  4. 39
      Clocker/ClockerUnitTests/StandardMenubarHandlerTests.swift
  5. 2
      Clocker/Onboarding/OnboardingParentViewController.swift
  6. 6
      Clocker/Onboarding/OnboardingSearchController.swift
  7. 2
      Clocker/Overall App/AppKit + Additions.swift
  8. 4
      Clocker/Overall App/DataStore.swift
  9. 2
      Clocker/Panel/PanelController.swift
  10. 2
      Clocker/Panel/ParentPanelController.swift
  11. 2
      Clocker/Preferences/About/AboutViewController.swift
  12. 4
      Clocker/Preferences/App Feedback/AppFeedbackWindowController.swift

2
Clocker/AppDelegate.swift

@ -110,7 +110,7 @@ open class AppDelegate: NSObject, NSApplicationDelegate {
if controller != nil {
controller = nil
}
// Check if another instance of the app is already running. If so, then stop this one.
checkIfAppIsAlreadyOpen()

2
Clocker/ClockerUnitTests/ClockerUnitTests.swift

@ -406,7 +406,7 @@ class ClockerUnitTests: XCTestCase {
func testToasty() {
let view = NSView(frame: CGRect.zero)
view.makeToast("Hello, this is a toast")
XCTAssertEqual(view.subviews.first?.accessibilityIdentifier(), "ToastView")
XCTAssertEqual(view.subviews.first?.accessibilityIdentifier(), "ToastView")
let toastExpectation = expectation(description: "Toast View should hide after 1 second")
let result = XCTWaiter.wait(for: [toastExpectation], timeout: 1.5) // Set 1.5 seconds here for a little leeway
if result == XCTWaiter.Result.timedOut {

19
Clocker/ClockerUnitTests/EventInfoTests.swift

@ -1,8 +1,8 @@
// Copyright © 2015 Abhishek Banthia
import XCTest
@testable import Clocker
import EventKit
import XCTest
class EventInfoTests: XCTestCase {
private let eventStore = EKEventStore()
@ -12,7 +12,7 @@ class EventInfoTests: XCTestCase {
let mockEvent = EKEvent(eventStore: eventStore)
mockEvent.title = "Mock Title"
mockEvent.startDate = Date().add(futureChunk)
let mockEventInfo = EventInfo(event: mockEvent,
isAllDay: false,
meetingURL: nil,
@ -20,13 +20,13 @@ class EventInfoTests: XCTestCase {
XCTAssert(mockEventInfo.metadataForMeeting() == "in 5m",
"Metadata for meeting: \(mockEventInfo.metadataForMeeting()) doesn't match expectation")
}
func testMetadataForUpcomingEventHappeningInTenSeconds() throws {
let futureChunk = TimeChunk(seconds: 10, minutes: 0, hours: 0, days: 0, weeks: 0, months: 0, years: 0)
let mockEvent = EKEvent(eventStore: eventStore)
mockEvent.title = "Mock Title"
mockEvent.startDate = Date().add(futureChunk)
let mockEventInfo = EventInfo(event: mockEvent,
isAllDay: false,
meetingURL: nil,
@ -40,7 +40,7 @@ class EventInfoTests: XCTestCase {
let mockEvent = EKEvent(eventStore: eventStore)
mockEvent.title = "Mock Title"
mockEvent.startDate = Date().subtract(pastChunk)
let mockEventInfo = EventInfo(event: mockEvent,
isAllDay: false,
meetingURL: nil,
@ -48,13 +48,13 @@ class EventInfoTests: XCTestCase {
XCTAssert(mockEventInfo.metadataForMeeting() == "started +2m.",
"Metadata for meeting: \(mockEventInfo.metadataForMeeting()) doesn't match expectation")
}
func testMetadataForEventPastTenMinutes() throws {
let pastChunk = TimeChunk(seconds: 10, minutes: 10, hours: 0, days: 0, weeks: 0, months: 0, years: 0)
let mockEvent = EKEvent(eventStore: eventStore)
mockEvent.title = "Mock Title"
mockEvent.startDate = Date().subtract(pastChunk)
let mockEventInfo = EventInfo(event: mockEvent,
isAllDay: false,
meetingURL: nil,
@ -62,13 +62,13 @@ class EventInfoTests: XCTestCase {
XCTAssert(mockEventInfo.metadataForMeeting() == "Error",
"Metadata for meeting: \(mockEventInfo.metadataForMeeting()) doesn't match expectation")
}
func testMetadataForEventHappeningTomorrow() throws {
let pastChunk = TimeChunk(seconds: 10, minutes: 0, hours: 25, days: 0, weeks: 0, months: 0, years: 0)
let mockEvent = EKEvent(eventStore: eventStore)
mockEvent.title = "Mock Title"
mockEvent.startDate = Date().add(pastChunk)
let mockEventInfo = EventInfo(event: mockEvent,
isAllDay: false,
meetingURL: nil,
@ -76,5 +76,4 @@ class EventInfoTests: XCTestCase {
XCTAssert(mockEventInfo.metadataForMeeting() == "in 25h",
"Metadata for meeting: \(mockEventInfo.metadataForMeeting()) doesn't match expectation")
}
}

39
Clocker/ClockerUnitTests/StandardMenubarHandlerTests.swift

@ -1,14 +1,14 @@
// Copyright © 2015 Abhishek Banthia
import CoreModelKit
import XCTest
import EventKit
import XCTest
@testable import Clocker
class StandardMenubarHandlerTests: XCTestCase {
private let eventStore = EKEventStore()
private let mumbai = ["customLabel": "Ghar",
"formattedAddress": "Mumbai",
"place_id": "ChIJwe1EZjDG5zsRaYxkjY_tpF0",
@ -116,73 +116,68 @@ class StandardMenubarHandlerTests: XCTestCase {
let menubarHandler = MenubarTitleProvider(with: store)
XCTAssertNotNil(menubarHandler.titleForMenubar())
}
func testFormattedUpcomingEvent() {
let store = makeMockStore()
let futureChunk = TimeChunk(seconds: 10, minutes: 10, hours: 0, days: 0, weeks: 0, months: 0, years: 0)
let mockEvent = EKEvent(eventStore: eventStore)
mockEvent.title = "Mock Title"
mockEvent.startDate = Date().add(futureChunk)
let menubarHandler = MenubarTitleProvider(with: store)
XCTAssert(menubarHandler.format(event: mockEvent) == "Mock Title in 10m",
"Suffix \(menubarHandler.format(event: mockEvent)) doesn't match expectation")
}
func testUpcomingEventHappeningWithinOneMinute() {
let store = makeMockStore()
let futureChunk = TimeChunk(seconds: 10, minutes: 1, hours: 0, days: 0, weeks: 0, months: 0, years: 0)
let mockEvent = EKEvent(eventStore: eventStore)
mockEvent.title = "Mock Title"
mockEvent.startDate = Date().add(futureChunk)
let menubarHandler = MenubarTitleProvider(with: store)
XCTAssert(menubarHandler.format(event: mockEvent) == "Mock Title in 1m",
"Suffix \(menubarHandler.format(event: mockEvent)) doesn't match expectation")
}
func testUpcomingEventHappeningWithinSeconds() {
let store = makeMockStore()
let futureChunk = TimeChunk(seconds: 10, minutes: 0, hours: 0, days: 0, weeks: 0, months: 0, years: 0)
let mockEvent = EKEvent(eventStore: eventStore)
mockEvent.title = "Mock Title"
mockEvent.startDate = Date().add(futureChunk)
let menubarHandler = MenubarTitleProvider(with: store)
XCTAssert(menubarHandler.format(event: mockEvent) == "Mock Title starts now.",
"Suffix \(menubarHandler.format(event: mockEvent)) doesn't match expectation")
}
func testEmptyUpcomingEvent() {
let store = makeMockStore()
let futureChunk = TimeChunk(seconds: 10, minutes: 0, hours: 0, days: 0, weeks: 0, months: 0, years: 0)
let mockEvent = EKEvent(eventStore: eventStore)
mockEvent.startDate = Date().add(futureChunk)
let menubarHandler = MenubarTitleProvider(with: store)
XCTAssert(menubarHandler.format(event: mockEvent) == CLEmptyString,
"Suffix \(menubarHandler.format(event: mockEvent)) doesn't match expectation")
}
func testLongUpcomingEvent() {
let store = makeMockStore()
let futureChunk = TimeChunk(seconds: 10, minutes: 0, hours: 0, days: 0, weeks: 0, months: 0, years: 0)
let mockEvent = EKEvent(eventStore: eventStore)
mockEvent.title = "Really long calendar event title that longer than the longest name"
mockEvent.startDate = Date().add(futureChunk)
let menubarHandler = MenubarTitleProvider(with: store)
XCTAssert(menubarHandler.format(event: mockEvent) == "Really long calendar event tit... starts now.",
"Suffix \(menubarHandler.format(event: mockEvent)) doesn't match expectation")
}
}

2
Clocker/Onboarding/OnboardingParentViewController.swift

@ -223,7 +223,7 @@ class OnboardingParentViewController: NSViewController {
if ProcessInfo.processInfo.arguments.contains(CLOnboaringTestsLaunchArgument) == false {
UserDefaults.standard.set(true, forKey: CLShowOnboardingFlow)
}
// Install the menubar option!
let appDelegate = NSApplication.shared.delegate as? AppDelegate
appDelegate?.continueUsually()

6
Clocker/Onboarding/OnboardingSearchController.swift

@ -40,7 +40,7 @@ class OnboardingSearchController: NSViewController {
super.viewDidLoad()
view.wantsLayer = true
resultsTableView.isHidden = true
resultsTableView.delegate = self
resultsTableView.setAccessibility("ResultsTableView")
@ -69,12 +69,12 @@ class OnboardingSearchController: NSViewController {
setupUndoButton()
}
override func viewWillAppear() {
super.viewWillAppear()
searchResultsDataSource = SearchDataSource(with: searchBar, location: .onboarding)
}
override func viewWillDisappear() {
super.viewWillDisappear()
searchResultsDataSource = nil

2
Clocker/Overall App/AppKit + Additions.swift

@ -21,7 +21,7 @@ extension NSTextField {
}
extension NSFont {
func size(_ string: String, _ width: Double, attributes: [NSAttributedString.Key: AnyObject]) -> CGSize {
func size(for string: String, width: Double, attributes: [NSAttributedString.Key: AnyObject]) -> CGSize {
let size = CGSize(width: width,
height: Double.greatestFiniteMagnitude)

4
Clocker/Overall App/DataStore.swift

@ -71,11 +71,11 @@ class DataStore: NSObject {
let cloudTimezones = ubiquitousStore?.object(forKey: CLDefaultPreferenceKey) as? [Data]
let cloudLastUpdateDate = (ubiquitousStore?.object(forKey: CLUbiquitousStoreLastUpdateKey) as? Date) ?? Date()
let defaultsLastUpdateDate = (ubiquitousStore?.object(forKey: CLUserDefaultsLastUpdateKey) as? Date) ?? Date()
if cloudTimezones == currentTimezones {
Logger.info("Ubiquitous Store timezones aren't equal to current timezones")
}
if defaultsLastUpdateDate.isLaterThanOrEqual(to: cloudLastUpdateDate) {
Logger.info("Ubiquitous Store is stale as compared to User Defaults")
}

2
Clocker/Panel/PanelController.swift

@ -74,7 +74,7 @@ class PanelController: ParentPanelController {
super.dismissRowActions()
updateDefaultPreferences()
setupUpcomingEventViewCollectionViewIfNeccesary()
if DataStore.shared().timezones().isEmpty || DataStore.shared().shouldDisplay(.futureSlider) == false {

2
Clocker/Panel/ParentPanelController.swift

@ -1151,7 +1151,7 @@ extension ParentPanelController: AppFeedbackWindowControllerDelegate {
func appFeedbackWindowWillClose() {
feedbackWindow = nil
}
func appFeedbackWindoEntryPoint() -> String {
return "parent_panel_controller"
}

2
Clocker/Preferences/About/AboutViewController.swift

@ -157,7 +157,7 @@ extension AboutViewController: AppFeedbackWindowControllerDelegate {
func appFeedbackWindowWillClose() {
feedbackWindow = nil
}
func appFeedbackWindoEntryPoint() -> String {
return "about_view_controller"
}

4
Clocker/Preferences/App Feedback/AppFeedbackWindowController.swift

@ -210,7 +210,7 @@ class AppFeedbackWindowController: NSWindowController {
AppFeedbackConstants.CLClockerVersion: versionInfo,
AppFeedbackConstants.CLAppFeedbackDateProperty: todaysDate(),
AppFeedbackConstants.CLAppFeedbackUserPreferences: generateUserPreferences(),
AppFeedbackConstants.CLFeedbackEntryPoint: appFeedbackWindowDelegate?.appFeedbackWindoEntryPoint() ?? "Error"
AppFeedbackConstants.CLFeedbackEntryPoint: appFeedbackWindowDelegate?.appFeedbackWindoEntryPoint() ?? "Error",
]
}
@ -228,7 +228,7 @@ class AppFeedbackWindowController: NSWindowController {
#if DEBUG
Logger.info("Sending a feedback in Debug builds will lead to a no-op")
#endif
guard let identifier = serialNumber else {
assertionFailure("Serial Identifier was unexpectedly nil")
return

Loading…
Cancel
Save