Browse Source

功能逻辑优化 - 多文档对照用 Block 方案进行代码优化,优化对照过程卡顿问题

zhudongyong 2 years ago
parent
commit
1b9f507624

+ 60 - 47
KdanAutoTest/KdanAuto.xcodeproj/project.pbxproj

@@ -7,20 +7,20 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
-		2400D7C729B9F52C0059AC45 /* libDocumentAI.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2400D7C029B9F52B0059AC45 /* libDocumentAI.dylib */; };
-		2400D7C829B9F52C0059AC45 /* libopencv_world.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2400D7C129B9F52B0059AC45 /* libopencv_world.dylib */; };
-		2400D7C929B9F52C0059AC45 /* ComDocumentAIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2400D7C229B9F52B0059AC45 /* ComDocumentAIKit.framework */; };
-		2400D7CA29B9F52C0059AC45 /* libopencv_world.4.2.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2400D7C329B9F52B0059AC45 /* libopencv_world.4.2.0.dylib */; };
-		2400D7CB29B9F52C0059AC45 /* libonnxruntime.1.12.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2400D7C429B9F52B0059AC45 /* libonnxruntime.1.12.0.dylib */; };
-		2400D7CC29B9F52C0059AC45 /* libpaddle2onnx.1.0.5.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2400D7C529B9F52B0059AC45 /* libpaddle2onnx.1.0.5.dylib */; };
-		2400D7CD29B9F52C0059AC45 /* libopencv_world.4.2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2400D7C629B9F52B0059AC45 /* libopencv_world.4.2.dylib */; };
-		2400D7CE29B9F5430059AC45 /* ComDocumentAIKit.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 2400D7C229B9F52B0059AC45 /* ComDocumentAIKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
-		2400D7CF29B9F5550059AC45 /* libDocumentAI.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 2400D7C029B9F52B0059AC45 /* libDocumentAI.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
-		2400D7D029B9F5550059AC45 /* libopencv_world.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 2400D7C129B9F52B0059AC45 /* libopencv_world.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
-		2400D7D129B9F5550059AC45 /* libopencv_world.4.2.0.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 2400D7C329B9F52B0059AC45 /* libopencv_world.4.2.0.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
-		2400D7D229B9F5550059AC45 /* libonnxruntime.1.12.0.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 2400D7C429B9F52B0059AC45 /* libonnxruntime.1.12.0.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
-		2400D7D329B9F5550059AC45 /* libpaddle2onnx.1.0.5.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 2400D7C529B9F52B0059AC45 /* libpaddle2onnx.1.0.5.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
-		2400D7D429B9F5550059AC45 /* libopencv_world.4.2.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 2400D7C629B9F52B0059AC45 /* libopencv_world.4.2.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
+		2400D7DD29B9FCC90059AC45 /* libDocumentAI.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2400D7D629B9FCC90059AC45 /* libDocumentAI.dylib */; };
+		2400D7DE29B9FCC90059AC45 /* libopencv_world.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2400D7D729B9FCC90059AC45 /* libopencv_world.dylib */; };
+		2400D7DF29B9FCC90059AC45 /* ComDocumentAIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2400D7D829B9FCC90059AC45 /* ComDocumentAIKit.framework */; };
+		2400D7E029B9FCC90059AC45 /* libopencv_world.4.2.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2400D7D929B9FCC90059AC45 /* libopencv_world.4.2.0.dylib */; };
+		2400D7E129B9FCC90059AC45 /* libonnxruntime.1.12.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2400D7DA29B9FCC90059AC45 /* libonnxruntime.1.12.0.dylib */; };
+		2400D7E229B9FCC90059AC45 /* libpaddle2onnx.1.0.5.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2400D7DB29B9FCC90059AC45 /* libpaddle2onnx.1.0.5.dylib */; };
+		2400D7E329B9FCC90059AC45 /* libopencv_world.4.2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2400D7DC29B9FCC90059AC45 /* libopencv_world.4.2.dylib */; };
+		2400D7E429B9FD200059AC45 /* libDocumentAI.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 2400D7D629B9FCC90059AC45 /* libDocumentAI.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
+		2400D7E529B9FD200059AC45 /* libopencv_world.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 2400D7D729B9FCC90059AC45 /* libopencv_world.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
+		2400D7E629B9FD200059AC45 /* ComDocumentAIKit.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 2400D7D829B9FCC90059AC45 /* ComDocumentAIKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
+		2400D7E729B9FD200059AC45 /* libopencv_world.4.2.0.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 2400D7D929B9FCC90059AC45 /* libopencv_world.4.2.0.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
+		2400D7E829B9FD200059AC45 /* libonnxruntime.1.12.0.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 2400D7DA29B9FCC90059AC45 /* libonnxruntime.1.12.0.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
+		2400D7E929B9FD200059AC45 /* libpaddle2onnx.1.0.5.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 2400D7DB29B9FCC90059AC45 /* libpaddle2onnx.1.0.5.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
+		2400D7EA29B9FD200059AC45 /* libopencv_world.4.2.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 2400D7DC29B9FCC90059AC45 /* libopencv_world.4.2.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
 		240509B329433CDE00B501B2 /* QuickLookThumbnailing.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 240509B029433CDE00B501B2 /* QuickLookThumbnailing.framework */; };
 		240509B429433CDE00B501B2 /* QuickLook.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 240509B129433CDE00B501B2 /* QuickLook.framework */; };
 		240509B529433CDE00B501B2 /* QuickLookUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 240509B229433CDE00B501B2 /* QuickLookUI.framework */; };
