소스 검색

交互优化 - 实时进度及状态更新;

zhudongyong 2 년 전
부모
커밋
e55d07de18

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


+ 8 - 1
KdanAutoTest/KdanAuto/Class/AutoTestCase/AutoTest.swift

@@ -23,7 +23,9 @@ class AutoTest : NSObject, AutoTestProtocal {
     var _params : NSDictionary = [:]
     
     var testFiles : NSArray = NSArray()
+    var convertFiles : NSMutableArray = NSMutableArray()
     var convertProgress : Double = 0.0
+    var compareFinishedFiles : NSMutableArray = NSMutableArray()
     var compareProgress : Double = 0.0
     
     var testlog : (_ msg:String, _ progress:Double) -> () = {(msg, progress) in
@@ -150,6 +152,8 @@ class AutoTest : NSObject, AutoTestProtocal {
     // Auto Test
     func autoTest(_ complention:@escaping (_ object:AutoTest, _ report:NSAttributedString?) -> ()) {
         clearCacheFiles()
+        self.compareFinishedFiles.removeAllObjects();
+        self.convertFiles.removeAllObjects()
         
         NSLog(String("转换\(self.type())"))
         let needCompare = self.selectedKeys().contains("快照")
@@ -214,6 +218,7 @@ class AutoTest : NSObject, AutoTestProtocal {
                         if (index != NSNotFound) {
                             self.convertProgress = Double(index) / Double(self.testFiles.count)
                         }
+                        self.convertFiles.add(fileName);
                         self.testlog("开始转换:"+fileName, (self.compareProgress + self.convertProgress)/2.0)
                         self.process(originPath, resultPath: resultPath) { status in
                             DispatchQueue.global().async {
@@ -340,6 +345,7 @@ class AutoTest : NSObject, AutoTestProtocal {
                                     if (index != NSNotFound) {
                                         self.compareProgress = Double(index) / Double(self.testFiles.count)
                                     }
+                                    self.compareFinishedFiles.add(fileName);
                                     self.testlog("对比完成:"+fileName, (self.compareProgress + self.convertProgress)/2.0)
                                 }
                             }
@@ -494,6 +500,7 @@ class AutoTest : NSObject, AutoTestProtocal {
                 if (index != NSNotFound) {
                     self.compareProgress = Double(index) / Double(self.testFiles.count)
                 }
+                self.compareFinishedFiles.add(fileName);
                 self.testlog("对比完成:"+fileName, (self.compareProgress + self.convertProgress)/2.0)
                 complention(0)
             }
@@ -865,7 +872,7 @@ extension AutoTest {
         return (NSString(string: self.className).isEqual(to: object.className) &&
                 NSString(string: self.fileType()).isEqual(to: object.fileType()) &&
                 NSString(string: self.type()).isEqual(to: object.type()) &&
-                NSString(string: _extention).isEqual(to: object._extention))
+                NSString(string: self.extention()).isEqual(to: object.extention()))
     }
 }
 

+ 10 - 1
KdanAutoTest/KdanAuto/Class/Norrmal/AutoTestAdvanceSettingView.swift

@@ -333,7 +333,16 @@ class AutoTestAdvanceSettingView : NSView, NSTableViewDataSource, NSTableViewDel
                 cellView?.setNeedReplaceBtn(false)
             }
             
-            if _autoTestObj != nil && _autoTestObj?.status() == .Finished {
+            if (_autoTestObj != nil) {
+                cellView?.set((_autoTestObj!.status() == .Process &&
+                               _autoTestObj!.convertFiles.contains(title) &&
+                               !_autoTestObj!.compareFinishedFiles.contains(title)))
+            }else {
+                cellView?.set(false)
+            }
+            if _autoTestObj != nil &&
+                (_autoTestObj?.status() == .Finished ||
+                 _autoTestObj!.compareFinishedFiles.contains(title)) {
                 cellView?.setNeedDegreeBtn(true)
                 cellView?.setDegree((_autoTestObj?.degreeOfFile(title))!)
             }else {

+ 18 - 0
KdanAutoTest/KdanAuto/Class/Norrmal/Cell/TestFileCellView.swift

@@ -21,6 +21,7 @@ protocol TestFileCellViewDelegate : NSObjectProtocol {
 class TestFileCellView : NSTableCellView, NSMenuDelegate {
     @IBOutlet var _titleLbl : NSTextField!
     @IBOutlet var _sepLine : NSView!
+    @IBOutlet var _progressView : NSProgressIndicator!
     
     @IBOutlet var _replaceBtn : NSButton!
     @IBOutlet var _testReportBtn : NSButton!
@@ -29,6 +30,8 @@ class TestFileCellView : NSTableCellView, NSMenuDelegate {
     var _isExpad: Bool!
     var _typeInfo : NSDictionary!
     
+    var _isActivting : Bool = false;
+    
     var _degree : Double = 0
     
     weak public var _delegate : (TestFileCellViewDelegate)?
@@ -82,6 +85,17 @@ class TestFileCellView : NSTableCellView, NSMenuDelegate {
         return _title
     }
     
+    public func set(_ activiting:Bool) {
+        _isActivting = activiting;
+        
+        if (_isActivting) {
+            _progressView.startAnimation(nil);
+        }else {
+            _progressView.stopAnimation(nil);
+        }
+        _progressView.isHidden = !_isActivting
+    }
+    
     public func fileType() -> String? {
         return _title
     }
@@ -102,6 +116,10 @@ class TestFileCellView : NSTableCellView, NSMenuDelegate {
     
     public func setNeedDegreeBtn(_ needDegree:Bool) {
         _testReportBtn.isHidden = !needDegree
+        
+        if (needDegree) {
+            self.set(!needDegree)
+        }
     }
     
     public func setDegree(_ degree:Double) {

+ 5 - 0
KdanAutoTest/KdanAuto/Class/Norrmal/Cell/TestFileCellView.xib

@@ -48,8 +48,13 @@
                         <action selector="showReportAction:" target="Ob6-j8-aNh" id="m1v-7B-LUA"/>
                     </connections>
                 </button>
+                <progressIndicator hidden="YES" fixedFrame="YES" maxValue="100" displayedWhenStopped="NO" indeterminate="YES" controlSize="small" style="spinning" id="sSA-JI-nga">
+                    <rect key="frame" x="314" y="7" width="16" height="16"/>
+                    <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
+                </progressIndicator>
             </subviews>
             <connections>
+                <outlet property="_progressView" destination="sSA-JI-nga" id="cnX-Qr-MPd"/>
                 <outlet property="_replaceBtn" destination="1iY-9V-oMo" id="oZj-hx-Yyo"/>
                 <outlet property="_sepLine" destination="Dg0-nG-U3m" id="fck-m4-6W4"/>
                 <outlet property="_testReportBtn" destination="k7x-WS-SBq" id="Aku-Zy-2rn"/>

+ 7 - 1
KdanAutoTest/KdanAuto/Class/Tools/FileConveter/FileConverter.swift

@@ -133,7 +133,13 @@ class FileConverter : NSObject, CPDFConverterDelegate, CPDFConverterFPDelegate {
                             }
                         }
                     }
-                    self.pdfConverter?.convert(toFilePath: cachePath, pageIndexs: self.pages, options: self.options)
+                    do {
+                        try? self.pdfConverter?.convert(toFilePath: cachePath, pageIndexs: self.pages, options: self.options)
+                    }catch {
+                        self.didSuccess = -1;
+                        
+                        self.complention(self.didSuccess)
+                    }
                 }
             }else if !useOldLib && NSArray(array: ["ppt", "PPT", "PPTX", "pptx"]).contains(self.pathExtension) {
                 autoreleasepool {

+ 2 - 3
KdanAutoTest/KdanAuto/Class/Tools/ImageProcess/ImageProcess.swift

@@ -221,7 +221,7 @@ class ImageProcess : NSObject {
             }
             
             if (ImageProcess.checkEqualFor(resultPath, checkPath: checkPath)) {
-                complention(1)
+                complention(100)
                 return
             }
             
@@ -566,8 +566,7 @@ class ImageProcess : NSObject {
             if (nil == data) {
                 return nil;
             }
-            
-            return String(format: "%x", data.hashValue);
+            return String(format: "%X", data.hashValue);
         }
         
         return nil;

+ 3 - 0
KdanAutoTest/KdanAuto/ViewController.swift

@@ -149,6 +149,9 @@ class ViewController : NSViewController, SettingViewControllerDelegate, AutoTest
                     testObject?.testlog = { (msg, progress) in
                         DispatchQueue.main.async {
                             self.view.window?.title = "\(msg)(\(Int(progress*100))%)";
+                            if (testObject!.isEqual(to: self.advanceView._autoTestObj)) {
+                                self.advanceView.setAutoTestObj(testObject)
+                            }
                         }
                     }
                     if (testObject != nil) {