Pārlūkot izejas kodu

V1.5.0 转档库替换,文件存储格式及样式同步,对照百分比校对;

zhudongyong 2 gadi atpakaļ
vecāks
revīzija
0255536132

BIN
KdanAutoTest/KdanAuto.xcodeproj/project.xcworkspace/xcuserdata/zhudongyong.xcuserdatad/UserInterfaceState.xcuserstate


+ 18 - 2
KdanAutoTest/KdanAuto.xcodeproj/xcuserdata/zhudongyong.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -14,8 +14,8 @@
             filePath = "KdanAuto/Class/AutoTestCase/AutoTest.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "625"
-            endingLineNumber = "625"
+            startingLineNumber = "640"
+            endingLineNumber = "640"
             landmarkName = "stringToImage(_:)"
             landmarkType = "7">
          </BreakpointContent>
@@ -116,5 +116,21 @@
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "69E2542A-FB22-4698-AD51-984D3B098517"
+            shouldBeEnabled = "No"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "KdanAuto/Class/DataModel/TestDegreeManager.swift"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "77"
+            endingLineNumber = "77"
+            landmarkName = "degreeFor(_:type:fileName:refFilePath:)"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
    </Breakpoints>
 </Bucket>

+ 25 - 10
KdanAutoTest/KdanAuto/Class/AutoTestCase/AutoTest.swift

@@ -121,6 +121,7 @@ class AutoTest : NSObject, AutoTestProtocal {
         clearCacheFiles()
         
         if hasOriginFile() {
+            NSLog(String("转换\(self.type())"))
             let needCompare = self.selectedKeys().contains("快照")
             
             if !needCompare {
@@ -163,7 +164,7 @@ class AutoTest : NSObject, AutoTestProtocal {
                             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) {
+                                if (NSArray(array: [_extention]).contains(ext)) {
                                     let fileName = NSString(string: fName+"."+_extention+"/\(item as! String)").deletingPathExtension
                                     items.add(fileName)
                                 }
@@ -202,10 +203,11 @@ class AutoTest : NSObject, AutoTestProtocal {
                                             let pathCompotent = "/"+subImageName
                                             let degree = ImageProcess.compareJPEG(String(rComparePath+pathCompotent), checkPath: String(cComparePath+pathCompotent), processCover: true)
                                             
-                                            if isDirectory.boolValue {
-                                                TestDegreeManager.shared().set(degree, fileType: self.fileType(), type: self.type(),
-                                                                               fileName: fileName, refFilePath: subFileName+".jpg"+pathCompotent)
-                                            }
+                                            
+                                            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",
@@ -227,10 +229,10 @@ class AutoTest : NSObject, AutoTestProtocal {
                                         
                                         let degree = ImageProcess.compareJPEG(rComparePath, checkPath: cComparePath, processCover: true)
                                         
-                                        if isDirectory.boolValue {
-                                            TestDegreeManager.shared().set(degree, fileType: self.fileType(), type: self.type(),
-                                                                           fileName: fileName, refFilePath: subFileName+".jpg")
-                                        }
+                                        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",
@@ -296,6 +298,19 @@ class AutoTest : NSObject, AutoTestProtocal {
         convertQueue.async {
             success = FileConverter.shared().converter(originPath, inDesPath: resultPath)
             
+            // 修复转 PNG 实际图片为 JPG 问题, 导致无法匹配问题
+            if (NSArray(array: ["png", "PNG"]).contains(NSString(string: resultPath).pathExtension)) {
+                let items = FileManager.default.subpaths(atPath: resultPath)! as [String]
+                for item in items {
+                    if NSArray(array: ["jpg", "JPG"]).contains(NSString(string:item).pathExtension) {
+                        let path = NSString(string: resultPath).appendingPathComponent(item);
+                        
+                        try? FileManager.default.moveItem(atPath: path,
+                                                          toPath: NSString(string: path).deletingPathExtension+".png");
+                    }
+                }
+            }
+            
             convertSemaphore.signal()
         }
         convertSemaphore.wait()
@@ -542,7 +557,7 @@ class AutoTest : NSObject, AutoTestProtocal {
                 let cComparePath = NSString(string: checkDirectory).appendingPathComponent(subFileName+".jpg")
                 
                 let fileInfo = NSMutableDictionary.fileInfoWith(fileName,
-                                                                refFilePath: (isDirectory.boolValue ? (subFileName+".jpg") : nil),
+                                                                refFilePath: subFileName+".jpg",
                                                                 resultPath: rComparePath,
                                                                 comparePath: cComparePath,
                                                                 objc: self)

+ 7 - 2
KdanAutoTest/KdanAuto/Class/AutoTestCase/StringAutoTest.swift

@@ -66,7 +66,7 @@ class CharacterAutoTest : AutoTest {
             var success = process(originPath, resultPath: resultPath)
             
             if FileManager.default.fileExists(atPath: resultPath) && success {
-                if checkString {
+                if checkString && FileManager.default.fileExists(atPath: checkPath) {
                     // Load check file
                     let checkData = NSData.init(contentsOfFile: checkPath) as! Data
                     var documentAttributes:NSDictionary!
@@ -247,7 +247,12 @@ class CharacterAutoTest : AutoTest {
                                 TestDegreeManager.shared().set(degree,
                                                                fileType: self.fileType(),
                                                                type: self.type(),
-                                                               fileName: fileName)
+                                                               fileName: fileName);
+                                TestDegreeManager.shared().set(degree,
+                                                               fileType: self.fileType(),
+                                                               type: self.type(),
+                                                               fileName: fileName,
+                                                               refFilePath: fName+".jpg");
                                 
                                 tDegree += degree
                                 tCount += 1

+ 5 - 0
KdanAutoTest/KdanAuto/Class/AutoTestCase/TextColorAutoTest.swift

@@ -287,6 +287,11 @@ class TextColorAutoTest : AutoTest {
                                                                fileType: self.fileType(),
                                                                type: self.type(),
                                                                fileName: fileName)
+                                TestDegreeManager.shared().set(degree,
+                                                               fileType: self.fileType(),
+                                                               type: self.type(),
+                                                               fileName: fileName,
+                                                               refFilePath: fName+".jpg");
                                 
                                 tDegree += degree
                                 tCount += 1