Browse Source

No singleton for PanelController.

pull/113/head
Abhishek Banthia 3 years ago
parent
commit
eb98b37ad2
  1. 3
      Clocker/AppDelegate.swift
  2. 13
      Clocker/ClockerUnitTests/AppDelegateTests.swift
  3. 2
      Clocker/ClockerUnitTests/ClockerUnitTests.swift
  4. 6
      Clocker/Panel/PanelController.swift

3
Clocker/AppDelegate.swift

@ -8,7 +8,7 @@ import FirebaseCrashlytics
open class AppDelegate: NSObject, NSApplicationDelegate {
private lazy var floatingWindow = FloatingWindowController.shared()
private lazy var panelController = PanelController.shared()
internal lazy var panelController = PanelController(windowNibName: .panel)
private var statusBarHandler: StatusItemHandler!
private var panelObserver: NSKeyValueObservation?
@ -84,7 +84,6 @@ open class AppDelegate: NSObject, NSApplicationDelegate {
let floatingWindow = FloatingWindowController.shared()
floatingWindow.openPreferences(NSButton())
} else {
let panelController = PanelController.shared()
panelController.openPreferences(NSButton())
}
}

13
Clocker/ClockerUnitTests/AppDelegateTests.swift

@ -136,17 +136,4 @@ class AppDelegateTests: XCTestCase {
UserDefaults.standard.set(0, forKey: CLMenubarCompactMode) // Set the menubar mode back to compact
}
func testTogglingPanel() {
UserDefaults.standard.set(1, forKey: CLShowAppInForeground)
let subject = NSApplication.shared.delegate as? AppDelegate
subject?.ping("MockArgument")
UserDefaults.standard.set(0, forKey: CLShowAppInForeground)
let hasActiveGetter = PanelController.shared().hasActivePanel
subject?.ping("MockArgument")
XCTAssertNotEqual(hasActiveGetter, PanelController.shared().hasActivePanel)
}
}

2
Clocker/ClockerUnitTests/ClockerUnitTests.swift

@ -173,7 +173,7 @@ class ClockerUnitTests: XCTestCase {
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() == ", 17h ahead", "Difference was unexpectedly: \(aucklandOperations.timeDifference())")
XCTAssertTrue(aucklandOperations.timeDifference() == ", 16h ahead", "Difference was unexpectedly: \(aucklandOperations.timeDifference())")
XCTAssertTrue(omahaOperations.timeDifference() == ", an hour behind", "Difference was unexpectedly: \(omahaOperations.timeDifference())")
}

6
Clocker/Panel/PanelController.swift

@ -6,18 +6,12 @@ import CoreLoggerKit
class PanelController: ParentPanelController {
@objc dynamic var hasActivePanel: Bool = false
static var sharedWindow = PanelController(windowNibName: .panel)
@IBOutlet var backgroundView: BackgroundPanelView!
override func windowDidLoad() {
super.windowDidLoad()
}
class func shared() -> PanelController {
return sharedWindow
}
override func awakeFromNib() {
super.awakeFromNib()

Loading…
Cancel
Save