Browse Source

RTF - 拆分文档自动化测试验证,快照生成验证

zhudongyong 2 years ago
parent
commit
ad1f5ca62a
23 changed files with 729 additions and 630 deletions
  1. 14 24
      KdanAutoTest/KdanAuto.xcodeproj/project.pbxproj
  2. BIN
      KdanAutoTest/KdanAuto.xcodeproj/project.xcworkspace/xcuserdata/zhudongyong.xcuserdatad/UserInterfaceState.xcuserstate
  3. 30 78
      KdanAutoTest/KdanAuto.xcodeproj/xcuserdata/zhudongyong.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
  4. 73 9
      KdanAutoTest/KdanAuto/Base.lproj/Main.storyboard
  5. 15 23
      KdanAutoTest/KdanAuto/Class/AutoTestCase/AutoTest.swift
  6. 3 3
      KdanAutoTest/KdanAuto/Class/AutoTestCase/AutoTestProperty.plist
  7. 0 1
      KdanAutoTest/KdanAuto/Class/AutoTestCase/AutoTestProtocal.swift
  8. 0 259
      KdanAutoTest/KdanAuto/Class/AutoTestCase/ChineseStringAutoTest.swift
  9. 5 12
      KdanAutoTest/KdanAuto/Class/AutoTestCase/FontAutoTest.swift
  10. 0 16
      KdanAutoTest/KdanAuto/Class/AutoTestCase/RTFAutoTest.swift
  11. 0 28
      KdanAutoTest/KdanAuto/Class/AutoTestCase/SpecialCharacterAutoTest.swift
  12. 271 0
      KdanAutoTest/KdanAuto/Class/AutoTestCase/StringAutoTest.swift
  13. 89 71
      KdanAutoTest/KdanAuto/Class/AutoTestCase/TextColorAutoTest.swift
  14. 0 16
      KdanAutoTest/KdanAuto/Class/AutoTestCase/WordAutoTest.swift
  15. 22 1
      KdanAutoTest/KdanAuto/Class/DataModel/DataModel.swift
  16. 89 6
      KdanAutoTest/KdanAuto/Class/Norrmal/AutoTestAdvanceSettingView.swift
  17. 2 0
      KdanAutoTest/KdanAuto/Class/Norrmal/Cell/AutoTestCellInfo.swift
  18. 9 9
      KdanAutoTest/KdanAuto/Class/Norrmal/Cell/TestCaseCellView.swift
  19. 3 3
      KdanAutoTest/KdanAuto/Class/Norrmal/Cell/TestCaseCellView.xib
  20. 4 4
      KdanAutoTest/KdanAuto/Class/Norrmal/Cell/TestTypeCellView.swift
  21. 3 12
      KdanAutoTest/KdanAuto/Class/Norrmal/Cell/TestTypeCellView.xib
  22. 77 41
      KdanAutoTest/KdanAuto/ViewController.swift
  23. 20 14
      KdanAutoTest/ProcessCheckFile/Process/ProcessThumbnal.swift

+ 14 - 24
KdanAutoTest/KdanAuto.xcodeproj/project.pbxproj

@@ -14,12 +14,11 @@
 		243DACD32940C6E8008A8AA6 /* ActivityView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 243DACD22940C6E8008A8AA6 /* ActivityView.swift */; };
 		24A6FF49293091E000B34F2E /* AutoTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24A6FF48293091E000B34F2E /* AutoTest.swift */; };
 		24A6FF4B2930939D00B34F2E /* TextColorAutoTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24A6FF4A2930939D00B34F2E /* TextColorAutoTest.swift */; };
-		24A6FF4D2930988F00B34F2E /* SpecialCharacterAutoTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24A6FF4C2930988F00B34F2E /* SpecialCharacterAutoTest.swift */; };
 		24A6FF4F2930A1E100B34F2E /* FontAutoTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24A6FF4E2930A1E100B34F2E /* FontAutoTest.swift */; };
 		24A6FF512930AC4D00B34F2E /* AutoTestAdvanceSettingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24A6FF502930AC4D00B34F2E /* AutoTestAdvanceSettingView.swift */; };
 		24D70000292B6FD100DAB5EE /* SettingViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 24D7FFFF292B6FD100DAB5EE /* SettingViewController.xib */; };
 		24D70009292D14DA00DAB5EE /* AutoTestProtocal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24D70008292D14DA00DAB5EE /* AutoTestProtocal.swift */; };
-		24D7000B292D16BB00DAB5EE /* ChineseStringAutoTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24D7000A292D16BB00DAB5EE /* ChineseStringAutoTest.swift */; };
+		24D7000B292D16BB00DAB5EE /* StringAutoTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24D7000A292D16BB00DAB5EE /* StringAutoTest.swift */; };
 		24D7FF9B29261A6400DAB5EE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24D7FF9A29261A6400DAB5EE /* AppDelegate.swift */; };
 		24D7FF9D29261A6400DAB5EE /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24D7FF9C29261A6400DAB5EE /* ViewController.swift */; };
 		24D7FF9F29261A6600DAB5EE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 24D7FF9E29261A6600DAB5EE /* Assets.xcassets */; };
@@ -42,12 +41,11 @@
 		24DCE8A9295046A5004EBA35 /* TestCaseCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24DCE8A7295046A5004EBA35 /* TestCaseCellView.swift */; };
 		24DCE8AC295046E7004EBA35 /* TestFileTypeCellView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 24DCE8AA295046E7004EBA35 /* TestFileTypeCellView.xib */; };
 		24DCE8AD295046E7004EBA35 /* TestFileTypeCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24DCE8AB295046E7004EBA35 /* TestFileTypeCellView.swift */; };
-		24DCE8B0295047D8004EBA35 /* TestTypeCellView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 24DCE8AE295047D8004EBA35 /* TestTypeCellView.xib */; };
-		24DCE8B1295047D8004EBA35 /* TestTypeCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24DCE8AF295047D8004EBA35 /* TestTypeCellView.swift */; };
+		24DCE8B0295047D8004EBA35 /* TestFileCellView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 24DCE8AE295047D8004EBA35 /* TestFileCellView.xib */; };
+		24DCE8B1295047D8004EBA35 /* TestFileCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24DCE8AF295047D8004EBA35 /* TestFileCellView.swift */; };
 		24DCE8B32950543C004EBA35 /* AutoTestCellInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24DCE8B22950543C004EBA35 /* AutoTestCellInfo.swift */; };
 		24DCE8B529506CDE004EBA35 /* AutoTestProperty.plist in Resources */ = {isa = PBXBuildFile; fileRef = 24DCE8B429506CDE004EBA35 /* AutoTestProperty.plist */; };
-		24DCE8B829508806004EBA35 /* RTFAutoTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24DCE8B729508806004EBA35 /* RTFAutoTest.swift */; };
-		24DCE8BA29508845004EBA35 /* WordAutoTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24DCE8B929508845004EBA35 /* WordAutoTest.swift */; };
+		24DCE8BB29518FD3004EBA35 /* ProcessThumbnal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 240509B62943479800B501B2 /* ProcessThumbnal.swift */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
@@ -89,12 +87,11 @@
 		243DACD22940C6E8008A8AA6 /* ActivityView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityView.swift; sourceTree = "<group>"; };
 		24A6FF48293091E000B34F2E /* AutoTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoTest.swift; sourceTree = "<group>"; };
 		24A6FF4A2930939D00B34F2E /* TextColorAutoTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextColorAutoTest.swift; sourceTree = "<group>"; };
-		24A6FF4C2930988F00B34F2E /* SpecialCharacterAutoTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpecialCharacterAutoTest.swift; sourceTree = "<group>"; };
 		24A6FF4E2930A1E100B34F2E /* FontAutoTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FontAutoTest.swift; sourceTree = "<group>"; };
 		24A6FF502930AC4D00B34F2E /* AutoTestAdvanceSettingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoTestAdvanceSettingView.swift; sourceTree = "<group>"; };
 		24D70001292B71FB00DAB5EE /* KdanAutoDebug.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = KdanAutoDebug.entitlements; sourceTree = "<group>"; };
 		24D70008292D14DA00DAB5EE /* AutoTestProtocal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoTestProtocal.swift; sourceTree = "<group>"; };
-		24D7000A292D16BB00DAB5EE /* ChineseStringAutoTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChineseStringAutoTest.swift; sourceTree = "<group>"; };
+		24D7000A292D16BB00DAB5EE /* StringAutoTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringAutoTest.swift; sourceTree = "<group>"; };
 		24D7FF9729261A6400DAB5EE /* KdanAuto.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = KdanAuto.app; sourceTree = BUILT_PRODUCTS_DIR; };
 		24D7FF9A29261A6400DAB5EE /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
 		24D7FF9C29261A6400DAB5EE /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
@@ -127,12 +124,10 @@
 		24DCE8A7295046A5004EBA35 /* TestCaseCellView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestCaseCellView.swift; sourceTree = "<group>"; };
 		24DCE8AA295046E7004EBA35 /* TestFileTypeCellView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = TestFileTypeCellView.xib; sourceTree = "<group>"; };
 		24DCE8AB295046E7004EBA35 /* TestFileTypeCellView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestFileTypeCellView.swift; sourceTree = "<group>"; };
-		24DCE8AE295047D8004EBA35 /* TestTypeCellView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = TestTypeCellView.xib; sourceTree = "<group>"; };
-		24DCE8AF295047D8004EBA35 /* TestTypeCellView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestTypeCellView.swift; sourceTree = "<group>"; };
+		24DCE8AE295047D8004EBA35 /* TestFileCellView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = TestFileCellView.xib; sourceTree = "<group>"; };
+		24DCE8AF295047D8004EBA35 /* TestFileCellView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestFileCellView.swift; sourceTree = "<group>"; };
 		24DCE8B22950543C004EBA35 /* AutoTestCellInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoTestCellInfo.swift; sourceTree = "<group>"; };
 		24DCE8B429506CDE004EBA35 /* AutoTestProperty.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = AutoTestProperty.plist; sourceTree = "<group>"; };
-		24DCE8B729508806004EBA35 /* RTFAutoTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RTFAutoTest.swift; sourceTree = "<group>"; };
-		24DCE8B929508845004EBA35 /* WordAutoTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordAutoTest.swift; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -219,11 +214,8 @@
 				24DCE8A329504430004EBA35 /* AutoTestTypes.swift */,
 				24D70008292D14DA00DAB5EE /* AutoTestProtocal.swift */,
 				24A6FF48293091E000B34F2E /* AutoTest.swift */,
-				24DCE8B729508806004EBA35 /* RTFAutoTest.swift */,
-				24DCE8B929508845004EBA35 /* WordAutoTest.swift */,
-				24D7000A292D16BB00DAB5EE /* ChineseStringAutoTest.swift */,
+				24D7000A292D16BB00DAB5EE /* StringAutoTest.swift */,
 				24A6FF4A2930939D00B34F2E /* TextColorAutoTest.swift */,
