|
@@ -19,9 +19,6 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
var _type : String = "Others"
|
|
var _type : String = "Others"
|
|
var _extention : String = "rtf"
|
|
var _extention : String = "rtf"
|
|
|
|
|
|
- var _degree : Double = 0.0
|
|
|
|
- var _fileDegreeInfo : [String:Double] = [:]
|
|
|
|
-
|
|
|
|
class func autoTestFor(_ fileType:NSString ,type:NSString) -> AutoTest? {
|
|
class func autoTestFor(_ fileType:NSString ,type:NSString) -> AutoTest? {
|
|
let key = String(fileType) + "." + String(type)
|
|
let key = String(fileType) + "." + String(type)
|
|
|
|
|
|
@@ -207,6 +204,14 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
|
|
|
|
let degree = ImageProcess.compareJPEG(rComparePath, checkPath: cComparePath)
|
|
let degree = ImageProcess.compareJPEG(rComparePath, checkPath: cComparePath)
|
|
|
|
|
|
|
|
+ if isDirectory.boolValue {
|
|
|
|
+ TestDegreeManager.shared().set(degree,
|
|
|
|
+ fileType: self.fileType(),
|
|
|
|
+ type: self.type(),
|
|
|
|
+ fileName: fileName,
|
|
|
|
+ refFilePath: subFileName)
|
|
|
|
+ }
|
|
|
|
+
|
|
if degree == -1 {
|
|
if degree == -1 {
|
|
self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(subResultPath)\"快照对比失败,生成快照失败或无比对文件\n",
|
|
self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(subResultPath)\"快照对比失败,生成快照失败或无比对文件\n",
|
|
attributes:[.foregroundColor : NSColor.red]))
|
|
attributes:[.foregroundColor : NSColor.red]))
|
|
@@ -238,7 +243,10 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
subDegree = 0.0
|
|
subDegree = 0.0
|
|
}
|
|
}
|
|
|
|
|
|
- _fileDegreeInfo[fileName] = subDegree
|
|
|
|
|
|
+ TestDegreeManager.shared().set(subDegree,
|
|
|
|
+ fileType: self.fileType(),
|
|
|
|
+ type: self.type(),
|
|
|
|
+ fileName: fileName)
|
|
tDegree += subDegree;
|
|
tDegree += subDegree;
|
|
tCount += 1
|
|
tCount += 1
|
|
}
|
|
}
|
|
@@ -248,12 +256,10 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if tCount != 0 {
|
|
|
|
- _degree = tDegree/Double(tCount)
|
|
|
|
- }else {
|
|
|
|
- _degree = 0.0
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ TestDegreeManager.shared().set(((tCount != 0) ? tDegree/Double(tCount) : 0.0),
|
|
|
|
+ fileType: _fileType,
|
|
|
|
+ type: _type)
|
|
|
|
+
|
|
_status = .Finished
|
|
_status = .Finished
|
|
}else {
|
|
}else {
|
|
_status = .Normal
|
|
_status = .Normal
|
|
@@ -266,7 +272,7 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
}
|
|
}
|
|
|
|
|
|
func degree() -> Double {
|
|
func degree() -> Double {
|
|
- return _degree
|
|
|
|
|
|
+ return TestDegreeManager.shared().degreeFor(self.fileType(), type: self.type())
|
|
}
|
|
}
|
|
|
|
|
|
// func testReportOfFile(_ fileName:String) -> NSAttributedString? {
|
|
// func testReportOfFile(_ fileName:String) -> NSAttributedString? {
|
|
@@ -274,10 +280,14 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
// }
|
|
// }
|
|
|
|
|
|
func degreeOfFile(_ fileName:String) -> Double {
|
|
func degreeOfFile(_ fileName:String) -> Double {
|
|
- if _fileDegreeInfo[fileName] != nil {
|
|
|
|
- return _fileDegreeInfo[fileName]!
|
|
|
|
|
|
+ return TestDegreeManager.shared().degreeFor(self.fileType(), type: self.type(), fileName: fileName)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ func degreeOfFile(_ fileName:String, refFilePath:String?) -> Double {
|
|
|
|
+ if refFilePath != nil {
|
|
|
|
+ return TestDegreeManager.shared().degreeFor(self.fileType(), type: self.type(), fileName: fileName, refFilePath: refFilePath)
|
|
}else {
|
|
}else {
|
|
- return 0
|
|
|
|
|
|
+ return degreeOfFile(fileName)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -483,12 +493,20 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
items.add(fName)
|
|
items.add(fName)
|
|
}
|
|
}
|
|
|
|
|
|
- for item in items {
|
|
|
|
|
|
+ let nitems = items.sortedArray { str1, str2 in
|
|
|
|
+ let s1 = str1 as! String
|
|
|
|
+ let s2 = str2 as! String
|
|
|
|
+
|
|
|
|
+ return NSString(string: s1).compare(s2)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for item in nitems {
|
|
let subFileName = item as! String
|
|
let subFileName = item as! String
|
|
let rComparePath = NSString(string: resultDirectory).appendingPathComponent(subFileName+".jpg")
|
|
let rComparePath = NSString(string: resultDirectory).appendingPathComponent(subFileName+".jpg")
|
|
let cComparePath = NSString(string: checkDirectory).appendingPathComponent(subFileName+".jpg")
|
|
let cComparePath = NSString(string: checkDirectory).appendingPathComponent(subFileName+".jpg")
|
|
|
|
|
|
- let fileInfo = NSMutableDictionary.fileInfoWith(subFileName,
|
|
|
|
|
|
+ let fileInfo = NSMutableDictionary.fileInfoWith(fileName,
|
|
|
|
+ refFilePath: (isDirectory.boolValue ? subFileName : nil),
|
|
resultPath: rComparePath,
|
|
resultPath: rComparePath,
|
|
comparePath: cComparePath,
|
|
comparePath: cComparePath,
|
|
objc: self)
|
|
objc: self)
|
|
@@ -549,10 +567,6 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
- _degree = 0.0;
|
|
|
|
- _fileDegreeInfo.removeAll()
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|