Skip to content

Commit 249e404

Browse files
authored
Merge pull request #600 from exyte/test/587-Make-tests-for-OSX
#587 Make all iOS tests work on OSX as well
2 parents 42ca598 + 501e9c5 commit 249e404

13 files changed

+81
-51
lines changed

MacawTests/Animation/AnimationUtilsTests.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77
//
88

99
import XCTest
10+
1011
#if os(OSX)
1112
@testable import MacawOSX
12-
#endif
13-
14-
#if os(iOS)
13+
#elseif os(iOS)
1514
@testable import Macaw
1615
#endif
1716

MacawTests/Animation/CombineAnimationTests.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,27 @@
66
// Copyright © 2017 Exyte. All rights reserved.
77
//
88

9-
#if os(iOS)
10-
119
import XCTest
10+
11+
#if os(OSX)
12+
@testable import MacawOSX
13+
#elseif os(iOS)
1214
@testable import Macaw
15+
#endif
1316

1417
class CombineAnimationTests: XCTestCase {
1518

1619
var testView: MacawView!
1720
var testGroup: Group!
18-
var window: UIWindow!
21+
var window: MWindow!
1922

2023
override func setUp() {
2124
super.setUp()
2225

2326
testGroup = [Shape(form:Rect(x: 0.0, y: 0.0, w: 0.0, h: 0.0))].group()
24-
testView = MacawView(node: testGroup, frame: CGRect.zero)
27+
testView = MacawView(node: testGroup, frame: .zero)
2528

26-
window = UIWindow()
29+
window = MWindow()
2730
window.addSubview(testView)
2831
}
2932

@@ -98,5 +101,3 @@ class CombineAnimationTests: XCTestCase {
98101
}
99102

100103
}
101-
102-
#endif

MacawTests/Animation/ControlStatesTests.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ import XCTest
1010

1111
#if os(OSX)
1212
@testable import MacawOSX
13-
#endif
14-
15-
#if os(iOS)
13+
#elseif os(iOS)
1614
@testable import Macaw
1715
#endif
1816

MacawTests/Animation/DelayedAnimationTests.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,27 @@
66
// Copyright © 2017 Exyte. All rights reserved.
77
//
88

9-
#if os(iOS)
10-
119
import XCTest
10+
11+
#if os(OSX)
12+
@testable import MacawOSX
13+
#elseif os(iOS)
1214
@testable import Macaw
15+
#endif
1316

1417
class DelayedAnimationTests: XCTestCase {
1518

16-
1719
var testView: MacawView!
1820
var testGroup: Group!
19-
var window: UIWindow!
21+
var window: MWindow!
2022

2123
override func setUp() {
2224
super.setUp()
2325

2426
testGroup = [Shape(form:Rect(x: 0.0, y: 0.0, w: 0.0, h: 0.0))].group()
25-
testView = MacawView(node: testGroup, frame: CGRect.zero)
27+
testView = MacawView(node: testGroup, frame: .zero)
2628

27-
window = UIWindow()
29+
window = MWindow()
2830
window.addSubview(testView)
2931
}
3032

@@ -54,5 +56,3 @@ class DelayedAnimationTests: XCTestCase {
5456
XCTAssert(animation.paused && !animation.manualStop, "Wrong animation state on pause")
5557
}
5658
}
57-
58-
#endif

MacawTests/Animation/SequenceAnimationTests.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,27 @@
66
// Copyright © 2017 Exyte. All rights reserved.
77
//
88

9-
#if os(iOS)
10-
119
import XCTest
10+
11+
#if os(OSX)
12+
@testable import MacawOSX
13+
#elseif os(iOS)
1214
@testable import Macaw
15+
#endif
1316

1417
class SequenceAnimationTests: XCTestCase {
1518

1619
var testView: MacawView!
1720
var testGroup: Group!
18-
var window: UIWindow!
21+
var window: MWindow!
1922

2023
override func setUp() {
2124
super.setUp()
2225

2326
testGroup = [Shape(form:Rect(x: 0.0, y: 0.0, w: 0.0, h: 0.0))].group()
24-
testView = MacawView(node: testGroup, frame: CGRect.zero)
27+
testView = MacawView(node: testGroup, frame: .zero)
2528

26-
window = UIWindow()
29+
window = MWindow()
2730
window.addSubview(testView)
2831
}
2932

@@ -78,5 +81,3 @@ class SequenceAnimationTests: XCTestCase {
7881
}
7982

8083
}
81-
82-
#endif

MacawTests/Bounds/ImageBoundsTests.swift

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
// Copyright © 2017 Exyte. All rights reserved.
77
//
88

9-
#if os(iOS)
10-
119
import XCTest
10+
11+
#if os(OSX)
12+
@testable import MacawOSX
13+
#elseif os(iOS)
1214
@testable import Macaw
15+
#endif
1316