@@ -122,13 +122,13 @@
 			dstPath = "";
 			dstSubfolderSpec = 10;
 			files = (
-				2400D7CF29B9F5550059AC45 /* libDocumentAI.dylib in CopyFiles */,
-				2400D7D029B9F5550059AC45 /* libopencv_world.dylib in CopyFiles */,
-				2400D7D129B9F5550059AC45 /* libopencv_world.4.2.0.dylib in CopyFiles */,
-				2400D7D229B9F5550059AC45 /* libonnxruntime.1.12.0.dylib in CopyFiles */,
-				2400D7D329B9F5550059AC45 /* libpaddle2onnx.1.0.5.dylib in CopyFiles */,
-				2400D7D429B9F5550059AC45 /* libopencv_world.4.2.dylib in CopyFiles */,
-				2400D7CE29B9F5430059AC45 /* ComDocumentAIKit.framework in CopyFiles */,
+				2400D7E429B9FD200059AC45 /* libDocumentAI.dylib in CopyFiles */,
+				2400D7E529B9FD200059AC45 /* libopencv_world.dylib in CopyFiles */,
+				2400D7E629B9FD200059AC45 /* ComDocumentAIKit.framework in CopyFiles */,
+				2400D7E729B9FD200059AC45 /* libopencv_world.4.2.0.dylib in CopyFiles */,
+				2400D7E829B9FD200059AC45 /* libonnxruntime.1.12.0.dylib in CopyFiles */,
+				2400D7E929B9FD200059AC45 /* libpaddle2onnx.1.0.5.dylib in CopyFiles */,
+				2400D7EA29B9FD200059AC45 /* libopencv_world.4.2.dylib in CopyFiles */,
 				240550FF2952F42F00B95E0B /* ComPDFKit_Conversion.framework in CopyFiles */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -136,13 +136,13 @@
 /* End PBXCopyFilesBuildPhase section */
 
 /* Begin PBXFileReference section */
-		2400D7C029B9F52B0059AC45 /* libDocumentAI.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libDocumentAI.dylib; sourceTree = "<group>"; };
-		2400D7C129B9F52B0059AC45 /* libopencv_world.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_world.dylib; sourceTree = "<group>"; };
-		2400D7C229B9F52B0059AC45 /* ComDocumentAIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = ComDocumentAIKit.framework; sourceTree = "<group>"; };
-		2400D7C329B9F52B0059AC45 /* libopencv_world.4.2.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_world.4.2.0.dylib; sourceTree = "<group>"; };
-		2400D7C429B9F52B0059AC45 /* libonnxruntime.1.12.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libonnxruntime.1.12.0.dylib; sourceTree = "<group>"; };
-		2400D7C529B9F52B0059AC45 /* libpaddle2onnx.1.0.5.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libpaddle2onnx.1.0.5.dylib; sourceTree = "<group>"; };
-		2400D7C629B9F52B0059AC45 /* libopencv_world.4.2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_world.4.2.dylib; sourceTree = "<group>"; };
+		2400D7D629B9FCC90059AC45 /* libDocumentAI.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libDocumentAI.dylib; sourceTree = "<group>"; };
+		2400D7D729B9FCC90059AC45 /* libopencv_world.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_world.dylib; sourceTree = "<group>"; };
+		2400D7D829B9FCC90059AC45 /* ComDocumentAIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = ComDocumentAIKit.framework; sourceTree = "<group>"; };
+		2400D7D929B9FCC90059AC45 /* libopencv_world.4.2.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_world.4.2.0.dylib; sourceTree = "<group>"; };
+		2400D7DA29B9FCC90059AC45 /* libonnxruntime.1.12.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libonnxruntime.1.12.0.dylib; sourceTree = "<group>"; };
+		2400D7DB29B9FCC90059AC45 /* libpaddle2onnx.1.0.5.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libpaddle2onnx.1.0.5.dylib; sourceTree = "<group>"; };
+		2400D7DC29B9FCC90059AC45 /* libopencv_world.4.2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_world.4.2.dylib; sourceTree = "<group>"; };
 		240509B029433CDE00B501B2 /* QuickLookThumbnailing.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuickLookThumbnailing.framework; path = System/Library/PrivateFrameworks/QuickLookThumbnailing.framework; sourceTree = SDKROOT; };
 		240509B129433CDE00B501B2 /* QuickLook.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuickLook.framework; path = System/Library/Frameworks/QuickLook.framework; sourceTree = SDKROOT; };
 		240509B229433CDE00B501B2 /* QuickLookUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuickLookUI.framework; path = System/Library/Frameworks/QuickLookUI.framework; sourceTree = SDKROOT; };
@@ -226,18 +226,18 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
-				2400D7C829B9F52C0059AC45 /* libopencv_world.dylib in Frameworks */,
+				2400D7DE29B9FCC90059AC45 /* libopencv_world.dylib in Frameworks */,
 				2411D9CD29ABAF36009DE4A8 /* PDFKit.framework in Frameworks */,
-				2400D7CD29B9F52C0059AC45 /* libopencv_world.4.2.dylib in Frameworks */,
+				2400D7E329B9FCC90059AC45 /* libopencv_world.4.2.dylib in Frameworks */,
 				2451F58B2952E4E50049FA9C /* ComPDFKit_Conversion.framework in Frameworks */,
-				2400D7CB29B9F52C0059AC45 /* libonnxruntime.1.12.0.dylib in Frameworks */,
+				2400D7E129B9FCC90059AC45 /* libonnxruntime.1.12.0.dylib in Frameworks */,
 				240509B329433CDE00B501B2 /* QuickLookThumbnailing.framework in Frameworks */,
 				240509B429433CDE00B501B2 /* QuickLook.framework in Frameworks */,
 				240509B529433CDE00B501B2 /* QuickLookUI.framework in Frameworks */,
-				2400D7C929B9F52C0059AC45 /* ComDocumentAIKit.framework in Frameworks */,
-				2400D7CC29B9F52C0059AC45 /* libpaddle2onnx.1.0.5.dylib in Frameworks */,
-				2400D7CA29B9F52C0059AC45 /* libopencv_world.4.2.0.dylib in Frameworks */,
-				2400D7C729B9F52C0059AC45 /* libDocumentAI.dylib in Frameworks */,
+				2400D7DF29B9FCC90059AC45 /* ComDocumentAIKit.framework in Frameworks */,
+				2400D7E229B9FCC90059AC45 /* libpaddle2onnx.1.0.5.dylib in Frameworks */,
+				2400D7E029B9FCC90059AC45 /* libopencv_world.4.2.0.dylib in Frameworks */,
+				2400D7DD29B9FCC90059AC45 /* libDocumentAI.dylib in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -279,19 +279,18 @@
 /* End PBXFrameworksBuildPhase section */
 
 /* Begin PBXGroup section */
-		2400D7BF29B9F52B0059AC45 /* otherlib */ = {
+		2400D7D529B9FCC90059AC45 /* otherlib */ = {
 			isa = PBXGroup;
 			children = (
-				2400D7C029B9F52B0059AC45 /* libDocumentAI.dylib */,
-				2400D7C129B9F52B0059AC45 /* libopencv_world.dylib */,
-				2400D7C229B9F52B0059AC45 /* ComDocumentAIKit.framework */,
-				2400D7C329B9F52B0059AC45 /* libopencv_world.4.2.0.dylib */,
-				2400D7C429B9F52B0059AC45 /* libonnxruntime.1.12.0.dylib */,
-				2400D7C529B9F52B0059AC45 /* libpaddle2onnx.1.0.5.dylib */,
-				2400D7C629B9F52B0059AC45 /* libopencv_world.4.2.dylib */,
-			);
-			name = otherlib;
-			path = "../../../../../../../../../Users/zhudongyong/Library/Containers/com.tencent.WeWorkMac/Data/Documents/Profiles/4E1ABC1AA40B741D302D9B14F8ADC05C/Caches/Files/2023-03/47b92f906f9cbbc24790f7d89342b69f/otherlib";
+				2400D7D629B9FCC90059AC45 /* libDocumentAI.dylib */,
+				2400D7D729B9FCC90059AC45 /* libopencv_world.dylib */,
+				2400D7D829B9FCC90059AC45 /* ComDocumentAIKit.framework */,
+				2400D7D929B9FCC90059AC45 /* libopencv_world.4.2.0.dylib */,
+				2400D7DA29B9FCC90059AC45 /* libonnxruntime.1.12.0.dylib */,
+				2400D7DB29B9FCC90059AC45 /* libpaddle2onnx.1.0.5.dylib */,
+				2400D7DC29B9FCC90059AC45 /* libopencv_world.4.2.dylib */,
+			);
+			path = otherlib;
 			sourceTree = "<group>";
 		};
 		240509AF29433CDE00B501B2 /* Frameworks */ = {
@@ -564,7 +563,7 @@
 		24E4FD43293462F0008BA2EC /* Third Part Library */ = {
 			isa = PBXGroup;
 			children = (
-				2400D7BF29B9F52B0059AC45 /* otherlib */,
+				2400D7D529B9FCC90059AC45 /* otherlib */,
 				2451F58A2952E4E50049FA9C /* ComPDFKit_Conversion.framework */,
 			);
 			path = "Third Part Library";
@@ -1055,6 +1054,7 @@
 					"$(inherited)",
 					"$(PROJECT_DIR)/KdanAuto/Third\\ Part\\ Library",
 					"$(USER_LIBRARY_DIR)/Containers/com.tencent.WeWorkMac/Data/Documents/Profiles/4E1ABC1AA40B741D302D9B14F8ADC05C/Caches/Files/2023-03/47b92f906f9cbbc24790f7d89342b69f/otherlib",
+					"$(PROJECT_DIR)/KdanAuto/Third\\ Part\\ Library/otherlib",
 				);
 				GENERATE_INFOPLIST_FILE = YES;
 				INFOPLIST_KEY_NSHumanReadableCopyright = "";
@@ -1067,6 +1067,12 @@
 				LIBRARY_SEARCH_PATHS = (
 					"$(inherited)",
 					"$(USER_LIBRARY_DIR)/Containers/com.tencent.WeWorkMac/Data/Documents/Profiles/4E1ABC1AA40B741D302D9B14F8ADC05C/Caches/Files/2023-03/47b92f906f9cbbc24790f7d89342b69f/otherlib",
+					"$(PROJECT_DIR)/KdanAuto/Third\\ Part\\ Library/otherlib",
+					"$(PROJECT_DIR)/KdanAuto/Third\\ Part\\ Library/otherlib",
+					"$(PROJECT_DIR)/KdanAuto/Third\\ Part\\ Library/otherlib",
+					"$(PROJECT_DIR)/KdanAuto/Third\\ Part\\ Library/otherlib",
+					"$(PROJECT_DIR)/KdanAuto/Third\\ Part\\ Library/otherlib",
+					"$(PROJECT_DIR)/KdanAuto/Third\\ Part\\ Library/otherlib",
 				);
 				MACOSX_DEPLOYMENT_TARGET = 11.0;
 				MARKETING_VERSION = 1.0;
@@ -1098,6 +1104,7 @@
 					"$(inherited)",
 					"$(PROJECT_DIR)/KdanAuto/Third\\ Part\\ Library",
 					"$(USER_LIBRARY_DIR)/Containers/com.tencent.WeWorkMac/Data/Documents/Profiles/4E1ABC1AA40B741D302D9B14F8ADC05C/Caches/Files/2023-03/47b92f906f9cbbc24790f7d89342b69f/otherlib",
+					"$(PROJECT_DIR)/KdanAuto/Third\\ Part\\ Library/otherlib",
 				);
 				GENERATE_INFOPLIST_FILE = YES;
 				INFOPLIST_KEY_NSHumanReadableCopyright = "";
@@ -1110,6 +1117,12 @@
 				LIBRARY_SEARCH_PATHS = (
 					"$(inherited)",
 					"$(USER_LIBRARY_DIR)/Containers/com.tencent.WeWorkMac/Data/Documents/Profiles/4E1ABC1AA40B741D302D9B14F8ADC05C/Caches/Files/2023-03/47b92f906f9cbbc24790f7d89342b69f/otherlib",
+					"$(PROJECT_DIR)/KdanAuto/Third\\ Part\\ Library/otherlib",
+					"$(PROJECT_DIR)/KdanAuto/Third\\ Part\\ Library/otherlib",
+					"$(PROJECT_DIR)/KdanAuto/Third\\ Part\\ Library/otherlib",
+					"$(PROJECT_DIR)/KdanAuto/Third\\ Part\\ Library/otherlib",
+					"$(PROJECT_DIR)/KdanAuto/Third\\ Part\\ Library/otherlib",
+					"$(PROJECT_DIR)/KdanAuto/Third\\ Part\\ Library/otherlib",
 				);
 				MACOSX_DEPLOYMENT_TARGET = 11.0;
 				MARKETING_VERSION = 1.0;

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


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

@@ -94,11 +94,43 @@
             filePath = "KdanAuto/Class/DataModel/TestDegreeManager.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "77"
-            endingLineNumber = "77"
+            startingLineNumber = "79"
+            endingLineNumber = "79"
             landmarkName = "degreeFor(_:type:fileName:refFilePath:)"
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "1FAF7F75-A574-4C98-A03F-51E2906B9F80"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "ProcessCheckFile/Process/ProcessThumbnal.swift"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "105"
+            endingLineNumber = "105"
+            landmarkName = "process(_:desPath:outputSize:)"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "13B517F1-4C9C-49C9-9011-7FE175401600"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "KdanAuto/Class/AutoTestCase/AutoTest.swift"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "373"
+            endingLineNumber = "373"
+            landmarkName = "compareResult(_:resultPath:status:needCompare:complention:)"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
    </Breakpoints>
 </Bucket>

+ 199 - 167
KdanAutoTest/KdanAuto/Class/AutoTestCase/AutoTest.swift

@@ -21,7 +21,6 @@ class AutoTest : NSObject, AutoTestProtocal {
     var _extention : String = "rtf"
     var _name : String = "对照测试"
     var _params : NSDictionary = [:]
-    let compareImageQueue = OperationQueue()
     
     class func autoTestFor(_ fileType:NSString ,type:NSString) -> AutoTest? {
         let key = String(fileType) + "." + String(type)
@@ -173,10 +172,11 @@ class AutoTest : NSObject, AutoTestProtocal {
                 
                 var tDegree = Double(0);
                 var tCount = Int(0)
+                var fileIndex = 0
                 
                 // 用 Block 递归调用形式,确保转档单任务执行
-                var convertFileBlock = { (files:[String], fileIndex:Int) in }
-                convertFileBlock = { (files:[String], fileIndex:Int) in
+                var convertFileBlock = { (files:[String]) in }
+                convertFileBlock = { (files:[String]) in
                     if (fileIndex >= files.count) {
                         //所有任务已经执行完成
                         TestDegreeManager.shared().set(((tCount != 0) ? tDegree/Double(tCount) : 0.0),
@@ -193,6 +193,10 @@ class AutoTest : NSObject, AutoTestProtocal {
                     //
                     let fileName = files[fileIndex];
                     autoreleasepool {
+                        let checkDirectory = self.checkFileDirectory()
+                        let originDirectory = self.originFileDirectory()
+                        let resultDirectory = self.resultFileDirectory()
+                        
                         let fName = NSString(string: fileName).deletingPathExtension
                         let originPath = NSString(string: originDirectory).appendingPathComponent(fName+".pdf")
                         let resultPath = NSString(string: resultDirectory).appendingPathComponent(fName+"."+self.extention())
@@ -204,176 +208,17 @@ class AutoTest : NSObject, AutoTestProtocal {
                         // ...
                         // 执行异步转换过程
                         self.process(originPath, resultPath: resultPath) { status in
-                            var isDirectory = ObjCBool(false)
-                            if FileManager.default.fileExists(atPath: resultPath, isDirectory:&isDirectory) && status == 1 {
-                                // compare screenshoot between result file with check file
-                                if needCompare {
-                                    let items = NSMutableArray()
-                                    if (isDirectory.boolValue) {
-                                        let searchItems = try! FileManager.default.contentsOfDirectory(atPath: resultPath)
-                                        for item in NSArray(array: searchItems) {
-                                            let ext = NSString(string: item as! String).pathExtension.lowercased()
-                                            if (NSArray(array: [self.extention()]).contains(ext)) {
-                                                let fileName = NSString(string: fName+"."+self.extention()+"/\(item as! String)").deletingPathExtension
-                                                items.add(fileName)
-                                            }
-                                        }
-                                    }else {
-                                        items.add(fName)
-                                    }
-                                    
-                                    var subDegree = Double(0);
-                                    var subCount = Int(0)
-                                    
-                                    self.compareImageQueue.maxConcurrentOperationCount = 3;
-                                    
-                                    var processCount = Int(0);
-                                    for item in items {
-                                        self.compareImageQueue.addOperation {
-                                            DispatchQueue.global().async {
-                                                autoreleasepool {
-                                                    let subFileName = item as! String
-                                                    let subResultPath = NSString(string: resultDirectory).appendingPathComponent(subFileName+"."+self.extention())
-                                                    
-                                                    self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(subFileName+".\(self.extention())")\"快照生成中\n",
-                                                                                                             attributes:[.foregroundColor : NSColor.black]))
-                                                    let rComparePath = NSString(string: resultDirectory).appendingPathComponent(subFileName+".jpg")
-                                                    let cComparePath = NSString(string: checkDirectory).appendingPathComponent(subFileName+".jpg")
-                                                    
-                                                    
-                                                    ProcessThumbnal.process(subResultPath, desPath: rComparePath, outputSize: CGSize.init(width: 2048, height: 2048)) { processSuccess in
-                                                        if ( processSuccess &&
-                                                             FileManager.default.fileExists(atPath: rComparePath)) {
-                                                            
-                                                            var isDirectory = ObjCBool(false)
-                                                            if FileManager.default.fileExists(atPath: rComparePath, isDirectory: &isDirectory) && isDirectory.boolValue {
-                                                                // 单个文件生成批量快照目录情形
-                                                                let subImages = try! FileManager.default.contentsOfDirectory(atPath: rComparePath)
-                                                                for subImageName in subImages {
-                                                                    let pathCompotent = "/"+subImageName
-                                                                    let degree = ImageProcess.compareJPEG(String(rComparePath+pathCompotent), checkPath: String(cComparePath+pathCompotent), processCover: true)
-                                                                    
-                                                                    
-                                                                    NSLog(String("文件夹,\(subFileName+".jpg"+pathCompotent)"))
-                                                                    
-                                                                    TestDegreeManager.shared().set(degree, fileType: self.fileType(), type: self.type(),
-                                                                                                   fileName: fileName, refFilePath: subFileName+".jpg"+pathCompotent)
-                                                                    
-                                                                    if degree == -1 {
-                                                                        self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(subResultPath+pathCompotent)\"快照对比失败,生成快照失败或无比对文件\n",
-                                                                                                                                 attributes:[.foregroundColor : NSColor.red]))
-                                                                    }else {
-                                                                        var color = NSColor.black
-                                                                        if fabs(degree-100.0) >= 0.01 {
-                                                                            color = NSColor.red
-                                                                        }
-                                                                        subDegree += degree
-                                                                        subCount += 1
-                                                                        
-                                                                        self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(subResultPath+pathCompotent)\"快照对比完成,图像相似度 \(degree)%\n",
-                                                                                                                                 attributes:[.foregroundColor : color]))
-                                                                    }
-                                                                }
-                                                            }else {
-                                                                // 单个文件生成单个快照文件情形
-                                                                
-                                                                let degree = ImageProcess.compareJPEG(rComparePath, checkPath: cComparePath, processCover: true)
-                                                                
-                                                                NSLog(String("非文件夹,\(subFileName+".jpg")"))
-                                                                
-                                                                TestDegreeManager.shared().set(degree, fileType: self.fileType(), type: self.type(),
-                                                                                               fileName: fileName, refFilePath: subFileName+".jpg")
-                                                                
-                                                                if degree == -1 {
-                                                                    self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(subResultPath)\"快照对比失败,生成快照失败或无比对文件\n",
-                                                                                                                             attributes:[.foregroundColor : NSColor.red]))
-                                                                }else {
-                                                                    var color = NSColor.black
-                                                                    if fabs(degree-100.0) >= 0.01 {
-                                                                        color = NSColor.red
-                                                                    }
-                                                                    subDegree += degree
-                                                                    subCount += 1
-                                                                    
-                                                                    self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(subResultPath)\"快照对比完成,图像相似度 \(degree)%\n",
-                                                                                                                             attributes:[.foregroundColor : color]))
-                                                                }
-                                                            }
-                                                        }else {
-                                                            self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(subResultPath)\"快照生成失败\n",
-                                                                                                                     attributes:[.foregroundColor : NSColor.red]))
-                                                        }
-                                                        
-                                                        processCount = processCount+1
-                                                        
-                                                        if (processCount >= items.count) {
-                                                            if subCount != 0 {
-                                                                subDegree = subDegree/Double(subCount)
-                                                            }else {
-                                                                subDegree = 0.0
-                                                            }
-                                                            
-                                                            TestDegreeManager.shared().set(subDegree,
-                                                                                           fileType: self.fileType(),
-                                                                                           type: self.type(),
-                                                                                           fileName: fileName)
-                                                            tDegree += subDegree;
-                                                            tCount += 1
-                                                            
-                                                            DispatchQueue.global().async {
-                                                                autoreleasepool {
-                                                                    // 执行下一个文件转档
-                                                                    convertFileBlock(files, fileIndex + 1)
-                                                                }
-                                                            }
-                                                        }
-                                                    }
-                                                }
-                                            }
-                                        }
-                                    }
-                                    if (items.count != 0) {
-                                        return
-                                    }
-                                    
-                                    if subCount != 0 {
-                                        subDegree = subDegree/Double(subCount)
-                                    }else {
-                                        subDegree = 0.0
-                                    }
-                                    
-                                    TestDegreeManager.shared().set(subDegree,
-                                                                   fileType: self.fileType(),
-                                                                   type: self.type(),
-                                                                   fileName: fileName)
-                                    tDegree += subDegree;
-                                    tCount += 1
-                                }
-                            }else {
-                                if (status == 0) {
-                                    self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(fName)\"转档失败!\n",
-                                                                                        attributes:[.foregroundColor : NSColor.red]))
-                                }else if (status == -1 || status == -2) {
-                                    self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(fName)\"文档无法打开!\n",
-                                                                                        attributes:[.foregroundColor : NSColor.red]))
-                                }else if (status == -3) {
-                                    self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(fName)\"转档中 Crash!\n",
-                                                                                        attributes:[.foregroundColor : NSColor.red]))
-                                }
-                                
-                            }
-                            
-                            DispatchQueue.global().async {
+                            self.compareResult(fileName, resultPath: resultPath, status: status, needCompare: needCompare) { degree in
                                 autoreleasepool {
-                                    // 执行下一个文件转档
-                                    convertFileBlock(files, fileIndex + 1)
+                                    fileIndex += 1;
+                                    convertFileBlock(files)
                                 }
-                            }
+                            };
                         }
                     }
                 }
                 // 启动第0号任务
