Skip to content

Commit dfef32b

Browse files
committed
Add basic 1.1F2 tests
1 parent 58b9840 commit dfef32b

23 files changed

+1835
-82
lines changed

SVGView.xcodeproj/project.pbxproj

+12-8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
5815298A25B752E600E8D23A /* SVGPreserveAspectRatio.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5815298925B752E600E8D23A /* SVGPreserveAspectRatio.swift */; };
1313
5852D66325BD726A00AD201D /* w3c in Resources */ = {isa = PBXBuildFile; fileRef = 5852D66225BD726A00AD201D /* w3c */; };
1414
5852D67725BD74EF00AD201D /* SVG12Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5852D67625BD74EF00AD201D /* SVG12Tests.swift */; };
15+
585A5C2725CFF2B9000E8B88 /* SVGRefGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 585A5C2625CFF2B9000E8B88 /* SVGRefGenerator.swift */; };
16+
585A5C2F25D007B6000E8B88 /* SVG11Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 585A5C2E25D007B6000E8B88 /* SVG11Tests.swift */; };
17+
585A5C3525D007EA000E8B88 /* BaseTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 585A5C3425D007EA000E8B88 /* BaseTestCase.swift */; };
1518
58869B6D25B5C52D00F6E324 /* Serializer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58869B6C25B5C52D00F6E324 /* Serializer.swift */; };
1619
58869B7525B5EB0B00F6E324 /* Serializable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58869B7425B5EB0B00F6E324 /* Serializable.swift */; };
1720
58869B7925B5EB3300F6E324 /* Serializations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58869B7825B5EB3300F6E324 /* Serializations.swift */; };
@@ -23,8 +26,6 @@
2326
5B10181A2536C64700105E9A /* SVGUserSpaceNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B1018192536C64700105E9A /* SVGUserSpaceNode.swift */; };
2427
5B1F4630251348F70068EF42 /* MBezierPath+Extension_macOS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B1F462F251348F70068EF42 /* MBezierPath+Extension_macOS.swift */; };
2528
5B23AA6B24EA5D5F0085D48E /* SVGGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B23AA6A24EA5D5F0085D48E /* SVGGroup.swift */; };
26-
5B23AA7024EA80250085D48E /* TestCreateUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B23AA6F24EA80250085D48E /* TestCreateUtils.swift */; };
27-
5B23AA7224EA88040085D48E /* CompareUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B23AA7124EA88040085D48E /* CompareUtils.swift */; };
2829
5BE3322724E1446A00BB0D60 /* SVGView.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5BE3321D24E1446A00BB0D60 /* SVGView.framework */; };
2930
5BE3325F24E144B200BB0D60 /* SVGText.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BE3323924E144B200BB0D60 /* SVGText.swift */; };
3031
5BE3326024E144B200BB0D60 /* SVGNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BE3323A24E144B200BB0D60 /* SVGNode.swift */; };
@@ -68,6 +69,9 @@
6869
5815298925B752E600E8D23A /* SVGPreserveAspectRatio.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SVGPreserveAspectRatio.swift; sourceTree = "<group>"; };
6970
5852D66225BD726A00AD201D /* w3c */ = {isa = PBXFileReference; lastKnownFileType = folder; path = w3c; sourceTree = "<group>"; };
7071
5852D67625BD74EF00AD201D /* SVG12Tests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SVG12Tests.swift; sourceTree = "<group>"; };
72+
585A5C2625CFF2B9000E8B88 /* SVGRefGenerator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SVGRefGenerator.swift; sourceTree = "<group>"; };
73+
585A5C2E25D007B6000E8B88 /* SVG11Tests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SVG11Tests.swift; sourceTree = "<group>"; };
74+
585A5C3425D007EA000E8B88 /* BaseTestCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseTestCase.swift; sourceTree = "<group>"; };
7175
58869B6C25B5C52D00F6E324 /* Serializer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Serializer.swift; sourceTree = "<group>"; };
7276
58869B7425B5EB0B00F6E324 /* Serializable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Serializable.swift; sourceTree = "<group>"; };
7377
58869B7825B5EB3300F6E324 /* Serializations.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Serializations.swift; sourceTree = "<group>"; };
@@ -79,8 +83,6 @@
7983
5B1018192536C64700105E9A /* SVGUserSpaceNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SVGUserSpaceNode.swift; sourceTree = "<group>"; };
8084
5B1F462F251348F70068EF42 /* MBezierPath+Extension_macOS.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "MBezierPath+Extension_macOS.swift"; sourceTree = "<group>"; };
8185
5B23AA6A24EA5D5F0085D48E /* SVGGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SVGGroup.swift; sourceTree = "<group>"; };
82-
5B23AA6F24EA80250085D48E /* TestCreateUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestCreateUtils.swift; sourceTree = "<group>"; };
83-
5B23AA7124EA88040085D48E /* CompareUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompareUtils.swift; sourceTree = "<group>"; };
8486
5BE3321D24E1446A00BB0D60 /* SVGView.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SVGView.framework; sourceTree = BUILT_PRODUCTS_DIR; };
8587
5BE3322624E1446A00BB0D60 /* SVGViewTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SVGViewTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
8688
5BE3322D24E1446A00BB0D60 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@@ -162,9 +164,10 @@
162164
isa = PBXGroup;
163165
children = (
164166
5852D66225BD726A00AD201D /* w3c */,
167+
585A5C3425D007EA000E8B88 /* BaseTestCase.swift */,
168+
585A5C2E25D007B6000E8B88 /* SVG11Tests.swift */,
165169
5852D67625BD74EF00AD201D /* SVG12Tests.swift */,
166-
5B23AA6F24EA80250085D48E /* TestCreateUtils.swift */,
167-
5B23AA7124EA88040085D48E /* CompareUtils.swift */,
170+
585A5C2625CFF2B9000E8B88 /* SVGRefGenerator.swift */,
168171
5BE3322D24E1446A00BB0D60 /* Info.plist */,
169172
);
170173
path = SVGViewTests;
@@ -443,9 +446,10 @@
443446
isa = PBXSourcesBuildPhase;
444447
buildActionMask = 2147483647;
445448
files = (
446-
5B23AA7224EA88040085D48E /* CompareUtils.swift in Sources */,
447-
5B23AA7024EA80250085D48E /* TestCreateUtils.swift in Sources */,
449+
585A5C2F25D007B6000E8B88 /* SVG11Tests.swift in Sources */,
450+
585A5C2725CFF2B9000E8B88 /* SVGRefGenerator.swift in Sources */,
448451
5852D67725BD74EF00AD201D /* SVG12Tests.swift in Sources */,
452+
585A5C3525D007EA000E8B88 /* BaseTestCase.swift in Sources */,
449453
5B1F4630251348F70068EF42 /* MBezierPath+Extension_macOS.swift in Sources */,
450454
);
451455
runOnlyForDeploymentPostprocessing = 0;

