Browse Source

Refactoring..

pull/113/head
Abhishek Banthia 3 years ago
parent
commit
d660558195
  1. 531
      Clocker/ClockerUnitTests/ThemerTests.swift

531
Clocker/ClockerUnitTests/ThemerTests.swift

@ -5,346 +5,263 @@ import XCTest
@testable import Clocker @testable import Clocker
class ThemerTests: XCTestCase { class ThemerTests: XCTestCase {
private struct ThemeExpectations {
// Colors
let expectedSliderKnobColor: NSColor
let expectedSliderRightColor: NSColor
let expectedBackgroundColor: NSColor
let expectedTextColor: NSColor
let expectedTextBackgroundColor: NSColor
// Popover Appearance
let expectedPopoverApperarance: NSAppearance
// Images
let expectedShutdownImageName: String
let expectedPreferenceImageName: String
let expectedPinImageName: String
let expectedSunriseImageName: String
let expectedSunsetImageName: String
let expectedRemoveImageName: String
let expectedExtraOptionsImage: String
let expectedMenubarOnboardingImage: String
let expectedExtraOptionsHighlightedImage: String
let expectedSharingImage: String
let expectedCurrentLocationImage: String
let expectedAddImage: String
let expectedAddImageHighlighted: String
let expectedPrivacyTabImage: String
let expectedAppearanceTabImage: String
let expectedCalendarTabImage: String
let expectedGeneralTabImage: String
let expectedAboutTabImage: String
let expectedVideoCallImage: String
let expectedFilledTrashImage: String
let expectedBackwardsImage: String
let expectedForwardsImage: String
let expectedResetSliderImage: String
}
@available(macOS 10.14, *) @available(macOS 10.14, *)
func testSettingTheme() { func testSettingTheme() {
// Set to some random number should set to 0 // Set to some random number should set to 0
let subject = Themer(index: 124) let subject = Themer(index: 124)
XCTAssertEqual(NSAppearance(named: .aqua), NSAppearance(named: .aqua)) XCTAssertEqual(NSAppearance(named: .aqua), NSAppearance(named: .aqua))
// Set the same theme; this should return early // Set the same theme; this should return early
subject.set(theme: 0) subject.set(theme: 0)
// Set the theme to dark theme // Set the theme to dark theme
subject.set(theme: 1) subject.set(theme: 1)
let expectedApperance = NSAppearance(named: .darkAqua) let expectedApperance = NSAppearance(named: .darkAqua)
XCTAssertEqual(expectedApperance, NSApp.appearance) 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 expectedThemeElements = ThemeExpectations(expectedSliderKnobColor: NSColor(deviceRed: 255.0, green: 255.0, blue: 255, alpha: 0.9),
let expectedSliderRightColor = NSColor.gray expectedSliderRightColor: NSColor.gray, expectedBackgroundColor: NSColor.white,
let expectedBackgroundColor = NSColor.white expectedTextColor: NSColor.black,
let expectedTextColor = NSColor.black expectedTextBackgroundColor: NSColor(deviceRed: 241.0 / 255.0, green: 241.0 / 255.0, blue: 241.0 / 255.0, alpha: 1.0),
let expectedTextBackgroundColor = NSColor(deviceRed: 241.0 / 255.0, green: 241.0 / 255.0, blue: 241.0 / 255.0, alpha: 1.0) expectedPopoverApperarance: NSAppearance(named: NSAppearance.Name.vibrantLight)!,
expectedShutdownImageName: "ellipsis.circle",
let expectedShutdownImageName = "ellipsis.circle" expectedPreferenceImageName: "plus",
let expectedPreferenceImageName = "plus" expectedPinImageName: "macwindow.on.rectangle",
let expectedPinImageName = "macwindow.on.rectangle" expectedSunriseImageName: "sunrise.fill",
let expectedSunriseImageName = "sunrise.fill" expectedSunsetImageName: "sunset.fill",
let expectedSunsetImageName = "sunset.fill" expectedRemoveImageName: "xmark",
let expectedRemoveImageName = "xmark" expectedExtraOptionsImage: "Extra",
let expectedExtraOptionsImage = "Extra" expectedMenubarOnboardingImage: "Light Menubar",
let expectedMenubarOnboardingImage = "Light Menubar" expectedExtraOptionsHighlightedImage: "ExtraHighlighted",
let expectedExtraOptionsHighlightedImage = "ExtraHighlighted" expectedSharingImage: "square.and.arrow.up.on.square.fill",
let expectedSharingImage = "square.and.arrow.up.on.square.fill" expectedCurrentLocationImage: "location.fill",
let expectedCurrentLocationImage = "location.fill" expectedAddImage: "plus",
let expectedPopoverApperarance = NSAppearance(named: NSAppearance.Name.vibrantLight)! expectedAddImageHighlighted: "Add Highlighted",
let expectedAddImage = "plus" expectedPrivacyTabImage: "lock",
let expectedAddImageHighlighted = "Add Highlighted" expectedAppearanceTabImage: "eye",
let expectedPrivacyTabImage = "lock" expectedCalendarTabImage: "calendar",
let expectedAppearanceTabImage = "eye" expectedGeneralTabImage: "gearshape",
let expectedCalendarTabImage = "calendar" expectedAboutTabImage: "info.circle",
let expectedGeneralTabImage = "gearshape" expectedVideoCallImage: "video.circle.fill",
let expectedAboutTabImage = "info.circle" expectedFilledTrashImage: "trash.fill",
let expectedVideoCallImage = "video.circle.fill" expectedBackwardsImage: "gobackward.15",
let expectedFilledTrashImage = "trash.fill" expectedForwardsImage: "goforward.15",
let expectedBackwardsImage = "gobackward.15" expectedResetSliderImage: "xmark.circle.fill")
let expectedForwardsImage = "goforward.15" testSubject(subject: subject, withExpectatations: expectedThemeElements)
let expectedResetSliderImage = "xmark.circle.fill"
XCTAssertEqual(subject.sliderKnobColor(), expectedSliderKnobColor)
XCTAssertEqual(subject.sliderRightColor(), expectedSliderRightColor)
XCTAssertEqual(subject.mainBackgroundColor(), expectedBackgroundColor)
XCTAssertEqual(subject.mainTextColor(), expectedTextColor)
XCTAssertEqual(subject.textBackgroundColor(), expectedTextBackgroundColor)
XCTAssertEqual(subject.shutdownImage().accessibilityDescription, expectedShutdownImageName)
XCTAssertEqual(subject.preferenceImage().accessibilityDescription, expectedPreferenceImageName)
XCTAssertEqual(subject.pinImage().accessibilityDescription, expectedPinImageName)
XCTAssertEqual(subject.sunriseImage().accessibilityDescription, expectedSunriseImageName)
XCTAssertEqual(subject.sunsetImage().accessibilityDescription, expectedSunsetImageName)
XCTAssertEqual(subject.removeImage().accessibilityDescription, expectedRemoveImageName)
XCTAssertEqual(subject.extraOptionsImage().name(), expectedExtraOptionsImage)
XCTAssertEqual(subject.menubarOnboardingImage().name(), expectedMenubarOnboardingImage)
XCTAssertEqual(subject.extraOptionsHighlightedImage().name(), expectedExtraOptionsHighlightedImage)
XCTAssertEqual(subject.sharingImage().accessibilityDescription, expectedSharingImage)
XCTAssertEqual(subject.currentLocationImage().accessibilityDescription, expectedCurrentLocationImage)
XCTAssertEqual(subject.popoverAppearance(), expectedPopoverApperarance)
XCTAssertEqual(subject.addImage().accessibilityDescription, expectedAddImage)
XCTAssertEqual(subject.addImageHighlighted().name(), expectedAddImageHighlighted)
XCTAssertEqual(subject.privacyTabImage().accessibilityDescription, expectedPrivacyTabImage)
XCTAssertEqual(subject.appearanceTabImage().accessibilityDescription, expectedAppearanceTabImage)
XCTAssertEqual(subject.calendarTabImage().accessibilityDescription, expectedCalendarTabImage)
XCTAssertEqual(subject.generalTabImage()?.accessibilityDescription, expectedGeneralTabImage)
XCTAssertEqual(subject.aboutTabImage()?.accessibilityDescription, expectedAboutTabImage)
XCTAssertEqual(subject.videoCallImage()?.accessibilityDescription, expectedVideoCallImage)
XCTAssertEqual(subject.filledTrashImage()?.accessibilityDescription, expectedFilledTrashImage)
XCTAssertEqual(subject.goBackwardsImage()?.accessibilityDescription, expectedBackwardsImage)
XCTAssertEqual(subject.goForwardsImage()?.accessibilityDescription, expectedForwardsImage)
XCTAssertEqual(subject.resetModernSliderImage()?.accessibilityDescription, expectedResetSliderImage)
} }
func testDarkTheme() throws { func testDarkTheme() throws {
let subject = Themer(index: 1) // 1 is for dark theme let subject = Themer(index: 1) // 1 is for dark theme
let expectedSliderKnobColor = NSColor(deviceRed: 0.0, green: 0.0, blue: 0, alpha: 0.9) let expectedThemeElements = ThemeExpectations(expectedSliderKnobColor: NSColor(deviceRed: 0.0, green: 0.0, blue: 0, alpha: 0.9),
let expectedSliderRightColor = NSColor.white expectedSliderRightColor: NSColor.white,
let expectedBackgroundColor = NSColor(deviceRed: 42.0 / 255.0, green: 42.0 / 255.0, blue: 42.0 / 255.0, alpha: 1.0) expectedBackgroundColor: NSColor(deviceRed: 42.0 / 255.0, green: 42.0 / 255.0, blue: 42.0 / 255.0, alpha: 1.0),
let expectedTextColor = NSColor.white expectedTextColor: NSColor.white,
let expectedTextBackgroundColor = NSColor(deviceRed: 42.0 / 255.0, green: 55.0 / 255.0, blue: 62.0 / 255.0, alpha: 1.0) expectedTextBackgroundColor: NSColor(deviceRed: 42.0 / 255.0, green: 55.0 / 255.0, blue: 62.0 / 255.0, alpha: 1.0),
expectedPopoverApperarance: NSAppearance(named: NSAppearance.Name.vibrantDark)!,
let expectedShutdownImageName = "ellipsis.circle" expectedShutdownImageName: "ellipsis.circle",
let expectedPreferenceImageName = "plus" expectedPreferenceImageName: "plus",
let expectedPinImageName = "macwindow.on.rectangle" expectedPinImageName: "macwindow.on.rectangle",
let expectedSunriseImageName = "sunrise.fill" expectedSunriseImageName: "sunrise.fill",
let expectedSunsetImageName = "sunset.fill" expectedSunsetImageName: "sunset.fill",
let expectedRemoveImageName = "xmark" expectedRemoveImageName: "xmark",
let expectedExtraOptionsImage = "ExtraWhite" expectedExtraOptionsImage: "ExtraWhite",
let expectedMenubarOnboardingImage = "Dark Menubar" expectedMenubarOnboardingImage: "Dark Menubar",
let expectedExtraOptionsHighlightedImage = "ExtraWhiteHighlighted" expectedExtraOptionsHighlightedImage: "ExtraWhiteHighlighted",
let expectedSharingImage = "square.and.arrow.up.on.square.fill" expectedSharingImage: "square.and.arrow.up.on.square.fill",
let expectedCurrentLocationImage = "location.fill" expectedCurrentLocationImage: "location.fill",
let expectedPopoverApperarance = NSAppearance(named: NSAppearance.Name.vibrantDark)! expectedAddImage: "plus",
let expectedAddImage = "plus" expectedAddImageHighlighted: "Add White",
let expectedAddImageHighlighted = "Add White" expectedPrivacyTabImage: "lock",
let expectedPrivacyTabImage = "lock" expectedAppearanceTabImage: "eye",
let expectedAppearanceTabImage = "eye" expectedCalendarTabImage: "calendar",
let expectedCalendarTabImage = "calendar" expectedGeneralTabImage: "gearshape",
let expectedGeneralTabImage = "gearshape" expectedAboutTabImage: "info.circle",
let expectedAboutTabImage = "info.circle" expectedVideoCallImage: "video.circle.fill",
let expectedVideoCallImage = "video.circle.fill" expectedFilledTrashImage: "trash.fill",
let expectedFilledTrashImage = "trash.fill" expectedBackwardsImage: "gobackward.15",
let expectedBackwardsImage = "gobackward.15" expectedForwardsImage: "goforward.15",
let expectedForwardsImage = "goforward.15" expectedResetSliderImage: "xmark.circle.fill")
let expectedResetSliderImage = "xmark.circle.fill" testSubject(subject: subject, withExpectatations: expectedThemeElements)
XCTAssertEqual(subject.sliderKnobColor(), expectedSliderKnobColor)
XCTAssertEqual(subject.sliderRightColor(), expectedSliderRightColor)
XCTAssertEqual(subject.mainBackgroundColor(), expectedBackgroundColor)
XCTAssertEqual(subject.mainTextColor(), expectedTextColor)
XCTAssertEqual(subject.textBackgroundColor(), expectedTextBackgroundColor)
XCTAssertEqual(subject.shutdownImage().accessibilityDescription, expectedShutdownImageName)
XCTAssertEqual(subject.preferenceImage().accessibilityDescription, expectedPreferenceImageName)
XCTAssertEqual(subject.pinImage().accessibilityDescription, expectedPinImageName)
XCTAssertEqual(subject.sunriseImage().accessibilityDescription, expectedSunriseImageName)
XCTAssertEqual(subject.sunsetImage().accessibilityDescription, expectedSunsetImageName)
XCTAssertEqual(subject.removeImage().accessibilityDescription, expectedRemoveImageName)
XCTAssertEqual(subject.extraOptionsImage().name(), expectedExtraOptionsImage)
XCTAssertEqual(subject.menubarOnboardingImage().name(), expectedMenubarOnboardingImage)
XCTAssertEqual(subject.extraOptionsHighlightedImage().name(), expectedExtraOptionsHighlightedImage)
XCTAssertEqual(subject.sharingImage().accessibilityDescription, expectedSharingImage)
XCTAssertEqual(subject.currentLocationImage().accessibilityDescription, expectedCurrentLocationImage)
XCTAssertEqual(subject.popoverAppearance(), expectedPopoverApperarance)
XCTAssertEqual(subject.addImage().accessibilityDescription, expectedAddImage)
XCTAssertEqual(subject.addImageHighlighted().name(), expectedAddImageHighlighted)
XCTAssertEqual(subject.privacyTabImage().accessibilityDescription, expectedPrivacyTabImage)
XCTAssertEqual(subject.appearanceTabImage().accessibilityDescription, expectedAppearanceTabImage)
XCTAssertEqual(subject.calendarTabImage().accessibilityDescription, expectedCalendarTabImage)
XCTAssertEqual(subject.generalTabImage()?.accessibilityDescription, expectedGeneralTabImage)
XCTAssertEqual(subject.aboutTabImage()?.accessibilityDescription, expectedAboutTabImage)
XCTAssertEqual(subject.videoCallImage()?.accessibilityDescription, expectedVideoCallImage)
XCTAssertEqual(subject.filledTrashImage()?.accessibilityDescription, expectedFilledTrashImage)
XCTAssertEqual(subject.goBackwardsImage()?.accessibilityDescription, expectedBackwardsImage)
XCTAssertEqual(subject.goForwardsImage()?.accessibilityDescription, expectedForwardsImage)
XCTAssertEqual(subject.resetModernSliderImage()?.accessibilityDescription, expectedResetSliderImage)
XCTAssertEqual(subject.description, "Current Theme is \(Themer.Theme.dark)") XCTAssertEqual(subject.description, "Current Theme is \(Themer.Theme.dark)")
} }
func testSystemTheme() throws { func testSystemTheme() throws {
let currentSystemTheme = let currentSystemTheme =
UserDefaults.standard.string(forKey: "AppleInterfaceStyle")?.lowercased().contains("dark") ?? false ? Themer.Theme.dark : Themer.Theme.light UserDefaults.standard.string(forKey: "AppleInterfaceStyle")?.lowercased().contains("dark") ?? false ? Themer.Theme.dark : Themer.Theme.light
let subject = Themer(index: 2) // 2 is for system theme let subject = Themer(index: 2) // 2 is for system theme
let expectedSliderKnobColor = currentSystemTheme == .light ? NSColor(deviceRed: 255.0, green: 255.0, blue: 255, alpha: 0.9) : NSColor(deviceRed: 0.0, green: 0.0, blue: 0, alpha: 0.9) let expectedSliderKnobColor = currentSystemTheme == .light ? NSColor(deviceRed: 255.0, green: 255.0, blue: 255, alpha: 0.9) : NSColor(deviceRed: 0.0, green: 0.0, blue: 0, alpha: 0.9)
let expectedSliderRightColor = currentSystemTheme == .dark ? NSColor.white : NSColor.gray let expectedSliderRightColor = currentSystemTheme == .dark ? NSColor.white : NSColor.gray
let expectedBackgroundColor = currentSystemTheme == .dark ? NSColor.windowBackgroundColor : NSColor.white let expectedBackgroundColor = currentSystemTheme == .dark ? NSColor.windowBackgroundColor : NSColor.white
let expectedTextColor = NSColor.textColor let expectedTextColor = NSColor.textColor
let expectedTextBackgroundColor = currentSystemTheme == .light ? NSColor(deviceRed: 241.0 / 255.0, green: 241.0 / 255.0, blue: 241.0 / 255.0, alpha: 1.0) : NSColor.controlBackgroundColor let expectedTextBackgroundColor = currentSystemTheme == .light ? NSColor(deviceRed: 241.0 / 255.0, green: 241.0 / 255.0, blue: 241.0 / 255.0, alpha: 1.0) : NSColor.controlBackgroundColor
let expectedThemeElements = ThemeExpectations(expectedSliderKnobColor: expectedSliderKnobColor,
let expectedShutdownImageName = "ellipsis.circle" expectedSliderRightColor: expectedSliderRightColor,
let expectedPreferenceImageName = "plus" expectedBackgroundColor: expectedBackgroundColor,
let expectedPinImageName = "macwindow.on.rectangle" expectedTextColor: expectedTextColor,
let expectedSunriseImageName = "sunrise.fill" expectedTextBackgroundColor: expectedTextBackgroundColor,
let expectedSunsetImageName = "sunset.fill" expectedPopoverApperarance: NSAppearance.current!,
let expectedRemoveImageName = "xmark" expectedShutdownImageName: "ellipsis.circle",
let expectedExtraOptionsImage = "Extra Dynamic" expectedPreferenceImageName: "plus",
let expectedMenubarOnboardingImage = "Dynamic Menubar" expectedPinImageName: "macwindow.on.rectangle",
let expectedExtraOptionsHighlightedImage = "ExtraHighlighted Dynamic" expectedSunriseImageName: "sunrise.fill",
let expectedSharingImage = "square.and.arrow.up.on.square.fill" expectedSunsetImageName: "sunset.fill",
let expectedCurrentLocationImage = "location.fill" expectedRemoveImageName: "xmark",
let expectedPopoverApperarance = NSAppearance.current expectedExtraOptionsImage: "Extra Dynamic",
let expectedAddImage = "plus" expectedMenubarOnboardingImage: "Dynamic Menubar",
let expectedAddImageHighlighted = "Add White" expectedExtraOptionsHighlightedImage: "ExtraHighlighted Dynamic",
let expectedPrivacyTabImage = "lock" expectedSharingImage: "square.and.arrow.up.on.square.fill",
let expectedAppearanceTabImage = "eye" expectedCurrentLocationImage: "location.fill",
let expectedCalendarTabImage = "calendar" expectedAddImage: "plus",
let expectedGeneralTabImage = "gearshape" expectedAddImageHighlighted: "Add White",
let expectedAboutTabImage = "info.circle" expectedPrivacyTabImage: "lock",
let expectedVideoCallImage = "video.circle.fill" expectedAppearanceTabImage: "eye",
let expectedFilledTrashImage = "trash.fill" expectedCalendarTabImage: "calendar",
let expectedBackwardsImage = "gobackward.15" expectedGeneralTabImage: "gearshape",
let expectedForwardsImage = "goforward.15" expectedAboutTabImage: "info.circle",
let expectedResetSliderImage = "xmark.circle.fill" expectedVideoCallImage: "video.circle.fill",
expectedFilledTrashImage: "trash.fill",
XCTAssertEqual(subject.sliderKnobColor(), expectedSliderKnobColor) expectedBackwardsImage: "gobackward.15",
XCTAssertEqual(subject.sliderRightColor(), expectedSliderRightColor) expectedForwardsImage: "goforward.15",
XCTAssertEqual(subject.mainBackgroundColor(), expectedBackgroundColor) expectedResetSliderImage: "xmark.circle.fill")
XCTAssertEqual(subject.mainTextColor(), expectedTextColor) testSubject(subject: subject, withExpectatations: expectedThemeElements)
XCTAssertEqual(subject.textBackgroundColor(), expectedTextBackgroundColor)
XCTAssertEqual(subject.shutdownImage().accessibilityDescription, expectedShutdownImageName)
XCTAssertEqual(subject.preferenceImage().accessibilityDescription, expectedPreferenceImageName)
XCTAssertEqual(subject.pinImage().accessibilityDescription, expectedPinImageName)
XCTAssertEqual(subject.sunriseImage().accessibilityDescription, expectedSunriseImageName)
XCTAssertEqual(subject.sunsetImage().accessibilityDescription, expectedSunsetImageName)
XCTAssertEqual(subject.removeImage().accessibilityDescription, expectedRemoveImageName)
XCTAssertEqual(subject.extraOptionsImage().name(), expectedExtraOptionsImage)
XCTAssertEqual(subject.menubarOnboardingImage().name(), expectedMenubarOnboardingImage)
XCTAssertEqual(subject.extraOptionsHighlightedImage().name(), expectedExtraOptionsHighlightedImage)
XCTAssertEqual(subject.sharingImage().accessibilityDescription, expectedSharingImage)
XCTAssertEqual(subject.currentLocationImage().accessibilityDescription, expectedCurrentLocationImage)
XCTAssertEqual(subject.popoverAppearance(), expectedPopoverApperarance)
XCTAssertEqual(subject.addImage().accessibilityDescription, expectedAddImage)
XCTAssertEqual(subject.addImageHighlighted().name(), expectedAddImageHighlighted)
XCTAssertEqual(subject.privacyTabImage().accessibilityDescription, expectedPrivacyTabImage)
XCTAssertEqual(subject.appearanceTabImage().accessibilityDescription, expectedAppearanceTabImage)
XCTAssertEqual(subject.calendarTabImage().accessibilityDescription, expectedCalendarTabImage)
XCTAssertEqual(subject.generalTabImage()?.accessibilityDescription, expectedGeneralTabImage)
XCTAssertEqual(subject.aboutTabImage()?.accessibilityDescription, expectedAboutTabImage)
XCTAssertEqual(subject.videoCallImage()?.accessibilityDescription, expectedVideoCallImage)
XCTAssertEqual(subject.filledTrashImage()?.accessibilityDescription, expectedFilledTrashImage)
XCTAssertEqual(subject.goBackwardsImage()?.accessibilityDescription, expectedBackwardsImage)
XCTAssertEqual(subject.goForwardsImage()?.accessibilityDescription, expectedForwardsImage)
XCTAssertEqual(subject.resetModernSliderImage()?.accessibilityDescription, expectedResetSliderImage)
XCTAssertEqual(subject.description, "System Theme is \(currentSystemTheme == .dark ? Themer.Theme.dark : Themer.Theme.light)") XCTAssertEqual(subject.description, "System Theme is \(currentSystemTheme == .dark ? Themer.Theme.dark : Themer.Theme.light)")
} }
func testSolarizedLightTheme() throws { func testSolarizedLightTheme() throws {
let subject = Themer(index: 3) // 3 is for solarized light theme let subject = Themer(index: 3) // 3 is for solarized light theme
let expectedSliderKnobColor = NSColor(deviceRed: 255.0, green: 255.0, blue: 255, alpha: 0.9) let expectedThemeElements = ThemeExpectations(expectedSliderKnobColor: NSColor(deviceRed: 255.0, green: 255.0, blue: 255, alpha: 0.9),
let expectedSliderRightColor = NSColor.gray expectedSliderRightColor: NSColor.gray,
let expectedBackgroundColor = NSColor(deviceRed: 253.0 / 255.0, green: 246.0 / 255.0, blue: 227.0 / 255.0, alpha: 1.0) expectedBackgroundColor: NSColor(deviceRed: 253.0 / 255.0, green: 246.0 / 255.0, blue: 227.0 / 255.0, alpha: 1.0),
let expectedTextColor = NSColor.black expectedTextColor: NSColor.black,
let expectedTextBackgroundColor = NSColor(deviceRed: 238.0 / 255.0, green: 232.0 / 255.0, blue: 213.0 / 255.0, alpha: 1.0) expectedTextBackgroundColor: NSColor(deviceRed: 238.0 / 255.0, green: 232.0 / 255.0, blue: 213.0 / 255.0, alpha: 1.0),
expectedPopoverApperarance: NSAppearance(named: NSAppearance.Name.vibrantLight)!,
let expectedShutdownImageName = "ellipsis.circle" expectedShutdownImageName: "ellipsis.circle",
let expectedPreferenceImageName = "plus" expectedPreferenceImageName: "plus",
let expectedPinImageName = "macwindow.on.rectangle" expectedPinImageName: "macwindow.on.rectangle",
let expectedSunriseImageName = "sunrise.fill" expectedSunriseImageName: "sunrise.fill",
let expectedSunsetImageName = "sunset.fill" expectedSunsetImageName: "sunset.fill",
let expectedRemoveImageName = "xmark" expectedRemoveImageName: "xmark",
let expectedExtraOptionsImage = "Extra" expectedExtraOptionsImage: "Extra",
let expectedMenubarOnboardingImage = "Light Menubar" expectedMenubarOnboardingImage: "Light Menubar",
let expectedExtraOptionsHighlightedImage = "ExtraHighlighted" expectedExtraOptionsHighlightedImage: "ExtraHighlighted",
let expectedSharingImage = "square.and.arrow.up.on.square.fill" expectedSharingImage: "square.and.arrow.up.on.square.fill",
let expectedCurrentLocationImage = "location.fill" expectedCurrentLocationImage: "location.fill",
let expectedPopoverApperarance = NSAppearance(named: NSAppearance.Name.vibrantLight)! expectedAddImage: "plus",
let expectedAddImage = "plus" expectedAddImageHighlighted: "Add White",
let expectedAddImageHighlighted = "Add White" expectedPrivacyTabImage: "lock",
let expectedPrivacyTabImage = "lock" expectedAppearanceTabImage: "eye",
let expectedAppearanceTabImage = "eye" expectedCalendarTabImage: "calendar",
let expectedCalendarTabImage = "calendar" expectedGeneralTabImage: "gearshape",
let expectedGeneralTabImage = "gearshape" expectedAboutTabImage: "info.circle",
let expectedAboutTabImage = "info.circle" expectedVideoCallImage: "video.circle.fill",
let expectedVideoCallImage = "video.circle.fill" expectedFilledTrashImage: "trash.fill",
let expectedFilledTrashImage = "trash.fill" expectedBackwardsImage: "gobackward.15",
let expectedBackwardsImage = "gobackward.15" expectedForwardsImage: "goforward.15",
let expectedForwardsImage = "goforward.15" expectedResetSliderImage: "xmark.circle.fill")
let expectedResetSliderImage = "xmark.circle.fill" testSubject(subject: subject, withExpectatations: expectedThemeElements)
XCTAssertEqual(subject.sliderKnobColor(), expectedSliderKnobColor)
XCTAssertEqual(subject.sliderRightColor(), expectedSliderRightColor)
XCTAssertEqual(subject.mainBackgroundColor(), expectedBackgroundColor)
XCTAssertEqual(subject.mainTextColor(), expectedTextColor)
XCTAssertEqual(subject.textBackgroundColor(), expectedTextBackgroundColor)
XCTAssertEqual(subject.shutdownImage().accessibilityDescription, expectedShutdownImageName)
XCTAssertEqual(subject.preferenceImage().accessibilityDescription, expectedPreferenceImageName)
XCTAssertEqual(subject.pinImage().accessibilityDescription, expectedPinImageName)
XCTAssertEqual(subject.sunriseImage().accessibilityDescription, expectedSunriseImageName)
XCTAssertEqual(subject.sunsetImage().accessibilityDescription, expectedSunsetImageName)
XCTAssertEqual(subject.removeImage().accessibilityDescription, expectedRemoveImageName)
XCTAssertEqual(subject.extraOptionsImage().name(), expectedExtraOptionsImage)
XCTAssertEqual(subject.menubarOnboardingImage().name(), expectedMenubarOnboardingImage)
XCTAssertEqual(subject.extraOptionsHighlightedImage().name(), expectedExtraOptionsHighlightedImage)
XCTAssertEqual(subject.sharingImage().accessibilityDescription, expectedSharingImage)
XCTAssertEqual(subject.currentLocationImage().accessibilityDescription, expectedCurrentLocationImage)
XCTAssertEqual(subject.popoverAppearance(), expectedPopoverApperarance)
XCTAssertEqual(subject.addImage().accessibilityDescription, expectedAddImage)
XCTAssertEqual(subject.addImageHighlighted().name(), expectedAddImageHighlighted)
XCTAssertEqual(subject.privacyTabImage().accessibilityDescription, expectedPrivacyTabImage)
XCTAssertEqual(subject.appearanceTabImage().accessibilityDescription, expectedAppearanceTabImage)
XCTAssertEqual(subject.calendarTabImage().accessibilityDescription, expectedCalendarTabImage)
XCTAssertEqual(subject.generalTabImage()?.accessibilityDescription, expectedGeneralTabImage)
XCTAssertEqual(subject.aboutTabImage()?.accessibilityDescription, expectedAboutTabImage)
XCTAssertEqual(subject.videoCallImage()?.accessibilityDescription, expectedVideoCallImage)
XCTAssertEqual(subject.filledTrashImage()?.accessibilityDescription, expectedFilledTrashImage)
XCTAssertEqual(subject.goBackwardsImage()?.accessibilityDescription, expectedBackwardsImage)
XCTAssertEqual(subject.goForwardsImage()?.accessibilityDescription, expectedForwardsImage)
XCTAssertEqual(subject.resetModernSliderImage()?.accessibilityDescription, expectedResetSliderImage)
} }
func testSolarizedDarkTheme() throws { func testSolarizedDarkTheme() throws {
let subject = Themer(index: 4) // 4 is for solarized dark theme let subject = Themer(index: 4) // 4 is for solarized dark theme
let expectedSliderKnobColor = NSColor(deviceRed: 0.0, green: 0.0, blue: 0, alpha: 0.9) let expectedThemeElements = ThemeExpectations(expectedSliderKnobColor: NSColor(deviceRed: 0.0, green: 0.0, blue: 0, alpha: 0.9),
let expectedSliderRightColor = NSColor.gray expectedSliderRightColor: NSColor.gray,
let expectedBackgroundColor = NSColor(deviceRed: 7.0 / 255.0, green: 54.0 / 255.0, blue: 66.0 / 255.0, alpha: 1.0) expectedBackgroundColor: NSColor(deviceRed: 7.0 / 255.0, green: 54.0 / 255.0, blue: 66.0 / 255.0, alpha: 1.0),
let expectedTextColor = NSColor.white expectedTextColor: NSColor.white,
let expectedTextBackgroundColor = NSColor(deviceRed: 0.0 / 255.0, green: 43.0 / 255.0, blue: 54.0 / 255.0, alpha: 1.0) expectedTextBackgroundColor: NSColor(deviceRed: 0.0 / 255.0, green: 43.0 / 255.0, blue: 54.0 / 255.0, alpha: 1.0),
expectedPopoverApperarance: NSAppearance(named: NSAppearance.Name.vibrantDark)!,
let expectedShutdownImageName = "ellipsis.circle" expectedShutdownImageName: "ellipsis.circle",
let expectedPreferenceImageName = "plus" expectedPreferenceImageName: "plus",
let expectedPinImageName = "macwindow.on.rectangle" expectedPinImageName: "macwindow.on.rectangle",
let expectedSunriseImageName = "sunrise.fill" expectedSunriseImageName: "sunrise.fill",
let expectedSunsetImageName = "sunset.fill" expectedSunsetImageName: "sunset.fill",
let expectedRemoveImageName = "xmark" expectedRemoveImageName: "xmark",
let expectedExtraOptionsImage = "ExtraWhite" expectedExtraOptionsImage: "ExtraWhite",
let expectedMenubarOnboardingImage = "Dark Menubar" expectedMenubarOnboardingImage: "Dark Menubar",
let expectedExtraOptionsHighlightedImage = "ExtraWhiteHighlighted" expectedExtraOptionsHighlightedImage: "ExtraWhiteHighlighted",
let expectedSharingImage = "square.and.arrow.up.on.square.fill" expectedSharingImage: "square.and.arrow.up.on.square.fill",
let expectedCurrentLocationImage = "location.fill" expectedCurrentLocationImage: "location.fill",
let expectedPopoverApperarance = NSAppearance(named: NSAppearance.Name.vibrantDark)! expectedAddImage: "plus",
let expectedAddImage = "plus" expectedAddImageHighlighted: "Add White",
let expectedAddImageHighlighted = "Add White" expectedPrivacyTabImage: "lock",
let expectedPrivacyTabImage = "lock" expectedAppearanceTabImage: "eye",
let expectedAppearanceTabImage = "eye" expectedCalendarTabImage: "calendar",
let expectedCalendarTabImage = "calendar" expectedGeneralTabImage: "gearshape",
let expectedGeneralTabImage = "gearshape" expectedAboutTabImage: "info.circle",
let expectedAboutTabImage = "info.circle" expectedVideoCallImage: "video.circle.fill",
let expectedVideoCallImage = "video.circle.fill" expectedFilledTrashImage: "trash.fill",
let expectedFilledTrashImage = "trash.fill" expectedBackwardsImage: "gobackward.15",
let expectedBackwardsImage = "gobackward.15" expectedForwardsImage: "goforward.15",
let expectedForwardsImage = "goforward.15" expectedResetSliderImage: "xmark.circle.fill")
let expectedResetSliderImage = "xmark.circle.fill" testSubject(subject: subject, withExpectatations: expectedThemeElements)
}
XCTAssertEqual(subject.sliderKnobColor(), expectedSliderKnobColor)
XCTAssertEqual(subject.sliderRightColor(), expectedSliderRightColor) private func testSubject(subject: Themer, withExpectatations expectations: ThemeExpectations) {
XCTAssertEqual(subject.mainBackgroundColor(), expectedBackgroundColor) XCTAssertEqual(subject.sliderKnobColor(), expectations.expectedSliderKnobColor)
XCTAssertEqual(subject.mainTextColor(), expectedTextColor) XCTAssertEqual(subject.sliderRightColor(), expectations.expectedSliderRightColor)
XCTAssertEqual(subject.textBackgroundColor(), expectedTextBackgroundColor) XCTAssertEqual(subject.mainBackgroundColor(), expectations.expectedBackgroundColor)
XCTAssertEqual(subject.shutdownImage().accessibilityDescription, expectedShutdownImageName) XCTAssertEqual(subject.mainTextColor(), expectations.expectedTextColor)
XCTAssertEqual(subject.preferenceImage().accessibilityDescription, expectedPreferenceImageName) XCTAssertEqual(subject.textBackgroundColor(), expectations.expectedTextBackgroundColor)
XCTAssertEqual(subject.pinImage().accessibilityDescription, expectedPinImageName) XCTAssertEqual(subject.shutdownImage().accessibilityDescription, expectations.expectedShutdownImageName)
XCTAssertEqual(subject.sunriseImage().accessibilityDescription, expectedSunriseImageName) XCTAssertEqual(subject.preferenceImage().accessibilityDescription, expectations.expectedPreferenceImageName)
XCTAssertEqual(subject.sunsetImage().accessibilityDescription, expectedSunsetImageName) XCTAssertEqual(subject.pinImage().accessibilityDescription, expectations.expectedPinImageName)
XCTAssertEqual(subject.removeImage().accessibilityDescription, expectedRemoveImageName) XCTAssertEqual(subject.sunriseImage().accessibilityDescription, expectations.expectedSunriseImageName)
XCTAssertEqual(subject.extraOptionsImage().name(), expectedExtraOptionsImage) XCTAssertEqual(subject.sunsetImage().accessibilityDescription, expectations.expectedSunsetImageName)
XCTAssertEqual(subject.menubarOnboardingImage().name(), expectedMenubarOnboardingImage) XCTAssertEqual(subject.removeImage().accessibilityDescription, expectations.expectedRemoveImageName)
XCTAssertEqual(subject.extraOptionsHighlightedImage().name(), expectedExtraOptionsHighlightedImage) XCTAssertEqual(subject.extraOptionsImage().name(), expectations.expectedExtraOptionsImage)
XCTAssertEqual(subject.sharingImage().accessibilityDescription, expectedSharingImage) XCTAssertEqual(subject.menubarOnboardingImage().name(), expectations.expectedMenubarOnboardingImage)
XCTAssertEqual(subject.currentLocationImage().accessibilityDescription, expectedCurrentLocationImage) XCTAssertEqual(subject.extraOptionsHighlightedImage().name(), expectations.expectedExtraOptionsHighlightedImage)
XCTAssertEqual(subject.popoverAppearance(), expectedPopoverApperarance) XCTAssertEqual(subject.sharingImage().accessibilityDescription, expectations.expectedSharingImage)
XCTAssertEqual(subject.addImage().accessibilityDescription, expectedAddImage) XCTAssertEqual(subject.currentLocationImage().accessibilityDescription, expectations.expectedCurrentLocationImage)
XCTAssertEqual(subject.addImageHighlighted().name(), expectedAddImageHighlighted) XCTAssertEqual(subject.popoverAppearance(), expectations.expectedPopoverApperarance)
XCTAssertEqual(subject.privacyTabImage().accessibilityDescription, expectedPrivacyTabImage) XCTAssertEqual(subject.addImage().accessibilityDescription, expectations.expectedAddImage)
XCTAssertEqual(subject.appearanceTabImage().accessibilityDescription, expectedAppearanceTabImage) XCTAssertEqual(subject.addImageHighlighted().name(), expectations.expectedAddImageHighlighted)
XCTAssertEqual(subject.calendarTabImage().accessibilityDescription, expectedCalendarTabImage) XCTAssertEqual(subject.privacyTabImage().accessibilityDescription, expectations.expectedPrivacyTabImage)
XCTAssertEqual(subject.generalTabImage()?.accessibilityDescription, expectedGeneralTabImage) XCTAssertEqual(subject.appearanceTabImage().accessibilityDescription, expectations.expectedAppearanceTabImage)
XCTAssertEqual(subject.aboutTabImage()?.accessibilityDescription, expectedAboutTabImage) XCTAssertEqual(subject.calendarTabImage().accessibilityDescription, expectations.expectedCalendarTabImage)
XCTAssertEqual(subject.videoCallImage()?.accessibilityDescription, expectedVideoCallImage) XCTAssertEqual(subject.generalTabImage()?.accessibilityDescription, expectations.expectedGeneralTabImage)
XCTAssertEqual(subject.filledTrashImage()?.accessibilityDescription, expectedFilledTrashImage) XCTAssertEqual(subject.aboutTabImage()?.accessibilityDescription, expectations.expectedAboutTabImage)
XCTAssertEqual(subject.goBackwardsImage()?.accessibilityDescription, expectedBackwardsImage) XCTAssertEqual(subject.videoCallImage()?.accessibilityDescription, expectations.expectedVideoCallImage)
XCTAssertEqual(subject.goForwardsImage()?.accessibilityDescription, expectedForwardsImage) XCTAssertEqual(subject.filledTrashImage()?.accessibilityDescription, expectations.expectedFilledTrashImage)
XCTAssertEqual(subject.resetModernSliderImage()?.accessibilityDescription, expectedResetSliderImage) XCTAssertEqual(subject.goBackwardsImage()?.accessibilityDescription, expectations.expectedBackwardsImage)
XCTAssertEqual(subject.goForwardsImage()?.accessibilityDescription, expectations.expectedForwardsImage)
XCTAssertEqual(subject.resetModernSliderImage()?.accessibilityDescription, expectations.expectedResetSliderImage)
} }
} }

Loading…
Cancel
Save