-                convertFileBlock(files, 0);
+                convertFileBlock(files);
             }
             
             
@@ -409,6 +254,193 @@ class AutoTest : NSObject, AutoTestProtocal {
         }
     }
     
+    func compareResult(_ fileName:String, resultPath:String, status:Int, needCompare:Bool, complention:@escaping (_ degree:Double) -> ()) {
+        let checkDirectory = self.checkFileDirectory()
+//        let originDirectory = self.originFileDirectory()
+        let resultDirectory = self.resultFileDirectory()
+        let fName = NSString(string: fileName).deletingPathExtension
+        
+        var isDirectory = ObjCBool(false)
+        if FileManager.default.fileExists(atPath: resultPath, isDirectory:&isDirectory) && status == 1 {
+            // compare screenshoot between result file with check file
+            if needCompare {
+                let items = NSMutableArray()
+                if (isDirectory.boolValue) {
+                    let searchItems = try! FileManager.default.contentsOfDirectory(atPath: resultPath)
+                    for item in NSArray(array: searchItems) {
+                        let ext = NSString(string: item as! String).pathExtension.lowercased()
+                        if (NSArray(array: [self.extention()]).contains(ext)) {
+                            let fileName = NSString(string: fName+"."+self.extention()+"/\(item as! String)").deletingPathExtension
+                            items.add(fileName)
+                        }
+                    }
+                }else {
+                    items.add(fName)
+                }
+                var subDegree = Double(0);
+                var subCount = Int(0)
+                var itemIndex = 0;
+                
+                var processItemBlock = {(items:NSMutableArray) in
+                    
+                }
+                processItemBlock = {(items:NSMutableArray) in
+                    if (itemIndex >= items.count) {
+                        if subCount != 0 {
+                            subDegree = subDegree/Double(subCount)
+                        }else {
+                            subDegree = 0.0
+                        }
+                        
+                        TestDegreeManager.shared().set(subDegree,
+                                                       fileType: self.fileType(),
+                                                       type: self.type(),
+                                                       fileName: fileName)
+                        DispatchQueue.global().async {
+                            autoreleasepool {
+                                // 执行下一个文件转档
+                                complention(subDegree)
+                            }
+                        }
+                        return
+                    }
+                    DispatchQueue.global().async {
+                        autoreleasepool {
+                            let item = items[itemIndex]
+                            NSLog("\(itemIndex):\(item)")
+                            let subFileName = item as! String
+                            let subResultPath = NSString(string: resultDirectory).appendingPathComponent(subFileName+"."+self.extention())
+                            objc_sync_enter(self)
+                            self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(subFileName+".\(self.extention())")\"快照生成中\n",
+                                                                                     attributes:[.foregroundColor : NSColor.black]))
+                            objc_sync_exit(self)
+                            let rComparePath = NSString(string: resultDirectory).appendingPathComponent(subFileName+".jpg")
+                            let cComparePath = NSString(string: checkDirectory).appendingPathComponent(subFileName+".jpg")
+                            
+                            
+                            ProcessThumbnal.process(subResultPath, desPath: rComparePath, outputSize: CGSize.init(width: 2048, height: 2048)) { processSuccess in
+                                autoreleasepool {
+                                    if ( processSuccess &&
+                                         FileManager.default.fileExists(atPath: rComparePath)) {
+                                        
+                                        var isDirectory = ObjCBool(false)
+                                        if FileManager.default.fileExists(atPath: rComparePath, isDirectory: &isDirectory) && isDirectory.boolValue {
+                                            // 单个文件生成批量快照目录情形
+                                            let subImages = try! FileManager.default.contentsOfDirectory(atPath: rComparePath)
+                                            
+                                            var compareCount = 0;
+                                            for sImageName in subImages {
+                                                let subImageName = sImageName
+                                                autoreleasepool {
+                                                    let pathCompotent = "/"+subImageName
+                                                    ImageProcess.compareJPEG(String(rComparePath+pathCompotent), checkPath: String(cComparePath+pathCompotent), processCover: true, complention: { degree in
+                                                        NSLog(String("文件夹,\(subFileName+".jpg"+pathCompotent)"))
+                                                        
+                                                        TestDegreeManager.shared().set(degree, fileType: self.fileType(), type: self.type(),
+                                                                                       fileName: fileName, refFilePath: subFileName+".jpg"+pathCompotent)
+                                                        
+                                                        if degree == -1 {
+                                                            objc_sync_enter(self)
+                                                            self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(subResultPath+pathCompotent)\"快照对比失败,生成快照失败或无比对文件\n",
+                                                                                                                     attributes:[.foregroundColor : NSColor.red]))
+                                                            objc_sync_exit(self)
+                                                        }else {
+                                                            var color = NSColor.black
+                                                            if fabs(degree-100.0) >= 0.01 {
+                                                                color = NSColor.red
+                                                            }
+                                                            subDegree += degree
+                                                            subCount += 1
+                                                            
+                                                            objc_sync_enter(self)
+                                                            self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(subResultPath+pathCompotent)\"快照对比完成,图像相似度 \(degree)%\n",
+                                                                                                                     attributes:[.foregroundColor : color]))
+                                                            objc_sync_exit(self)
+                                                        }
+                                                        
+                                                        compareCount += 1
+                                                        if (compareCount >= subImages.count) {
+                                                            itemIndex += 1
+                                                            processItemBlock(items)
+                                                        }
+                                                    })
+                                                }
+                                            }
+                                            
+                                            if (subImages.count == 0) {
+                                                // complention
+                                                itemIndex += 1
+                                                processItemBlock(items)
+                                                return
+                                            }
+                                        }else {
+                                            // 单个文件生成单个快照文件情形
+                                            ImageProcess.compareJPEG(rComparePath, checkPath: cComparePath, processCover: true, complention: { degree in
+                                                NSLog(String("非文件夹,\(subFileName+".jpg")"))
+                                                
+                                                TestDegreeManager.shared().set(degree, fileType: self.fileType(), type: self.type(),
+                                                                               fileName: fileName, refFilePath: subFileName+".jpg")
+                                                
+                                                if degree == -1 {
+                                                    self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(subResultPath)\"快照对比失败,生成快照失败或无比对文件\n",
+                                                                                                             attributes:[.foregroundColor : NSColor.red]))
+                                                }else {
+                                                    var color = NSColor.black
+                                                    if fabs(degree-100.0) >= 0.01 {
+                                                        color = NSColor.red
+                                                    }
+                                                    subDegree += degree
+                                                    subCount += 1
+                                                    
+                                                    self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(subResultPath)\"快照对比完成,图像相似度 \(degree)%\n",
+                                                                                                             attributes:[.foregroundColor : color]))
+                                                }
+                                                
+                                                // complention
+                                                itemIndex += 1
+                                                processItemBlock(items)
+                                            })
+                                        }
+                                    }else {
+                                        self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(subResultPath)\"快照生成失败\n",
+                                                                                                 attributes:[.foregroundColor : NSColor.red]))
+                                        
+                                        // complention
+                                        itemIndex += 1
+                                        processItemBlock(items)
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+                processItemBlock(items)
+                
+                return
+            }
+        }else {
+            if (status == 0) {
+                self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(fName)\"转档失败!\n",
+                                                                         attributes:[.foregroundColor : NSColor.red]))
+            }else if (status == -1 || status == -2) {
+                self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(fName)\"文档无法打开!\n",
+                                                                         attributes:[.foregroundColor : NSColor.red]))
+            }else if (status == -3) {
+                self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】文件 \"\(fName)\"转档中 Crash!\n",
+                                                                         attributes:[.foregroundColor : NSColor.red]))
+            }
+        }
+        
+        DispatchQueue.global().async {
+            autoreleasepool {
+                // 执行下一个文件转档
+                complention(0)
+            }
+        }
+    }
+    
+    
+    ///
     func testReport() -> NSAttributedString? {
         return reportString
     }

