|
@@ -19,6 +19,9 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
|
var _type : String = "Others"
|
|
|
var _extention : String = "rtf"
|
|
|
|
|
|
+ var _degree : Double = 0.0
|
|
|
+ var _fileDegree : [Double] = []
|
|
|
+
|
|
|
class func autoTestFor(_ fileType:NSString ,type:NSString) -> AutoTest? {
|
|
|
let key = String(fileType) + "." + String(type)
|
|
|
|
|
@@ -136,6 +139,10 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
|
let checkDirectory = self.checkFileDirectory()
|
|
|
let originDirectory = self.originFileDirectory()
|
|
|
let resultDirectory = self.resultFileDirectory()
|
|
|
+
|
|
|
+ var degree = Double(0);
|
|
|
+ var count = Int(0)
|
|
|
+
|
|
|
for fileName in files {
|
|
|
let fName = NSString(string: fileName).deletingPathExtension
|
|
|
let originPath = NSString(string: originDirectory).appendingPathComponent(fName+".pdf")
|
|
@@ -176,6 +183,9 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
|
items.add(fName)
|
|
|
}
|
|
|
|
|
|
+ var subDegree = Double(0);
|
|
|
+ var subCount = Int(0)
|
|
|
+
|
|
|
for item in items {
|
|
|
let subFileName = item as! String
|
|
|
let subResultPath = NSString(string: resultDirectory).appendingPathComponent(subFileName+"."+_extention)
|
|
@@ -205,6 +215,9 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
|
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]))
|
|
|
}
|
|
@@ -218,6 +231,16 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
|
processThumbSemaphore.wait()
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ if subCount != 0 {
|
|
|
+ subDegree = subDegree/Double(subCount)
|
|
|
+ }else {
|
|
|
+ subDegree = 0.0
|
|
|
+ }
|
|
|
+
|
|
|
+ _fileDegree.append(subDegree)
|
|
|
+ degree += subDegree;
|
|
|
+ count += 1
|
|
|
}
|
|
|
}else {
|
|
|
reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(fName)\"转档失败!\n",
|
|
@@ -225,16 +248,42 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if count != 0 {
|
|
|
+ _degree = degree/Double(count)
|
|
|
+ }else {
|
|
|
+ _degree = 0.0
|
|
|
+ }
|
|
|
+
|
|
|
_status = .Finished
|
|
|
}else {
|
|
|
_status = .Normal
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
func testReport() -> NSAttributedString? {
|
|
|
return reportString
|
|
|
}
|
|
|
|
|
|
+ func degree() -> Double {
|
|
|
+ return _degree
|
|
|
+ }
|
|
|
+
|
|
|
+// func testReportOfFile(_ fileName:String) -> NSAttributedString? {
|
|
|
+//
|
|
|
+// }
|
|
|
+
|
|
|
+ func degreeOfFile(_ fileName:String) -> Double {
|
|
|
+ let files = DataModel.shared.originFilesFor(_fileType, type: _type) as [String]
|
|
|
+
|
|
|
+ let index = files.firstIndex(of: fileName)
|
|
|
+
|
|
|
+ if index == NSNotFound || index! >= _fileDegree.count {
|
|
|
+ return 0
|
|
|
+ }else {
|
|
|
+ return _fileDegree[index!]
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
// Image compare
|
|
|
func compareJPEG(_ resultPath:String, checkPath:String) -> Double {
|
|
@@ -540,6 +589,10 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ _degree = 0.0;
|
|
|
+ _fileDegree.removeAll()
|
|
|
}
|
|
|
}
|
|
|
|