79 lines
2.8 KiB
Swift
79 lines
2.8 KiB
Swift
import XCTest
|
|
@testable import TargetPrint
|
|
|
|
final class AirPrintTests: XCTestCase {
|
|
func testAppleAirPrintURI() {
|
|
XCTAssertTrue(AirPrintDetector.isAirPrint(
|
|
uri: "apple-airprint://Brother%20HL._ipp._tcp.local/",
|
|
ppdText: "",
|
|
make: "Brother",
|
|
model: "HL-L3270CDW"
|
|
))
|
|
}
|
|
|
|
func testAPAirPrintTrueInPPD() {
|
|
XCTAssertTrue(AirPrintDetector.isAirPrint(
|
|
uri: "ipps://living-room.local/ipp/print",
|
|
ppdText: "*Manufacturer: Apple\n*APAirPrint: True\n",
|
|
make: "Apple",
|
|
model: "AirPrint Printer"
|
|
))
|
|
}
|
|
|
|
func testAppleManufacturerAirPrintModel() {
|
|
XCTAssertTrue(AirPrintDetector.isAirPrint(
|
|
uri: "dnssd://Foo._ipp._tcp.local/",
|
|
ppdText: "",
|
|
make: "Apple",
|
|
model: "Living Room AirPrint"
|
|
))
|
|
}
|
|
|
|
func testOEMUSBIsNotAirPrint() {
|
|
XCTAssertFalse(AirPrintDetector.isAirPrint(
|
|
uri: "usb://EPSON/XP-55%20Series?serial=X5R001",
|
|
ppdText: "*Manufacturer: Epson\n*EPSONColorControls: Off\n",
|
|
make: "Epson",
|
|
model: "XP-55"
|
|
))
|
|
}
|
|
|
|
func testIPPSWithoutAirPrintMarkerIsNotAirPrint() {
|
|
XCTAssertFalse(AirPrintDetector.isAirPrint(
|
|
uri: "ipps://office-printer.local/ipp/print",
|
|
ppdText: "*Manufacturer: HP\n*HPColorControl: Off\n",
|
|
make: "HP",
|
|
model: "OfficeJet Pro 9010"
|
|
))
|
|
}
|
|
|
|
func testVendorBypassEpsonCanonHP() {
|
|
let epson = CUPSManager.vendorColorBypass(make: "Epson", model: "XP-55", ppdText: "")
|
|
XCTAssertEqual(epson["ColorModel"], "RGB")
|
|
XCTAssertEqual(epson["EPSONColorControls"], "Off")
|
|
let canon = CUPSManager.vendorColorBypass(make: "Canon", model: "PRO-100", ppdText: "")
|
|
XCTAssertEqual(canon["CNColorMatching"], "None")
|
|
let hp = CUPSManager.vendorColorBypass(make: "HP", model: "9010", ppdText: "")
|
|
XCTAssertEqual(hp["HPColorControl"], "Off")
|
|
}
|
|
|
|
func testGenericColorOffFromPPD() {
|
|
let ppd = """
|
|
*OpenUI *SomeColourControl/Colour: PickOne
|
|
*SomeColourControl Off/Off: ""
|
|
*SomeColourControl On/On: ""
|
|
*CloseUI: *SomeColourControl
|
|
"""
|
|
let map = CUPSManager.vendorColorBypass(make: "Generic", model: "X", ppdText: ppd)
|
|
XCTAssertEqual(map["SomeColourControl"], "Off")
|
|
}
|
|
|
|
func testColorMatchingModeKeys() {
|
|
XCTAssertEqual(ColorMatchingMode.unmanaged.pmValue, "APCustomColorMatching")
|
|
XCTAssertEqual(ColorMatchingMode.colorsync.pmValue, "APColorSync")
|
|
XCTAssertEqual(ColorMatchingMode.driver.pmValue, "APPrinterExtension")
|
|
XCTAssertEqual(ColorMatchingMode.from(forceUnmanagedColor: true), .unmanaged)
|
|
XCTAssertEqual(ColorMatchingMode.from(forceUnmanagedColor: false), .colorsync)
|
|
}
|
|
}
|