+ 10 - 0
KdanAutoTest/KdanAuto/Class/AutoTestCase/AutoTestProperty.plist

@@ -293,6 +293,11 @@
 			<string>快照对比(新库)</string>
 			<key>Class</key>
 			<string>AutoTest</string>
+			<key>Params</key>
+			<dict>
+				<key>imageDpi</key>
+				<integer>200</integer>
+			</dict>
 		</dict>
 	</array>
 	<key>PNG</key>
@@ -338,6 +343,11 @@
 			<string>快照对比(新库)</string>
 			<key>Class</key>
 			<string>AutoTest</string>
+			<key>Params</key>
+			<dict>
+				<key>imageDpi</key>
+				<integer>200</integer>
+			</dict>
 		</dict>
 	</array>
 	<key>GIF</key>

+ 6 - 4
KdanAutoTest/KdanAuto/Class/AutoTestCase/StringAutoTest.swift

@@ -57,9 +57,10 @@ class CharacterAutoTest : AutoTest {
         
         var tDegree = Double(0);
         var tCount = Int(0)
+        var fileIndex = 0;
         
-        var convertFileBlock = { (files:[String], fileIndex:Int) in }
-        convertFileBlock = { (files:[String], fileIndex:Int) in
+        var convertFileBlock = { (files:[String]) in }
+        convertFileBlock = { (files:[String]) in
             if (fileIndex >= files.count) {
                 TestDegreeManager.shared().set(((tCount != 0) ? tDegree/Double(tCount) : 0.0),
                                                fileType: self.fileType(),
@@ -300,10 +301,11 @@ class CharacterAutoTest : AutoTest {
                     }
                 }
                 
-                convertFileBlock(files, fileIndex + 1);
+                fileIndex += 1
+                convertFileBlock(files);
             }
         }
-        convertFileBlock(files, 0);
+        convertFileBlock(files);
     }
     
     ///Compare

+ 6 - 4
KdanAutoTest/KdanAuto/Class/AutoTestCase/TextColorAutoTest.swift

@@ -78,9 +78,10 @@ class TextColorAutoTest : AutoTest {
         
         var tDegree = Double(0);
         var tCount = Int(0)
+        var fileIndex = 0;
         
-        var convertFileBlock = { (files:[String], fileIndex:Int) in }
-        convertFileBlock = { (files:[String], fileIndex:Int) in
+        var convertFileBlock = { (files:[String]) in }
+        convertFileBlock = { (files:[String]) in
             if (fileIndex >= files.count) {
                 TestDegreeManager.shared().set(((tCount != 0) ? tDegree/Double(tCount) : 0.0),
                                                fileType: self.fileType(),
@@ -341,10 +342,11 @@ class TextColorAutoTest : AutoTest {
                     }
                 }
                 
-                convertFileBlock(files, fileIndex + 1);
+                fileIndex += 1;
+                convertFileBlock(files);
             }
         }
-        convertFileBlock(files, 0);
+        convertFileBlock(files);
     }
     
     // Change String(Red, Green, Blue) to Color

+ 9 - 4
KdanAutoTest/KdanAuto/Class/Tools/FileConveter/FileConverter.swift

@@ -60,11 +60,11 @@ class FileConverter : NSObject, CPDFConverterDelegate, CPDFConverterFPDelegate {
         self.desPath = inDesPath
         
         if FileManager.default.fileExists(atPath: desPath) {
-            try! FileManager.default.removeItem(atPath: desPath)
+            try? FileManager.default.removeItem(atPath: desPath)
         }
         let directory = NSString(string: desPath).deletingLastPathComponent
         if !FileManager.default.fileExists(atPath: directory) {
-            try! FileManager.default.createDirectory(atPath: directory, withIntermediateDirectories: true)
+            try? FileManager.default.createDirectory(atPath: directory, withIntermediateDirectories: true)
         }
         let attributy = try! FileManager.default.attributesOfItem(atPath: srcPath)
         let fileType = attributy[FileAttributeKey.type] as! FileAttributeType
@@ -76,7 +76,7 @@ class FileConverter : NSObject, CPDFConverterDelegate, CPDFConverterFPDelegate {
         }
         
         if FileManager.default.fileExists(atPath: self.desPath) {
-            try! FileManager.default.removeItem(atPath: self.desPath)
+            try? FileManager.default.removeItem(atPath: self.desPath)
         }
         
         self.pathExtension = NSString(string: self.desPath).pathExtension
@@ -95,7 +95,7 @@ class FileConverter : NSObject, CPDFConverterDelegate, CPDFConverterFPDelegate {
             }
         }
         
-        NSLog("%@ - %@", useOldLib ? "老库" : "新库", params ?? "")
+        NSLog("%@ - %@\n\(inSrcPath)", useOldLib ? "老库" : "新库", params ?? "")
         
         self.convertQueue.async {
             let url = URL.init(fileURLWithPath: self.srcPath, isDirectory: false)
@@ -126,6 +126,11 @@ class FileConverter : NSObject, CPDFConverterDelegate, CPDFConverterFPDelegate {
                     }else {
                         (self.options as! CPDFConvertImgOptions).type = .PNG
                     }
+                    if (params != nil) {
+                        if let dipValue = params!["imageDpi"] as? NSNumber {
+                            try? (self.options as! CPDFConvertImgOptions).imageDpi = Int32(dipValue.intValue)
+                        }
+                    }
                     self.pdfConverter?.convert(toFilePath: cachePath, pageIndexs: self.pages, options: self.options)
                 }
             }else if !useOldLib && NSArray(array: ["ppt", "PPT", "PPTX", "pptx"]).contains(self.pathExtension) {

+ 198 - 13
KdanAutoTest/KdanAuto/Class/Tools/ImageProcess/ImageProcess.swift

@@ -32,13 +32,13 @@ class ImageProcess : NSObject {
             
             let rWidth = resultImageRep.pixelsWide
             let rHeight = resultImageRep.pixelsHigh
-//            let rBitPerPixel = resultImageRep.bitsPerPixel / 8
-//            let rBytePerRow = resultImageRep.bytesPerRow
+            //            let rBitPerPixel = resultImageRep.bitsPerPixel / 8
+            //            let rBytePerRow = resultImageRep.bytesPerRow
             
             let cWidth = checkImageRep.pixelsWide
             let cHeight = checkImageRep.pixelsHigh
-//            let cBitPerPixel = checkImageRep.bitsPerPixel / 8
-//            let cBytePerRow = checkImageRep.bytesPerRow
+            //            let cBitPerPixel = checkImageRep.bitsPerPixel / 8
+            //            let cBytePerRow = checkImageRep.bytesPerRow
             
             let maxWidth = min(rWidth, cWidth) - 1
             let maxHeight = min(rHeight, cHeight) - 1
@@ -72,20 +72,205 @@ class ImageProcess : NSObject {
                 }
             }
             
-//            if nil != bgColor {
-//                NSLog(String("识别到背景色\(bgColor)"))
-//            }
+            //            if nil != bgColor {
+            //                NSLog(String("识别到背景色\(bgColor)"))
+            //            }
             
-//            let bg_r = Int(bgColor.redComponent*255);
-//            let bg_g = Int(bgColor.redComponent*255);
-//            let bg_b = Int(bgColor.redComponent*255);
-//            let bg_a = Int(bgColor.redComponent*255);
-//
+            //            let bg_r = Int(bgColor.redComponent*255);
+            //            let bg_g = Int(bgColor.redComponent*255);
+            //            let bg_b = Int(bgColor.redComponent*255);
+            //            let bg_a = Int(bgColor.redComponent*255);
+            //
+            let data = NSMutableData.init(length: cWidth * cHeight * 4)
+            // Compare
+            let compareDifValue = DataModel.shared.comparativeDifference()
+            var equalCount = 0 as Double
+            var bgCount = 0 as Double
+            
+            let semaphore = DispatchSemaphore(value: 0)
+            let operateQueue = OperationQueue()
+            operateQueue.maxConcurrentOperationCount = 20;
+            var processCount = Int(0)
+            for w in 0...maxWidth {
+                let x = Int(w)
+                
+                operateQueue.addOperation {
+                    for h in 0...maxHeight {
+                        let y = Int(h)
+                        
+                        objc_sync_enter(self)
+                        let cColor = checkImageRep.colorAt(x: x, y: y) as! NSColor
+                        let rColor = resultImageRep.colorAt(x: x, y: y) as! NSColor
+                        objc_sync_exit(self)
+                        
+                        let cr = Int(cColor.redComponent*255)
+                        let cg = Int(cColor.greenComponent*255)
+                        let cb = Int(cColor.blueComponent*255)
+                        let ca = Int(cColor.blueComponent*255)
+                        
+                        let rr = Int(rColor.redComponent*255)
+                        let rg = Int(rColor.greenComponent*255)
+                        let rb = Int(rColor.blueComponent*255)
+                        let ra = Int(rColor.blueComponent*255)
+                        
+                        //                if (cColor.isEqual(to: rColor)) {
+                        if (abs(cr - rr) <= compareDifValue &&
+                            abs(cg - rg) <= compareDifValue &&
+                            abs(cb - rb) <= compareDifValue &&
+                            abs(ca - ra) <= compareDifValue) {
+                            equalCount = equalCount + 1
+                            
+                            if cColor.isEqual(to: bgColor) {
+                                objc_sync_enter(self)
+                                bgCount += 1
+                                objc_sync_exit(self)
+                            }
+                        }else if (processCover && nil != data){
+                            let addr = cWidth * 4 * y + x * 4
+                            
+                            objc_sync_enter(self)
+                            var r = uint8(255)
+                            data!.replaceBytes(in: NSRange.init(location: addr+0, length: 1), withBytes: &r)
+                            var g = uint8(255 * rColor.greenComponent/2)
+                            data!.replaceBytes(in: NSRange.init(location: addr+1, length: 1), withBytes: &g)
+                            var b = uint8(255 * rColor.blueComponent/2)
+                            data!.replaceBytes(in: NSRange.init(location: addr+2, length: 1), withBytes: &b)
+                            var a = uint8(255 * rColor.alphaComponent * 0.7)
+                            data!.replaceBytes(in: NSRange.init(location: addr+3, length: 1), withBytes: &a)
+                            objc_sync_exit(self)
+                        }
+                    }
+                    
+                    processCount = processCount+1
+                    if (processCount >= maxWidth) {
+                        semaphore.signal()
+                    }
+                }
+            }
+            
+            semaphore.wait()
+            
+            let outDegree = Double(max(equalCount-bgCount, 1)/(max(Double(cWidth) * Double(cHeight)-bgCount, 1)) * 100.0)
+            if (abs(outDegree - 100) > 0 && processCover && nil != data) {
+                DispatchQueue.global().async {
+                    let cfData = CFDataCreate(kCFAllocatorDefault, data?.bytes, data!.length)
+                    let dataProvider = CGDataProvider.init(data: cfData!)
+                    
+                    let colorSpace = CGColorSpaceCreateDeviceRGB()
+                    let cgImage = CGImage.init(width: cWidth,
+                                               height: cHeight,
+                                               bitsPerComponent: 8,
+                                               bitsPerPixel: 8 * 4,
+                                               bytesPerRow: cWidth * 4,
+                                               space: colorSpace,
+                                               bitmapInfo: CGBitmapInfo(rawValue: CGImageAlphaInfo.premultipliedLast.rawValue | CGBitmapInfo.byteOrderDefault.rawValue) ?? CGBitmapInfo.byteOrderDefault,
+                                               provider: dataProvider!,
+                                               decode: nil,
+                                               shouldInterpolate: true,
+                                               intent: CGColorRenderingIntent.defaultIntent)
+                    
+                    if nil != cgImage {
+                        let coverPath = NSString(format: "%@_cover.png", NSString(string: resultPath).deletingPathExtension) as! String
+                        let rep = NSBitmapImageRep.init(cgImage: cgImage!)
+                        
+                        if let saveData = rep.representation(using: .png, properties: [:]) {
+                            let url = URL.init(fileURLWithPath: coverPath, isDirectory: false)
+                            try? saveData.write(to: url)
+                        }
+                    }
+                }
+            }
+            
+            NSLog(String("过滤点数目\(bgCount)"))
+            
+            return outDegree
+        }
+    }
+    
+    class func compareJPEG(_ resultPath:String, checkPath:String, processCover:Bool, complention:@escaping (_ degree:Double) -> ()) {
+        autoreleasepool {
+            if !FileManager.default.fileExists(atPath: resultPath) || !FileManager.default.fileExists(atPath: checkPath) {
+                complention(-1)
+                return
+            }
+            
+            let rImage = NSImage.init(contentsOfFile: resultPath) ?? nil
+            let cImage = NSImage.init(contentsOfFile: checkPath) ?? nil
+            
+            if nil == rImage || nil == cImage {
+                complention(-1)
+                return
+            }
+            
+            let resultImage = rImage!
+            let checkImage = cImage!
+            
+            let resultImageRep = NSBitmapImageRep.init(cgImage: resultImage.cgImage(forProposedRect: nil, context: nil, hints: nil)!)
+            let checkImageRep = NSBitmapImageRep.init(cgImage: checkImage.cgImage(forProposedRect: nil, context: nil, hints: nil)!)
+            
+            let rWidth = resultImageRep.pixelsWide
+            let rHeight = resultImageRep.pixelsHigh
+            //            let rBitPerPixel = resultImageRep.bitsPerPixel / 8
+            //            let rBytePerRow = resultImageRep.bytesPerRow
+            
+            let cWidth = checkImageRep.pixelsWide
+            let cHeight = checkImageRep.pixelsHigh
+            //            let cBitPerPixel = checkImageRep.bitsPerPixel / 8
+            //            let cBytePerRow = checkImageRep.bytesPerRow
+            
+            let maxWidth = min(rWidth, cWidth) - 1
+            let maxHeight = min(rHeight, cHeight) - 1
+            
+            if (maxWidth == 0) {
+                complention(-1)
+                return
+            }
+            
+            // check background color
+            // 挑选图片 对角斜线 上的相素进行识别
+            let markInfo = NSMutableDictionary.init()
+            for w in 0...maxWidth {
+                let x = Int(w)
+                for mark in 0...1 {
+                    let color = checkImageRep.colorAt(x: min(x, cWidth-1), y: min(mark == 0 ? x : (maxWidth - x), (cHeight-1))) as! NSColor
+                    
+                    if (markInfo[color] != nil) {
+                        let count = (markInfo[color] as? NSNumber)!.intValue
+                        
+                        markInfo[color] = NSNumber.init(value: count + 1)
+                    }else {
+                        markInfo[color] = NSNumber.init(value: 1)
+                    }
+                }
+            }
+            
+            var maxCount = Int(0);
+            var bgColor : NSColor = NSColor.clear
+            for color in markInfo.allKeys {
+                let count = (markInfo[color] as? NSNumber)!.intValue
+                
+                if count > maxCount {
+                    maxCount = count
+                    bgColor = color as! NSColor
+                }
+            }
+            
+            //            if nil != bgColor {
+            //                NSLog(String("识别到背景色\(bgColor)"))
+            //            }
+            
+            //            let bg_r = Int(bgColor.redComponent*255);
+            //            let bg_g = Int(bgColor.redComponent*255);
+            //            let bg_b = Int(bgColor.redComponent*255);
+            //            let bg_a = Int(bgColor.redComponent*255);
+            //
             let data = NSMutableData.init(length: cWidth * cHeight * 4)
             // Compare
             let compareDifValue = DataModel.shared.comparativeDifference()
             var equalCount = 0 as Double
             var bgCount = 0 as Double
+            
+            var processCount = Int(0)
             for w in 0...maxWidth {
                 let x = Int(w)
                 
@@ -163,7 +348,7 @@ class ImageProcess : NSObject {
             
             NSLog(String("过滤点数目\(bgCount)"))
             
-            return outDegree
+            complention(outDegree)
         }
     }
     

+ 11 - 8
KdanAutoTest/KdanAuto/ViewController.swift

@@ -134,7 +134,7 @@ class ViewController : NSViewController, SettingViewControllerDelegate, AutoTest
         
         DispatchQueue.global().async {
             let report = NSMutableAttributedString.init()
-//            DataModel.shared.generaNewReportID()
+            //            DataModel.shared.generaNewReportID()
             TestDegreeManager.shared().clearAllHistory()
             
             let objects = NSMutableArray()
@@ -155,13 +155,15 @@ class ViewController : NSViewController, SettingViewControllerDelegate, AutoTest
                     self.reloadListData()
                 }
             }
-            var autotestBlock:(NSMutableArray, Int) -> () = { (objects:NSMutableArray, index:Int) in
+            
+            var objectIndex = 0
+            var autotestBlock:(NSMutableArray) -> () = { (objects:NSMutableArray) in
                 
             }
             //创建 Block
-            autotestBlock = { (objects:NSMutableArray, index:Int) in
-                NSLog("Auto Test \(index)")
-                if (index >= objects.count) {
+            autotestBlock = { (objects:NSMutableArray) in
+                NSLog("Auto Test \(objectIndex)")
+                if (objectIndex >= objects.count) {
                     // 所有自动化测试对象均执行完成
                     do {
                         let rtfData = try report.data(from: .init(location: 0, length: report.length),
@@ -189,7 +191,7 @@ class ViewController : NSViewController, SettingViewControllerDelegate, AutoTest
                 }
                 
                 // 执行当前索引自动化测试对象
-                let testobject = objects.object(at: index) as! AutoTest
+                let testobject = objects.object(at: objectIndex) as! AutoTest
                 testobject.setStatus(.Process)
                 
                 // 异步执行自动化测试
@@ -218,7 +220,8 @@ class ViewController : NSViewController, SettingViewControllerDelegate, AutoTest
                     DispatchQueue.global().async {
                         autoreleasepool {
                             // 触发下一个自动化测试对象进入自动化测试
-                            autotestBlock(objects, index+1)
+                            objectIndex += 1
+                            autotestBlock(objects)
                         }
                     }
                     
@@ -226,7 +229,7 @@ class ViewController : NSViewController, SettingViewControllerDelegate, AutoTest
                 }
             }
             // 异步第0号位置自动化测试
-            autotestBlock(objects, 0)
+            autotestBlock(objects)
         }
     }
     

+ 18 - 7
KdanAutoTest/ProcessCheckFile/Process/ProcessThumbnal.swift

@@ -13,6 +13,8 @@ import QuickLookThumbnailing
 
 import ImageIO
 
+let generate = QLThumbnailGenerator.shared
+
 class ProcessThumbnal : NSObject {
     
     // 异步方法
@@ -56,14 +58,17 @@ class ProcessThumbnal : NSObject {
                 
                 return true
             })
+            
+            return 
         }
         
         var didFinished = false
+        var didCallback = false;
         
         let url = URL.init(fileURLWithPath: filePath, isDirectory: false)
-        let generate = QLThumbnailGenerator.shared
-        generate.generateRepresentations(for: QLThumbnailGenerator.Request.init(fileAt: url, size: outputSize, scale: 2.0, representationTypes: QLThumbnailGenerator.Request.RepresentationTypes.thumbnail),
-                                            update: { (representation, type, error) in
+        let request = QLThumbnailGenerator.Request.init(fileAt: url, size: outputSize, scale: 2.0, representationTypes: QLThumbnailGenerator.Request.RepresentationTypes.thumbnail)
+        generate.generateBestRepresentation(for: request,
+                                            completion: { (representation, error) in
             if nil != representation {
                 autoreleasepool {
                     let image = representation!.nsImage as NSImage
@@ -80,7 +85,12 @@ class ProcessThumbnal : NSObject {
                 }
             }
             
-            complention(didFinished)
+            if (!didCallback) {
+                didCallback = true;
+                complention(didFinished)
+            }
+            
+            generate.cancel(request)
         })
     }
     
@@ -132,9 +142,9 @@ class ProcessThumbnal : NSObject {
         let semaphore = DispatchSemaphore(value: 0)
         let url = URL.init(fileURLWithPath: filePath, isDirectory: false)
         DispatchQueue.main.async {
-            let generate = QLThumbnailGenerator.shared
-            generate.generateRepresentations(for: QLThumbnailGenerator.Request.init(fileAt: url, size: outputSize, scale: 2.0, representationTypes: QLThumbnailGenerator.Request.RepresentationTypes.thumbnail),
-                                                update: { (representation, type, error) in
+            let request = QLThumbnailGenerator.Request.init(fileAt: url, size: outputSize, scale: 2.0, representationTypes: QLThumbnailGenerator.Request.RepresentationTypes.thumbnail)
+            generate.generateBestRepresentation(for: request,
+                                                completion: { (representation, error) in
                 if nil != representation {
                     autoreleasepool {
                         let image = representation!.nsImage as NSImage
@@ -151,6 +161,7 @@ class ProcessThumbnal : NSObject {
                     }
                 }
                 
+                generate.cancel(request)
                 semaphore.signal()
             })
         }