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

@ -5,6 +5,20 @@ import XCTest
@testable import Clocker
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 {
let subject = Themer(index: 0) // 0 is for light theme

23
Clocker/Overall App/Themer.swift

@ -168,20 +168,11 @@ extension Themer {
return symbolImageForShutdown
}
if #available(macOS 10.14, *) {
switch themeIndex {
case .light:
return NSImage(named: NSImage.Name("PowerIcon"))!
case .dark, .solarizedDark:
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"))!
return fallbackImageProvider(NSImage(named: NSImage.Name("PowerIcon"))!,
NSImage(named: NSImage.Name("PowerIcon-White"))!,
NSImage(named: NSImage.Name("Power"))!,
NSImage(named: NSImage.Name("PowerIcon"))!,
NSImage(named: NSImage.Name("PowerIcon-White"))!)
}
func preferenceImage() -> NSImage {
@ -257,11 +248,11 @@ extension Themer {
case .system:
return NSImage(named: NSImage.Name("Dynamic Menubar"))!
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 {

Loading…
Cancel
Save