123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- //
- // AutoTest.swift
- // KdanAuto
- //
- // Created by 朱东勇 on 2022/11/25.
- //
- import Foundation
- import AppKit
- let testCaseNames = [
- "PDFConvert_Font_Auto_Test",
- "PDFConvert_Color_Auto_Test",
- "PDFConvert_China_Auto_Test",
- "PDFConvert_SpecialCharacter_Auto_Test"
- ]
- class AutoTest : NSObject, AutoTestProtocal {
- var reportString : NSAttributedString? = nil
-
- class func autoTestForType(_ type:NSString) -> AutoTest? {
-
- if type.isEqual(to: "PDFConvert_Font_Auto_Test") {
- return FontAutoTest.shared()
- }else if type.isEqual(to: "PDFConvert_China_Auto_Test") {
- return ChineseStringAutoTest.shared()
- }else if type.isEqual(to: "PDFConvert_Color_Auto_Test") {
- return TextColorAutoTest.shared()
- }else if type.isEqual(to: "PDFConvert_SpecialCharacter_Auto_Test") {
- return SpecialCharacterAutoTest.shared()
- }
-
- return nil
- }
-
- static var sharedInstance = AutoTest()
- class func shared() -> AutoTest? {
- return sharedInstance
- }
-
- func type() -> String {
- return "Base_Auto_Test"
- }
-
- func name() -> String {
- return "基础测试基类"
- }
-
-
- func keys() -> NSArray {
- return []
- }
-
- func selectedKeys() -> NSArray {
- let userDefaults = UserDefaults.standard
-
- let key = self.type() + ".selectedKeys"
-
- if userDefaults.value(forKey: key) != nil {
- return userDefaults.value(forKey: key) as! NSArray
- }
-
- self.setSelectedKeys(self.keys())
-
- return self.keys()
- }
-
- func setSelectedKeys(_ keys: NSArray) {
- let userDefaults = UserDefaults.standard
-
- let key = self.type() + ".selectedKeys"
-
- userDefaults.setValue(keys, forKey: key)
- userDefaults.synchronize()
- }
-
-
- // Auto Test
- func autoTest() {
-
- }
-
- func autoCheck() {
-
- }
-
-
- func testReport() -> NSAttributedString? {
- return reportString
- }
-
- /// Path
- func originFilePath() -> String {
- return DataModel.shared.originPath().appendingFormat("/\(self.type()).pdf")
- }
-
- func resultFilePath() -> String {
- return DataModel.shared.resultPath().appendingFormat("/\(self.type()).rtf")
- }
-
- func checkFilePath() -> String {
- return DataModel.shared.checkPath().appendingFormat("/\(self.type()).rtf")
- }
-
- // check File Exist
- func isOriginFileExist() -> Bool {
- if nil != self.originFilePath() {
- return FileManager.default.fileExists(atPath: self.originFilePath())
- }
-
- return false
- }
-
- func isResultFileExist() -> Bool {
- if nil != self.resultFilePath() {
- return FileManager.default.fileExists(atPath: self.resultFilePath())
- }
-
- return false
- }
-
- func isCheckFileExist() -> Bool {
- if nil != self.checkFilePath() {
- return FileManager.default.fileExists(atPath: self.checkFilePath())
- }
-
- return false
- }
- }
|