|
@@ -14,14 +14,25 @@ class ViewController : NSViewController, SettingViewControllerDelegate, AutoTest
|
|
|
@IBOutlet var settingVC : SettingViewController!
|
|
|
|
|
|
@IBOutlet var itemsList : NSTableView!
|
|
|
+ var _currentCellInfo : AutoTestCellInfo?
|
|
|
@IBOutlet var advanceView : AutoTestAdvanceSettingView!
|
|
|
|
|
|
@IBOutlet var startBtn : NSButton!
|
|
|
var _isProcessing : Bool!
|
|
|
+
|
|
|
+ var _selectFileType : String! = ""
|
|
|
|
|
|
override func viewDidLoad() {
|
|
|
super.viewDidLoad()
|
|
|
|
|
|
+ // Load Infos
|
|
|
+ let path = Bundle.main.path(forResource: "AutoTestProperty", ofType: "plist")!
|
|
|
+ let initInfo = try! NSDictionary.init(contentsOf: URL.init(filePath: path), error: ())
|
|
|
+
|
|
|
+ testFileTypes = initInfo.allKeys as [String]
|
|
|
+ testTypeInfo = initInfo as NSDictionary
|
|
|
+
|
|
|
+ //
|
|
|
advanceView.delegate = self;
|
|
|
updateProcessStatus()
|
|
|
// Do any additional setup after loading the view.
|
|
@@ -46,6 +57,19 @@ class ViewController : NSViewController, SettingViewControllerDelegate, AutoTest
|
|
|
|
|
|
}
|
|
|
|
|
|
+ // Setter & Getter
|
|
|
+ func setCurrentCellInfo(_ cellInfo : AutoTestCellInfo?) {
|
|
|
+ _currentCellInfo = cellInfo
|
|
|
+
|
|
|
+ if (nil != _currentCellInfo) {
|
|
|
+ let autoTestObj = AutoTest.autoTestFor(NSString(string: (_currentCellInfo?.fileType())!), type:NSString(string: (_currentCellInfo?.typeInfo()["Type"] as! String)))
|
|
|
+
|
|
|
+ advanceView.setAutoTestObj(autoTestObj)
|
|
|
+ }else {
|
|
|
+ advanceView.setAutoTestObj(nil)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
// IBAction
|
|
|
@IBAction func showSettingVC(_ sender:NSButton) {
|
|
@@ -60,43 +84,43 @@ 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)
|
|
|
- }
|
|
|
+// 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)
|
|
|
+// }
|
|
|
|
|
|
DispatchQueue.main.async {
|
|
|
self._isProcessing = false
|
|
@@ -108,32 +132,25 @@ class ViewController : NSViewController, SettingViewControllerDelegate, AutoTest
|
|
|
|
|
|
// TableView Delegate
|
|
|
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
|
|
|
- let cellView = TestCaseCellView.shared()
|
|
|
-
|
|
|
- let type = testCaseNames[row]
|
|
|
- let autoTestObj = AutoTest.autoTestForType(type as! NSString)
|
|
|
+ let cellInfo = AutoTestCellInfo.initWithRow(row)
|
|
|
|
|
|
- cellView?.setAutoTestObj(autoTestObj)
|
|
|
-
|
|
|
- return cellView
|
|
|
+ if cellInfo.isFileType() {
|
|
|
+ let cellView = TestFileTypeCellView.shared()
|
|
|
+
|
|
|
+ let title = cellInfo.fileType()
|
|
|
+
|
|
|
+ cellView?.setTitle(title)
|
|
|
+
|
|
|
+ return cellView
|
|
|
+ }else {
|
|
|
+ let cellView = TestTypeCellView.shared()
|
|
|
+
|
|
|
+ cellView?.setTypeInfo(cellInfo.typeInfo());
|
|
|
+
|
|
|
+ return cellView
|
|
|
+ }
|
|
|
}
|
|
|
-//
|
|
|
-// func tableView(_ tableView: NSTableView, rowViewForRow row: Int) -> NSTableRowView? {
|
|
|
-// let cell = TestCaseCellView.shared()
|
|
|
-//
|
|
|
-// cell?.setTitle(testCaseNames[row])
|
|
|
-//
|
|
|
-// return cell as! NSTableRowView
|
|
|
-// }
|
|
|
|
|
|
-// func tableView(_ tableView: NSTableView, dataCellFor tableColumn: NSTableColumn?, row: Int) -> NSCell? {
|
|
|
-// var cell = NSCell.init(textCell: testCaseNames[row]);
|
|
|
-//
|
|
|
-// cell.title = testCaseNames[row]
|
|
|
-//
|
|
|
-// return cell
|
|
|
-// }
|
|
|
-
|
|
|
func selectionShouldChange(in tableView: NSTableView) -> Bool {
|
|
|
|
|
|
|
|
@@ -163,7 +180,7 @@ class ViewController : NSViewController, SettingViewControllerDelegate, AutoTest
|
|
|
}
|
|
|
|
|
|
func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat {
|
|
|
- return 60
|
|
|
+ return 30
|
|
|
}
|
|
|
|
|
|
func tableView(_ tableView: NSTableView, isGroupRow row: Int) -> Bool {
|
|
@@ -179,14 +196,23 @@ class ViewController : NSViewController, SettingViewControllerDelegate, AutoTest
|
|
|
}
|
|
|
|
|
|
func tableViewSelectionDidChange(_ notification: Notification) {
|
|
|
- let selectRow = itemsList.selectedRow
|
|
|
- if selectRow != -1 {
|
|
|
- let type = testCaseNames[selectRow]
|
|
|
- let autoTestObj = AutoTest.autoTestForType(type as! NSString)
|
|
|
+ if ((notification.object as! NSTableView) == itemsList) {
|
|
|
+ let selectRow = itemsList.selectedRow
|
|
|
|
|
|
- advanceView?.setAutoTestObj(autoTestObj)
|
|
|
- }else {
|
|
|
- advanceView?.setAutoTestObj(nil)
|
|
|
+ if selectRow != -1 {
|
|
|
+ let cellInfo = AutoTestCellInfo.initWithRow(selectRow)
|
|
|
+
|
|
|
+ if cellInfo.isFileType() {
|
|
|
+ let isExpend = DataModel.shared.isExpand(cellInfo.fileType())
|
|
|
+
|
|
|
+ DataModel.shared.setIsExpand(cellInfo.fileType(), expand: (!isExpend))
|
|
|
+ itemsList.reloadData()
|
|
|
+ }else {
|
|
|
+ self.setCurrentCellInfo(cellInfo)
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -195,14 +221,25 @@ class ViewController : NSViewController, SettingViewControllerDelegate, AutoTest
|
|
|
|
|
|
// TableView Data Source
|
|
|
func numberOfRows(in tableView: NSTableView) -> Int {
|
|
|
- return testCaseNames.count;
|
|
|
+ var count = testFileTypes.count
|
|
|
+
|
|
|
+ for fileType in testFileTypes {
|
|
|
+ //当前文件类型是否为展开
|
|
|
+ if (DataModel.shared.isExpand(fileType)) {
|
|
|
+ let testTypes = testTypeInfo[fileType] as! NSArray
|
|
|
+
|
|
|
+ count = count + testTypes.count
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return count
|
|
|
}
|
|
|
|
|
|
/* This method is required for the "Cell Based" TableView, and is optional for the "View Based" TableView. If implemented in the latter case, the value will be set to the view at a given row/column if the view responds to -setObjectValue: (such as NSControl and NSTableCellView). Note that NSTableCellView does not actually display the objectValue, and its value is to be used for bindings. See NSTableCellView.h for more information.
|
|
|
*/
|
|
|
- func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? {
|
|
|
- return testCaseNames[row]
|
|
|
- }
|
|
|
+// func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? {
|
|
|
+// return testCaseNames[row]
|
|
|
+// }
|
|
|
|
|
|
|
|
|
// SettingViewConntroller Handle
|
|
@@ -212,17 +249,7 @@ class ViewController : NSViewController, SettingViewControllerDelegate, AutoTest
|
|
|
|
|
|
//AutoTestAdvanceSettingView Delegate
|
|
|
func advanceSettingDidUpdate(_ settingView: NSView?) {
|
|
|
- let selectRow = itemsList.selectedRow
|
|
|
- if selectRow != -1 {
|
|
|
- let cellView = itemsList.view(atColumn: 0, row: selectRow, makeIfNecessary: true) as! TestCaseCellView
|
|
|
-
|
|
|
- let type = testCaseNames[selectRow]
|
|
|
- let autoTestObj = AutoTest.autoTestForType(type as! NSString)
|
|
|
-
|
|
|
- cellView.setAutoTestObj(autoTestObj)
|
|
|
- }else {
|
|
|
- itemsList.reloadData()
|
|
|
- }
|
|
|
+ self.setCurrentCellInfo(_currentCellInfo)
|
|
|
}
|
|
|
|
|
|
}
|