Browse Source

功能完善 - App 再次启动时,载入最后一次的测试结果/报告

zhudongyong 1 year ago
parent
commit
44a01ae49e

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


+ 12 - 0
KdanAutoTest/KdanAuto/Base.lproj/Main.storyboard

@@ -490,6 +490,17 @@
                                     <action selector="showCompareReportAction:" target="XfG-lQ-9wD" id="3LT-OL-5xV"/>
                                 </connections>
                             </button>
+                            <button toolTip="Replace refrence images for all file type" verticalHuggingPriority="750" id="r1f-nd-TJ0">
+                                <rect key="frame" x="758" y="34" width="127" height="32"/>
+                                <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
+                                <buttonCell key="cell" type="push" title="显示上一次报告" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="8Yd-bX-NTi">
+                                    <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                    <font key="font" metaFont="system"/>
+                                </buttonCell>
+                                <connections>
+                                    <action selector="showLatestReportAction:" target="XfG-lQ-9wD" id="xQf-6z-j9T"/>
+                                </connections>
+                            </button>
                         </subviews>
                     </view>
                     <connections>
@@ -498,6 +509,7 @@
                         <outlet property="customView" destination="WFX-nZ-eg1" id="Qum-9S-ko1"/>
                         <outlet property="exportReportBtn" destination="KSs-7p-lxT" id="1N0-GT-3nS"/>
                         <outlet property="itemsList" destination="4NA-ss-yPX" id="uIe-KN-SjY"/>
+                        <outlet property="latestResultBtn" destination="r1f-nd-TJ0" id="Ayi-mH-WBt"/>
                         <outlet property="replaceAllBtn" destination="NYu-z2-pHZ" id="ad4-9q-UWw"/>
                         <outlet property="startBtn" destination="CUw-Wo-mUO" id="mGh-eH-Fbj"/>
                     </connections>

+ 24 - 3
KdanAutoTest/KdanAuto/ViewController.swift

@@ -24,6 +24,7 @@ class ViewController : NSViewController, SettingViewControllerDelegate, AutoTest
     @IBOutlet var replaceAllBtn : NSButton!
     @IBOutlet var exportReportBtn : NSButton!
     @IBOutlet var advanceBtn : NSButton!
+    @IBOutlet var latestResultBtn : NSButton!
     
     var operateQueue = OperationQueue()
     var _isProcessing : Bool!
@@ -323,9 +324,11 @@ class ViewController : NSViewController, SettingViewControllerDelegate, AutoTest
                 let type = ti["Type"] as! NSString
                 
                 let testObject = AutoTest.autoTestFor(fileType as NSString, type: type)
-                let tFiles = testObject?.compareFiles();
-                if (tFiles != nil && tFiles?.count != 0) {
-                    files.addObjects(from: tFiles as! [Any])
+                if (testObject?.selectedKeys().count != 0) {
+                    let tFiles = testObject?.compareFiles();
+                    if (tFiles != nil && tFiles?.count != 0) {
+                        files.addObjects(from: tFiles as! [Any])
+                    }
                 }
             }
         }
@@ -338,7 +341,25 @@ class ViewController : NSViewController, SettingViewControllerDelegate, AutoTest
             compareVC.showIn(self.view.window?.contentView ?? self.view, rect: NSRect.init(origin: point, size: sender.frame.size))
         }
         return
+    }
+    
+    @IBAction func showLatestReportAction(_ sender:NSButton) {
+        latestResultBtn.isHidden = true;
         
+        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)
+                
+                if (testObject?.selectedKeys().count ?? 0 > 0) {
+                    testObject?.setStatus(.Finished)
+                }
+            }
+        }
+        self.reloadListData()
     }