-				24A6FF4C2930988F00B34F2E /* SpecialCharacterAutoTest.swift */,
 				24A6FF4E2930A1E100B34F2E /* FontAutoTest.swift */,
 			);
 			path = AutoTestCase;
@@ -359,8 +351,8 @@
 		24DCE8A5295046A5004EBA35 /* Cell */ = {
 			isa = PBXGroup;
 			children = (
-				24DCE8AF295047D8004EBA35 /* TestTypeCellView.swift */,
-				24DCE8AE295047D8004EBA35 /* TestTypeCellView.xib */,
+				24DCE8AF295047D8004EBA35 /* TestFileCellView.swift */,
+				24DCE8AE295047D8004EBA35 /* TestFileCellView.xib */,
 				24DCE8AB295046E7004EBA35 /* TestFileTypeCellView.swift */,
 				24DCE8AA295046E7004EBA35 /* TestFileTypeCellView.xib */,
 				24DCE8A6295046A5004EBA35 /* TestCaseCellView.xib */,
@@ -553,7 +545,7 @@
 				24DCE8B529506CDE004EBA35 /* AutoTestProperty.plist in Resources */,
 				24D70000292B6FD100DAB5EE /* SettingViewController.xib in Resources */,
 				24D7FFA229261A6600DAB5EE /* Main.storyboard in Resources */,
-				24DCE8B0295047D8004EBA35 /* TestTypeCellView.xib in Resources */,
+				24DCE8B0295047D8004EBA35 /* TestFileCellView.xib in Resources */,
 				24DCE8AC295046E7004EBA35 /* TestFileTypeCellView.xib in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -603,23 +595,21 @@
 			buildActionMask = 2147483647;
 			files = (
 				24D70009292D14DA00DAB5EE /* AutoTestProtocal.swift in Sources */,
-				24A6FF4D2930988F00B34F2E /* SpecialCharacterAutoTest.swift in Sources */,
 				24A6FF4F2930A1E100B34F2E /* FontAutoTest.swift in Sources */,
 				24A6FF49293091E000B34F2E /* AutoTest.swift in Sources */,
+				24DCE8BB29518FD3004EBA35 /* ProcessThumbnal.swift in Sources */,
 				24D7FF9D29261A6400DAB5EE /* ViewController.swift in Sources */,
 				24A6FF512930AC4D00B34F2E /* AutoTestAdvanceSettingView.swift in Sources */,
 				24DCE8AD295046E7004EBA35 /* TestFileTypeCellView.swift in Sources */,
 				24D7FFFE292B509000DAB5EE /* DataModel.swift in Sources */,
 				24D7FF9B29261A6400DAB5EE /* AppDelegate.swift in Sources */,
 				243DACD32940C6E8008A8AA6 /* ActivityView.swift in Sources */,
-				24D7000B292D16BB00DAB5EE /* ChineseStringAutoTest.swift in Sources */,
+				24D7000B292D16BB00DAB5EE /* StringAutoTest.swift in Sources */,
 				24DCE8A9295046A5004EBA35 /* TestCaseCellView.swift in Sources */,
 				24D7FFFB292B501100DAB5EE /* SettingViewController.swift in Sources */,
-				24DCE8B829508806004EBA35 /* RTFAutoTest.swift in Sources */,
 				24DCE8A429504430004EBA35 /* AutoTestTypes.swift in Sources */,
 				24DCE8B32950543C004EBA35 /* AutoTestCellInfo.swift in Sources */,
-				24DCE8BA29508845004EBA35 /* WordAutoTest.swift in Sources */,
-				24DCE8B1295047D8004EBA35 /* TestTypeCellView.swift in Sources */,
+				24DCE8B1295047D8004EBA35 /* TestFileCellView.swift in Sources */,
 				24A6FF4B2930939D00B34F2E /* TextColorAutoTest.swift in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;

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


+ 30 - 78
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 = "167"
-            endingLineNumber = "167"
+            startingLineNumber = "159"
+            endingLineNumber = "159"
             landmarkName = "stringToImage(_:)"
             landmarkType = "7">
          </BreakpointContent>
@@ -23,15 +23,15 @@
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
-            uuid = "F73D4F30-3B42-4FA7-95C9-E8D3D4B71A26"
+            uuid = "BE82D1A4-86CD-4BB0-8D10-81DF8FE4BC37"
             shouldBeEnabled = "No"
             ignoreCount = "0"
             continueAfterRunningActions = "No"
-            filePath = "KdanAuto/Class/AutoTestCase/TextColorAutoTest.swift"
+            filePath = "KdanAuto/Class/AutoTestCase/ChineseStringAutoTest.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "41"
-            endingLineNumber = "41"
+            startingLineNumber = "34"
+            endingLineNumber = "34"
             landmarkName = "autoTest()"
             landmarkType = "7">
          </BreakpointContent>
@@ -39,47 +39,47 @@
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
-            uuid = "B249943F-1C9E-4636-97D1-DB2DB2618D11"
-            shouldBeEnabled = "No"
+            uuid = "B00CE63B-56B3-4419-B64E-CCE9098EDE56"
+            shouldBeEnabled = "Yes"
             ignoreCount = "0"
             continueAfterRunningActions = "No"
-            filePath = "KdanAuto/Class/AutoTestCase/TextColorAutoTest.swift"
+            filePath = "KdanAuto/ViewController.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "187"
-            endingLineNumber = "187"
-            landmarkName = "autoTest()"
+            startingLineNumber = "191"
+            endingLineNumber = "191"
+            landmarkName = "tableView(_:shouldSelect:)"
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
-            uuid = "4A31CAC7-35B0-4E97-A907-8935F005B410"
+            uuid = "B54E22B4-6E30-41B2-B5D8-90862655E3C6"
             shouldBeEnabled = "No"
             ignoreCount = "0"
             continueAfterRunningActions = "No"
-            filePath = "KdanAuto/Class/AutoTestCase/TextColorAutoTest.swift"
+            filePath = "KdanAuto/Class/AutoTestCase/AutoTest.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "199"
-            endingLineNumber = "199"
-            landmarkName = "autoTest()"
+            startingLineNumber = "31"
+            endingLineNumber = "31"
+            landmarkName = "autoTestFor(_:type:)"
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
-            uuid = "1ABBAD0F-5D3E-4CD3-A351-B8F62C48A917"
-            shouldBeEnabled = "No"
+            uuid = "F47EEC65-D2F8-447A-952F-2E946A0D5865"
+            shouldBeEnabled = "Yes"
             ignoreCount = "0"
             continueAfterRunningActions = "No"
             filePath = "KdanAuto/Class/AutoTestCase/ChineseStringAutoTest.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "49"
-            endingLineNumber = "49"
+            startingLineNumber = "213"
+            endingLineNumber = "213"
             landmarkName = "autoTest()"
             landmarkType = "7">
          </BreakpointContent>
@@ -87,15 +87,15 @@
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
-            uuid = "BE82D1A4-86CD-4BB0-8D10-81DF8FE4BC37"
-            shouldBeEnabled = "No"
+            uuid = "70DF023C-5390-49BC-8A4D-02729A885041"
+            shouldBeEnabled = "Yes"
             ignoreCount = "0"
             continueAfterRunningActions = "No"
             filePath = "KdanAuto/Class/AutoTestCase/ChineseStringAutoTest.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "36"
-            endingLineNumber = "36"
+            startingLineNumber = "49"
+            endingLineNumber = "49"
             landmarkName = "autoTest()"
             landmarkType = "7">
          </BreakpointContent>
@@ -103,64 +103,16 @@
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
-            uuid = "B00CE63B-56B3-4419-B64E-CCE9098EDE56"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "KdanAuto/ViewController.swift"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "166"
-            endingLineNumber = "166"
-            landmarkName = "tableView(_:shouldSelect:)"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "E9C25D88-92BC-47CF-BC4D-59A9993A9D60"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "KdanAuto/Class/Norrmal/ActivityView/ActivityView.swift"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "178"
-            endingLineNumber = "178"
-            landmarkName = "updateStatus()"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "E8826860-4436-49CB-AF21-CBEE62A4F2B3"
+            uuid = "FDA93AAD-DD5C-41D4-980B-D261C7BA8D5D"
             shouldBeEnabled = "Yes"
             ignoreCount = "0"
             continueAfterRunningActions = "No"
-            filePath = "KdanAuto/Class/Norrmal/ActivityView/ActivityView.swift"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "110"
-            endingLineNumber = "110"
-            landmarkName = "reloadSubviews()"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "B54E22B4-6E30-41B2-B5D8-90862655E3C6"
-            shouldBeEnabled = "No"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "KdanAuto/Class/AutoTestCase/AutoTest.swift"
+            filePath = "KdanAuto/Class/AutoTestCase/ChineseStringAutoTest.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "30"
-            endingLineNumber = "30"
-            landmarkName = "autoTestFor(_:type:)"
+            startingLineNumber = "51"
+            endingLineNumber = "51"
+            landmarkName = "autoTest()"
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>

+ 73 - 9
KdanAutoTest/KdanAuto/Base.lproj/Main.storyboard

@@ -685,7 +685,7 @@
             <objects>
                 <windowController id="B8D-0N-5wS" sceneMemberID="viewController">
                     <window key="window" title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" titleVisibility="hidden" id="IQv-IB-iLA">
-                        <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
+                        <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
                         <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
                         <rect key="contentRect" x="196" y="240" width="800" height="600"/>
                         <rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
@@ -726,30 +726,94 @@
                                                     <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                                 </textFieldCell>
                                             </textField>
-                                            <scrollView fixedFrame="YES" borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="AmP-9q-6TA">
-                                                <rect key="frame" x="40" y="36" width="475" height="415"/>
-                                                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+                                            <scrollView borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" usesPredominantAxisScrolling="NO" id="AmP-9q-6TA">
+                                                <rect key="frame" x="40" y="338" width="475" height="113"/>
+                                                <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
                                                 <clipView key="contentView" drawsBackground="NO" id="n3n-SJ-Ypz">
-                                                    <rect key="frame" x="0.0" y="0.0" width="475" height="415"/>
+                                                    <rect key="frame" x="0.0" y="0.0" width="475" height="113"/>
                                                     <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                                     <subviews>
                                                         <view id="S9g-Wx-VNn">
-                                                            <rect key="frame" x="0.0" y="0.0" width="460" height="400"/>
+                                                            <rect key="frame" x="0.0" y="-302" width="460" height="400"/>
                                                             <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                                                         </view>
                                                     </subviews>
                                                 </clipView>
                                                 <scroller key="horizontalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="Piq-J5-Npt">
-                                                    <rect key="frame" x="0.0" y="399" width="475" height="16"/>
+                                                    <rect key="frame" x="0.0" y="97" width="475" height="16"/>
+                                                    <autoresizingMask key="autoresizingMask"/>
+                                                </scroller>
+                                                <scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="RDM-Fo-oeX">
+                                                    <rect key="frame" x="459" y="0.0" width="16" height="113"/>
+                                                    <autoresizingMask key="autoresizingMask"/>
+                                                </scroller>
+                                            </scrollView>
+                                            <scrollView borderType="none" horizontalLineScroll="24" horizontalPageScroll="10" verticalLineScroll="24" verticalPageScroll="10" hasHorizontalScroller="NO" hasVerticalScroller="NO" usesPredominantAxisScrolling="NO" id="yne-Go-aGr">
+                                                <rect key="frame" x="10" y="9" width="501" height="321"/>
+                                                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                                                <clipView key="contentView" drawsBackground="NO" id="NxD-NS-AL6">
+                                                    <rect key="frame" x="0.0" y="0.0" width="501" height="321"/>
+                                                    <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                                                    <subviews>
+                                                        <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" multipleSelection="NO" autosaveColumns="NO" rowHeight="24" rowSizeStyle="automatic" viewBased="YES" id="3yx-Nh-6Zg">
+                                                            <rect key="frame" x="0.0" y="0.0" width="501" height="321"/>
+                                                            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                                                            <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                                            <color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
+                                                            <tableColumns>
+                                                                <tableColumn identifier="AutomaticTableColumnIdentifier.0" width="469" minWidth="40" maxWidth="1000" id="tho-Im-VMj">
+                                                                    <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border">
+                                                                        <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
+                                                                        <color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
+                                                                    </tableHeaderCell>
+                                                                    <textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="XcW-Mt-5Nc">
+                                                                        <font key="font" metaFont="system"/>
+                                                                        <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+                                                                        <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                                                    </textFieldCell>
+                                                                    <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
+                                                                    <prototypeCellViews>
+                                                                        <tableCellView id="Tt2-uB-m3g">
+                                                                            <rect key="frame" x="10" y="0.0" width="481" height="24"/>
+                                                                            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                                                                            <subviews>
+                                                                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="MRV-3Y-yO9">
+                                                                                    <rect key="frame" x="0.0" y="4" width="481" height="16"/>
+                                                                                    <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
+                                                                                    <textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="rww-Rv-HvX">
+                                                                                        <font key="font" usesAppearanceFont="YES"/>
+                                                                                        <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+                                                                                        <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                                                                    </textFieldCell>
+                                                                                </textField>
+                                                                            </subviews>
+                                                                            <connections>
+                                                                                <outlet property="textField" destination="MRV-3Y-yO9" id="PrR-Eo-y5b"/>
+                                                                            </connections>
+                                                                        </tableCellView>
+                                                                    </prototypeCellViews>
+                                                                </tableColumn>
+                                                            </tableColumns>
+                                                            <connections>
+                                                                <outlet property="dataSource" destination="Kjq-VU-WrU" id="ppS-sn-ZZI"/>
+                                                                <outlet property="delegate" destination="Kjq-VU-WrU" id="XvG-En-5af"/>
+                                                            </connections>
+                                                        </tableView>
+                                                    </subviews>
+                                                    <nil key="backgroundColor"/>
+                                                </clipView>
+                                                <scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="vLO-FY-5D0">
+                                                    <rect key="frame" x="-100" y="-100" width="141" height="16"/>
                                                     <autoresizingMask key="autoresizingMask"/>
                                                 </scroller>
-                                                <scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="RDM-Fo-oeX">
-                                                    <rect key="frame" x="459" y="0.0" width="16" height="415"/>
+                                                <scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="suF-OV-khW">
+                                                    <rect key="frame" x="-100" y="-100" width="15" height="102"/>
                                                     <autoresizingMask key="autoresizingMask"/>
                                                 </scroller>
                                             </scrollView>
                                         </subviews>
                                         <connections>
+                                            <outlet property="_fileList" destination="3yx-Nh-6Zg" id="Fvu-8v-vPN"/>
                                             <outlet property="_keyContentView" destination="S9g-Wx-VNn" id="Ns7-LW-Z1T"/>
                                             <outlet property="_keyScrollView" destination="AmP-9q-6TA" id="ynY-Qs-1DP"/>
                                             <outlet property="_titleLbl" destination="97D-lF-aBw" id="IzQ-1i-sEY"/>

+ 15 - 23
KdanAutoTest/KdanAuto/Class/AutoTestCase/AutoTest.swift

@@ -14,6 +14,7 @@ class AutoTest : NSObject, AutoTestProtocal {
     public var _status :  AutoTestStatus = .Normal
     
     var _fileType : String = "RTF"
+    var _type : String = "Others"
     
     class func autoTestFor(_ fileType:NSString ,type:NSString) -> AutoTest? {
         let fileTypes = testTypeInfo[fileType] as! NSArray
@@ -30,6 +31,7 @@ class AutoTest : NSObject, AutoTestProtocal {
                 
                 let object = cl.shared()
                 object?._fileType = fileType as! String
+                object?._type = String(cType)
                 
                 return object
             }
@@ -38,6 +40,7 @@ class AutoTest : NSObject, AutoTestProtocal {
         let object = AutoTest.shared()
         
         object?._fileType = fileType as String
+        object?._type = String(cType)
         
         return object
     }
@@ -52,7 +55,7 @@ class AutoTest : NSObject, AutoTestProtocal {
     }
     
     func type() -> String {
-        return "Others"
+        return _type
     }
     
     func name() -> String {
@@ -99,48 +102,37 @@ class AutoTest : NSObject, AutoTestProtocal {
         
     }
     
-    func autoCheck() {
-        
-    }
-    
-    
     func testReport() -> NSAttributedString? {
         return reportString
     }
     
     /// Path
-    func originFilePath() -> String {
+    func originFileDirectory() -> String {
         return DataModel.shared.directoryPath().appendingFormat("/\(self.fileType())/\(self.type())/\(kOriginPathComponent)")
     }
     
-    func resultFilePath() -> String {
+    func resultFileDirectory() -> String {
         return DataModel.shared.directoryPath().appendingFormat("/\(self.fileType())/\(self.type())/\(kResultPathComponent)")
     }
     
-    func checkFilePath() -> String {
+    func checkFileDirectory() -> String {
         return DataModel.shared.directoryPath().appendingFormat("/\(self.fileType())/\(self.type())/\(kCheckPathComponent)")
     }
     
     // check File Exist
-    func isOriginFileExist() -> Bool {
-        if nil != self.originFilePath() {
-            return FileManager.default.fileExists(atPath: self.originFilePath())
-        }
-        
-        return false
-    }
-    
-    func isResultFileExist() -> Bool {
-        if nil != self.resultFilePath() {
-            return FileManager.default.fileExists(atPath: self.resultFilePath())
+    func hasOriginFileExist() -> Bool {
+        if nil != self.originFileDirectory() {
+            return (FileManager.default.fileExists(atPath: self.originFileDirectory()) &&
+                    FileManager.default.subpaths(atPath: self.originFileDirectory())!.count > 0)
         }
         
         return false
     }
     
-    func isCheckFileExist() -> Bool {
-        if nil != self.checkFilePath() {
-            return FileManager.default.fileExists(atPath: self.checkFilePath())
+    func hasResultFileExist() -> Bool {
+        if nil != self.resultFileDirectory() {
+            return (FileManager.default.fileExists(atPath: self.resultFileDirectory()) &&
+                    FileManager.default.subpaths(atPath: self.resultFileDirectory())!.count > 0)
         }
         
         return false

+ 3 - 3
KdanAutoTest/KdanAuto/Class/AutoTestCase/AutoTestProperty.plist

@@ -20,13 +20,13 @@
 			<key>Type</key>
 			<string>Characters</string>
 			<key>Class</key>
-			<string>ChineseStringAutoTest</string>
+			<string>CharacterAutoTest</string>
 		</dict>
 		<dict>
 			<key>Type</key>
 			<string>Others</string>
 			<key>Class</key>
-			<string>RTFAutoTest</string>
+			<string>AutoTest</string>
 		</dict>
 	</array>
 	<key>Word</key>
@@ -35,7 +35,7 @@
 			<key>Type</key>
 			<string>Others</string>
 			<key>Class</key>
-			<string>WordAutoTest</string>
+			<string>AutoTest</string>
 		</dict>
 	</array>
 	<key>PPT</key>

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

@@ -32,7 +32,6 @@ protocol AutoTestProtocal : NSObjectProtocol {
     func setSelectedKeys(_ keys:NSArray)
     
     func autoTest()
-    func autoCheck()
     
     func testReport() -> NSAttributedString?
     

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

@@ -1,259 +0,0 @@
-//
-//  ChineseStringAutoTest.swift
-//  KdanAuto
-//
-//  Created by 朱东勇 on 2022/11/22.
-//
-
-import Foundation
-import Cocoa
-
-class ChineseStringAutoTest : AutoTest {
-    
-    override func type() -> String {
-        return "PDFConvert_China_Auto_Test"
-    }
-    
-    override func name() -> String {
-        return "中文字符转换准确率测试"
-    }
-    
-    override func keys() -> NSArray {
-        return ["字符对比", "快照对比"]
-    }
-    
-    static var cSharedInstance = ChineseStringAutoTest()
-    override class func shared() -> AutoTest? {
-        return cSharedInstance
-    }
-    
-    
-    // Auto Test refrence Check File
-    override func autoTest() {
-        _status = .Process
-        
-        let checkString = self.selectedKeys().contains("字符对比")
-        let needCompare = self.selectedKeys().contains("快照对比")
-        
-        if !needCompare && !checkString {
-            return
-        }
-        
-        // 暂时先用转RTF做为范例
-        let checkPath = self.checkFilePath()
-        let originPath = self.originFilePath()
-        
-        // ...
-        // 执行转换过程
-        
-        if self.isResultFileExist() {
-            if checkString {
-                reportString = NSMutableAttributedString.init(string: "\n【\(self.name())】字符比对开始!\n",
-                                                              attributes:[.foregroundColor : NSColor.blue])
-                
-                // Load check file
-                let checkData = NSData.init(contentsOfFile: checkPath) as! Data
-                var documentAttributes:NSDictionary!
-                let checkAttString = NSAttributedString.init(rtf: checkData, documentAttributes: &documentAttributes)
-                var checkString = NSString(string: checkAttString!.string) as NSString
-                
-                let resultPath = self.resultFilePath()
-                let resultString = try? NSString.init(contentsOfFile: resultPath, encoding: NSUTF8StringEncoding)
-                
-                
-#if true
-                //识别字符串 \shptxt\shptxt ... }
-                let pageInfoStrings = resultString!.components(separatedBy: "\\shptxt\\shptxt") as NSArray
-                var finalString = ""
-                if pageInfoStrings.count > 0 {
-                    let subStrings = pageInfoStrings.subarray(with: NSMakeRange(1, Int(pageInfoStrings.count - 1))) as! [String]
-                    for pageInfoString in subStrings {
-                        let endRange = NSString(string: pageInfoString).range(of: "}")
-                        finalString = finalString.appending(NSString(string: pageInfoString).substring(to: endRange.location))
-                    }
-                }
-                
-                
-                //识别所有 【空格 ~ \】 之间的值,并进行缝合
-                // Detect all strings between Spaces and \ and stitch
-                let strings = finalString.components(separatedBy: " ")
-                var resultStr = "" as NSString
-                for str in strings {
-                    let markStr = str as NSString
-                    
-                    if (markStr.contains("\\f")) {
-                        let fRange = markStr.range(of: "\\f")
-                        let cRange = markStr.range(of: "\\c")
-                        let bRange = markStr.range(of: "\\b")
-                        let iRange = markStr.range(of: "\\i")
-                        let eRange = markStr.range(of: "\\e")
-                        let pRange = markStr.range(of: "\\p")
-                        let minPos = min(Int(fRange.location),
-                                         Int(cRange.location),
-                                         Int(bRange.location),
-                                         Int(iRange.location),
-                                         Int(eRange.location),
-                                         Int(pRange.location))
-                        resultStr = resultStr.appending(markStr.substring(to: minPos)) as NSString
-                    }else {
-                        resultStr = resultStr.appending(markStr as String) as NSString
-                    }
-                }
-                resultStr = self.replaceUnicodeString(resultStr)
-#else
-                let resultData = NSData.init(contentsOfFile: resultPath) as! Data
-                var rDocumentAttributes:NSDictionary!
-                let resultAttString = NSAttributedString.init(rtf: resultData, documentAttributes: &rDocumentAttributes)
-                var resultStr = NSString(string: resultAttString!.string)
-#endif
-                resultStr = resultStr.replacingOccurrences(of: "\n", with: "") as NSString
-                checkString = checkString.replacingOccurrences(of: "\n", with: "") as NSString
-                resultStr = resultStr.replacingOccurrences(of: " ", with: "") as NSString
-                checkString = checkString.replacingOccurrences(of: " ", with: "") as NSString
-                resultStr = resultStr.replacingOccurrences(of: "\\pard", with: "") as NSString
-                resultStr = resultStr.replacingOccurrences(of: "\\par", with: "") as NSString
-                
-//                do { // save cache file for test
-//                    try? NSString(string: resultStr).write(toFile: NSString(string: DataModel.shared.resultPath()).appending("/\(self.name())-result-cache.txt"),
-//                                                      atomically: true, encoding: NSUTF8StringEncoding)
-//                    
-//                    try? NSString(string: checkString).write(toFile: NSString(string: DataModel.shared.resultPath()).appending("/\(self.name())-check-cache.txt"),
-//                                                          atomically: true, encoding: NSUTF8StringEncoding)
-//                }
-                
-                let maxSize = checkString.length
-                var successCount = 0;
-                /**
-                 (A0 = B0)
-                 - A-1 & B-1
-                 (A0 != B0) & (A0 in B) & (B0 in A)
-                 - 取 A0,B0最小 Range 值
-                 - 字符串裁剪对齐
-                 (A0 != B0) & (A0 in B)
-                 - 存储B0到识别错误缓存
-                 (A0 != B0) & (B0 in A)
-                 - 存储 A0到识别遗漏字符串
-                 (A0 != B0)
-                 - 分别存储 A0、B0到遗漏及错误字串
-                 */
-                var skipString = NSString()
-                var failString = NSString()
-                while (checkString.length > 0 && resultStr.length > 0) {
-                    let subc = checkString.substring(to: 1) as NSString
-                    let subr = resultStr.substring(to: 1) as NSString
-                    
-                    if subc.isEqual(to: subr) { // (A0 = B0)
-                                                // Check Success
-                        appendErrorInfo(skipString, failString: failString)
-                        skipString = NSString()
-                        failString = NSString()
-                        
-                        
-                        checkString = checkString.substring(from:1) as NSString
-                        resultStr = resultStr.substring(from:1) as NSString
-                        successCount = successCount + 1
-                    }else if (checkString.contains(subr as String) && resultStr.contains(subc as String)) {
-                        appendErrorInfo(skipString, failString: failString)
-                        skipString = NSString()
-                        failString = NSString()
-                        
-                        let cRange = checkString.range(of: subr as String)
-                        let rRange = resultStr.range(of: subc as String)
-                        
-                        if (cRange.location < rRange.location) {
-                            let cacheString = checkString.substring(to:cRange.location + cRange.length)
-                            reportString?.append(NSMutableAttributedString.init(string: "对照字符串【\(cacheString)】未识别到\n",
-                                                                                attributes:[.foregroundColor : NSColor.red]))
-                            checkString = checkString.substring(from:cRange.location) as NSString
-                        }else {
-                            let cacheString = resultStr.substring(to:rRange.location)
-                            reportString?.append(NSMutableAttributedString.init(string: "字符串【\(cacheString)】识别出错\n",
-                                                                                attributes:[.foregroundColor : NSColor.red]))
-                            resultStr = resultStr.substring(from:rRange.location + rRange.length) as NSString
-                        }
-                        
-                    }else if (checkString.contains(subr as String)) {
-                        skipString = skipString.appending(subc as String) as NSString
-                        checkString = checkString.substring(from:1) as NSString
-                    }else if (resultStr.contains(subc as String)) {
-                        failString = failString.appending(subr as String) as NSString
-                        resultStr = resultStr.substring(from:1) as NSString
-                    }else {
-                        skipString = skipString.appending(subc as String) as NSString
-                        failString = failString.appending(subr as String) as NSString
-                        
-                        checkString = checkString.substring(from:1) as NSString
-                        resultStr = resultStr.substring(from:1) as NSString
-                    }
-                }
-                
-                skipString = skipString.appending(checkString as String) as NSString
-                failString = failString.appending(resultStr as String) as NSString
-                
-                
-                appendErrorInfo(skipString, failString: failString)
-                
-                reportString?.append(NSAttributedString.init(string: "【\(self.name())】字符串比对完成,准确率\(Float(successCount)/Float(maxSize) * 100)%(\(successCount)/\(maxSize))\n",
-                                                             attributes:[.foregroundColor : NSColor.blue]))
-            }
-            
-            // compare screenshoot between result file with check file
-            if needCompare {
-                
-            }
-        }else {
-            reportString = NSMutableAttributedString.init(string: "\n【\(self.name())】转档失败!\n",
-                                                          attributes:[.foregroundColor : NSColor.red])
-        }
-        
-        NSLog("\(reportString)")
-        
-        
-        _status = .Finished
-    }
-    
-    func appendErrorInfo(_ skipString:NSString, failString: NSString) {
-        if skipString.length > 0  && failString.length > 0 {
-            reportString?.append(NSMutableAttributedString.init(string: "对比字符串【\(skipString)】错识别为【\(failString)】\n",
-                                                                attributes:[.foregroundColor : NSColor.red]))
-        }else if (skipString.length > 0) {
-            reportString?.append(NSMutableAttributedString.init(string: "对比字符串【\(skipString)】未识别到\n",
-                                                                attributes:[.foregroundColor : NSColor.red]))
-        }else if failString.length > 0 {
-            reportString?.append(NSMutableAttributedString.init(string: "字符串【\(failString)】识别出错\n",
-                                                                attributes:[.foregroundColor : NSColor.red]))
-        }
-    }
-    
-    func replaceUnicodeString(_ string:NSString) -> NSString {
-        let items = string.components(separatedBy: "\\u") as [NSString]
-        
-        var resultString = NSString()
-        for item in items {
-            if (item.contains("?")) {
-                let unicodeValue = item.intValue
-                let skipRange = item.range(of: "?")
-                let nextString = item.substring(from: Int(skipRange.location + skipRange.length)) as NSString
-                let bytes : [UInt8] = [UInt8(unicodeValue/256),UInt8(unicodeValue%256)]
-                let data = NSData.init(bytes: bytes, length: 2)
-                
-                let unicodeString = NSString.init(data: data as Data, encoding: NSUnicodeStringEncoding)! as NSString
-                resultString = resultString.appending(String("\(unicodeString)\(nextString)")) as NSString
-            }else {
-                resultString = resultString.appending(String(item)) as NSString
-            }
-        }
-        
-        return resultString
-    }
-    
-    // Auto Test refrence Latest Status
-    override func autoCheck() {
-        _status = .Process
-        
-        
-        
-        _status = .Finished
-    }
-    
-}