SVGViewTests/CompareUtils.swift SVGViewTests/BaseTestCase.swift

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
1+
//
2+
// BaseTestCase.swift
3+
// SVGViewTests
4+
//
5+
// Created by Yuriy Strot on 07.02.2021.
6+
//
7+
18
import XCTest
29
@testable import SVGView
310

4-
extension SVG12Tests {
11+
class BaseTestCase : XCTestCase {
12+
13+
var dir: String {
14+
return "1.2T"
15+
}
516

617
func compareToReference(_ fileName: String) {
718
let bundle = Bundle(for: type(of: self))
8-
let svgURL = bundle.url(forResource: fileName, withExtension: "svg", subdirectory: "w3c/1.2T/svg/")!
9-
let refURL = bundle.url(forResource: fileName, withExtension: "ref", subdirectory: "w3c/1.2T/refs/")!
19+
let svgURL = bundle.url(forResource: fileName, withExtension: "svg", subdirectory: "w3c/\(dir)/svg/")!
20+
let refURL = bundle.url(forResource: fileName, withExtension: "ref", subdirectory: "w3c/\(dir)/refs/")!
1021

1122
print(svgURL)
1223
let node = SVGParser.parse(fileURL: svgURL)
@@ -77,7 +88,6 @@ fileprivate func prettyFirstDifferenceBetweenNSStrings(s1: NSString, s2: NSStrin
7788
return prettyDescriptionOfFirstDifferenceResult(firstDifferenceResult: firstDifferenceResult, s1: s1, s2: s2)
7889
}
7990

80-
8191
/// Create a formatted String representation of a FirstDifferenceResult for two strings
8292
///
8393
/// :param: firstDifferenceResult FirstDifferenceResult

SVGViewTests/SVG11Tests.swift

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Generated by script-test-cases.sh
2+
3+
import XCTest
4+
@testable import SVGView
5+
6+
class SVG11Tests: BaseTestCase {
7+
8+
override var dir: String {
9+
return "1.1F2"
10+
}
11+
12+
func testColorProp02F() {
13+
compareToReference("color-prop-02-f")
14+
}
15+
16+
func testColorProp03T() {
17+
compareToReference("color-prop-03-t")
18+
}
19+
20+
func testCoordsCoord01T() {
21+
compareToReference("coords-coord-01-t")
22+
}
23+
24+
func testCoordsTrans01B() {
25+
compareToReference("coords-trans-01-b")
26+
}
27+
28+
func testCoordsTrans02T() {
29+
compareToReference("coords-trans-02-t")
30+
}
31+
32+
func testCoordsTrans03T() {
33+
compareToReference("coords-trans-03-t")
34+
}
35+
36+
func testCoordsTrans04T() {
37+
compareToReference("coords-trans-04-t")
38+
}
39+
40+
func testCoordsTrans05T() {
41+
compareToReference("coords-trans-05-t")
42+
}
43+
44+
func testCoordsTrans06T() {
45+
compareToReference("coords-trans-06-t")
46+
}
47+
48+
func testCoordsTrans07T() {
49+
compareToReference("coords-trans-07-t")
50+
}
51+
52+
func testCoordsTrans08T() {
53+
compareToReference("coords-trans-08-t")
54+
}
55+
56+
func testCoordsTrans09T() {
57+
compareToReference("coords-trans-09-t")
58+
}
59+
60+
}

SVGViewTests/SVG12Tests.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
import XCTest
44
@testable import SVGView
55

6-
class SVG12Tests: XCTestCase {
6+
class SVG12Tests: BaseTestCase {
77

8-
let testFolderName = "TestOutputData"
8+
override var dir: String {
9+
return "1.2T"
10+
}
911

1012
func testCoordsTrans01T() {
1113
compareToReference("coords-trans-01-t")

SVGViewTests/TestCreateUtils.swift SVGViewTests/SVGRefGenerator.swift

+31-13
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,41 @@
1+
//
2+
// SVGRefGenerator.swift
3+
// SVGViewTests
4+
//
5+
// Created by Yuriy Strot on 07.02.2021.
6+
//
7+
18
import XCTest
29
@testable import SVGView
310

4-
extension SVG12Tests {
11+
class SVGRefGenerator: XCTestCase {
12+
13+
let testFolderName = "TestOutputData"
14+
let v11 = "w3c/1.1F2/svg/"
15+
let v12 = "w3c/1.2T/svg/"
516

6-
// uncomment to recreate all references
7-
// func testCreateReferences() {
8-
// let path = Bundle(for: type(of: self)).resourcePath!
9-
// for url in getContents(path) {
10-
// if url.pathExtension == "svg" {
11-
// createReference(url)
12-
// }
13-
// }
14-
// }
17+
func testCreateReferences() {
18+
createReference(name: "color-prop-02-f", version: v11)
19+
createReference(name: "color-prop-03-t", version: v11)
20+
createReference(name: "coords-coord-01-t", version: v11)
21+
createReference(name: "coords-trans-01-b", version: v11)
22+
createReference(name: "coords-trans-02-t", version: v11)
23+
createReference(name: "coords-trans-03-t", version: v11)
24+
createReference(name: "coords-trans-04-t", version: v11)
25+
createReference(name: "coords-trans-05-t", version: v11)
26+
createReference(name: "coords-trans-06-t", version: v11)
27+
createReference(name: "coords-trans-07-t", version: v11)
28+
createReference(name: "coords-trans-08-t", version: v11)
29+
createReference(name: "coords-trans-09-t", version: v11)
30+
}
1531

16-
func createReference(_ testResource: URL) {
32+
func createReference(name: String, version: String) {
33+
let bundle = Bundle(for: type(of: self))
34+
let url = bundle.url(forResource: name, withExtension: "svg", subdirectory: version)!
1735
let testDirectory = getTestDir()
18-
let node = SVGParser.parse(fileURL: testResource)
36+
let node = SVGParser.parse(fileURL: url)
1937
let content = Serializer.serialize(node)
20-
let fileName = testResource.deletingPathExtension().lastPathComponent
38+
let fileName = url.deletingPathExtension().lastPathComponent
2139
let path = testDirectory.appendingPathComponent(fileName).appendingPathExtension("ref")
2240
writeToFile(content: content, fileURL: path)
2341
print("New reference file in \(path)")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
SVGViewport {
2+
id: "svg-root",
3+
viewBox: { width: 480, height: 360 },
4+
contents: [
5+
SVGGroup {
6+
id: "test-body-content",
7+
contents: [
8+
SVGGroup {
9+
contents: [
10+
SVGCircle { cx: 75, cy: 40, r: 20, fill: "crimson" },
11+
SVGCircle { cx: 115, cy: 40, r: 20, fill: "crimson" },
12+
SVGCircle { cx: 75, cy: 80, r: 20, fill: "crimson" },
13+
SVGCircle { cx: 115, cy: 80, r: 20, fill: "crimson" }
14+
]
15+
},
16+
SVGGroup {
17+
contents: [
18+
SVGCircle { cx: 200, cy: 40, r: 20, fill: "palegreen" },
19+
SVGCircle { cx: 240, cy: 40, r: 20, fill: "palegreen" },
20+
SVGCircle { cx: 200, cy: 80, r: 20, fill: "palegreen" },
21+
SVGCircle { cx: 240, cy: 80, r: 20, fill: "palegreen" }
22+
]
23+
},
24+
SVGGroup {
25+
contents: [
26+
SVGCircle { cx: 325, cy: 40, r: 20, fill: "royalblue" },
27+
SVGCircle { cx: 365, cy: 40, r: 20, fill: "royalblue" },
28+
SVGCircle { cx: 325, cy: 80, r: 20, fill: "royalblue" },
29+
SVGCircle { cx: 365, cy: 80, r: 20, fill: "royalblue" }
30+
]
31+
},
32+
SVGGroup {
33+
contents: [
34+
SVGCircle { cx: 75, cy: 135, r: 20, fill: "firebrick" },
35+
SVGCircle { cx: 115, cy: 135, r: 20, fill: "firebrick" },
36+
SVGCircle { cx: 75, cy: 175, r: 20, fill: "firebrick" },
37+
SVGCircle { cx: 115, cy: 175, r: 20, fill: "firebrick" }
38+
]
39+
},
40+
SVGGroup {
41+
contents: [
42+
SVGCircle { cx: 200, cy: 135, r: 20, fill: "seagreen" },
43+
SVGCircle { cx: 240, cy: 135, r: 20, fill: "seagreen" },
44+
SVGCircle { cx: 200, cy: 175, r: 20, fill: "seagreen" },
45+
SVGCircle { cx: 240, cy: 175, r: 20, fill: "seagreen" }
46+
]
47+
},
48+
SVGGroup {
49+
contents: [
50+
SVGCircle { cx: 325, cy: 135, r: 20, fill: "mediumblue" },
51+
SVGCircle { cx: 365, cy: 135, r: 20, fill: "mediumblue" },
52+
SVGCircle { cx: 325, cy: 175, r: 20, fill: "mediumblue" },
53+
SVGCircle { cx: 365, cy: 175, r: 20, fill: "mediumblue" }
54+
]
55+
},
56+
SVGGroup {
57+
contents: [
58+
SVGCircle { cx: 75, cy: 230, r: 20, fill: "indianred" },
59+
SVGCircle { cx: 115, cy: 230, r: 20, fill: "indianred" },
60+
SVGCircle { cx: 75, cy: 270, r: 20, fill: "indianred" },
61+
SVGCircle { cx: 115, cy: 270, r: 20, fill: "indianred" }
62+
]
63+
},
64+
SVGGroup {
65+
contents: [
66+
SVGCircle { cx: 200, cy: 230, r: 20, fill: "lawngreen" },
67+
SVGCircle { cx: 240, cy: 230, r: 20, fill: "lawngreen" },
68+
SVGCircle { cx: 200, cy: 270, r: 20, fill: "lawngreen" },
69+
SVGCircle { cx: 240, cy: 270, r: 20, fill: "lawngreen" }
70+
]
71+
},
72+
SVGGroup {
73+
contents: [
74+
SVGCircle { cx: 325, cy: 230, r: 20, fill: "mediumturquoise" },
75+
SVGCircle { cx: 365, cy: 230, r: 20, fill: "mediumturquoise" },
76+
SVGCircle { cx: 325, cy: 270, r: 20, fill: "mediumturquoise" },
77+
SVGCircle { cx: 365, cy: 270, r: 20, fill: "mediumturquoise" }
78+
]
79+
}
80+
]
81+
},
82+
SVGGroup {
83+
contents: [
84+
SVGText {
85+
id: "revision",
86+
text: "$Revision: 1.9 $",
87+
font: { name: "SVGFreeSansASCII,sans-serif", size: 32 },
88+
fill: "black",
89+
transform: [1, 0, 0, 1, 10, 340]
90+
}
91+
]
92+
},
93+
SVGRect {
94+
id: "test-frame",
95+
x: 1,
96+
y: 1,
97+
width: 478,
98+
height: 358,
99+
stroke: { fill: "black" }
100+
}
101+
]
102+
}

0 commit comments

Comments
 (0)