1417
class ImageBoundsTests: XCTestCase {
1518

@@ -26,7 +29,11 @@ class ImageBoundsTests: XCTestCase {
2629
return
2730
}
2831

29-
XCTAssert(bounds.w == 1174.0 && bounds.h == 862.0, "Wrong bounds for path src")
32+
#if os(iOS)
33+
XCTAssert(bounds.w == 1174.0 && bounds.h == 862.0, "Wrong bounds for path src")
34+
#elseif os(OSX)
35+
XCTAssert(bounds.w == 587.0 && bounds.h == 431.0, "Wrong bounds for path src")
36+
#endif
3037
}
3138

3239
func testSrcAsBase64() {
@@ -36,7 +43,6 @@ class ImageBoundsTests: XCTestCase {
3643
return
3744
}
3845

39-
4046
let url = URL(fileURLWithPath: path)
4147
guard let base64Content = try? String(contentsOf: url) else {
4248
XCTFail()
@@ -49,25 +55,40 @@ class ImageBoundsTests: XCTestCase {
4955
return
5056
}
5157

52-
XCTAssert(bounds.w == 1174.0 && bounds.h == 862.0, "Wrong bounds for base64 src")
58+
#if os(iOS)
59+
XCTAssert(bounds.w == 1174.0 && bounds.h == 862.0, "Wrong bounds for base64 src")
60+
#elseif os(OSX)
61+
XCTAssert(bounds.w == 587.0 && bounds.h == 431.0, "Wrong bounds for base64 src")
62+
#endif
5363
}
5464

5565
func testInMemoryImage() {
5666
let bundle = Bundle(for: type(of: TestUtils()))
67+
68+
#if os(iOS)
5769
guard let mImage = MImage(named: "logo.png", in: bundle, compatibleWith: .none) else {
5870
XCTFail()
5971
return
6072
}
6173

74+
#elseif os(OSX)
75+
guard let mImage = bundle.image(forResource: "logo.png") else {
76+
XCTFail()
77+
return
78+
}
79+
#endif
80+
6281
let image = Image(image: mImage)
6382
guard let bounds = image.bounds else {
6483
XCTFail("Bounds not available")
6584
return
6685
}
6786

68-
XCTAssert(bounds.w == 1174.0 && bounds.h == 862.0, "Wrong bounds for in-memory image")
87+
#if os(iOS)
88+
XCTAssert(bounds.w == 1174.0 && bounds.h == 862.0, "Wrong bounds for in-memory image")
89+
#elseif os(OSX)
90+
XCTAssert(bounds.w == 587.0 && bounds.h == 431.0, "Wrong bounds for in-memory image")
91+
#endif
6992
}
7093

7194
}
72-
73-
#endif

MacawTests/Bounds/NodeBoundsTests.swift

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,24 @@
66
// Copyright © 2017 Exyte. All rights reserved.
77
//
88

9-
#if os(iOS)
10-
119
import XCTest
10+
11+
#if os(OSX)
12+
@testable import MacawOSX
13+
#elseif os(iOS)
1214
@testable import Macaw
15+
#endif
1316

1417
class NodeBoundsTests: XCTestCase {
15-
var window: UIWindow!
18+
var window: MWindow!
1619

1720
//TO DO: need to test paths bounds: M 50 50 C 20 20, 40 20, 50 10 and M 50 50 c 20 20, 40 20, 50 10
1821
//currently doesn't work because of http://www.openradar.me/6468254639 or #41355347 on https://bugreport.apple.com/
1922

2023
override func setUp() {
2124
super.setUp()
2225

23-
window = UIWindow()
26+
window = MWindow()
2427
}
2528

2629
override func tearDown() {
@@ -317,5 +320,3 @@ class NodeBoundsTests: XCTestCase {
317320
validate(node: shape, referenceBounds: targetRect)
318321
}
319322
}
320-
321-
#endif

MacawTests/MacawSVGTests.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import XCTest
22

33
#if os(OSX)
44
@testable import MacawOSX
5-
#endif
6-
7-
#if os(iOS)
5+
#elseif os(iOS)
86
@testable import Macaw
97
#endif
108

MacawTests/MacawTests.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import XCTest
2+
23
#if os(OSX)
34
@testable import MacawOSX
4-
#endif
5-
6-
#if os(iOS)
5+
#elseif os(iOS)
76
@testable import Macaw
87
#endif
98

MacawTests/SVGParserTest.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77
//
88

99
import XCTest
10+
1011
#if os(OSX)
1112
@testable import MacawOSX
12-
#endif
13-
14-
#if os(iOS)
13+
#elseif os(iOS)
1514
@testable import Macaw
1615
#endif
1716

0 commit comments

Comments
 (0)