+ 5 - 12
KdanAutoTest/KdanAuto/Class/AutoTestCase/FontAutoTest.swift

@@ -8,10 +8,10 @@
 import Foundation
 
 class FontAutoTest : AutoTest {
-    
-    override func type() -> String {
-        return "PDFConvert_Font_Auto_Test"
-    }
+//
+//    override func type() -> String {
+//        return "PDFConvert_Font_Auto_Test"
+//    }
     
     override func name() -> String {
         return "字体转换准确率测试"
@@ -21,9 +21,8 @@ class FontAutoTest : AutoTest {
         return ["字体名称", "字体大小", "字体样式", "快照对比"]
     }
     
-    static var fSharedInstance = FontAutoTest()
     override class func shared() -> AutoTest? {
-        return fSharedInstance
+        return FontAutoTest()
     }
     
     
@@ -35,10 +34,4 @@ class FontAutoTest : AutoTest {
         _status = .Finished
     }
     
-    // Auto Test refrence Latest Status
-    override func autoCheck() {
-        _status = .Process
-        
-        _status = .Finished
-    }
 }

+ 0 - 16
KdanAutoTest/KdanAuto/Class/AutoTestCase/RTFAutoTest.swift

@@ -1,16 +0,0 @@
-//
-//  RTFAutoTest.swift
-//  KdanAuto
-//
-//  Created by 朱东勇 on 2022/12/19.
-//
-
-import Foundation
-
-class RTFAutoTest : AutoTest {
-    
-    override func fileType() -> String {
-        return "RTF"
-    }
-    
-}

+ 0 - 28
KdanAutoTest/KdanAuto/Class/AutoTestCase/SpecialCharacterAutoTest.swift

@@ -1,28 +0,0 @@
-//
-//  SpecialCharacterAutoTest.swift
-//  KdanAuto
-//
-//  Created by 朱东勇 on 2022/11/25.
-//
-
-import Foundation
-
-class SpecialCharacterAutoTest : ChineseStringAutoTest {
-    
-    override func type() -> String {
-        return "PDFConvert_SpecialCharacter_Auto_Test"
-    }
-    
-    override func name() -> String {
-        return "特殊字符转换准确率测试"
-    }
-    
-    static var scSharedInstance = SpecialCharacterAutoTest()
-    override class func shared() -> AutoTest? {
-        return scSharedInstance
-    }
-    
-    override func autoTest() {
-        super.autoTest()
-    }
-}

+ 271 - 0
KdanAutoTest/KdanAuto/Class/AutoTestCase/StringAutoTest.swift

@@ -0,0 +1,271 @@
+//
+//  CharacterAutoTest.swift
+//  KdanAuto
+//
+//  Created by 朱东勇 on 2022/11/22.
+//
+
+import Foundation
+import Cocoa
+
+class CharacterAutoTest : AutoTest {
+    
+//    override func type() -> String {
+//        return "PDFConvert_China_Auto_Test"
+//    }
+    
+    override func name() -> String {
+        return "字符转换准确率测试"
+    }
+    
+    override func keys() -> NSArray {
+        return ["字符对比", "快照对比"]
+    }
+    
+    static var cSharedInstance = CharacterAutoTest()
+    override class func shared() -> AutoTest? {
+        return cSharedInstance
+    }
+    
+    
+    // Auto Test refrence Check File
+    override func autoTest() {
+        let checkString = self.selectedKeys().contains("字符对比")
+        let needCompare = self.selectedKeys().contains("快照对比")
+        
+        if !needCompare && !checkString {
+            _status = .Finished
+            return
+        }
+        
+        _status = .Process
+        reportString = NSMutableAttributedString.init(string: "\n【\(String(self.fileType())) - \(self.name())】字符比对开始!\n",
+                                                      attributes:[.foregroundColor : NSColor.blue])
+        let files = DataModel.shared.originFilesFor(_fileType, type: _type)
+        
+        let checkDirectory = self.checkFileDirectory()
+        let originDirectory = self.originFileDirectory()
+        let resultDirectory = self.resultFileDirectory()
+        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+".rtf")
+            let checkPath = NSString(string: checkDirectory).appendingPathComponent(fName+".rtf")
+            
+            
+            reportString?.append(NSMutableAttributedString.init(string: "\n【\(String(self.fileType())) - \(self.name())】开始转换文件 \"\(fName)\"\n",
+                                                               attributes:[.foregroundColor : NSColor.blue]))
+            // ...
+            // 执行转换过程
+            
+            if FileManager.default.fileExists(atPath: resultPath) {
+                if checkString {
+                    // Load check file
+                    let checkData = NSData.init(contentsOfFile: checkPath) as! Data
+                    var documentAttributes:NSDictionary!
+                    let checkAttString = NSAttributedString.init(rtf: checkData, documentAttributes: &documentAttributes)
+                    var checkString = NSString(string: checkAttString!.string) as NSString
+                    
+                    let resultString = try? NSString.init(contentsOfFile: resultPath, encoding: NSUTF8StringEncoding)
+                    
+                    
+#if true
+                    //识别字符串 \shptxt\shptxt ... }
+                    let pageInfoStrings = resultString!.components(separatedBy: "\\shptxt\\shptxt") as NSArray
+                    var finalString = ""
+                    if pageInfoStrings.count > 0 {
+                        let subStrings = pageInfoStrings.subarray(with: NSMakeRange(1, Int(pageInfoStrings.count - 1))) as! [String]
+                        for pageInfoString in subStrings {
+                            let endRange = NSString(string: pageInfoString).range(of: "}")
+                            finalString = finalString.appending(NSString(string: pageInfoString).substring(to: endRange.location))
+                        }
+                    }
+                    
+                    
+                    //识别所有 【空格 ~ \】 之间的值,并进行缝合
+                    // Detect all strings between Spaces and \ and stitch
+                    let strings = finalString.components(separatedBy: " ")
+                    var resultStr = "" as NSString
+                    for str in strings {
+                        let markStr = str as NSString
+                        
+                        if (markStr.contains("\\f")) {
+                            let fRange = markStr.range(of: "\\f")
+                            let cRange = markStr.range(of: "\\c")
+                            let bRange = markStr.range(of: "\\b")
+                            let iRange = markStr.range(of: "\\i")
+                            let eRange = markStr.range(of: "\\e")
+                            let pRange = markStr.range(of: "\\p")
+                            let minPos = min(Int(fRange.location),
+                                             Int(cRange.location),
+                                             Int(bRange.location),
+                                             Int(iRange.location),
+                                             Int(eRange.location),
+                                             Int(pRange.location))
+                            resultStr = resultStr.appending(markStr.substring(to: minPos)) as NSString
+                        }else {
+                            resultStr = resultStr.appending(markStr as String) as NSString
+                        }
+                    }
+                    resultStr = self.replaceUnicodeString(resultStr)
+#else
+                    let resultData = NSData.init(contentsOfFile: resultPath) as! Data
+                    var rDocumentAttributes:NSDictionary!
+                    let resultAttString = NSAttributedString.init(rtf: resultData, documentAttributes: &rDocumentAttributes)
+                    var resultStr = NSString(string: resultAttString!.string)
+#endif
+                    resultStr = resultStr.replacingOccurrences(of: "\n", with: "") as NSString
+                    checkString = checkString.replacingOccurrences(of: "\n", with: "") as NSString
+                    resultStr = resultStr.replacingOccurrences(of: " ", with: "") as NSString
+                    checkString = checkString.replacingOccurrences(of: " ", with: "") as NSString
+                    resultStr = resultStr.replacingOccurrences(of: "\\pard", with: "") as NSString
+                    resultStr = resultStr.replacingOccurrences(of: "\\par", with: "") as NSString
+                    
+                    //                do { // save cache file for test
+                    //                    try? NSString(string: resultStr).write(toFile: NSString(string: DataModel.shared.resultPath()).appending("/\(self.name())-result-cache.txt"),
+                    //                                                      atomically: true, encoding: NSUTF8StringEncoding)
+                    //
+                    //                    try? NSString(string: checkString).write(toFile: NSString(string: DataModel.shared.resultPath()).appending("/\(self.name())-check-cache.txt"),
+                    //                                                          atomically: true, encoding: NSUTF8StringEncoding)
+                    //                }
+                    
+                    let maxSize = checkString.length
+                    var successCount = 0;
+                    /**
+                     (A0 = B0)
+                     - A-1 & B-1
+                     (A0 != B0) & (A0 in B) & (B0 in A)
+                     - 取 A0,B0最小 Range 值
+                     - 字符串裁剪对齐
+                     (A0 != B0) & (A0 in B)
+                     - 存储B0到识别错误缓存
+                     (A0 != B0) & (B0 in A)
+                     - 存储 A0到识别遗漏字符串
+                     (A0 != B0)
+                     - 分别存储 A0、B0到遗漏及错误字串
+                     */
+                    var skipString = NSString()
+                    var failString = NSString()
+                    while (checkString.length > 0 && resultStr.length > 0) {
+                        let subc = checkString.substring(to: 1) as NSString
+                        let subr = resultStr.substring(to: 1) as NSString
+                        
+                        if subc.isEqual(to: subr) { // (A0 = B0)
+                                                    // Check Success
+                            appendErrorInfo(skipString, failString: failString)
+                            skipString = NSString()
+                            failString = NSString()
+                            
+                            
+                            checkString = checkString.substring(from:1) as NSString
+                            resultStr = resultStr.substring(from:1) as NSString
+                            successCount = successCount + 1
+                        }else if (checkString.contains(subr as String) && resultStr.contains(subc as String)) {
+                            appendErrorInfo(skipString, failString: failString)
+                            skipString = NSString()
+                            failString = NSString()
+                            
+                            let cRange = checkString.range(of: subr as String)
+                            let rRange = resultStr.range(of: subc as String)
+                            
+                            if (cRange.location < rRange.location) {
+                                let cacheString = checkString.substring(to:cRange.location + cRange.length)
+                                reportString?.append(NSMutableAttributedString.init(string: "对照字符串【\(cacheString)】未识别到\n",
+                                                                                    attributes:[.foregroundColor : NSColor.red]))
+                                checkString = checkString.substring(from:cRange.location) as NSString
+                            }else {
+                                let cacheString = resultStr.substring(to:rRange.location)
+                                reportString?.append(NSMutableAttributedString.init(string: "字符串【\(cacheString)】识别出错\n",
+                                                                                    attributes:[.foregroundColor : NSColor.red]))
+                                resultStr = resultStr.substring(from:rRange.location + rRange.length) as NSString
+                            }
+                            
+                        }else if (checkString.contains(subr as String)) {
+                            skipString = skipString.appending(subc as String) as NSString
+                            checkString = checkString.substring(from:1) as NSString
+                        }else if (resultStr.contains(subc as String)) {
+                            failString = failString.appending(subr as String) as NSString
+                            resultStr = resultStr.substring(from:1) as NSString
+                        }else {
+                            skipString = skipString.appending(subc as String) as NSString
+                            failString = failString.appending(subr as String) as NSString
+                            
+                            checkString = checkString.substring(from:1) as NSString
+                            resultStr = resultStr.substring(from:1) as NSString
+                        }
+                    }
+                    
+                    skipString = skipString.appending(checkString as String) as NSString
+                    failString = failString.appending(resultStr as String) as NSString
+                    
+                    
+                    appendErrorInfo(skipString, failString: failString)
+                    
+                    reportString?.append(NSAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(fName)\"比对完成,准确率\(Float(successCount)/Float(maxSize) * 100)%(\(successCount)/\(maxSize))\n",
+                                                                 attributes:[.foregroundColor : NSColor.blue]))
+                    
+                    // compare screenshoot between result file with check file
+                    if needCompare {
+                        reportString?.append(NSMutableAttributedString.init(string: "\n【\(String(self.fileType())) - \(self.name())】文件 \"\(fName)\"快照生成中\n",
+                                                                            attributes:[.foregroundColor : NSColor.black]))
+                        let rComparePath = NSString(string: resultDirectory).appendingPathComponent(fName+"_\(DataModel.shared.latestReportID()!).png")
+                        
+                        if (ProcessThumbnal.process(resultPath, desPath: rComparePath, outputSize: CGSize.init(width: 1000, height: 1000)) &&
+                            FileManager.default.fileExists(atPath: rComparePath)) {
+                            reportString?.append(NSMutableAttributedString.init(string: "\n【\(String(self.fileType())) - \(self.name())】文件 \"\(fName)\"快照对比完成,图像准确率 X%\n",
+                                                                                attributes:[.foregroundColor : NSColor.red]))
+                        }else {
+                            reportString?.append(NSMutableAttributedString.init(string: "\n【\(String(self.fileType())) - \(self.name())】文件 \"\(fName)\"快照生成失败\n",
+                                                                                attributes:[.foregroundColor : NSColor.red]))
+                        }
+                    }
+                }
+            }else {
+                reportString?.append(NSMutableAttributedString.init(string: "\n【\(String(self.fileType())) - \(self.name())】文件 \"\(fName)\"转档失败!\n",
+                                                              attributes:[.foregroundColor : NSColor.red]))
+            }
+            
+        }
+        
+        NSLog("\(reportString)")
+        
+        
+        _status = .Finished
+    }
+    
+    func appendErrorInfo(_ skipString:NSString, failString: NSString) {
+        if skipString.length > 0  && failString.length > 0 {
+            reportString?.append(NSMutableAttributedString.init(string: "对比字符串【\(skipString)】错识别为【\(failString)】\n",
+                                                                attributes:[.foregroundColor : NSColor.red]))
+        }else if (skipString.length > 0) {
+            reportString?.append(NSMutableAttributedString.init(string: "对比字符串【\(skipString)】未识别到\n",
+                                                                attributes:[.foregroundColor : NSColor.red]))
+        }else if failString.length > 0 {
+            reportString?.append(NSMutableAttributedString.init(string: "字符串【\(failString)】识别出错\n",
+                                                                attributes:[.foregroundColor : NSColor.red]))
+        }
+    }
+    
+    func replaceUnicodeString(_ string:NSString) -> NSString {
+        let items = string.components(separatedBy: "\\u") as [NSString]
+        
+        var resultString = NSString()
+        for item in items {
+            if (item.contains("?")) {
+                let unicodeValue = item.intValue
+                let skipRange = item.range(of: "?")
+                let nextString = item.substring(from: Int(skipRange.location + skipRange.length)) as NSString
+                let bytes : [UInt8] = [UInt8(unicodeValue/256),UInt8(unicodeValue%256)]
+                let data = NSData.init(bytes: bytes, length: 2)
+                
+                let unicodeString = NSString.init(data: data as Data, encoding: NSUnicodeStringEncoding)! as NSString
+                resultString = resultString.appending(String("\(unicodeString)\(nextString)")) as NSString
+            }else {
+                resultString = resultString.appending(String(item)) as NSString
+            }
+        }
+        
+        return resultString
+    }
+    
+}

