From feb96db0076381846f0f3e68e4f177fd9882c501 Mon Sep 17 00:00:00 2001 From: Alexandra Novikova Date: Fri, 10 Jun 2016 15:32:10 +0200 Subject: [PATCH] tests infrastructure --- Macaw.xcodeproj/project.pbxproj | 144 ++++++++++++++++++++++++++++++++ MacawTests/Info.plist | 24 ++++++ MacawTests/MacawTests.swift | 54 ++++++++++++ MacawTests/triangle.svg | 7 ++ 4 files changed, 229 insertions(+) create mode 100644 MacawTests/Info.plist create mode 100644 MacawTests/MacawTests.swift create mode 100644 MacawTests/triangle.svg diff --git a/Macaw.xcodeproj/project.pbxproj b/Macaw.xcodeproj/project.pbxproj index a125b9a1..8ed91183 100644 --- a/Macaw.xcodeproj/project.pbxproj +++ b/Macaw.xcodeproj/project.pbxproj @@ -79,8 +79,22 @@ B03276231C78882A000BDD33 /* ImageRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = B03276221C78882A000BDD33 /* ImageRenderer.swift */; }; B03276271C789217000BDD33 /* RenderContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = B03276261C789217000BDD33 /* RenderContext.swift */; }; B03F88BE1C1C6A9E00F24FFC /* Signal.swift in Sources */ = {isa = PBXBuildFile; fileRef = B03F88BD1C1C6A9E00F24FFC /* Signal.swift */; }; + C11A9F3E1D0724700028B402 /* triangle.svg in Resources */ = {isa = PBXBuildFile; fileRef = C11A9F3D1D0724700028B402 /* triangle.svg */; }; + C1F9650A1D06F82B00C03BB5 /* MacawTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1F965091D06F82B00C03BB5 /* MacawTests.swift */; }; + C1F9650C1D06F82B00C03BB5 /* Macaw.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B02E75D61C160F8D00D1971D /* Macaw.framework */; }; + C1F965131D07012300C03BB5 /* Pods_Macaw.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C1F965121D07012300C03BB5 /* Pods_Macaw.framework */; }; /* End PBXBuildFile section */ +/* Begin PBXContainerItemProxy section */ + C1F9650D1D06F82B00C03BB5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = B02E75CD1C160F8D00D1971D /* Project object */; + proxyType = 1; + remoteGlobalIDString = B02E75D51C160F8D00D1971D; + remoteInfo = Macaw; + }; +/* End PBXContainerItemProxy section */ + /* Begin PBXFileReference section */ 0D10CB2117557903E2D9F24D /* Pods-Macaw.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Macaw.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Macaw/Pods-Macaw.debug.xcconfig"; sourceTree = ""; }; 5742238F1CA5448C001EE463 /* Animation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Animation.swift; sourceTree = ""; }; @@ -158,6 +172,12 @@ B03276261C789217000BDD33 /* RenderContext.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RenderContext.swift; sourceTree = ""; }; B03F88BD1C1C6A9E00F24FFC /* Signal.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Signal.swift; sourceTree = ""; }; BA114AD1025D7DA0B0DC35A8 /* Pods_Macaw.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Macaw.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + C11A9F3D1D0724700028B402 /* triangle.svg */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = triangle.svg; sourceTree = ""; }; + C1F965071D06F82B00C03BB5 /* MacawTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MacawTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + C1F965091D06F82B00C03BB5 /* MacawTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MacawTests.swift; sourceTree = ""; }; + C1F9650B1D06F82B00C03BB5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + C1F965121D07012300C03BB5 /* Pods_Macaw.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Pods_Macaw.framework; path = "Pods/../build/Debug-iphoneos/Pods_Macaw.framework"; sourceTree = ""; }; + C1FD30DB1D06EEDF00ED9A91 /* RxSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RxSwift.framework; path = "../../Library/Developer/Xcode/DerivedData/Macaw-fuqawvveoioyskgwaknphywvhrwf/Build/Products/Debug-iphonesimulator/RxSwift.framework"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -169,6 +189,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + C1F965041D06F82B00C03BB5 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + C1F965131D07012300C03BB5 /* Pods_Macaw.framework in Frameworks */, + C1F9650C1D06F82B00C03BB5 /* Macaw.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -261,6 +290,7 @@ isa = PBXGroup; children = ( B02E75E11C160FF200D1971D /* Source */, + C1F965081D06F82B00C03BB5 /* MacawTests */, B02E75D71C160F8D00D1971D /* Products */, 549363F57810A86F4226A525 /* Pods */, DB1EC634C50C9231DFC4041E /* Frameworks */, @@ -271,6 +301,7 @@ isa = PBXGroup; children = ( B02E75D61C160F8D00D1971D /* Macaw.framework */, + C1F965071D06F82B00C03BB5 /* MacawTests.xctest */, ); name = Products; sourceTree = ""; @@ -398,9 +429,29 @@ path = events; sourceTree = ""; }; + C11A9F401D072C510028B402 /* SVG */ = { + isa = PBXGroup; + children = ( + C11A9F3D1D0724700028B402 /* triangle.svg */, + ); + name = SVG; + sourceTree = ""; + }; + C1F965081D06F82B00C03BB5 /* MacawTests */ = { + isa = PBXGroup; + children = ( + C11A9F401D072C510028B402 /* SVG */, + C1F965091D06F82B00C03BB5 /* MacawTests.swift */, + C1F9650B1D06F82B00C03BB5 /* Info.plist */, + ); + path = MacawTests; + sourceTree = ""; + }; DB1EC634C50C9231DFC4041E /* Frameworks */ = { isa = PBXGroup; children = ( + C1F965121D07012300C03BB5 /* Pods_Macaw.framework */, + C1FD30DB1D06EEDF00ED9A91 /* RxSwift.framework */, BA114AD1025D7DA0B0DC35A8 /* Pods_Macaw.framework */, ); name = Frameworks; @@ -439,18 +490,40 @@ productReference = B02E75D61C160F8D00D1971D /* Macaw.framework */; productType = "com.apple.product-type.framework"; }; + C1F965061D06F82B00C03BB5 /* MacawTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = C1F9650F1D06F82B00C03BB5 /* Build configuration list for PBXNativeTarget "MacawTests" */; + buildPhases = ( + C1F965031D06F82B00C03BB5 /* Sources */, + C1F965041D06F82B00C03BB5 /* Frameworks */, + C1F965051D06F82B00C03BB5 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + C1F9650E1D06F82B00C03BB5 /* PBXTargetDependency */, + ); + name = MacawTests; + productName = MacawTests; + productReference = C1F965071D06F82B00C03BB5 /* MacawTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ B02E75CD1C160F8D00D1971D /* Project object */ = { isa = PBXProject; attributes = { + LastSwiftUpdateCheck = 0730; LastUpgradeCheck = 0710; ORGANIZATIONNAME = Exyte; TargetAttributes = { B02E75D51C160F8D00D1971D = { CreatedOnToolsVersion = 7.1.1; }; + C1F965061D06F82B00C03BB5 = { + CreatedOnToolsVersion = 7.3; + }; }; }; buildConfigurationList = B02E75D01C160F8D00D1971D /* Build configuration list for PBXProject "Macaw" */; @@ -466,6 +539,7 @@ projectRoot = ""; targets = ( B02E75D51C160F8D00D1971D /* Macaw */, + C1F965061D06F82B00C03BB5 /* MacawTests */, ); }; /* End PBXProject section */ @@ -478,6 +552,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + C1F965051D06F82B00C03BB5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C11A9F3E1D0724700028B402 /* triangle.svg in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ @@ -592,8 +674,24 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + C1F965031D06F82B00C03BB5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C1F9650A1D06F82B00C03BB5 /* MacawTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXTargetDependency section */ + C1F9650E1D06F82B00C03BB5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = B02E75D51C160F8D00D1971D /* Macaw */; + targetProxy = C1F9650D1D06F82B00C03BB5 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + /* Begin XCBuildConfiguration section */ B02E75DC1C160F8D00D1971D /* Debug */ = { isa = XCBuildConfiguration; @@ -616,6 +714,7 @@ COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = dwarf; + DEFINES_MODULE = YES; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; @@ -664,6 +763,7 @@ COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; @@ -722,6 +822,41 @@ }; name = Release; }; + C1F965101D06F82B00C03BB5 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 0D10CB2117557903E2D9F24D /* Pods-Macaw.debug.xcconfig */; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/build/Debug-iphoneos", + ); + INFOPLIST_FILE = MacawTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.3; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = exyte.MacawTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = ""; + }; + name = Debug; + }; + C1F965111D06F82B00C03BB5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/build/Debug-iphoneos", + ); + INFOPLIST_FILE = MacawTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.3; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = exyte.MacawTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = ""; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -743,6 +878,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + C1F9650F1D06F82B00C03BB5 /* Build configuration list for PBXNativeTarget "MacawTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C1F965101D06F82B00C03BB5 /* Debug */, + C1F965111D06F82B00C03BB5 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ }; rootObject = B02E75CD1C160F8D00D1971D /* Project object */; diff --git a/MacawTests/Info.plist b/MacawTests/Info.plist new file mode 100644 index 00000000..ba72822e --- /dev/null +++ b/MacawTests/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/MacawTests/MacawTests.swift b/MacawTests/MacawTests.swift new file mode 100644 index 00000000..98d4ec30 --- /dev/null +++ b/MacawTests/MacawTests.swift @@ -0,0 +1,54 @@ +import XCTest +@testable import Macaw + +class MacawTests: XCTestCase { + + override func setUp() { + super.setUp() + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDown() { + // Put teardown code here. This method is called after the invocation of each test method in the class. + super.tearDown() + } + + func testSVGTriangle() { + compareWithEtalonObject("triangle", referenceObject: createTriangleReferenceObject()) + } + + func compareWithEtalonObject(fileName: String, referenceObject: AnyObject) -> Bool { + let bundle = NSBundle(forClass: self.dynamicType) + let path = bundle.pathForResource(fileName, ofType: "svg") + if let _ = path { + let content = try? NSString(contentsOfFile: path!, encoding: NSUTF8StringEncoding) + if let svgString = content as? String { + let parser = SVGParser(svgString) + let group = parser.parse() + let referenceArray = prepareParametersList(Mirror(reflecting: referenceObject)) + let parametersArray = prepareParametersList(Mirror(reflecting: group)) + return referenceArray.elementsEqual(parametersArray, isEquivalent: { first, second in + return first.0 == second.0 && first.1 == second.1 + }) + } + } + return false + } + + func prepareParametersList(mirror: Mirror) -> [(String, String)] { + var result:[(String, String)] = [] + for (_, attribute) in mirror.children.enumerate() { + if let label = attribute.label where label == "_value" || label.characters.first != "_" { + result.append((label, String(attribute.value))) + result.appendContentsOf(prepareParametersList(Mirror(reflecting: attribute.value))) + } + } + return result + } + + func createTriangleReferenceObject() -> Group { + let path = Path(segments: [Move(x: 150, y: 0), PLine(x: 75, y: 200), PLine(x: 225, y: 200), Close()]) + return Group(contents: [Shape(form: path)]) + } + +} diff --git a/MacawTests/triangle.svg b/MacawTests/triangle.svg new file mode 100644 index 00000000..b873826a --- /dev/null +++ b/MacawTests/triangle.svg @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file