Browse Source

More tests..

pull/113/head
Abhishek Banthia 3 years ago
parent
commit
3e7c4be100
  1. 14
      Clocker/ClockerUnitTests/ThemerTests.swift
  2. 23
      Clocker/Overall App/Themer.swift

14
Clocker/ClockerUnitTests/ThemerTests.swift

@ -6,6 +6,20 @@ import XCTest
class ThemerTests: XCTestCase { class ThemerTests: XCTestCase {
@available(macOS 10.14, *)
func testSettingTheme() {
let subject = Themer(index: 0)
XCTAssertEqual(NSAppearance(named: .aqua), NSAppearance(named: .aqua))
// Set the same theme; this should return early
subject.set(theme: 0)
// Set the theme to dark theme
subject.set(theme: 1)
let expectedApperance = NSAppearance(named: .darkAqua)
XCTAssertEqual(expectedApperance, NSApp.appearance)
}
func testLightTheme() throws { func testLightTheme() throws {
let subject = Themer(index: 0) // 0 is for light theme let subject = Themer(index: 0) // 0 is for light theme
let expectedSliderKnobColor = NSColor(deviceRed: 255.0, green: 255.0, blue: 255, alpha: 0.9) let expectedSliderKnobColor = NSColor(deviceRed: 255.0, green: 255.0, blue: 255, alpha: 0.9)

23
Clocker/Overall App/Themer.swift

@ -168,20 +168,11 @@ extension Themer {
return symbolImageForShutdown return symbolImageForShutdown
} }
if #available(macOS 10.14, *) { return fallbackImageProvider(NSImage(named: NSImage.Name("PowerIcon"))!,
switch themeIndex { NSImage(named: NSImage.Name("PowerIcon-White"))!,
case .light: NSImage(named: NSImage.Name("Power"))!,
return NSImage(named: NSImage.Name("PowerIcon"))! NSImage(named: NSImage.Name("PowerIcon"))!,
case .dark, .solarizedDark: NSImage(named: NSImage.Name("PowerIcon-White"))!)
return NSImage(named: NSImage.Name("PowerIcon-White"))!
case .system:
return NSImage(named: NSImage.Name("Power"))!
case .solarizedLight:
return NSImage(named: NSImage.Name("PowerIcon"))!
}
}
return themeIndex == .light ? NSImage(named: NSImage.Name("PowerIcon"))! : NSImage(named: NSImage.Name("PowerIcon-White"))!
} }
func preferenceImage() -> NSImage { func preferenceImage() -> NSImage {
@ -257,11 +248,11 @@ extension Themer {
case .system: case .system:
return NSImage(named: NSImage.Name("Dynamic Menubar"))! return NSImage(named: NSImage.Name("Dynamic Menubar"))!
default: default:
return UserDefaults.standard.string(forKey: "AppleInterfaceStyle") == "Dark" ? NSImage(named: NSImage.Name("Dark Menubar"))! : NSImage(named: NSImage.Name("Light Menubar"))! return retrieveCurrentSystem() == .dark ? NSImage(named: NSImage.Name("Dark Menubar"))! : NSImage(named: NSImage.Name("Light Menubar"))!
} }
} }
return UserDefaults.standard.string(forKey: "AppleInterfaceStyle") == "Dark" ? NSImage(named: NSImage.Name("Dark Menubar"))! : NSImage(named: NSImage.Name("Light Menubar"))! return retrieveCurrentSystem() == .dark ? NSImage(named: NSImage.Name("Dark Menubar"))! : NSImage(named: NSImage.Name("Light Menubar"))!
} }
func extraOptionsHighlightedImage() -> NSImage { func extraOptionsHighlightedImage() -> NSImage {

Loading…
Cancel
Save