Browse Source

Add more tests.

pull/113/head
Abhishek Banthia 3 years ago
parent
commit
d2bb0d8109
  1. 17
      Clocker/ClockerUnitTests/ClockerUnitTests.swift
  2. 7
      Clocker/Panel/UI/NoTimezoneView.swift
  3. 6
      Clocker/Preferences/About/UnderlinedButton.swift

17
Clocker/ClockerUnitTests/ClockerUnitTests.swift

@ -415,4 +415,21 @@ class ClockerUnitTests: XCTestCase {
XCTAssertTrue(view.subviews.isEmpty) XCTAssertTrue(view.subviews.isEmpty)
} }
} }
func testPointingHandButton() {
let sampleRect = CGRect(x: 0, y: 0, width: 200, height: 200)
let pointingHandCursorButton = UnderlinedButton(frame: CGRect.zero)
pointingHandCursorButton.draw(sampleRect)
pointingHandCursorButton.resetCursorRects()
XCTAssertEqual(pointingHandCursorButton.pointingHandCursor, NSCursor.pointingHand)
}
func testNoTimezoneView() {
let sampleRect = CGRect(x: 0, y: 0, width: 200, height: 200)
let subject = NoTimezoneView(frame: sampleRect)
// Perform a layout to add subviews
subject.layout()
XCTAssertEqual(subject.subviews.count, 2) // Two textfields
XCTAssertEqual(subject.subviews.first?.layer?.animationKeys(), ["notimezone.emoji"])
}
} }

7
Clocker/Panel/UI/NoTimezoneView.swift

@ -66,12 +66,5 @@ class NoTimezoneView: NSView {
emoji.layer?.removeAllAnimations() emoji.layer?.removeAllAnimations()
emoji.layer?.add(emojiAnimation, forKey: "notimezone.emoji") emoji.layer?.add(emojiAnimation, forKey: "notimezone.emoji")
let shadowScale = CABasicAnimation(keyPath: "transform.scale")
shadowScale.toValue = 0.9
shadowScale.repeatCount = .greatestFiniteMagnitude
shadowScale.autoreverses = true
shadowScale.duration = 1
shadowScale.timingFunction = function
} }
} }

6
Clocker/Preferences/About/UnderlinedButton.swift

@ -3,17 +3,13 @@
import Cocoa import Cocoa
class UnderlinedButton: NSButton { class UnderlinedButton: NSButton {
var cursor: NSCursor? = NSCursor.pointingHand let pointingHandCursor: NSCursor = NSCursor.pointingHand
override func draw(_ dirtyRect: NSRect) { override func draw(_ dirtyRect: NSRect) {
super.draw(dirtyRect) super.draw(dirtyRect)
} }
override func resetCursorRects() { override func resetCursorRects() {
if let pointingHandCursor = cursor {
addCursorRect(bounds, cursor: pointingHandCursor) addCursorRect(bounds, cursor: pointingHandCursor)
} else {
super.resetCursorRects()
}
} }
} }

Loading…
Cancel
Save