diff --git a/Tests/LayoutTests/LayoutExampleTests.swift b/Tests/LayoutTests/LayoutExampleTests.swift index 41d2a1c5..7d2eda62 100644 --- a/Tests/LayoutTests/LayoutExampleTests.swift +++ b/Tests/LayoutTests/LayoutExampleTests.swift @@ -86,7 +86,7 @@ final class LayoutExampleTests: XCTestCase { // GIVEN - let subview: UIView = pinkView + let subview: UIView = .pink() // THEN @@ -100,8 +100,8 @@ final class LayoutExampleTests: XCTestCase { // GIVEN - let subview1: UIView = pinkView - let subview2: UIView = blueView + let subview1: UIView = .pink() + let subview2: UIView = .blue() // THEN @@ -122,7 +122,7 @@ final class LayoutExampleTests: XCTestCase { // GIVEN - let siblingView: UIView = pinkView + let siblingView: UIView = .pink() let label: UILabel = { let label: UILabel = .init() @@ -150,7 +150,7 @@ final class LayoutExampleTests: XCTestCase { // GIVEN - let siblingView: UIView = pinkView + let siblingView: UIView = .pink() let label: UILabel = { let label: UILabel = .init() @@ -180,7 +180,7 @@ final class LayoutExampleTests: XCTestCase { // GIVEN - let subview: UIView = blueView + let subview: UIView = .blue() // THEN @@ -195,7 +195,7 @@ final class LayoutExampleTests: XCTestCase { // GIVEN - let subview1: UIView = orangeView + let subview1: UIView = .orange() let subview2: UIImageView = .init(image: .checkmark) // THEN @@ -212,7 +212,7 @@ final class LayoutExampleTests: XCTestCase { // GIVEN - let siblingView: UIView = pinkView + let siblingView: UIView = .pink() let label: UILabel = { let label: UILabel = .init() @@ -240,7 +240,7 @@ final class LayoutExampleTests: XCTestCase { // GIVEN - let siblingView: UIView = pinkView + let siblingView: UIView = .pink() let label: UILabel = { let label: UILabel = .init() diff --git a/Tests/LayoutTests/LayoutItemTests.swift b/Tests/LayoutTests/LayoutItemTests.swift index 4aee9a67..332a7634 100644 --- a/Tests/LayoutTests/LayoutItemTests.swift +++ b/Tests/LayoutTests/LayoutItemTests.swift @@ -69,14 +69,14 @@ final class LayoutItemTests: XCTestCase { // Size CGSize with Default Priority - pinkView + UIView.pink() .to([.top, .leading]) .size(CGSize(width: 150, height: 250), priority: .high) .size(CGSize(width: 100, height: 200)) // Size CGSize with Priority - yellowView + UIView.yellow() .to([.top, .trailing]) .size(CGSize(width: 50, height: 50), priority: .low) .size(CGSize(width: 100, height: 200), priority: .high) @@ -92,14 +92,14 @@ final class LayoutItemTests: XCTestCase { // Size Width and Height with Default Priority - pinkView + UIView.pink() .to([.top, .leading]) .size(width: 150, height: 250, priority: .high) .size(width: 100, height: 200) // Size Width and Height with Priority - yellowView + UIView.yellow() .to([.top, .trailing]) .size(width: 50, height: 50, priority: .low) .size(width: 100, height: 200, priority: .high) @@ -121,7 +121,7 @@ final class LayoutItemTests: XCTestCase { // Size Width with Relation and Default Priority - pinkView + UIView.pink() .to([.top, .leading]) .height(100) .width(is: .greaterThanOrEqual, to: 100, priority: .high) @@ -129,7 +129,7 @@ final class LayoutItemTests: XCTestCase { // Size Width with Priority - yellowView + UIView.yellow() .to([.top, .trailing]) .height(100) .width(1, priority: .low) @@ -137,7 +137,7 @@ final class LayoutItemTests: XCTestCase { // Size Width with GreaterThanOrEqual Relation and Priority - blueView + UIView.blue() .to([.bottom, .leading]) .height(100) .width(is: .equal, to: 40, priority: .high) @@ -145,7 +145,7 @@ final class LayoutItemTests: XCTestCase { // Size Width with LessThanOrEqual Relation and Priority - greenView + UIView.green() .to([.bottom, .trailing]) .height(100) .width(is: .equal, to: 60, priority: .high) @@ -153,7 +153,7 @@ final class LayoutItemTests: XCTestCase { // Size Width with GreaterThanOrEqual Relation - redView + UIView.red() .to(.centerY, constant: -50) .to(.centerX) .height(100) @@ -162,7 +162,7 @@ final class LayoutItemTests: XCTestCase { // Size Width with LessThanOrEqual Relation - orangeView + UIView.orange() .to(.centerY, constant: 50) .to(.centerX) .height(100) @@ -182,7 +182,7 @@ final class LayoutItemTests: XCTestCase { // Size Width with Default Priority - pinkView + UIView.pink() .to([.top, .leading]) .height(100) .width(100, priority: .high) @@ -190,7 +190,7 @@ final class LayoutItemTests: XCTestCase { // Size Width with Priority - yellowView + UIView.yellow() .to([.top, .trailing]) .height(100) .width(1, priority: .low) @@ -213,7 +213,7 @@ final class LayoutItemTests: XCTestCase { // Size Height with Relation and Default Priority - pinkView + UIView.pink() .to([.top, .leading]) .width(50) .height(is: .greaterThanOrEqual, to: 150, priority: .high) @@ -221,7 +221,7 @@ final class LayoutItemTests: XCTestCase { // Size Height with Relation and Priority - yellowView + UIView.yellow() .to([.top, .trailing]) .width(50) .height(is: .equal, to: 1, priority: .low) @@ -229,7 +229,7 @@ final class LayoutItemTests: XCTestCase { // Size Height with GreaterThanOrEqual Relation - blueView + UIView.blue() .to([.bottom, .leading]) .width(50) .height(is: .equal, to: 75, priority: .high) @@ -237,7 +237,7 @@ final class LayoutItemTests: XCTestCase { // Size Height with LessThanOrEqual Relation - greenView + UIView.green() .to([.bottom, .trailing]) .width(50) .height(is: .equal, to: 125, priority: .high) @@ -245,7 +245,7 @@ final class LayoutItemTests: XCTestCase { // Size Height with GreaterThanOrEqual Relation and Priority - redView + UIView.red() .to([.centerY], constant: -50) .to([.centerX]) .width(50) @@ -254,7 +254,7 @@ final class LayoutItemTests: XCTestCase { // Size Height with LessThanOrEqual Relation and Priority - orangeView + UIView.orange() .to([.centerY], constant: 50) .to([.centerX]) .width(50) @@ -274,7 +274,7 @@ final class LayoutItemTests: XCTestCase { // Size Height with Default Priority - pinkView + UIView.pink() .to([.top, .leading]) .width(100) .height(100, priority: .high) @@ -282,7 +282,7 @@ final class LayoutItemTests: XCTestCase { // Size Height with Priority - yellowView + UIView.yellow() .to([.top, .trailing]) .width(100) .height(1, priority: .low) @@ -301,14 +301,14 @@ final class LayoutItemTests: XCTestCase { // Square Length with Default Priority - pinkView + UIView.pink() .to([.top, .leading]) .square(200, priority: .high) .square(100) // Square Length with Priority - yellowView + UIView.yellow() .to([.top, .trailing]) .square(25, priority: .low) .square(100, priority: .high) @@ -324,14 +324,14 @@ final class LayoutItemTests: XCTestCase { // Square with Width - pinkView + UIView.pink() .to([.top, .leading]) .width(100) .square() // Square with Height - yellowView + UIView.yellow() .to([.top, .trailing]) .height(100) .square() @@ -349,7 +349,7 @@ final class LayoutItemTests: XCTestCase { // Aspect Ratio with Default Priority - pinkView + UIView.pink() .to([.top, .leading]) .height(100) .aspectRatio(0.5, priority: .high) @@ -357,7 +357,7 @@ final class LayoutItemTests: XCTestCase { // Aspect Ratio with Priority - yellowView + UIView.yellow() .to([.top, .trailing]) .height(100) .aspectRatio(0.25, priority: .low) @@ -376,20 +376,20 @@ final class LayoutItemTests: XCTestCase { // Center with Default Offset - pinkView + UIView.pink() .size(width: 50, height: 50) .center(offset: UIOffset(horizontal: 50, vertical: 50), priority: .high) .center() // Center with Offset - yellowView + UIView.yellow() .size(width: 50, height: 50) .center(offset: UIOffset(horizontal: 50, vertical: 50)) // Center with Priority - blueView + UIView.blue() .size(width: 50, height: 50) .center(offset: UIOffset(horizontal: -25, vertical: -25), priority: .low) .center(offset: UIOffset(horizontal: -50, vertical: -50), priority: .high) @@ -405,7 +405,7 @@ final class LayoutItemTests: XCTestCase { // Center with Vertical Axis and Default Multiplier and Priority - pinkView + UIView.pink() .size(width: 100, height: 100) .to(.leading) .center(.vertical, offset: 50, multiplier: 0.5, priority: .high) @@ -413,7 +413,7 @@ final class LayoutItemTests: XCTestCase { // Center with Horizontal Axis and Default Multiplier and Priority - yellowView + UIView.yellow() .size(width: 100, height: 100) .to(.top) .center(.horizontal, offset: 50, multiplier: 0.5, priority: .high) @@ -421,21 +421,21 @@ final class LayoutItemTests: XCTestCase { // Center with Vertical Axis and Offset - blueView + UIView.blue() .size(width: 100, height: 100) .to(.leading) .center(.vertical, offset: 100) // Center with Horizontal Axis and Multiplier - greenView + UIView.green() .size(width: 100, height: 100) .to(.top) .center(.horizontal, multiplier: 1.5) // Center with Vertical Axis and Priority - orangeView + UIView.orange() .size(width: 100, height: 100) .to(.leading) .center(.vertical, offset: -350, priority: .low) @@ -449,7 +449,7 @@ final class LayoutItemTests: XCTestCase { func testCenterBetweenLeadingAndTrailing() { assertLayout(devices: Device.allTestDevices) { view in view.layout( - pinkView + UIView.pink() .size(width: 200, height: 100) .to(.top) .center(between: view.safeAreaLayoutGuide.leading, and: view.safeAreaLayoutGuide.trailing) @@ -463,7 +463,7 @@ final class LayoutItemTests: XCTestCase { assertLayout(devices: Device.allTestDevices) { view in view .layout { - pinkView + UIView.pink() .size(width: 200, height: 100) .to(.leading) .center(between: view.safeAreaLayoutGuide.top, and: view.safeAreaLayoutGuide.bottom) @@ -481,7 +481,7 @@ final class LayoutItemTests: XCTestCase { // To Top Leading with Default Relation, Multiplier and Priority - pinkView + UIView.pink() .size(width: 100, height: 100) .to(.top, is: .greaterThanOrEqual, multiplier: 0.5, constant: 50, priority: .high) .to(.leading, is: .greaterThanOrEqual, multiplier: 0.5, constant: 50, priority: .high) @@ -490,28 +490,28 @@ final class LayoutItemTests: XCTestCase { // To Top Trailing with Constant - yellowView + UIView.yellow() .size(width: 100, height: 100) .to(.top, constant: 25) .to(.trailing, constant: -25) // To Leading Bottom with Bottom Multiplier - blueView + UIView.blue() .size(width: 100, height: 100) .to(.bottom, multiplier: 0.5) .to(.leading) // To Leading Bottom with Bottom Multiplier and Constant - greenView + UIView.green() .size(width: 100, height: 100) .to(.bottom, multiplier: 0.75, constant: 50) .to(.leading) // To Bottom Trailing with Constant and Priority - orangeView + UIView.orange() .size(width: 100, height: 100) .to(.bottom, constant: -100, priority: .low) .to(.bottom, constant: -50, priority: .high) @@ -529,7 +529,7 @@ final class LayoutItemTests: XCTestCase { // To Top Leading with Less Than Or Equal Relation and Constant - pinkView + UIView.pink() .size(width: 100, height: 100) .to(.top, is: .lessThanOrEqual, constant: 100) .to(.top, constant: 150, priority: .high) @@ -537,7 +537,7 @@ final class LayoutItemTests: XCTestCase { // To Top Trailing with Less Than Or Equal Relation and Constant - yellowView + UIView.yellow() .size(width: 100, height: 100) .to(.top, is: .lessThanOrEqual, constant: 100) .to(.top, constant: 50, priority: .high) @@ -545,7 +545,7 @@ final class LayoutItemTests: XCTestCase { // To Top Trailing with Greater Than Or Equal Relation and Constant - blueView + UIView.blue() .size(width: 100, height: 100) .to(.bottom, is: .greaterThanOrEqual, constant: -100) .to(.bottom, constant: -150, priority: .high) @@ -553,7 +553,7 @@ final class LayoutItemTests: XCTestCase { // To Top Trailing with Greater Than Or Equal Relation and Constant - greenView + UIView.green() .size(width: 100, height: 100) .to(.bottom, is: .greaterThanOrEqual, constant: -100) .to(.bottom, constant: -50, priority: .high) @@ -570,20 +570,20 @@ final class LayoutItemTests: XCTestCase { // To Bottom Leading with Default Constant and Priority - pinkView + UIView.pink() .size(width: 100, height: 100) .to([.bottom, .leading], constant: 50, priority: .high) .to([.bottom, .leading]) // To Bottom Trailing with Constant - yellowView + UIView.yellow() .size(width: 100, height: 100) .to([.bottom, .trailing], constant: -100) // To Top Leading with Priority - blueView + UIView.blue() .size(width: 100, height: 100) .to([.top, .leading], constant: 25, priority: .low) .to([.top, .leading], constant: 100, priority: .high) @@ -601,14 +601,14 @@ final class LayoutItemTests: XCTestCase { // To Edges with Insets and Default Priority - pinkView + UIView.pink() .toEdges(insets: NSDirectionalEdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0), priority: .high) .toEdges(insets: NSDirectionalEdgeInsets(top: 0, leading: 5, bottom: 10, trailing: 15)) // To Edges with Insets and Priority - yellowView + UIView.yellow() .toEdges( insets: NSDirectionalEdgeInsets(top: 5, leading: 5, bottom: 5, trailing: 5), priority: .low @@ -629,13 +629,13 @@ final class LayoutItemTests: XCTestCase { // To Edges with Insets and Default Priority - pinkView + UIView.pink() .toEdges(insets: UIEdgeInsets(top: 0, left: 5, bottom: 10, right: 15), priority: .high) .toEdges(insets: UIEdgeInsets(top: 0, left: 5, bottom: 10, right: 15)) // To Edges with Insets and Priority - yellowView + UIView.yellow() .toEdges(insets: UIEdgeInsets(top: 0, left: 5, bottom: 10, right: 15), priority: .low) .toEdges(insets: UIEdgeInsets(top: 50, left: 50, bottom: 50, right: 50), priority: .high) } @@ -650,20 +650,20 @@ final class LayoutItemTests: XCTestCase { // To Edges Top, Leading and Trailing with Default Priority - pinkView + UIView.pink() .height(100) .toEdges([.top, .leading, .trailing], inset: 50, priority: .high) .toEdges([.top, .leading, .trailing]) // To Edges Bottom, Leading and Trailing with Inset - yellowView + UIView.yellow() .height(100) .toEdges([.bottom, .leading, .trailing], inset: 25) // To Edges Leading and Trailing with Vertical Center, Inset and Priority - blueView + UIView.blue() .height(100) .to(.centerY) .toEdges([.leading, .trailing], inset: 25, priority: .low) @@ -680,25 +680,25 @@ final class LayoutItemTests: XCTestCase { // To Edges with Default Edges, Inset and Priority - pinkView + UIView.pink() .toEdges([.top, .leading], inset: 50, priority: .high) .toEdges() // To Edges Top, Left and Right - yellowView + UIView.yellow() .height(100) .toEdges(canonical: [.top, .left, .right]) // To Edges Bottom, Left and Right with Inset - blueView + UIView.blue() .height(100) .toEdges(canonical: [.bottom, .left, .right], inset: 25) // To Edges Left and Right with Vertical Center, Inset and Priority - orangeView + UIView.orange() .height(100) .to(.centerY) .toEdges(canonical: [.left, .right], inset: 25, priority: .low) @@ -715,7 +715,7 @@ final class LayoutItemTests: XCTestCase { // To Side Edges with Default Inset and Priority - pinkView + UIView.pink() .height(100) .to(.top) .toSideEdges(inset: 50, priority: .high) @@ -723,14 +723,14 @@ final class LayoutItemTests: XCTestCase { // To Side Edges with Inset - yellowView + UIView.yellow() .height(100) .to(.centerY) .toSideEdges(inset: 50) // To Side Edges with Inset and Priority - blueView + UIView.blue() .height(100) .to(.bottom) .toSideEdges(inset: 0, priority: .low) @@ -771,14 +771,14 @@ final class LayoutItemTests: XCTestCase { // To Margins with Default Priority - pinkView + UIView.pink() .toMargins(insets: NSDirectionalEdgeInsets(top: 10, leading: 10, bottom: 10, trailing: 10), priority: .high) .toMargins(insets: NSDirectionalEdgeInsets.zero) // To Margins with Insets and Priority - blueView + UIView.blue() .toMargins(insets: NSDirectionalEdgeInsets.zero, priority: .low) .toMargins(insets: NSDirectionalEdgeInsets(top: 20, leading: 30, bottom: 50, trailing: 90), priority: .high) @@ -794,13 +794,13 @@ final class LayoutItemTests: XCTestCase { // To Margins with Default Priority - pinkView + UIView.pink() .toMargins(insets: UIEdgeInsets.zero, priority: .high) .toMargins(insets: UIEdgeInsets(top: 10, left: 20, bottom: 40, right: 80)) // To Margins with Priority - blueView + UIView.blue() .toMargins(insets: UIEdgeInsets.zero, priority: .low) .toMargins(insets: UIEdgeInsets(top: 20, left: 30, bottom: 50, right: 90), priority: .high) } @@ -815,18 +815,18 @@ final class LayoutItemTests: XCTestCase { // To Margins with Default Inset and Priority - pinkView + UIView.pink() .toMargins([.top, .leading, .trailing, .bottom], inset: 50, priority: .high) .toMargins([.top, .leading, .trailing, .bottom]) // To Margins with Inset - blueView + UIView.blue() .toMargins([.top, .leading, .trailing, .bottom], inset: 25) // To Margins with Inset and Priority - orangeView + UIView.orange() .toMargins([.top, .leading, .trailing, .bottom], inset: 0, priority: .low) .toMargins([.top, .leading, .trailing, .bottom], inset: 50, priority: .high) } @@ -841,24 +841,24 @@ final class LayoutItemTests: XCTestCase { // To Margins with Default Inset and Priority - pinkView + UIView.pink() .toMargins(canonical: CanonicalEdge.allCases, inset: 50, priority: .high) .toMargins() // To Margins with Inset - blueView + UIView.blue() .toMargins(inset: 25) // To Margins with Inset and Priority - orangeView + UIView.orange() .toMargins(inset: 0, priority: .low) .toMargins(inset: 50, priority: .high) // To Margins Top Left with Inset - yellowView + UIView.yellow() .size(width: 50, height: 50) .toMargins(canonical: [.top, .left], inset: 75) } @@ -873,7 +873,7 @@ final class LayoutItemTests: XCTestCase { // To Side Margins with Default Inset and Priority - pinkView + UIView.pink() .to(.top) .height(100) .toSideMargins() @@ -881,14 +881,14 @@ final class LayoutItemTests: XCTestCase { // To Side Margins with Inset - blueView + UIView.blue() .center(.vertical) .height(100) .toSideMargins(inset: 20) // To Side Margins with Inset and Priority - orangeView + UIView.orange() .to(.bottom) .height(100) .toSideMargins(inset: 20, priority: .low) @@ -929,14 +929,14 @@ final class LayoutItemTests: XCTestCase { // To Safe Area with Insets and Default Priority - pinkView + UIView.pink() .toSafeArea(insets: NSDirectionalEdgeInsets(top: 5, leading: 5, bottom: 5, trailing: 5), priority: .high) .toSafeArea(insets: NSDirectionalEdgeInsets(top: 0, leading: 5, bottom: 10, trailing: 15)) // To Safe Area with Insets and Priority - yellowView + UIView.yellow() .toSafeArea( insets: NSDirectionalEdgeInsets(top: 5, leading: 5, bottom: 5, trailing: 5), priority: .low @@ -957,13 +957,13 @@ final class LayoutItemTests: XCTestCase { // To Safe Area with Insets and Default Priority - pinkView + UIView.pink() .toSafeArea(insets: UIEdgeInsets(top: 5, left: 5, bottom: 5, right: 5), priority: .high) .toSafeArea(insets: UIEdgeInsets(top: 0, left: 5, bottom: 10, right: 15)) // To Safe Area with Insets and Priority - yellowView + UIView.yellow() .toSafeArea(insets: UIEdgeInsets(top: 5, left: 5, bottom: 5, right: 5), priority: .low) .toSafeArea(insets: UIEdgeInsets(top: 50, left: 50, bottom: 50, right: 50), priority: .high) } @@ -978,13 +978,13 @@ final class LayoutItemTests: XCTestCase { // To Safe Area with Default Priority - pinkView + UIView.pink() .toSafeArea(DirectionalEdge.allCases, inset: 50, priority: .high) .toSafeArea(DirectionalEdge.allCases) // To Safe Area with Inset and Priority - blueView + UIView.blue() .toSafeArea(DirectionalEdge.allCases, inset: 0, priority: .low) .toSafeArea(DirectionalEdge.allCases, inset: 25, priority: .high) } @@ -999,19 +999,19 @@ final class LayoutItemTests: XCTestCase { // To Safe Area with Default Edges, Inset and Priority - pinkView + UIView.pink() .toSafeArea(canonical: [.top, .left], inset: 50, priority: .high) .toSafeArea() // To Safe Area with Inset and Priority - blueView + UIView.blue() .toSafeArea(inset: 0, priority: .low) .toSafeArea(inset: 50, priority: .high) // To Safe Area Top Left Right Bottom with Inset - orangeView + UIView.orange() .toSafeArea(canonical: CanonicalEdge.allCases, inset: 75) } .activate() diff --git a/Tests/LayoutTests/LayoutTests.swift b/Tests/LayoutTests/LayoutTests.swift index 8d99849a..3c11696c 100644 --- a/Tests/LayoutTests/LayoutTests.swift +++ b/Tests/LayoutTests/LayoutTests.swift @@ -277,8 +277,8 @@ final class LayoutTests: XCTestCase { // GIVEN - let pinkView: UIView = pinkView - let yellowView: UIView = yellowView + let pinkView: UIView = .pink() + let yellowView: UIView = .yellow() // THEN @@ -332,8 +332,8 @@ final class LayoutTests: XCTestCase { // GIVEN - let pinkView: UIView = pinkView - let yellowView: UIView = yellowView + let pinkView: UIView = .pink() + let yellowView: UIView = .yellow() // THEN @@ -434,10 +434,10 @@ final class LayoutTests: XCTestCase { // GIVEN - let pinkView: UIView = pinkView - let yellowView: UIView = yellowView - let blueView: UIView = blueView - let greenView: UIView = greenView + let pinkView: UIView = .pink() + let yellowView: UIView = .yellow() + let blueView: UIView = .blue() + let greenView: UIView = .green() // THEN @@ -504,8 +504,8 @@ final class LayoutTests: XCTestCase { // GIVEN - let pinkView: UIView = pinkView - let yellowView: UIView = yellowView + let pinkView: UIView = .pink() + let yellowView: UIView = .yellow() // THEN @@ -550,9 +550,9 @@ final class LayoutTests: XCTestCase { // GIVEN - let blueView: UIView = blueView - let pinkView: UIView = pinkView - let yellowView: UIView = yellowView + let blueView: UIView = .blue() + let pinkView: UIView = .pink() + let yellowView: UIView = .yellow() // THEN @@ -582,8 +582,8 @@ final class LayoutTests: XCTestCase { // GIVEN - let pinkView: UIView = pinkView - let yellowView: UIView = yellowView + let pinkView: UIView = .pink() + let yellowView: UIView = .yellow() // THEN @@ -606,8 +606,8 @@ final class LayoutTests: XCTestCase { // GIVEN - let pinkView: UIView = pinkView - let yellowView: UIView = yellowView + let pinkView: UIView = .pink() + let yellowView: UIView = .yellow() // THEN @@ -632,8 +632,8 @@ final class LayoutTests: XCTestCase { // GIVEN - let pinkView: UIView = pinkView - let yellowView: UIView = yellowView + let pinkView: UIView = .pink() + let yellowView: UIView = .yellow() // THEN @@ -662,8 +662,8 @@ final class LayoutTests: XCTestCase { // GIVEN - let pinkView: UIView = pinkView - let yellowView: UIView = yellowView + let pinkView: UIView = .pink() + let yellowView: UIView = .yellow() // THEN @@ -720,8 +720,8 @@ final class LayoutTests: XCTestCase { // GIVEN - let pinkView: UIView = pinkView - let yellowView: UIView = yellowView + let pinkView: UIView = .pink() + let yellowView: UIView = .yellow() // THEN @@ -745,8 +745,8 @@ final class LayoutTests: XCTestCase { // GIVEN - let pinkView: UIView = pinkView - let yellowView: UIView = yellowView + let pinkView: UIView = .pink() + let yellowView: UIView = .yellow() // THEN @@ -807,8 +807,8 @@ final class LayoutTests: XCTestCase { // GIVEN - let pinkView: UIView = pinkView - let yellowView: UIView = yellowView + let pinkView: UIView = .pink() + let yellowView: UIView = .yellow() // THEN @@ -871,10 +871,10 @@ final class LayoutTests: XCTestCase { // GIVEN - let pinkView: UIView = pinkView - let yellowView: UIView = yellowView - let blueView: UIView = blueView - let greenView: UIView = greenView + let pinkView: UIView = .pink() + let yellowView: UIView = .yellow() + let blueView: UIView = .blue() + let greenView: UIView = .green() // THEN @@ -930,8 +930,8 @@ final class LayoutTests: XCTestCase { // GIVEN - let pinkView: UIView = pinkView - let yellowView: UIView = yellowView + let pinkView: UIView = .pink() + let yellowView: UIView = .yellow() // THEN @@ -999,10 +999,10 @@ final class LayoutTests: XCTestCase { // GIVEN - let pinkView: UIView = pinkView - let yellowView: UIView = yellowView - let blueView: UIView = blueView - let greenView: UIView = greenView + let pinkView: UIView = .pink() + let yellowView: UIView = .yellow() + let blueView: UIView = .blue() + let greenView: UIView = .green() // THEN @@ -1040,8 +1040,8 @@ final class LayoutTests: XCTestCase { // GIVEN - let pinkView: UIView = pinkView - let yellowView: UIView = yellowView + let pinkView: UIView = .pink() + let yellowView: UIView = .yellow() // THEN diff --git a/Tests/LayoutTests/Support/SnapshotTesting.swift b/Tests/LayoutTests/Support/SnapshotTesting.swift index bab97acc..ff095042 100644 --- a/Tests/LayoutTests/Support/SnapshotTesting.swift +++ b/Tests/LayoutTests/Support/SnapshotTesting.swift @@ -18,7 +18,11 @@ extension XCTestCase { private final class ViewController: UIViewController { override func loadView() { - view = View(named: "", with: .white) + view = { + let view: View = .init() + view.backgroundColor = .white + return view + }() } } diff --git a/Tests/LayoutTests/Support/View.swift b/Tests/LayoutTests/Support/View.swift index c43777c6..be6e7f53 100644 --- a/Tests/LayoutTests/Support/View.swift +++ b/Tests/LayoutTests/Support/View.swift @@ -27,90 +27,56 @@ internal final class View: UIView { } fatalError("iOS 15+ required for unit tests.") } - - internal convenience init(named name: String, with color: UIColor) { - self.init() - accessibilityIdentifier = name - backgroundColor = color - } -} - -@MainActor -internal var pinkView: UIView { - View(named: "Pink", with: UIColor(red: 1, green: 0.176471, blue: 0.333333, alpha: 1)) -} - -@MainActor -internal var blackView: UIView { - View(named: "Black", with: .black) -} - -@MainActor -internal var darkGrayView: UIView { - View(named: "DarkGray", with: .darkGray) -} - -@MainActor -internal var lightGrayView: UIView { - View(named: "LightGray", with: .lightGray) -} - -@MainActor -internal var whiteView: UIView { - View(named: "White", with: .white) -} - -@MainActor -internal var grayView: UIView { - View(named: "Gray", with: .gray) -} - -@MainActor -internal var redView: UIView { - View(named: "Red", with: .red) } -@MainActor -internal var greenView: UIView { - View(named: "Green", with: .green) -} - -@MainActor -internal var blueView: UIView { - View(named: "Blue", with: .blue) -} +extension UIView { -@MainActor -internal var cyanView: UIView { - View(named: "Cyan", with: .cyan) -} + internal static func pink() -> UIView { + let view: View = .init() + view.accessibilityIdentifier = "Pink" + view.backgroundColor = UIColor(red: 1, green: 0.176471, blue: 0.333333, alpha: 1) + return view + } -@MainActor -internal var yellowView: UIView { - View(named: "Yellow", with: .yellow) -} + internal static func white() -> UIView { + let view: View = .init() + view.accessibilityIdentifier = "White" + view.backgroundColor = .white + return view + } -@MainActor -internal var magentaView: UIView { - View(named: "Magenta", with: .magenta) -} + internal static func red() -> UIView { + let view: View = .init() + view.accessibilityIdentifier = "Red" + view.backgroundColor = .red + return view + } -@MainActor -internal var orangeView: UIView { - View(named: "Orange", with: .orange) -} + internal static func green() -> UIView { + let view: View = .init() + view.accessibilityIdentifier = "Green" + view.backgroundColor = .green + return view + } -@MainActor -internal var purpleView: UIView { - View(named: "Purple", with: .purple) -} + internal static func blue() -> UIView { + let view: View = .init() + view.accessibilityIdentifier = "Blue" + view.backgroundColor = .blue + return view + } -@MainActor -internal var brownView: UIView { - View(named: "Brown", with: .brown) -} + internal static func yellow() -> UIView { + let view: View = .init() + view.accessibilityIdentifier = "Yellow" + view.backgroundColor = .yellow + return view + } -@MainActor -internal var clearView: UIView { - View(named: "Clear", with: .clear) + internal static func orange() -> UIView { + let view: View = .init() + view.accessibilityIdentifier = "Orange" + view.backgroundColor = .orange + return view + } } diff --git a/Tests/LayoutTests/UIKit/NSLayoutConstraintTests.swift b/Tests/LayoutTests/UIKit/NSLayoutConstraintTests.swift index afd4872a..42e2a7a4 100644 --- a/Tests/LayoutTests/UIKit/NSLayoutConstraintTests.swift +++ b/Tests/LayoutTests/UIKit/NSLayoutConstraintTests.swift @@ -20,7 +20,7 @@ final class NSLayoutConstraintTests: XCTestCase { // GIVEN - let subview: UIView = pinkView + let subview: UIView = .pink() let formats: [String] = ["H:|-leftMargin-[subview(width)]", "V:|-topMargin-[subview(height)]"] let views: [String: Any] = ["subview": subview] let metrics: [String: Any] = [ @@ -50,7 +50,7 @@ final class NSLayoutConstraintTests: XCTestCase { // GIVEN - let subview: UIView = pinkView + let subview: UIView = .pink() let formats: [String] = ["H:|-leftMargin-[subview(width)]", "V:|-topMargin-[subview(height)]"] let views: [String: Any] = ["subview": subview] let metrics: [String: Any] = [