|
@@ -55,7 +55,7 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
object?._extention = String(cExtention)
|
|
object?._extention = String(cExtention)
|
|
object?._name = String(cName)
|
|
object?._name = String(cName)
|
|
if nil != cParams {
|
|
if nil != cParams {
|
|
- object?._params = cParams!;
|
|
|
|
|
|
+ object?._params = cParams ?? [:];
|
|
}
|
|
}
|
|
cacheObjects.setValue(object, forKey: key)
|
|
cacheObjects.setValue(object, forKey: key)
|
|
|
|
|
|
@@ -165,76 +165,102 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
var tCount = Int(0)
|
|
var tCount = Int(0)
|
|
|
|
|
|
for fileName in files {
|
|
for fileName in files {
|
|
- let fName = NSString(string: fileName).deletingPathExtension
|
|
|
|
- let originPath = NSString(string: originDirectory).appendingPathComponent(fName+".pdf")
|
|
|
|
- let resultPath = NSString(string: resultDirectory).appendingPathComponent(fName+"."+_extention)
|
|
|
|
- let checkPath = NSString(string: checkDirectory).appendingPathComponent(fName+"."+_extention)
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】开始转换文件 \"\(fName)\"\n",
|
|
|
|
- attributes:[.foregroundColor : NSColor.blue]))
|
|
|
|
- // ...
|
|
|
|
- // 执行转换过程
|
|
|
|
- var success = process(originPath, resultPath: resultPath)
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- var isDirectory = ObjCBool(false)
|
|
|
|
- if FileManager.default.fileExists(atPath: resultPath, isDirectory:&isDirectory) && success {
|
|
|
|
- // compare screenshoot between result file with check file
|
|
|
|
- if needCompare {
|
|
|
|
- let items = NSMutableArray()
|
|
|
|
- if (isDirectory.boolValue) {
|
|
|
|
- let searchItems = try! FileManager.default.contentsOfDirectory(atPath: resultPath)
|
|
|
|
- for item in NSArray(array: searchItems) {
|
|
|
|
- let ext = NSString(string: item as! String).pathExtension.lowercased()
|
|
|
|
- if (NSArray(array: [_extention]).contains(ext)) {
|
|
|
|
- let fileName = NSString(string: fName+"."+_extention+"/\(item as! String)").deletingPathExtension
|
|
|
|
- items.add(fileName)
|
|
|
|
|
|
+ autoreleasepool {
|
|
|
|
+ let fName = NSString(string: fileName).deletingPathExtension
|
|
|
|
+ let originPath = NSString(string: originDirectory).appendingPathComponent(fName+".pdf")
|
|
|
|
+ let resultPath = NSString(string: resultDirectory).appendingPathComponent(fName+"."+_extention)
|
|
|
|
+ // let checkPath = NSString(string: checkDirectory).appendingPathComponent(fName+"."+_extention)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】开始转换文件 \"\(fName)\"\n",
|
|
|
|
+ attributes:[.foregroundColor : NSColor.blue]))
|
|
|
|
+ // ...
|
|
|
|
+ // 执行转换过程
|
|
|
|
+ let status = process(originPath, resultPath: resultPath)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ var isDirectory = ObjCBool(false)
|
|
|
|
+ if FileManager.default.fileExists(atPath: resultPath, isDirectory:&isDirectory) && status == 1 {
|
|
|
|
+ // compare screenshoot between result file with check file
|
|
|
|
+ if needCompare {
|
|
|
|
+ let items = NSMutableArray()
|
|
|
|
+ if (isDirectory.boolValue) {
|
|
|
|
+ let searchItems = try! FileManager.default.contentsOfDirectory(atPath: resultPath)
|
|
|
|
+ for item in NSArray(array: searchItems) {
|
|
|
|
+ let ext = NSString(string: item as! String).pathExtension.lowercased()
|
|
|
|
+ if (NSArray(array: [_extention]).contains(ext)) {
|
|
|
|
+ let fileName = NSString(string: fName+"."+_extention+"/\(item as! String)").deletingPathExtension
|
|
|
|
+ items.add(fileName)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ }else {
|
|
|
|
+ items.add(fName)
|
|
}
|
|
}
|
|
- }else {
|
|
|
|
- items.add(fName)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- var subDegree = Double(0);
|
|
|
|
- var subCount = Int(0)
|
|
|
|
-
|
|
|
|
- for item in items {
|
|
|
|
- autoreleasepool {
|
|
|
|
- let subFileName = item as! String
|
|
|
|
- let subResultPath = NSString(string: resultDirectory).appendingPathComponent(subFileName+"."+_extention)
|
|
|
|
-
|
|
|
|
- reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(subFileName+".\(_extention)")\"快照生成中\n",
|
|
|
|
- attributes:[.foregroundColor : NSColor.black]))
|
|
|
|
- let rComparePath = NSString(string: resultDirectory).appendingPathComponent(subFileName+".jpg")
|
|
|
|
- let cComparePath = NSString(string: checkDirectory).appendingPathComponent(subFileName+".jpg")
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- let processThumbSemaphore = DispatchSemaphore(value: 0)
|
|
|
|
- var processSuccess = false
|
|
|
|
- let thumbnailQueue = DispatchQueue.global()
|
|
|
|
- thumbnailQueue.async {
|
|
|
|
- processSuccess = ProcessThumbnal.process(subResultPath, desPath: rComparePath, outputSize: CGSize.init(width: 2048, height: 2048))
|
|
|
|
|
|
+
|
|
|
|
+ var subDegree = Double(0);
|
|
|
|
+ var subCount = Int(0)
|
|
|
|
+
|
|
|
|
+ for item in items {
|
|
|
|
+ autoreleasepool {
|
|
|
|
+ let subFileName = item as! String
|
|
|
|
+ let subResultPath = NSString(string: resultDirectory).appendingPathComponent(subFileName+"."+_extention)
|
|
|
|
+
|
|
|
|
+ reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(subFileName+".\(_extention)")\"快照生成中\n",
|
|
|
|
+ attributes:[.foregroundColor : NSColor.black]))
|
|
|
|
+ let rComparePath = NSString(string: resultDirectory).appendingPathComponent(subFileName+".jpg")
|
|
|
|
+ let cComparePath = NSString(string: checkDirectory).appendingPathComponent(subFileName+".jpg")
|
|
|
|
|
|
- if ( processSuccess &&
|
|
|
|
- FileManager.default.fileExists(atPath: rComparePath)) {
|
|
|
|
|
|
+
|
|
|
|
+ let processThumbSemaphore = DispatchSemaphore(value: 0)
|
|
|
|
+ var processSuccess = false
|
|
|
|
+ let thumbnailQueue = DispatchQueue.global()
|
|
|
|
+ thumbnailQueue.async {
|
|
|
|
+ processSuccess = ProcessThumbnal.process(subResultPath, desPath: rComparePath, outputSize: CGSize.init(width: 2048, height: 2048))
|
|
|
|
|
|
- var isDirectory = ObjCBool(false)
|
|
|
|
- if FileManager.default.fileExists(atPath: rComparePath, isDirectory: &isDirectory) && isDirectory.boolValue {
|
|
|
|
- // 单个文件生成批量快照目录情形
|
|
|
|
- let subImages = try! FileManager.default.contentsOfDirectory(atPath: rComparePath)
|
|
|
|
- for subImageName in subImages {
|
|
|
|
- let pathCompotent = "/"+subImageName
|
|
|
|
- let degree = ImageProcess.compareJPEG(String(rComparePath+pathCompotent), checkPath: String(cComparePath+pathCompotent), processCover: true)
|
|
|
|
|
|
+ if ( processSuccess &&
|
|
|
|
+ FileManager.default.fileExists(atPath: rComparePath)) {
|
|
|
|
+
|
|
|
|
+ var isDirectory = ObjCBool(false)
|
|
|
|
+ if FileManager.default.fileExists(atPath: rComparePath, isDirectory: &isDirectory) && isDirectory.boolValue {
|
|
|
|
+ // 单个文件生成批量快照目录情形
|
|
|
|
+ let subImages = try! FileManager.default.contentsOfDirectory(atPath: rComparePath)
|
|
|
|
+ for subImageName in subImages {
|
|
|
|
+ let pathCompotent = "/"+subImageName
|
|
|
|
+ let degree = ImageProcess.compareJPEG(String(rComparePath+pathCompotent), checkPath: String(cComparePath+pathCompotent), processCover: true)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ NSLog(String("文件夹,\(subFileName+".jpg"+pathCompotent)"))
|
|
|
|
+
|
|
|
|
+ TestDegreeManager.shared().set(degree, fileType: self.fileType(), type: self.type(),
|
|
|
|
+ fileName: fileName, refFilePath: subFileName+".jpg"+pathCompotent)
|
|
|
|
+
|
|
|
|
+ if degree == -1 {
|
|
|
|
+ self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(subResultPath+pathCompotent)\"快照对比失败,生成快照失败或无比对文件\n",
|
|
|
|
+ attributes:[.foregroundColor : NSColor.red]))
|
|
|
|
+ }else {
|
|
|
|
+ var color = NSColor.black
|
|
|
|
+ if fabs(degree-100.0) >= 0.01 {
|
|
|
|
+ color = NSColor.red
|
|
|
|
+ }
|
|
|
|
+ subDegree += degree
|
|
|
|
+ subCount += 1
|
|
|
|
+
|
|
|
|
+ self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(subResultPath+pathCompotent)\"快照对比完成,图像相似度 \(degree)%\n",
|
|
|
|
+ attributes:[.foregroundColor : color]))
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ // 单个文件生成单个快照文件情形
|
|
|
|
|
|
|
|
+ let degree = ImageProcess.compareJPEG(rComparePath, checkPath: cComparePath, processCover: true)
|
|
|
|
|
|
- NSLog(String("文件夹,\(subFileName+".jpg"+pathCompotent)"))
|
|
|
|
|
|
+ NSLog(String("非文件夹,\(subFileName+".jpg")"))
|
|
|
|
|
|
TestDegreeManager.shared().set(degree, fileType: self.fileType(), type: self.type(),
|
|
TestDegreeManager.shared().set(degree, fileType: self.fileType(), type: self.type(),
|
|
- fileName: fileName, refFilePath: subFileName+".jpg"+pathCompotent)
|
|
|
|
|
|
+ fileName: fileName, refFilePath: subFileName+".jpg")
|
|
|
|
|
|
if degree == -1 {
|
|
if degree == -1 {
|
|
- self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(subResultPath+pathCompotent)\"快照对比失败,生成快照失败或无比对文件\n",
|
|
|
|
|
|
+ self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(subResultPath)\"快照对比失败,生成快照失败或无比对文件\n",
|
|
attributes:[.foregroundColor : NSColor.red]))
|
|
attributes:[.foregroundColor : NSColor.red]))
|
|
}else {
|
|
}else {
|
|
var color = NSColor.black
|
|
var color = NSColor.black
|
|
@@ -244,62 +270,46 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
subDegree += degree
|
|
subDegree += degree
|
|
subCount += 1
|
|
subCount += 1
|
|
|
|
|
|
- self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(subResultPath+pathCompotent)\"快照对比完成,图像相似度 \(degree)%\n",
|
|
|
|
|
|
+ self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(subResultPath)\"快照对比完成,图像相似度 \(degree)%\n",
|
|
attributes:[.foregroundColor : color]))
|
|
attributes:[.foregroundColor : color]))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}else {
|
|
}else {
|
|
- // 单个文件生成单个快照文件情形
|
|
|
|
-
|
|
|
|
- let degree = ImageProcess.compareJPEG(rComparePath, checkPath: cComparePath, processCover: true)
|
|
|
|
-
|
|
|
|
- NSLog(String("非文件夹,\(subFileName+".jpg")"))
|
|
|
|
-
|
|
|
|
- TestDegreeManager.shared().set(degree, fileType: self.fileType(), type: self.type(),
|
|
|
|
- fileName: fileName, refFilePath: subFileName+".jpg")
|
|
|
|
-
|
|
|
|
- if degree == -1 {
|
|
|
|
- self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(subResultPath)\"快照对比失败,生成快照失败或无比对文件\n",
|
|
|
|
- attributes:[.foregroundColor : NSColor.red]))
|
|
|
|
- }else {
|
|
|
|
- var color = NSColor.black
|
|
|
|
- if fabs(degree-100.0) >= 0.01 {
|
|
|
|
- color = NSColor.red
|
|
|
|
- }
|
|
|
|
- subDegree += degree
|
|
|
|
- subCount += 1
|
|
|
|
-
|
|
|
|
- self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(subResultPath)\"快照对比完成,图像相似度 \(degree)%\n",
|
|
|
|
- attributes:[.foregroundColor : color]))
|
|
|
|
- }
|
|
|
|
|
|
+ self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(subResultPath)\"快照生成失败\n",
|
|
|
|
+ attributes:[.foregroundColor : NSColor.red]))
|
|
}
|
|
}
|
|
- }else {
|
|
|
|
- self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(subResultPath)\"快照生成失败\n",
|
|
|
|
- attributes:[.foregroundColor : NSColor.red]))
|
|
|
|
|
|
+
|
|
|
|
+ processThumbSemaphore.signal()
|
|
}
|
|
}
|
|
-
|
|
|
|
- processThumbSemaphore.signal()
|
|
|
|
|
|
+ processThumbSemaphore.wait()
|
|
}
|
|
}
|
|
- processThumbSemaphore.wait()
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if subCount != 0 {
|
|
|
|
+ subDegree = subDegree/Double(subCount)
|
|
|
|
+ }else {
|
|
|
|
+ subDegree = 0.0
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ TestDegreeManager.shared().set(subDegree,
|
|
|
|
+ fileType: self.fileType(),
|
|
|
|
+ type: self.type(),
|
|
|
|
+ fileName: fileName)
|
|
|
|
+ tDegree += subDegree;
|
|
|
|
+ tCount += 1
|
|
}
|
|
}
|
|
-
|
|
|
|
- if subCount != 0 {
|
|
|
|
- subDegree = subDegree/Double(subCount)
|
|
|
|
- }else {
|
|
|
|
- subDegree = 0.0
|
|
|
|
|
|
+ }else {
|
|
|
|
+ if (status == 0) {
|
|
|
|
+ reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(fName)\"转档失败!\n",
|
|
|
|
+ attributes:[.foregroundColor : NSColor.red]))
|
|
|
|
+ }else if (status == -1 || status == -2) {
|
|
|
|
+ reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(fName)\"文档无法打开!\n",
|
|
|
|
+ attributes:[.foregroundColor : NSColor.red]))
|
|
|
|
+ }else if (status == -3) {
|
|
|
|
+ reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(fName)\"转档中 Crash!\n",
|
|
|
|
+ attributes:[.foregroundColor : NSColor.red]))
|
|
}
|
|
}
|
|
-
|
|
|
|
- TestDegreeManager.shared().set(subDegree,
|
|
|
|
- fileType: self.fileType(),
|
|
|
|
- type: self.type(),
|
|
|
|
- fileName: fileName)
|
|
|
|
- tDegree += subDegree;
|
|
|
|
- tCount += 1
|
|
|
|
}
|
|
}
|
|
- }else {
|
|
|
|
- reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(fName)\"转档失败!\n",
|
|
|
|
- attributes:[.foregroundColor : NSColor.red]))
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -313,19 +323,19 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- func process(_ originPath:String, resultPath:String) -> Bool {
|
|
|
|
- process(originPath, resultPath: resultPath, params: self.params())
|
|
|
|
|
|
+ func process(_ originPath:String, resultPath:String) -> Int {
|
|
|
|
+ return process(originPath, resultPath: resultPath, params: self.params())
|
|
}
|
|
}
|
|
|
|
|
|
- func process(_ originPath:String, resultPath:String, params:NSDictionary) -> Bool {
|
|
|
|
|
|
+ func process(_ originPath:String, resultPath:String, params:NSDictionary) -> Int {
|
|
// ...
|
|
// ...
|
|
// 执行转换过程
|
|
// 执行转换过程
|
|
let convertSemaphore = DispatchSemaphore(value: 0)
|
|
let convertSemaphore = DispatchSemaphore(value: 0)
|
|
- var success = false
|
|
|
|
|
|
+ var status = Int(1)
|
|
let convertQueue = DispatchQueue.global()
|
|
let convertQueue = DispatchQueue.global()
|
|
convertQueue.async {
|
|
convertQueue.async {
|
|
autoreleasepool {
|
|
autoreleasepool {
|
|
- success = FileConverter.shared().converter(originPath, inDesPath: resultPath, params: params)
|
|
|
|
|
|
+ status = FileConverter.shared().converter(originPath, inDesPath: resultPath, params: params)
|
|
|
|
|
|
// 修复转 PNG 实际图片为 JPG 问题, 导致无法匹配问题
|
|
// 修复转 PNG 实际图片为 JPG 问题, 导致无法匹配问题
|
|
if (NSArray(array: ["png", "PNG"]).contains(NSString(string: resultPath).pathExtension)) {
|
|
if (NSArray(array: ["png", "PNG"]).contains(NSString(string: resultPath).pathExtension)) {
|
|
@@ -345,7 +355,7 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
}
|
|
}
|
|
convertSemaphore.wait()
|
|
convertSemaphore.wait()
|
|
|
|
|
|
- return success
|
|
|
|
|
|
+ return status
|
|
}
|
|
}
|
|
|
|
|
|
func testReport() -> NSAttributedString? {
|
|
func testReport() -> NSAttributedString? {
|
|
@@ -377,14 +387,14 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
func canUpdateRefImage() -> Bool {
|
|
func canUpdateRefImage() -> Bool {
|
|
let files = DataModel.shared.originFilesFor(_fileType, type: _type) as [String]
|
|
let files = DataModel.shared.originFilesFor(_fileType, type: _type) as [String]
|
|
let checkDirectory = self.checkFileDirectory()
|
|
let checkDirectory = self.checkFileDirectory()
|
|
- let originDirectory = self.originFileDirectory()
|
|
|
|
|
|
+// let originDirectory = self.originFileDirectory()
|
|
let resultDirectory = self.resultFileDirectory()
|
|
let resultDirectory = self.resultFileDirectory()
|
|
|
|
|
|
for fileName in files {
|
|
for fileName in files {
|
|
let fName = NSString(string: fileName).deletingPathExtension
|
|
let fName = NSString(string: fileName).deletingPathExtension
|
|
- let originPath = NSString(string: originDirectory).appendingPathComponent(fName+".pdf")
|
|
|
|
|
|
+// let originPath = NSString(string: originDirectory).appendingPathComponent(fName+".pdf")
|
|
let resultPath = NSString(string: resultDirectory).appendingPathComponent(fName+"."+_extention)
|
|
let resultPath = NSString(string: resultDirectory).appendingPathComponent(fName+"."+_extention)
|
|
- let checkPath = NSString(string: checkDirectory).appendingPathComponent(fName+"."+_extention)
|
|
|
|
|
|
+// let checkPath = NSString(string: checkDirectory).appendingPathComponent(fName+"."+_extention)
|
|
|
|
|
|
|
|
|
|
var isDirectory = ObjCBool(false)
|
|
var isDirectory = ObjCBool(false)
|
|
@@ -437,13 +447,13 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
|
|
|
|
func canUpdateRefImage(_ fileName:String) -> Bool {
|
|
func canUpdateRefImage(_ fileName:String) -> Bool {
|
|
let checkDirectory = self.checkFileDirectory()
|
|
let checkDirectory = self.checkFileDirectory()
|
|
- let originDirectory = self.originFileDirectory()
|
|
|
|
|
|
+// let originDirectory = self.originFileDirectory()
|
|
let resultDirectory = self.resultFileDirectory()
|
|
let resultDirectory = self.resultFileDirectory()
|
|
|
|
|
|
let fName = NSString(string: fileName).deletingPathExtension
|
|
let fName = NSString(string: fileName).deletingPathExtension
|
|
- let originPath = NSString(string: originDirectory).appendingPathComponent(fName+".pdf")
|
|
|
|
|
|
+// let originPath = NSString(string: originDirectory).appendingPathComponent(fName+".pdf")
|
|
let resultPath = NSString(string: resultDirectory).appendingPathComponent(fName+"."+_extention)
|
|
let resultPath = NSString(string: resultDirectory).appendingPathComponent(fName+"."+_extention)
|
|
- let checkPath = NSString(string: checkDirectory).appendingPathComponent(fName+"."+_extention)
|
|
|
|
|
|
+// let checkPath = NSString(string: checkDirectory).appendingPathComponent(fName+"."+_extention)
|
|
|
|
|
|
|
|
|
|
var isDirectory = ObjCBool(false)
|
|
var isDirectory = ObjCBool(false)
|
|
@@ -487,13 +497,13 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
|
|
|
|
func updateRefImage(_ fileName:String) {
|
|
func updateRefImage(_ fileName:String) {
|
|
let checkDirectory = self.checkFileDirectory()
|
|
let checkDirectory = self.checkFileDirectory()
|
|
- let originDirectory = self.originFileDirectory()
|
|
|
|
|
|
+// let originDirectory = self.originFileDirectory()
|
|
let resultDirectory = self.resultFileDirectory()
|
|
let resultDirectory = self.resultFileDirectory()
|
|
|
|
|
|
let fName = NSString(string: fileName).deletingPathExtension
|
|
let fName = NSString(string: fileName).deletingPathExtension
|
|
- let originPath = NSString(string: originDirectory).appendingPathComponent(fName+".pdf")
|
|
|
|
|
|
+// let originPath = NSString(string: originDirectory).appendingPathComponent(fName+".pdf")
|
|
let resultPath = NSString(string: resultDirectory).appendingPathComponent(fName+"."+_extention)
|
|
let resultPath = NSString(string: resultDirectory).appendingPathComponent(fName+"."+_extention)
|
|
- let checkPath = NSString(string: checkDirectory).appendingPathComponent(fName+"."+_extention)
|
|
|
|
|
|
+// let checkPath = NSString(string: checkDirectory).appendingPathComponent(fName+"."+_extention)
|
|
|
|
|
|
|
|
|
|
var isDirectory = ObjCBool(false)
|
|
var isDirectory = ObjCBool(false)
|
|
@@ -548,7 +558,7 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
let files = NSMutableArray()
|
|
let files = NSMutableArray()
|
|
|
|
|
|
let checkDirectory = self.checkFileDirectory()
|
|
let checkDirectory = self.checkFileDirectory()
|
|
- let originDirectory = self.originFileDirectory()
|
|
|
|
|
|
+// let originDirectory = self.originFileDirectory()
|
|
let resultDirectory = self.resultFileDirectory()
|
|
let resultDirectory = self.resultFileDirectory()
|
|
|
|
|
|
let fName = NSString(string: fileName).deletingPathExtension
|
|
let fName = NSString(string: fileName).deletingPathExtension
|
|
@@ -623,7 +633,7 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
|
|
|
|
// check File Exist
|
|
// check File Exist
|
|
func hasOriginFile() -> Bool {
|
|
func hasOriginFile() -> Bool {
|
|
- if nil != self.originFileDirectory() && FileManager.default.fileExists(atPath: self.originFileDirectory()) {
|
|
|
|
|
|
+ if FileManager.default.fileExists(atPath: self.originFileDirectory()) {
|
|
let files = try? FileManager.default.subpathsOfDirectory(atPath: self.originFileDirectory())
|
|
let files = try? FileManager.default.subpathsOfDirectory(atPath: self.originFileDirectory())
|
|
return (files ?? []).count > 0
|
|
return (files ?? []).count > 0
|
|
}
|
|
}
|
|
@@ -632,7 +642,7 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
}
|
|
}
|
|
|
|
|
|
func hasResultFile() -> Bool {
|
|
func hasResultFile() -> Bool {
|
|
- if nil != self.resultFileDirectory() && FileManager.default.fileExists(atPath: self.resultFileDirectory()) {
|
|
|
|
|
|
+ if FileManager.default.fileExists(atPath: self.resultFileDirectory()) {
|
|
let files = try? FileManager.default.subpathsOfDirectory(atPath: self.resultFileDirectory())
|
|
let files = try? FileManager.default.subpathsOfDirectory(atPath: self.resultFileDirectory())
|
|
return (files ?? []).count > 0
|
|
return (files ?? []).count > 0
|
|
}
|
|
}
|
|
@@ -664,7 +674,7 @@ extension AutoTest {
|
|
func stringToImage(_ string:String) ->NSImage? {
|
|
func stringToImage(_ string:String) ->NSImage? {
|
|
let length = Int(string.lengthOfBytes(using: .utf8)/2)
|
|
let length = Int(string.lengthOfBytes(using: .utf8)/2)
|
|
|
|
|
|
- var bytes = malloc(length)!
|
|
|
|
|
|
+ let bytes = malloc(length)!
|
|
|
|
|
|
for i in 0..<length {
|
|
for i in 0..<length {
|
|
let index = i
|
|
let index = i
|
|
@@ -672,7 +682,7 @@ extension AutoTest {
|
|
bytes.storeBytes(of: UInt8(hexForString(subString)), as: UInt8.self)
|
|
bytes.storeBytes(of: UInt8(hexForString(subString)), as: UInt8.self)
|
|
}
|
|
}
|
|
|
|
|
|
- var data = Data.init(bytes: bytes, count: length)
|
|
|
|
|
|
+ let data = Data.init(bytes: bytes, count: length)
|
|
let image = NSImage.init(data: data)
|
|
let image = NSImage.init(data: data)
|
|
|
|
|
|
return image
|
|
return image
|