Jelajahi Sumber

综合 - 测试项,修改测试类型,类型需要重启才能切换问题修复;

zhudongyong 1 tahun lalu
induk
melakukan
eee41d905f
1 mengubah file dengan 53 tambahan dan 8 penghapusan
  1. 53 8
      KdanAutoTest/KdanAuto/Class/AutoTestCase/AutoTest.swift

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

@@ -1031,23 +1031,68 @@ extension AutoTest {
         return object
     }
     
-    func update(_ property:NSDictionary) {
+    func update(_ property:NSDictionary) -> AutoTest? {
+        let cClass = property["Class"] as! NSString
+        let oClass = self.m_info["Class"] as! NSString
+        
         let cID = property["ID"] as! NSString
         let cType = property["Type"] as! NSString
         let cExtention = property["Extention"] as! NSString
         let cName = property["Name"] as! NSString
         let cParams = property["Params"] as? NSDictionary
         
-        self.m_id = cID as String
-        self.m_info = NSDictionary(dictionary: property)
-        self._type = String(cType)
-        self._extention = String(cExtention)
-        self._name = String(cName)
-        if nil != cParams {
-            self._params = cParams ?? [:];
+        var object = self;
+        if (cClass.isEqual(to: oClass)) {
+            self.m_id = cID as String
+            self.m_info = NSDictionary(dictionary: property)
+            self._type = String(cType)
+            self._extention = String(cExtention)
+            self._name = String(cName)
+            if nil != cParams {
+                self._params = cParams ?? [:];
+            }
+        }else {
+            let fileType = self.fileType() as String
+            let key = self.fileType() as String
+            let ID = cID
+            
+            // 移除原来的Object
+            if cacheObjects.value(forKey: key) != nil {
+                let objectInfo = cacheObjects.value(forKey: key) as! NSMutableDictionary
+                
+                if objectInfo.value(forKey: ID as String) != nil {
+                    objectInfo.setValue(nil, forKey: ID as String)
+                }
+            }
+            
+            var objectInfo = cacheObjects.value(forKey: key) as? NSMutableDictionary
+            if (nil == objectInfo) {
+                objectInfo = NSMutableDictionary()
+                cacheObjects.setValue(objectInfo, forKey: key)
+            }
+            
+            let params = NSMutableDictionary(dictionary: property)
+            let clsname = "KdanAuto"//Bundle.main.infoDictionary! ["CFBundleExecutable"]
+            let className = String((clsname )+"."+(params["Class"] as! String))
+            let cl = NSClassFromString(className) as! AutoTest.Type
+            
+            object = cl.shared()!
+            object.m_id = ID as String
+            object.m_info = NSDictionary(dictionary: params)
+            object._fileType = fileType
+            object._type = String(cType)
+            object._extention = String(cExtention)
+            object._name = String(cName)
+            if nil != cParams {
+                object._params = cParams ?? [:];
+            }
+            objectInfo!.setValue(object, forKey: ID as String)
+            
         }
         
         AutoTest.saveObjects()
+        
+        return object
     }
     
     func delete() {