+ 89 - 71
KdanAutoTest/KdanAuto/Class/AutoTestCase/TextColorAutoTest.swift

@@ -10,9 +10,9 @@ import AppKit
 
 class TextColorAutoTest : AutoTest {
     
-    override func type() -> String {
-        return "PDFConvert_Color_Auto_Test"
-    }
+//    override func type() -> String {
+//        return "PDFConvert_Color_Auto_Test"
+//    }
     
     override func name() -> String {
         return "字符颜色值转换测试"
@@ -30,40 +30,54 @@ class TextColorAutoTest : AutoTest {
     
     // Auto Test refrence Check File
     override func autoTest() {
-        _status = .Process
+        let checkRGB = self.selectedKeys().contains("RGB")
+        let checkAlpha = self.selectedKeys().contains("透明度")
+        let needCompare = self.selectedKeys().contains("快照对比")
         
-        let originPath = self.originFilePath()
+        if checkRGB || checkAlpha {
+            //需要检测颜色 或 Alpha 值 至少其一
+            if checkRGB && checkAlpha {
+                reportString = NSMutableAttributedString.init(string: "\n【\(String(self.fileType())) - \(self.name())】识别颜色(转档库暂不支持 Alpha )!\n",
+                                                              attributes:[.foregroundColor : NSColor.blue])
+            }else if checkRGB {
+                reportString = NSMutableAttributedString.init(string: "\n【\(String(self.fileType())) - \(self.name())】识别颜色(不带Alpha )!\n",
+                                                              attributes:[.foregroundColor : NSColor.blue])
+            }else {
+                reportString = NSMutableAttributedString.init(string: "\n【\(String(self.fileType())) - \(self.name())】转档暂不支持 Alpha!\n",
+                                                              attributes:[.foregroundColor : NSColor.blue])
+                
+                return
+            }
+        }
         
-        // ...
-        // 执行转换过程
+        _status = .Process
+        reportString?.append(NSMutableAttributedString.init(string: "\n【\(String(self.fileType())) - \(self.name())】颜色比对开始!\n",
+                                                            attributes:[.foregroundColor : NSColor.blue]))
+        let files = DataModel.shared.originFilesFor(_fileType, type: _type)
         
-        let resultPath = self.resultFilePath()
-        if self.isResultFileExist() {
-            // 转换成功
+        let checkDirectory = self.checkFileDirectory()
+        let originDirectory = self.originFileDirectory()
+        let resultDirectory = self.resultFileDirectory()
+        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+".rtf")
+//            let checkPath = NSString(string: checkDirectory).appendingPathComponent(fName+".rtf")
+            
+            
+            
+            reportString?.append(NSMutableAttributedString.init(string: "\n【\(String(self.fileType())) - \(self.name())】开始转换文件 \"\(fName)\"\n",
+                                                          attributes:[.foregroundColor : NSColor.blue]))
+            // ...
+            // 执行转换过程
             
-            let checkRGB = self.selectedKeys().contains("RGB")
-            let checkAlpha = self.selectedKeys().contains("透明度")
-            let needCompare = self.selectedKeys().contains("快照对比")
             
             var maxCount = 0;
             var succCount = 0;
-            if checkRGB || checkAlpha {
-                //需要检测颜色 或 Alpha 值 至少其一
-                let checkPath = self.checkFilePath()
+            
+            if FileManager.default.fileExists(atPath: resultPath) {
+                // 转换成功
                 
-                if checkRGB && checkAlpha {
-                    reportString = NSMutableAttributedString.init(string: "\n【\(self.name())】识别颜色(转档库暂不支持 Alpha )!\n",
-                                                           attributes:[.foregroundColor : NSColor.blue])
-                }else if checkRGB {
-                    reportString = NSMutableAttributedString.init(string: "\n【\(self.name())】识别颜色(不带Alpha )!\n",
-                                                           attributes:[.foregroundColor : NSColor.blue])
-                }else {
-                    reportString = NSMutableAttributedString.init(string: "\n【\(self.name())】转档暂不支持 Alpha!\n",
-                                                           attributes:[.foregroundColor : NSColor.blue])
-                    
-                    return
-                }
-
 #if true // 新文档框排形式
                 
                 /// 转换结果信息
@@ -171,14 +185,14 @@ class TextColorAutoTest : AutoTest {
                 }
                 
 #else   // 原富文本形式
-                /// 检测信息
+        /// 检测信息
                 let resultData = NSData.init(contentsOfFile: resultPath)! as Data
                 var rDocumentAttributes:NSDictionary!
                 let resultAttString = NSAttributedString.init(rtf: resultData, documentAttributes: &rDocumentAttributes)
-
+                
                 let string = resultAttString?.string
-
-
+                
+                
                 var maxCount = 0 as Int
                 var succCount = 0 as Int
                 let semaphore = DispatchSemaphore.init(value: 1)
@@ -198,44 +212,56 @@ class TextColorAutoTest : AutoTest {
                         
                         NSLog("\(attributes)")
                         
-//                        let currentString = cItem as! NSString
-//
-//                        let cColor = subAttrString.at
-//                        let cColorString = self.colorStringWithColor(cColor, withAlpha: false) as! NSString
-//
-//                        let dRange = currentString.range(of: "Color Check(") as NSRange
-//                        let mRange = currentString.range(of: "[") as NSRange
-//                        let markString = currentString.substring(from: Int(mRange.location+mRange.length)) as! NSString
-//                        let mark = markString.intValue
-//                        let dColorString = self.colorStringWithString(currentString.substring(from: Int(dRange.location + dRange.length)), withAlpha: false)! as  NSString
-//
-//                        if dColorString.isEqual(to: cColorString) {
-//                            succCount = succCount+1
-//                        }else {
-//                            reportString?.append(NSAttributedString.init(string: "【\(mark)】识别颜色出错, 文本识别颜色:\(dColorString) RTF文档颜色:\(cColorString)\n",
-//                                                                         attributes:[.foregroundColor : NSColor.red]))
-//
-//                            NSLog("\(item):\(dColorString)")
-//
-//                        }
+                        let currentString = cItem as! NSString
+                        
+                        let cColor = subAttrString.at
+                        let cColorString = self.colorStringWithColor(cColor, withAlpha: false) as! NSString
+                        
+                        let dRange = currentString.range(of: "Color Check(") as NSRange
+                        let mRange = currentString.range(of: "[") as NSRange
+                        let markString = currentString.substring(from: Int(mRange.location+mRange.length)) as! NSString
+                        let mark = markString.intValue
+                        let dColorString = self.colorStringWithString(currentString.substring(from: Int(dRange.location + dRange.length)), withAlpha: false)! as  NSString
+                        
+                        if dColorString.isEqual(to: cColorString) {
+                            succCount = succCount+1
+                        }else {
+                            reportString?.append(NSAttributedString.init(string: "【\(mark)】识别颜色出错, 文本识别颜色:\(dColorString) RTF文档颜色:\(cColorString)\n",
+                                                                         attributes:[.foregroundColor : NSColor.red]))
+                            
+                            NSLog("\(item):\(dColorString)")
+                            
+                        }
                     }
                 }
-
+                
                 semaphore.wait()
 #endif
                 
-                reportString?.append(NSAttributedString.init(string: "【\(self.name())】字体颜色对比完成,准确率\(Float(succCount)/Float(maxCount) * 100)%(\(succCount)/\(maxCount))\n",
-                                                             attributes:[.foregroundColor : NSColor.blue]))
+                reportString?.append(NSMutableAttributedString.init(string: "\n【\(String(self.fileType())) - \(self.name())】文件 \"\(fName)\"颜色对比完成,准确率\(Float(succCount)/Float(maxCount) * 100)%(\(succCount)/\(maxCount))\n",
+                                                              attributes:[.foregroundColor : NSColor.blue]))
+                
+                
+                if needCompare {
+                    reportString?.append(NSMutableAttributedString.init(string: "\n【\(String(self.fileType())) - \(self.name())】文件 \"\(fName)\"快照生成中\n",
+                                                                        attributes:[.foregroundColor : NSColor.black]))
+                    let rComparePath = NSString(string: resultDirectory).appendingPathComponent(fName+"_\(DataModel.shared.latestReportID()!).png")
+                    
+                    if (ProcessThumbnal.process(resultPath, desPath: rComparePath, outputSize: CGSize.init(width: 1000, height: 1000)) &&
+                        FileManager.default.fileExists(atPath: rComparePath)) {
+                        reportString?.append(NSMutableAttributedString.init(string: "\n【\(String(self.fileType())) - \(self.name())】文件 \"\(fName)\"快照对比完成,图像准确率 X%\n",
+                                                                            attributes:[.foregroundColor : NSColor.red]))
+                    }else {
+                        reportString?.append(NSMutableAttributedString.init(string: "\n【\(String(self.fileType())) - \(self.name())】文件 \"\(fName)\"快照生成失败\n",
+                                                                            attributes:[.foregroundColor : NSColor.red]))
+                    }
+                }
+            }else {
+                reportString?.append(NSMutableAttributedString.init(string: "\n【\(String(self.fileType())) - \(self.name())】文件 \"\(fName)\"转档失败!\n",
+                                                              attributes:[.foregroundColor : NSColor.red]))
             }
-            
-            
-        } else {
-            reportString = NSMutableAttributedString.init(string: "\n【\(self.name())】转档失败!\n",
-                                                   attributes:[.foregroundColor : NSColor.red])
         }
         
-        NSLog("\(reportString)")
-        
         _status = .Finished
     }
     
@@ -293,13 +319,5 @@ class TextColorAutoTest : AutoTest {
         return nil
     }
     
-    // Auto Test refrence Latest Status
-    override func autoCheck() {
-        _status = .Process
-        
-        
-        _status = .Finished
-    }
-    
     //
 }

+ 0 - 16
KdanAutoTest/KdanAuto/Class/AutoTestCase/WordAutoTest.swift

@@ -1,16 +0,0 @@
-//
-//  WordAutoTest.swift
-//  KdanAuto
-//
-//  Created by 朱东勇 on 2022/12/19.
-//
-
-import Foundation
-
-class WordAutoTest : AutoTest {
-    
-    override func fileType() -> String {
-        return "Word"
-    }
-    
-}

+ 22 - 1
KdanAutoTest/KdanAuto/Class/DataModel/DataModel.swift

@@ -12,6 +12,8 @@ let kLoadDirectoryPathKey : String   = "kLoadDirectoryPathKey";
 let kOriginPathComponent : String = "Origin Files"
 let kResultPathComponent : String = "Result Files"
 let kCheckPathComponent : String = "Check Files"
+
+let kLatestReportIDKey : String = "LatestReportID"
     
 class DataModel : NSObject {
     static var shared : DataModel = DataModel()
@@ -62,7 +64,26 @@ class DataModel : NSObject {
         path = path.appendingPathComponent(type) as NSString
         path = path.appendingPathComponent(kOriginPathComponent) as NSString
         
-        return FileManager.default.subpaths(atPath: path as String) ?? []
+        var subPaths = NSMutableArray(array: FileManager.default.subpaths(atPath: path as String) ?? [])
+        subPaths.remove(".DS_Store")
+        
+        return subPaths as! [String]
+    }
+    
+    public func generaNewReportID() -> String {
+        let string = NSString.init(format: "%.0f", NSDate.now.timeIntervalSince1970) as String
+        
+        let userDefaults = UserDefaults.standard
+        userDefaults.set(string, forKey: kLatestReportIDKey)
+        userDefaults.synchronize()
+        
+        return string
+    }
+    
+    public func latestReportID() -> String? {
+        let userDefaults = UserDefaults.standard
+        
+        return userDefaults.value(forKey: kLatestReportIDKey) as? String
     }
     
     /// Save Data

+ 89 - 6
KdanAutoTest/KdanAuto/Class/Norrmal/AutoTestAdvanceSettingView.swift

@@ -8,19 +8,25 @@
 import Foundation
 import AppKit
 
+let kItemCountPerRow   = 3
+
 public protocol AutoTestAdvanceSettingViewDelegate : NSObjectProtocol {
     func advanceSettingDidUpdate(_ settingView:NSView?)
 }
 
 
-class AutoTestAdvanceSettingView : NSView {
+class AutoTestAdvanceSettingView : NSView, NSTableViewDataSource, NSTableViewDelegate {
     @IBOutlet var _titleLbl : NSTextField!
     @IBOutlet var _keyScrollView : NSScrollView!
     @IBOutlet var _keyContentView : NSView!
     
+    @IBOutlet var _fileList : NSTableView!
+    
     var _keyViews : NSMutableArray!
     var _autoTestObj : AutoTest?
     
+    var _files : [String]! = []
+    
     var delegate : AutoTestAdvanceSettingViewDelegate?
     
     
@@ -36,8 +42,8 @@ class AutoTestAdvanceSettingView : NSView {
         _autoTestObj = obj;
         
         // Set Title
-        self.setAccessibilityEnabled((_autoTestObj?.isOriginFileExist() == true && _autoTestObj?.isCheckFileExist() == true))
-        
+//        self.setAccessibilityEnabled((_autoTestObj?.isOriginFileExist() == true && _autoTestObj?.isCheckFileExist() == true))
+//        
         if nil != _autoTestObj {
             _titleLbl.stringValue = String("[\(_autoTestObj?.fileType() as! String)]\(_autoTestObj?.name() as! String)")
             let checkKeys = _autoTestObj?.keys() as! NSArray
@@ -58,7 +64,7 @@ class AutoTestAdvanceSettingView : NSView {
                 }
             }
             
-            var height = CGFloat(_keyViews.count * (Int(kCheckBtnDefaultHeight) + 5));
+            var height = CGFloat((_keyViews.count + 1)/kItemCountPerRow * (Int(kCheckBtnDefaultHeight) + 5));
         
             //        _keyContentView.frame = NSRect(x: 0, y: 0, width: width, height: kTFDefaultHeight)
             if (height > _keyScrollView.frame.height) {
@@ -83,13 +89,20 @@ class AutoTestAdvanceSettingView : NSView {
                 
                 checkBtn.sizeToFit()
                 
-                checkBtn.frame = CGRect.init(x: 0, y: CGFloat(height - kCheckBtnDefaultHeight), width: checkBtn.frame.width, height: kCheckBtnDefaultHeight)
+                checkBtn.frame = CGRect.init(x: CGFloat(i % kItemCountPerRow) * _keyContentView.frame.size.width/CGFloat(kItemCountPerRow), y: CGFloat(height - kCheckBtnDefaultHeight), width: checkBtn.frame.width, height: kCheckBtnDefaultHeight)
                 checkBtn.autoresizingMask = .maxXMargin.union(.minYMargin)
                 
-                height = height - checkBtn.frame.height - 5
+                if i % kItemCountPerRow == (kItemCountPerRow - 1) {
+                    height = height - checkBtn.frame.height - 5
+                }
             }
             
             _keyScrollView.documentView = _keyContentView;
+            
+            _files = DataModel.shared.originFilesFor(String(_autoTestObj?.fileType() ?? ""),
+                                                     type: String(_autoTestObj?.type() ?? ""))
+            _fileList.reloadData()
+            
         }else {
             _titleLbl.stringValue = ""
             if _keyViews == nil {
@@ -99,6 +112,9 @@ class AutoTestAdvanceSettingView : NSView {
                 (_keyViews.lastObject as! NSView).removeFromSuperview()
                 _keyViews.removeLastObject()
             }
+            
+            _files = []
+            _fileList.reloadData()
         }
     }
     
@@ -125,4 +141,71 @@ class AutoTestAdvanceSettingView : NSView {
         }
     }
     
+    
+    // TableView Delegate
+    func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
+        let cellView = TestFileCellView.shared()
+        
+        if (_files.count >= row) {
+            let title = _files[row]
+            
+            cellView?.setTitle(title)
+        }
+        
+        return cellView
+    }
+    
+    func selectionShouldChange(in tableView: NSTableView) -> Bool {
+        
+        return true
+    }
+    
+    func tableView(_ tableView: NSTableView, shouldSelectRow row: Int) -> Bool {
+        
+        return false
+    }
+    
+    func tableView(_ tableView: NSTableView, shouldSelect tableColumn: NSTableColumn?) -> Bool {
+        
+        return false
+    }
+    
+    func tableView(_ tableView: NSTableView, mouseDownInHeaderOf tableColumn: NSTableColumn) {
+        
+    }
+    
+    func tableView(_ tableView: NSTableView, didClick tableColumn: NSTableColumn) {
+        
+    }
+    
+    func tableView(_ tableView: NSTableView, didDrag tableColumn: NSTableColumn) {
+        
+    }
+    
+    func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat {
+        return 30
+    }
+    
+    func tableView(_ tableView: NSTableView, isGroupRow row: Int) -> Bool {
+        return false
+    }
+    
+    func tableView(_ tableView: NSTableView, sizeToFitWidthOfColumn column: Int) -> CGFloat {
+        return tableView.frame.width
+    }
+    
+    func tableView(_ tableView: NSTableView, rowActionsForRow row: Int, edge: NSTableView.RowActionEdge) -> [NSTableViewRowAction] {
+        return []
+    }
+    
+    func tableViewSelectionDidChange(_ notification: Notification) {
+        
+    }
+    
+    // TableView Data Source
+    func numberOfRows(in tableView: NSTableView) -> Int {
+        return _files.count
+    }
+    
+    
 }

+ 2 - 0
KdanAutoTest/KdanAuto/Class/Norrmal/Cell/AutoTestCellInfo.swift

@@ -14,9 +14,11 @@ class AutoTestCellInfo : NSObject {
     var _isType : Bool! = false
     var _typeInfo: NSDictionary = NSDictionary()
     
+    var _row : Int! = 0
     
     class func initWithRow(_ row:Int) -> AutoTestCellInfo {
         var cellInfo = AutoTestCellInfo()
+        cellInfo._row = row
 
         var index = 0
 

+ 9 - 9
KdanAutoTest/KdanAuto/Class/Norrmal/Cell/TestCaseCellView.swift

@@ -111,24 +111,24 @@ class TestCaseCellView : NSTableCellView {
     public func setAutoTestObj(_ obj: AutoTest?) {
         _autoTestObj = obj
         
-        self.setAccessibilityEnabled((_autoTestObj?.isOriginFileExist() == true && _autoTestObj?.isCheckFileExist() == true))
+//        self.setAccessibilityEnabled((_autoTestObj?.isOriginFileExist() == true && _autoTestObj?.isCheckFileExist() == true))
         if nil != _autoTestObj {
             self.setTitle((_autoTestObj?.name())!)
             self.setCheckKeys((_autoTestObj?.selectedKeys())!)
             
 
-            self.wantsLayer = true
-            if _autoTestObj?.isOriginFileExist() == true && _autoTestObj?.isCheckFileExist() == true {
-                self.layer?.opacity = 1
-            }else {
-                self.layer?.opacity = 0.5
-            }
+//            self.wantsLayer = true
+//            if _autoTestObj?.isOriginFileExist() == true && _autoTestObj?.isCheckFileExist() == true {
+//                self.layer?.opacity = 1
+//            }else {
+//                self.layer?.opacity = 0.5
+//            }
         }else {
             self.setTitle("")
             self.setCheckKeys([])
             
-            self.wantsLayer = true
-            self.layer?.opacity = 0.5
+//            self.wantsLayer = true
+//            self.layer?.opacity = 0.5
         }
         
         updateStatus()

+ 3 - 3
KdanAutoTest/KdanAuto/Class/Norrmal/Cell/TestCaseCellView.xib

@@ -17,15 +17,15 @@
                     <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
                 </customView>
                 <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="EgA-BQ-X23">
-                    <rect key="frame" x="0.0" y="39" width="339" height="16"/>
+                    <rect key="frame" x="7" y="39" width="334" height="16"/>
                     <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
                     <textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="4yb-fM-clL">
                         <font key="font" metaFont="systemBold"/>
-                        <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+                        <color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
                         <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                     </textFieldCell>
                 </textField>
-                <scrollView borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" hasVerticalScroller="NO" usesPredominantAxisScrolling="NO" id="n2m-gK-mlz">
+                <scrollView borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" hasVerticalScroller="NO" usesPredominantAxisScrolling="NO" verticalScrollElasticity="none" id="n2m-gK-mlz">
                     <rect key="frame" x="9" y="6" width="320" height="32"/>
                     <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
                     <clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="VAh-KM-jZY">

+ 4 - 4
KdanAutoTest/KdanAuto/Class/Norrmal/Cell/TestTypeCellView.swift

@@ -8,7 +8,7 @@
 import Foundation
 import AppKit
 
-class TestTypeCellView : NSTableCellView {
+class TestFileCellView : NSTableCellView {
     @IBOutlet var _titleLbl : NSTextField!
     @IBOutlet var _sepLine : NSView!
     
@@ -16,13 +16,13 @@ class TestTypeCellView : NSTableCellView {
     var _isExpad: Bool!
     var _typeInfo : NSDictionary!
     
-    class func shared() -> TestTypeCellView? {
+    class func shared() -> TestFileCellView? {
         var objects : NSArray!
         
-        Bundle.main.loadNibNamed("TestTypeCellView", owner: nil, topLevelObjects: &objects)
+        Bundle.main.loadNibNamed("TestFileCellView", owner: nil, topLevelObjects: &objects)
         
         for tView in objects {
-            if let tv = tView as? TestTypeCellView {
+            if let tv = tView as? TestFileCellView {
                 return tv
             }
         }

+ 3 - 12
KdanAutoTest/KdanAuto/Class/Norrmal/Cell/TestTypeCellView.xib

@@ -8,12 +8,12 @@
         <customObject id="-2" userLabel="File's Owner"/>
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
         <customObject id="-3" userLabel="Application" customClass="NSObject"/>
-        <tableCellView id="Ob6-j8-aNh" customClass="TestTypeCellView" customModule="KdanAuto" customModuleProvider="target">
+        <tableCellView id="Ob6-j8-aNh" customClass="TestFileCellView" customModule="KdanAuto" customModuleProvider="target">
             <rect key="frame" x="0.0" y="0.0" width="339" height="30"/>
             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
             <subviews>
                 <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="EgA-BQ-X23">
-                    <rect key="frame" x="10" y="9" width="335" height="16"/>
+                    <rect key="frame" x="-2" y="9" width="335" height="16"/>
                     <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
                     <textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="4yb-fM-clL">
                         <font key="font" metaFont="system" size="11"/>
@@ -22,18 +22,9 @@
                     </textFieldCell>
                 </textField>
                 <customView id="Dg0-nG-U3m">
-                    <rect key="frame" x="12" y="0.0" width="331" height="1"/>
+                    <rect key="frame" x="0.0" y="0.0" width="331" height="1"/>
                     <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
                 </customView>
-                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="VzC-B0-Ms0">
-                    <rect key="frame" x="318" y="8" width="14" height="19"/>
-                    <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
-                    <textFieldCell key="cell" lineBreakMode="clipping" title="&gt;" id="k44-ke-U8H">
-                        <font key="font" metaFont="system" size="15"/>
-                        <color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
-                        <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
-                    </textFieldCell>
-                </textField>
             </subviews>
             <connections>
                 <outlet property="_sepLine" destination="Dg0-nG-U3m" id="fck-m4-6W4"/>

+ 77 - 41
KdanAutoTest/KdanAuto/ViewController.swift

@@ -84,43 +84,66 @@ class ViewController : NSViewController, SettingViewControllerDelegate, AutoTest
         
         DispatchQueue.global().async {
             var report = NSMutableAttributedString.init()
-//            for testType in testCaseNames {
-//                let testObject = AutoTest.autoTestForType(testType as NSString)
-//                testObject?.setStatus(.Wait)
-//            }
-//            self.reloadListData()
-//
-//            for testType in testCaseNames {
-//                let testObject = AutoTest.autoTestForType(testType as NSString)
-//                testObject?.setStatus(.Process)
-//                self.reloadListData()
-//
-//                if nil != testObject {
-//                    testObject?.autoTest()
-//
-//                    testObject?.autoCheck()
-//
-//                    if let cReport = testObject?.testReport() {
-//                        report.append(cReport)
-//                    }
-//                }
-//                testObject?.setStatus(.Finished)
-//                self.reloadListData()
-//            }
-//            for testType in testCaseNames {
-//                let testObject = AutoTest.autoTestForType(testType as NSString)
-//                testObject?.setStatus(.Normal)
-//            }
-//
-//            do {
-//                let rtfData = try report.data(from: .init(location: 0, length: report.length),
-//                                                 documentAttributes: [.documentType: NSAttributedString.DocumentType.rtf])
-//
-//                let path = DataModel.shared.resultPath().appendingFormat("/TestReport_\(NSDate.now.timeIntervalSince1970).rtf")
-//                try rtfData.write(to: NSURL.fileURL(withPath: path))
-//            } catch {
-//                print(error)
-//            }
+            DataModel.shared.generaNewReportID()
+            
+            // Update For Waiting
+            for fileType in testFileTypes {
+                let types = testTypeInfo[fileType] as! NSArray
+                for typeInfo in types {
+                    let ti = typeInfo as! NSDictionary
+                    let type = ti["Type"] as! NSString
+                    
+                    let testObject = AutoTest.autoTestFor(fileType as NSString, type: type)
+                    testObject?.setStatus(.Wait)
+                }
+                DispatchQueue.main.sync {
+                    self.reloadListData()
+                }
+            }
+            
+            for fileType in testFileTypes {
+                let types = testTypeInfo[fileType] as! NSArray
+                for typeInfo in types {
+                    let ti = typeInfo as! NSDictionary
+                    let type = ti["Type"] as! NSString
+                    
+                    let testObject = AutoTest.autoTestFor(fileType as NSString, type: type)
+                    testObject?.setStatus(.Process)
+                    DispatchQueue.main.sync {
+                        self.reloadListData()
+                    }
+                    
+                    if nil != testObject {
+                        testObject?.autoTest()
+                        
+                        if let cReport = testObject?.testReport() {
+                            report.append(cReport)
+                        }
+                    }
+                    testObject?.setStatus(.Finished)
+                    DispatchQueue.main.sync {
+                        self.reloadListData()
+                    }
+                }
+                
+                for typeInfo in types {
+                    let ti = typeInfo as! NSDictionary
+                    let type = ti["Type"] as! NSString
+                    
+                    let testObject = AutoTest.autoTestFor(fileType as NSString, type: type)
+                    testObject?.setStatus(.Normal)
+                }
+            }
+
+            do {
+                let rtfData = try report.data(from: .init(location: 0, length: report.length),
+                                                 documentAttributes: [.documentType: NSAttributedString.DocumentType.rtf])
+
+                let path = DataModel.shared.directoryPath().appendingFormat("/TestReport_\(DataModel.shared.latestReportID()!).rtf")
+                try rtfData.write(to: NSURL.fileURL(withPath: path))
+            } catch {
+                print(error)
+            }
             
             DispatchQueue.main.async {
                 self._isProcessing = false
@@ -143,9 +166,11 @@ class ViewController : NSViewController, SettingViewControllerDelegate, AutoTest
             
             return cellView
         }else {
-            let cellView = TestTypeCellView.shared()
+            let cellView = TestCaseCellView.shared()
             
-            cellView?.setTypeInfo(cellInfo.typeInfo());
+            let autoTestObj = AutoTest.autoTestFor(NSString(string: (cellInfo.fileType())), type:NSString(string: (cellInfo.typeInfo()["Type"] as! String)))
+            
+            cellView?.setAutoTestObj(autoTestObj);
             
             return cellView
         }
@@ -180,7 +205,13 @@ class ViewController : NSViewController, SettingViewControllerDelegate, AutoTest
     }
     
     func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat {
-        return 30
+        let cellInfo = AutoTestCellInfo.initWithRow(row)
+        
+        if cellInfo.isFileType() {
+            return 30
+        }else {
+            return 60
+        }
     }
     
     func tableView(_ tableView: NSTableView, isGroupRow row: Int) -> Bool {
@@ -249,7 +280,12 @@ class ViewController : NSViewController, SettingViewControllerDelegate, AutoTest
     
     //AutoTestAdvanceSettingView Delegate
     func advanceSettingDidUpdate(_ settingView: NSView?) {
-        self.setCurrentCellInfo(_currentCellInfo)
+        if (nil != _currentCellInfo) {
+            itemsList.reloadData(forRowIndexes: IndexSet(integer: IndexSet.Element((_currentCellInfo?._row)!)),
+                                 columnIndexes: IndexSet(integer: IndexSet.Element(0)))
+        }else {
+            reloadListData()
+        }
     }
     
 }

+ 20 - 14
KdanAutoTest/ProcessCheckFile/Process/ProcessThumbnal.swift

@@ -15,29 +15,35 @@ let generator = QLThumbnailGenerator.shared
 
 class ProcessThumbnal : NSObject {
     
-    class func process(_ filePath:String) {
-        let url = URL.init(filePath: filePath)
-                generator.generateRepresentations(for: QLThumbnailGenerator.Request.init(fileAt: url, size: CGSizeMake(1024.0, 10240.0), scale: 1.0, representationTypes: QLThumbnailGenerator.Request.RepresentationTypes.thumbnail),
-
-                                                  update: { (representation, type, error) in
-            let image = representation!.nsImage as NSImage
-                         
-            try? image.tiffRepresentation?.write(to: URL.init(filePath: "/Users/zhudongyong/Desktop/imae01.png"))
-            NSLog("\(representation?.nsImage)\(error)")
-        })
+    class func process(_ filePath:String, desPath:String) -> Bool {
+        let kDefaultThumbnailSize = CGSizeMake(1000.0, 1000.0)
+        
+        return process(filePath, desPath: desPath, outputSize: kDefaultThumbnailSize)
+    }
+    
+    class func process(_ filePath:String, desPath:String, outputSize:CGSize) -> Bool {
+        var didFinished = false
         
+        let semaphore = DispatchSemaphore(value: 0)
+        let url = URL.init(filePath: filePath)
         generator.generateRepresentations(for: QLThumbnailGenerator.Request.init(fileAt: url, size: CGSizeMake(1024.0, 10240.0), scale: 1.0, representationTypes: QLThumbnailGenerator.Request.RepresentationTypes.thumbnail),
+                                          
                                           update: { (representation, type, error) in
             let image = representation!.nsImage as NSImage
             
-            try? image.tiffRepresentation?.write(to: URL.init(filePath: "/Users/zhudongyong/Desktop/imae02.png"))
-            NSLog("\(representation?.nsImage)\(error)")
+            if nil != image {
+                didFinished = true
+                
+                try? image.tiffRepresentation?.write(to: URL.init(filePath: desPath))
+            }
+            
+            semaphore.signal()
         })
         
         
+        semaphore.wait()
         
-//        return []
+        return didFinished
     }
     
-    
 }