Browse Source

结果校对 - 颜色值转换结果校对前数据解析

zhudongyong 2 years ago
parent
commit
e0be4ad374

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


+ 7 - 0
KdanAutoTest/KdanAuto/Class/AutoTestCase/AutoTest.swift

@@ -6,6 +6,7 @@
 //
 
 import Foundation
+import AppKit
 
 let testCaseNames = [
     "PDFConvert_Font_Auto_Test",
@@ -15,6 +16,8 @@ let testCaseNames = [
 ]
 
 class AutoTest : NSObject, AutoTestProtocal {
+    var reportString : NSAttributedString? = nil
+    
     class func autoTestForType(_ type:NSString) -> AutoTest? {
         
         if type.isEqual(to: "PDFConvert_Font_Auto_Test") {
@@ -82,6 +85,10 @@ class AutoTest : NSObject, AutoTestProtocal {
     }
     
     
+    func testReport() -> NSAttributedString? {
+        return reportString
+    }
+    
     /// Path
     func originFilePath() -> String {
         return DataModel.shared.originPath().appendingFormat("/\(self.type()).pdf")

+ 3 - 1
KdanAutoTest/KdanAuto/Class/AutoTestCase/AutoTestProtocal.swift

@@ -8,7 +8,7 @@
 import Foundation
 
 protocol AutoTestProtocal : NSObjectProtocol {
-    
+    // 类型关键字
     func type() -> String
     func name() -> String
     
@@ -19,4 +19,6 @@ protocol AutoTestProtocal : NSObjectProtocol {
     
     func autoTest()
     func autoCheck()
+    
+    func testReport() -> NSAttributedString?
 }

+ 9 - 0
KdanAutoTest/KdanAuto/Class/AutoTestCase/ChineseStringAutoTest.swift

@@ -30,6 +30,15 @@ class ChineseStringAutoTest : AutoTest {
     
     // Auto Test refrence Check File
     override func autoTest() {
+        // 暂时先用转RTF做为范例
+        let checkPath = self.checkFilePath()
+        let originPath = self.originFilePath()
+        
+        let checkData = NSData.init(contentsOfFile: checkPath) as! Data
+        var documentAttributes:NSDictionary!
+        let checkAttString = NSAttributedString.init(rtf: checkData, documentAttributes: &documentAttributes)
+        
+        NSLog("\(checkAttString)")
         
     }
     

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

@@ -6,6 +6,7 @@
 //
 
 import Foundation
+import AppKit
 
 class TextColorAutoTest : AutoTest {
     
@@ -29,7 +30,29 @@ class TextColorAutoTest : AutoTest {
     
     // Auto Test refrence Check File
     override func autoTest() {
+        let originPath = self.originFilePath()
         
+        // ...
+        // 执行转换过程
+        
+        let resultPath = self.resultFilePath()
+        if self.isResultFileExist() {
+            // 转换成功
+            let checkPath = self.checkFilePath()
+            
+            let checkData = NSData.init(contentsOfFile: checkPath) as! Data
+            var cDocumentAttributes:NSDictionary!
+            let checkAttString = NSAttributedString.init(rtf: checkData, documentAttributes: &cDocumentAttributes)
+            
+            let resultData = NSData.init(contentsOfFile: resultPath) as! Data
+            var rDocumentAttributes:NSDictionary!
+            let resultAttString = NSAttributedString.init(rtf: resultData, documentAttributes: &rDocumentAttributes)
+            
+            NSLog("\(checkAttString)")
+        } else {
+            reportString = NSAttributedString.init(string: "\n【\(self.type())】转档失败!\n",
+                                                   attributes:[.foregroundColor : NSColor.red])
+        }
     }
     
     // Auto Test refrence Latest Status

+ 1 - 4
KdanAutoTest/KdanAuto/ViewController.swift

@@ -137,10 +137,7 @@ class ViewController : NSViewController, SettingViewControllerDelegate, AutoTest
         
     }
     
-    func tableView(_ tableView: NSTableView?, heightOfRow ros: Int) -> CGFloat {
-        if row == 0 {
-            
-        }
+    func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat {
         return 60
     }